nux-0.9.46

Nux/ComboBoxSimple.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 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     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00043 
00044     // make the class abstract
00045 //    virtual void Draw(GraphicsEngine& GfxContext, bool force_draw);
00046 //    virtual void DrawContent(GraphicsEngine& GfxContext, bool force_draw);
00047 //    virtual void PostDraw(GraphicsEngine& GfxContext, bool force_draw);
00048 
00049   public:
00050     ActionItem *AddItem (const TCHAR *label, int Uservalue = 0);
00051     void RemoveItem (ActionItem *item);
00052     void RemoveAllItem();
00053     
00054     // emitters
00055     void OnMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00056     void OnMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00057     void OnPopupStop();
00058 
00059     // signals
00060     void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00061     void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00062     void RecvSigActionTriggered (MenuPage *, ActionItem *);
00063     void RecvSigActionTriggered2 (TableCtrl *table, TableItem *item, unsigned int row, unsigned int column);
00064     void RecvSigTerminateMenuCascade();
00065     void RecvGeometryChanged(Area *area, Geometry &geo);
00066 
00067     const TCHAR *GetSelectionLabel() const;
00068     int GetSelectionUserValue() const;
00069     int GetNumItem() const;
00070     ActionItem *GetItem (int index) const;
00071     int GetSelectionIndex() const;
00072     void SetSelectionIndex (int index);
00073 
00074     // moves the currently selected item up/down - just shorthand for SetSelectionIndex
00075     void MoveSelectionUp ();
00076     void MoveSelectionDown ();
00077 
00078     MenuPage * GetMenuPage ()
00079     {
00080       return m_CurrentMenu;
00081     }
00082 
00083     sigc::signal<void, ComboBoxSimple *> sigTriggered;
00084     sigc::signal<void, ActionItem *> sigActionTriggered;
00085 
00086   protected:
00087     MenuPage   *m_CurrentMenu;
00088     ActionItem *m_SelectedAction;
00089 
00090     virtual void DoSetFocused (bool focused);
00091     bool        m_block_focus; // used to selectively ignore focus keyevents
00092 
00093   };
00094 
00095 }
00096 
00097 #endif // COMBOBOX_LOGIC_H