source: tol/tolbase/lib/byswidget/btab/btab.tcl @ 20907d9

1941-docker-image-to-testdevel
Last change on this file since 20907d9 was 20907d9, checked in by Pedro Gea <pgea@…>, 10 years ago

Refs #1933
Se prescinde de BLT en algunos widgets.
Otros que no se han convertido se marcan como obsoletos.

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