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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* Copyright (C) 2002-2003 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. class OptionsDialogCallback {
  30. public:
  31. virtual void setOptions() = 0;
  32. virtual void getOptions() = 0;
  33. };
  34. class OptionsDialog : public TXDialog, public TXButtonCallback,
  35. public TXCheckboxCallback, public TXEntryCallback {
  36. public:
  37. OptionsDialog(Display* dpy, OptionsDialogCallback* cb_)
  38. : TXDialog(dpy, 400, 450, "VNC Viewer: Connection Options"), cb(cb_),
  39. formatAndEnc(dpy, "Encoding and Color Level:", this),
  40. inputs(dpy, "Inputs:", this),
  41. misc(dpy, "Misc:", this),
  42. autoSelect(dpy, "Auto select", this, false, this),
  43. fullColour(dpy, "Full (all available colors)", this, true, this),
  44. mediumColour(dpy, "Medium (256 colors)", this, true, this),
  45. lowColour(dpy, "Low (64 colors)", this, true, this),
  46. veryLowColour(dpy, "Very low (8 colors)", this, true, this),
  47. tight(dpy, "Tight", this, true, this),
  48. zrle(dpy, "ZRLE", this, true, this),
  49. hextile(dpy, "Hextile", this, true, this),
  50. raw(dpy, "Raw", this, true, this),
  51. customCompressLevel(dpy, "Custom compression level:", this, false, this),
  52. compressLevel(dpy, this, this, false, 30),
  53. compressLevelLabel(dpy, "level (1=fast, 9=best)", this),
  54. noJpeg(dpy, "Allow JPEG compression:", this, false, this),
  55. qualityLevel(dpy, this, this, false, 30),
  56. qualityLevelLabel(dpy, "quality (1=poor, 9=best)", this),
  57. viewOnly(dpy, "View only (ignore mouse & keyboard)", this, false, this),
  58. acceptClipboard(dpy, "Accept clipboard from server", this, false, this),
  59. sendClipboard(dpy, "Send clipboard to server", this, false, this),
  60. sendPrimary(dpy, "Send primary selection & cut buffer as clipboard",
  61. this, false, this),
  62. shared(dpy, "Shared (don't disconnect other viewers)", this, false,this),
  63. fullScreen(dpy, "Full-screen mode", this, false, this),
  64. useLocalCursor(dpy, "Render cursor locally", this, false, this),
  65. dotWhenNoCursor(dpy, "Show dot when no cursor", this, false, this),
  66. okButton(dpy, "OK", this, this, 60),
  67. cancelButton(dpy, "Cancel", this, this, 60)
  68. {
  69. int y = yPad;
  70. formatAndEnc.move(xPad, y);
  71. y += formatAndEnc.height();
  72. autoSelect.move(xPad, y);
  73. int x2 = xPad + autoSelect.width() + xPad*5;
  74. y += autoSelect.height();
  75. tight.move(xPad, y);
  76. fullColour.move(x2, y);
  77. y += tight.height();
  78. zrle.move(xPad, y);
  79. mediumColour.move(x2, y);
  80. y += zrle.height();
  81. hextile.move(xPad, y);
  82. lowColour.move(x2, y);
  83. y += hextile.height();
  84. raw.move(xPad, y);
  85. veryLowColour.move(x2, y);
  86. y += raw.height() + yPad*2;
  87. customCompressLevel.move(xPad, y);
  88. y += customCompressLevel.height();
  89. compressLevel.move(xPad*10, y);
  90. compressLevelLabel.move(xPad*20, y);
  91. y += compressLevel.height();
  92. noJpeg.move(xPad, y);
  93. y += noJpeg.height();
  94. qualityLevel.move(xPad*10, y);
  95. qualityLevelLabel.move(xPad*20, y);
  96. y += qualityLevel.height();
  97. y += yPad*4;
  98. inputs.move(xPad, y);
  99. y += inputs.height();
  100. viewOnly.move(xPad, y);
  101. y += viewOnly.height();
  102. acceptClipboard.move(xPad, y);
  103. y += acceptClipboard.height();
  104. sendClipboard.move(xPad, y);
  105. y += sendClipboard.height();
  106. sendPrimary.move(xPad, y);
  107. y += sendPrimary.height();
  108. y += yPad*4;
  109. misc.move(xPad, y);
  110. y += misc.height();
  111. shared.move(xPad, y);
  112. y += shared.height();
  113. fullScreen.move(xPad, y);
  114. y += fullScreen.height();
  115. useLocalCursor.move(xPad, y);
  116. y += useLocalCursor.height();
  117. dotWhenNoCursor.move(xPad, y);
  118. y += dotWhenNoCursor.height();
  119. okButton.move(width() - xPad*12 - cancelButton.width() - okButton.width(),
  120. height() - yPad*4 - okButton.height());
  121. cancelButton.move(width() - xPad*6 - cancelButton.width(),
  122. height() - yPad*4 - cancelButton.height());
  123. setBorderWidth(1);
  124. }
  125. virtual void initDialog() {
  126. if (cb) cb->setOptions();
  127. tight.disabled(autoSelect.checked());
  128. zrle.disabled(autoSelect.checked());
  129. hextile.disabled(autoSelect.checked());
  130. raw.disabled(autoSelect.checked());
  131. fullColour.disabled(autoSelect.checked());
  132. mediumColour.disabled(autoSelect.checked());
  133. lowColour.disabled(autoSelect.checked());
  134. veryLowColour.disabled(autoSelect.checked());
  135. sendPrimary.disabled(!sendClipboard.checked());
  136. dotWhenNoCursor.disabled(!useLocalCursor.checked());
  137. compressLevel.disabled(!customCompressLevel.checked());
  138. qualityLevel.disabled(!noJpeg.checked());
  139. }
  140. virtual void takeFocus(Time time) {
  141. //XSetInputFocus(dpy, entry.win, RevertToParent, time);
  142. }
  143. virtual void buttonActivate(TXButton* b) {
  144. if (b == &okButton) {
  145. if (cb) cb->getOptions();
  146. unmap();
  147. } else if (b == &cancelButton) {
  148. unmap();
  149. }
  150. }
  151. virtual void checkboxSelect(TXCheckbox* checkbox) {
  152. if (checkbox == &autoSelect) {
  153. tight.disabled(autoSelect.checked());
  154. zrle.disabled(autoSelect.checked());
  155. hextile.disabled(autoSelect.checked());
  156. raw.disabled(autoSelect.checked());
  157. fullColour.disabled(autoSelect.checked());
  158. mediumColour.disabled(autoSelect.checked());
  159. lowColour.disabled(autoSelect.checked());
  160. veryLowColour.disabled(autoSelect.checked());
  161. } else if (checkbox == &fullColour || checkbox == &mediumColour ||
  162. checkbox == &lowColour || checkbox == &veryLowColour) {
  163. fullColour.checked(checkbox == &fullColour);
  164. mediumColour.checked(checkbox == &mediumColour);
  165. lowColour.checked(checkbox == &lowColour);
  166. veryLowColour.checked(checkbox == &veryLowColour);
  167. } else if (checkbox == &tight || checkbox == &zrle || checkbox == &hextile || checkbox == &raw) {
  168. tight.checked(checkbox == &tight);
  169. zrle.checked(checkbox == &zrle);
  170. hextile.checked(checkbox == &hextile);
  171. raw.checked(checkbox == &raw);
  172. } else if (checkbox == &sendClipboard) {
  173. sendPrimary.disabled(!sendClipboard.checked());
  174. } else if (checkbox == &useLocalCursor) {
  175. dotWhenNoCursor.disabled(!useLocalCursor.checked());
  176. } else if (checkbox == &customCompressLevel) {
  177. compressLevel.disabled(!customCompressLevel.checked());
  178. } else if (checkbox == &noJpeg) {
  179. qualityLevel.disabled(!noJpeg.checked());
  180. }
  181. }
  182. virtual void entryCallback(TXEntry* e, Detail detail, Time time) {
  183. }
  184. OptionsDialogCallback* cb;
  185. TXLabel formatAndEnc, inputs, misc;
  186. TXCheckbox autoSelect;
  187. TXCheckbox fullColour, mediumColour, lowColour, veryLowColour;
  188. TXCheckbox tight, zrle, hextile, raw;
  189. TXCheckbox customCompressLevel; TXEntry compressLevel; TXLabel compressLevelLabel;
  190. TXCheckbox noJpeg; TXEntry qualityLevel; TXLabel qualityLevelLabel;
  191. TXCheckbox viewOnly, acceptClipboard, sendClipboard, sendPrimary;
  192. TXCheckbox shared, fullScreen, useLocalCursor, dotWhenNoCursor;
  193. TXButton okButton, cancelButton;
  194. };
  195. #endif