Index: 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 [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 ""
+ set accel $akey
+ set event ""
}
Ctrl {
- set accel "Ctrl+[string toupper $key]"
- set event ""
+ set accel "Ctrl+$akey"
+ set event ""
}
Alt {
- set accel "Alt+[string toupper $key]"
- set event ""
+ set accel "Alt+$akey"
+ set event ""
}
CtrlAlt {
- set accel "Ctrl+Alt+[string toupper $key]"
- set event ""
+ set accel "Ctrl+Alt+$akey"
+ set event ""
}
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 @@
- NAME
- MainFrame
- - Manage toplevel with menu, toolbar and statusbar
+ - Manage toplevel with menu, toolbar and statusbar
- CREATION
@@ -22,21 +22,26 @@
-progressvar (see -variable) |
+
- WIDGET-SPECIFIC OPTIONS
@@ -82,14 +87,36 @@
MainFrame manage toplevel to have:
- simple menu creation, with automatic accelerator bindings and
-DynamicHelp association,
-
- one or more toolbars that user can hide,
-
- a status bar, displaying a user message or a menu description, and optionally a
-ProgressBar.
+DynamicHelp association,
+- one or more toolbars that user can hide,
+- a status bar, displaying a user message or a menu description, and optionally a
+ProgressBar.
WIDGET-SPECIFIC OPTIONS
+
+- -casesensitive
+-
+Controlls the interpretation of accelerator definition by the -menu
+option. If this option is false 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 true the accelerator binding
+and the menu entry is done as given.
+
+Example:
+Both accelerators are identically if -casesensitive is specified as false. See
+-menu for the syntax of the menu discription list.
+
+
+...
+{command "&Save" {} {Save the document} {Ctrl s} -command Menu::save}
+{command "&Save As" {} {Save with different name} {Ctrl S} -command Menu::saveAs}
+...
+
+
+
+
- -height
-
@@ -107,33 +134,35 @@
where menuentries is a list where each element describe one menu entry, which can be:
- for a separator:
- {separator}
+ {separator}
- for a command:
- {command menuname ?tags? ?description? ?accelerator? ?option value? ...}
+ {command menuname ?tags? ?description? ?accelerator? ?option value? ...}
- for a check button:
- {checkbutton menuname ?tags? ?description? ?accelerator? ?option value? ...}
+ {checkbutton menuname ?tags? ?description? ?accelerator? ?option value? ...}
- for a radio button:
- {radiobutton menuname ?tags? ?description? ?accelerator ?option value? ...}
+ {radiobutton menuname ?tags? ?description? ?accelerator ?option value? ...}
- for a cascade menu:
- {cascade menuname tags menuId tearoff menuentries}
+ {cascade menuname tags menuId tearoff menuentries}
where:
- menuname is the name of the menu. If it contains a &, the following character
is automatically converted to the corresponding -underline option of menu add
-command.
+command.
- tags is the tags list for the entry, used for enabling or disabling menu
-entries with MainFrame::setmenustate.
+entries with MainFrame::setmenustate.
- menuId is an id for the menu, from which you can get menu pathname with
- MainFrame::getmenu.
-
- tearoff specifies if menu has tearoff entry.
-
- description specifies a string for DynamicHelp.
+ MainFrame::getmenu.
+- tearoff specifies if menu has tearoff entry.
+- description specifies a string for DynamicHelp.
- accelerator specifies a key sequence. It is a list of two elements, where the first
-is one of Ctrl, Alt or CtrlAlt, and the second as letter or a digit.
+is one of Ctrl, Alt or CtrlAlt, and the second as letter
+(see -casesensitive 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.
- option value specifies additionnal options for the entry (see menu add
-command).
+command).
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}
}