forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitPanel.java
More file actions
executable file
·107 lines (87 loc) · 2.3 KB
/
Copy pathSplitPanel.java
File metadata and controls
executable file
·107 lines (87 loc) · 2.3 KB
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
package javaforce.webui;
/** SplitPanel - divides two Panels vertically or horizontally.
*
* @author pquiring
*/
public class SplitPanel extends Container {
private int dir;
private int pos = 50; //pixels of left/top component
private Container top;
private Component div;
private Block b1, b2;
public static final int VERTICAL = 1;
public static final int HORIZONTAL = 2;
public SplitPanel(int direction) {
dir = VERTICAL;
add(b1 = new Block()); //left/top component
b1.add(new Label(""));
b1.addClass("splitPanel");
add(b2 = new Block()); //right/bottom component
b2.add(new Label(""));
b2.addClass("splitPanel");
switch (dir) {
case VERTICAL:
top = new Row();
get(0).setWidth(pos);
break;
case HORIZONTAL:
top = new Column();
get(0).setHeight(pos);
break;
}
add(top);
top.add(get(0)); //left/top component
div = new Block();
div.setWidth(5);
div.setBackColor("grey");
top.add(div);
top.add(get(1)); //right/bottom component
get(1).addClass("pad");
}
public void init() {
super.init();
div.addEvent("onmousedown", "onmousedownSplitPanel(event, this,\"" + get(0).id + "\",\"" + get(1).id + "\");");
}
public String html() {
return top.html();
}
public int getDirection() {
return dir;
}
public void setDividerPosition(int pos) {
this.pos = pos;
switch (dir) {
case VERTICAL: getLeftComponent().setWidth(pos); break;
case HORIZONTAL: getTopComponent().setHeight(pos); break;
}
}
public int getDividerPosition() {
return pos;
}
public Component getLeftComponent() {
return b1.get(0);
}
public Component getTopComponent() {
return b1.get(0);
}
public Component getRightComponent() {
return b2.get(0);
}
public Component getBottomComponent() {
return b2.get(0);
}
public void setLeftComponent(Component c) {
b1.set(0, c);
}
public void setTopComponent(Component c) {
b1.set(0, c);
}
public void setRightComponent(Component c) {
c.addClass("pad");
b2.set(0, c);
}
public void setBottomComponent(Component c) {
c.addClass("pad");
b2.set(0, c);
}
}