CMenuWindow.hpp

Go to the documentation of this file.
00001 #ifndef __CMenuWindow__
00002 #define __CMenuWindow__
00003 
00004 #include "CWindow.hpp"
00005 #include "../Controls/CSubMenuMenuItem.hpp"
00006 #include "../Controls/SMenuColours.hpp"
00007 #include "../Listeners/IMenuListener.hpp"
00008 
00009 //  ===========================================================================
00010 
00011 using Exponent::GUI::Windowing::CWindow;
00012 using Exponent::GUI::Controls::CSubMenuMenuItem;
00013 using Exponent::GUI::Controls::SMenuColours;
00014 using Exponent::GUI::Listeners::IMenuListener;
00015 
00016 //  ===========================================================================
00017 
00018 namespace Exponent
00019 {
00020     namespace GUI
00021     {
00022         namespace Windowing
00023         {
00041             class CMenuWindow : public CWindow, public IMenuListener
00042             {
00044                 EXPONENT_CLASS_DECLARATION;
00047 //  ===========================================================================
00048 
00049             public:
00050 
00051 //  ===========================================================================
00052 
00053                 const static long CMENU_WINDOW_NO_SELECTION = -1;           
00055 //  ===========================================================================
00056 
00065                 CMenuWindow(const CRect &size, CWindowAttributes *attributes, CMenu *menu, const bool useIcons = true, IMenuListener *listener = NULL);
00066 
00070                 virtual ~CMenuWindow();
00071 
00072 //  ===========================================================================
00073 
00078                 virtual void openPopupWindow(const CPoint &point);
00079 
00083                 virtual void closePopupWindow();
00084 
00089                 virtual void gainedFocus(IWindow *window);
00090 
00095                 virtual void lostFocus(IWindow *window);                                 
00096 
00097 //  ===========================================================================
00098 
00103                 virtual void registerMenuListener(IMenuListener *listener) { m_menuListener = listener; }
00104 
00110                 virtual void handleMenuOpening(const CMenuEvent &event);
00111 
00117                 virtual void handleMenuClosing(const CMenuEvent &event);
00118 
00124                 virtual void handleMenuSelection(const CMenuEvent &event);
00125 
00126 //  ===========================================================================
00127 
00132                 virtual void setMenu(CMenu *menu);
00133                 
00138                 virtual void setMenuAndSize(CMenu *menu);
00139 
00145                 virtual void setFont(CFont *font);
00146 
00151                 virtual void setMenuColours(const SMenuColours &colours);
00152 
00157                 virtual void setCurrentSelection(const long selection = CMENU_WINDOW_NO_SELECTION);
00158 
00163                 virtual void useIcons(const bool icons = true);
00164 
00170                 virtual void setMinimumWidth(const long width);
00171 
00172 //  ===========================================================================
00173 
00178                 virtual void setParentMenuWindow(CMenuWindow *menuWindow) { m_parentMenuWindow = menuWindow; }
00179 
00184                 void preLauchSubWindow(const bool launching = true) { m_openingSubMenuWindow = launching; }
00185                     
00191                 void lauchSubWindow(CSubMenuMenuItem *item, IControl *control);
00192 
00196                 void killSubWindow();
00197 
00198 //  ===========================================================================
00199 
00200             protected:
00201 
00202 //  ===========================================================================
00203 
00209                 class CMenuRoot : public CControlRoot
00210                 {
00211                 public:
00212 
00217                     CMenuRoot(IWindow *parent);
00218 
00222                     virtual ~CMenuRoot();
00223 
00224 //  ===========================================================================
00225 
00230                     virtual void drawRootControl(CGraphics &graphics);
00231 
00232 //  ===========================================================================
00233 
00238                     virtual void handleLeftButtonDown(CMouseEvent &event);
00239 
00244                     virtual void handleLeftButtonUp(CMouseEvent &event);
00245 
00250                     virtual void handleMouseMovement(CMouseEvent &event);
00251 
00256                     virtual void handleMouseLeavingArea(CMouseEvent &event);
00257 
00258 //  ===========================================================================
00259 
00265                     virtual CDimension *setMenu(CMenu *menu);
00266 
00271                     virtual CMenu *getMenu() const { return m_menu; }
00272 
00277                     virtual void setRootArea(const CRect &area) { m_rootArea = area; }
00278 
00279 //  ===========================================================================
00280 
00286                     virtual void setFont(CFont *font);
00287                     
00292                     virtual CFont *getFont() { return m_font; }
00293 
00298                     virtual void setMenuColours(const SMenuColours &colours);
00299                     
00304                     virtual const SMenuColours &getMenuColours() const { return m_colours; }
00305 
00306 //  ===========================================================================
00307 
00312                     virtual void setCurrentSelection(const long selection = CMENU_WINDOW_NO_SELECTION);
00313 
00314 //  ===========================================================================
00315 
00320                     virtual void useIcons(const bool icons = true);
00321 
00327                     virtual void setMinimumWidth(const long width);
00328 
00329 //  ===========================================================================
00330 
00331                 protected:
00332 
00333 //  ===========================================================================
00334 
00339                     void findMaxStringDimension(CDimension &maxDimension);
00340 
00346                     bool findMaxIconDimension(CDimension &maxDimension);
00347 
00353                     bool doesMenuHaveExtraItems(bool &selectable);
00354 
00355 
00356 
00357 //  ===========================================================================
00358                     
00359                     CMenu *m_menu;                              
00360                     CFont *m_font;                              
00362                     //long m_itemHeight;                            /**< Height of a single item */
00363                     //long m_itemWidth;                         /**< Width of an item */
00364                     long m_minimumWidth;                        
00365                     long m_currentSelection;                    
00366                     long m_guardSelection;                      
00368                     SMenuColours m_colours;                     
00370                     CRect m_rootArea;                           
00371                     bool m_useIcons;                            
00373                 };
00374 
00375 //  ===========================================================================
00376 
00377                 IMenuListener *m_menuListener;                  
00378                 CDimension *m_mySizeOnInitialise;               
00379                 CMenuWindow *m_subWindow;                       
00380                 CMenuWindow *m_parentMenuWindow;                
00381                 bool m_openingSubMenuWindow;                    
00382                 bool m_useIcons;                                
00384                 #ifndef WIN32
00385 
00386                     bool m_closingWindow;                       
00387                     WindowGroupRef m_windowGroup;               
00389                 #endif
00390 
00392             };
00393         }
00394     }
00395 }
00396 #endif  // End of CMenuWindow.hpp

Infinity API - CMenuWindow.hpp Source File generated on 7 Mar 2007