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.26 2004/04/22 20:51:04 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 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 00102 /// Construct label with given text and icon 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 00105 /// Create server-side resources 00106 virtual void create(); 00107 00108 /// Detach server-side resources 00109 virtual void detach(); 00110 00111 /// Enable the window 00112 virtual void enable(); 00113 00114 /// Disable the window 00115 virtual void disable(); 00116 00117 /// Return default width 00118 virtual FXint getDefaultWidth(); 00119 00120 /// Return default height 00121 virtual FXint getDefaultHeight(); 00122 00123 /// Set the text for this label 00124 void setText(const FXString& text); 00125 00126 /// Get the text for this label 00127 FXString getText() const { return label; } 00128 00129 /// Set the icon for this label 00130 void setIcon(FXIcon* ic); 00131 00132 /// Get the icon for this label 00133 FXIcon* getIcon() const { return icon; } 00134 00135 /// Set the text font 00136 void setFont(FXFont *fnt); 00137 00138 /// Get the text font 00139 FXFont* getFont() const { return font; } 00140 00141 /// Get the current text color 00142 FXColor getTextColor() const { return textColor; } 00143 00144 /// Set the current text color 00145 void setTextColor(FXColor clr); 00146 00147 /// Set the current text-justification mode. 00148 void setJustify(FXuint mode); 00149 00150 /// Get the current text-justification mode. 00151 FXuint getJustify() const; 00152 00153 /// Set the current icon position 00154 void setIconPosition(FXuint mode); 00155 00156 /// Get the current icon position 00157 FXuint getIconPosition() const; 00158 00159 /// Set the status line help text for this label 00160 void setHelpText(const FXString& text){ help=text; } 00161 00162 /// Get the status line help text for this label 00163 FXString getHelpText() const { return help; } 00164 00165 /// Set the tool tip message for this label 00166 void setTipText(const FXString& text){ tip=text; } 00167 00168 /// Get the tool tip message for this label 00169 FXString getTipText() const { return tip; } 00170 00171 /// Save label to a stream 00172 virtual void save(FXStream& store) const; 00173 00174 /// Load label from a stream 00175 virtual void load(FXStream& store); 00176 00177 /// Destructor 00178 virtual ~FXLabel(); 00179 }; 00180 00181 } 00182 00183 #endif

Copyright © 1997-2004 Jeroen van der Zijp