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 namespace casa { 00040 00041 //# Forward declarations 00042 class PlotMSApp; 00043 class PlotMSPlotter; 00044 00045 00046 // Abstract parent for any widget that goes in the tabbed side panel of the 00047 // PlotMSPlotter. 00048 class PlotMSTab : public QWidget, public PlotMSParametersWatcher { 00049 Q_OBJECT 00050 00051 public: 00052 // Static // 00053 00054 // Convenience methods for setting the current value of the given QComboBox 00055 // to the given. 00056 // <group> 00057 static bool setChooser(QComboBox* chooser, const QString& value); 00058 static bool setChooser(QComboBox* chooser, const String& value) { 00059 QString str(value.c_str()); 00060 return setChooser(chooser, str); } 00061 static bool setChooser(QComboBox* chooser, const char* value) { 00062 QString str(value); 00063 return setChooser(chooser, str); } 00064 // </group> 00065 00066 00067 // Non-Static // 00068 00069 // Constructor that takes the parent plotter for this tab. 00070 PlotMSTab(PlotMSPlotter* parent); 00071 00072 // Destructor. 00073 virtual ~PlotMSTab(); 00074 00075 00076 // Returns a string to use as the tab name for this widget. 00077 virtual QString tabName() const = 0; 00078 00079 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_ */