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

FXLabel.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * L a b e l W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXLabel.h,v 1.31 2006/03/01 02:13:21 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXLABEL_H
25 #define FXLABEL_H
26 
27 #ifndef FXFRAME_H
28 #include "FXFrame.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Relationship options for icon-labels
35 enum {
36  ICON_UNDER_TEXT = 0, /// Icon appears under text
37  ICON_AFTER_TEXT = 0x00080000, /// Icon appears after text (to its right)
38  ICON_BEFORE_TEXT = 0x00100000, /// Icon appears before text (to its left)
39  ICON_ABOVE_TEXT = 0x00200000, /// Icon appears above text
40  ICON_BELOW_TEXT = 0x00400000, /// Icon appears below text
41  TEXT_OVER_ICON = ICON_UNDER_TEXT, /// Same as ICON_UNDER_TEXT
42  TEXT_AFTER_ICON = ICON_BEFORE_TEXT, /// Same as ICON_BEFORE_TEXT
43  TEXT_BEFORE_ICON = ICON_AFTER_TEXT, /// Same as ICON_AFTER_TEXT
44  TEXT_ABOVE_ICON = ICON_BELOW_TEXT, /// Same as ICON_BELOW_TEXT
45  TEXT_BELOW_ICON = ICON_ABOVE_TEXT /// Same as ICON_ABOVE_TEXT
46  };
47 
48 
49 /// Normal way to show label
50 enum {
52  };
53 
54 
55 class FXIcon;
56 class FXFont;
57 
58 
59 /**
60 * A label widget can be used to place a text and/or icon for
61 * explanation purposes. The text label may have an optional tooltip
62 * and/or help string. Icon and label are placed relative to the widget
63 * using the justfication options, and relative to each other as determined
64 * by the icon relationship options. A large number of arrangements is
65 * possible.
66 */
67 class FXAPI FXLabel : public FXFrame {
69 protected:
70  FXString label; // Text on the label
71  FXIcon* icon; // Icon on the label
72  FXFont* font; // Label font
73  FXHotKey hotkey; // Hotkey
74  FXint hotoff; // Offset in string
75  FXColor textColor; // Text color
76  FXString tip; // Tooltip
77  FXString help; // Help message
78 protected:
80  FXint labelHeight(const FXString& text) const;
81  FXint labelWidth(const FXString& text) const;
82  void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th);
83  void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw);
84  void just_y(FXint& ty,FXint& iy,FXint th,FXint ih);
85 private:
86  FXLabel(const FXLabel&);
87  FXLabel &operator=(const FXLabel&);
88 public:
89  long onPaint(FXObject*,FXSelector,void*);
90  long onHotKeyPress(FXObject*,FXSelector,void*);
91  long onHotKeyRelease(FXObject*,FXSelector,void*);
92  long onCmdSetValue(FXObject*,FXSelector,void*);
93  long onCmdSetStringValue(FXObject*,FXSelector,void*);
94  long onCmdGetStringValue(FXObject*,FXSelector,void*);
95  long onCmdSetIconValue(FXObject*,FXSelector,void*);
96  long onCmdGetIconValue(FXObject*,FXSelector,void*);
97  long onCmdSetHelp(FXObject*,FXSelector,void*);
98  long onCmdGetHelp(FXObject*,FXSelector,void*);
99  long onCmdSetTip(FXObject*,FXSelector,void*);
100  long onCmdGetTip(FXObject*,FXSelector,void*);
101  long onQueryHelp(FXObject*,FXSelector,void*);
102  long onQueryTip(FXObject*,FXSelector,void*);
103 public:
104 
105  /// Construct label with given text and icon
107 
108  /// Create server-side resources
109  virtual void create();
110 
111  /// Detach server-side resources
112  virtual void detach();
113 
114  /// Enable the window
115  virtual void enable();
116 
117  /// Disable the window
118  virtual void disable();
119 
120  /// Return default width
121  virtual FXint getDefaultWidth();
122 
123  /// Return default height
124  virtual FXint getDefaultHeight();
125 
126  /// Set the text for this label
127  void setText(const FXString& text);
128 
129  /// Get the text for this label
130  FXString getText() const { return label; }
131 
132  /// Set the icon for this label
133  void setIcon(FXIcon* ic);
134 
135  /// Get the icon for this label
136  FXIcon* getIcon() const { return icon; }
137 
138  /// Set the text font
139  void setFont(FXFont *fnt);
140 
141  /// Get the text font
142  FXFont* getFont() const { return font; }
143 
144  /// Get the current text color
145  FXColor getTextColor() const { return textColor; }
146 
147  /// Set the current text color
148  void setTextColor(FXColor clr);
149 
150  /// Set the current text-justification mode.
151  void setJustify(FXuint mode);
152 
153  /// Get the current text-justification mode.
154  FXuint getJustify() const;
155 
156  /// Set the current icon position
157  void setIconPosition(FXuint mode);
158 
159  /// Get the current icon position
160  FXuint getIconPosition() const;
161 
162  /// Set the status line help text for this label
163  void setHelpText(const FXString& text){ help=text; }
164 
165  /// Get the status line help text for this label
166  const FXString& getHelpText() const { return help; }
167 
168  /// Set the tool tip message for this label
169  void setTipText(const FXString& text){ tip=text; }
170 
171  /// Get the tool tip message for this label
172  const FXString& getTipText() const { return tip; }
173 
174  /// Save label to a stream
175  virtual void save(FXStream& store) const;
176 
177  /// Load label from a stream
178  virtual void load(FXStream& store);
179 
180  /// Destructor
181  virtual ~FXLabel();
182  };
183 
184 }
185 
186 #endif
Definition: FXLabel.h:58
Same as ICON_BELOW_TEXT.
Definition: FXLabel.h:47
A label widget can be used to place a text and/or icon for explanation purposes.
Definition: FXLabel.h:79
The Frame widget provides borders around some contents.
Definition: FXFrame.h:73
unsigned int FXuint
Definition: fxdefs.h:389
FXuint FXHotKey
Definition: fxdefs.h:450
Definition: FXFrame.h:56
Same as ICON_ABOVE_TEXT.
Definition: FXLabel.h:48
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
Base composite.
Definition: FXComposite.h:35
Same as ICON_BEFORE_TEXT.
Definition: FXLabel.h:45
FXuint FXColor
Definition: fxdefs.h:447
Icon appears above text.
Definition: FXLabel.h:42
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
Same as ICON_UNDER_TEXT.
Definition: FXLabel.h:44
Icon appears under text.
Definition: FXLabel.h:39
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Window Device Context.
Definition: FXDCWindow.h:52
Icon appears below text.
Definition: FXLabel.h:43
Same as ICON_AFTER_TEXT.
Definition: FXLabel.h:46
Icon appears after text (to its right)
Definition: FXLabel.h:40
Icon appears before text (to its left)
Definition: FXLabel.h:41
Font class.
Definition: FXFont.h:142
Default justification is centered text.
Definition: FXFrame.h:39
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp