Tk Source Code

Changes On Branch tip-517
Login
Bounty program for improvements to Tcl and certain Tcl packages.

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

Changes In Branch bug-43b596451e Excluding Merge-Ins

This is equivalent to a diff from 28b52309 to 9cd6fd0b

2018-09-23
12:56
Merge TIP #517 (Add -activerelief Configuration Option to the menu Widget) implementation following positive vote by the TCT. check-in: a9556bcb user: fvogel tags: trunk
12:41
Add tests checking the new option -activerelief Closed-Leaf check-in: 9cd6fd0b user: fvogel tags: tip-517, bug-43b596451e
08:22
Merge trunk check-in: 1ab46e2b user: oehhar tags: tip518-event-last-child-unmanaged
2018-09-12
21:07
Add documentation for -activerelief check-in: d110699e user: fvogel tags: tip-517, bug-43b596451e
2018-09-09
08:01
Alternate fix for [43b596451e]: relief for active menu entries. If tk_strictMotif is not set, render the menu active item with flat relief. If tk_strictMotif is set, render the menu active item with raised relief. Closed-Leaf check-in: bcb0b981 user: fvogel tags: bug-43b596451e-alt, tip-517-alt
2018-09-08
22:15
Proof of concept for fixing [43b596451e]: relief for active menu entries. Add a -activerelief option to menues. Works on Linux only so far. check-in: f7d48119 user: fvogel tags: tip-517, bug-43b596451e
17:08
Fix [6fcaaa6f80]: ttk::entry insertion cursor not visible. Patch from Csaba Nemethi. check-in: 28b52309 user: fvogel tags: trunk
17:08
Fix [6fcaaa6f80]: ttk::entry insertion cursor not visible. Patch from Csaba Nemethi. check-in: 4c6cdfa4 user: fvogel tags: core-8-6-branch
17:03
Fix [382712ade6] (X11: 'event generate . <KeyPress>' segfaults) again with a different fix. Patch from Christian Werner. check-in: 93ca7e58 user: fvogel tags: trunk

Changes to doc/menu.n.

    15     15   .nf
    16     16   \fBmenu\fR \fIpathName \fR?\fIoptions\fR?
    17     17   \fBtk_menuSetFocus\fR \fIpathName\fR
    18     18   .SO
    19     19   \-activebackground	\-borderwidth	\-foreground
    20     20   \-activeborderwidth	\-cursor	\-relief
    21     21   \-activeforeground	\-disabledforeground	\-takefocus
    22         -\-background	\-font
           22  +\-background	\-font	\-activerelief
    23     23   .SE
    24     24   .SH "WIDGET-SPECIFIC OPTIONS"
    25     25   .OP \-postcommand postCommand Command
    26     26   If this option is specified then it provides a Tcl command to execute
    27     27   each time the menu is posted.  The command is invoked by the \fBpost\fR
    28     28   widget command before posting the menu. Note that in Tk 8.0 on Macintosh
    29     29   and Windows, all post-commands in a system of menus are executed before any

Changes to doc/options.n.

    54     54   definition of active elements.
    55     55   The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
    56     56   This option is typically only available in widgets displaying more
    57     57   than one element at a time (e.g. menus but not buttons).
    58     58   .OP \-activeforeground activeForeground Background
    59     59   Specifies foreground color to use when drawing active elements.
    60     60   See above for definition of active elements.
           61  +.OP \-activerelief activeRelief Relief
           62  +Specifies the 3-D effect desired for the active item of the widget.
           63  +See the \fB-relief\fR option for details.
    61     64   .OP \-anchor anchor Anchor
    62     65   Specifies how the information in a widget (e.g. text or a bitmap)
    63     66   is to be displayed in the widget.
    64     67   Must be one of the values \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR,
    65     68   \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR.
    66     69   For example, \fBnw\fR means display the information such that its
    67     70   top-left corner is at the top-left corner of the widget.

Changes to generic/tkMenu.c.

   255    255       {TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth",
   256    256   	"BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH,
   257    257   	Tk_Offset(TkMenu, activeBorderWidthPtr), -1, 0, NULL, 0},
   258    258       {TK_OPTION_COLOR, "-activeforeground", "activeForeground",
   259    259   	"Background", DEF_MENU_ACTIVE_FG_COLOR,
   260    260   	Tk_Offset(TkMenu, activeFgPtr), -1, 0,
   261    261   	(ClientData) DEF_MENU_ACTIVE_FG_MONO, 0},
          262  +    {TK_OPTION_RELIEF, "-activerelief", "activeRelief", "Relief",
          263  +	DEF_MENU_ACTIVE_RELIEF, Tk_Offset(TkMenu, activeReliefPtr),
          264  +	-1, 0, NULL, 0},
   262    265       {TK_OPTION_BORDER, "-background", "background", "Background",
   263    266   	DEF_MENU_BG_COLOR, Tk_Offset(TkMenu, borderPtr), -1, 0,
   264    267   	(ClientData) DEF_MENU_BG_MONO, 0},
   265    268       {TK_OPTION_SYNONYM, "-bd", NULL, NULL,
   266    269   	NULL, 0, -1, 0, "-borderwidth", 0},
   267    270       {TK_OPTION_SYNONYM, "-bg", NULL, NULL,
   268    271   	NULL, 0, -1, 0, "-background", 0},

