]> git.saurik.com Git - wxWidgets.git/blame - samples/widgets/widgets.h
CSS colour compatibility after #1473731.
[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;
5378558e 16class WXDLLEXPORT wxBookCtrlBase;
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:
5378558e 40 WidgetsPage(wxBookCtrlBase *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
1301e228
VZ
48 // recreate the control shown by this page
49 //
50 // this is currently used only to take into account the border flags
51 virtual void RecreateWidget() = 0;
52
53 // the default flags for the widget, currently only contains border flags
54 static int ms_defaultFlags;
55
32b8ec41
VZ
56protected:
57 // several helper functions for page creation
58
59 // create a horz sizer containing the given control and the text ctrl
60 // (pointer to which will be saved in the provided variable if not NULL)
61 // with the specified id
62 wxSizer *CreateSizerWithText(wxControl *control,
206d3a16 63 wxWindowID id = wxID_ANY,
32b8ec41
VZ
64 wxTextCtrl **ppText = NULL);
65
66 // create a sizer containing a label and a text ctrl
67 wxSizer *CreateSizerWithTextAndLabel(const wxString& label,
206d3a16 68 wxWindowID id = wxID_ANY,
32b8ec41
VZ
69 wxTextCtrl **ppText = NULL);
70
71 // create a sizer containing a button and a text ctrl
72 wxSizer *CreateSizerWithTextAndButton(wxWindowID idBtn,
73 const wxString& labelBtn,
206d3a16 74 wxWindowID id = wxID_ANY,
32b8ec41
VZ
75 wxTextCtrl **ppText = NULL);
76
77 // create a checkbox and add it to the sizer
78 wxCheckBox *CreateCheckBoxAndAddToSizer(wxSizer *sizer,
79 const wxString& label,
206d3a16 80 wxWindowID id = wxID_ANY);
32b8ec41
VZ
81
82public:
83 // the head of the linked list containinginfo about all pages
84 static WidgetsPageInfo *ms_widgetPages;
85};
86
87// ----------------------------------------------------------------------------
88// dynamic WidgetsPage creation helpers
89// ----------------------------------------------------------------------------
90
2b5f62a0 91class WidgetsPageInfo
32b8ec41
VZ
92{
93public:
5378558e 94 typedef WidgetsPage *(*Constructor)(wxBookCtrlBase *book,
32b8ec41
VZ
95 wxImageList *imaglist);
96
97 // our ctor
98 WidgetsPageInfo(Constructor ctor, const wxChar *label);
99
100 // accessors
101 const wxString& GetLabel() const { return m_label; }
102 Constructor GetCtor() const { return m_ctor; }
103 WidgetsPageInfo *GetNext() const { return m_next; }
104
2673bcb0
DS
105 void SetNext(WidgetsPageInfo *next) { m_next = next; }
106
32b8ec41
VZ
107private:
108 // the label of the page
109 wxString m_label;
110
111 // the function to create this page
112 Constructor m_ctor;
113
114 // next node in the linked list or NULL
115 WidgetsPageInfo *m_next;
116};
117
118// to declare a page, this macro must be used in the class declaration
119#define DECLARE_WIDGETS_PAGE(classname) \
120 private: \
121 static WidgetsPageInfo ms_info##classname; \
122 public: \
123 const WidgetsPageInfo *GetPageInfo() const \
124 { return &ms_info##classname; }
125
126// and this one must be inserted somewhere in the source file
127#define IMPLEMENT_WIDGETS_PAGE(classname, label) \
5378558e 128 WidgetsPage *wxCtorFor##classname(wxBookCtrlBase *book, \
32b8ec41 129 wxImageList *imaglist) \
61c083e7 130 { return new classname(book, imaglist); } \
32b8ec41
VZ
131 WidgetsPageInfo classname:: \
132 ms_info##classname(wxCtorFor##classname, label)
133
134#endif // _WX_SAMPLE_WIDGETS_H_