2001-06-26 17:05:06 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2004-05-25 07:20:37 -04:00
|
|
|
// Program: wxWidgets Widgets Sample
|
2001-06-26 17:05:06 -04:00
|
|
|
// Name: widgets.h
|
|
|
|
// Purpose: Common stuff for all widgets project files
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 27.03.01
|
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 2001 Vadim Zeitlin
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SAMPLE_WIDGETS_H_
|
|
|
|
#define _WX_SAMPLE_WIDGETS_H_
|
|
|
|
|
2006-07-16 12:06:27 -04:00
|
|
|
#if wxUSE_TREEBOOK && !defined(__WXHANDHELD__)
|
2006-05-17 15:49:09 -04:00
|
|
|
#include "wx/treebook.h"
|
|
|
|
#define USE_TREEBOOK 1
|
|
|
|
#define WidgetsBookCtrl wxTreebook
|
|
|
|
#define WidgetsBookCtrlEvent wxTreebookEvent
|
2006-08-24 17:05:20 -04:00
|
|
|
#define EVT_WIDGETS_PAGE_CHANGING(id,func) EVT_TREEBOOK_PAGE_CHANGING(id,func)
|
2006-10-04 05:38:56 -04:00
|
|
|
#define wxEVT_COMMAND_WIDGETS_PAGE_CHANGED wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED
|
|
|
|
#define wxWidgetsbookEventHandler(func) wxTreebookEventHandler(func)
|
2006-05-17 15:49:09 -04:00
|
|
|
#else
|
|
|
|
#include "wx/bookctrl.h"
|
|
|
|
#define USE_TREEBOOK 0
|
|
|
|
#define WidgetsBookCtrl wxBookCtrl
|
|
|
|
#define WidgetsBookCtrlEvent wxBookCtrlEvent
|
2006-08-24 17:05:20 -04:00
|
|
|
#define EVT_WIDGETS_PAGE_CHANGING(id,func) EVT_BOOKCTRL_PAGE_CHANGING(id,func)
|
2006-10-04 05:38:56 -04:00
|
|
|
#define wxEVT_COMMAND_WIDGETS_PAGE_CHANGED wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED
|
|
|
|
#define wxWidgetsbookEventHandler(func) wxBookctrlEventHandler(func)
|
2006-05-17 15:49:09 -04:00
|
|
|
#endif
|
|
|
|
|
2006-05-26 10:07:47 -04:00
|
|
|
#if wxUSE_LOG && !defined(__WXHANDHELD__)
|
2006-05-17 15:49:09 -04:00
|
|
|
#define USE_LOG 1
|
|
|
|
#else
|
|
|
|
#define USE_LOG 0
|
|
|
|
#endif
|
|
|
|
|
2006-05-26 10:07:47 -04:00
|
|
|
#if defined(__WXHANDHELD__)
|
|
|
|
#define USE_ICONS_IN_BOOK 0
|
|
|
|
#else
|
|
|
|
#define USE_ICONS_IN_BOOK 1
|
2007-04-07 09:25:34 -04:00
|
|
|
#define ICON_SIZE 16
|
2006-05-26 10:07:47 -04:00
|
|
|
#endif
|
|
|
|
|
2007-09-12 13:39:46 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSizer;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE WidgetsBookCtrl;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
class WidgetsPageInfo;
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2001-11-25 10:54:25 -05:00
|
|
|
#include "wx/panel.h"
|
|
|
|
|
2006-05-17 15:49:09 -04:00
|
|
|
// INTRODUCING NEW PAGES DON'T FORGET TO ADD ENTRIES TO 'WidgetsCategories'
|
|
|
|
enum
|
|
|
|
{
|
2006-05-18 11:36:44 -04:00
|
|
|
// On wxUniversal-based build (wxX11, wxMGL, wxMSWUniv, wxGTKUniv, etc.)
|
|
|
|
// 'native' means 'made with wxUniv port renderer'
|
2006-05-17 15:49:09 -04:00
|
|
|
NATIVE_PAGE = 0,
|
2006-05-18 11:36:44 -04:00
|
|
|
UNIVERSAL_PAGE = NATIVE_PAGE,
|
2006-05-17 15:49:09 -04:00
|
|
|
GENERIC_PAGE,
|
|
|
|
PICKER_PAGE,
|
|
|
|
COMBO_PAGE,
|
|
|
|
WITH_ITEMS_PAGE,
|
|
|
|
EDITABLE_PAGE,
|
|
|
|
BOOK_PAGE,
|
|
|
|
ALL_PAGE,
|
|
|
|
MAX_PAGES
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NATIVE_CTRLS = 1 << NATIVE_PAGE,
|
2006-05-18 11:36:44 -04:00
|
|
|
UNIVERSAL_CTRLS = NATIVE_CTRLS,
|
2006-05-17 15:49:09 -04:00
|
|
|
GENERIC_CTRLS = 1 << GENERIC_PAGE,
|
|
|
|
PICKER_CTRLS = 1 << PICKER_PAGE,
|
|
|
|
COMBO_CTRLS = 1 << COMBO_PAGE,
|
|
|
|
WITH_ITEMS_CTRLS = 1 << WITH_ITEMS_PAGE,
|
|
|
|
EDITABLE_CTRLS = 1 << EDITABLE_PAGE,
|
|
|
|
BOOK_CTRLS = 1 << BOOK_PAGE,
|
|
|
|
ALL_CTRLS = 1 << ALL_PAGE
|
|
|
|
};
|
2005-01-07 13:30:36 -05:00
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2004-11-23 06:45:07 -05:00
|
|
|
// WidgetsPage: a book page demonstrating some widget
|
2001-06-26 17:05:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WidgetsPage : public wxPanel
|
|
|
|
{
|
|
|
|
public:
|
2006-05-26 10:07:47 -04:00
|
|
|
WidgetsPage(WidgetsBookCtrl *book,
|
|
|
|
wxImageList *imaglist,
|
|
|
|
char* icon[]);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
2004-11-19 14:03:04 -05:00
|
|
|
// return the control shown by this page
|
|
|
|
virtual wxControl *GetWidget() const = 0;
|
|
|
|
|
2006-06-06 10:10:06 -04:00
|
|
|
// lazy creation of the content
|
|
|
|
virtual void CreateContent() = 0;
|
|
|
|
|
2005-02-27 20:15:46 -05:00
|
|
|
// some pages show 2 controls, in this case override this one as well
|
|
|
|
virtual wxControl *GetWidget2() const { return NULL; }
|
|
|
|
|
2006-04-16 19:39:11 -04:00
|
|
|
// recreate the control shown by this page
|
|
|
|
//
|
|
|
|
// this is currently used only to take into account the border flags
|
|
|
|
virtual void RecreateWidget() = 0;
|
|
|
|
|
|
|
|
// the default flags for the widget, currently only contains border flags
|
|
|
|
static int ms_defaultFlags;
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
protected:
|
|
|
|
// several helper functions for page creation
|
|
|
|
|
|
|
|
// create a horz sizer containing the given control and the text ctrl
|
|
|
|
// (pointer to which will be saved in the provided variable if not NULL)
|
|
|
|
// with the specified id
|
|
|
|
wxSizer *CreateSizerWithText(wxControl *control,
|
2003-12-11 05:32:15 -05:00
|
|
|
wxWindowID id = wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
wxTextCtrl **ppText = NULL);
|
|
|
|
|
|
|
|
// create a sizer containing a label and a text ctrl
|
|
|
|
wxSizer *CreateSizerWithTextAndLabel(const wxString& label,
|
2003-12-11 05:32:15 -05:00
|
|
|
wxWindowID id = wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
wxTextCtrl **ppText = NULL);
|
|
|
|
|
|
|
|
// create a sizer containing a button and a text ctrl
|
|
|
|
wxSizer *CreateSizerWithTextAndButton(wxWindowID idBtn,
|
|
|
|
const wxString& labelBtn,
|
2003-12-11 05:32:15 -05:00
|
|
|
wxWindowID id = wxID_ANY,
|
2001-06-26 17:05:06 -04:00
|
|
|
wxTextCtrl **ppText = NULL);
|
|
|
|
|
|
|
|
// create a checkbox and add it to the sizer
|
|
|
|
wxCheckBox *CreateCheckBoxAndAddToSizer(wxSizer *sizer,
|
|
|
|
const wxString& label,
|
2003-12-11 05:32:15 -05:00
|
|
|
wxWindowID id = wxID_ANY);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// the head of the linked list containinginfo about all pages
|
|
|
|
static WidgetsPageInfo *ms_widgetPages;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// dynamic WidgetsPage creation helpers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
class WidgetsPageInfo
|
2001-06-26 17:05:06 -04:00
|
|
|
{
|
|
|
|
public:
|
2006-05-17 15:49:09 -04:00
|
|
|
typedef WidgetsPage *(*Constructor)(WidgetsBookCtrl *book,
|
2001-06-26 17:05:06 -04:00
|
|
|
wxImageList *imaglist);
|
|
|
|
|
|
|
|
// our ctor
|
2006-05-17 15:49:09 -04:00
|
|
|
WidgetsPageInfo(Constructor ctor, const wxChar *label, int categories);
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
// accessors
|
|
|
|
const wxString& GetLabel() const { return m_label; }
|
2006-05-17 15:49:09 -04:00
|
|
|
int GetCategories() const { return m_categories; }
|
2001-06-26 17:05:06 -04:00
|
|
|
Constructor GetCtor() const { return m_ctor; }
|
|
|
|
WidgetsPageInfo *GetNext() const { return m_next; }
|
|
|
|
|
2004-01-19 08:27:24 -05:00
|
|
|
void SetNext(WidgetsPageInfo *next) { m_next = next; }
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
private:
|
|
|
|
// the label of the page
|
|
|
|
wxString m_label;
|
|
|
|
|
2006-05-17 15:49:09 -04:00
|
|
|
// the list (flags) for sharing page between categories
|
|
|
|
int m_categories;
|
|
|
|
|
2001-06-26 17:05:06 -04:00
|
|
|
// the function to create this page
|
|
|
|
Constructor m_ctor;
|
|
|
|
|
|
|
|
// next node in the linked list or NULL
|
|
|
|
WidgetsPageInfo *m_next;
|
|
|
|
};
|
|
|
|
|
|
|
|
// to declare a page, this macro must be used in the class declaration
|
|
|
|
#define DECLARE_WIDGETS_PAGE(classname) \
|
|
|
|
private: \
|
|
|
|
static WidgetsPageInfo ms_info##classname; \
|
|
|
|
public: \
|
|
|
|
const WidgetsPageInfo *GetPageInfo() const \
|
|
|
|
{ return &ms_info##classname; }
|
|
|
|
|
|
|
|
// and this one must be inserted somewhere in the source file
|
2006-05-17 15:49:09 -04:00
|
|
|
#define IMPLEMENT_WIDGETS_PAGE(classname, label, categories) \
|
|
|
|
WidgetsPage *wxCtorFor##classname(WidgetsBookCtrl *book, \
|
2001-06-26 17:05:06 -04:00
|
|
|
wxImageList *imaglist) \
|
2004-11-23 06:45:07 -05:00
|
|
|
{ return new classname(book, imaglist); } \
|
2001-06-26 17:05:06 -04:00
|
|
|
WidgetsPageInfo classname:: \
|
2006-05-17 15:49:09 -04:00
|
|
|
ms_info##classname(wxCtorFor##classname, label, ALL_CTRLS | categories)
|
2001-06-26 17:05:06 -04:00
|
|
|
|
|
|
|
#endif // _WX_SAMPLE_WIDGETS_H_
|