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 
00035 enum {
00036   ICON_UNDER_TEXT      = 0,               
00037   ICON_AFTER_TEXT      = 0x00080000,              
00038   ICON_BEFORE_TEXT     = 0x00100000,              
00039   ICON_ABOVE_TEXT      = 0x00200000,              
00040   ICON_BELOW_TEXT      = 0x00400000,              
00041   TEXT_OVER_ICON       = ICON_UNDER_TEXT,         
00042   TEXT_AFTER_ICON      = ICON_BEFORE_TEXT,        
00043   TEXT_BEFORE_ICON     = ICON_AFTER_TEXT,         
00044   TEXT_ABOVE_ICON      = ICON_BELOW_TEXT,         
00045   TEXT_BELOW_ICON      = ICON_ABOVE_TEXT          
00046   };
00047 
00048 
00050 enum {
00051   LABEL_NORMAL         = JUSTIFY_NORMAL|ICON_BEFORE_TEXT
00052   };
00053 
00054 
00055 class FXIcon;
00056 class FXFont;
00057 
00058 
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 
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 
00109   virtual void create();
00110 
00112   virtual void detach();
00113 
00115   virtual void enable();
00116 
00118   virtual void disable();
00119 
00121   virtual FXint getDefaultWidth();
00122 
00124   virtual FXint getDefaultHeight();
00125 
00127   void setText(const FXString& text);
00128 
00130   FXString getText() const { return label; }
00131 
00133   void setIcon(FXIcon* ic);
00134 
00136   FXIcon* getIcon() const { return icon; }
00137 
00139   void setFont(FXFont *fnt);
00140 
00142   FXFont* getFont() const { return font; }
00143 
00145   FXColor getTextColor() const { return textColor; }
00146 
00148   void setTextColor(FXColor clr);
00149 
00151   void setJustify(FXuint mode);
00152 
00154   FXuint getJustify() const;
00155 
00157   void setIconPosition(FXuint mode);
00158 
00160   FXuint getIconPosition() const;
00161 
00163   void setHelpText(const FXString& text){ help=text; }
00164 
00166   const FXString& getHelpText() const { return help; }
00167 
00169   void setTipText(const FXString& text){ tip=text; }
00170 
00172   const FXString& getTipText() const { return tip; }
00173 
00175   virtual void save(FXStream& store) const;
00176 
00178   virtual void load(FXStream& store);
00179 
00181   virtual ~FXLabel();
00182   };
00183 
00184 }
00185 
00186 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:23 2009 for TnFOX by doxygen v1.4.7