]> git.saurik.com Git - wxWidgets.git/blob - samples/widgets/widgets.h
fixes for programmatically deleting the find/replace dialog
[wxWidgets.git] / samples / widgets / widgets.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Program: wxWindows Widgets Sample
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
15 class WXDLLEXPORT wxCheckBox;
16 class WXDLLEXPORT wxNotebook;
17 class WXDLLEXPORT wxSizer;
18 class WXDLLEXPORT wxTextCtrl;
19
20 class WXDLLEXPORT WidgetsPageInfo;
21
22 // all source files use wxImageList
23 #include "wx/imaglist.h"
24
25 // ----------------------------------------------------------------------------
26 // WidgetsPage: a notebook page demonstrating some widget
27 // ----------------------------------------------------------------------------
28
29 class WidgetsPage : public wxPanel
30 {
31 public:
32 WidgetsPage(wxNotebook *notebook);
33
34 protected:
35 // several helper functions for page creation
36
37 // create a horz sizer containing the given control and the text ctrl
38 // (pointer to which will be saved in the provided variable if not NULL)
39 // with the specified id
40 wxSizer *CreateSizerWithText(wxControl *control,
41 wxWindowID id = -1,
42 wxTextCtrl **ppText = NULL);
43
44 // create a sizer containing a label and a text ctrl
45 wxSizer *CreateSizerWithTextAndLabel(const wxString& label,
46 wxWindowID id = -1,
47 wxTextCtrl **ppText = NULL);
48
49 // create a sizer containing a button and a text ctrl
50 wxSizer *CreateSizerWithTextAndButton(wxWindowID idBtn,
51 const wxString& labelBtn,
52 wxWindowID id = -1,
53 wxTextCtrl **ppText = NULL);
54
55 // create a checkbox and add it to the sizer
56 wxCheckBox *CreateCheckBoxAndAddToSizer(wxSizer *sizer,
57 const wxString& label,
58 wxWindowID id = -1);
59
60 public:
61 // the head of the linked list containinginfo about all pages
62 static WidgetsPageInfo *ms_widgetPages;
63 };
64
65 // ----------------------------------------------------------------------------
66 // dynamic WidgetsPage creation helpers
67 // ----------------------------------------------------------------------------
68
69 class WXDLLEXPORT WidgetsPageInfo
70 {
71 public:
72 typedef WidgetsPage *(*Constructor)(wxNotebook *notebook,
73 wxImageList *imaglist);
74
75 // our ctor
76 WidgetsPageInfo(Constructor ctor, const wxChar *label);
77
78 // accessors
79 const wxString& GetLabel() const { return m_label; }
80 Constructor GetCtor() const { return m_ctor; }
81 WidgetsPageInfo *GetNext() const { return m_next; }
82
83 private:
84 // the label of the page
85 wxString m_label;
86
87 // the function to create this page
88 Constructor m_ctor;
89
90 // next node in the linked list or NULL
91 WidgetsPageInfo *m_next;
92 };
93
94 // to declare a page, this macro must be used in the class declaration
95 #define DECLARE_WIDGETS_PAGE(classname) \
96 private: \
97 static WidgetsPageInfo ms_info##classname; \
98 public: \
99 const WidgetsPageInfo *GetPageInfo() const \
100 { return &ms_info##classname; }
101
102 // and this one must be inserted somewhere in the source file
103 #define IMPLEMENT_WIDGETS_PAGE(classname, label) \
104 WidgetsPage *wxCtorFor##classname(wxNotebook *notebook, \
105 wxImageList *imaglist) \
106 { return new classname(notebook, imaglist); } \
107 WidgetsPageInfo classname:: \
108 ms_info##classname(wxCtorFor##classname, label)
109
110 #endif // _WX_SAMPLE_WIDGETS_H_