]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/Qt2BC.C
various fixes
[lyx.git] / src / frontends / qt2 / Qt2BC.C
1 /**
2  * \file Qt2BC.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Allan Rae <rae@lyx.org>
7  * \author Angus Leeming <a.leeming@ic.ac.uk>
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "Qt2BC.h"
17 #include "debug.h"
18
19 #include <qbutton.h>
20 #include <qlineedit.h>
21
22 Qt2BC::Qt2BC(string const & cancel, string const & close)
23         : GuiBC<QButton, QWidget>(cancel, close)
24 {}
25
26
27 void Qt2BC::setButtonEnabled(QButton * obj, bool enabled)
28 {
29         lyxerr << "Qt2BC: setting button " 
30                 << obj << " to " << enabled << std::endl;
31  
32         obj->setEnabled(enabled);
33 }
34
35
36 void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled)
37 {
38         lyxerr << "Qt2BC: setting " 
39                 << obj << " to " << enabled << std::endl;
40  
41         // yuck, rtti, but the user comes first
42         if (obj->inherits("QLineEdit")) {
43                 QLineEdit * le(static_cast<QLineEdit*>(obj)); 
44                 le->setReadOnly(enabled);
45         } else {
46                 obj->setEnabled(enabled);
47         }
48  
49         QWidget::FocusPolicy const p =
50                 (enabled) ? QWidget::StrongFocus : QWidget::NoFocus; 
51         obj->setFocusPolicy(p);
52 }
53
54
55 void Qt2BC::setButtonLabel(QButton * obj, string const & label)
56 {
57         obj->setText(label.c_str());
58 }