Bwidget Source Code
Check-in [0406abeac2]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:* mainframe.tcl: Modified menu creation/setmenustate functions to support a new model of menustate. Instead of enabling/disabling a menu item whenever any one of its tags changes state, now it only enables menu items if all of its tags are set. This makes it really easy to, say, only enable the "New Action" entry if both a project is open and an element is selected.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0406abeac2d8e81820c3a32bc58686cc0e0d148a
User & Date: ericm 1999-09-17 17:46:47
Context
1999-09-17
20:50
* buttonbox.tcl: Added tagging mechanism to buttonbox. When using $bbox add, the first parameter is a list of tags for the button. Then use $bbox setbuttonstate to change the state of a tag. check-in: f3ebbcbe31 user: ericm tags: trunk
17:46
* mainframe.tcl: Modified menu creation/setmenustate functions to support a new model of menustate. Instead of enabling/disabling a menu item whenever any one of its tags changes state, now it only enables menu items if all of its tags are set. This makes it really easy to, say, only enable the "New Action" entry if both a project is open and an element is selected. check-in: 0406abeac2 user: ericm tags: trunk
1999-09-16
15:36
Adding a ChangeLog check-in: 5a459c8574 user: ericm tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.









1
2
3
4
5







1999-09-16  Eric Melski  <[email protected]>

	* notebook.tcl: Added some (non-functional) code for doing
	tab-notebooks with the tabs on the bottom.

>
>
>
>
>
>
>
>





1
2
3
4
5
6
7
8
9
10
11
12
13
1999-09-17  Eric Melski  <[email protected]

	* mainframe.tcl: Modified menu creation/setmenustate functions to support
	a new model of menustate.  Instead of enabling/disabling a menu item 
	whenever any one of its tags changes state, now it only enables menu items
	if all of its tags are set.  This makes it really easy to, say, only enable
	the "New Action" entry if both a project is open and an element is selected.

1999-09-16  Eric Melski  <[email protected]>

	* notebook.tcl: Added some (non-functional) code for doing
	tab-notebooks with the tabs on the bottom.

Changes to mainframe.tcl.

1
2
3
4
5
6
7
8
9
10
11
...
278
279
280
281
282
283
284
285















286









287
288
289

290
291
292
293
294
295
296
...
372
373
374
375
376
377
378



379




380
381
382
383
384
385
386
...
406
407
408
409
410
411
412



413



414
415
416
417
418
419
420
# ------------------------------------------------------------------------------
#  mainframe.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: mainframe.tcl,v 1.1.1.1 1999/08/03 20:20:23 ericm Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - MainFrame::create
#     - MainFrame::configure
#     - MainFrame::cget
#     - MainFrame::getframe
#     - MainFrame::addtoolbar
................................................................................

# ------------------------------------------------------------------------------
#  Command MainFrame::setmenustate
# ------------------------------------------------------------------------------
proc MainFrame::setmenustate { path tag state } {
    variable _widget

    if { [info exists _widget($path,tags,$tag)] } {















        foreach {menu entry} $_widget($path,tags,$tag) {









            $menu entryconfigure $entry -state $state
        }
    }

}


# ------------------------------------------------------------------------------
#  Command MainFrame::showtoolbar
# ------------------------------------------------------------------------------
proc MainFrame::showtoolbar { path index bool } {
................................................................................
        } else {
	    set menu $menubar.menu$count
	}
        eval $menubar add cascad $opt -menu $menu
        menu $menu -tearoff $tearoff -background $bg
        foreach tag $tags {
            lappend _widget($path,tags,$tag) $menubar $count



        }




        if { [string length $menuid] } {
            # menu has identifier
            set _widget($path,menuid,$menuid) $menu
        }
        _create_entries $path $menu $bg $entries
        incr count
    }
