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

FXOptionMenu.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                             O p t i o n   M e n u                             *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXOptionMenu.h,v 1.28 2006/02/06 02:03:38 fox Exp $                      *
00023 ********************************************************************************/
00024 #ifndef FXOPTIONMENU_H
00025 #define FXOPTIONMENU_H
00026 
00027 #ifndef FXLABEL_H
00028 #include "FXLabel.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 class FXPopup;
00035 
00036 
00037 /// Option Menu Button
00038 class FXAPI FXOption : public FXLabel {
00039   FXDECLARE(FXOption)
00040 protected:
00041   FXColor selbackColor;
00042   FXColor seltextColor;
00043 protected:
00044   FXOption();
00045 private:
00046   FXOption(const FXOption&);
00047   FXOption &operator=(const FXOption&);
00048 public:
00049   long onPaint(FXObject*,FXSelector,void*);
00050   long onEnter(FXObject*,FXSelector,void*);
00051   long onLeave(FXObject*,FXSelector,void*);
00052   long onLeftBtnPress(FXObject*,FXSelector,void*);
00053   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00054   long onKeyPress(FXObject*,FXSelector,void*);
00055   long onKeyRelease(FXObject*,FXSelector,void*);
00056   long onHotKeyPress(FXObject*,FXSelector,void*);
00057   long onHotKeyRelease(FXObject*,FXSelector,void*);
00058 public:
00059 
00060   /// Constructor
00061   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);
00062 
00063   /// Return default width
00064   virtual FXint getDefaultWidth();
00065 
00066   /// Return default height
00067   virtual FXint getDefaultHeight();
00068 
00069   /// Returns true because a menu button can receive focus
00070   virtual bool canFocus() const;
00071 
00072   /// Set focus to this window
00073   virtual void setFocus();
00074 
00075   /// Remove the focus from this window
00076   virtual void killFocus();
00077 
00078   /// Return the selection background color
00079   void setSelBackColor(FXColor clr);
00080 
00081   /// Return the selection background color
00082   FXColor getSelBackColor() const { return selbackColor; }
00083 
00084   /// Return the selection text color
00085   void setSelTextColor(FXColor clr);
00086 
00087   /// Return the selection text color
00088   FXColor getSelTextColor() const { return seltextColor; }
00089 
00090   /// Destructor
00091   virtual ~FXOption();
00092   };
00093 
00094 
00095 
00096 /// Option Menu
00097 class FXAPI FXOptionMenu : public FXLabel {
00098   FXDECLARE(FXOptionMenu)
00099 protected:
00100   FXPopup  *pane;
00101   FXOption *current;
00102 protected:
00103   FXOptionMenu(){}
00104 private:
00105   FXOptionMenu(const FXOptionMenu&);
00106   FXOptionMenu &operator=(const FXOptionMenu&);
00107 public:
00108   long onPaint(FXObject*,FXSelector,void*);
00109   long onLeftBtnPress(FXObject*,FXSelector,void*);
00110   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00111   long onFocusIn(FXObject*,FXSelector,void*);
00112   long onFocusOut(FXObject*,FXSelector,void*);
00113   long onMotion(FXObject*,FXSelector,void*);
00114   long onKeyPress(FXObject*,FXSelector,void*);
00115   long onKeyRelease(FXObject*,FXSelector,void*);
00116   long onCmdPost(FXObject*,FXSelector,void*);
00117   long onCmdUnpost(FXObject*,FXSelector,void*);
00118   long onQueryHelp(FXObject*,FXSelector,void*);
00119   long onQueryTip(FXObject*,FXSelector,void*);
00120   long onCmdSetValue(FXObject*,FXSelector,void*);
00121   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00122   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00123   long onMouseWheel(FXObject*,FXSelector,void*);
00124 public:
00125 
00126   /// Constructor
00127   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);
00128 
00129   /// Create server-side resources
00130   virtual void create();
00131 
00132   /// Detach server-side resources
00133   virtual void detach();
00134 
00135   /// Delete server-side resources
00136   virtual void destroy();
00137 
00138   /// Perform layout
00139   virtual void layout();
00140 
00141   /// Remove the focus from this window
00142   virtual void killFocus();
00143 
00144   /// Return default width
00145   virtual FXint getDefaultWidth();
00146 
00147   /// Return default height
00148   virtual FXint getDefaultHeight();
00149 
00150   /// Return TRUE if the position is logically in the pane
00151   virtual bool contains(FXint parentx,FXint parenty) const;
00152 
00153   /// Set the current option
00154   void setCurrent(FXOption *win,FXbool notify=FALSE);
00155 
00156   /// Return the current option
00157   FXOption* getCurrent() const { return current; }
00158 
00159   /// Set the current option number
00160   void setCurrentNo(FXint no,FXbool notify=FALSE);
00161 
00162   /// Get the current option number
00163   FXint getCurrentNo() const;
00164 
00165   /// Get number of options
00166   FXint getNumOptions() const;
00167 
00168   /// Set the pane which will be popped up
00169   void setMenu(FXPopup *pup);
00170 
00171   /// Return the pane which is poppup up
00172   FXPopup* getMenu() const { return pane; }
00173 
00174   /// Returns true because a option menu can receive focus
00175   virtual bool canFocus() const;
00176 
00177   /// Return TRUE if popped up
00178   FXbool isPopped() const;
00179 
00180   /// Save option menu to a stream
00181   virtual void save(FXStream& store) const;
00182 
00183   /// Load option menu from a stream
00184   virtual void load(FXStream& store);
00185 
00186   /// Destructor
00187   virtual ~FXOptionMenu();
00188   };
00189 
00190 }
00191 
00192 #endif

Copyright © 1997-2005 Jeroen van der Zijp