nux-1.16.0
ComboBoxSimple.h
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 COMBOBOX_LOGIC_H
00024 #define COMBOBOX_LOGIC_H
00025 
00026 #include "AbstractComboBox.h"
00027 #include "ActionItem.h"
00028 
00029 namespace nux
00030 {
00031 
00032   class MenuPage;
00033   class ActionItem;
00034   class TableItem;
00035   class TableCtrl;
00036 
00037   class ComboBoxSimple : public AbstractComboBox
00038   {
00039   public:
00040     ComboBoxSimple (NUX_FILE_LINE_PROTO);
00041     ~ComboBoxSimple();
00042 
00043     // make the class abstract
00044 //    virtual void Draw(GraphicsEngine& GfxContext, bool force_draw);
00045 //    virtual void DrawContent(GraphicsEngine& GfxContext, bool force_draw);
00046 //    virtual void PostDraw(GraphicsEngine& GfxContext, bool force_draw);
00047 
00048   public:
00049     ActionItem *AddItem (const TCHAR *label, int Uservalue = 0);
00050     void RemoveItem (ActionItem *item);
00051     void RemoveAllItem();
00052     
00053     // emitters
00054     void OnMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00055     void OnMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00056     void OnPopupStop();
00057 
00058     // signals
00059     void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00060     void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00061     void RecvSigActionTriggered (MenuPage *, ActionItem *);
00062     void RecvSigActionTriggered2 (TableCtrl *table, TableItem *item, unsigned int row, unsigned int column);
00063     void RecvSigTerminateMenuCascade();
00064     void RecvGeometryChanged(Area *area, Geometry &geo);
00065 
00066     const TCHAR *GetSelectionLabel() const;
00067     int GetSelectionUserValue() const;
00068     int GetNumItem() const;
00069     ActionItem *GetItem (int index) const;
00070     int GetSelectionIndex() const;
00071     void SetSelectionIndex (int index);
00072 
00073     // moves the currently selected item up/down - just shorthand for SetSelectionIndex
00074     void MoveSelectionUp ();
00075     void MoveSelectionDown ();
00076 
00077     MenuPage * GetMenuPage ()
00078     {
00079       return m_CurrentMenu;
00080     }
00081 
00082     sigc::signal<void, ComboBoxSimple *> sigTriggered;
00083     sigc::signal<void, ActionItem *> sigActionTriggered;
00084 
00085   protected:
00086     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00087     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00088 
00089     void RecvClosingMenuSignal(MenuPage* menu_page);
00090 
00091     MenuPage   *m_CurrentMenu;
00092     ActionItem *m_SelectedAction;
00093 
00094     virtual void DoSetFocused (bool focused);
00095     bool        m_block_focus; // used to selectively ignore focus keyevents
00096 
00097   };
00098 
00099 }
00100 
00101 #endif // COMBOBOX_LOGIC_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends