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

Last change on this file since 856 was 676, checked in by mmc, 17 years ago

Fixed all fonts to set pixelsize instead of pointsize, so that fonts in
the latest X distribution look right.

Added initial Rappture::bugreport::submit command for submitting bug
reports to nanoHUB.org. This isn't tied in yet, but it's a start.

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