]>
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 #if wxUSE_LOG && !defined(__SMARTPHONE__)
33 // ----------------------------------------------------------------------------
34 // WidgetsPage: a book page demonstrating some widget
35 // ----------------------------------------------------------------------------
37 class WidgetsPage
: public wxPanel
40 WidgetsPage(wxBookCtrl
*book
);
42 // return the control shown by this page
43 virtual wxControl
*GetWidget() const = 0;
46 // several helper functions for page creation
48 // create a horz sizer containing the given control and the text ctrl
49 // (pointer to which will be saved in the provided variable if not NULL)
50 // with the specified id
51 wxSizer
*CreateSizerWithText(wxControl
*control
,
52 wxWindowID id
= wxID_ANY
,
53 wxTextCtrl
**ppText
= NULL
);
55 // create a sizer containing a label and a text ctrl
56 wxSizer
*CreateSizerWithTextAndLabel(const wxString
& label
,
57 wxWindowID id
= wxID_ANY
,
58 wxTextCtrl
**ppText
= NULL
);
60 // create a sizer containing a button and a text ctrl
61 wxSizer
*CreateSizerWithTextAndButton(wxWindowID idBtn
,
62 const wxString
& labelBtn
,
63 wxWindowID id
= wxID_ANY
,
64 wxTextCtrl
**ppText
= NULL
);
66 // create a checkbox and add it to the sizer
67 wxCheckBox
*CreateCheckBoxAndAddToSizer(wxSizer
*sizer
,
68 const wxString
& label
,
69 wxWindowID id
= wxID_ANY
);
72 // the head of the linked list containinginfo about all pages
73 static WidgetsPageInfo
*ms_widgetPages
;
76 // ----------------------------------------------------------------------------
77 // dynamic WidgetsPage creation helpers
78 // ----------------------------------------------------------------------------
83 typedef WidgetsPage
*(*Constructor
)(wxBookCtrl
*book
,
84 wxImageList
*imaglist
);
87 WidgetsPageInfo(Constructor ctor
, const wxChar
*label
);
90 const wxString
& GetLabel() const { return m_label
; }
91 Constructor
GetCtor() const { return m_ctor
; }
92 WidgetsPageInfo
*GetNext() const { return m_next
; }
94 void SetNext(WidgetsPageInfo
*next
) { m_next
= next
; }
97 // the label of the page
100 // the function to create this page
103 // next node in the linked list or NULL
104 WidgetsPageInfo
*m_next
;
107 // to declare a page, this macro must be used in the class declaration
108 #define DECLARE_WIDGETS_PAGE(classname) \
110 static WidgetsPageInfo ms_info##classname; \
112 const WidgetsPageInfo *GetPageInfo() const \
113 { return &ms_info##classname; }
115 // and this one must be inserted somewhere in the source file
116 #define IMPLEMENT_WIDGETS_PAGE(classname, label) \
117 WidgetsPage *wxCtorFor##classname(wxBookCtrl *book, \
118 wxImageList *imaglist) \
119 { return new classname(book, imaglist); } \
120 WidgetsPageInfo classname:: \
121 ms_info##classname(wxCtorFor##classname, label)
123 #endif // _WX_SAMPLE_WIDGETS_H_