]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/tabctrl.h
use memcpy() instead of wxTmemcpy() as the latter is defined in wx/wxcrt.h which...
[wxWidgets.git] / include / wx / msw / tabctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tabctrl.h
3 // Purpose: wxTabCtrl class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TABCTRL_H_
13 #define _WX_TABCTRL_H_
14
15 class WXDLLIMPEXP_FWD_CORE wxImageList;
16
17 /*
18 * Flags returned by HitTest
19 */
20
21 #define wxTAB_HITTEST_NOWHERE 1
22 #define wxTAB_HITTEST_ONICON 2
23 #define wxTAB_HITTEST_ONLABEL 4
24 #define wxTAB_HITTEST_ONITEM 6
25
26 class WXDLLIMPEXP_CORE wxTabCtrl: public wxControl
27 {
28 DECLARE_DYNAMIC_CLASS(wxTabCtrl)
29 public:
30 /*
31 * Public interface
32 */
33
34 wxTabCtrl();
35
36 inline wxTabCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
37 long style = 0, const wxString& name = wxT("tabCtrl"))
38 {
39 Create(parent, id, pos, size, style, name);
40 }
41 virtual ~wxTabCtrl();
42
43 // Accessors
44
45 // Get the selection
46 int GetSelection() const;
47
48 // Get the tab with the current keyboard focus
49 int GetCurFocus() const;
50
51 // Get the associated image list
52 wxImageList* GetImageList() const;
53
54 // Get the number of items
55 int GetItemCount() const;
56
57 // Get the rect corresponding to the tab
58 bool GetItemRect(int item, wxRect& rect) const;
59
60 // Get the number of rows
61 int GetRowCount() const;
62
63 // Get the item text
64 wxString GetItemText(int item) const ;
65
66 // Get the item image
67 int GetItemImage(int item) const;
68
69 // Get the item data
70 void* GetItemData(int item) const;
71
72 // Set the selection
73 int SetSelection(int item);
74
75 // Set the image list
76 void SetImageList(wxImageList* imageList);
77
78 // Set the text for an item
79 bool SetItemText(int item, const wxString& text);
80
81 // Set the image for an item
82 bool SetItemImage(int item, int image);
83
84 // Set the data for an item
85 bool SetItemData(int item, void* data);
86
87 // Set the size for a fixed-width tab control
88 void SetItemSize(const wxSize& size);
89
90 // Set the padding between tabs
91 void SetPadding(const wxSize& padding);
92
93 // Operations
94
95 bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
96 long style = 0, const wxString& name = wxT("tabCtrl"));
97
98 // Delete all items
99 bool DeleteAllItems();
100
101 // Delete an item
102 bool DeleteItem(int item);
103
104 // Hit test
105 int HitTest(const wxPoint& pt, long& flags);
106
107 // Insert an item
108 bool InsertItem(int item, const wxString& text, int imageId = -1, void* data = NULL);
109
110 // Implementation
111
112 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
113
114 // Responds to colour changes
115 void OnSysColourChanged(wxSysColourChangedEvent& event);
116
117 protected:
118 wxImageList* m_imageList;
119
120 DECLARE_EVENT_TABLE()
121 DECLARE_NO_COPY_CLASS(wxTabCtrl)
122 };
123
124 class WXDLLIMPEXP_CORE wxTabEvent : public wxNotifyEvent
125 {
126 public:
127 wxTabEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
128 int nSel = -1, int nOldSel = -1)
129 : wxNotifyEvent(commandType, id)
130 {
131 m_nSel = nSel;
132 m_nOldSel = nOldSel;
133 }
134
135 // accessors
136 // the currently selected page (-1 if none)
137 int GetSelection() const { return m_nSel; }
138 void SetSelection(int nSel) { m_nSel = nSel; }
139 // the page that was selected before the change (-1 if none)
140 int GetOldSelection() const { return m_nOldSel; }
141 void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
142
143 private:
144 int m_nSel, // currently selected page
145 m_nOldSel; // previously selected page
146
147 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTabEvent)
148 };
149
150 typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&);
151
152 #define EVT_TAB_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGED, \
153 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),
154 #define EVT_TAB_SEL_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGING, \
155 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),
156
157 #endif
158 // _WX_TABCTRL_H_