00001 //# QtLEL.qo.h: Helper class for viewer data manager widget (QtDataManager). 00002 //# Copyright (C) 2005 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef QTLELEDIT_H 00029 #define QTLELEDIT_H 00030 00031 #include <casa/aips.h> 00032 00033 #include <graphics/X11/X_enter.h> 00034 # include <QLineEdit> 00035 # include <QColor> 00036 #include <graphics/X11/X_exit.h> 00037 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 00042 class QtLELEdit : public QLineEdit { 00043 //# Used within QtDataManager's designer-created gui (QtDataManager.ui[.h]). 00044 //# A QLineEdit which also signals whenever it gets focus. 00045 00046 Q_OBJECT 00047 00048 00049 public: 00050 00051 QtLELEdit(QWidget* parent=0) : QLineEdit(parent) { 00052 00053 inactivePalette_ = activePalette_ = palette(); 00054 00055 //# The inactive pallette shows text in the 'disabled' color, even 00056 //# if the edit widget is not really disabled. This is to provide 00057 //# feedback that the LEL expression is / is not being used. 00058 00059 QColor dsbldText = palette().color(QPalette::Disabled, QPalette::Text); 00060 inactivePalette_.setColor(QPalette::Active, QPalette::Text, dsbldText); 00061 inactivePalette_.setColor(QPalette::Inactive, QPalette::Text, dsbldText); 00062 00063 deactivate(); 00064 } 00065 00066 00067 Bool isActive() { 00068 return active_; 00069 } 00070 00071 00072 signals: 00073 00074 void gotFocus(QFocusEvent* ev); 00075 00076 00077 public slots: 00078 00079 virtual void activate() { 00080 setPalette(activePalette_); 00081 active_ = True; 00082 } 00083 00084 virtual void deactivate() { 00085 setPalette(inactivePalette_); 00086 active_ = False; 00087 } 00088 00089 00090 00091 protected slots: 00092 00093 virtual void focusInEvent(QFocusEvent* ev) { 00094 QLineEdit::focusInEvent(ev); 00095 activate(); 00096 emit gotFocus(ev); 00097 } 00098 00099 00100 protected: 00101 00102 QPalette activePalette_; 00103 QPalette inactivePalette_; 00104 Bool active_; 00105 00106 }; 00107 00108 00109 00110 } //# NAMESPACE CASA - END 00111 00112 #endif