Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXLabel.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                            L a b e l   W i d g e t                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXLabel.h,v 1.31 2006/03/01 02:13:21 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXLABEL_H
00025 #define FXLABEL_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Relationship options for icon-labels
00035 enum {
00036   ICON_UNDER_TEXT      = 0,           /// Icon appears under text
00037   ICON_AFTER_TEXT      = 0x00080000,          /// Icon appears after text (to its right)
00038   ICON_BEFORE_TEXT     = 0x00100000,          /// Icon appears before text (to its left)
00039   ICON_ABOVE_TEXT      = 0x00200000,          /// Icon appears above text
00040   ICON_BELOW_TEXT      = 0x00400000,          /// Icon appears below text
00041   TEXT_OVER_ICON       = ICON_UNDER_TEXT,       /// Same as ICON_UNDER_TEXT
00042   TEXT_AFTER_ICON      = ICON_BEFORE_TEXT,        /// Same as ICON_BEFORE_TEXT
00043   TEXT_BEFORE_ICON     = ICON_AFTER_TEXT,       /// Same as ICON_AFTER_TEXT
00044   TEXT_ABOVE_ICON      = ICON_BELOW_TEXT,       /// Same as ICON_BELOW_TEXT
00045   TEXT_BELOW_ICON      = ICON_ABOVE_TEXT        /// Same as ICON_ABOVE_TEXT
00046   };
00047 
00048 
00049 /// Normal way to show label
00050 enum {
00051   LABEL_NORMAL         = JUSTIFY_NORMAL|ICON_BEFORE_TEXT
00052   };
00053 
00054 
00055 class FXIcon;
00056 class FXFont;
00057 
00058 
00059 /**
00060 * A label widget can be used to place a text and/or icon for
00061 * explanation purposes.  The text label may have an optional tooltip
00062 * and/or help string.  Icon and label are placed relative to the widget
00063 * using the justfication options, and relative to each other as determined
00064 * by the icon relationship options.  A large number of arrangements is
00065 * possible.
00066 */
00067 class FXAPI FXLabel : public FXFrame {
00068   FXDECLARE(FXLabel)
00069 protected:
00070   FXString label;       // Text on the label
00071   FXIcon*  icon;        // Icon on the label
00072   FXFont*  font;        // Label font
00073   FXHotKey hotkey;      // Hotkey
00074   FXint    hotoff;      // Offset in string
00075   FXColor  textColor;   // Text color
00076   FXString tip;         // Tooltip
00077   FXString help;        // Help message
00078 protected:
00079   FXLabel();
00080   FXint labelHeight(const FXString& text) const;
00081   FXint labelWidth(const FXString& text) const;
00082   void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th);
00083   void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw);
00084   void just_y(FXint& ty,FXint& iy,FXint th,FXint ih);
00085 private:
00086   FXLabel(const FXLabel&);
00087   FXLabel &operator=(const FXLabel&);
00088 public:
00089   long onPaint(FXObject*,FXSelector,void*);
00090   long onHotKeyPress(FXObject*,FXSelector,void*);
00091   long onHotKeyRelease(FXObject*,FXSelector,void*);
00092   long onCmdSetValue(FXObject*,FXSelector,void*);
00093   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00094   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00095   long onCmdSetIconValue(FXObject*,FXSelector,void*);
00096   long onCmdGetIconValue(FXObject*,FXSelector,void*);
00097   long onCmdSetHelp(FXObject*,FXSelector,void*);
00098   long onCmdGetHelp(FXObject*,FXSelector,void*);
00099   long onCmdSetTip(FXObject*,FXSelector,void*);
00100   long onCmdGetTip(FXObject*,FXSelector,void*);
00101   long onQueryHelp(FXObject*,FXSelector,void*);
00102   long onQueryTip(FXObject*,FXSelector,void*);
00103 public:
00104 
00105   /// Construct label with given text and icon
00106   FXLabel(FXComposite* p,const FXString& text,FXIcon* ic=0,FXuint opts=LABEL_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
00107 
00108   /// Create server-side resources
00109   virtual void create();
00110 
00111   /// Detach server-side resources
00112   virtual void detach();
00113 
00114   /// Enable the window
00115   virtual void enable();
00116 
00117   /// Disable the window
00118   virtual void disable();
00119 
00120   /// Return default width
00121   virtual FXint getDefaultWidth();
00122 
00123   /// Return default height
00124   virtual FXint getDefaultHeight();
00125 
00126   /// Set the text for this label
00127   void setText(const FXString& text);
00128 
00129   /// Get the text for this label
00130   FXString getText() const { return label; }
00131 
00132   /// Set the icon for this label
00133   void setIcon(FXIcon* ic);
00134 
00135   /// Get the icon for this label
00136   FXIcon* getIcon() const { return icon; }
00137 
00138   /// Set the text font
00139   void setFont(FXFont *fnt);
00140 
00141   /// Get the text font
00142   FXFont* getFont() const { return font; }
00143 
00144   /// Get the current text color
00145   FXColor getTextColor() const { return textColor; }
00146 
00147   /// Set the current text color
00148   void setTextColor(FXColor clr);
00149 
00150   /// Set the current text-justification mode.
00151   void setJustify(FXuint mode);
00152 
00153   /// Get the current text-justification mode.
00154   FXuint getJustify() const;
00155 
00156   /// Set the current icon position
00157   void setIconPosition(FXuint mode);
00158 
00159   /// Get the current icon position
00160   FXuint getIconPosition() const;
00161 
00162   /// Set the status line help text for this label
00163   void setHelpText(const FXString& text){ help=text; }
00164 
00165   /// Get the status line help text for this label
00166   const FXString& getHelpText() const { return help; }
00167 
00168   /// Set the tool tip message for this label
00169   void setTipText(const FXString& text){ tip=text; }
00170 
00171   /// Get the tool tip message for this label
00172   const FXString& getTipText() const { return tip; }
00173 
00174   /// Save label to a stream
00175   virtual void save(FXStream& store) const;
00176 
00177   /// Load label from a stream
00178   virtual void load(FXStream& store);
00179 
00180   /// Destructor
00181   virtual ~FXLabel();
00182   };
00183 
00184 }
00185 
00186 #endif

Copyright © 1997-2005 Jeroen van der Zijp