![]() |
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,2009 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 * $Id: FXLabel.h,v 1.35 2009/01/06 13:07:25 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXLABEL_H 00024 #define FXLABEL_H 00025 00026 #ifndef FXFRAME_H 00027 #include "FXFrame.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// Relationship options for icon-labels 00034 enum { 00035 ICON_UNDER_TEXT = 0, /// Icon appears under text 00036 ICON_AFTER_TEXT = 0x00080000, /// Icon appears after text (to its right) 00037 ICON_BEFORE_TEXT = 0x00100000, /// Icon appears before text (to its left) 00038 ICON_ABOVE_TEXT = 0x00200000, /// Icon appears above text 00039 ICON_BELOW_TEXT = 0x00400000, /// Icon appears below text 00040 TEXT_OVER_ICON = ICON_UNDER_TEXT, /// Same as ICON_UNDER_TEXT 00041 TEXT_AFTER_ICON = ICON_BEFORE_TEXT, /// Same as ICON_BEFORE_TEXT 00042 TEXT_BEFORE_ICON = ICON_AFTER_TEXT, /// Same as ICON_AFTER_TEXT 00043 TEXT_ABOVE_ICON = ICON_BELOW_TEXT, /// Same as ICON_BELOW_TEXT 00044 TEXT_BELOW_ICON = ICON_ABOVE_TEXT /// Same as ICON_ABOVE_TEXT 00045 }; 00046 00047 00048 /// Normal way to show label 00049 enum { 00050 LABEL_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT 00051 }; 00052 00053 00054 class FXIcon; 00055 class FXFont; 00056 00057 00058 /** 00059 * A label widget can be used to place a text and/or icon for 00060 * explanation purposes. The text label may have an optional tooltip 00061 * and/or help string. Icon and label are placed relative to the widget 00062 * using the justfication options, and relative to each other as determined 00063 * by the icon relationship options. A large number of arrangements is 00064 * possible. 00065 */ 00066 class FXAPI FXLabel : public FXFrame { 00067 FXDECLARE(FXLabel) 00068 protected: 00069 FXString label; // Text on the label 00070 FXIcon* icon; // Icon on the label 00071 FXFont* font; // Label font 00072 FXHotKey hotkey; // Hotkey 00073 FXint hotoff; // Offset in string 00074 FXColor textColor; // Text color 00075 FXString tip; // Tooltip 00076 FXString help; // Help message 00077 protected: 00078 FXLabel(); 00079 FXint labelHeight(const FXString& text) const; 00080 FXint labelWidth(const FXString& text) const; 00081 void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th); 00082 void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw); 00083 void just_y(FXint& ty,FXint& iy,FXint th,FXint ih); 00084 private: 00085 FXLabel(const FXLabel&); 00086 FXLabel &operator=(const FXLabel&); 00087 public: 00088 long onPaint(FXObject*,FXSelector,void*); 00089 long onHotKeyPress(FXObject*,FXSelector,void*); 00090 long onHotKeyRelease(FXObject*,FXSelector,void*); 00091 long onCmdSetValue(FXObject*,FXSelector,void*); 00092 long onCmdSetStringValue(FXObject*,FXSelector,void*); 00093 long onCmdGetStringValue(FXObject*,FXSelector,void*); 00094 long onCmdSetIconValue(FXObject*,FXSelector,void*); 00095 long onCmdGetIconValue(FXObject*,FXSelector,void*); 00096 long onCmdSetHelp(FXObject*,FXSelector,void*); 00097 long onCmdGetHelp(FXObject*,FXSelector,void*); 00098 long onCmdSetTip(FXObject*,FXSelector,void*); 00099 long onCmdGetTip(FXObject*,FXSelector,void*); 00100 long onQueryHelp(FXObject*,FXSelector,void*); 00101 long onQueryTip(FXObject*,FXSelector,void*); 00102 public: 00103 00104 /// Construct label with given text and icon 00105 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); 00106 00107 /// Create server-side resources 00108 virtual void create(); 00109 00110 /// Detach server-side resources 00111 virtual void detach(); 00112 00113 /// Enable the window 00114 virtual void enable(); 00115 00116 /// Disable the window 00117 virtual void disable(); 00118 00119 /// Return default width 00120 virtual FXint getDefaultWidth(); 00121 00122 /// Return default height 00123 virtual FXint getDefaultHeight(); 00124 00125 /// Set the text for this label 00126 void setText(const FXString& text); 00127 00128 /// Get the text for this label 00129 FXString getText() const { return label; } 00130 00131 /// Set the icon for this label 00132 void setIcon(FXIcon* ic); 00133 00134 /// Get the icon for this label 00135 FXIcon* getIcon() const { return icon; } 00136 00137 /// Set the text font 00138 void setFont(FXFont *fnt); 00139 00140 /// Get the text font 00141 FXFont* getFont() const { return font; } 00142 00143 /// Get the current text color 00144 FXColor getTextColor() const { return textColor; } 00145 00146 /// Set the current text color 00147 void setTextColor(FXColor clr); 00148 00149 /// Set the current text-justification mode. 00150 void setJustify(FXuint mode); 00151 00152 /// Get the current text-justification mode. 00153 FXuint getJustify() const; 00154 00155 /// Set the current icon position 00156 void setIconPosition(FXuint mode); 00157 00158 /// Get the current icon position 00159 FXuint getIconPosition() const; 00160 00161 /// Set the status line help text for this label 00162 void setHelpText(const FXString& text){ help=text; } 00163 00164 /// Get the status line help text for this label 00165 const FXString& getHelpText() const { return help; } 00166 00167 /// Set the tool tip message for this label 00168 void setTipText(const FXString& text){ tip=text; } 00169 00170 /// Get the tool tip message for this label 00171 const FXString& getTipText() const { return tip; } 00172 00173 /// Save label to a stream 00174 virtual void save(FXStream& store) const; 00175 00176 /// Load label from a stream 00177 virtual void load(FXStream& store); 00178 00179 /// Destructor 00180 virtual ~FXLabel(); 00181 }; 00182 00183 } 00184 00185 #endif
![]() |