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

MenuTopPane.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 //    Author: Richard van Balen
00003 
00004 #ifndef OglGui_MenuTopPane_h
00005 #define OglGui_MenuTopPane_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 MenuTopPane : public Window
00018 {
00019 public:
00020     MenuTopPane(Window* parent) :
00021         Window(oglSys.GetTopOGLWND(parent->GetOGLWND()), 0, 0, 20, 20)
00022     {
00023         Init();
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     void Open()
00040     {
00041         oglSys.BringToFront(mOglWnd);
00042         SetDimensions(0,0,mOglTopWnd->width,mOglTopWnd->height);
00043         SetVisible(true);
00044         oglFocusWnd = mOglWnd;
00045     }
00046 
00047     void Hide()
00048     {
00049         oglFocusWnd = 0;
00050         SetVisible(false);
00051         LIST *obj;
00052         //ForAllElements(obj, mOglWnd->wndList)
00053         for(obj = mOglWnd->wndList ; obj ; obj = obj->next)
00054         {
00055             //OGLWND* oglWnd = (OGLWND*) Info(obj);
00056             OGLWND* oglWnd = (OGLWND*) ((obj) -> info);
00057             ClearTags((TAGABLE*)oglWnd, visibleTag);
00058         }
00059     }
00060 
00061     virtual void InitDisplayFunc()
00062     {
00063         SetDimensions(0,0,mOglTopWnd->width,mOglTopWnd->height);
00064         Window::InitDisplayFunc();
00065     }
00066 
00067     virtual void MouseFunc(int msg, int btn, int state, int x, int y)
00068     {
00069         if (msg==oglMouseDown)
00070         {
00071             Hide();
00072             // Pass on to allow immediate action if mouse clicked on some item
00073             oglSys.MouseEvent(mOglTopWnd,msg,btn,state,x,y);
00074         }
00075     }
00076 
00077 private:
00078     MenuListener*       mMenuListener;
00079     OGLWND*             mOglTopWnd;
00080 
00081     void Init()
00082     {
00083         mOglTopWnd = oglSys.GetTopOGLWND(mOglWnd);
00084         mMenuListener = 0;
00085         SetVisible(false);
00086     }
00087 };
00088 
00089 } // Namespace OglGui
00090 #endif
00091 

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