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

FXLabel.h
1 /********************************************************************************
2 * *
3 * L a b e l W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXLABEL_H
22 #define FXLABEL_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  ICON_UNDER_TEXT = 0,
34  ICON_AFTER_TEXT = 0x00080000,
35  ICON_BEFORE_TEXT = 0x00100000,
36  ICON_ABOVE_TEXT = 0x00200000,
37  ICON_BELOW_TEXT = 0x00400000,
38  TEXT_OVER_ICON = ICON_UNDER_TEXT,
39  TEXT_AFTER_ICON = ICON_BEFORE_TEXT,
40  TEXT_BEFORE_ICON = ICON_AFTER_TEXT,
41  TEXT_ABOVE_ICON = ICON_BELOW_TEXT,
42  TEXT_BELOW_ICON = ICON_ABOVE_TEXT
43  };
44 
45 
47 enum {
48  LABEL_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT
49  };
50 
51 
52 class FXIcon;
53 class FXFont;
54 
55 
64 class FXAPI FXLabel : public FXFrame {
65  FXDECLARE(FXLabel)
66 protected:
67  FXString label; // Text on the label
68  FXIcon *icon; // Icon on the label
69  FXFont *font; // Label font
70  FXString help; // Help message
71  FXString tip; // Tooltip
72  FXColor textColor; // Text color
73  FXHotKey hotkey; // Hotkey
74  FXint hotoff; // Offset in string
75 protected:
76  FXLabel();
77  FXint labelHeight(const FXString& text) const;
78  FXint labelWidth(const FXString& text) const;
79  void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th);
80  void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw);
81  void just_y(FXint& ty,FXint& iy,FXint th,FXint ih);
82 private:
83  FXLabel(const FXLabel&);
84  FXLabel &operator=(const FXLabel&);
85 public:
86  long onPaint(FXObject*,FXSelector,void*);
87  long onHotKeyPress(FXObject*,FXSelector,void*);
88  long onHotKeyRelease(FXObject*,FXSelector,void*);
89  long onCmdSetValue(FXObject*,FXSelector,void*);
90  long onCmdSetStringValue(FXObject*,FXSelector,void*);
91  long onCmdGetStringValue(FXObject*,FXSelector,void*);
92  long onCmdSetIconValue(FXObject*,FXSelector,void*);
93  long onCmdGetIconValue(FXObject*,FXSelector,void*);
94  long onCmdSetHelp(FXObject*,FXSelector,void*);
95  long onCmdGetHelp(FXObject*,FXSelector,void*);
96  long onCmdSetTip(FXObject*,FXSelector,void*);
97  long onCmdGetTip(FXObject*,FXSelector,void*);
98  long onQueryHelp(FXObject*,FXSelector,void*);
99  long onQueryTip(FXObject*,FXSelector,void*);
100 public:
101 
103  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);
104 
106  virtual void create();
107 
109  virtual void detach();
110 
112  virtual void enable();
113 
115  virtual void disable();
116 
118  virtual FXint getDefaultWidth();
119 
121  virtual FXint getDefaultHeight();
122 
124  void setTextAndHotKey(const FXString& hotkeytext);
125 
127  void setText(const FXString& text);
128 
130  FXString getText() const { return label; }
131 
133  void setIcon(FXIcon* ic);
134 
136  FXIcon* getIcon() const { return icon; }
137 
139  void setFont(FXFont *fnt);
140 
142  FXFont* getFont() const { return font; }
143 
145  FXColor getTextColor() const { return textColor; }
146 
148  void setTextColor(FXColor clr);
149 
151  void setJustify(FXuint mode);
152 
154  FXuint getJustify() const;
155 
157  void setIconPosition(FXuint mode);
158 
160  FXuint getIconPosition() const;
161 
163  void setHelpText(const FXString& text){ help=text; }
164 
166  const FXString& getHelpText() const { return help; }
167 
169  void setTipText(const FXString& text){ tip=text; }
170 
172  const FXString& getTipText() const { return tip; }
173 
175  virtual void save(FXStream& store) const;
176 
178  virtual void load(FXStream& store);
179 
181  virtual ~FXLabel();
182  };
183 
184 }
185 
186 #endif
FXString getText() const
Get the text for this label.
Definition: FXLabel.h:130
void setTipText(const FXString &text)
Set the tool tip message for this label.
Definition: FXLabel.h:169
void setHelpText(const FXString &text)
Set the status line help text for this label.
Definition: FXLabel.h:163
const FXString & getHelpText() const
Get the status line help text for this label.
Definition: FXLabel.h:166
A label widget can be used to place a text and/or icon for explanation purposes.
Definition: FXLabel.h:64
The Frame widget provides borders around some contents.
Definition: FXFrame.h:58
FXIcon * getIcon() const
Get the icon for this label.
Definition: FXLabel.h:136
Base composite.
Definition: FXComposite.h:32
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXColor getTextColor() const
Get the current text color.
Definition: FXLabel.h:145
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
FXFont * getFont() const
Get the text font.
Definition: FXLabel.h:142
const FXString & getTipText() const
Get the tool tip message for this label.
Definition: FXLabel.h:172
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
Window Device Context.
Definition: FXDCWindow.h:48
Font class.
Definition: FXFont.h:137
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp