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