1Widget(n)                          [incr Tk]                         Widget(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       Widget - base class for mega-widgets within a frame
9

INHERITANCE

11       itk::Archetype <- itk::Widget
12

STANDARD OPTIONS

14       background      cursor
15
16       See the "options" manual entry for details on the standard options.
17_________________________________________________________________
18
19

DESCRIPTION

21       The Widget class inherits everything from the Archetype class, and adds
22       a Tk frame called the "hull" component to represent  the  body  of  the
23       mega-widget.   The  window  class name for the hull is set to the most-
24       specific class  name  for  the  mega-widget.   The  protected  variable
25       itk_interior  contains  the  window path name for the "hull" component.
26       Derived classes specialize this widget by packing other  widget  compo‐
27       nents into the hull.
28
29       Since  the  hull  for  the Widget class is implemented with a Tk frame,
30       mega-widgets in the Widget class can be packed into  other  frames  and
31       toplevels.
32
33

COMPONENTS

35       Name:           hull
36       Class:          Frame
37
38              The  "hull"  component acts as the body for the entire mega-wid‐
39              get.  Other components are packed into the hull to further  spe‐
40              cialize the widget.
41
42

EXAMPLE

44       The  following example implements a simple TextDisplay mega-widget.  It
45       creates a read-only display of text with a text widget and a scrollbar.
46              option add *TextDisplay.wrap none widgetDefault
47              option add *TextDisplay.textBackground ivory widgetDefault
48              option add *TextDisplay.width 40 widgetDefault
49              option add *TextDisplay.height 10 widgetDefault
50
51              itcl::class TextDisplay {
52                  inherit itk::Widget
53
54                  constructor {args} {
55                      itk_component add text {
56                          text $itk_interior.info -state disabled                 -yscrollcommand [code $itk_interior.sbar set]
57                      } {
58                          usual
59                          keep -tabs -wrap -width -height
60                          rename -background -textbackground textBackground Background
61                      }
62                      pack $itk_component(text) -side left -expand yes -fill both
63
64                      itk_component add scrollbar {
65                          scrollbar $itk_interior.sbar                 -command [code $itk_interior.info yview]
66                      }
67                      pack $itk_component(scrollbar) -side right -fill y
68
69                      eval itk_initialize $args
70                  }
71
72                  public method display {info}
73                  public method append {info}
74              }
75
76              itcl::body TextDisplay::display {info} {
77                  $itk_component(text) configure -state normal
78                  $itk_component(text) delete 1.0 end
79                  $itk_component(text) insert 1.0 $info
80                  $itk_component(text) configure -state disabled
81              }
82
83              itcl::body TextDisplay::append {info} {
84                  $itk_component(text) configure -state normal
85                  $itk_component(text) insert end $info
86                  $itk_component(text) configure -state disabled
87              }
88
89              itk::usual TextDisplay {
90                  keep -background -cursor -foreground -font
91                  keep -activebackground -activerelief
92                  keep -highlightcolor -highlightthickness
93                  keep -insertbackground -insertborderwidth -insertwidth
94                  keep -insertontime -insertofftime
95                  keep -selectbackground -selectborderwidth -selectforeground
96                  keep -textbackground -troughcolor
97              }
98
99              #
100              # EXAMPLE:  Display the /etc/passwd file
101              #
102              TextDisplay .file -background red
103              pack .file
104
105              .file display [exec cat /etc/passwd]
106
107

KEYWORDS

109       itk, Archetype, Widget, mega-widget
110
111
112
113itk                                   3.0                            Widget(n)
Impressum