Changes to generic/tkMenu.h.

   293    293   				 * background for menu. */
   294    294       Tcl_Obj *borderWidthPtr;	/* Width of border around whole menu. */
   295    295       Tcl_Obj *activeBorderPtr;	/* Used to draw background and border for
   296    296   				 * active element (if any). */
   297    297       Tcl_Obj *activeBorderWidthPtr;
   298    298   				/* Width of border around active element. */
   299    299       Tcl_Obj *reliefPtr;		/* 3-d effect: TK_RELIEF_RAISED, etc. */
          300  +    Tcl_Obj *activeReliefPtr;	/* 3-d effect for active element. */
   300    301       Tcl_Obj *fontPtr;		/* Text font for menu entries. */
   301    302       Tcl_Obj *fgPtr;		/* Foreground color for entries. */
   302    303       Tcl_Obj *disabledFgPtr;	/* Foreground color when disabled. NULL means
   303    304   				 * use normalFg with a 50% stipple instead. */
   304    305       Tcl_Obj *activeFgPtr;	/* Foreground color for active entry. */
   305    306       Tcl_Obj *indicatorFgPtr;	/* Color for indicators in radio and check
   306    307   				 * button entries. */

Changes to macosx/tkMacOSXDefault.h.

   310    310    */
   311    311   
   312    312   #define DEF_MENU_ACTIVE_BG_COLOR	"systemMenuActive"
   313    313   #define DEF_MENU_ACTIVE_BG_MONO		BLACK
   314    314   #define DEF_MENU_ACTIVE_BORDER_WIDTH	"0"
   315    315   #define DEF_MENU_ACTIVE_FG_COLOR	"systemMenuActiveText"
   316    316   #define DEF_MENU_ACTIVE_FG_MONO		WHITE
          317  +#define DEF_MENU_ACTIVE_RELIEF		"flat"
   317    318   #define DEF_MENU_BG_COLOR		"systemMenu"
   318    319   #define DEF_MENU_BG_MONO		WHITE
   319    320   #define DEF_MENU_BORDER_WIDTH		"0"
   320    321   #define DEF_MENU_CURSOR			"arrow"
   321    322   #define DEF_MENU_DISABLED_FG_COLOR	"systemMenuDisabled"
   322    323   #define DEF_MENU_DISABLED_FG_MONO	""
   323    324   #define DEF_MENU_FONT			"menu" /* special: see tkMacOSXMenu.c */

Changes to tests/menu.test.

   171    171       .m1 configure -activeforeground #ff0000
   172    172       .m1 cget -activeforeground
   173    173   } -result {#ff0000}
   174    174   test menu-2.6 {configuration options -activeforeground non-existent} -body {
   175    175       .m1 configure -activeforeground non-existent
   176    176   } -returnCodes error -result {unknown color name "non-existent"}
   177    177   
          178  +test menu-2.6a {configuration options -activerelief sunken} -body {
          179  +    .m1 configure -activerelief sunken
          180  +    .m1 cget -activerelief
          181  +} -result {sunken}
          182  +test menu-2.6b {configuration options -activerelief badValue} -body {
          183  +    .m1 configure -activerelief badValue
          184  +} -returnCodes error -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
          185  +
   178    186   test menu-2.7 {configuration options -background #ff0000} -body {
   179    187       .m1 configure -background #ff0000
   180    188       .m1 cget -background
   181    189   } -result {#ff0000}
   182    190   test menu-2.8 {configuration options -background non-existent} -body {
   183    191       .m1 configure -background non-existent
   184    192   } -returnCodes error -result {unknown color name "non-existent"}
................................................................................
  1355   1363   test menu-3.18 {MenuWidgetCmd procedure, "configure" option} -setup {
  1356   1364   	destroy .m1
  1357   1365   } -body {
  1358   1366       menu .m1
  1359   1367       llength [.m1 configure]
  1360   1368   } -cleanup {
  1361   1369   	destroy .m1
  1362         -} -result {20}
         1370  +} -result {21}
  1363   1371   test menu-3.19 {MenuWidgetCmd procedure, "configure" option} -setup {
  1364   1372   	destroy .m1
  1365   1373   } -body {
  1366   1374       menu .m1
  1367   1375       .m1 configure -gorp
  1368   1376   } -returnCodes error -result {unknown option "-gorp"}
  1369   1377   test menu-3.20 {MenuWidgetCmd procedure, "configure" option} -setup {

Changes to unix/tkUnixDefault.h.

   272    272    */
   273    273   
   274    274   #define DEF_MENU_ACTIVE_BG_COLOR	ACTIVE_BG
   275    275   #define DEF_MENU_ACTIVE_BG_MONO		BLACK
   276    276   #define DEF_MENU_ACTIVE_BORDER_WIDTH	"1"
   277    277   #define DEF_MENU_ACTIVE_FG_COLOR	BLACK
   278    278   #define DEF_MENU_ACTIVE_FG_MONO		WHITE
          279  +#define DEF_MENU_ACTIVE_RELIEF		"raised"
   279    280   #define DEF_MENU_BG_COLOR		NORMAL_BG
   280    281   #define DEF_MENU_BG_MONO		WHITE
   281    282   #define DEF_MENU_BORDER_WIDTH		"1"
   282    283   #define DEF_MENU_CURSOR			"arrow"
   283    284   #define DEF_MENU_DISABLED_FG_COLOR	DISABLED
   284    285   #define DEF_MENU_DISABLED_FG_MONO	""
   285    286   #define DEF_MENU_FONT			"TkMenuFont"

Changes to unix/tkUnixMenu.c.

   439    439       	bgBorder = activeBorder;
   440    440   
   441    441   	if ((menuPtr->menuType == MENUBAR)
   442    442   		&& ((menuPtr->postedCascade == NULL)
   443    443   		|| (menuPtr->postedCascade != mePtr))) {
   444    444   	    relief = TK_RELIEF_FLAT;
   445    445   	} else {
   446         -	    relief = TK_RELIEF_RAISED;
          446  +	    Tk_GetReliefFromObj(NULL, menuPtr->activeReliefPtr, &relief);
   447    447   	}
   448         -
   449    448   	Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
   450    449   		menuPtr->activeBorderWidthPtr, &activeBorderWidth);
   451    450   	Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height,
   452    451   		activeBorderWidth, relief);
   453    452       } else {
   454    453   	Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height,
   455    454   		0, TK_RELIEF_FLAT);

