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

FXPopup.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                     P o p u p   W i n d o w   W i d g e t                     *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2009 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 * $Id: FXPopup.h,v 1.46 2009/02/05 07:23:56 fox Exp $                           *
00022 ********************************************************************************/
00023 #ifndef FXPOPUP_H
00024 #define FXPOPUP_H
00025 
00026 #ifndef FXSHELL_H
00027 #include "FXShell.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /// Popup internal orientation
00034 enum {
00035   POPUP_VERTICAL   = 0,               /// Vertical orientation
00036   POPUP_HORIZONTAL = 0x00020000,      /// Horizontal orientation
00037   POPUP_SHRINKWRAP = 0x00040000       /// Shrinkwrap to content
00038   };
00039 
00040 
00041 
00042 /**
00043 * Popup window is used as a container for transitional controls
00044 * such as menu panes and other ephemeral windows.  One of its
00045 * principal characteristics is that no other controls, except the
00046 * ones inside the popup are capable of interaction.  Any click outside
00047 * of a popup will cause the popup to be closed.
00048 * Contents of popups may be arranged vertically (POPUP_VERTICAL) or 
00049 * horizontally (POPUP_HORIZONTAL).
00050 * The special POPUP_SHRINKWRAP option causes the application to recompute
00051 * the size of the popup window based on its contents at the time it is
00052 * shown, thus permitting dynamically changing content.
00053 */
00054 class FXAPI FXPopup : public FXShell {
00055   FXDECLARE(FXPopup)
00056 private:
00057   FXPopup  *prevActive;         // Popup below this one in stack
00058   FXPopup  *nextActive;         // Popup above this one in stack
00059 protected:
00060   FXWindow *grabowner;          // Window which will get grabbed when outside
00061   FXColor   baseColor;
00062   FXColor   hiliteColor;
00063   FXColor   shadowColor;
00064   FXColor   borderColor;
00065   FXint     border;
00066 protected:
00067   FXPopup();
00068   virtual FXbool doesOverrideRedirect() const;
00069   void drawBorderRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00070   void drawRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00071   void drawSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00072   void drawRidgeRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00073   void drawGrooveRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00074   void drawDoubleRaisedRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00075   void drawDoubleSunkenRectangle(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00076   void drawFrame(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00077 private:
00078   FXPopup(const FXPopup&);
00079   FXPopup &operator=(const FXPopup&);
00080 #ifdef WIN32
00081   virtual const void* GetClass() const;
00082 #endif
00083 public:
00084   long onPaint(FXObject*,FXSelector,void*);
00085   long onFocusUp(FXObject*,FXSelector,void*);
00086   long onFocusDown(FXObject*,FXSelector,void*);
00087   long onFocusLeft(FXObject*,FXSelector,void*);
00088   long onFocusRight(FXObject*,FXSelector,void*);
00089   long onFocusNext(FXObject*,FXSelector,void*);
00090   long onFocusPrev(FXObject*,FXSelector,void*);
00091   long onEnter(FXObject*,FXSelector,void*);
00092   long onLeave(FXObject*,FXSelector,void*);
00093   long onMotion(FXObject*,FXSelector,void*);
00094   long onMap(FXObject*,FXSelector,void*);
00095   long onButtonPress(FXObject*,FXSelector,void*);
00096   long onButtonRelease(FXObject*,FXSelector,void*);
00097   long onUngrabbed(FXObject*,FXSelector,void*);
00098   long onCmdUnpost(FXObject*,FXSelector,void*);
00099   long onKeyPress(FXObject*,FXSelector,void*);
00100   long onKeyRelease(FXObject*,FXSelector,void*);
00101   long onCmdChoice(FXObject*,FXSelector,void*);
00102 public:
00103   enum {
00104     ID_CHOICE=FXShell::ID_LAST,
00105     ID_LAST=ID_CHOICE+1000
00106     };
00107 public:
00108 
00109   /// Construct popup pane
00110   FXPopup(FXWindow* owner,FXuint opts=POPUP_VERTICAL|FRAME_RAISED|FRAME_THICK,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00111 
00112   /// Return the default width of this window
00113   virtual FXint getDefaultWidth();
00114 
00115   /// Return the default height of this window
00116   virtual FXint getDefaultHeight();
00117 
00118   /// Perform layout
00119   virtual void layout();
00120 
00121   /// Return a pointer to the prior active popup
00122   FXPopup* getPrevActive() const { return prevActive; }
00123 
00124   /// Return a pointer to the next active popup
00125   FXPopup* getNextActive() const { return nextActive; }
00126 
00127   /// Move the focus to this window
00128   virtual void setFocus();
00129 
00130   /// Remove the focus from this window
00131   virtual void killFocus();
00132 
00133   /// Show this window
00134   virtual void show();
00135 
00136   /// Hide this window
00137   virtual void hide();
00138 
00139   /// Change frame style
00140   void setFrameStyle(FXuint style);
00141 
00142   /// Return frame style
00143   FXuint getFrameStyle() const;
00144 
00145   /// Return border width
00146   FXint getBorderWidth() const { return border; }
00147 
00148   /// Change highlight color
00149   void setHiliteColor(FXColor clr);
00150 
00151   /// Return highlight color
00152   FXColor getHiliteColor() const { return hiliteColor; }
00153 
00154   /// Change shadow color
00155   void setShadowColor(FXColor clr);
00156 
00157   /// Return shadow color
00158   FXColor getShadowColor() const { return shadowColor; }
00159 
00160   /// Change border color
00161   void setBorderColor(FXColor clr);
00162 
00163   /// Return border color
00164   FXColor getBorderColor() const { return borderColor; }
00165 
00166   /// Change base color
00167   void setBaseColor(FXColor clr);
00168 
00169   /// Return base color
00170   FXColor getBaseColor() const { return baseColor; }
00171 
00172   /// Popup the menu and grab to the given owner
00173   virtual void popup(FXWindow* grabto,FXint x,FXint y,FXint w=0,FXint h=0);
00174 
00175   /// Pop down the menu
00176   virtual void popdown();
00177 
00178   /// Return current grab owner
00179   FXWindow* getGrabOwner() const;
00180 
00181 //   /// Popup the menu and grab to the given owner
00182 //   virtual FXint popup(FXint x,FXint y,FXint w=0,FXint h=0);
00183 //
00184 //   /// Pop down the menu
00185 //   virtual void popdown(FXint value);
00186 
00187   /// Change popup orientation
00188   void setOrientation(FXuint orient);
00189 
00190   /// Return popup orientation
00191   FXuint getOrientation() const;
00192 
00193   /// Change shrinkwrap mode
00194   void setShrinkWrap(FXbool flag);
00195 
00196   /// Return shrinkwrap mode
00197   FXbool getShrinkWrap() const;
00198 
00199   /// Does save-unders
00200   virtual FXbool doesSaveUnder() const;
00201 
00202   /// Destructor
00203   virtual ~FXPopup();
00204   };
00205 
00206 }
00207 
00208 #endif

Copyright © 1997-2009 Jeroen van der Zijp