1 # application-vcc3client.tcl --
2 #
3 # Creates a Vcc3Client and gives it a frame to display in
4 #
5 # Copyright (c) 2000-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 Import enable
32
33 import Application Vcc3Client
34
35 Class Vcc3ClientApplication -superclass Application
36
37 Vcc3ClientApplication instproc showUsage {} {
38 puts stdout "usage: vcc3client \[-port <port>\] \[-host <host>\]"
39 }
40
41 Vcc3ClientApplication instproc getFlags {argv} {
42 $self instvar hostname_ port_ labeltxt_
43
44 # defaults
45 set hostname_ "garfield.cs.berkeley.edu"
46 set port_ 6905
47
48 set state flag
49 foreach arg $argv {
50 switch -exact -- $state {
51 flag {
52 switch -exact -- $arg {
53 -port {
54 set state "port"
55 }
56 -host {
57 set state "host"
58 }
59 -label {
60 set state "label"
61 }
62 -help {
63 $self showUsage
64 exit
65 }
66 default {
67 $self showUsage
68 exit
69 }
70 }
71 }
72 port {
73 set port_ $arg
74 set state "flag"
75 }
76 host {
77 set hostname_ $arg
78 set state "flag"
79 }
80 label {
81 set labeltxt_ $arg
82 set state "flag"
83 }
84 }
85 }
86 }
87
88 Vcc3ClientApplication instproc init {argv} {
89 $self next "vcc3Client"
90 $self instvar client_ hostname_ port_ labeltxt_
91 set labeltxt_ ""
92 $self getFlags $argv
93
94 $self initUI
95
96 if [catch {new Vcc3Client "" $hostname_ $port_} client_] {
97 puts stderr "ERROR: vcc3client: unable to connect to server ${hostname_} at port ${port_}"
98 puts stderr "Return error is: $client_"
99 exit
100 }
101 }
102
103 Vcc3ClientApplication instproc initUI {} {
104 $self instvar client_ hostname_ port_ labeltxt_
105
106 wm title . "Vcc3Client: $hostname_"
107 # wm minsize . 200 100
108
109 frame .clientFrame -relief ridge -borderwidth 5
110 pack .clientFrame -side top
111
112 # make exit button
113 label .l -text $labeltxt_
114 button .exit -text "Exit" -command exit
115 pack .l .exit -side bottom
116 }
117
118
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.