PlotPanel.h

Go to the documentation of this file.
00001 //# PlotPanel.h: Custom plot panels and buttons.
00002 //# Copyright (C) 2008
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 PLOTPANEL_H_
00028 #define PLOTPANEL_H_
00029 
00030 #include <graphics/GenericPlotter/PlotEventHandler.h>
00031 
00032 namespace casa {
00033 
00034 // Abstract superclass for any widget that goes on a PlotPanel.
00035 class PlotWidget {
00036 public:
00037     // Constructor.
00038     PlotWidget() { }
00039     
00040     // Destructor.
00041     virtual ~PlotWidget() { }
00042     
00043     // Returns true if the widget is currently enabled, false otherwise.
00044     // A widget button should be grayed out or not interact-able.
00045     virtual bool isEnabled() const = 0;
00046     
00047     // Enables/disables the widget.
00048     virtual void setEnabled(bool enabled = true) = 0;
00049     
00050     // Returns true if the widget is currently visible.
00051     virtual bool isVisible() const = 0;
00052     
00053     // Show/hide the widget.
00054     virtual void setVisible(bool visible = true) = 0;
00055     
00056     // Returns the tooltip for this widget.
00057     virtual String tooltip() const = 0;
00058     
00059     // Sets the tooltip for this widget.
00060     virtual void setTooltip(const String& text) = 0;
00061 };
00062 typedef CountedPtr<PlotWidget> PlotWidgetPtr;
00063 
00064 
00065 // Generic class for a button that goes on a PlotPanel.  A button has
00066 // properties that can be set, as well as registration for event
00067 // handlers.  A button can only be seen/interacted with on a PlotPanel.
00068 class PlotButton : public virtual PlotWidget {
00069 public:
00070     // Constructor.
00071     PlotButton() { }
00072     
00073     // Destructor.
00074     virtual ~PlotButton() { }
00075     
00076     // Returns true if text is being shown on the button, false otherwise.
00077     virtual bool textShown() const = 0;
00078     
00079     // Show/hide the set text on the button.
00080     virtual void showText(bool show = true) = 0;
00081     
00082     // Currently set button text.  (May not be displayed.)
00083     virtual String text() const = 0;
00084     
00085     // Sets the button text.
00086     virtual void setText(const String& text) = 0;
00087     
00088     // Returns true if an image is being shown on the button, false otherwise.
00089     virtual bool imageShown() const = 0;
00090     
00091     // Show/hide the set image on the button.
00092     virtual void showImage(bool show = true) = 0;
00093     
00094     // Set the image path to be shown on the button.
00095     virtual void setImagePath(const String& imgPath) = 0;
00096     
00097     // Returns true if the button is "toggleable", false otherwise.  A button
00098     // that is toggleable sticks down when pushed, then comes back up when
00099     // pushed again.  The state can be determined with isToggled().
00100     virtual bool isToggleable() const = 0;
00101     
00102     // Sets whether this button is "toggleable" or not.
00103     virtual void setToggleable(bool toggleable = true) = 0;
00104     
00105     // Returns whether this button is in a toggled state or not.
00106     virtual bool isToggled() const = 0;
00107     
00108     // Sets whether this button is in a toggled state or not.  (Does not
00109     // affect buttons that are not toggleable.)
00110     virtual void setToggled(bool toggled = true) = 0;
00111     
00112     // Register the given event handler for this button.
00113     virtual void registerHandler(PlotButtonEventHandlerPtr handler) = 0;
00114     
00115     // Returns all event handlers currently registered on this button.
00116     virtual vector<PlotButtonEventHandlerPtr> allHandlers() const = 0;
00117     
00118     // Unregisters the given event handler.
00119     virtual void unregisterHandler(PlotButtonEventHandlerPtr handler) = 0;
00120 };
00121 
00122 
00123 // Generic class for a checkbox that goes on a PlotPanel.  A checkbox has
00124 // properties that can be set, as well as registration for event
00125 // handlers.  A checkbox can only be seen/interacted with on a PlotPanel.
00126 class PlotCheckbox : public virtual PlotWidget {
00127 public:
00128     // Constructor.
00129     PlotCheckbox() { }
00130     
00131     // Destructor.
00132     virtual ~PlotCheckbox() { }
00133     
00134     // Returns the text for this checkbox.
00135     virtual String text() const = 0;
00136     
00137     // Sets the text for this checkbox.
00138     virtual void setText(const String& text) = 0;
00139     
00140     // Returns true if the checkbox is currently checked, false otherwise.
00141     virtual bool isChecked() const = 0;
00142     
00143     // Sets whether the checkbox is checked or not.
00144     virtual void setChecked(bool checked = true) = 0;
00145     
00146     // Register the given event handler for this checkbox.
00147     virtual void registerHandler(PlotCheckboxEventHandlerPtr handler) = 0;
00148     
00149     // Returns all event handlers currently registered on this button.
00150     virtual vector<PlotCheckboxEventHandlerPtr> allHandlers() const = 0;
00151     
00152     // Unregisters the given event handler.
00153     virtual void unregisterHandler(PlotCheckboxEventHandlerPtr handler) = 0;
00154 };
00155 
00156 
00157 // A PlotPanel is a panel that goes on the bottom of the plot window.  A
00158 // single panel can contain multiple widgets.
00159 class PlotPanel {
00160 public:
00161     PlotPanel() { }
00162     
00163     virtual ~PlotPanel() { }
00164     
00165     // Returns all PlotWidgets currently on the panel.
00166     virtual vector<PlotWidgetPtr> widgets() const = 0;
00167     
00168     // Adds the given widget to this panel.
00169     virtual int addWidget(PlotWidgetPtr widget) = 0;
00170     
00171     // Clears all widgets on the panel.
00172     virtual void clearWidgets() = 0;
00173     
00174     // Removes the given widget from this panel.
00175     virtual void removeWidget(PlotWidgetPtr widget) = 0;
00176     
00177     // Removes the widget at the given index from this panel.
00178     virtual void removeWidget(int index) = 0;
00179 };
00180 
00181 
00183 // SMART POINTER DEFINITIONS //
00185 
00186 INHERITANCE_POINTER2(PlotButton, PlotButtonPtr, PlotWidget, PlotWidgetPtr)
00187 INHERITANCE_POINTER2(PlotCheckbox, PlotCheckboxPtr, PlotWidget, PlotWidgetPtr)
00188 typedef CountedPtr<PlotPanel> PlotPanelPtr;
00189 
00190 }
00191 
00192 #endif /*PLOTPANEL_H_*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1