1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTabCtrl class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TABCTRL_H_
13 #define _WX_TABCTRL_H_
15 class WXDLLIMPEXP_CORE wxImageList
;
17 // extern WXDLLEXPORT_DATA(const wxChar*) wxToolBarNameStr;
20 * Flags returned by HitTest
23 #define wxTAB_HITTEST_NOWHERE 1
24 #define wxTAB_HITTEST_ONICON 2
25 #define wxTAB_HITTEST_ONLABEL 4
26 #define wxTAB_HITTEST_ONITEM 6
28 class WXDLLEXPORT wxTabCtrl
: public wxControl
30 DECLARE_DYNAMIC_CLASS(wxTabCtrl
)
38 inline wxTabCtrl(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
39 long style
= 0, const wxString
& name
= wxT("tabCtrl"))
41 Create(parent
, id
, pos
, size
, style
, name
);
48 int GetSelection() const;
50 // Get the tab with the current keyboard focus
51 int GetCurFocus() const;
53 // Get the associated image list
54 wxImageList
* GetImageList() const;
56 // Get the number of items
57 int GetItemCount() const;
59 // Get the rect corresponding to the tab
60 bool GetItemRect(int item
, wxRect
& rect
) const;
62 // Get the number of rows
63 int GetRowCount() const;
66 wxString
GetItemText(int item
) const ;
69 int GetItemImage(int item
) const;
72 void* GetItemData(int item
) const;
75 int SetSelection(int item
);
78 void SetImageList(wxImageList
* imageList
);
80 // Set the text for an item
81 bool SetItemText(int item
, const wxString
& text
);
83 // Set the image for an item
84 bool SetItemImage(int item
, int image
);
86 // Set the data for an item
87 bool SetItemData(int item
, void* data
);
89 // Set the size for a fixed-width tab control
90 void SetItemSize(const wxSize
& size
);
92 // Set the padding between tabs
93 void SetPadding(const wxSize
& padding
);
97 bool Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
98 long style
= 0, const wxString
& name
= wxT("tabCtrl"));
101 bool DeleteAllItems();
104 bool DeleteItem(int item
);
107 int HitTest(const wxPoint
& pt
, long& flags
);
110 bool InsertItem(int item
, const wxString
& text
, int imageId
= -1, void* data
= NULL
);
114 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
116 // Responds to colour changes
117 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
120 wxImageList
* m_imageList
;
122 DECLARE_EVENT_TABLE()
123 DECLARE_NO_COPY_CLASS(wxTabCtrl
)
126 class WXDLLEXPORT wxTabEvent
: public wxNotifyEvent
129 wxTabEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
130 int nSel
= -1, int nOldSel
= -1)
131 : wxNotifyEvent(commandType
, id
)
138 // the currently selected page (-1 if none)
139 int GetSelection() const { return m_nSel
; }
140 void SetSelection(int nSel
) { m_nSel
= nSel
; }
141 // the page that was selected before the change (-1 if none)
142 int GetOldSelection() const { return m_nOldSel
; }
143 void SetOldSelection(int nOldSel
) { m_nOldSel
= nOldSel
; }
146 int m_nSel
, // currently selected page
147 m_nOldSel
; // previously selected page
149 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTabEvent
)
152 typedef void (wxEvtHandler::*wxTabEventFunction
)(wxTabEvent
&);
154 #define EVT_TAB_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGED, \
155 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),
156 #define EVT_TAB_SEL_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGING, \
157 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),