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 | // ServerDialog.h |
| 20 | // |
| 21 | |
| 22 | #ifndef __SERVERDIALOG_H__ |
| 23 | #define __SERVERDIALOG_H__ |
| 24 | |
| 25 | #include "TXDialog.h" |
| 26 | #include "TXLabel.h" |
| 27 | #include "TXEntry.h" |
| 28 | #include "TXButton.h" |
| 29 | #include "OptionsDialog.h" |
| 30 | #include "AboutDialog.h" |
| 31 | |
| 32 | class ServerDialog : public TXDialog, public TXEntryCallback, |
| 33 | public TXButtonCallback { |
| 34 | public: |
| 35 | ServerDialog(Display* dpy, OptionsDialog* options_, AboutDialog* about_) |
| 36 | : TXDialog(dpy, 355, 120, _("VNC Viewer: Connection Details"), true), |
| 37 | label(dpy, _("VNC server:"), this, 100), |
| 38 | entry(dpy, this, this, false, 180), |
| 39 | aboutButton(dpy, _("About..."), this, this, 70), |
| 40 | optionsButton(dpy, _("Options..."), this, this, 70), |
| 41 | okButton(dpy, _("OK"), this, this, 70), |
| 42 | cancelButton(dpy, _("Cancel"), this, this, 70), |
| 43 | options(options_), about(about_) |
| 44 | { |
| 45 | label.move(0, 30); |
| 46 | entry.move(label.width(), 28); |
| 47 | int x = width(); |
| 48 | int y = height() - yPad*4 - cancelButton.height(); |
| 49 | x -= cancelButton.width() + xPad*4; |
| 50 | cancelButton.move(x, y); |
| 51 | x -= okButton.width() + xPad*4; |
| 52 | okButton.move(x, y); |
| 53 | x -= optionsButton.width() + xPad*4; |
| 54 | optionsButton.move(x, y); |
| 55 | x -= aboutButton.width() + xPad*4; |
| 56 | aboutButton.move(x, y); |
| 57 | } |
| 58 | |
| 59 | virtual void takeFocus(Time time) { |
| 60 | XSetInputFocus(dpy, entry.win(), RevertToParent, time); |
| 61 | } |
| 62 | |
| 63 | virtual void entryCallback(TXEntry* e, Detail detail, Time time) { |
| 64 | if (detail == ENTER) { |
| 65 | ok = true; |
| 66 | done = true; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | virtual void buttonActivate(TXButton* b) { |
| 71 | if (b == &okButton) { |
| 72 | ok = true; |
| 73 | done = true; |
| 74 | } else if (b == &cancelButton) { |
| 75 | ok = false; |
| 76 | done = true; |
| 77 | } else if (b == &optionsButton) { |
| 78 | options->show(); |
| 79 | } else if (b == &aboutButton) { |
| 80 | about->show(); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | TXLabel label; |
| 85 | TXEntry entry; |
| 86 | TXButton aboutButton, optionsButton, okButton, cancelButton; |
| 87 | OptionsDialog* options; |
| 88 | AboutDialog* about; |
| 89 | }; |
| 90 | |
| 91 | #endif |