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