[HOME][CONTENTS][DOWNLOAD][PREV][NEXT]


COMB WIDGET EXAMPLES

Fold Container. A fold container (fold) is a comb-widget that is used as a container. It provides a multi-page folder to host various widgets of a graphic user interface. Each fold widget is referred to by a pathname specified at the creation. Pages in a fold widget can be created simultaneously with the fold widget or added into after the fold widget is created. A page in a fold widget is referred by a pagepath, which may be retrieved with a page's label, or directly returned after a new page is added into a fold widget. In addition to a pagepath, a page can also be referred to by a pageID that is uniquely assigned in creation of the page. Like any other widgets, a page can be deleted too. A page is a container (i.e., a comb-widget) that hosts various application items (widgets). An item is referred to by an itemID. An item can be bound with procedures, added into or deleted from a page as needed. 

EXAMPLE: The following example creates a fold of three pages: Palette, Editor and Buttons, and adds a pal widget into Palette, a text widget into Editor, and two gbtn widgets into Buttons. It then adds into the fold widget another page Fold in which an inside fold widget of four pages is added. At last, it adds a num widget into Page0 of the inside fold widget. This example shows how a complicated widget tree can be created using the container fold

catch "destroy .f"
toplevel .f
wm title .f "fold Widget"
wm geom .f 300x200
set fold [fold.create .f.fold -labels {Palette Editor Buttons}] 
pack $fold -expand 1 -fill both
pack [fold.addItem $fold Palette -palette pal.create ""] -expand 1
pack [fold.addItem $fold Editor -editor text ""] \
    -expand 1 -fill both

global ra
set ra 1

pack [fold.addItem $fold Buttons -radio gbtn.create "\
    -label {-text {Radio Buttons}} -btns {\
    {radio -text radio0 -var ra -val 0} \
    {radio -text radio1 -var ra -val 1} \
    {radio -text radio2 -var ra -val 2} \
    {radio -text radio3 -var ra -val 3} }"] \
    -expand 1 -fill both -side left -padx 5

pack [fold.addItem $fold Buttons -check gbtn.create "\
    -label {-text {Check Buttons}} -btns {\
    {check -text check0} \
    {check -text check1} \
    {check -text check2} \
    {check -text check3} }"] \
    -expand 1 -fill both -side right -padx 5

fold.add $fold Fold
set insideFold [fold.addItem $fold Fold -fold fold.create "\ 
    -labels {Page0 Page1 Page2 Page3}"]
pack $insideFold -expand 1 -fill both
fold.winconfig $fold
pack [fold.addItem $insideFold Page0 -num num.create "\
    -label {-text {Numeric Thums}} -ent {-width 8} \
    -up {-relief groove -bd 2} -down {-relief groove -bd 2}"] \
    -expand 1 -fill both -padx 10 -pady 10 

A palette widget within fold

A text widget within a page of fold

Two gbtn widgets are added into a page of fold

An inside fold is added into a page of fold. The numeric 
thumbs is added into the inside fold

CLASS NAME: fold

COMB-WIDGET OPTIONS

-labels pageLabelList It specifies a list of text labels for every page in a fold widget. Each item in this list defines a page in the fold widget. 
-fwidth initFoldWidth This is an integer to specify the initial width of the fold widget. 
-fheight initFoldHeight This is an integer to specify the initial height of the fold widget. 
-fclr frontColor It defines a color value for the front page label text. A defaulted value is black. 
-bclr backColor It defines a color value for the back page label text. A defaulted value is gray50
-x startx This is an integer to specify the x coordinate of a page start point. 
-y starty This is an integer to specify the y coordinate of a page start point. 
-dx labelWidth This is an integer to specify the minimum width of a label. 
-dy labelHeight This is an integer to specify the height of a label. 
-maxdx maxLabelWidth This is an integer to specify the maximum width of a label. 
-wx windowx This is an integer to specify the x coordinate of the upleft of the item window within a folder page. 
-wy windowy This is an integer to specify the y coordinate of the upleft of the item window within a folder page. 
User-defined options: an option may be defined by a user after a widget is added into a fold widget. 
WIDGET API
fold.create pathname ?options? This command create a fold widget with the options. It returns the pathname if the fold widget is successfully created. Otherwise it return an empty string. 
fold.add pathname label update This command adds a new page into a fold widget referred to by pathname. The newly added page will have a text label as specified by label. If the update is specified with a non-empty string, the fold widget's display will be updated immediately. A pagepath will be returned if the procedure is successfully completed. Otherwise an empty string is returned. 
fold.addFoldItem pagepath itemID creator ?options? This command adds an item (a sub-widget) into a fold page referred to by pagepath. An itemID is a -varName variable that uniquely identifies the corresponding sub-widget. The creator is a commad that creates the sub-widget. The ?options? is a list of options for the sub-widget configuration during its creation. 
fold.addItem pathname label itemID creator ?options? This command adds an item into a page referred to by a label of a fold widget, pathname. This command is similar to fold.addFoldItem. The difference is that it uses pathname and label to identify the pagepath
fold.bindPage pathname event cmd label This command binds a page referred to by a label to a command cmd for an event event
fold.delete pathname label update This command deletes a page referred to by a label from a fold widget referred to by pathname. If the update is not empty, the fold widget's display will be updated immediately. 
fold.deleteItem pathname label itemID This command deletes an item referred to by an itemID from a page referred to by a label from a fold widget referred to by a pathname
fold.disableItem pathname label itemID This command disables an item referred to by an itemID of a page referred to by a label of a fold widget referred to by a pathname
fold.enableItem pathname label itemID This command enables an item referred to by an itemID of a page referred to by a label of a fold widget referred to by a pathname
fold.get pathname label This command retrieves a pagepath of a page referred to by a label of a fold widget referred to by a pathname
fold.getPID pathname label This command retrieves a pageID of a page referred to by a label of a fold widget referred to by a pathname
fold.rename pathname label newLabel update This command renames a page referred to by a label to a new label referred to by newLabel. If the update variable is not empty, the fold widget's display will be updated immediately. 
fold.winconfig pathname width height This command reconfigures the window of the fold widget with a new width and height. 
RELATED PROCEDURES

The followings are procedures used in fold widget implementation and test. A user may access to these procedures through the fold widget API, and should never use these procedures directly in an application program. 

fold.draw pathname id x y wd ht offset dx dy label.
fold.free pathname.
fold.info pathname.
fold.page pathname.
fold.test pathname. 

[HOME][CONTENTS][DOWNLOAD] 1