casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PlotMSTab.qo.h
Go to the documentation of this file.
00001 //# PlotMSTabs.qo.h: Tab GUI widgets.
00002 //# Copyright (C) 2009
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 #ifndef PLOTMSTABS_QO_H_
00028 #define PLOTMSTABS_QO_H_
00029 
00030 #include <casa/BasicSL/String.h>
00031 #include <plotms/PlotMS/PlotMSWatchedParameters.h>
00032 
00033 #include <QComboBox>
00034 #include <QLabel>
00035 #include <QList>
00036 #include <QToolButton>
00037 #include <QGroupBox>
00038 
00039 #include <casa/namespace.h>
00040 
00041 namespace casa {
00042 
00043 //# Forward declarations
00044 class PlotMSApp;
00045 class PlotMSPlotter;
00046 
00047 
00048 // Abstract parent for any widget that goes in the tabbed side panel of the
00049 // PlotMSPlotter.
00050 class PlotMSTab : public QWidget, public PlotMSParametersWatcher {
00051     Q_OBJECT
00052     
00053 public:
00054     // Static //
00055     
00056     // Convenience methods for setting the current value of the given QComboBox
00057     // to the given.
00058     // <group>
00059     static bool setChooser(QComboBox* chooser, const QString& value);
00060     static bool setChooser(QComboBox* chooser, const String& value) {
00061         QString str(value.c_str());
00062         return setChooser(chooser, str); }
00063     static bool setChooser(QComboBox* chooser, const char* value) {
00064         QString str(value);
00065         return setChooser(chooser, str); }
00066     // </group>
00067     
00068     
00069     // Non-Static //
00070     
00071     // Constructor that takes the parent plotter for this tab.
00072     PlotMSTab(PlotMSPlotter* parent);
00073     
00074     // Destructor.
00075     virtual ~PlotMSTab();
00076     
00077     
00078     // Returns a string to use as the tab name for this widget.
00079     virtual QString tabName() const = 0;
00080     
00081     // Returns all tool buttons on this tab.
00082     virtual QList<QToolButton*> toolButtons() const {
00083         return QList<QToolButton*>(); }
00084     
00085     // Sets up the tab for the given maximum width.
00086     virtual void setupForMaxWidth(int maxWidth) { (void)maxWidth; }
00087     
00088 protected:
00089     // Parent.
00090     PlotMSApp* itsParent_;
00091     
00092     // Plotter.
00093     PlotMSPlotter* itsPlotter_;
00094     
00095     // Default text for labels, so that they can be easily switched to red or
00096     // normal depending on whether the item has changed or not.
00097     QMap<QLabel*, QString> itsLabelDefaults_;
00098     
00099     
00100     // These alter the displayed text of 
00101     // Some widget types have a .title not a .text, and there's no
00102     // Qt4 abstract class that encompasses all types that do have .text,
00103     // so we overload highlightWidgetText for several classes.
00104     // Note that the Button version is meant for QCheckBox and QRadioButton,
00105     // and probably isn't as useful for pushbuttons.
00106     // Note: was formerly named changedText(). Name and purpose was unclear.
00107     // <group>
00108     void highlightWidgetText(QLabel* label,  bool highlight);
00109     void highlightWidgetText(QGroupBox *box,  bool highlight);
00110     void highlightWidgetText(QAbstractButton *but,  bool highlight);
00111     // </group>
00112     
00113     
00114     // Returns the given text altered with HTML tags for highlighting,
00115     // meant to be assigned to a Qt widget's title or similar property.
00116     // If highlight is false, the text is returned stripped of any HTML.
00117     // If highlighted, the text is made red using a <font> tag.
00118     // <group>
00119     static QString highlightifyText(const QString& text, bool highlight);
00120     
00121     // Variation taking a casacore String.
00122     static QString highlightifyText(const String& text, bool changed)  {
00123         QString str(text.c_str());
00124         return highlightifyText(str, changed); }
00125         
00126     // Variation of highlightifyText taking plain C-style text.
00127     static QString highlightifyText(const char* text, bool changed)  {
00128         QString str(text);
00129         return highlightifyText(str, changed); }
00130         
00131 
00132       
00133     // </group>
00134 };
00135 
00136 }
00137 
00138 #endif /* PLOTMSTABS_QO_H_ */