![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * L a b e l W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2002 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.18 2002/09/30 13:06:56 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 /// Justification modes 00035 enum { 00036 JUSTIFY_NORMAL = 0, /// Default justification is centered text 00037 JUSTIFY_CENTER_X = 0, /// Text is centered horizontally 00038 JUSTIFY_LEFT = 0x00008000, /// Text is left-justified 00039 JUSTIFY_RIGHT = 0x00010000, /// Text is right-justified 00040 JUSTIFY_HZ_APART = JUSTIFY_LEFT|JUSTIFY_RIGHT, /// Combination of JUSTIFY_LEFT & JUSTIFY_RIGHT 00041 JUSTIFY_CENTER_Y = 0, /// Text is centered vertically 00042 JUSTIFY_TOP = 0x00020000, /// Text is aligned with label top 00043 JUSTIFY_BOTTOM = 0x00040000, /// Text is aligned with label bottom 00044 JUSTIFY_VT_APART = JUSTIFY_TOP|JUSTIFY_BOTTOM /// Combination of JUSTIFY_TOP & JUSTIFY_BOTTOM 00045 }; 00046 00047 00048 00049 /// Relationship options for icon-labels 00050 enum { 00051 ICON_UNDER_TEXT = 0, /// Icon appears under text 00052 ICON_AFTER_TEXT = 0x00080000, /// Icon appears after text (to its right) 00053 ICON_BEFORE_TEXT = 0x00100000, /// Icon appears before text (to its left) 00054 ICON_ABOVE_TEXT = 0x00200000, /// Icon appears above text 00055 ICON_BELOW_TEXT = 0x00400000, /// Icon appears below text 00056 TEXT_OVER_ICON = ICON_UNDER_TEXT, /// Same as ICON_UNDER_TEXT 00057 TEXT_AFTER_ICON = ICON_BEFORE_TEXT, /// Same as ICON_BEFORE_TEXT 00058 TEXT_BEFORE_ICON = ICON_AFTER_TEXT, /// Same as ICON_AFTER_TEXT 00059 TEXT_ABOVE_ICON = ICON_BELOW_TEXT, /// Same as ICON_BELOW_TEXT 00060 TEXT_BELOW_ICON = ICON_ABOVE_TEXT /// Same as ICON_ABOVE_TEXT 00061 }; 00062 00063 00064 /// Normal way to show label 00065 enum { 00066 LABEL_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT 00067 }; 00068 00069 00070 class FXIcon; 00071 class FXFont; 00072 00073 00074 /** 00075 * A label widget can be used to place a text and/or icon for 00076 * explanation purposes. The text label may have an optional tooltip 00077 * and/or help string. 00078 */ 00079 class FXAPI FXLabel : public FXFrame { 00080 FXDECLARE(FXLabel) 00081 protected: 00082 FXString label; 00083 FXIcon* icon; 00084 FXFont* font; 00085 FXHotKey hotkey; 00086 FXint hotoff; 00087 FXColor textColor; 00088 FXString tip; 00089 FXString help; 00090 protected: 00091 FXLabel(); 00092 FXint labelHeight(const FXString& text) const; 00093 FXint labelWidth(const FXString& text) const; 00094 void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th); 00095 void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw); 00096 void just_y(FXint& ty,FXint& iy,FXint th,FXint ih); 00097 private: 00098 FXLabel(const FXLabel&); 00099 FXLabel &operator=(const FXLabel&); 00100 public: 00101 long onPaint(FXObject*,FXSelector,void*); 00102 long onHotKeyPress(FXObject*,FXSelector,void*); 00103 long onHotKeyRelease(FXObject*,FXSelector,void*); 00104 long onCmdGetStringValue(FXObject*,FXSelector,void*); 00105 long onCmdSetStringValue(FXObject*,FXSelector,void*); 00106 long onQueryHelp(FXObject*,FXSelector,void*); 00107 long onQueryTip(FXObject*,FXSelector,void*); 00108 public: 00109 00110 /// Construct label with given text and icon 00111 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); 00112 00113 /// Create server-side resources 00114 virtual void create(); 00115 00116 /// Detach server-side resources 00117 virtual void detach(); 00118 00119 /// Enable the window 00120 virtual void enable(); 00121 00122 /// Disable the window 00123 virtual void disable(); 00124 00125 /// Return default width 00126 virtual FXint getDefaultWidth(); 00127 00128 /// Return default height 00129 virtual FXint getDefaultHeight(); 00130 00131 /// Set the text for this label 00132 void setText(const FXString& text); 00133 00134 /// Get the text for this label 00135 FXString getText() const { return label; } 00136 00137 /// Set the icon for this label 00138 void setIcon(FXIcon* ic); 00139 00140 /// Get the icon for this label 00141 FXIcon* getIcon() const { return icon; } 00142 00143 /// Set the text font 00144 void setFont(FXFont *fnt); 00145 00146 /// Get the text font 00147 FXFont* getFont() const { return font; } 00148 00149 /// Get the current text color 00150 FXColor getTextColor() const { return textColor; } 00151 00152 /// Set the current text color 00153 void setTextColor(FXColor clr); 00154 00155 /// Set the current text-justification mode. 00156 void setJustify(FXuint mode); 00157 00158 /// Get the current text-justification mode. 00159 FXuint getJustify() const; 00160 00161 /// Set the current icon position 00162 void setIconPosition(FXuint mode); 00163 00164 /// Get the current icon position 00165 FXuint getIconPosition() const; 00166 00167 /// Set the status line help text for this label 00168 void setHelpText(const FXString& text); 00169 00170 /// Get the status line help text for this label 00171 const FXString& getHelpText() const { return help; } 00172 00173 /// Set the tool tip message for this label 00174 void setTipText(const FXString& text); 00175 00176 /// Get the tool tip message for this label 00177 const FXString& getTipText() const { return tip; } 00178 00179 /// Save label to a stream 00180 virtual void save(FXStream& store) const; 00181 00182 /// Load label from a stream 00183 virtual void load(FXStream& store); 00184 00185 /// Destructor 00186 virtual ~FXLabel(); 00187 }; 00188 00189 } 00190 00191 #endif