]>
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 | ||
19 | class wxImageList; | |
20 | ||
21 | /* | |
22 | * Flags returned by HitTest | |
23 | */ | |
24 | ||
25 | #define wxTAB_HITTEST_NOWHERE 1 | |
26 | #define wxTAB_HITTEST_ONICON 2 | |
27 | #define wxTAB_HITTEST_ONLABEL 4 | |
28 | #define wxTAB_HITTEST_ONITEM 6 | |
29 | ||
30 | class WXDLLEXPORT wxTabCtrl: public wxControl | |
31 | { | |
32 | DECLARE_DYNAMIC_CLASS(wxTabCtrl) | |
33 | public: | |
34 | /* | |
35 | * Public interface | |
36 | */ | |
37 | ||
38 | wxTabCtrl(); | |
39 | ||
40 | inline wxTabCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
41 | long style = 0, const wxString& name = wxT("tabCtrl")) | |
42 | { | |
43 | Create(parent, id, pos, size, style, name); | |
44 | } | |
45 | ~wxTabCtrl(); | |
46 | ||
47 | // Accessors | |
48 | ||
49 | // Get the selection | |
50 | int GetSelection() const; | |
51 | ||
52 | // Get the tab with the current keyboard focus | |
53 | int GetCurFocus() const; | |
54 | ||
55 | // Get the associated image list | |
56 | wxImageList* GetImageList() const; | |
57 | ||
58 | // Get the number of items | |
59 | int GetItemCount() const; | |
60 | ||
61 | // Get the rect corresponding to the tab | |
62 | bool GetItemRect(int item, wxRect& rect) const; | |
63 | ||
64 | // Get the number of rows | |
65 | int GetRowCount() const; | |
66 | ||
67 | // Get the item text | |
68 | wxString GetItemText(int item) const ; | |
69 | ||
70 | // Get the item image | |
71 | int GetItemImage(int item) const; | |
72 | ||
73 | // Get the item data | |
74 | void* GetItemData(int item) const; | |
75 | ||
76 | // Set the selection | |
77 | int SetSelection(int item); | |
78 | ||
79 | // Set the image list | |
80 | void SetImageList(wxImageList* imageList); | |
81 | ||
82 | // Set the text for an item | |
83 | bool SetItemText(int item, const wxString& text); | |
84 | ||
85 | // Set the image for an item | |
86 | bool SetItemImage(int item, int image); | |
87 | ||
88 | // Set the data for an item | |
89 | bool SetItemData(int item, void* data); | |
90 | ||
91 | // Set the size for a fixed-width tab control | |
92 | void SetItemSize(const wxSize& size); | |
93 | ||
94 | // Set the padding between tabs | |
95 | void SetPadding(const wxSize& padding); | |
96 | ||
97 | // Operations | |
98 | ||
99 | bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
100 | long style = 0, const wxString& name = wxT("tabCtrl")); | |
101 | ||
102 | // Delete all items | |
103 | bool DeleteAllItems(); | |
104 | ||
105 | // Delete an item | |
106 | bool DeleteItem(int item); | |
107 | ||
108 | // Hit test | |
109 | int HitTest(const wxPoint& pt, long& flags); | |
110 | ||
111 | // Insert an item | |
112 | bool InsertItem(int item, const wxString& text, int imageId = -1, void* data = NULL); | |
113 | ||
114 | void Command(wxCommandEvent& event); | |
115 | ||
116 | protected: | |
117 | wxImageList* m_imageList; | |
118 | ||
119 | DECLARE_EVENT_TABLE() | |
120 | }; | |
121 | ||
5eee8dcf | 122 | class WXDLLEXPORT wxTabEvent : public wxNotifyEvent |
8cf73271 | 123 | { |
5eee8dcf SC |
124 | public: |
125 | wxTabEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
126 | int nSel = -1, int nOldSel = -1) | |
127 | : wxNotifyEvent(commandType, id) | |
128 | { | |
129 | m_nSel = nSel; | |
130 | m_nOldSel = nOldSel; | |
131 | } | |
132 | ||
133 | // accessors | |
134 | // the currently selected page (-1 if none) | |
135 | int GetSelection() const { return m_nSel; } | |
136 | void SetSelection(int nSel) { m_nSel = nSel; } | |
137 | // the page that was selected before the change (-1 if none) | |
138 | int GetOldSelection() const { return m_nOldSel; } | |
139 | void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; } | |
140 | ||
141 | private: | |
142 | int m_nSel, // currently selected page | |
143 | m_nOldSel; // previously selected page | |
144 | ||
145 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxTabEvent) | |
8cf73271 SC |
146 | }; |
147 | ||
148 | typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&); | |
149 | ||
5eee8dcf SC |
150 | #define EVT_TAB_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGED, \ |
151 | id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL), | |
152 | #define EVT_TAB_SEL_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGING, \ | |
153 | id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL), | |
8cf73271 SC |
154 | |
155 | #endif | |
156 | // _WX_TABCTRL_H_ |