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

FXLabel.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                            L a b e l   W i d g e t                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2004 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.24 2004/02/08 17:17:33 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.
00063 */
00064 class FXAPI FXLabel : public FXFrame {
00065   FXDECLARE(FXLabel)
00066 protected:
00067   FXString label;
00068   FXIcon*  icon;
00069   FXFont*  font;
00070   FXHotKey hotkey;
00071   FXint    hotoff;
00072   FXColor  textColor;
00073   FXString tip;
00074   FXString help;
00075 protected:
00076   FXLabel();
00077   FXint labelHeight(const FXString& text) const;
00078   FXint labelWidth(const FXString& text) const;
00079   void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th);
00080   void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw);
00081   void just_y(FXint& ty,FXint& iy,FXint th,FXint ih);
00082 private:
00083   FXLabel(const FXLabel&);
00084   FXLabel &operator=(const FXLabel&);
00085 public:
00086   long onPaint(FXObject*,FXSelector,void*);
00087   long onHotKeyPress(FXObject*,FXSelector,void*);
00088   long onHotKeyRelease(FXObject*,FXSelector,void*);
00089   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00090   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00091   long onCmdSetIconValue(FXObject*,FXSelector,void*);
00092   long onCmdGetIconValue(FXObject*,FXSelector,void*);
00093   long onCmdSetHelp(FXObject*,FXSelector,void*);
00094   long onCmdGetHelp(FXObject*,FXSelector,void*);
00095   long onCmdSetTip(FXObject*,FXSelector,void*);
00096   long onCmdGetTip(FXObject*,FXSelector,void*);
00097   long onQueryHelp(FXObject*,FXSelector,void*);
00098   long onQueryTip(FXObject*,FXSelector,void*);
00099 public:
00100 
00101   /// Construct label with given text and icon
00102   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);
00103 
00104   /// Create server-side resources
00105   virtual void create();
00106 
00107   /// Detach server-side resources
00108   virtual void detach();
00109 
00110   /// Enable the window
00111   virtual void enable();
00112 
00113   /// Disable the window
00114   virtual void disable();
00115 
00116   /// Return default width
00117   virtual FXint getDefaultWidth();
00118 
00119   /// Return default height
00120   virtual FXint getDefaultHeight();
00121 
00122   /// Set the text for this label
00123   void setText(const FXString& text);
00124 
00125   /// Get the text for this label
00126   FXString getText() const { return label; }
00127 
00128   /// Set the icon for this label
00129   void setIcon(FXIcon* ic);
00130 
00131   /// Get the icon for this label
00132   FXIcon* getIcon() const { return icon; }
00133 
00134   /// Set the text font
00135   void setFont(FXFont *fnt);
00136 
00137   /// Get the text font
00138   FXFont* getFont() const { return font; }
00139 
00140   /// Get the current text color
00141   FXColor getTextColor() const { return textColor; }
00142 
00143   /// Set the current text color
00144   void setTextColor(FXColor clr);
00145 
00146   /// Set the current text-justification mode.
00147   void setJustify(FXuint mode);
00148 
00149   /// Get the current text-justification mode.
00150   FXuint getJustify() const;
00151 
00152   /// Set the current icon position
00153   void setIconPosition(FXuint mode);
00154 
00155   /// Get the current icon position
00156   FXuint getIconPosition() const;
00157 
00158   /// Set the status line help text for this label
00159   void setHelpText(const FXString& text);
00160 
00161   /// Get the status line help text for this label
00162   FXString getHelpText() const { return help; }
00163 
00164   /// Set the tool tip message for this label
00165   void setTipText(const FXString&  text);
00166 
00167   /// Get the tool tip message for this label
00168   FXString getTipText() const { return tip; }
00169 
00170   /// Save label to a stream
00171   virtual void save(FXStream& store) const;
00172 
00173   /// Load label from a stream
00174   virtual void load(FXStream& store);
00175 
00176   /// Destructor
00177   virtual ~FXLabel();
00178   };
00179 
00180 }
00181 
00182 #endif

Copyright © 1997-2004 Jeroen van der Zijp