annotate src/OptionsFrame.java @ 0:e04119c40b9b

upload all file of tighVNCClient
author e085711
date Tue, 12 Apr 2011 12:57:33 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
1 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
2 // Copyright (C) 2001 HorizonLive.com, Inc. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
3 // Copyright (C) 2001 Constantin Kaplinsky. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
4 // Copyright (C) 2000 Tridia Corporation. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
5 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
6 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
7 // This is free software; you can redistribute it and/or modify
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
8 // it under the terms of the GNU General Public License as published by
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
9 // the Free Software Foundation; either version 2 of the License, or
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
10 // (at your option) any later version.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
11 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
12 // This software is distributed in the hope that it will be useful,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
15 // GNU General Public License for more details.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
16 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
17 // You should have received a copy of the GNU General Public License
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
18 // along with this software; if not, write to the Free Software
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
20 // USA.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
21 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
22
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
23 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
24 // Options frame.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
25 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
26 // This deals with all the options the user can play with.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
27 // It sets the encodings array and some booleans.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
28 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
29
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
30 import java.awt.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
31 import java.awt.event.*;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
32
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
33 class OptionsFrame extends Frame
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
34 implements WindowListener, ActionListener, ItemListener {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
35
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
36 static String[] names = {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
37 "Encoding",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
38 "Compression level",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
39 "JPEG image quality",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
40 "Cursor shape updates",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
41 "Use CopyRect",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
42 "Restricted colors",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
43 "Mouse buttons 2 and 3",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
44 "View only",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
45 "Scale remote cursor",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
46 "Share desktop",
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
47 };
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
48
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
49 static String[][] values = {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
50 { "Auto", "Raw", "RRE", "CoRRE", "Hextile", "Zlib", "Tight", "ZRLE" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
51 { "Default", "1", "2", "3", "4", "5", "6", "7", "8", "9" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
52 { "JPEG off", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
53 { "Enable", "Ignore", "Disable" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
54 { "Yes", "No" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
55 { "Yes", "No" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
56 { "Normal", "Reversed" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
57 { "Yes", "No" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
58 { "No", "50%", "75%", "125%", "150%" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
59 { "Yes", "No" },
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
60 };
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
61
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
62 final int
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
63 encodingIndex = 0,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
64 compressLevelIndex = 1,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
65 jpegQualityIndex = 2,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
66 cursorUpdatesIndex = 3,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
67 useCopyRectIndex = 4,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
68 eightBitColorsIndex = 5,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
69 mouseButtonIndex = 6,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
70 viewOnlyIndex = 7,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
71 scaleCursorIndex = 8,
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
72 shareDesktopIndex = 9;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
73
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
74 Label[] labels = new Label[names.length];
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
75 Choice[] choices = new Choice[names.length];
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
76 Button closeButton;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
77 VncViewer viewer;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
78
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
79
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
80 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
81 // The actual data which other classes look at:
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
82 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
83
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
84 int preferredEncoding;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
85 int compressLevel;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
86 int jpegQuality;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
87 boolean useCopyRect;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
88 boolean requestCursorUpdates;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
89 boolean ignoreCursorUpdates;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
90
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
91 boolean eightBitColors;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
92
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
93 boolean reverseMouseButtons2And3;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
94 boolean shareDesktop;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
95 boolean viewOnly;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
96 int scaleCursor;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
97
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
98 boolean autoScale;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
99 int scalingFactor;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
100
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
101 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
102 // Constructor. Set up the labels and choices from the names and values
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
103 // arrays.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
104 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
105
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
106 OptionsFrame(VncViewer v) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
107 super("TightVNC Options");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
108
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
109 viewer = v;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
110
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
111 GridBagLayout gridbag = new GridBagLayout();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
112 setLayout(gridbag);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
113
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
114 GridBagConstraints gbc = new GridBagConstraints();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
115 gbc.fill = GridBagConstraints.BOTH;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
116
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
117 for (int i = 0; i < names.length; i++) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
118 labels[i] = new Label(names[i]);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
119 gbc.gridwidth = 1;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
120 gridbag.setConstraints(labels[i],gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
121 add(labels[i]);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
122
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
123 choices[i] = new Choice();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
124 gbc.gridwidth = GridBagConstraints.REMAINDER;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
125 gridbag.setConstraints(choices[i],gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
126 add(choices[i]);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
127 choices[i].addItemListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
128
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
129 for (int j = 0; j < values[i].length; j++) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
130 choices[i].addItem(values[i][j]);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
131 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
132 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
133
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
134 closeButton = new Button("Close");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
135 gbc.gridwidth = GridBagConstraints.REMAINDER;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
136 gridbag.setConstraints(closeButton, gbc);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
137 add(closeButton);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
138 closeButton.addActionListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
139
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
140 pack();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
141
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
142 addWindowListener(this);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
143
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
144 // Set up defaults
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
145
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
146 choices[encodingIndex].select("Auto");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
147 choices[compressLevelIndex].select("Default");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
148 choices[jpegQualityIndex].select("6");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
149 choices[cursorUpdatesIndex].select("Enable");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
150 choices[useCopyRectIndex].select("Yes");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
151 choices[eightBitColorsIndex].select("No");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
152 choices[mouseButtonIndex].select("Normal");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
153 choices[viewOnlyIndex].select("No");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
154 choices[scaleCursorIndex].select("No");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
155 choices[shareDesktopIndex].select("Yes");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
156
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
157 // But let them be overridden by parameters
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
158
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
159 for (int i = 0; i < names.length; i++) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
160 String s = viewer.readParameter(names[i], false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
161 if (s != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
162 for (int j = 0; j < values[i].length; j++) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
163 if (s.equalsIgnoreCase(values[i][j])) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
164 choices[i].select(j);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
165 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
166 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
167 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
168 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
169
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
170 // FIXME: Provide some sort of GUI for "Scaling Factor".
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
171
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
172 autoScale = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
173 scalingFactor = 100;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
174 String s = viewer.readParameter("Scaling Factor", false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
175 if (s != null) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
176 if (s.equalsIgnoreCase("Auto")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
177 autoScale = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
178 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
179 // Remove the '%' char at the end of string if present.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
180 if (s.charAt(s.length() - 1) == '%') {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
181 s = s.substring(0, s.length() - 1);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
182 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
183 // Convert to an integer.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
184 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
185 scalingFactor = Integer.parseInt(s);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
186 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
187 catch (NumberFormatException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
188 scalingFactor = 100;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
189 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
190 // Make sure scalingFactor is in the range of [1..1000].
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
191 if (scalingFactor < 1) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
192 scalingFactor = 1;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
193 } else if (scalingFactor > 1000) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
194 scalingFactor = 1000;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
195 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
196 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
197 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
198
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
199 // Make the booleans and encodings array correspond to the state of the GUI
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
200
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
201 setEncodings();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
202 setColorFormat();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
203 setOtherOptions();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
204 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
205
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
206
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
207 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
208 // Disable the shareDesktop option
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
209 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
210
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
211 void disableShareDesktop() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
212 labels[shareDesktopIndex].setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
213 choices[shareDesktopIndex].setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
214 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
215
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
216 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
217 // setEncodings looks at the encoding, compression level, JPEG
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
218 // quality level, cursor shape updates and copyRect choices and sets
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
219 // corresponding variables properly. Then it calls the VncViewer's
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
220 // setEncodings method to send a SetEncodings message to the RFB
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
221 // server.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
222 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
223
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
224 void setEncodings() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
225 useCopyRect = choices[useCopyRectIndex].getSelectedItem().equals("Yes");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
226
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
227 preferredEncoding = RfbProto.EncodingRaw;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
228 boolean enableCompressLevel = false;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
229
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
230 if (choices[encodingIndex].getSelectedItem().equals("RRE")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
231 preferredEncoding = RfbProto.EncodingRRE;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
232 } else if (choices[encodingIndex].getSelectedItem().equals("CoRRE")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
233 preferredEncoding = RfbProto.EncodingCoRRE;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
234 } else if (choices[encodingIndex].getSelectedItem().equals("Hextile")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
235 preferredEncoding = RfbProto.EncodingHextile;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
236 } else if (choices[encodingIndex].getSelectedItem().equals("ZRLE")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
237 preferredEncoding = RfbProto.EncodingZRLE;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
238 } else if (choices[encodingIndex].getSelectedItem().equals("Zlib")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
239 preferredEncoding = RfbProto.EncodingZlib;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
240 enableCompressLevel = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
241 } else if (choices[encodingIndex].getSelectedItem().equals("Tight")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
242 preferredEncoding = RfbProto.EncodingTight;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
243 enableCompressLevel = true;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
244 } else if (choices[encodingIndex].getSelectedItem().equals("Auto")) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
245 preferredEncoding = -1;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
246 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
247
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
248 // Handle compression level setting.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
249
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
250 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
251 compressLevel =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
252 Integer.parseInt(choices[compressLevelIndex].getSelectedItem());
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
253 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
254 catch (NumberFormatException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
255 compressLevel = -1;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
256 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
257 if (compressLevel < 1 || compressLevel > 9) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
258 compressLevel = -1;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
259 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
260 labels[compressLevelIndex].setEnabled(enableCompressLevel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
261 choices[compressLevelIndex].setEnabled(enableCompressLevel);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
262
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
263 // Handle JPEG quality setting.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
264
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
265 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
266 jpegQuality =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
267 Integer.parseInt(choices[jpegQualityIndex].getSelectedItem());
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
268 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
269 catch (NumberFormatException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
270 jpegQuality = -1;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
271 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
272 if (jpegQuality < 0 || jpegQuality > 9) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
273 jpegQuality = -1;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
274 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
275
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
276 // Request cursor shape updates if necessary.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
277
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
278 requestCursorUpdates =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
279 !choices[cursorUpdatesIndex].getSelectedItem().equals("Disable");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
280
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
281 if (requestCursorUpdates) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
282 ignoreCursorUpdates =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
283 choices[cursorUpdatesIndex].getSelectedItem().equals("Ignore");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
284 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
285
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
286 viewer.setEncodings();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
287 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
288
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
289 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
290 // setColorFormat sets eightBitColors variable depending on the GUI
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
291 // setting, causing switches between 8-bit and 24-bit colors mode if
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
292 // necessary.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
293 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
294
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
295 void setColorFormat() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
296
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
297 eightBitColors =
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
298 choices[eightBitColorsIndex].getSelectedItem().equals("Yes");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
299
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
300 boolean enableJPEG = !eightBitColors;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
301
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
302 labels[jpegQualityIndex].setEnabled(enableJPEG);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
303 choices[jpegQualityIndex].setEnabled(enableJPEG);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
304 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
305
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
306 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
307 // setOtherOptions looks at the "other" choices (ones that do not
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
308 // cause sending any protocol messages) and sets the boolean flags
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
309 // appropriately.
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
310 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
311
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
312 void setOtherOptions() {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
313
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
314 reverseMouseButtons2And3
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
315 = choices[mouseButtonIndex].getSelectedItem().equals("Reversed");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
316
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
317 viewOnly
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
318 = choices[viewOnlyIndex].getSelectedItem().equals("Yes");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
319 if (viewer.vc != null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
320 viewer.vc.enableInput(!viewOnly);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
321
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
322 shareDesktop
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
323 = choices[shareDesktopIndex].getSelectedItem().equals("Yes");
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
324
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
325 String scaleString = choices[scaleCursorIndex].getSelectedItem();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
326 if (scaleString.endsWith("%"))
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
327 scaleString = scaleString.substring(0, scaleString.length() - 1);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
328 try {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
329 scaleCursor = Integer.parseInt(scaleString);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
330 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
331 catch (NumberFormatException e) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
332 scaleCursor = 0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
333 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
334 if (scaleCursor < 10 || scaleCursor > 500) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
335 scaleCursor = 0;
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
336 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
337 if (requestCursorUpdates && !ignoreCursorUpdates && !viewOnly) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
338 labels[scaleCursorIndex].setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
339 choices[scaleCursorIndex].setEnabled(true);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
340 } else {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
341 labels[scaleCursorIndex].setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
342 choices[scaleCursorIndex].setEnabled(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
343 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
344 if (viewer.vc != null)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
345 viewer.vc.createSoftCursor(); // update cursor scaling
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
346 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
347
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
348
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
349 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
350 // Respond to actions on Choice controls
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
351 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
352
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
353 public void itemStateChanged(ItemEvent evt) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
354 Object source = evt.getSource();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
355
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
356 if (source == choices[encodingIndex] ||
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
357 source == choices[compressLevelIndex] ||
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
358 source == choices[jpegQualityIndex] ||
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
359 source == choices[cursorUpdatesIndex] ||
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
360 source == choices[useCopyRectIndex]) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
361
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
362 setEncodings();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
363
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
364 if (source == choices[cursorUpdatesIndex]) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
365 setOtherOptions(); // update scaleCursor state
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
366 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
367
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
368 } else if (source == choices[eightBitColorsIndex]) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
369
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
370 setColorFormat();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
371
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
372 } else if (source == choices[mouseButtonIndex] ||
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
373 source == choices[shareDesktopIndex] ||
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
374 source == choices[viewOnlyIndex] ||
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
375 source == choices[scaleCursorIndex]) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
376
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
377 setOtherOptions();
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
378
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
379 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
380 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
381
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
382 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
383 // Respond to button press
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
384 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
385
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
386 public void actionPerformed(ActionEvent evt) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
387 if (evt.getSource() == closeButton)
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
388 setVisible(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
389 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
390
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
391 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
392 // Respond to window events
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
393 //
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
394
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
395 public void windowClosing(WindowEvent evt) {
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
396 setVisible(false);
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
397 }
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
398
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
399 public void windowActivated(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
400 public void windowDeactivated(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
401 public void windowOpened(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
402 public void windowClosed(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
403 public void windowIconified(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
404 public void windowDeiconified(WindowEvent evt) {}
e04119c40b9b upload all file of tighVNCClient
e085711
parents:
diff changeset
405 }