~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to tcl/get.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
############################################
 
2
# TKSCILAB Gui Interface facility for Scilab
 
3
# Bertrand Guiheneuf - 1998 
 
4
############################################
 
5
#
 
6
 
 
7
 
 
8
 
 
9
 
 
10
######################################################################################
 
11
proc GetField { handle field } {
 
12
# This the procedure called when get(...) is invoked by Scilab 
 
13
# There is a simple default behaviour when there is no
 
14
# a default behaviour when there is no
 
15
# specific get function associated to $field
 
16
# it just returns the value of the field 
 
17
# in a *string*.
 
18
 
 
19
  global Win;
 
20
  set name $Win($handle);
 
21
  global "$name";
 
22
  
 
23
  # implemented fields
 
24
  set KnownFunc  { value };
 
25
 
 
26
  # is it an implemented?
 
27
  set idx  [lsearch $KnownFunc $field];
 
28
    
 
29
  if { $idx != -1} {
 
30
    
 
31
    # call the specific getfield
 
32
    "Get$field" $name ;    
 
33
 
 
34
  } else {
 
35
 
 
36
    # just get the string
 
37
      if ([info exists "$name\($field)"]) {
 
38
          return [set "$name\($field)"];
 
39
      } else {
 
40
          return "";
 
41
      }
 
42
  }
 
43
}
 
44
 
 
45
 
 
46
 
 
47
 
 
48
 
 
49
 
 
50
 
 
51
 
 
52
 
 
53
 
 
54
proc Getvalue { name } {
 
55
    # return the value field of a control
 
56
    # when the control is a listbox, retruns a string 
 
57
    # 'idx1|idx2 ...' where idx1, .. are the indexes of
 
58
    # the selected items;
 
59
 
 
60
    global $name;
 
61
    
 
62
    set style [ set "$name\(style)"];
 
63
    switch -exact -- $style {
 
64
        
 
65
        listbox {
 
66
            
 
67
            set path [ set "$name\(path)"];
 
68
            set sel [$path.list curselection];
 
69
            set tmp [list];
 
70
            for {set i 0} {$i< [llength $sel]} {incr i} {
 
71
                set current [lindex $sel $i];
 
72
                incr current; 
 
73
                lappend tmp $current;
 
74
            }
 
75
            
 
76
            return [join $tmp |];
 
77
        }
 
78
        
 
79
        default {
 
80
            if ([info exists "$name\(value)"]) {
 
81
                return [set "$name\(value)"];
 
82
            } else {
 
83
                return "";
 
84
            }
 
85
        }
 
86
    }
 
87
 
 
88
}
 
 
b'\\ No newline at end of file'