source: tol/tolbaseBLT/lib/byswidget/btab/btab.tcl @ 56ade3b

1941-docker-image-to-testdevel
Last change on this file since 56ade3b was 56ade3b, checked in by Jorge Pérez <josp.jorge@…>, 10 years ago

fixes #1932, se ha creado la rama trunk/tolbaseBLT copia de trunk/tolbase

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7330 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 7.9 KB
Line 
1#/////////////////////////////////////////////////////////////////////////////
2# FILE    : btab.tcl
3# PURPOSE : Bayes tab manager
4#/////////////////////////////////////////////////////////////////////////////
5
6package require BLT
7package require snit
8
9#/////////////////////////////////////////////////////////////////////////////
10::snit::widget btab {
11#
12# PURPOSE: 
13#
14#/////////////////////////////////////////////////////////////////////////////
15# SPECIFIC OPTIONS
16# -label      -> Label that will be shown in the tabs
17# -createcmd  -> Function that creates the widget in each tab.
18#                Must have a parameter called path, where the widget will be
19#                created.
20# BOTH OPTIONS MUST BE SPECIFIED IN CREATION TIME
21#
22# VARIABLES
23# created     -> Created flag
24# widget      -> Contains path of the widgets of the component
25# data        -> Contains data  of the component
26# counter     -> Counter to create tabs
27#                             
28#/////////////////////////////////////////////////////////////////////////////
29  widgetclass Btab
30 
31  option -label        {}
32  option -createcmd    {}
33
34  variable created
35  variable widget
36  variable data
37  variable counter     0
38
39  #///////////////////////////////////////////////////////////////////////////
40  constructor {args} {
41  #
42  # PURPOSE: btab constructor
43  #
44  # PARAMETERS:
45  #   args ->  list of arguments for btab
46  #
47  #//////////////////////////////////////////////////////////////////////////
48    $self configure -label      [from args -label ""]
49    $self configure -createcmd  [from args -createcmd ""]
50    # Apply all arguments given:
51#    $self configurelist $args   
52
53    # Create the widget
54    $self createwidget $args
55
56    # Widget is now created
57    set created 1
58  }
59
60  #///////////////////////////////////////////////////////////////////////////
61  method createwidget { args } {
62  #
63  # PURPOSE: Creates widget of the component
64  #
65  # PARAMETERS:
66  #   args -> List with the options for the component.
67  #
68  #///////////////////////////////////////////////////////////////////////////
69    set widget(fr) [frame $self.f]
70#    set widget(sb) [$self _CreateScrollBar]
71    set widget(ts) [$self _CreateTabSet]
72    set widget(bt) [$self _CreateButtons]
73   
74#    $widget(sb) configure -command [list $widget(ts) view]
75#    $widget(ts) configure -scrollcommand [list $widget(sb) set] \
76#                           -scrollincrement 20
77
78    $self insertTab
79
80#     pack $widget(sb) $widget(bt)
81    pack $widget(bt)
82
83    grid $widget(fr) -column 0 -row 0 -sticky nw
84    grid $widget(ts) -column 1 -row 0 -sticky news
85    grid columnconfigure $self 0 -weight 0
86    grid columnconfigure $self 1 -weight 1
87    grid rowconfigure    $self 0 -weight 1
88  }
89
90  #///////////////////////////////////////////////////////////////////////////
91  method _CreateScrollBar { } {
92  #
93  # PURPOSE: Crea la barra de desplazamiento
94  #
95  #///////////////////////////////////////////////////////////////////////////
96    set sb [scrollbar $self.f.sb -orient horizontal]
97    return $sb
98  }
99
100  #///////////////////////////////////////////////////////////////////////////
101  method _CreateTabSet { } {
102  #
103  # PURPOSE: Crea el tabset
104  #
105  #///////////////////////////////////////////////////////////////////////////
106    set ts [::blt::tabset $self.ts -relief flat \
107      -highlightthickness 0 -bd 0 -outerpad 0 -slant right \
108      -textside right -scrollincrement 20]
109    return $ts
110  }
111
112  #///////////////////////////////////////////////////////////////////////////
113  method _CreateButtons { } {
114  #
115  # PURPOSE: Crea la barra de botones
116  #
117  #///////////////////////////////////////////////////////////////////////////
118#     set TF [::toolbar::ToolbarFrame $self.f.toolbarFrame]
119#     ## 2) Create a toolbar in this toolbar frame...
120#     set tb1 [::toolbar::create $TF.tb1]
121#     ::toolbar::addbutton $tb1 -image [::Bitmap::get reverse] \
122#       -tooltip [mc "TOL Inspector"]\
123#       -command [list ::TolConsole::RaiseInspector]
124#     ::toolbar::addbutton $tb1 -image [::Bitmap::get play] \
125#       -statuswidget $widgets(sb,path) -tooltip [mc "Connection to database"]\
126#       -command [list $::project::data(bodbc) showdialog]
127#     ::toolbar::addseparator $tb1
128#     ::toolbar::addbutton $tb1 -image [::Bitmap::get newtab] \
129#       -statuswidget $widgets(sb,path) -tooltip [mc "New TOL file"]\
130#       -command [list ::Editor::New]
131#     ::toolbar::addbutton $tb1 -image [::Bitmap::get closetab] \
132#       -statuswidget $widgets(sb,path) -tooltip [mc "Open TOL file"]\
133#       -command [list ::Editor::Open]
134#     return $TF
135    set bbox \
136      [ButtonBox $self.f.bb -orient vertical -spacing 3 -padx 0 -pady 0 \
137         -homogeneous false]
138    $bbox add -relief link -command [list $widget(ts) view -1] \
139      -helptext [mc "Scrolls tabset to the left"] -disabledforeground ""\
140      -image [::Bitmap::get reverse ] -compound left -padx 1 -pady 3
141    $bbox add -relief link -command [list $widget(ts) view 1] \
142      -helptext [mc "Scrolls tabset to the right"] -disabledforeground ""\
143      -image [::Bitmap::get play ] -compound left -padx 1 -pady 3
144    $bbox add -relief link -command [list $self insertTab] \
145      -helptext [mc "Inserts new tab"] -disabledforeground ""\
146      -image [::Bitmap::get newtab ] -compound left -padx 1 -pady 3
147    $bbox add -relief link -command [list $self deleteTab] \
148      -helptext [mc "Deletes current tab"] -disabledforeground ""\
149      -image [::Bitmap::get closetab] -compound left -padx 1 -pady 3
150
151    return $bbox
152  }
153
154  #///////////////////////////////////////////////////////////////////////////
155  #  PRIVATE METHODS
156  #///////////////////////////////////////////////////////////////////////////
157 
158  #///////////////////////////////////////////////////////////////////////////
159  #  PUBLIC METHODS
160  #///////////////////////////////////////////////////////////////////////////
161
162  #///////////////////////////////////////////////////////////////////////////
163  method insertTab { } {
164  #
165  # PURPOSE: Inserts new tab at the end and creates new widget associated
166  #          with the tab.
167  #
168  #///////////////////////////////////////////////////////////////////////////
169    $widget(ts) insert end widget$counter
170    set path "$self.ts.widget$counter"
171    eval [$self cget -createcmd] $path
172    pack $path -fill both -expand true
173    $widget(ts) tab configure widget$counter \
174      -text "[mc "List"] $counter" \
175      -window $path -fill both
176    incr counter
177  }
178 
179  #///////////////////////////////////////////////////////////////////////////
180  method deleteTab { } {
181  #
182  # PURPOSE: Deletes active tab
183  #
184  #///////////////////////////////////////////////////////////////////////////
185    if { [$widget(ts) size] > 1 } {
186      destroy $widget(ts).[$widget(ts) get select]
187      $widget(ts) delete [$widget(ts) index select]
188    }
189  }
190
191  #///////////////////////////////////////////////////////////////////////////
192  method getSelected { {entry select}  } {
193  #
194  # PURPOSE: Returns path of the selected widget in the tab
195  #
196  #///////////////////////////////////////////////////////////////////////////
197    return $widget(ts).[$widget(ts) get $entry]
198  }
199
200  #///////////////////////////////////////////////////////////////////////////
201  method configureentry { entry args } {
202  #
203  # PURPOSE: configures widget in the given entry
204  # PARAMETERS: entry -> entry index nr#, select, active...
205  #             args  -> arguments to configure
206  #
207  #///////////////////////////////////////////////////////////////////////////
208    set path "$widget(ts).[$widget(ts) get $entry]"
209    eval $path configure $args
210  }
211
212  #///////////////////////////////////////////////////////////////////////////
213  method configureall { args } {
214  #
215  # PURPOSE: configures all widgets in tabs with the given options
216  # PARAMETERS:  args  -> arguments to configure
217  #
218  #///////////////////////////////////////////////////////////////////////////
219    for {set i 0} {$i < [$widget(ts) size]} {incr i} {
220      eval $self configureentry $i $args
221    }
222  }
223}
224
225package provide btab 1.0
Note: See TracBrowser for help on using the repository browser.