1 /********************************************************************************
2 *                                                                               *
3 *                             O p t i o n   M e n u                             *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2005 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: FXOptionMenu.h,v 1.24 2005/01/16 16:06:06 fox Exp $                      *
23 ********************************************************************************/
24 #ifndef FXOPTIONMENU_H
25 #define FXOPTIONMENU_H
26 
27 #ifndef FXLABEL_H
28 #include "FXLabel.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXPopup;
35 
36 
37 /// Option Menu Button
38 class FXAPI FXOption : public FXLabel {
FXDECLARE(FXOption)39   FXDECLARE(FXOption)
40 protected:
41   FXOption(){}
42 private:
43   FXOption(const FXOption&);
44   FXOption &operator=(const FXOption&);
45 public:
46   long onPaint(FXObject*,FXSelector,void*);
47   long onEnter(FXObject*,FXSelector,void*);
48   long onLeave(FXObject*,FXSelector,void*);
49   long onLeftBtnPress(FXObject*,FXSelector,void*);
50   long onLeftBtnRelease(FXObject*,FXSelector,void*);
51   long onKeyPress(FXObject*,FXSelector,void*);
52   long onKeyRelease(FXObject*,FXSelector,void*);
53   long onHotKeyPress(FXObject*,FXSelector,void*);
54   long onHotKeyRelease(FXObject*,FXSelector,void*);
55 public:
56 
57   /// Constructor
58   FXOption(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT,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);
59 
60   /// Return default width
61   virtual FXint getDefaultWidth();
62 
63   /// Return default height
64   virtual FXint getDefaultHeight();
65 
66   /// Returns true because a menu button can receive focus
67   virtual FXbool canFocus() const;
68 
69   /// Set focus to this window
70   virtual void setFocus();
71 
72   /// Remove the focus from this window
73   virtual void killFocus();
74 
75   /// Destructor
76   virtual ~FXOption();
77   };
78 
79 
80 
81 /// Option Menu
82 class FXAPI FXOptionMenu : public FXLabel {
83   FXDECLARE(FXOptionMenu)
84 protected:
85   FXPopup  *pane;
86   FXOption *current;
87 protected:
FXOptionMenu()88   FXOptionMenu(){}
89 private:
90   FXOptionMenu(const FXOptionMenu&);
91   FXOptionMenu &operator=(const FXOptionMenu&);
92 public:
93   long onPaint(FXObject*,FXSelector,void*);
94   long onLeftBtnPress(FXObject*,FXSelector,void*);
95   long onLeftBtnRelease(FXObject*,FXSelector,void*);
96   long onFocusIn(FXObject*,FXSelector,void*);
97   long onFocusOut(FXObject*,FXSelector,void*);
98   long onMotion(FXObject*,FXSelector,void*);
99   long onKeyPress(FXObject*,FXSelector,void*);
100   long onKeyRelease(FXObject*,FXSelector,void*);
101   long onCmdPost(FXObject*,FXSelector,void*);
102   long onCmdUnpost(FXObject*,FXSelector,void*);
103   long onQueryHelp(FXObject*,FXSelector,void*);
104   long onQueryTip(FXObject*,FXSelector,void*);
105   long onCmdSetValue(FXObject*,FXSelector,void*);
106   long onCmdSetIntValue(FXObject*,FXSelector,void*);
107   long onCmdGetIntValue(FXObject*,FXSelector,void*);
108 public:
109 
110   /// Constructor
111   FXOptionMenu(FXComposite* p,FXPopup* pup=NULL,FXuint opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT,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);
112 
113   /// Create server-side resources
114   virtual void create();
115 
116   /// Detach server-side resources
117   virtual void detach();
118 
119   /// Delete server-side resources
120   virtual void destroy();
121 
122   /// Perform layout
123   virtual void layout();
124 
125   /// Remove the focus from this window
126   virtual void killFocus();
127 
128   /// Return default width
129   virtual FXint getDefaultWidth();
130 
131   /// Return default height
132   virtual FXint getDefaultHeight();
133 
134   /// Return TRUE if the position is logically in the pane
135   virtual FXbool contains(FXint parentx,FXint parenty) const;
136 
137   /// Set the current option
138   void setCurrent(FXOption *win,FXbool notify=FALSE);
139 
140   /// Return the current option
getCurrent()141   FXOption* getCurrent() const { return current; }
142 
143   /// Set the current option number
144   void setCurrentNo(FXint no,FXbool notify=FALSE);
145 
146   /// Get the current option number
147   FXint getCurrentNo() const;
148 
149   /// Get number of options
150   FXint getNumOptions() const;
151 
152   /// Set the pane which will be popped up
153   void setMenu(FXPopup *pup);
154 
155   /// Return the pane which is poppup up
getMenu()156   FXPopup* getMenu() const { return pane; }
157 
158   /// Returns true because a option menu can receive focus
159   virtual FXbool canFocus() const;
160 
161   /// Return TRUE if popped up
162   FXbool isPopped() const;
163 
164   /// Save option menu to a stream
165   virtual void save(FXStream& store) const;
166 
167   /// Load option menu from a stream
168   virtual void load(FXStream& store);
169 
170   /// Destructor
171   virtual ~FXOptionMenu();
172   };
173 
174 }
175 
176 #endif
177