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

FXToggleButton.h
1 /********************************************************************************
2 * *
3 * T o g g l e B u t t o n W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2022 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 FXTOGGLEBUTTON_H
22 #define FXTOGGLEBUTTON_H
23 
24 #ifndef FXLABEL_H
25 #include "FXLabel.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  TOGGLEBUTTON_AUTOGRAY = 0x00800000,
34  TOGGLEBUTTON_AUTOHIDE = 0x01000000,
35  TOGGLEBUTTON_TOOLBAR = 0x02000000,
36  TOGGLEBUTTON_KEEPSTATE= 0x04000000,
37  TOGGLEBUTTON_NORMAL = FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT
38  };
39 
40 
48 class FXAPI FXToggleButton : public FXLabel {
49  FXDECLARE(FXToggleButton)
50 protected:
51  FXString altlabel;
52  FXIcon *alticon;
53  FXHotKey althotkey;
54  FXint althotoff;
55  FXString alttip;
56  FXString althelp;
57  FXuchar state;
58  FXuchar down;
59 protected:
61  void press(FXuchar dn);
62 private:
64  FXToggleButton& operator=(const FXToggleButton&);
65 public:
66  long onPaint(FXObject*,FXSelector,void*);
67  long onUpdate(FXObject*,FXSelector,void*);
68  long onEnter(FXObject*,FXSelector,void*);
69  long onLeave(FXObject*,FXSelector,void*);
70  long onFocusIn(FXObject*,FXSelector,void*);
71  long onFocusOut(FXObject*,FXSelector,void*);
72  long onUngrabbed(FXObject*,FXSelector,void*);
73  long onLeftBtnPress(FXObject*,FXSelector,void*);
74  long onLeftBtnRelease(FXObject*,FXSelector,void*);
75  long onKeyPress(FXObject*,FXSelector,void*);
76  long onKeyRelease(FXObject*,FXSelector,void*);
77  long onHotKeyPress(FXObject*,FXSelector,void*);
78  long onHotKeyRelease(FXObject*,FXSelector,void*);
79  long onCheck(FXObject*,FXSelector,void*);
80  long onUncheck(FXObject*,FXSelector,void*);
81  long onQueryHelp(FXObject*,FXSelector,void*);
82  long onQueryTip(FXObject*,FXSelector,void*);
83  long onCmdSetValue(FXObject*,FXSelector,void*);
84  long onCmdSetIntValue(FXObject*,FXSelector,void*);
85  long onCmdGetIntValue(FXObject*,FXSelector,void*);
86 public:
87 
89  FXToggleButton(FXComposite* p,const FXString& text1,const FXString& text2,FXIcon* icon1=nullptr,FXIcon* icon2=nullptr,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TOGGLEBUTTON_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);
90 
92  virtual void create();
93 
95  virtual void detach();
96 
98  virtual FXbool canFocus() const;
99 
101  virtual FXint getDefaultWidth();
102 
104  virtual FXint getDefaultHeight();
105 
107  void setAltTextAndHotKey(const FXString& hotkeytext);
108 
110  void setAltText(const FXString& text);
111 
113  FXString getAltText() const { return altlabel; }
114 
116  void setAltIcon(FXIcon* ic);
117 
119  FXIcon* getAltIcon() const { return alticon; }
120 
122  void setState(FXuchar s=true,FXbool notify=false);
123 
125  FXuchar getState() const { return state; }
126 
128  void setAltHelpText(const FXString& text);
129 
131  FXString getAltHelpText() const { return althelp; }
132 
134  void setAltTipText(const FXString& text);
135 
137  FXString getAltTipText() const { return alttip; }
138 
140  void setToggleStyle(FXuint style);
141 
143  FXuint getToggleStyle() const;
144 
146  virtual void save(FXStream& store) const;
147 
149  virtual void load(FXStream& store);
150 
152  virtual ~FXToggleButton();
153  };
154 
155 }
156 
157 #endif
FXString getAltHelpText() const
Return alternate help text.
Definition: FXToggleButton.h:131
FXString getAltTipText() const
Return alternate tip text.
Definition: FXToggleButton.h:137
A label widget can be used to place a text and/or icon for explanation purposes.
Definition: FXLabel.h:64
Base composite.
Definition: FXComposite.h:32
The toggle button provides a two-state button, which toggles between the on and the off state each ti...
Definition: FXToggleButton.h:48
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
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
FXuchar getState() const
Return toggled state.
Definition: FXToggleButton.h:125
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
FXIcon * getAltIcon() const
Return alternate icon.
Definition: FXToggleButton.h:119
FXString getAltText() const
Return alternate text.
Definition: FXToggleButton.h:113
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp