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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXMenuButton.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                        M e n u B u t t o n   W i d g e t                      *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXMENUBUTTON_H
00022 #define FXMENUBUTTON_H
00023 
00024 #ifndef FXLABEL_H
00025 #include "FXLabel.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 class FXPopup;
00032 
00033 
00034 // Menu button options
00035 enum {
00036   MENUBUTTON_AUTOGRAY      = 0x00800000,                                      
00037   MENUBUTTON_AUTOHIDE      = 0x01000000,                                      
00038   MENUBUTTON_TOOLBAR       = 0x02000000,                                      
00039   MENUBUTTON_DOWN          = 0,                                               
00040   MENUBUTTON_UP            = 0x04000000,                                      
00041   MENUBUTTON_LEFT          = 0x08000000,                                      
00042   MENUBUTTON_RIGHT         = MENUBUTTON_LEFT|MENUBUTTON_UP,                   
00043   MENUBUTTON_NOARROWS      = 0x10000000,                                      
00044   MENUBUTTON_ATTACH_LEFT   = 0,                                               
00045   MENUBUTTON_ATTACH_TOP    = MENUBUTTON_ATTACH_LEFT,                          
00046   MENUBUTTON_ATTACH_RIGHT  = 0x20000000,                                      
00047   MENUBUTTON_ATTACH_BOTTOM = MENUBUTTON_ATTACH_RIGHT,                         
00048   MENUBUTTON_ATTACH_CENTER = 0x40000000,                                      
00049   MENUBUTTON_ATTACH_BOTH   = MENUBUTTON_ATTACH_CENTER|MENUBUTTON_ATTACH_RIGHT 
00050   };
00051 
00052 
00053 
00069 class FXAPI FXMenuButton : public FXLabel {
00070   FXDECLARE(FXMenuButton)
00071 protected:
00072   FXPopup *pane;                  // Pane to pop up
00073   FXint    offsetx;               // Shift attachment point x
00074   FXint    offsety;               // Shift attachment point y
00075   FXbool   state;                 // Pane was popped
00076 protected:
00077   FXMenuButton();
00078 private:
00079   FXMenuButton(const FXMenuButton&);
00080   FXMenuButton &operator=(const FXMenuButton&);
00081 public:
00082   long onPaint(FXObject*,FXSelector,void*);
00083   long onUpdate(FXObject*,FXSelector,void*);
00084   long onEnter(FXObject*,FXSelector,void*);
00085   long onLeave(FXObject*,FXSelector,void*);
00086   long onFocusIn(FXObject*,FXSelector,void*);
00087   long onFocusOut(FXObject*,FXSelector,void*);
00088   long onUngrabbed(FXObject*,FXSelector,void*);
00089   long onMotion(FXObject*,FXSelector,void*);
00090   long onButtonPress(FXObject*,FXSelector,void*);
00091   long onButtonRelease(FXObject*,FXSelector,void*);
00092   long onKeyPress(FXObject*,FXSelector,void*);
00093   long onKeyRelease(FXObject*,FXSelector,void*);
00094   long onHotKeyPress(FXObject*,FXSelector,void*);
00095   long onHotKeyRelease(FXObject*,FXSelector,void*);
00096   long onCmdPost(FXObject*,FXSelector,void*);
00097   long onCmdUnpost(FXObject*,FXSelector,void*);
00098 public:
00099 
00101   FXMenuButton(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXPopup* pup=NULL,FXuint opts=JUSTIFY_NORMAL|ICON_BEFORE_TEXT|MENUBUTTON_DOWN,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);
00102 
00104   virtual void create();
00105 
00107   virtual void detach();
00108 
00110   virtual FXint getDefaultWidth();
00111 
00113   virtual FXint getDefaultHeight();
00114 
00116   virtual FXbool canFocus() const;
00117 
00119   virtual void killFocus();
00120 
00122   virtual FXbool contains(FXint parentx,FXint parenty) const;
00123 
00125   void setMenu(FXPopup *pup);
00126 
00128   FXPopup* getMenu() const { return pane; }
00129 
00131   void showMenu(FXbool shw);
00132 
00134   FXbool isMenuShown() const;
00135 
00137   void setXOffset(FXint offx){ offsetx=offx; }
00138 
00140   FXint getXOffset() const { return offsetx; }
00141 
00143   void setYOffset(FXint offy){ offsety=offy; }
00144 
00146   FXint getYOffset() const { return offsety; }
00147 
00149   void setButtonStyle(FXuint style);
00150 
00152   FXuint getButtonStyle() const;
00153 
00155   void setPopupStyle(FXuint style);
00156 
00158   FXuint getPopupStyle() const;
00159 
00161   void setAttachment(FXuint att);
00162 
00164   FXuint getAttachment() const;
00165 
00167   virtual void save(FXStream& store) const;
00168 
00170   virtual void load(FXStream& store);
00171 
00173   virtual ~FXMenuButton();
00174   };
00175 
00176 }
00177 
00178 #endif

Copyright © 1997-2011 Jeroen van der Zijp