FXMenuButton.h

Go to the documentation of this file.
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,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: FXMenuButton.h,v 1.24 2006/01/22 17:58:06 fox Exp $                      *
00023 ********************************************************************************/
00024 #ifndef FXMENUBUTTON_H
00025 #define FXMENUBUTTON_H
00026 
00027 #ifndef FXLABEL_H
00028 #include "FXLabel.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 class FXPopup;
00035 
00036 
00037 // Menu button options
00038 enum {
00039   MENUBUTTON_AUTOGRAY      = 0x00800000,                                      
00040   MENUBUTTON_AUTOHIDE      = 0x01000000,                                      
00041   MENUBUTTON_TOOLBAR       = 0x02000000,                                      
00042   MENUBUTTON_DOWN          = 0,                                               
00043   MENUBUTTON_UP            = 0x04000000,                                      
00044   MENUBUTTON_LEFT          = 0x08000000,                                      
00045   MENUBUTTON_RIGHT         = MENUBUTTON_LEFT|MENUBUTTON_UP,                   
00046   MENUBUTTON_NOARROWS      = 0x10000000,                                      
00047   MENUBUTTON_ATTACH_LEFT   = 0,                                               
00048   MENUBUTTON_ATTACH_TOP    = MENUBUTTON_ATTACH_LEFT,                          
00049   MENUBUTTON_ATTACH_RIGHT  = 0x20000000,                                      
00050   MENUBUTTON_ATTACH_BOTTOM = MENUBUTTON_ATTACH_RIGHT,                         
00051   MENUBUTTON_ATTACH_CENTER = 0x40000000,                                      
00052   MENUBUTTON_ATTACH_BOTH   = MENUBUTTON_ATTACH_CENTER|MENUBUTTON_ATTACH_RIGHT 
00053   };
00054 
00055 
00056 
00072 class FXAPI FXMenuButton : public FXLabel {
00073   FXDECLARE(FXMenuButton)
00074 protected:
00075   FXPopup *pane;                  // Pane to pop up
00076   FXint    offsetx;               // Shift attachment point x
00077   FXint    offsety;               // Shift attachment point y
00078   FXbool   state;                 // Pane was popped
00079 protected:
00080   FXMenuButton();
00081 private:
00082   FXMenuButton(const FXMenuButton&);
00083   FXMenuButton &operator=(const FXMenuButton&);
00084 public:
00085   long onPaint(FXObject*,FXSelector,void*);
00086   long onUpdate(FXObject*,FXSelector,void*);
00087   long onEnter(FXObject*,FXSelector,void*);
00088   long onLeave(FXObject*,FXSelector,void*);
00089   long onFocusIn(FXObject*,FXSelector,void*);
00090   long onFocusOut(FXObject*,FXSelector,void*);
00091   long onUngrabbed(FXObject*,FXSelector,void*);
00092   long onMotion(FXObject*,FXSelector,void*);
00093   long onLeftBtnPress(FXObject*,FXSelector,void*);
00094   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00095   long onKeyPress(FXObject*,FXSelector,void*);
00096   long onKeyRelease(FXObject*,FXSelector,void*);
00097   long onHotKeyPress(FXObject*,FXSelector,void*);
00098   long onHotKeyRelease(FXObject*,FXSelector,void*);
00099   long onCmdPost(FXObject*,FXSelector,void*);
00100   long onCmdUnpost(FXObject*,FXSelector,void*);
00101 public:
00102 
00104   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);
00105 
00107   virtual void create();
00108 
00110   virtual void detach();
00111 
00113   virtual FXint getDefaultWidth();
00114 
00116   virtual FXint getDefaultHeight();
00117 
00119   virtual bool canFocus() const;
00120 
00122   virtual void killFocus();
00123 
00125   virtual bool contains(FXint parentx,FXint parenty) const;
00126 
00128   void setMenu(FXPopup *pup);
00129 
00131   FXPopup* getMenu() const { return pane; }
00132 
00134   void setXOffset(FXint offx){ offsetx=offx; }
00135 
00137   FXint getXOffset() const { return offsetx; }
00138 
00140   void setYOffset(FXint offy){ offsety=offy; }
00141 
00143   FXint getYOffset() const { return offsety; }
00144 
00146   void setButtonStyle(FXuint style);
00147 
00149   FXuint getButtonStyle() const;
00150 
00152   void setPopupStyle(FXuint style);
00153 
00155   FXuint getPopupStyle() const;
00156 
00158   void setAttachment(FXuint att);
00159 
00161   FXuint getAttachment() const;
00162 
00164   virtual void save(FXStream& store) const;
00165 
00167   virtual void load(FXStream& store);
00168 
00170   virtual ~FXMenuButton();
00171   };
00172 
00173 }
00174 
00175 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:23 2009 for TnFOX by doxygen v1.4.7