annotate src/myVncClient/OptionsFrame.java @ 17:f9ecb0315303

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