source: trunk/gui/scripts/groupentry.tcl @ 83

Last change on this file since 83 was 26, checked in by mmc, 19 years ago

Fixed the rendering of groups, and groups within groups.
If groups are mixed in with other elements, then they are
drawn with a gray outline/heading, with the title taken
from the <group><about><label>. However, if a group
contains only other groups, then it is treated as a tabbed
notebook, and each group within is put on a separate page.

WARNING: There are many bad interactions between the
blt::tabset, the Rappture::Scroller, and the Rappture::Pager.
Pages shake violently when all are in play. The only way I
could get them to settle down was by putting the tabs above
the pages they control. Have to revisit this some time to
make it look better...

File size: 5.1 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: GroupEntry - widget containing a group of controls
3#
4#  This widget represents a <group> entry on a control panel.
5#  It contains a series of other controls.  Sort of a glorified
6#  frame widget.
7# ======================================================================
8#  AUTHOR:  Michael McLennan, Purdue University
9#  Copyright (c) 2004-2005
10#  Purdue Research Foundation, West Lafayette, IN
11# ======================================================================
12package require Itk
13
14option add *GroupEntry.headingBackground #cccccc widgetDefault
15option add *GroupEntry.headingForeground white widgetDefault
16option add *GroupEntry.font -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
17
18itcl::class Rappture::GroupEntry {
19    inherit itk::Widget
20
21    itk_option define -heading heading Heading 1
22
23    constructor {owner path args} { # defined below }
24
25    public method value {args}
26
27    public method label {}
28    public method tooltip {}
29
30    protected method _fixheading {}
31
32    private variable _owner ""    ;# thing managing this control
33    private variable _path ""     ;# path in XML to this number
34}
35
36itk::usual GroupEntry {
37    keep -cursor -font
38    keep -foreground -background
39    keep -textbackground
40    keep -selectbackground -selectforeground -selectborderwidth
41}
42
43# ----------------------------------------------------------------------
44# CONSTRUCTOR
45# ----------------------------------------------------------------------
46itcl::body Rappture::GroupEntry::constructor {owner path args} {
47    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
48        error "bad object \"$owner\": should be Rappture::ControlOwner"
49    }
50    set _owner $owner
51    set _path $path
52
53    itk_component add heading {
54        ::label $itk_interior.heading -anchor w
55    } {
56        usual
57        rename -background -headingbackground headingBackground Background
58        rename -foreground -headingforeground headingForeground Foreground
59    }
60
61    $itk_component(heading) configure \
62        -text [$_owner xml get $_path.about.label]
63    Rappture::Tooltip::for $itk_component(heading) \
64        [$_owner xml get $_path.about.description]
65
66    itk_component add outline {
67        frame $itk_interior.outline -borderwidth 1
68    } {
69        usual
70        ignore -borderwidth
71        rename -background -headingbackground headingBackground Background
72    }
73    pack $itk_component(outline) -expand yes -fill both
74
75    itk_component add inner {
76        frame $itk_component(outline).inner -borderwidth 3
77    } {
78        usual
79        ignore -borderwidth
80    }
81    pack $itk_component(inner) -expand yes -fill both
82
83    eval itk_initialize $args
84}
85
86# ----------------------------------------------------------------------
87# USAGE: value ?-check? ?<newval>?
88#
89# Clients use this to query/set the value for this widget.  With
90# no args, it returns the current value for the widget.  If the
91# <newval> is specified, it sets the value of the widget and
92# sends a <<Value>> event.  If the -check flag is included, the
93# new value is not actually applied, but just checked for correctness.
94# ----------------------------------------------------------------------
95itcl::body Rappture::GroupEntry::value {args} {
96    # groups have no value
97    return ""
98}
99
100# ----------------------------------------------------------------------
101# USAGE: label
102#
103# Clients use this to query the label associated with this widget.
104# Reaches into the XML and pulls out the appropriate label string.
105# ----------------------------------------------------------------------
106itcl::body Rappture::GroupEntry::label {} {
107    return ""  ;# manage the label inside this group
108}
109
110# ----------------------------------------------------------------------
111# USAGE: tooltip
112#
113# Clients use this to query the tooltip associated with this widget.
114# Reaches into the XML and pulls out the appropriate description
115# string.  Returns the string that should be used with the
116# Rappture::Tooltip facility.
117# ----------------------------------------------------------------------
118itcl::body Rappture::GroupEntry::tooltip {} {
119    return [$_owner xml get $_path.about.description]
120}
121
122# ----------------------------------------------------------------------
123# CONFIGURATION OPTION: -heading
124# Turns the heading bar at the top of this group on/off.
125# ----------------------------------------------------------------------
126itcl::configbody Rappture::GroupEntry::heading {
127    if {![string is boolean -strict $itk_option(-heading)]} {
128        error "bad value \"$itk_option(-heading)\": should be boolean"
129    }
130
131    set str [$itk_component(heading) cget -text]
132    if {$itk_option(-heading) && "" != $str} {
133        eval pack forget [pack slaves $itk_component(hull)]
134        pack $itk_component(heading) -side top -fill x
135        pack $itk_component(outline) -expand yes -fill both
136        $itk_component(outline) configure -borderwidth 1
137        $itk_component(inner) configure -borderwidth 3
138    } else {
139        pack forget $itk_component(heading)
140        $itk_component(outline) configure -borderwidth 0
141        $itk_component(inner) configure -borderwidth 0
142    }
143}
Note: See TracBrowser for help on using the repository browser.