Tk Source Code

Check-in [ec385b79]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:formatting, unnecessary if's
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ec385b79fd8c967018000a88d8ba2e7dea0550cc
User & Date: jan.nijtmans 2012-08-09 08:22:44
Context
2012-08-09
10:23
it's no longer necessary to set _USE_32BIT_TIME_T in Tk check-in: be5939e3 user: jan.nijtmans tags: trunk
10:19
too many things checked in.... not intentional. Closed-Leaf check-in: c5c2bb89 user: jan.nijtmans tags: mistake
08:22
formatting, unnecessary if's check-in: ec385b79 user: jan.nijtmans tags: trunk
07:25
partly backport from 8.6 check-in: c2823d74 user: jan.nijtmans tags: core-8-5-branch
2012-08-07
21:49
Fix regression in cutting/pasting text; thanks to Adrian Robert for patch check-in: e9db775b user: kevin_walzer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/ttk/ttkLabel.c.

347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
     * Do not stipple at all under Aqua, just draw the image: it shows up 
     * as a white rectangle otherwise.
     */

    
    if (state & TTK_STATE_DISABLED) {
	if (TtkSelectImage(image->imageSpec, 0ul) == image->tkimg) {
	 #ifndef MAC_OSX_TK
	    StippleOver(image, tkwin, d, b.x,b.y);
	  #endif
	}
    }
}

static void ImageElementSize(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)







|

|







347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
     * Do not stipple at all under Aqua, just draw the image: it shows up 
     * as a white rectangle otherwise.
     */

    
    if (state & TTK_STATE_DISABLED) {
	if (TtkSelectImage(image->imageSpec, 0ul) == image->tkimg) {
#ifndef MAC_OSX_TK
	    StippleOver(image, tkwin, d, b.x,b.y);
#endif
	}
    }
}

static void ImageElementSize(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)

Changes to library/demos/toolbar.tcl.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
set w .toolbar
destroy $w
toplevel $w
wm title $w "Toolbar Demonstration"
wm iconname $w "toolbar"
positionWindow $w

if {[tk windowingsystem] ne {}} {
    ttk::label $w.msg -wraplength 4i -text "This is a demonstration of how to do\
	    a toolbar that is styled correctly and which can be torn off. The\
	    buttons are configured to be \u201Ctoolbar style\u201D buttons by\
	    telling them that they are to use the Toolbutton style. At the left\
	    end of the toolbar is a simple marker that the cursor changes to a\
	    movement icon over; drag that away from the toolbar to tear off the\
	    whole toolbar into a separate toplevel widget. When the dragged-off\
	    toolbar is no longer needed, just close it like any normal toplevel\
	    and it will reattach to the window it was torn off from."
} else {
ttk::label $w.msg -wraplength 4i -text "This is a demonstration of how to do\
	    a toolbar that is styled correctly. The buttons are configured to\
	    be \u201Ctoolbar style\u201D buttons by telling them that they are\
	    to use the Toolbutton style."
}

## Set up the toolbar hull
set t [frame $w.toolbar]		;# Must be a frame!
ttk::separator $w.sep
ttk::frame $t.tearoff -cursor fleur
if {[tk windowingsystem] ne {}} {
    ttk::separator $t.tearoff.to -orient vertical
    ttk::separator $t.tearoff.to2 -orient vertical
    pack $t.tearoff.to -fill y -expand 1 -padx 2 -side left
    pack $t.tearoff.to2 -fill y -expand 1 -side left
}
ttk::frame $t.contents
grid $t.tearoff $t.contents -sticky nsew
grid columnconfigure $t $t.contents -weight 1
grid columnconfigure $t.contents 1000 -weight 1

if {[tk windowingsystem] ne {}} {
    ## Bindings so that the toolbar can be torn off and reattached
    bind $t.tearoff     <B1-Motion> [list tearoff $t %X %Y]
    bind $t.tearoff.to  <B1-Motion> [list tearoff $t %X %Y]
    bind $t.tearoff.to2 <B1-Motion> [list tearoff $t %X %Y]
    proc tearoff {w x y} {
	if {[string match $w* [winfo containing $x $y]]} {
	    return
	}
	grid remove $w
	grid remove $w.tearoff
	wm manage $w
	wm protocol $w WM_DELETE_WINDOW [list untearoff $w]
    }
    proc untearoff {w} {
	wm forget $w
	grid $w.tearoff
	grid $w
    }
}

## Toolbar contents
ttk::button $t.button -text "Button" -style Toolbutton -command [list \
	$w.txt insert end "Button Pressed\n"]
ttk::checkbutton $t.check -text "Check" -variable check -style Toolbutton \
	-command [concat [list $w.txt insert end] {"check is $check\n"}]







<
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<





<
|
|
|
|
<





<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<







11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26






27
28
29
30
31

32
33
34
35

36
37
38
39
40

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
set w .toolbar
destroy $w
toplevel $w
wm title $w "Toolbar Demonstration"
wm iconname $w "toolbar"
positionWindow $w


ttk::label $w.msg -wraplength 4i -text "This is a demonstration of how to do\
	a toolbar that is styled correctly and which can be torn off. The\
	buttons are configured to be \u201Ctoolbar style\u201D buttons by\
	telling them that they are to use the Toolbutton style. At the left\
	end of the toolbar is a simple marker that the cursor changes to a\
	movement icon over; drag that away from the toolbar to tear off the\
	whole toolbar into a separate toplevel widget. When the dragged-off\
	toolbar is no longer needed, just close it like any normal toplevel\
	and it will reattach to the window it was torn off from."







## Set up the toolbar hull
set t [frame $w.toolbar]		;# Must be a frame!
ttk::separator $w.sep
ttk::frame $t.tearoff -cursor fleur

ttk::separator $t.tearoff.to -orient vertical
ttk::separator $t.tearoff.to2 -orient vertical
pack $t.tearoff.to -fill y -expand 1 -padx 2 -side left
pack $t.tearoff.to2 -fill y -expand 1 -side left

ttk::frame $t.contents
grid $t.tearoff $t.contents -sticky nsew
grid columnconfigure $t $t.contents -weight 1
grid columnconfigure $t.contents 1000 -weight 1


## Bindings so that the toolbar can be torn off and reattached
bind $t.tearoff     <B1-Motion> [list tearoff $t %X %Y]
bind $t.tearoff.to  <B1-Motion> [list tearoff $t %X %Y]
bind $t.tearoff.to2 <B1-Motion> [list tearoff $t %X %Y]
proc tearoff {w x y} {
    if {[string match $w* [winfo containing $x $y]]} {
	return
    }
    grid remove $w
    grid remove $w.tearoff
    wm manage $w
    wm protocol $w WM_DELETE_WINDOW [list untearoff $w]
}
proc untearoff {w} {
    wm forget $w
    grid $w.tearoff
    grid $w

}

## Toolbar contents
ttk::button $t.button -text "Button" -style Toolbutton -command [list \
	$w.txt insert end "Button Pressed\n"]
ttk::checkbutton $t.check -text "Check" -variable check -style Toolbutton \
	-command [concat [list $w.txt insert end] {"check is $check\n"}]