Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. // PasswdDialog.h
  20. //
  21. #ifndef __PASSWDDIALOG_H__
  22. #define __PASSWDDIALOG_H__
  23. #include "TXDialog.h"
  24. #include "TXLabel.h"
  25. #include "TXEntry.h"
  26. class PasswdDialog : public TXDialog, public TXEntryCallback {
  27. public:
  28. PasswdDialog(Display* dpy, const char* title, bool userDisabled)
  29. : TXDialog(dpy, 320, 100, title, true),
  30. userLabel(dpy, _("Username:"), this, 120),
  31. userEntry(dpy, this, this, false, 180),
  32. passwdLabel(dpy, _("Password:"), this, 120),
  33. passwdEntry(dpy, this, this, true, 180)
  34. {
  35. userLabel.move(0, 20);
  36. userEntry.move(userLabel.width(), 18);
  37. userEntry.disabled(userDisabled);
  38. passwdLabel.move(0, 60);
  39. passwdEntry.move(passwdLabel.width(), 58);
  40. }
  41. void takeFocus(Time time) {
  42. if (!userEntry.disabled())
  43. XSetInputFocus(dpy, userEntry.win(), RevertToParent, time);
  44. else
  45. XSetInputFocus(dpy, passwdEntry.win(), RevertToParent, time);
  46. }
  47. void entryCallback(TXEntry* e, Detail detail, Time time) {
  48. if (e == &userEntry) {
  49. if (detail == ENTER || detail == NEXT_FOCUS || detail == PREV_FOCUS)
  50. XSetInputFocus(dpy, passwdEntry.win(), RevertToParent, time);
  51. } else if (e == &passwdEntry) {
  52. if (detail == ENTER) {
  53. ok = true;
  54. done = true;
  55. } else if (detail == NEXT_FOCUS || detail == PREV_FOCUS) {
  56. XSetInputFocus(dpy, userEntry.win(), RevertToParent, time);
  57. }
  58. }
  59. }
  60. TXLabel userLabel;
  61. TXEntry userEntry;
  62. TXLabel passwdLabel;
  63. TXEntry passwdEntry;
  64. };
  65. #endif