Overview
| Artifact ID: | 3a6159b8545502c0c02e0398586b410a417e7154 |
|---|---|
| Ticket: | 1977644fffffffffffffffffffffffffffffffff |
| Date: | 2008-05-29 18:09:59 |
| User: | cmard |
| Artifact Attached: | 28409b148d35e8c4e40373a287bf77970b2c3cfe |
| Filename: | patch-mainframe1.23-casesensitive.txt |
| Description: | Patch for source code and documentation |
Content:
1 2 3 4 5 6 7 8 9 10 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285Index: mainframe.tcl =================================================================== --- mainframe.tcl (revision 5) +++ mainframe.tcl (working copy) @@ -38,13 +38,14 @@ } Widget::declare MainFrame { - {-width TkResource 0 0 frame} - {-height TkResource 0 0 frame} - {-background TkResource "" 0 frame} - {-textvariable String "" 0} - {-menu String {} 1} - {-separator Enum both 1 {none top bottom both}} - {-bg Synonym -background} + {-width TkResource 0 0 frame} + {-height TkResource 0 0 frame} + {-background TkResource "" 0 frame} + {-textvariable String "" 0} + {-casesensitive Boolean 0 0} + {-menu String {} 1} + {-separator Enum both 1 {none top bottom both}} + {-bg Synonym -background} {-menubarfont String "" 0} {-menuentryfont String "" 0} @@ -176,7 +177,7 @@ set menu [Widget::getoption $path -menu] if { [llength $menu] } { - _create_menubar $path $menu + _create_menubar $path $menu [Widget::getoption $path -casesensitive] } bind $path <Destroy> [list MainFrame::_destroy %W] @@ -503,7 +504,7 @@ # ---------------------------------------------------------------------------- # Command MainFrame::_create_menubar # ---------------------------------------------------------------------------- -proc MainFrame::_create_menubar { path descmenu } { +proc MainFrame::_create_menubar { path descmenu casesensitive } { variable _widget global tcl_platform @@ -554,7 +555,7 @@ # menu has identifier set _widget($path,menuid,$menuid) $menu } - _create_entries $path $menu $menuopts $entries + _create_entries $path $menu $menuopts $entries $casesensitive incr count } } @@ -563,7 +564,7 @@ # ---------------------------------------------------------------------------- # Command MainFrame::_create_entries # ---------------------------------------------------------------------------- -proc MainFrame::_create_entries { path menu menuopts entries } { +proc MainFrame::_create_entries { path menu menuopts entries casesensitive } { variable _widget set count [$menu cget -tearoff] @@ -601,7 +602,7 @@ # menu has identifier set _widget($path,menuid,$menuid) $submenu } - _create_entries $path $submenu $menuopts [lindex $entry 5] + _create_entries $path $submenu $menuopts [lindex $entry 5] $casesensitive incr count continue } @@ -617,7 +618,7 @@ } # entry accelerator - set accel [_parse_accelerator [lindex $entry 4]] + set accel [_parse_accelerator [lindex $entry 4] $casesensitive] if { [llength $accel] } { lappend opt -accelerator [lindex $accel 0] bind $_widget($path,top) [lindex $accel 1] [list $menu invoke $count] @@ -668,40 +669,47 @@ # Results: # {accel event} a list containing the accelerator string and the event -proc MainFrame::_parse_accelerator { desc } { +proc MainFrame::_parse_accelerator { desc casesensitive } { if { [llength $desc] == 1 } { set seq None - set key [string tolower [lindex $desc 0]] + set key [lindex $desc 0] # If the key is an F key (ie, F1, F2, etc), it has to be capitalized - if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} $key]} { + if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} [string tolower $key]]} { set key [string toupper $key] } } elseif { [llength $desc] == 2 } { set seq [lindex $desc 0] - set key [string tolower [lindex $desc 1]] + set key [lindex $desc 1] # If the key is an F key (ie, F1, F2, etc), it has to be capitalized - if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} $key]} { + if {[regexp {^f([1-9]|([12][0-9]|3[0-5]))$} [string tolower $key]]} { set key [string toupper $key] } } else { return {} } + if {! $casesensitive} { + set akey [string toupper $key] + set ekey [string tolower $key] + } else { + set akey $key + set ekey $key + } switch -- $seq { None { - set accel "[string toupper $key]" - set event "<Key-$key>" + set accel $akey + set event "<Key-$ekey>" } Ctrl { - set accel "Ctrl+[string toupper $key]" - set event "<Control-Key-$key>" + set accel "Ctrl+$akey" + set event "<Control-Key-$ekey>" } Alt { - set accel "Alt+[string toupper $key]" - set event "<Alt-Key-$key>" + set accel "Alt+$akey" + set event "<Alt-Key-$ekey>" } CtrlAlt { - set accel "Ctrl+Alt+[string toupper $key]" - set event "<Control-Alt-Key-$key>" + set accel "Ctrl+Alt+$akey" + set event "<Control-Alt-Key-$ekey>" } default { return -code error "invalid accelerator code $seq" Index: BWman/MainFrame.html =================================================================== --- BWman/MainFrame.html (revision 5) +++ BWman/MainFrame.html (working copy) @@ -3,7 +3,7 @@ <BODY BGCOLOR=white> <DL><DT><I><A HREF="#descr">NAME</A></I></DT> <DD><B>MainFrame</B> - - Manage toplevel with menu, toolbar and statusbar + - Manage toplevel with menu, toolbar and statusbar </DD></DL> <DL> <DT><I>CREATION</I></DT> @@ -22,21 +22,26 @@ </TR> <TR> <TD> -progressvar (see <B>-variable</B>)</TD> +</TR> </TABLE></DD> </DL> <DL> <DT><I><A HREF="#wso">WIDGET-SPECIFIC OPTIONS</A></I></DT> <DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0> <TR> -<TD> <A HREF="#-height">-height</A></TR> -<TD> <A HREF="#-menu">-menu</A></TR> +<TD> <A HREF="#-casesensitive">-casesensitive</A></TD></TR> +<TR> +<TD> <A HREF="#-height">-height</A></TD></TR> +<TR> +<TD> <A HREF="#-menu">-menu</A></TD> </TR> <TR> -<TD> <A HREF="#-separator">-separator</A></TR> -<TD> <A HREF="#-textvariable">-textvariable</A></TR> +<TD> <A HREF="#-separator">-separator</A></TD></TR> +<TR> +<TD> <A HREF="#-textvariable">-textvariable</A></TD> </TR> <TR> -<TD> <A HREF="#-width">-width</A></TR> +<TD> <A HREF="#-width">-width</A></TD></TR> </TABLE></DD> </DL> <DL> @@ -82,14 +87,36 @@ MainFrame manage toplevel to have:<BR> <UL> <LI>simple menu creation, with automatic accelerator bindings and -<A HREF="DynamicHelp.html">DynamicHelp</A> association, -<LI>one or more toolbars that user can hide, -<LI>a status bar, displaying a user message or a menu description, and optionally a -<A HREF="ProgressBar.html">ProgressBar</A>. +<A HREF="DynamicHelp.html">DynamicHelp</A> association,</LI> +<LI>one or more toolbars that user can hide,</LI> +<LI>a status bar, displaying a user message or a menu description, and optionally a +<A HREF="ProgressBar.html">ProgressBar</A>.</LI> </UL> </P> <BR><HR WIDTH="50%"><BR> <B><A NAME="wso">WIDGET-SPECIFIC OPTIONS</A></B><BR> + +<DL><DT><A NAME="-casesensitive"><B>-casesensitive</B></A></DT> +<DD> +Controlls the interpretation of <I>accelerator</I> definition by the <B>-menu</B> +option. If this option is <B>false</B> or not given, the accelerator binding is done +for lowercase letters (no Shift Key pressed) and the accelerator text of the menu entry +is shown in uppercase letters. If it is set to <B>true</B> the accelerator binding +and the menu entry is done as given. +<P> +Example:<BR> +Both accelerators are identically if <B>-casesensitive</B> is specified as false. See +<A HREF="#-menu">-menu</A> for the syntax of the menu discription list. +</P> +<PRE> +... +{command "&Save" {} {Save the document} {<B>Ctrl s</B>} -command Menu::save} +{command "&Save As" {} {Save with different name} {<B>Ctrl S</B>} -command Menu::saveAs} +... +</PRE> +</DD> +</DL> + <DL><DT><A NAME="-height"><B>-height</B></A></DT> <DD> @@ -107,33 +134,35 @@ where <I>menuentries</I> is a list where each element describe one menu entry, which can be: <UL> <LI>for a separator:<BR> - {<B>separator</B>} + {<B>separator</B>}</LI> <LI>for a command:<BR> - {<B>command</B> <I>menuname</I> ?<I>tags</I>? ?<I>description</I>? ?<I>accelerator</I>? ?<I>option</I> <I>value</I>? ...} + {<B>command</B> <I>menuname</I> ?<I>tags</I>? ?<I>description</I>? ?<I>accelerator</I>? ?<I>option</I> <I>value</I>? ...}</LI> <LI>for a check button:<BR> - {<B>checkbutton</B> <I>menuname</I> ?<I>tags</I>? ?<I>description</I>? ?<I>accelerator</I>? ?<I>option</I> <I>value</I>? ...} + {<B>checkbutton</B> <I>menuname</I> ?<I>tags</I>? ?<I>description</I>? ?<I>accelerator</I>? ?<I>option</I> <I>value</I>? ...}</LI> <LI>for a radio button:<BR> - {<B>radiobutton</B> <I>menuname</I> ?<I>tags</I>? ?<I>description</I>? ?<I>accelerator</I> ?<I>option</I> <I>value</I>? ...} + {<B>radiobutton</B> <I>menuname</I> ?<I>tags</I>? ?<I>description</I>? ?<I>accelerator</I> ?<I>option</I> <I>value</I>? ...}</LI> <LI>for a cascade menu:<BR> - {<B>cascade</B> <I>menuname</I> <I>tags</I> <I>menuId</I> <I>tearoff</I> <I>menuentries</I>} + {<B>cascade</B> <I>menuname</I> <I>tags</I> <I>menuId</I> <I>tearoff</I> <I>menuentries</I>}</LI> </UL> where: <UL> <LI><I>menuname</I> is the name of the menu. If it contains a &, the following character is automatically converted to the corresponding <B>-underline</B> option of <B>menu add</B> -command. +command.</LI> <LI><I>tags</I> is the tags list for the entry, used for enabling or disabling menu -entries with <B>MainFrame::setmenustate</B>. +entries with <B>MainFrame::setmenustate</B>.</LI> <LI><I>menuId</I> is an id for the menu, from which you can get menu pathname with - <B>MainFrame::getmenu</B>. -<LI><I>tearoff</I> specifies if menu has tearoff entry. -<LI><I>description</I> specifies a string for <A HREF=\"DynamicHelp.html\">DynamicHelp</A>. + <B>MainFrame::getmenu</B>.</LI> +<LI><I>tearoff</I> specifies if menu has tearoff entry.</LI> +<LI><I>description</I> specifies a string for <A HREF=\"DynamicHelp.html\">DynamicHelp</A>.</LI> <LI><I>accelerator</I> specifies a key sequence. It is a list of two elements, where the first -is one of <B>Ctrl</B>, <B>Alt</B> or <B>CtrlAlt</B>, and the second as letter or a digit. +is one of <B>Ctrl</B>, <B>Alt</B> or <B>CtrlAlt</B>, and the second as letter +(see <A HREF="#-casesensitive">-casesensitive</A> option for interpretation), a digit or +a special key name. An accelerator string is build and corresponding binding set on the toplevel to invoke the -menu entry. +menu entry.</LI> <LI><I>option value</I> specifies additionnal options for the entry (see <B>menu add</B> -command). +command).</LI> </UL> Each value enclosed by ? are optional and defaulted to empty string, but must be provided if one or more following options is not empty. @@ -154,7 +183,7 @@ {command "E&xit" {} "Exit the application" {} -command Menu::exit} } "&Options" {} {} 0 { - {checkbutton "Toolbar" {} "Show/hide toolbar" {} + {checkbutton "Toolbar" {} "Show/hide toolbar" {} -variable Menu::_drawtoolbar -command {$Menu::_mainframe showtoolbar toolbar $Menu::_drawtoolbar} }
