]>
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 wxBookCtrl
;
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 book page demonstrating some widget
29 // ----------------------------------------------------------------------------
31 class WidgetsPage
: public wxPanel
34 WidgetsPage(wxBookCtrl
*book
);
36 // return the control shown by this page
37 virtual wxControl
*GetWidget() const = 0;
40 // several helper functions for page creation
42 // create a horz sizer containing the given control and the text ctrl
43 // (pointer to which will be saved in the provided variable if not NULL)
44 // with the specified id
45 wxSizer
*CreateSizerWithText(wxControl
*control
,
46 wxWindowID id
= wxID_ANY
,
47 wxTextCtrl
**ppText
= NULL
);
49 // create a sizer containing a label and a text ctrl
50 wxSizer
*CreateSizerWithTextAndLabel(const wxString
& label
,
51 wxWindowID id
= wxID_ANY
,
52 wxTextCtrl
**ppText
= NULL
);
54 // create a sizer containing a button and a text ctrl
55 wxSizer
*CreateSizerWithTextAndButton(wxWindowID idBtn
,
56 const wxString
& labelBtn
,
57 wxWindowID id
= wxID_ANY
,
58 wxTextCtrl
**ppText
= NULL
);
60 // create a checkbox and add it to the sizer
61 wxCheckBox
*CreateCheckBoxAndAddToSizer(wxSizer
*sizer
,
62 const wxString
& label
,
63 wxWindowID id
= wxID_ANY
);
66 // the head of the linked list containinginfo about all pages
67 static WidgetsPageInfo
*ms_widgetPages
;
70 // ----------------------------------------------------------------------------
71 // dynamic WidgetsPage creation helpers
72 // ----------------------------------------------------------------------------
77 typedef WidgetsPage
*(*Constructor
)(wxBookCtrl
*book
,
78 wxImageList
*imaglist
);
81 WidgetsPageInfo(Constructor ctor
, const wxChar
*label
);
84 const wxString
& GetLabel() const { return m_label
; }
85 Constructor
GetCtor() const { return m_ctor
; }
86 WidgetsPageInfo
*GetNext() const { return m_next
; }
88 void SetNext(WidgetsPageInfo
*next
) { m_next
= next
; }
91 // the label of the page
94 // the function to create this page
97 // next node in the linked list or NULL
98 WidgetsPageInfo
*m_next
;
101 // to declare a page, this macro must be used in the class declaration
102 #define DECLARE_WIDGETS_PAGE(classname) \
104 static WidgetsPageInfo ms_info##classname; \
106 const WidgetsPageInfo *GetPageInfo() const \
107 { return &ms_info##classname; }
109 // and this one must be inserted somewhere in the source file
110 #define IMPLEMENT_WIDGETS_PAGE(classname, label) \
111 WidgetsPage *wxCtorFor##classname(wxBookCtrl *book, \
112 wxImageList *imaglist) \
113 { return new classname(book, imaglist); } \
114 WidgetsPageInfo classname:: \
115 ms_info##classname(wxCtorFor##classname, label)
117 #endif // _WX_SAMPLE_WIDGETS_H_