]>
git.saurik.com Git - wxWidgets.git/blob - samples/widgets/widgets.h
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 WidgetsPageInfo
;
24 // all source files use wxImageList
25 #include "wx/imaglist.h"
27 // ----------------------------------------------------------------------------
28 // WidgetsPage: a notebook page demonstrating some widget
29 // ----------------------------------------------------------------------------
31 class WidgetsPage
: public wxPanel
34 WidgetsPage(wxNotebook
*notebook
);
37 // several helper functions for page creation
39 // create a horz sizer containing the given control and the text ctrl
40 // (pointer to which will be saved in the provided variable if not NULL)
41 // with the specified id
42 wxSizer
*CreateSizerWithText(wxControl
*control
,
44 wxTextCtrl
**ppText
= NULL
);
46 // create a sizer containing a label and a text ctrl
47 wxSizer
*CreateSizerWithTextAndLabel(const wxString
& label
,
49 wxTextCtrl
**ppText
= NULL
);
51 // create a sizer containing a button and a text ctrl
52 wxSizer
*CreateSizerWithTextAndButton(wxWindowID idBtn
,
53 const wxString
& labelBtn
,
55 wxTextCtrl
**ppText
= NULL
);
57 // create a checkbox and add it to the sizer
58 wxCheckBox
*CreateCheckBoxAndAddToSizer(wxSizer
*sizer
,
59 const wxString
& label
,
63 // the head of the linked list containinginfo about all pages
64 static WidgetsPageInfo
*ms_widgetPages
;
67 // ----------------------------------------------------------------------------
68 // dynamic WidgetsPage creation helpers
69 // ----------------------------------------------------------------------------
74 typedef WidgetsPage
*(*Constructor
)(wxNotebook
*notebook
,
75 wxImageList
*imaglist
);
78 WidgetsPageInfo(Constructor ctor
, const wxChar
*label
);
81 const wxString
& GetLabel() const { return m_label
; }
82 Constructor
GetCtor() const { return m_ctor
; }
83 WidgetsPageInfo
*GetNext() const { return m_next
; }
86 // the label of the page
89 // the function to create this page
92 // next node in the linked list or NULL
93 WidgetsPageInfo
*m_next
;
96 // to declare a page, this macro must be used in the class declaration
97 #define DECLARE_WIDGETS_PAGE(classname) \
99 static WidgetsPageInfo ms_info##classname; \
101 const WidgetsPageInfo *GetPageInfo() const \
102 { return &ms_info##classname; }
104 // and this one must be inserted somewhere in the source file
105 #define IMPLEMENT_WIDGETS_PAGE(classname, label) \
106 WidgetsPage *wxCtorFor##classname(wxNotebook *notebook, \
107 wxImageList *imaglist) \
108 { return new classname(notebook, imaglist); } \
109 WidgetsPageInfo classname:: \
110 ms_info##classname(wxCtorFor##classname, label)
112 #endif // _WX_SAMPLE_WIDGETS_H_