Back to index

nux  3.0.0
MenuBar.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef MENUBAR_H
00024 #define MENUBAR_H
00025 
00026 #include "ScrollView.h"
00027 #include "ToolButton.h"
00028 #include "MenuPage.h"
00029 #include "Painter.h"
00030 
00031 namespace nux
00032 {
00033 
00034   class PopupBox;
00035   class BaseWindow;
00036   class MenuBar;
00037   class HLayout;
00038 
00039 
00040   class MenuBarItem: public Object
00041   {
00042   public:
00043     NUX_DECLARE_OBJECT_TYPE(MenuBarItem, Object);
00044 
00045     MenuBarItem(NUX_FILE_LINE_PROTO);
00046     ~MenuBarItem();
00047   private:
00048     InputArea   *area;
00049     MenuPage   *menu;
00050     BaseTexture   *icon; // should be 24x24
00051 
00052     friend class MenuBar;
00053   };
00054 
00055   class MenuBar: public View
00056   {
00057     NUX_DECLARE_OBJECT_TYPE(MenuBar, View);
00058 
00059   public:
00060     MenuBar(NUX_FILE_LINE_PROTO);
00061     ~MenuBar();
00062 
00063     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00064     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00065     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00066 
00067     //void AddActionItem(ActionItem* actionItem);
00068 
00069     void AddMenu(const char *MenuLabel, MenuPage *popup);
00070     void AddMenu(const char *MenuLabel, MenuPage *menu, BaseTexture *icon);
00071 
00072 
00074     //  EMITERS    //
00076 
00077   private:
00078     void EmitItemMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags, MenuBarItem *menubar_item);
00079     void EmitItemMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags, MenuBarItem *menubar_item);
00080     void EmitItemMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags, MenuBarItem *menubar_item);
00081     void EmitItemMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags, MenuBarItem *menubar_item);
00082     void RecvItemMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags, MenuBarItem *menubar_item);
00083     void RecvSigActionTriggered(MenuPage *, ActionItem *);
00084     void RecvSigTerminateMenuCascade();
00085 
00087     /*
00088         Process a mouse down event outside of the menu cascade. The menu bar checks if the mouse down happened on one of its menu bar item.
00089         If yes, it let the menu bar item process the event. if no, it will initiate the closure of the menu cascade.
00090 
00091         \param menu menu item
00092         \param x    coordinate of the mouse down event
00093         \param y    coordinate of the mouse down event
00094     */
00095     void RecvSigMouseDownOutsideMenuCascade(MenuPage *menu, int x, int y);
00096 
00097   protected:
00098 
00099 
00100   private:
00101     std::list< MenuBarItem * > m_MenuBarItemList;
00102 
00103     HLayout *m_hlayout;
00104     bool m_MenuIsActive;
00105     MenuBarItem *m_CurrentMenu;
00106     bool m_IsOpeningMenu;
00107     BaseWindow *m_MenuBarWindow;
00108   };
00109 
00110 }
00111 
00112 #endif // MENUBAR_H