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.

ServerDialog.h 2.7KB

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