Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Menus.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 //    Author: Richard van Balen
00003 
00004 #ifndef OglGui_Menus_h
00005 #define OglGui_Menus_h
00006 
00007 #ifndef OglGui_Window_h
00008 #include "OglGui/Window.h"
00009 #endif
00010 
00011 #ifndef OglGui_MenuListener_h
00012 #include "OglGui/MenuListener.h"
00013 #endif
00014 
00015 namespace OglGui {
00016 
00017 class Menus : public Window
00018 {
00019 public:
00020     Menus(Window* parent) :
00021         Window(oglSys.GetTopOGLWND(parent->GetOGLWND()), 0, 0, 20, 20)
00022     {
00023         Init(oglSys.GetTopOGLWND(mOglWnd));
00024     }
00025 
00026     void SetMenuListener(MenuListener*l)
00027     {
00028         mMenuListener = l;
00029     }
00030 
00031     void ActivateListener(Menu* menu, int menuIdx, std::string itemName,
00032                           int itemIdx, void* userData)
00033     {
00034         if (!mMenuListener)
00035             return;
00036         mMenuListener->OnMenuItem(menu, menuIdx, itemName, itemIdx, userData);
00037     }
00038 
00039     Menu* CreateMenu(int menuIdx=0, int w=100)
00040     {
00041         Menu* menu = new Menu(this, menuIdx, w);
00042         mMenus.push_back(menu);
00043     }
00044 
00045     void Open()
00046     {
00047         oglSys.BringToFront(mOglWnd);
00048         oglSys.SetDimensions(mOglWnd,0,0,mOglTopWnd->width,mOglTopWnd->height);
00049         SetVisible(true);
00050         oglFocusWnd = mOglWnd;
00051     }
00052 
00053     void Hide()
00054     {
00055         oglFocusWnd = 0;
00056         SetVisible(false);
00057         for (int i=0; i<mMenus.size(); i++)
00058         {
00059             mMenus[i]->SetVisible(false);
00060         }
00061     }
00062 
00063     virtual void InitDisplayFunc()
00064     {
00065         oglSys.SetDimensions(mOglWnd,0,0,mOglTopWnd->width,mOglTopWnd->height);
00066         Window::InitDisplayFunc();
00067     }
00068 
00069     virtual void MouseFunc(int msg, int btn, int state, int x, int y)
00070     {
00071         if (msg==oglMouseDown)
00072             Hide();
00073     }
00074 
00075 private:
00076     std::vector<Menu*>  mMenus;
00077     MenuListener*       mMenuListener;
00078     OGLWND*             mOglTopWnd;
00079 
00080     void Init(OGLWND* oglTopWnd)
00081     {
00082         mMenuListener = 0;
00083         mOglTopWnd = oglTopWnd;
00084         SetVisible(false);
00085     }
00086 };
00087 
00088 } // Namespace OglGui
00089 #endif
00090 

Generated on Fri Mar 19 09:31:37 2010 for ImpalaSrc by  doxygen 1.5.1