................................................................................
        }

        # entry name and tags
        set opt  [_parse_name [lindex $entry 1]]
        set tags [lindex $entry 2]
        foreach tag $tags {
            lappend _widget($path,tags,$tag) $menu $count



        }




        if { ![string compare $type "cascad"] } {
            set menuid  [lindex $entry 3]
            set tearoff [lindex $entry 4]
            set submenu $menu.menu$count
            eval $menu add cascad $opt -menu $submenu
            menu $submenu -tearoff $tearoff -background $bg


|







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
|

>







 







>
>
>
|
>
>
>
>







 







>
>
>
|
>
>
>







1
2
3
4
5
6
7
8
9
10
11
...
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
...
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# ------------------------------------------------------------------------------
#  mainframe.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: mainframe.tcl,v 1.2 1999/09/17 17:46:47 ericm Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - MainFrame::create
#     - MainFrame::configure
#     - MainFrame::cget
#     - MainFrame::getframe
#     - MainFrame::addtoolbar
................................................................................

# ------------------------------------------------------------------------------
#  Command MainFrame::setmenustate
# ------------------------------------------------------------------------------
proc MainFrame::setmenustate { path tag state } {
    variable _widget

    #    if { [info exists _widget($path,tags,$tag)] } {
    #        foreach {menu entry} $_widget($path,tags,$tag) {
    #            $menu entryconfigure $entry -state $state
    #        }
    #    }
	    
    # We need a more sophisticated state system.
    # The original model was this:  each menu item has a list of tags;
    # whenever any one of those tags changed state, the menu item did too.
    # This makes it hard to have items that are enabled only when both tagA and
    # tagB are.  The new model therefore only sets the menustate to enabled
    # when ALL of its tags are enabled.

    # First see if this is a real tag
    if { [info exists _widget($path,tagstate,$tag)] } {
	set _widget($path,tagstate,$tag) $state
	foreach {menu entry} $_widget($path,tags,$tag) {
	    set expression "1"
	    foreach menutag $_widget($path,menutags,[list $menu $entry]) {
		append expression " && $_widget($path,tagstate,$menutag)"
	    }
	    if { [expr $expression] } {
		set state normal
	    } else {
		set state disabled
	    }
	    $menu entryconfigure $entry -state $state
	}
    }
    return
}


# ------------------------------------------------------------------------------
#  Command MainFrame::showtoolbar
# ------------------------------------------------------------------------------
proc MainFrame::showtoolbar { path index bool } {
................................................................................
        } else {
	    set menu $menubar.menu$count
	}
        eval $menubar add cascad $opt -menu $menu
        menu $menu -tearoff $tearoff -background $bg
        foreach tag $tags {
            lappend _widget($path,tags,$tag) $menubar $count
	    # [email protected]:  Add a tagstate tracker
	    if { ![info exists _widget($path,tagstate,$tag)] } {
		set _widget($path,tagstate,$tag) 0
	    }
        }
	# [email protected]:  Add mapping from menu items to tags
	set _widget($path,menutags,[list $menubar $count]) $tags
	    
        if { [string length $menuid] } {
            # menu has identifier
            set _widget($path,menuid,$menuid) $menu
        }
        _create_entries $path $menu $bg $entries
        incr count
    }
................................................................................
        }

        # entry name and tags
        set opt  [_parse_name [lindex $entry 1]]
        set tags [lindex $entry 2]
        foreach tag $tags {
            lappend _widget($path,tags,$tag) $menu $count
	    # [email protected]:  Add a tagstate tracker
	    if { ![info exists _widget($path,tagstate,$tag)] } {
		set _widget($path,tagstate,$tag) 0
	    }
        }
	# [email protected]:  Add mapping from menu items to tags
	set _widget($path,menutags,[list $menu $count]) $tags

        if { ![string compare $type "cascad"] } {
            set menuid  [lindex $entry 3]
            set tearoff [lindex $entry 4]
            set submenu $menu.menu$count
            eval $menu add cascad $opt -menu $submenu
            menu $submenu -tearoff $tearoff -background $bg