casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtLELEdit.qo.h
Go to the documentation of this file.
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   Bool isActive() { return active_;  }
00067  
00068  
00069  signals:
00070  
00071   void gotFocus(QFocusEvent* ev);
00072 
00073  
00074  public slots:
00075  
00076   virtual void  activate() {
00077     setPalette(activePalette_);
00078     active_ = True;  }
00079   
00080   virtual void deactivate() {
00081     setPalette(inactivePalette_);
00082     active_ = False;  }
00083   
00084    
00085   
00086  protected slots:
00087   
00088   virtual void focusInEvent(QFocusEvent* ev) {
00089     QLineEdit::focusInEvent(ev);
00090     activate();
00091     emit gotFocus(ev);  }
00092 
00093     
00094  protected:
00095  
00096   QPalette activePalette_;
00097   QPalette inactivePalette_;
00098   Bool active_;
00099      
00100 };
00101 
00102 
00103 
00104 } //# NAMESPACE CASA - END
00105 
00106 #endif