]>
git.saurik.com Git - wxWidgets.git/blob - samples/widgets/widgets.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWidgets 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
,
43 wxWindowID id
= wxID_ANY
,
44 wxTextCtrl
**ppText
= NULL
);
46 // create a sizer containing a label and a text ctrl
47 wxSizer
*CreateSizerWithTextAndLabel(const wxString
& label
,
48 wxWindowID id
= wxID_ANY
,
49 wxTextCtrl
**ppText
= NULL
);
51 // create a sizer containing a button and a text ctrl
52 wxSizer
*CreateSizerWithTextAndButton(wxWindowID idBtn
,
53 const wxString
& labelBtn
,
54 wxWindowID id
= wxID_ANY
,
55 wxTextCtrl
**ppText
= NULL
);
57 // create a checkbox and add it to the sizer
58 wxCheckBox
*CreateCheckBoxAndAddToSizer(wxSizer
*sizer
,
59 const wxString
& label
,
60 wxWindowID id
= wxID_ANY
);
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
; }
85 void SetNext(WidgetsPageInfo
*next
) { m_next
= next
; }
88 // the label of the page
91 // the function to create this page
94 // next node in the linked list or NULL
95 WidgetsPageInfo
*m_next
;
98 // to declare a page, this macro must be used in the class declaration
99 #define DECLARE_WIDGETS_PAGE(classname) \
101 static WidgetsPageInfo ms_info##classname; \
103 const WidgetsPageInfo *GetPageInfo() const \
104 { return &ms_info##classname; }
106 // and this one must be inserted somewhere in the source file
107 #define IMPLEMENT_WIDGETS_PAGE(classname, label) \
108 WidgetsPage *wxCtorFor##classname(wxNotebook *notebook, \
109 wxImageList *imaglist) \
110 { return new classname(notebook, imaglist); } \
111 WidgetsPageInfo classname:: \
112 ms_info##classname(wxCtorFor##classname, label)
114 #endif // _WX_SAMPLE_WIDGETS_H_