]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/checklst.h
added assert to check that notebook page does have notebook as parent; removed duplic...
[wxWidgets.git] / include / wx / msw / checklst.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: checklst.h
3 // Purpose: wxCheckListBox class - a listbox with checkable items
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 16.11.97
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __CHECKLST__H_
13 #define __CHECKLST__H_
14
15 #ifdef __GNUG__
16 #pragma interface "checklst.h"
17 #endif
18
19 #if !wxUSE_OWNER_DRAWN
20 #error "wxCheckListBox class requires owner-drawn functionality."
21 #endif
22
23 class WXDLLEXPORT wxOwnerDrawn;
24 class WXDLLEXPORT wxCheckListBoxItem; // fwd decl, defined in checklst.cpp
25
26 class WXDLLEXPORT wxCheckListBox : public wxCheckListBoxBase
27 {
28 public:
29 // ctors
30 wxCheckListBox();
31 wxCheckListBox(wxWindow *parent, wxWindowID id,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 int nStrings = 0,
35 const wxString choices[] = NULL,
36 long style = 0,
37 const wxValidator& validator = wxDefaultValidator,
38 const wxString& name = wxListBoxNameStr);
39
40 bool Create(wxWindow *parent, wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 int n = 0, const wxString choices[] = NULL,
44 long style = 0,
45 const wxValidator& validator = wxDefaultValidator,
46 const wxString& name = wxListBoxNameStr);
47
48 // override base class virtuals
49 virtual void Delete(int n);
50
51 virtual bool SetFont( const wxFont &font );
52
53 // items may be checked
54 virtual bool IsChecked(size_t uiIndex) const;
55 virtual void Check(size_t uiIndex, bool bCheck = TRUE);
56
57 // return the index of the item at this position or wxNOT_FOUND
58 int HitTest(const wxPoint& pt) const { return DoHitTestItem(pt.x, pt.y); }
59 int HitTest(wxCoord x, wxCoord y) const { return DoHitTestItem(x, y); }
60
61 // accessors
62 size_t GetItemHeight() const { return m_nItemHeight; }
63
64 protected:
65 // we create our items ourselves and they have non-standard size,
66 // so we need to override these functions
67 virtual wxOwnerDrawn *CreateLboxItem(size_t n);
68 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
69
70 // this can't be called DoHitTest() because wxWindow already has this method
71 int DoHitTestItem(wxCoord x, wxCoord y) const;
72
73 // pressing space or clicking the check box toggles the item
74 void OnKeyDown(wxKeyEvent& event);
75 void OnLeftClick(wxMouseEvent& event);
76
77 private:
78 size_t m_nItemHeight; // height of checklistbox items (the same for all)
79
80 DECLARE_EVENT_TABLE()
81 DECLARE_DYNAMIC_CLASS(wxCheckListBox)
82 };
83
84 #endif //_CHECKLST_H