1 /*************************************************************************** 2 listbox.h - A List Box 3 ------------------- 4 begin : za mrt 8 2008 5 copyright : (C) 2008 by CJP 6 email : cornware-cjp@users.sourceforge.net 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 #ifndef LISTBOX_H 18 #define LISTBOX_H 19 20 #include <vector> 21 namespace std {} 22 using namespace std; 23 24 #include "widget.h" 25 #include "longmenu.h" 26 27 /** 28 @author CJP <cornware-cjp@users.sourceforge.net> 29 */ 30 class CListBox : public CWidget 31 { 32 public: 33 CListBox(); 34 ~CListBox(); 35 36 void setTitle(const CString &title); 37 38 virtual int onKeyPress(int key); 39 virtual int onMouseClick(int x, int y, unsigned int buttons); 40 virtual int onMouseMove(int x, int y, unsigned int buttons); 41 virtual int onRedraw(); 42 virtual int onResize(int x, int y, int w, int h); 43 44 void setOptions(const vector<CString> &options); 45 46 void setSelected(unsigned int sel); 47 unsigned int getSelected() const; 48 49 bool m_Cancelled; 50 protected: 51 CString m_Title; //the total text 52 vector<CString> m_Lines; //the text divided into lines 53 54 CLongMenu m_Menu; 55 56 void updateLines(); 57 58 void drawTitle(); 59 }; 60 61 #endif 62