casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtLELEdit.qo.h
Go to the documentation of this file.
1 //# QtLEL.qo.h: Helper class for viewer data manager widget (QtDataManager).
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef QTLELEDIT_H
29 #define QTLELEDIT_H
30 
31 #include <casa/aips.h>
32 
33 #include <graphics/X11/X_enter.h>
34 # include <QLineEdit>
35 # include <QColor>
36 #include <graphics/X11/X_exit.h>
37 
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41 
42  class QtLELEdit : public QLineEdit {
43  //# Used within QtDataManager's designer-created gui (QtDataManager.ui[.h]).
44  //# A QLineEdit which also signals whenever it gets focus.
45 
46  Q_OBJECT
47 
48 
49  public:
50 
51  QtLELEdit(QWidget* parent=0) : QLineEdit(parent) {
52 
53  inactivePalette_ = activePalette_ = palette();
54 
55  //# The inactive pallette shows text in the 'disabled' color, even
56  //# if the edit widget is not really disabled. This is to provide
57  //# feedback that the LEL expression is / is not being used.
58 
59  QColor dsbldText = palette().color(QPalette::Disabled, QPalette::Text);
60  inactivePalette_.setColor(QPalette::Active, QPalette::Text, dsbldText);
61  inactivePalette_.setColor(QPalette::Inactive, QPalette::Text, dsbldText);
62 
63  deactivate();
64  }
65 
66 
67  bool isActive() {
68  return active_;
69  }
70 
71 
72  signals:
73 
74  void gotFocus(QFocusEvent* ev);
75 
76 
77  public slots:
78 
79  virtual void activate() {
80  setPalette(activePalette_);
81  active_ = true;
82  }
83 
84  virtual void deactivate() {
85  setPalette(inactivePalette_);
86  active_ = false;
87  }
88 
89 
90 
91  protected slots:
92 
93  virtual void focusInEvent(QFocusEvent* ev) {
94  QLineEdit::focusInEvent(ev);
95  activate();
96  emit gotFocus(ev);
97  }
98 
99 
100  protected:
101 
102  QPalette activePalette_;
104  bool active_;
105 
106  };
107 
108 
109 
110 } //# NAMESPACE CASA - END
111 
112 #endif
virtual void deactivate()
Definition: QtLELEdit.qo.h:84
QPalette inactivePalette_
Definition: QtLELEdit.qo.h:103
virtual void activate()
Definition: QtLELEdit.qo.h:79
virtual void focusInEvent(QFocusEvent *ev)
Definition: QtLELEdit.qo.h:93
QPalette activePalette_
Definition: QtLELEdit.qo.h:102
QtLELEdit(QWidget *parent=0)
Definition: QtLELEdit.qo.h:51
void gotFocus(QFocusEvent *ev)