GraphicTextWidget.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef GRAPHICTEXTWIDGET_H
00011 #define GRAPHICTEXTWIDGET_H
00012 
00013 #include <QtGui/QCheckBox>
00014 #include <QtGui/QComboBox>
00015 #include <QtGui/QFontComboBox>
00016 #include <QtGui/QTextEdit>
00017 #include <QtGui/QWidget>
00018 
00019 class CustomColorButton;
00020 class FontSizeComboBox;
00021 
00022 /**
00023  *  A widget used to get text along with other customizable properties, such as font and color, from the user.
00024  *
00025  *  The graphic text widget will allow users to customize text, specifying alignment,
00026  *  font, and color. In addition, users may be able to modify the text. This widget is not
00027  *  meant to display the text but rather to allow the user to customize text which is displayed
00028  *  elsewhere, such as a Measurement or Plot.
00029  */
00030 class GraphicTextWidget : public QWidget
00031 {
00032    Q_OBJECT
00033 
00034 public:
00035    /**
00036     *  Creates a graphic text widget.
00037     *
00038     *  @param   pParent
00039     *           The parent widget.
00040     */
00041    GraphicTextWidget(QWidget* pParent = NULL);
00042 
00043    /**
00044     *  Destroys the graphic text widget and all child items.
00045     */
00046    virtual ~GraphicTextWidget();
00047 
00048    /**
00049     * Returns the text to be displayed to the user.
00050     *
00051     *  @return  The text to be displayed to the user. By default, an empty string will be returned.
00052     */
00053    QString getText() const;
00054 
00055    /**
00056     * Returns the alignment which should be used to display the text.
00057     * This will correspond to one or more of the values in Qt::AlignmentFlag.
00058     *
00059     *  @return  The alignment to use when displaying the text. By default, the alignment is Qt::AlignLeft.
00060     */
00061    int getAlignment() const;
00062 
00063    /**
00064     * Returns the font which should be used to display the text.
00065     *
00066     *  @return  The font to use when displaying the text.
00067     *           By default, the QFontComboBox default font is used without bold, italics, or underlining.
00068     *           By default, the FontSizeComboBox default font size is used.
00069     */
00070    QFont getTextFont() const;
00071 
00072    /**
00073     * Returns the color which should be used to display the text.
00074     *
00075     *  @return  The color to use when displaying the text. By default, the CustomColorButton default color is used.
00076     */
00077    QColor getColor() const;
00078 
00079 public slots:
00080    /**
00081     * Sets the text to be displayed to the user.
00082     *
00083     *  @param   text
00084     *           The text to display.
00085     */
00086    void setText(const QString& text);
00087 
00088    /**
00089     * Sets the alignment which should be used to display the text.
00090     * By default, the alignment is Qt::AlignLeft.
00091     *
00092     *  @param   alignment
00093     *           The alignment to use.
00094     *           The only supported values are Qt::AlignLeft, Qt::AlignHCenter, and Qt::AlignRight.
00095     */
00096    void setAlignment(int alignment);
00097 
00098    /**
00099     * Sets the font which should be used to display the text.
00100     * By default, the QFontComboBox default font is used without bold, italics, or underlining.
00101     * By default, the FontSizeComboBox default font size is used.
00102     *
00103     *  @param   textFont
00104     *           The font to use.
00105     */
00106    void setTextFont(const QFont& textFont);
00107 
00108    /**
00109     * Sets the color which should be used to display the text.
00110     * By default, the CustomColorButton default color is used.
00111     *
00112     *  @param   color
00113     *           The color to use.
00114     */
00115    void setColor(const QColor& color);
00116 
00117    /**
00118     * Sets whether the user can modify the text.
00119     * By default, the text can be edited by the user.
00120     *
00121     *  @param   bTextReadOnly
00122     *           \b True to disable editing, \b false otherwise.
00123     */
00124    void setTextReadOnly(bool bTextReadOnly);
00125 
00126 signals:
00127    /**
00128     *  Emitted when the text is changed.
00129     *
00130     *  @param   text
00131     *           The newly set text.
00132     */
00133    void textChanged(const QString& text);
00134 
00135    /**
00136     *  Emitted when the alignment is changed.
00137     *
00138     *  @param   alignment
00139     *           The newly set alignment.
00140     */
00141    void alignmentChanged(int alignment);
00142 
00143    /**
00144     *  Emitted when the font is changed.
00145     *
00146     *  @param   textFont
00147     *           The newly set font.
00148     */
00149    void fontChanged(const QFont& textFont);
00150 
00151    /**
00152     *  Emitted when the color is changed.
00153     *
00154     *  @param   color
00155     *           The newly set color.
00156     */
00157    void colorChanged(const QColor& color);
00158 
00159 protected slots:
00160    /**
00161     *  Causes textChanged() to be emitted.
00162     */
00163    void notifyTextChange();
00164 
00165    /**
00166     *  Causes alignmentChanged() to be emitted.
00167     */
00168    void notifyAlignmentChange();
00169 
00170    /**
00171     *  Causes fontChanged() to be emitted.
00172     */
00173    void notifyFontChange();
00174 
00175 private:
00176    GraphicTextWidget(const GraphicTextWidget& rhs);
00177    GraphicTextWidget& operator=(const GraphicTextWidget& rhs);
00178    QTextEdit* mpTextEdit;
00179    QComboBox* mpAlignmentCombo;
00180    QFontComboBox* mpFontCombo;
00181    FontSizeComboBox* mpFontSizeCombo;
00182    CustomColorButton* mpColorButton;
00183    QCheckBox* mpBoldCheck;
00184    QCheckBox* mpItalicsCheck;
00185    QCheckBox* mpUnderlineCheck;
00186 };
00187 
00188 #endif

Software Development Kit - Opticks 4.9.0 Build 16218