File: Controls.java

package info (click to toggle)
waba 1.5-3
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 1,996 kB
  • ctags: 3,231
  • sloc: ansic: 17,303; java: 4,436; sh: 2,345; makefile: 417
file content (154 lines) | stat: -rw-r--r-- 3,587 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*

Controls.java

Copyright (c) 1998, 1999 Wabasoft 

Wabasoft grants you a non-exclusive license to use, modify and re-distribute
this program provided that this copyright notice and license appear on all
copies of the software.

Software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR
IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
HEREBY EXCLUDED. THE ENTIRE RISK ARISING OUT OF USING THE SOFTWARE IS ASSUMED
BY THE LICENSEE. 

WABASOFT AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
LICENSEE OR ANY THIRD PARTY AS A RESULT OF USING OR DISTRIBUTING SOFTWARE.
IN NO EVENT WILL WABASOFT OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL
OR PUNITIVE DAMAGES, HOWEVER CAUSED AN REGARDLESS OF THE THEORY OF LIABILITY,
ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF WABASOFT HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 

*/

import waba.ui.*;
import waba.fx.*;

class ControlPage extends Container
{
Label label;
Button button;
Check check;
Radio radio;
Edit edit;

public ControlPage()
	{
	Label l = new Label("Label:", Label.RIGHT);
	l.setRect(5, 0, 40, 18);
	add(l);

	label = new Label("My Label");
	label.setRect(55, 0, 60, 18);
	add(label);

	l = new Label("Button:", Label.RIGHT);
	l.setRect(5, 25, 40, 18);
	add(l);

	button = new Button("My Button");
	button.setRect(55, 25, 60, 18);
	add(button);

	l = new Label("Check:", Label.RIGHT);
	l.setRect(5, 50, 40, 18);
	add(l);

	check = new Check("My Check");
	check.setRect(55, 50, 65, 18);
	add(check);

	l = new Label("Radio:", Label.RIGHT);
	l.setRect(5, 75, 40, 18);
	add(l);

	radio = new Radio("My Radio");
	radio.setRect(55, 75, 60, 18);
	add(radio);

	l = new Label("Edit:", Label.RIGHT);
	l.setRect(5, 100, 40, 18);
	add(l);

	edit = new Edit();
	edit.setText("My Edit");
	edit.setRect(55, 100, 60, 18);
	add(edit);
	}
}

class ContainerPage extends Container
{
TabBar tabBar;

public ContainerPage()
	{
	Label l = new Label("TabBar:");
	l.setRect(10, 0, 40, 18);
	add(l);
 	 
	tabBar = new TabBar();
	tabBar.add(new Tab("Yearly"));
	tabBar.add(new Tab("Monthly"));
	tabBar.add(new Tab("Daily"));
	tabBar.setRect(10, 20, 140, 20);
	add(tabBar);
	}
}

public class Controls extends MainWindow
{
Tab controlTab;
ControlPage controlPage;
Tab containerTab;
ContainerPage containerPage;
int pageShowing;

public Controls()
	{
	TabBar tabBar = new TabBar();
	controlTab = new Tab("Controls");
	tabBar.add(controlTab);
	containerTab = new Tab("Containers");
	tabBar.add(containerTab);
	tabBar.setRect(0, 0, this.width, 20);
	add(tabBar);

	controlPage = new ControlPage();
	controlPage.setRect(0, 30, this.width, this.height - 30);
	add(controlPage);
	}

public void onPaint(Graphics g)
	{
	g.setColor(0, 0, 0);
	g.drawLine(160, 0, 160, 160);
	g.drawLine(0, 160, 160, 160);
	}

public void onEvent(Event event)
	{
	if (event.type == ControlEvent.PRESSED)
		{
		if (event.target == controlTab)
			{
			if (containerPage != null)
				remove(containerPage);
			add(controlPage);
			}
		else if (event.target == containerTab)
			{
			if (containerPage == null)
				{
				containerPage = new ContainerPage();
				containerPage.setRect(0, 30, this.width, this.height - 30);
				}
			remove(controlPage);
			add(containerPage);
			}
		}
	}
}