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,2017 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 setText(const FXString& text);
125 
127  FXString getText() const { return label; }
128 
130  void setIcon(FXIcon* ic);
131 
133  FXIcon* getIcon() const { return icon; }
134 
136  void setFont(FXFont *fnt);
137 
139  FXFont* getFont() const { return font; }
140 
142  FXColor getTextColor() const { return textColor; }
143 
145  void setTextColor(FXColor clr);
146 
148  void setJustify(FXuint mode);
149 
151  FXuint getJustify() const;
152 
154  void setIconPosition(FXuint mode);
155 
157  FXuint getIconPosition() const;
158 
160  void setHelpText(const FXString& text){ help=text; }
161 
163  const FXString& getHelpText() const { return help; }
164 
166  void setTipText(const FXString& text){ tip=text; }
167 
169  const FXString& getTipText() const { return tip; }
170 
172  virtual void save(FXStream& store) const;
173 
175  virtual void load(FXStream& store);
176 
178  virtual ~FXLabel();
179  };
180 
181 }
182 
183 #endif

Copyright © 1997-2016 Jeroen van der Zijp