You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OptionsDialog.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /* 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. #ifndef __OPTIONSDIALOG_H__
  22. #define __OPTIONSDIALOG_H__
  23. #include "TXDialog.h"
  24. #include "TXLabel.h"
  25. #include "TXEntry.h"
  26. #include "TXButton.h"
  27. #include "TXCheckbox.h"
  28. #include "parameters.h"
  29. #define SECOND_COL_XPAD 350
  30. class OptionsDialogCallback {
  31. public:
  32. virtual void setOptions() = 0;
  33. virtual void getOptions() = 0;
  34. };
  35. class OptionsDialog : public TXDialog, public TXButtonCallback,
  36. public TXCheckboxCallback, public TXEntryCallback {
  37. public:
  38. OptionsDialog(Display* dpy, OptionsDialogCallback* cb_)
  39. : TXDialog(dpy, 450, 450, _("VNC Viewer: Connection Options")), cb(cb_),
  40. /* Encoding and color level */
  41. formatAndEnc(dpy, _("Encoding and Color Level:"), this),
  42. inputs(dpy, _("Inputs:"), this),
  43. misc(dpy, _("Misc:"), this),
  44. autoSelect(dpy, _("Auto select"), this, false, this),
  45. fullColour(dpy, _("Full (all available colors)"), this, true, this),
  46. mediumColour(dpy, _("Medium (256 colors)"), this, true, this),
  47. lowColour(dpy, _("Low (64 colors)"), this, true, this),
  48. veryLowColour(dpy, _("Very low (8 colors)"), this, true, this),
  49. tight(dpy, "Tight", this, true, this),
  50. zrle(dpy, "ZRLE", this, true, this),
  51. hextile(dpy, "Hextile", this, true, this),
  52. raw(dpy, "Raw", this, true, this),
  53. /* Compression */
  54. customCompressLevel(dpy, _("Custom compression level:"), this, false, this),
  55. compressLevel(dpy, this, this, false, 30),
  56. compressLevelLabel(dpy, _("level (1=fast, 9=best)"), this),
  57. noJpeg(dpy, _("Allow JPEG compression:"), this, false, this),
  58. qualityLevel(dpy, this, this, false, 30),
  59. qualityLevelLabel(dpy, _("quality (1=poor, 9=best)"), this),
  60. /* Inputs */
  61. viewOnly(dpy, _("View only (ignore mouse & keyboard)"), this, false, this),
  62. acceptClipboard(dpy, _("Accept clipboard from server"), this, false, this),
  63. sendClipboard(dpy, _("Send clipboard to server"), this, false, this),
  64. sendPrimary(dpy, _("Send primary selection & cut buffer as clipboard"),
  65. this, false, this),
  66. /* Misc */
  67. shared(dpy, _("Shared (don't disconnect other viewers)"), this, false,this),
  68. fullScreen(dpy, _("Full-screen mode"), this, false, this),
  69. useLocalCursor(dpy, _("Render cursor locally"), this, false, this),
  70. dotWhenNoCursor(dpy, _("Show dot when no cursor"), this, false, this),
  71. okButton(dpy, _("OK"), this, this, 60),
  72. cancelButton(dpy, _("Cancel"), this, this, 60)
  73. #ifdef HAVE_GNUTLS
  74. ,
  75. /* Security */
  76. security(dpy, _("Security:"), this),
  77. secVeNCrypt(dpy, _("Extended encryption and authentication methods (VeNCrypt)"),
  78. this, false, this),
  79. /* Encryption */
  80. encryption(dpy, _("Session encryption:"), this),
  81. encNone(dpy, _("None"), this, false, this),
  82. encTLS(dpy, _("TLS with anonymous certificates"), this, false, this),
  83. encX509(dpy, _("TLS with X509 certificates"), this, false, this),
  84. cacert(dpy, _("Path to X509 CA certificate"), this),
  85. ca(dpy, this, this, false, 350),
  86. crlcert(dpy, _("Path to X509 CRL file"), this),
  87. crl(dpy, this, this, false, 350),
  88. /* Authentication */
  89. authentication(dpy, _("Authentication:"), this),
  90. secNone(dpy, _("None"), this, false, this),
  91. secVnc(dpy, _("Standard VNC (insecure without encryption)"),
  92. this, false, this),
  93. secPlain(dpy, _("Username and password (insecure without encryption)"),
  94. this, false, this)
  95. #endif
  96. {
  97. /* Render the first collumn */
  98. int y = yPad;
  99. formatAndEnc.move(xPad, y);
  100. y += formatAndEnc.height();
  101. autoSelect.move(xPad, y);
  102. int x2 = xPad + autoSelect.width() + xPad*5;
  103. y += autoSelect.height();
  104. tight.move(xPad, y);
  105. fullColour.move(x2, y);
  106. y += tight.height();
  107. zrle.move(xPad, y);
  108. mediumColour.move(x2, y);
  109. y += zrle.height();
  110. hextile.move(xPad, y);
  111. lowColour.move(x2, y);
  112. y += hextile.height();
  113. raw.move(xPad, y);
  114. veryLowColour.move(x2, y);
  115. y += raw.height() + yPad*2;
  116. customCompressLevel.move(xPad, y);
  117. y += customCompressLevel.height();
  118. compressLevel.move(xPad*10, y);
  119. compressLevelLabel.move(xPad*20, y);
  120. y += compressLevel.height();
  121. noJpeg.move(xPad, y);
  122. y += noJpeg.height();
  123. qualityLevel.move(xPad*10, y);
  124. qualityLevelLabel.move(xPad*20, y);
  125. y += qualityLevel.height();
  126. y += yPad*4;
  127. inputs.move(xPad, y);
  128. y += inputs.height();
  129. viewOnly.move(xPad, y);
  130. y += viewOnly.height();
  131. acceptClipboard.move(xPad, y);
  132. y += acceptClipboard.height();
  133. sendClipboard.move(xPad, y);
  134. y += sendClipboard.height();
  135. sendPrimary.move(xPad, y);
  136. y += sendPrimary.height();
  137. y += yPad*4;
  138. misc.move(xPad, y);
  139. y += misc.height();
  140. shared.move(xPad, y);
  141. y += shared.height();
  142. fullScreen.move(xPad, y);
  143. y += fullScreen.height();
  144. useLocalCursor.move(xPad, y);
  145. y += useLocalCursor.height();
  146. dotWhenNoCursor.move(xPad, y);
  147. y += dotWhenNoCursor.height();
  148. #ifdef HAVE_GNUTLS
  149. /* Render the second collumn */
  150. y = yPad;
  151. xPad += SECOND_COL_XPAD;
  152. resize(750, height());
  153. security.move(xPad, y);
  154. y += security.height();
  155. secVeNCrypt.move(xPad, y);
  156. y += secVeNCrypt.height();
  157. encryption.move(xPad, y);
  158. y += encryption.height();
  159. encNone.move(xPad, y);
  160. y += encNone.height();
  161. encTLS.move(xPad, y);
  162. y += encTLS.height();
  163. encX509.move(xPad, y);
  164. y += encX509.height();
  165. cacert.move(xPad, y);
  166. y += cacert.height();
  167. ca.move(xPad, y);
  168. y += ca.height();
  169. crlcert.move(xPad, y);
  170. y += crlcert.height();
  171. crl.move(xPad, y);
  172. y += crl.height();
  173. authentication.move(xPad, y);
  174. y += authentication.height();
  175. secNone.move(xPad, y);
  176. y += secNone.height();
  177. secVnc.move(xPad, y);
  178. y += secVnc.height();
  179. secPlain.move(xPad, y);
  180. y += secPlain.height();
  181. xPad -= SECOND_COL_XPAD;
  182. #endif
  183. /* Render "OK" and "Cancel" buttons */
  184. okButton.move(width() - xPad*12 - cancelButton.width() - okButton.width(),
  185. height() - yPad*4 - okButton.height());
  186. cancelButton.move(width() - xPad*6 - cancelButton.width(),
  187. height() - yPad*4 - cancelButton.height());
  188. setBorderWidth(1);
  189. }
  190. virtual void initDialog() {
  191. if (cb) cb->setOptions();
  192. tight.disabled(autoSelect.checked());
  193. zrle.disabled(autoSelect.checked());
  194. hextile.disabled(autoSelect.checked());
  195. raw.disabled(autoSelect.checked());
  196. fullColour.disabled(autoSelect.checked());
  197. mediumColour.disabled(autoSelect.checked());
  198. lowColour.disabled(autoSelect.checked());
  199. veryLowColour.disabled(autoSelect.checked());
  200. sendPrimary.disabled(!sendClipboard.checked());
  201. dotWhenNoCursor.disabled(!useLocalCursor.checked());
  202. compressLevel.disabled(!customCompressLevel.checked());
  203. qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
  204. }
  205. virtual void takeFocus(Time time) {
  206. //XSetInputFocus(dpy, entry.win, RevertToParent, time);
  207. }
  208. virtual void buttonActivate(TXButton* b) {
  209. if (b == &okButton) {
  210. if (cb) cb->getOptions();
  211. unmap();
  212. } else if (b == &cancelButton) {
  213. unmap();
  214. }
  215. }
  216. virtual void checkboxSelect(TXCheckbox* checkbox) {
  217. if (checkbox == &autoSelect) {
  218. tight.disabled(autoSelect.checked());
  219. zrle.disabled(autoSelect.checked());
  220. hextile.disabled(autoSelect.checked());
  221. raw.disabled(autoSelect.checked());
  222. fullColour.disabled(autoSelect.checked());
  223. mediumColour.disabled(autoSelect.checked());
  224. lowColour.disabled(autoSelect.checked());
  225. veryLowColour.disabled(autoSelect.checked());
  226. qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
  227. } else if (checkbox == &fullColour || checkbox == &mediumColour ||
  228. checkbox == &lowColour || checkbox == &veryLowColour) {
  229. fullColour.checked(checkbox == &fullColour);
  230. mediumColour.checked(checkbox == &mediumColour);
  231. lowColour.checked(checkbox == &lowColour);
  232. veryLowColour.checked(checkbox == &veryLowColour);
  233. } else if (checkbox == &tight || checkbox == &zrle || checkbox == &hextile || checkbox == &raw) {
  234. tight.checked(checkbox == &tight);
  235. zrle.checked(checkbox == &zrle);
  236. hextile.checked(checkbox == &hextile);
  237. raw.checked(checkbox == &raw);
  238. } else if (checkbox == &sendClipboard) {
  239. sendPrimary.disabled(!sendClipboard.checked());
  240. } else if (checkbox == &useLocalCursor) {
  241. dotWhenNoCursor.disabled(!useLocalCursor.checked());
  242. } else if (checkbox == &customCompressLevel) {
  243. compressLevel.disabled(!customCompressLevel.checked());
  244. } else if (checkbox == &noJpeg) {
  245. qualityLevel.disabled(autoSelect.checked() || !noJpeg.checked());
  246. #ifdef HAVE_GNUTLS
  247. } else if (checkbox == &secVeNCrypt) {
  248. encTLS.checked(false);
  249. encTLS.disabled(!secVeNCrypt.checked());
  250. encX509.checked(false);
  251. encX509.disabled(!secVeNCrypt.checked());
  252. secPlain.checked(false);
  253. secPlain.disabled(!secVeNCrypt.checked());
  254. #endif
  255. }
  256. }
  257. virtual void entryCallback(TXEntry* e, Detail detail, Time time) {
  258. }
  259. OptionsDialogCallback* cb;
  260. TXLabel formatAndEnc, inputs, misc;
  261. TXCheckbox autoSelect;
  262. TXCheckbox fullColour, mediumColour, lowColour, veryLowColour;
  263. TXCheckbox tight, zrle, hextile, raw;
  264. TXCheckbox customCompressLevel; TXEntry compressLevel; TXLabel compressLevelLabel;
  265. TXCheckbox noJpeg; TXEntry qualityLevel; TXLabel qualityLevelLabel;
  266. TXCheckbox viewOnly, acceptClipboard, sendClipboard, sendPrimary;
  267. TXCheckbox shared, fullScreen, useLocalCursor, dotWhenNoCursor;
  268. TXButton okButton, cancelButton;
  269. #ifdef HAVE_GNUTLS
  270. TXLabel security;
  271. TXCheckbox secVeNCrypt;
  272. TXLabel encryption;
  273. TXCheckbox encNone, encTLS, encX509;
  274. TXLabel cacert; TXEntry ca; TXLabel crlcert; TXEntry crl;
  275. TXLabel authentication;
  276. TXCheckbox secNone, secVnc, secPlain;
  277. #endif
  278. };
  279. #endif