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