]>
Commit | Line | Data |
---|---|---|
8cf73271 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: tabctrl.h | |
3 | // Purpose: wxTabCtrl class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
65571936 | 9 | // Licence: wxWindows licence |
8cf73271 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_TABCTRL_H_ | |
13 | #define _WX_TABCTRL_H_ | |
14 | ||
15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
16 | #pragma interface "tabctrl.h" | |
17 | #endif | |
18 | ||
179e085f RN |
19 | #include "wx/control.h" |
20 | ||
8cf73271 SC |
21 | class wxImageList; |
22 | ||
23 | /* | |
24 | * Flags returned by HitTest | |
25 | */ | |
26 | ||
27 | #define wxTAB_HITTEST_NOWHERE 1 | |
28 | #define wxTAB_HITTEST_ONICON 2 | |
29 | #define wxTAB_HITTEST_ONLABEL 4 | |
30 | #define wxTAB_HITTEST_ONITEM 6 | |
31 | ||
32 | class WXDLLEXPORT wxTabCtrl: public wxControl | |
33 | { | |
34 | DECLARE_DYNAMIC_CLASS(wxTabCtrl) | |
35 | public: | |
36 | /* | |
37 | * Public interface | |
38 | */ | |
39 | ||
40 | wxTabCtrl(); | |
41 | ||
42 | inline wxTabCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
43 | long style = 0, const wxString& name = wxT("tabCtrl")) | |
44 | { | |
45 | Create(parent, id, pos, size, style, name); | |
46 | } | |
47 | ~wxTabCtrl(); | |
48 | ||
49 | // Accessors | |
50 | ||
51 | // Get the selection | |
52 | int GetSelection() const; | |
53 | ||
54 | // Get the tab with the current keyboard focus | |
55 | int GetCurFocus() const; | |
56 | ||
57 | // Get the associated image list | |
58 | wxImageList* GetImageList() const; | |
59 | ||
60 | // Get the number of items | |
61 | int GetItemCount() const; | |
62 | ||
63 | // Get the rect corresponding to the tab | |
64 | bool GetItemRect(int item, wxRect& rect) const; | |
65 | ||
66 | // Get the number of rows | |
67 | int GetRowCount() const; | |
68 | ||
69 | // Get the item text | |
70 | wxString GetItemText(int item) const ; | |
71 | ||
72 | // Get the item image | |
73 | int GetItemImage(int item) const; | |
74 | ||
75 | // Get the item data | |
76 | void* GetItemData(int item) const; | |
77 | ||
78 | // Set the selection | |
79 | int SetSelection(int item); | |
80 | ||
81 | // Set the image list | |
82 | void SetImageList(wxImageList* imageList); | |
83 | ||
84 | // Set the text for an item | |
85 | bool SetItemText(int item, const wxString& text); | |
86 | ||
87 | // Set the image for an item | |
88 | bool SetItemImage(int item, int image); | |
89 | ||
90 | // Set the data for an item | |
91 | bool SetItemData(int item, void* data); | |
92 | ||
93 | // Set the size for a fixed-width tab control | |
94 | void SetItemSize(const wxSize& size); | |
95 | ||
96 | // Set the padding between tabs | |
97 | void SetPadding(const wxSize& padding); | |
98 | ||
99 | // Operations | |
100 | ||
101 | bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
102 | long style = 0, const wxString& name = wxT("tabCtrl")); | |
103 | ||
104 | // Delete all items | |
105 | bool DeleteAllItems(); | |
106 | ||
107 | // Delete an item | |
108 | bool DeleteItem(int item); | |
109 | ||
110 | // Hit test | |
111 | int HitTest(const wxPoint& pt, long& flags); | |
112 | ||
113 | // Insert an item | |
114 | bool InsertItem(int item, const wxString& text, int imageId = -1, void* data = NULL); | |
115 | ||
116 | void Command(wxCommandEvent& event); | |
117 | ||
118 | protected: | |
119 | wxImageList* m_imageList; | |
120 | ||
121 | DECLARE_EVENT_TABLE() | |
122 | }; | |
123 | ||
5eee8dcf | 124 | class WXDLLEXPORT wxTabEvent : public wxNotifyEvent |
8cf73271 | 125 | { |
5eee8dcf SC |
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) | |
8cf73271 SC |
148 | }; |
149 | ||
150 | typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&); | |
151 | ||
5eee8dcf SC |
152 | #define EVT_TAB_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGED, \ |
153 | id, -1, (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, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL), | |
8cf73271 SC |
156 | |
157 | #endif | |
158 | // _WX_TABCTRL_H_ |