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