00001 #ifndef CHECKLISTBOX_H
00002 #define CHECKLISTBOX_H
00003
00004 #include <abuse/abuse.h>
00005 #include <string>
00006 #include <list>
00007 #include <map>
00008 #include <abuse/CriticalSection.h>
00009
00010 class CheckListbox
00011 {
00012 public:
00013 CheckListbox(const RECT& r,HWND hFather);
00014 ~CheckListbox();
00015 void addItem(const std::string& label,bool bSelected=false);
00016 void addItems(const std::list<std::pair<std::string,bool> >& items);
00017 void removeItem(const std::string& label);
00018 void removeItems();
00019 std::list<std::string> getSelected()const;
00020 std::list<std::string> getUnselected()const;
00021 void setSelected(const std::string& nm,bool bSelected);
00022 std::string getFocused()const;
00023 int getId()const;
00024 void selectAll();
00025 void deselectAll();
00026 private:
00027 HWND m_hWnd;
00028 HWND m_hFather;
00029 int m_id;
00030 std::list<std::string> m_selected;
00031 LRESULT fatherProc(UINT uMsg,WPARAM wP,LPARAM lP);
00032 LRESULT listProc(UINT uMsg,WPARAM wP,LPARAM lP);
00033 std::string getItem(int i)const;
00034 void alternateSelection(int i);
00035 static WNDPROC m_origListProc;
00036 class Boxes
00037 {
00038 public:
00039 Boxes();
00040 ~Boxes();
00041 void paintBox(HDC hDC,int x,int y,bool bSelected)const;
00042 SIZE size;
00043 private:
00044 HDC hInMem;
00045 HBITMAP hBitmap;
00046
00047 };
00048 static Boxes m_boxes;
00049 static LRESULT CALLBACK dispatchFatherProc(HWND hWnd,UINT uMsg,WPARAM wP,LPARAM lP);
00050 static LRESULT CALLBACK dispatchListProc(HWND hWnd,UINT uMsg,WPARAM wP,LPARAM lP);
00051 static int createId();
00052 static CriticalSection m_lock;
00053 static std::map<HWND,WNDPROC> m_origProcs;
00054 static std::map<HWND,std::list<CheckListbox*> > m_subclassing;
00055
00056 };
00057 #endif