Changes to win/tkWinDefault.h.

   275    275    */
   276    276   
   277    277   #define DEF_MENU_ACTIVE_BG_COLOR	SELECT_BG
   278    278   #define DEF_MENU_ACTIVE_BG_MONO		BLACK
   279    279   #define DEF_MENU_ACTIVE_BORDER_WIDTH	"0"
   280    280   #define DEF_MENU_ACTIVE_FG_COLOR	SELECT_FG
   281    281   #define DEF_MENU_ACTIVE_FG_MONO		WHITE
          282  +#define DEF_MENU_ACTIVE_RELIEF		"flat"
   282    283   #define DEF_MENU_BG_COLOR		MENU_BG
   283    284   #define DEF_MENU_BG_MONO		WHITE
   284    285   #define DEF_MENU_BORDER_WIDTH		"0"
   285    286   #define DEF_MENU_CURSOR			"arrow"
   286    287   #define DEF_MENU_DISABLED_FG_COLOR	DISABLED
   287    288   #define DEF_MENU_DISABLED_FG_MONO	""
   288    289   #define DEF_MENU_FONT			"TkMenuFont"

Changes to win/tkWinMenu.c.

  2786   2786       int x,			/* left edge */
  2787   2787       int y,			/* top edge */
  2788   2788       int width,			/* width of rectangle to draw */
  2789   2789       int height)			/* height of rectangle to draw */
  2790   2790   {
  2791   2791       if (mePtr->state == ENTRY_ACTIVE
  2792   2792   		|| (mePtr->entryFlags & ENTRY_PLATFORM_FLAG1)!=0 ) {
         2793  +	int relief;
         2794  +	int activeBorderWidth;
         2795  +
  2793   2796   	bgBorder = activeBorder;
         2797  +
         2798  +	if ((menuPtr->menuType == MENUBAR)
         2799  +		&& ((menuPtr->postedCascade == NULL)
         2800  +		|| (menuPtr->postedCascade != mePtr))) {
         2801  +	    relief = TK_RELIEF_FLAT;
         2802  +	} else {
         2803  +	    Tk_GetReliefFromObj(NULL, menuPtr->activeReliefPtr, &relief);
         2804  +	}
         2805  +	Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
         2806  +		menuPtr->activeBorderWidthPtr, &activeBorderWidth);
         2807  +	Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height,
         2808  +		activeBorderWidth, relief);
         2809  +    } else {
         2810  +        Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, 0,
         2811  +                TK_RELIEF_FLAT);
  2794   2812       }
  2795         -    Tk_Fill3DRectangle(menuPtr->tkwin, d, bgBorder, x, y, width, height, 0,
  2796         -	    TK_RELIEF_FLAT);
  2797   2813   }
  2798   2814   
  2799   2815   /*
  2800   2816    *--------------------------------------------------------------
  2801   2817    *
  2802   2818    * TkpComputeStandardMenuGeometry --
  2803   2819    *