OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [demos/] [samples/] [Select.tcl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Tix Demostration Program
2
#
3
# This sample program is structured in such a way so that it can be
4
# executed from the Tix demo program "widget": it must have a
5
# procedure called "RunSample". It should also have the "if" statment
6
# at the end of this file so that it can be run as a standalone
7
# program using tixwish.
8
 
9
# This file demonstrates the use of the tixSelect widget.
10
#
11
proc RunSample {w} {
12
    global demo_dir
13
 
14
    # Create the frame on the top of the dialog box with two tixSelect
15
    # widgets inside.
16
    #
17
    frame $w.top
18
 
19
    # There can be one and only type of justification for any piece of text.
20
    # So we set -radio to be true. Also, -allowzero is set to false: the user
21
    # cannot select a "none" justification
22
    #
23
    tixSelect $w.top.just -allowzero false -radio true \
24
        -label "Justification: "\
25
        -options {
26
            label.width 15
27
            label.padx 4
28
            label.anchor e
29
        }
30
 
31
    # The user can select one or many or none of the font attributes in
32
    # the font Select widget, so we set -radio to false (can select one or
33
    # many) and -allowzero to true (can select none)
34
    #
35
    tixSelect $w.top.font -allowzero true  -radio false \
36
        -label "Font: " \
37
        -options {
38
            label.width 15
39
            label.padx 4
40
            label.anchor e
41
        }
42
 
43
    pack $w.top.just $w.top.font -side top -expand yes -anchor c \
44
        -padx 4 -pady 4
45
 
46
    # Add the choices of available font attributes
47
    #
48
    #
49
    $w.top.font add bold      -bitmap @$demo_dir/bitmaps/bold.xbm
50
    $w.top.font add italic    -bitmap @$demo_dir/bitmaps/italic.xbm
51
    $w.top.font add underline -bitmap @$demo_dir/bitmaps/underlin.xbm
52
    $w.top.font add capital   -bitmap @$demo_dir/bitmaps/capital.xbm
53
 
54
    # Add the choices of available justification types
55
    #
56
    #
57
    $w.top.just add left      -bitmap @$demo_dir/bitmaps/leftj.xbm
58
    $w.top.just add right     -bitmap @$demo_dir/bitmaps/rightj.xbm
59
    $w.top.just add center    -bitmap @$demo_dir/bitmaps/centerj.xbm
60
    $w.top.just add justified -bitmap @$demo_dir/bitmaps/justify.xbm
61
 
62
    $w.top.font config -variable sel_font
63
    $w.top.just config -variable sel_just
64
 
65
    # Set the default value of the two Select widgets
66
    #
67
    #
68
    global sel_just sel_font
69
    set sel_just justified
70
    set sel_font {bold underline}
71
 
72
    # Use a ButtonBox to hold the buttons.
73
    #
74
    tixButtonBox $w.box -orientation horizontal
75
    $w.box add ok     -text Ok     -underline 0 -width 6\
76
        -command "sel:cmd $w; destroy $w"
77
 
78
    $w.box add apply  -text Apply  -underline 0 -width 6\
79
        -command "sel:cmd $w"
80
 
81
    $w.box add cancel -text Cancel -underline 0 -width 6\
82
        -command "destroy $w"
83
 
84
    pack $w.box -side bottom -fill x
85
    pack $w.top -side top -fill both -expand yes
86
}
87
 
88
# This procedure is called whenever the user pressed the OK or the Apply button
89
#
90
#
91
proc sel:cmd {w} {
92
    global sel_font sel_just
93
 
94
    puts "The justification is $sel_just"
95
 
96
    if {$sel_font == {}} {
97
        puts "The font is normal"
98
    } else {
99
        puts "The font is $sel_font"
100
    }
101
 
102
}
103
 
104
if {![info exists tix_demo_running]} {
105
    wm withdraw .
106
    set w .demo
107
    toplevel $w
108
    RunSample $w
109
    bind .demo <Destroy> exit
110
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.