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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "tabctrl.h"
19 class WXDLLIMPEXP_CORE wxImageList
;
21 // WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
24 * Flags returned by HitTest
27 #define wxTAB_HITTEST_NOWHERE 1
28 #define wxTAB_HITTEST_ONICON 2
29 #define wxTAB_HITTEST_ONLABEL 4
30 #define wxTAB_HITTEST_ONITEM 6
32 class WXDLLEXPORT wxTabCtrl
: public wxControl
34 DECLARE_DYNAMIC_CLASS(wxTabCtrl
)
42 inline wxTabCtrl(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
43 long style
= 0, const wxString
& name
= wxT("tabCtrl"))
45 Create(parent
, id
, pos
, size
, style
, name
);
52 int GetSelection() const;
54 // Get the tab with the current keyboard focus
55 int GetCurFocus() const;
57 // Get the associated image list
58 wxImageList
* GetImageList() const;
60 // Get the number of items
61 int GetItemCount() const;
63 // Get the rect corresponding to the tab
64 bool GetItemRect(int item
, wxRect
& rect
) const;
66 // Get the number of rows
67 int GetRowCount() const;
70 wxString
GetItemText(int item
) const ;
73 int GetItemImage(int item
) const;
76 void* GetItemData(int item
) const;
79 int SetSelection(int item
);
82 void SetImageList(wxImageList
* imageList
);
84 // Set the text for an item
85 bool SetItemText(int item
, const wxString
& text
);
87 // Set the image for an item
88 bool SetItemImage(int item
, int image
);
90 // Set the data for an item
91 bool SetItemData(int item
, void* data
);
93 // Set the size for a fixed-width tab control
94 void SetItemSize(const wxSize
& size
);
96 // Set the padding between tabs
97 void SetPadding(const wxSize
& padding
);
101 bool Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
102 long style
= 0, const wxString
& name
= wxT("tabCtrl"));
105 bool DeleteAllItems();
108 bool DeleteItem(int item
);
111 int HitTest(const wxPoint
& pt
, long& flags
);
114 bool InsertItem(int item
, const wxString
& text
, int imageId
= -1, void* data
= NULL
);
118 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
120 // Responds to colour changes
121 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
124 wxImageList
* m_imageList
;
126 DECLARE_EVENT_TABLE()
127 DECLARE_NO_COPY_CLASS(wxTabCtrl
)
130 class WXDLLEXPORT wxTabEvent
: public wxNotifyEvent
133 wxTabEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
134 int nSel
= -1, int nOldSel
= -1)
135 : wxNotifyEvent(commandType
, id
)
142 // the currently selected page (-1 if none)
143 int GetSelection() const { return m_nSel
; }
144 void SetSelection(int nSel
) { m_nSel
= nSel
; }
145 // the page that was selected before the change (-1 if none)
146 int GetOldSelection() const { return m_nOldSel
; }
147 void SetOldSelection(int nOldSel
) { m_nOldSel
= nOldSel
; }
150 int m_nSel
, // currently selected page
151 m_nOldSel
; // previously selected page
153 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTabEvent
)
156 typedef void (wxEvtHandler::*wxTabEventFunction
)(wxTabEvent
&);
158 #define EVT_TAB_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGED, \
159 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),
160 #define EVT_TAB_SEL_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGING, \
161 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),