00001 #ifndef __CComboBox__ 00002 #define __CComboBox__ 00003 00004 #include "CTextLabel.hpp" 00005 #include "CMenu.hpp" 00006 #include "../Windowing/CMenuWindow.hpp" 00007 #include "../Listeners/IMenuListener.hpp" 00008 00009 // =========================================================================== 00010 00011 using Exponent::GUI::Windowing::CMenuWindow; 00012 using Exponent::GUI::Controls::CTextLabel; 00013 using Exponent::GUI::Controls::CMenu; 00014 using Exponent::GUI::Listeners::IMenuListener; 00015 00016 // =========================================================================== 00017 00018 namespace Exponent 00019 { 00020 namespace GUI 00021 { 00022 namespace Controls 00023 { 00041 class CComboBox : public CTextLabel, public IMenuListener 00042 { 00044 EXPONENT_CLASS_DECLARATION; 00047 // =========================================================================== 00048 00049 public: 00050 00051 // =========================================================================== 00052 00062 CComboBox(IControlRoot *root, const long uniqueId, const CRect &area, const CString &text, CMenu *menu, IActionListener *listener); 00063 00067 virtual ~CComboBox(); 00068 00069 // =========================================================================== 00070 00075 virtual void handleLeftButtonDown(CMouseEvent &event); 00076 00081 virtual void handleMenuSelection(const CMenuEvent &event); 00082 00087 virtual void handleMenuOpening(const CMenuEvent &event) {} 00088 00093 virtual void handleMenuClosing(const CMenuEvent &event); 00094 00095 // =========================================================================== 00096 00101 virtual void drawControl(CGraphics &graphics); 00102 00107 virtual void setMenu(CMenu *menu); 00108 00113 CMenu *getMenu() { return m_menu; } 00114 00119 virtual void setSelectedIndex(const long index); 00120 00126 virtual CMenuItem *getMenuItem(const long index); 00127 00132 virtual CMenuWindow *getMenuWindow() { return m_menuWindow; } 00133 00138 virtual long getSelectedIndex() const { return m_selectedIndex; } 00139 00144 const CMenuItem *getLastMenuItem() const { return m_selectedItem; } 00145 00146 // =========================================================================== 00147 00152 virtual void setFont(CFont *font); 00153 00158 virtual void setMenuColours(const SMenuColours &colours); 00159 00164 virtual void setDownImage(IImage *downImage); 00165 00166 // =========================================================================== 00167 00173 virtual void setMenuWindowAttributes(CWindowAttributes *windowAttributes, const bool useIcons = true); 00174 00175 // =========================================================================== 00176 00177 protected: 00178 00179 // =========================================================================== 00180 00181 CMenu *m_menu; 00182 CMenuWindow *m_menuWindow; 00183 CWindowAttributes *m_windowAttributes; 00184 bool m_useIcons; 00185 long m_selectedIndex; 00186 bool m_state; 00187 IImage *m_downImage; 00188 CMenuItem *m_selectedItem; 00189 }; 00190 } 00191 } 00192 } 00193 #endif // End of CComboBox.hpp