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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXLabel.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                            L a b e l   W i d g e t                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXLABEL_H
00022 #define FXLABEL_H
00023 
00024 #ifndef FXFRAME_H
00025 #include "FXFrame.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00032 enum {
00033   ICON_UNDER_TEXT      = 0,           
00034   ICON_AFTER_TEXT      = 0x00080000,          
00035   ICON_BEFORE_TEXT     = 0x00100000,          
00036   ICON_ABOVE_TEXT      = 0x00200000,          
00037   ICON_BELOW_TEXT      = 0x00400000,          
00038   TEXT_OVER_ICON       = ICON_UNDER_TEXT,       
00039   TEXT_AFTER_ICON      = ICON_BEFORE_TEXT,        
00040   TEXT_BEFORE_ICON     = ICON_AFTER_TEXT,       
00041   TEXT_ABOVE_ICON      = ICON_BELOW_TEXT,       
00042   TEXT_BELOW_ICON      = ICON_ABOVE_TEXT        
00043   };
00044 
00045 
00047 enum {
00048   LABEL_NORMAL         = JUSTIFY_NORMAL|ICON_BEFORE_TEXT
00049   };
00050 
00051 
00052 class FXIcon;
00053 class FXFont;
00054 
00055 
00064 class FXAPI FXLabel : public FXFrame {
00065   FXDECLARE(FXLabel)
00066 protected:
00067   FXString  label;      // Text on the label
00068   FXIcon   *icon;       // Icon on the label
00069   FXFont   *font;       // Label font
00070   FXHotKey  hotkey;     // Hotkey
00071   FXint     hotoff;     // Offset in string
00072   FXColor   textColor;  // Text color
00073   FXString  tip;        // Tooltip
00074   FXString  help;       // Help message
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 onCmdSetValue(FXObject*,FXSelector,void*);
00090   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00091   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00092   long onCmdSetIconValue(FXObject*,FXSelector,void*);
00093   long onCmdGetIconValue(FXObject*,FXSelector,void*);
00094   long onCmdSetHelp(FXObject*,FXSelector,void*);
00095   long onCmdGetHelp(FXObject*,FXSelector,void*);
00096   long onCmdSetTip(FXObject*,FXSelector,void*);
00097   long onCmdGetTip(FXObject*,FXSelector,void*);
00098   long onQueryHelp(FXObject*,FXSelector,void*);
00099   long onQueryTip(FXObject*,FXSelector,void*);
00100 public:
00101 
00103   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);
00104 
00106   virtual void create();
00107 
00109   virtual void detach();
00110 
00112   virtual void enable();
00113 
00115   virtual void disable();
00116 
00118   virtual FXint getDefaultWidth();
00119 
00121   virtual FXint getDefaultHeight();
00122 
00124   void setText(const FXString& text);
00125 
00127   FXString getText() const { return label; }
00128 
00130   void setIcon(FXIcon* ic);
00131 
00133   FXIcon* getIcon() const { return icon; }
00134 
00136   void setFont(FXFont *fnt);
00137 
00139   FXFont* getFont() const { return font; }
00140 
00142   FXColor getTextColor() const { return textColor; }
00143 
00145   void setTextColor(FXColor clr);
00146 
00148   void setJustify(FXuint mode);
00149 
00151   FXuint getJustify() const;
00152 
00154   void setIconPosition(FXuint mode);
00155 
00157   FXuint getIconPosition() const;
00158 
00160   void setHelpText(const FXString& text){ help=text; }
00161 
00163   const FXString& getHelpText() const { return help; }
00164 
00166   void setTipText(const FXString& text){ tip=text; }
00167 
00169   const FXString& getTipText() const { return tip; }
00170 
00172   virtual void save(FXStream& store) const;
00173 
00175   virtual void load(FXStream& store);
00176 
00178   virtual ~FXLabel();
00179   };
00180 
00181 }
00182 
00183 #endif

Copyright © 1997-2011 Jeroen van der Zijp