1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWindows Widgets Sample
4 // Purpose: Common stuff for all widgets project files
5 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_SAMPLE_WIDGETS_H_
13 #define _WX_SAMPLE_WIDGETS_H_
15 class WXDLLEXPORT wxCheckBox
;
16 class WXDLLEXPORT wxNotebook
;
17 class WXDLLEXPORT wxSizer
;
18 class WXDLLEXPORT wxTextCtrl
;
20 class WXDLLEXPORT WidgetsPageInfo
;
22 // all source files use wxImageList
23 #include "wx/imaglist.h"
25 // ----------------------------------------------------------------------------
26 // WidgetsPage: a notebook page demonstrating some widget
27 // ----------------------------------------------------------------------------
29 class WidgetsPage
: public wxPanel
32 WidgetsPage(wxNotebook
*notebook
);
35 // several helper functions for page creation
37 // create a horz sizer containing the given control and the text ctrl
38 // (pointer to which will be saved in the provided variable if not NULL)
39 // with the specified id
40 wxSizer
*CreateSizerWithText(wxControl
*control
,
42 wxTextCtrl
**ppText
= NULL
);
44 // create a sizer containing a label and a text ctrl
45 wxSizer
*CreateSizerWithTextAndLabel(const wxString
& label
,
47 wxTextCtrl
**ppText
= NULL
);
49 // create a sizer containing a button and a text ctrl
50 wxSizer
*CreateSizerWithTextAndButton(wxWindowID idBtn
,
51 const wxString
& labelBtn
,
53 wxTextCtrl
**ppText
= NULL
);
55 // create a checkbox and add it to the sizer
56 wxCheckBox
*CreateCheckBoxAndAddToSizer(wxSizer
*sizer
,
57 const wxString
& label
,
61 // the head of the linked list containinginfo about all pages
62 static WidgetsPageInfo
*ms_widgetPages
;
65 // ----------------------------------------------------------------------------
66 // dynamic WidgetsPage creation helpers
67 // ----------------------------------------------------------------------------
69 class WXDLLEXPORT WidgetsPageInfo
72 typedef WidgetsPage
*(*Constructor
)(wxNotebook
*notebook
,
73 wxImageList
*imaglist
);
76 WidgetsPageInfo(Constructor ctor
, const wxChar
*label
);
79 const wxString
& GetLabel() const { return m_label
; }
80 Constructor
GetCtor() const { return m_ctor
; }
81 WidgetsPageInfo
*GetNext() const { return m_next
; }
84 // the label of the page
87 // the function to create this page
90 // next node in the linked list or NULL
91 WidgetsPageInfo
*m_next
;
94 // to declare a page, this macro must be used in the class declaration
95 #define DECLARE_WIDGETS_PAGE(classname) \
97 static WidgetsPageInfo ms_info##classname; \
99 const WidgetsPageInfo *GetPageInfo() const \
100 { return &ms_info##classname; }
102 // and this one must be inserted somewhere in the source file
103 #define IMPLEMENT_WIDGETS_PAGE(classname, label) \
104 WidgetsPage *wxCtorFor##classname(wxNotebook *notebook, \
105 wxImageList *imaglist) \
106 { return new classname(notebook, imaglist); } \
107 WidgetsPageInfo classname:: \
108 ms_info##classname(wxCtorFor##classname, label)
110 #endif // _WX_SAMPLE_WIDGETS_H_