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,2026 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  FXint spacing; // Icon and label spacing
73  FXColor textColor; // Text color
74  FXHotKey hotkey; // Hotkey
75  FXint hotoff; // Offset in string
76 protected:
77  FXLabel();
78  FXint labelHeight(const FXString& text) const;
79  FXint labelWidth(const FXString& text) const;
80  void drawLabel(FXDCWindow& dc,const FXString& text,FXint hot,FXint tx,FXint ty,FXint tw,FXint th);
81  void just_x(FXint& tx,FXint& ix,FXint tw,FXint iw);
82  void just_y(FXint& ty,FXint& iy,FXint th,FXint ih);
83 private:
84  FXLabel(const FXLabel&);
85  FXLabel &operator=(const FXLabel&);
86 public:
87  long onPaint(FXObject*,FXSelector,void*);
88  long onHotKeyPress(FXObject*,FXSelector,void*);
89  long onHotKeyRelease(FXObject*,FXSelector,void*);
90  long onCmdSetValue(FXObject*,FXSelector,void*);
91  long onCmdSetStringValue(FXObject*,FXSelector,void*);
92  long onCmdGetStringValue(FXObject*,FXSelector,void*);
93  long onCmdSetIconValue(FXObject*,FXSelector,void*);
94  long onCmdGetIconValue(FXObject*,FXSelector,void*);
95  long onCmdSetHelp(FXObject*,FXSelector,void*);
96  long onCmdGetHelp(FXObject*,FXSelector,void*);
97  long onCmdSetTip(FXObject*,FXSelector,void*);
98  long onCmdGetTip(FXObject*,FXSelector,void*);
99  long onQueryHelp(FXObject*,FXSelector,void*);
100  long onQueryTip(FXObject*,FXSelector,void*);
101 public:
102 
104  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);
105 
107  virtual void create() override;
108 
110  virtual void detach() override;
111 
113  virtual void enable() override;
114 
116  virtual void disable() override;
117 
119  virtual FXint getDefaultWidth() override;
120 
122  virtual FXint getDefaultHeight() override;
123 
125  void setTextAndHotKey(const FXString& hotkeytext);
126 
128  void setText(const FXString& text);
129 
131  FXString getText() const { return label; }
132 
134  void setIcon(FXIcon* ic);
135 
137  FXIcon* getIcon() const { return icon; }
138 
140  void setFont(FXFont *fnt);
141 
143  FXFont* getFont() const { return font; }
144 
146  FXColor getTextColor() const { return textColor; }
147 
149  void setTextColor(FXColor clr);
150 
152  void setJustify(FXuint mode);
153 
155  FXuint getJustify() const;
156 
158  void setIconPosition(FXuint mode);
159 
161  FXuint getIconPosition() const;
162 
164  void setSpacing(FXint sp);
165 
167  FXint getSpacing() const { return spacing; }
168 
170  void setHelpText(const FXString& text){ help=text; }
171 
173  const FXString& getHelpText() const { return help; }
174 
176  void setTipText(const FXString& text){ tip=text; }
177 
179  const FXString& getTipText() const { return tip; }
180 
182  virtual void save(FXStream& store) const override;
183 
185  virtual void load(FXStream& store) override;
186 
188  virtual ~FXLabel();
189  };
190 
191 }
192 
193 #endif
FXString getText() const
Get the text for this label.
Definition: FXLabel.h:131
void setTipText(const FXString &text)
Set the tool tip message for this label.
Definition: FXLabel.h:176
void setHelpText(const FXString &text)
Set the status line help text for this label.
Definition: FXLabel.h:170
const FXString & getHelpText() const
Get the status line help text for this label.
Definition: FXLabel.h:173
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:137
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:146
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:143
FXint getSpacing() const
Get spacing between icon and label.
Definition: FXLabel.h:167
const FXString & getTipText() const
Get the tool tip message for this label.
Definition: FXLabel.h:179
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:138
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-2026 Jeroen van der Zijp