]> git.saurik.com Git - wxWidgets.git/blame - samples/widgets/widgets.h
Make expat's configure detect if -ext o is needed (MW) so tests work correctly.
[wxWidgets.git] / samples / widgets / widgets.h
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
be5a51fb 2// Program: wxWidgets Widgets Sample
32b8ec41
VZ
3// Name: widgets.h
4// Purpose: Common stuff for all widgets project files
5// Author: Vadim Zeitlin
6// Created: 27.03.01
7// Id: $Id$
8// Copyright: (c) 2001 Vadim Zeitlin
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_SAMPLE_WIDGETS_H_
13#define _WX_SAMPLE_WIDGETS_H_
14
15class WXDLLEXPORT wxCheckBox;
61c083e7 16class WXDLLEXPORT wxBookCtrl;
32b8ec41
VZ
17class WXDLLEXPORT wxSizer;
18class WXDLLEXPORT wxTextCtrl;
19
2b5f62a0 20class WidgetsPageInfo;
32b8ec41 21
0b90b51c
GD
22#include "wx/panel.h"
23
32b8ec41
VZ
24// all source files use wxImageList
25#include "wx/imaglist.h"
26
49abcb2f
WS
27#if wxUSE_LOG && !defined(__SMARTPHONE__)
28 #define USE_LOG 1
29#else
30 #define USE_LOG 0
31#endif
32
32b8ec41 33// ----------------------------------------------------------------------------
61c083e7 34// WidgetsPage: a book page demonstrating some widget
32b8ec41
VZ
35// ----------------------------------------------------------------------------
36
37class WidgetsPage : public wxPanel
38{
39public:
61c083e7 40 WidgetsPage(wxBookCtrl *book);
32b8ec41 41
195df7a7
VZ
42 // return the control shown by this page
43 virtual wxControl *GetWidget() const = 0;
44
1c01dd16
VZ
45 // some pages show 2 controls, in this case override this one as well
46 virtual wxControl *GetWidget2() const { return NULL; }
47
32b8ec41
VZ
48protected:
49 // several helper functions for page creation
50
51 // create a horz sizer containing the given control and the text ctrl
52 // (pointer to which will be saved in the provided variable if not NULL)
53 // with the specified id
54 wxSizer *CreateSizerWithText(wxControl *control,
206d3a16 55 wxWindowID id = wxID_ANY,
32b8ec41
VZ
56 wxTextCtrl **ppText = NULL);
57
58 // create a sizer containing a label and a text ctrl
59 wxSizer *CreateSizerWithTextAndLabel(const wxString& label,
206d3a16 60 wxWindowID id = wxID_ANY,
32b8ec41
VZ
61 wxTextCtrl **ppText = NULL);
62
63 // create a sizer containing a button and a text ctrl
64 wxSizer *CreateSizerWithTextAndButton(wxWindowID idBtn,
65 const wxString& labelBtn,
206d3a16 66 wxWindowID id = wxID_ANY,
32b8ec41
VZ
67 wxTextCtrl **ppText = NULL);
68
69 // create a checkbox and add it to the sizer
70 wxCheckBox *CreateCheckBoxAndAddToSizer(wxSizer *sizer,
71 const wxString& label,
206d3a16 72 wxWindowID id = wxID_ANY);
32b8ec41
VZ
73
74public:
75 // the head of the linked list containinginfo about all pages
76 static WidgetsPageInfo *ms_widgetPages;
77};
78
79// ----------------------------------------------------------------------------
80// dynamic WidgetsPage creation helpers
81// ----------------------------------------------------------------------------
82
2b5f62a0 83class WidgetsPageInfo
32b8ec41
VZ
84{
85public:
61c083e7 86 typedef WidgetsPage *(*Constructor)(wxBookCtrl *book,
32b8ec41
VZ
87 wxImageList *imaglist);
88
89 // our ctor
90 WidgetsPageInfo(Constructor ctor, const wxChar *label);
91
92 // accessors
93 const wxString& GetLabel() const { return m_label; }
94 Constructor GetCtor() const { return m_ctor; }
95 WidgetsPageInfo *GetNext() const { return m_next; }
96
2673bcb0
DS
97 void SetNext(WidgetsPageInfo *next) { m_next = next; }
98
32b8ec41
VZ
99private:
100 // the label of the page
101 wxString m_label;
102
103 // the function to create this page
104 Constructor m_ctor;
105
106 // next node in the linked list or NULL
107 WidgetsPageInfo *m_next;
108};
109
110// to declare a page, this macro must be used in the class declaration
111#define DECLARE_WIDGETS_PAGE(classname) \
112 private: \
113 static WidgetsPageInfo ms_info##classname; \
114 public: \
115 const WidgetsPageInfo *GetPageInfo() const \
116 { return &ms_info##classname; }
117
118// and this one must be inserted somewhere in the source file
119#define IMPLEMENT_WIDGETS_PAGE(classname, label) \
61c083e7 120 WidgetsPage *wxCtorFor##classname(wxBookCtrl *book, \
32b8ec41 121 wxImageList *imaglist) \
61c083e7 122 { return new classname(book, imaglist); } \
32b8ec41
VZ
123 WidgetsPageInfo classname:: \
124 ms_info##classname(wxCtorFor##classname, label)
125
126#endif // _WX_SAMPLE_WIDGETS_H_