blob: 64c0910620d54e748df101e75573a5f62b947b51 [file] [log] [blame]
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18//
19// OptionsDialog.h
20//
21
22#ifndef __OPTIONSDIALOG_H__
23#define __OPTIONSDIALOG_H__
24
25#include "TXDialog.h"
26#include "TXLabel.h"
27#include "TXEntry.h"
28#include "TXButton.h"
29#include "TXCheckbox.h"
30#include "parameters.h"
31
Adam Tkace3cb0c32010-09-15 14:12:38 +000032#define SECOND_COL_XPAD 350
33
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000034class OptionsDialogCallback {
35public:
36 virtual void setOptions() = 0;
37 virtual void getOptions() = 0;
38};
39
40class OptionsDialog : public TXDialog, public TXButtonCallback,
41 public TXCheckboxCallback, public TXEntryCallback {
42public:
43 OptionsDialog(Display* dpy, OptionsDialogCallback* cb_)
Adam Tkace3cb0c32010-09-15 14:12:38 +000044 : TXDialog(dpy, 750, 450, _("VNC Viewer: Connection Options")), cb(cb_),
45
46 /* Encoding and color level */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000047 formatAndEnc(dpy, _("Encoding and Color Level:"), this),
48 inputs(dpy, _("Inputs:"), this),
49 misc(dpy, _("Misc:"), this),
50 autoSelect(dpy, _("Auto select"), this, false, this),
51 fullColour(dpy, _("Full (all available colors)"), this, true, this),
52 mediumColour(dpy, _("Medium (256 colors)"), this, true, this),
53 lowColour(dpy, _("Low (64 colors)"), this, true, this),
54 veryLowColour(dpy, _("Very low (8 colors)"), this, true, this),
55 tight(dpy, "Tight", this, true, this),
56 zrle(dpy, "ZRLE", this, true, this),
57 hextile(dpy, "Hextile", this, true, this),
58 raw(dpy, "Raw", this, true, this),
Adam Tkace3cb0c32010-09-15 14:12:38 +000059
60 /* Compression */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000061 customCompressLevel(dpy, _("Custom compression level:"), this, false, this),
62 compressLevel(dpy, this, this, false, 30),
63 compressLevelLabel(dpy, _("level (1=fast, 9=best)"), this),
64 noJpeg(dpy, _("Allow JPEG compression:"), this, false, this),
65 qualityLevel(dpy, this, this, false, 30),
66 qualityLevelLabel(dpy, _("quality (1=poor, 9=best)"), this),
Adam Tkace3cb0c32010-09-15 14:12:38 +000067
68 /* Inputs */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000069 viewOnly(dpy, _("View only (ignore mouse & keyboard)"), this, false, this),
70 acceptClipboard(dpy, _("Accept clipboard from server"), this, false, this),
71 sendClipboard(dpy, _("Send clipboard to server"), this, false, this),
72 sendPrimary(dpy, _("Send primary selection & cut buffer as clipboard"),
73 this, false, this),
Adam Tkace3cb0c32010-09-15 14:12:38 +000074
75 /* Misc */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000076 shared(dpy, _("Shared (don't disconnect other viewers)"), this, false,this),
77 fullScreen(dpy, _("Full-screen mode"), this, false, this),
78 useLocalCursor(dpy, _("Render cursor locally"), this, false, this),
79 dotWhenNoCursor(dpy, _("Show dot when no cursor"), this, false, this),
80 okButton(dpy, _("OK"), this, this, 60),
Adam Tkace3cb0c32010-09-15 14:12:38 +000081 cancelButton(dpy, _("Cancel"), this, this, 60),
82
83 /* Security */
84 security(dpy, _("Security:"), this),
85 secVeNCrypt(dpy, _("Extended encryption and authentication methods (VeNCrypt)"),
86 this, false, this),
87
88 /* Encryption */
89 encryption(dpy, _("Session encryption:"), this),
90 encNone(dpy, _("None"), this, false, this),
91 encTLS(dpy, _("TLS with anonymous certificates"), this, false, this),
92 encX509(dpy, _("TLS with X509 certificates"), this, false, this),
93 cacert(dpy, _("Path to X509 CA certificate"), this),
94 ca(dpy, this, this, false, 350),
95 crlcert(dpy, _("Path to X509 CRL file"), this),
96 crl(dpy, this, this, false, 350),
97
98 /* Authentication */
99 authentication(dpy, _("Authentication:"), this),
100 secNone(dpy, _("None"), this, false, this),
101 secVnc(dpy, _("Standard VNC (insecure without encryption)"),
102 this, false, this),
103 secPlain(dpy, _("Username and password (insecure without encryption)"),
104 this, false, this)
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000105 {
Adam Tkace3cb0c32010-09-15 14:12:38 +0000106 /* Render the first collumn */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000107 int y = yPad;
108 formatAndEnc.move(xPad, y);
109 y += formatAndEnc.height();
110 autoSelect.move(xPad, y);
111 int x2 = xPad + autoSelect.width() + xPad*5;
112 y += autoSelect.height();
113 tight.move(xPad, y);
114 fullColour.move(x2, y);
115 y += tight.height();
116 zrle.move(xPad, y);
117 mediumColour.move(x2, y);
118 y += zrle.height();
119 hextile.move(xPad, y);
120 lowColour.move(x2, y);
121 y += hextile.height();
122 raw.move(xPad, y);
123 veryLowColour.move(x2, y);
124 y += raw.height() + yPad*2;
125
126 customCompressLevel.move(xPad, y);
127 y += customCompressLevel.height();
128 compressLevel.move(xPad*10, y);
129 compressLevelLabel.move(xPad*20, y);
130 y += compressLevel.height();
131
132 noJpeg.move(xPad, y);
133 y += noJpeg.height();
134 qualityLevel.move(xPad*10, y);
135 qualityLevelLabel.move(xPad*20, y);
136 y += qualityLevel.height();
137
138 y += yPad*4;
139 inputs.move(xPad, y);
140 y += inputs.height();
141 viewOnly.move(xPad, y);
142 y += viewOnly.height();
143 acceptClipboard.move(xPad, y);
144 y += acceptClipboard.height();
145 sendClipboard.move(xPad, y);
146 y += sendClipboard.height();
147 sendPrimary.move(xPad, y);
148 y += sendPrimary.height();
149
150 y += yPad*4;
151 misc.move(xPad, y);
152 y += misc.height();
153 shared.move(xPad, y);
154 y += shared.height();
155 fullScreen.move(xPad, y);
156 y += fullScreen.height();
157 useLocalCursor.move(xPad, y);
158 y += useLocalCursor.height();
159 dotWhenNoCursor.move(xPad, y);
160 y += dotWhenNoCursor.height();
161
Adam Tkace3cb0c32010-09-15 14:12:38 +0000162
163 /* Render "OK" and "Cancel" buttons */
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000164 okButton.move(width() - xPad*12 - cancelButton.width() - okButton.width(),
165 height() - yPad*4 - okButton.height());
166 cancelButton.move(width() - xPad*6 - cancelButton.width(),
167 height() - yPad*4 - cancelButton.height());
Adam Tkace3cb0c32010-09-15 14:12:38 +0000168
169 /* Render the second collumn */
170 y = yPad;
171 xPad += SECOND_COL_XPAD;
172
173 security.move(xPad, y);
174 y += security.height();
175 secVeNCrypt.move(xPad, y);
176 y += secVeNCrypt.height();
177
178 encryption.move(xPad, y);
179 y += encryption.height();
180 encNone.move(xPad, y);
181 y += encNone.height();
182 encTLS.move(xPad, y);
183 y += encTLS.height();
184 encX509.move(xPad, y);
185 y += encX509.height();
186 cacert.move(xPad, y);
187 y += cacert.height();
188 ca.move(xPad, y);
189 y += ca.height();
190 crlcert.move(xPad, y);
191 y += crlcert.height();
192 crl.move(xPad, y);
193 y += crl.height();
194
195 authentication.move(xPad, y);
196 y += authentication.height();
197 secNone.move(xPad, y);
198 y += secNone.height();
199 secVnc.move(xPad, y);
200 y += secVnc.height();
201 secPlain.move(xPad, y);
202 y += secPlain.height();
203
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000204 setBorderWidth(1);
205 }
206
207 virtual void initDialog() {
208 if (cb) cb->setOptions();
209 tight.disabled(autoSelect.checked());
210 zrle.disabled(autoSelect.checked());
211 hextile.disabled(autoSelect.checked());
212 raw.disabled(autoSelect.checked());
213 fullColour.disabled(autoSelect.checked());
214 mediumColour.disabled(autoSelect.checked());
215 lowColour.disabled(autoSelect.checked());
216 veryLowColour.disabled(autoSelect.checked());
217 sendPrimary.disabled(!sendClipboard.checked());
218 dotWhenNoCursor.disabled(!useLocalCursor.checked());
219 compressLevel.disabled(!customCompressLevel.checked());
Pierre Ossman78b23592009-03-12 12:25:11 +0000220 qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000221 }
222
223 virtual void takeFocus(Time time) {
224 //XSetInputFocus(dpy, entry.win, RevertToParent, time);
225 }
226
227 virtual void buttonActivate(TXButton* b) {
228 if (b == &okButton) {
229 if (cb) cb->getOptions();
230 unmap();
231 } else if (b == &cancelButton) {
232 unmap();
233 }
234 }
235
236 virtual void checkboxSelect(TXCheckbox* checkbox) {
237 if (checkbox == &autoSelect) {
238 tight.disabled(autoSelect.checked());
239 zrle.disabled(autoSelect.checked());
240 hextile.disabled(autoSelect.checked());
241 raw.disabled(autoSelect.checked());
242 fullColour.disabled(autoSelect.checked());
243 mediumColour.disabled(autoSelect.checked());
244 lowColour.disabled(autoSelect.checked());
245 veryLowColour.disabled(autoSelect.checked());
Pierre Ossman78b23592009-03-12 12:25:11 +0000246 qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000247 } else if (checkbox == &fullColour || checkbox == &mediumColour ||
248 checkbox == &lowColour || checkbox == &veryLowColour) {
249 fullColour.checked(checkbox == &fullColour);
250 mediumColour.checked(checkbox == &mediumColour);
251 lowColour.checked(checkbox == &lowColour);
252 veryLowColour.checked(checkbox == &veryLowColour);
253 } else if (checkbox == &tight || checkbox == &zrle || checkbox == &hextile || checkbox == &raw) {
254 tight.checked(checkbox == &tight);
255 zrle.checked(checkbox == &zrle);
256 hextile.checked(checkbox == &hextile);
257 raw.checked(checkbox == &raw);
258 } else if (checkbox == &sendClipboard) {
259 sendPrimary.disabled(!sendClipboard.checked());
260 } else if (checkbox == &useLocalCursor) {
261 dotWhenNoCursor.disabled(!useLocalCursor.checked());
262 } else if (checkbox == &customCompressLevel) {
263 compressLevel.disabled(!customCompressLevel.checked());
264 } else if (checkbox == &noJpeg) {
Pierre Ossman78b23592009-03-12 12:25:11 +0000265 qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000266 }
267 }
268
269 virtual void entryCallback(TXEntry* e, Detail detail, Time time) {
270 }
271
272 OptionsDialogCallback* cb;
273 TXLabel formatAndEnc, inputs, misc;
274 TXCheckbox autoSelect;
275 TXCheckbox fullColour, mediumColour, lowColour, veryLowColour;
276 TXCheckbox tight, zrle, hextile, raw;
277
278 TXCheckbox customCompressLevel; TXEntry compressLevel; TXLabel compressLevelLabel;
279 TXCheckbox noJpeg; TXEntry qualityLevel; TXLabel qualityLevelLabel;
280
281 TXCheckbox viewOnly, acceptClipboard, sendClipboard, sendPrimary;
282 TXCheckbox shared, fullScreen, useLocalCursor, dotWhenNoCursor;
283 TXButton okButton, cancelButton;
Adam Tkace3cb0c32010-09-15 14:12:38 +0000284
285 TXLabel security;
286 TXCheckbox secVeNCrypt;
287
288 TXLabel encryption;
289 TXCheckbox encNone, encTLS, encX509;
290 TXLabel cacert; TXEntry ca; TXLabel crlcert; TXEntry crl;
291
292 TXLabel authentication;
293 TXCheckbox secNone, secVnc, secPlain;
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000294};
295
296#endif