initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

View File

@@ -0,0 +1,279 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msvc/wx/setup.h
// Purpose: wrapper around the real wx/setup.h for Visual C++
// Author: Vadim Zeitlin
// Created: 2004-12-12
// Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER
#error "This file should only be included when using Microsoft Visual C++"
#endif
// VC++ IDE predefines _DEBUG and _UNICODE for the new projects itself, but
// the other symbols (WXUSINGDLL, __WXUNIVERSAL__, ...) should be defined
// explicitly!
#include "wx/version.h"
#include "wx/cpp.h"
#ifndef _UNICODE
#error "wxWidgets requires Unicode."
#endif
// notice that wxSUFFIX_DEBUG is a string but wxSUFFIX itself must be an
// identifier as string concatenation is not done inside #include where we
// need it
#ifdef _DEBUG
#define wxSUFFIX_DEBUG "d"
#define wxSUFFIX ud
#else
#define wxSUFFIX_DEBUG ""
#define wxSUFFIX u
#endif
// compiler-specific prefix: by default it's always just "vc" for compatibility
// reasons but if you use multiple MSVC versions you probably build them with
// COMPILER_PREFIX=vcXX and in this case you may want to either predefine
// wxMSVC_VERSION as "XX" or define wxMSVC_VERSION_AUTO to use the appropriate
// version depending on the compiler used
//
// There is an additional complication with MSVC 14.0, 14.1 and 14.2 versions
// (a.k.a. MSVS 2015, 2017 and 2019): as they're all ABI-compatible with each
// other, it is convenient to use the same "vc14x" compiler prefix for all of
// them, but this is not how wxMSVC_VERSION_AUTO behaves by default, so you
// need to additionally define wxMSVC_VERSION_ABI_COMPAT to opt in into using
// this "vc14x" prefix.
#ifdef wxMSVC_VERSION
#define wxCOMPILER_PREFIX wxCONCAT(vc, wxMSVC_VERSION)
#elif defined(wxMSVC_VERSION_AUTO) || defined(wxMSVC_VERSION_ABI_COMPAT)
#if _MSC_VER < 1900
#error "Unsupported MSVC compiler version, 2015 or later is required."
#elif _MSC_VER >= 1900 && _MSC_VER < 2000
#ifdef wxMSVC_VERSION_ABI_COMPAT
#define wxCOMPILER_PREFIX vc14x
#else
#if _MSC_VER < 1910
#define wxCOMPILER_PREFIX vc140
#elif _MSC_VER >= 1910 && _MSC_VER < 1920
#define wxCOMPILER_PREFIX vc141
#elif _MSC_VER >= 1920 && _MSC_VER < 1930
#define wxCOMPILER_PREFIX vc142
#elif _MSC_VER >= 1930 && _MSC_VER < 2000
#define wxCOMPILER_PREFIX vc143
#else
#error "Unknown MSVC 14.x compiler version, please report to wx-dev."
#endif
#endif
#else
#error "Unknown MSVC compiler version, please report to wx-dev."
#endif
#else
#define wxCOMPILER_PREFIX vc
#endif
// architecture-specific part: not used (again, for compatibility), for x86
#if defined(_M_X64)
#define wxARCH_SUFFIX _x64
#elif defined(_M_ARM)
#define wxARCH_SUFFIX _arm
#elif defined(_M_ARM64)
#define wxARCH_SUFFIX _arm64
#elif defined(_M_IA64)
#define wxARCH_SUFFIX _ia64
#else // assume _M_IX86
#define wxARCH_SUFFIX
#endif
// Ensure the library configuration is defined
#ifndef wxCFG
#define wxCFG
#endif
// Construct the path for the subdirectory under /lib/ that the included setup.h
// will be used from
#ifdef WXUSINGDLL
#define wxLIB_SUBDIR \
wxCONCAT4(wxCOMPILER_PREFIX, wxARCH_SUFFIX, _dll, wxCFG)
#else // !DLL
#define wxLIB_SUBDIR \
wxCONCAT4(wxCOMPILER_PREFIX, wxARCH_SUFFIX, _lib, wxCFG)
#endif // DLL/!DLL
// The user can predefine a different prefix if not using the default MSW port
// with MSVC.
#ifndef wxTOOLKIT_PREFIX
#if defined(__WXGTK__)
#define wxTOOLKIT_PREFIX gtk2
#else
#define wxTOOLKIT_PREFIX msw
#endif
#endif // wxTOOLKIT_PREFIX
#define wxTOOLKIT_FULL wxCONCAT(wxTOOLKIT_PREFIX, wxSUFFIX)
// the real setup.h header file we need is in the build-specific directory,
// construct the path to it
#define wxSETUPH_PATH ../../../lib/wxLIB_SUBDIR/wxTOOLKIT_FULL/wx/setup.h
#define wxSETUPH_PATH_STR wxSTRINGIZE(wxSETUPH_PATH)
#include wxSETUPH_PATH_STR
// the library names depend on the build, these macro builds the correct
// library name for the given base name
#define wxSUFFIX_STR wxSTRINGIZE(wxSUFFIX)
#define wxSHORT_VERSION_STRING \
wxSTRINGIZE(wxMAJOR_VERSION) wxSTRINGIZE(wxMINOR_VERSION)
#define wxWX_LIB_NAME(name, subname) \
"wx" name wxSHORT_VERSION_STRING wxSUFFIX_STR subname
#define wxBASE_LIB_NAME(name) wxWX_LIB_NAME("base", "_" name)
#define wxTOOLKIT_LIB_NAME(name) wxWX_LIB_NAME(wxSTRINGIZE(wxTOOLKIT_PREFIX), "_" name)
// This one is for 3rd party libraries: they don't have the version number
// in their names and usually exist in ANSI version only (except for regex)
//
// 3rd party libraries are also are not linked in when using DLLs as they're
// embedded inside our own DLLs and don't need to be linked with the user code.
#define wx3RD_PARTY_LIB_NAME(name) "wx" name wxSUFFIX_DEBUG
// special version for regex as it does have a Unicode version
#define wx3RD_PARTY_LIB_NAME_U(name) "wx" name wxSUFFIX_STR
#if defined(wxMONOLITHIC) && wxMONOLITHIC == 1
#pragma comment(lib, wxWX_LIB_NAME("msw", ""))
#else
#pragma comment(lib, wxWX_LIB_NAME("base", ""))
#ifndef wxNO_NET_LIB
#pragma comment(lib, wxBASE_LIB_NAME("net"))
#endif
#if wxUSE_XML && !defined(wxNO_XML_LIB)
#pragma comment(lib, wxBASE_LIB_NAME("xml"))
#endif
#endif // defined(wxMONOLITHIC) && wxMONOLITHIC == 1
#if !defined(WXUSINGDLL)
#if !defined(wxNO_NET_LIB)
#pragma comment(lib, "ws2_32")
#endif
#if wxUSE_XML && !defined(wxNO_XML_LIB) && !defined(wxNO_EXPAT_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("expat"))
#endif
#if wxUSE_REGEX && !defined(wxNO_REGEX_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME_U("regex"))
#endif
#if wxUSE_ZLIB && !defined(wxNO_ZLIB_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("zlib"))
#endif
#endif // !defined(WXUSINGDLL)
#if wxUSE_GUI
#if !defined(WXUSINGDLL)
#if wxUSE_LIBJPEG && !defined(wxNO_JPEG_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("jpeg"))
#endif
#if wxUSE_LIBPNG && !defined(wxNO_PNG_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("png"))
#endif
#if wxUSE_LIBTIFF && !defined(wxNO_TIFF_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("tiff"))
#endif
#if wxUSE_LIBWEBP && !defined(wxNO_WEBP_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("webp"))
#endif
#if wxUSE_STC && !defined(wxNO_STC_LIB)
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("scintilla"))
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("lexilla"))
#endif
#endif // !defined(WXUSINGDLL)
#if !defined(wxMONOLITHIC) || wxMONOLITHIC == 0
#pragma comment(lib, wxTOOLKIT_LIB_NAME("core"))
#if wxUSE_HTML && !defined(wxNO_HTML_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("html"))
#endif
#if wxUSE_DEBUGREPORT && !defined(wxNO_QA_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("qa"))
#endif
#if wxUSE_XRC && !defined(wxNO_XRC_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("xrc"))
#endif
#if wxUSE_AUI && !defined(wxNO_AUI_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("aui"))
#endif
#if wxUSE_PROPGRID && !defined(wxNO_PROPGRID_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("propgrid"))
#endif
#if wxUSE_RIBBON && !defined(wxNO_RIBBON_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("ribbon"))
#endif
#if wxUSE_RICHTEXT && !defined(wxNO_RICHTEXT_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("richtext"))
#endif
#if wxUSE_MEDIACTRL && !defined(wxNO_MEDIA_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("media"))
#endif
#if wxUSE_STC && !defined(wxNO_STC_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("stc"))
#endif
#if wxUSE_WEBVIEW && !defined(wxNO_WEBVIEW_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("webview"))
#endif
#endif // !defined(wxMONOLITHIC) || wxMONOLITHIC == 0
#if wxUSE_GLCANVAS && !defined(wxNO_GL_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("gl"))
#endif
#endif // wxUSE_GUI
#ifndef WXUSINGDLL
// Make sure all required system libraries are added to the linker too when
// using static libraries.
#pragma comment(lib, "kernel32")
#pragma comment(lib, "user32")
#pragma comment(lib, "gdi32")
#pragma comment(lib, "gdiplus")
#pragma comment(lib, "msimg32")
#pragma comment(lib, "comdlg32")
#pragma comment(lib, "winspool")
#pragma comment(lib, "winmm")
#pragma comment(lib, "shell32")
#pragma comment(lib, "comctl32")
#pragma comment(lib, "ole32")
#pragma comment(lib, "oleaut32")
#pragma comment(lib, "uuid")
#pragma comment(lib, "rpcrt4")
#pragma comment(lib, "advapi32")
#if wxUSE_URL_NATIVE
#pragma comment(lib, "wininet")
#endif
#ifdef __WXGTK__
#ifdef __WXGTK3__
#pragma comment(lib, "libgtk-3.dll.a")
#pragma comment(lib, "libgdk-3.dll.a")
#else
#pragma comment(lib, "gtk-win32-2.0.lib")
#pragma comment(lib, "gdk-win32-2.0.lib")
#endif
#pragma comment(lib, "pangocairo-1.0.lib")
#pragma comment(lib, "gdk_pixbuf-2.0.lib")
#pragma comment(lib, "cairo.lib")
#pragma comment(lib, "pango-1.0.lib")
#pragma comment(lib, "gobject-2.0.lib")
#pragma comment(lib, "gthread-2.0.lib")
#pragma comment(lib, "glib-2.0.lib")
#endif
#endif // !WXUSINGDLL

View File

@@ -0,0 +1,169 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aboutdlg.h
// Purpose: declaration of wxAboutDialog class
// Author: Vadim Zeitlin
// Created: 2006-10-07
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ABOUTDLG_H_
#define _WX_ABOUTDLG_H_
#include "wx/defs.h"
#if wxUSE_ABOUTDLG
#include "wx/app.h"
#include "wx/icon.h"
// ----------------------------------------------------------------------------
// wxAboutDialogInfo: information shown by the standard "About" dialog
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxAboutDialogInfo
{
public:
// all fields are initially uninitialized
wxAboutDialogInfo() = default;
// accessors for various simply fields
// -----------------------------------
// name of the program, if not used defaults to wxApp::GetAppDisplayName()
void SetName(const wxString& name) { m_name = name; }
wxString GetName() const
{ return m_name.empty() ? wxTheApp->GetAppDisplayName() : m_name; }
// version should contain program version without "version" word (e.g.,
// "1.2" or "RC2") while longVersion may contain the full version including
// "version" word (e.g., "Version 1.2" or "Release Candidate 2")
//
// if longVersion is empty, it is automatically constructed from version
//
// generic and gtk native: use short version only, as a suffix to the
// program name msw and osx native: use long version
void SetVersion(const wxString& version,
const wxString& longVersion = wxString());
bool HasVersion() const { return !m_version.empty(); }
const wxString& GetVersion() const { return m_version; }
const wxString& GetLongVersion() const { return m_longVersion; }
// brief, but possibly multiline, description of the program
void SetDescription(const wxString& desc) { m_description = desc; }
bool HasDescription() const { return !m_description.empty(); }
const wxString& GetDescription() const { return m_description; }
// short string containing the program copyright information
void SetCopyright(const wxString& copyright) { m_copyright = copyright; }
bool HasCopyright() const { return !m_copyright.empty(); }
const wxString& GetCopyright() const { return m_copyright; }
// long, multiline string containing the text of the program licence
void SetLicence(const wxString& licence) { m_licence = licence; }
void SetLicense(const wxString& licence) { m_licence = licence; }
bool HasLicence() const { return !m_licence.empty(); }
const wxString& GetLicence() const { return m_licence; }
// icon to be shown in the dialog, defaults to the main frame icon
void SetIcon(const wxIcon& icon) { m_icon = icon; }
bool HasIcon() const { return m_icon.IsOk(); }
wxIcon GetIcon() const;
// web site for the program and its description (defaults to URL itself if
// empty)
void SetWebSite(const wxString& url, const wxString& desc = wxEmptyString)
{
m_url = url;
m_urlDesc = desc.empty() ? url : desc;
}
bool HasWebSite() const { return !m_url.empty(); }
const wxString& GetWebSiteURL() const { return m_url; }
const wxString& GetWebSiteDescription() const { return m_urlDesc; }
// accessors for the arrays
// ------------------------
// the list of developers of the program
void SetDevelopers(const wxArrayString& developers)
{ m_developers = developers; }
void AddDeveloper(const wxString& developer)
{ m_developers.push_back(developer); }
bool HasDevelopers() const { return !m_developers.empty(); }
const wxArrayString& GetDevelopers() const { return m_developers; }
// the list of documentation writers
void SetDocWriters(const wxArrayString& docwriters)
{ m_docwriters = docwriters; }
void AddDocWriter(const wxString& docwriter)
{ m_docwriters.push_back(docwriter); }
bool HasDocWriters() const { return !m_docwriters.empty(); }
const wxArrayString& GetDocWriters() const { return m_docwriters; }
// the list of artists for the program art
void SetArtists(const wxArrayString& artists)
{ m_artists = artists; }
void AddArtist(const wxString& artist)
{ m_artists.push_back(artist); }
bool HasArtists() const { return !m_artists.empty(); }
const wxArrayString& GetArtists() const { return m_artists; }
// the list of translators
void SetTranslators(const wxArrayString& translators)
{ m_translators = translators; }
void AddTranslator(const wxString& translator)
{ m_translators.push_back(translator); }
bool HasTranslators() const { return !m_translators.empty(); }
const wxArrayString& GetTranslators() const { return m_translators; }
// implementation only
// -------------------
// "simple" about dialog shows only textual information (with possibly
// default icon but without hyperlink nor any long texts such as the
// licence text)
bool IsSimple() const
{ return !HasWebSite() && !HasIcon() && !HasLicence(); }
// get the description and credits (i.e. all of developers, doc writers,
// artists and translators) as a one long multiline string
wxString GetDescriptionAndCredits() const;
// returns the copyright with the (C) string substituted by the Unicode
// character U+00A9
wxString GetCopyrightToDisplay() const;
private:
wxString m_name,
m_version,
m_longVersion,
m_description,
m_copyright,
m_licence;
wxIcon m_icon;
wxString m_url,
m_urlDesc;
wxArrayString m_developers,
m_docwriters,
m_artists,
m_translators;
};
// functions to show the about dialog box
WXDLLIMPEXP_ADV void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = nullptr);
#endif // wxUSE_ABOUTDLG
#endif // _WX_ABOUTDLG_H_

View File

@@ -0,0 +1,153 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/accel.h
// Purpose: wxAcceleratorEntry and wxAcceleratorTable classes
// Author: Julian Smart, Robert Roebling, Vadim Zeitlin
// Created: 31.05.01 (extracted from other files)
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCEL_H_BASE_
#define _WX_ACCEL_H_BASE_
#include "wx/defs.h"
#if wxUSE_ACCEL
#include "wx/object.h"
#include "wx/string.h"
class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable;
class WXDLLIMPEXP_FWD_CORE wxMenuItem;
class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// wxAcceleratorEntry flags
enum wxAcceleratorEntryFlags
{
wxACCEL_NORMAL = 0x0000, // no modifiers
wxACCEL_ALT = 0x0001, // hold Alt key down
wxACCEL_CTRL = 0x0002, // hold Ctrl key down
wxACCEL_SHIFT = 0x0004, // hold Shift key down
#if defined(__WXMAC__)
wxACCEL_RAW_CTRL= 0x0008, //
#else
wxACCEL_RAW_CTRL= wxACCEL_CTRL,
#endif
wxACCEL_CMD = wxACCEL_CTRL
};
// ----------------------------------------------------------------------------
// an entry in wxAcceleratorTable corresponds to one accelerator
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAcceleratorEntry
{
public:
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
wxMenuItem *item = nullptr)
: m_flags(flags)
, m_keyCode(keyCode)
, m_command(cmd)
, m_item(item)
{ }
// create accelerator corresponding to the specified string, return nullptr if
// string couldn't be parsed or a pointer to be deleted by the caller
static wxAcceleratorEntry *Create(const wxString& str);
void Set(int flags, int keyCode, int cmd, wxMenuItem *item = nullptr)
{
m_flags = flags;
m_keyCode = keyCode;
m_command = cmd;
m_item = item;
}
void SetMenuItem(wxMenuItem *item) { m_item = item; }
int GetFlags() const { return m_flags; }
int GetKeyCode() const { return m_keyCode; }
int GetCommand() const { return m_command; }
wxMenuItem *GetMenuItem() const { return m_item; }
bool operator==(const wxAcceleratorEntry& entry) const
{
return m_flags == entry.m_flags &&
m_keyCode == entry.m_keyCode &&
m_command == entry.m_command &&
m_item == entry.m_item;
}
bool operator!=(const wxAcceleratorEntry& entry) const
{ return !(*this == entry); }
bool IsOk() const
{
return m_keyCode != 0;
}
// string <-> wxAcceleratorEntry conversion
// ----------------------------------------
// returns a wxString for this accelerator.
// this function formats it using the <flags>-<keycode> format
// where <flags> maybe a hyphen-separated list of "shift|alt|ctrl"
wxString ToString() const { return AsPossiblyLocalizedString(true); }
// same as above but without translating, useful if the string is meant to
// be stored in a file or otherwise stored, instead of being shown to the
// user
wxString ToRawString() const { return AsPossiblyLocalizedString(false); }
// returns true if the given string correctly initialized this object
// (i.e. if IsOk() returns true after this call)
bool FromString(const wxString& str);
private:
wxString AsPossiblyLocalizedString(bool localized) const;
// common part of Create() and FromString()
static bool ParseAccel(const wxString& str, int *flags, int *keycode);
int m_flags; // combination of wxACCEL_XXX constants
int m_keyCode; // ASCII or virtual keycode
int m_command; // Command id to generate
// the menu item this entry corresponds to, may be null
wxMenuItem *m_item;
// for compatibility with old code, use accessors now!
friend class WXDLLIMPEXP_FWD_CORE wxMenu;
};
// ----------------------------------------------------------------------------
// include wxAcceleratorTable class declaration, it is only used by the library
// and so doesn't have any published user visible interface
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/generic/accel.h"
#elif defined(__WXMSW__)
#include "wx/msw/accel.h"
#elif defined(__WXGTK__)
#include "wx/gtk/accel.h"
#elif defined(__WXMAC__)
#include "wx/osx/accel.h"
#elif defined(__WXQT__)
#include "wx/qt/accel.h"
#endif
extern WXDLLIMPEXP_DATA_CORE(wxAcceleratorTable) wxNullAcceleratorTable;
#endif // wxUSE_ACCEL
#endif
// _WX_ACCEL_H_BASE_

View File

@@ -0,0 +1,376 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/access.h
// Purpose: Accessibility classes
// Author: Julian Smart
// Created: 2003-02-12
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCESSBASE_H_
#define _WX_ACCESSBASE_H_
// ----------------------------------------------------------------------------
// headers we have to include here
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_ACCESSIBILITY
#include "wx/variant.h"
enum wxAccStatus
{
wxACC_FAIL,
wxACC_FALSE,
wxACC_OK,
wxACC_NOT_IMPLEMENTED,
wxACC_NOT_SUPPORTED,
wxACC_INVALID_ARG
};
// Child ids are integer identifiers from 1 up.
// So zero represents 'this' object.
#define wxACC_SELF 0
// Navigation constants
enum wxNavDir
{
wxNAVDIR_DOWN,
wxNAVDIR_FIRSTCHILD,
wxNAVDIR_LASTCHILD,
wxNAVDIR_LEFT,
wxNAVDIR_NEXT,
wxNAVDIR_PREVIOUS,
wxNAVDIR_RIGHT,
wxNAVDIR_UP
};
// Role constants
enum wxAccRole {
wxROLE_NONE,
wxROLE_SYSTEM_ALERT,
wxROLE_SYSTEM_ANIMATION,
wxROLE_SYSTEM_APPLICATION,
wxROLE_SYSTEM_BORDER,
wxROLE_SYSTEM_BUTTONDROPDOWN,
wxROLE_SYSTEM_BUTTONDROPDOWNGRID,
wxROLE_SYSTEM_BUTTONMENU,
wxROLE_SYSTEM_CARET,
wxROLE_SYSTEM_CELL,
wxROLE_SYSTEM_CHARACTER,
wxROLE_SYSTEM_CHART,
wxROLE_SYSTEM_CHECKBUTTON,
wxROLE_SYSTEM_CLIENT,
wxROLE_SYSTEM_CLOCK,
wxROLE_SYSTEM_COLUMN,
wxROLE_SYSTEM_COLUMNHEADER,
wxROLE_SYSTEM_COMBOBOX,
wxROLE_SYSTEM_CURSOR,
wxROLE_SYSTEM_DIAGRAM,
wxROLE_SYSTEM_DIAL,
wxROLE_SYSTEM_DIALOG,
wxROLE_SYSTEM_DOCUMENT,
wxROLE_SYSTEM_DROPLIST,
wxROLE_SYSTEM_EQUATION,
wxROLE_SYSTEM_GRAPHIC,
wxROLE_SYSTEM_GRIP,
wxROLE_SYSTEM_GROUPING,
wxROLE_SYSTEM_HELPBALLOON,
wxROLE_SYSTEM_HOTKEYFIELD,
wxROLE_SYSTEM_INDICATOR,
wxROLE_SYSTEM_LINK,
wxROLE_SYSTEM_LIST,
wxROLE_SYSTEM_LISTITEM,
wxROLE_SYSTEM_MENUBAR,
wxROLE_SYSTEM_MENUITEM,
wxROLE_SYSTEM_MENUPOPUP,
wxROLE_SYSTEM_OUTLINE,
wxROLE_SYSTEM_OUTLINEITEM,
wxROLE_SYSTEM_PAGETAB,
wxROLE_SYSTEM_PAGETABLIST,
wxROLE_SYSTEM_PANE,
wxROLE_SYSTEM_PROGRESSBAR,
wxROLE_SYSTEM_PROPERTYPAGE,
wxROLE_SYSTEM_PUSHBUTTON,
wxROLE_SYSTEM_RADIOBUTTON,
wxROLE_SYSTEM_ROW,
wxROLE_SYSTEM_ROWHEADER,
wxROLE_SYSTEM_SCROLLBAR,
wxROLE_SYSTEM_SEPARATOR,
wxROLE_SYSTEM_SLIDER,
wxROLE_SYSTEM_SOUND,
wxROLE_SYSTEM_SPINBUTTON,
wxROLE_SYSTEM_STATICTEXT,
wxROLE_SYSTEM_STATUSBAR,
wxROLE_SYSTEM_TABLE,
wxROLE_SYSTEM_TEXT,
wxROLE_SYSTEM_TITLEBAR,
wxROLE_SYSTEM_TOOLBAR,
wxROLE_SYSTEM_TOOLTIP,
wxROLE_SYSTEM_WHITESPACE,
wxROLE_SYSTEM_WINDOW
};
// Object types
enum wxAccObject {
wxOBJID_WINDOW = 0x00000000,
wxOBJID_SYSMENU = 0xFFFFFFFF,
wxOBJID_TITLEBAR = 0xFFFFFFFE,
wxOBJID_MENU = 0xFFFFFFFD,
wxOBJID_CLIENT = 0xFFFFFFFC,
wxOBJID_VSCROLL = 0xFFFFFFFB,
wxOBJID_HSCROLL = 0xFFFFFFFA,
wxOBJID_SIZEGRIP = 0xFFFFFFF9,
wxOBJID_CARET = 0xFFFFFFF8,
wxOBJID_CURSOR = 0xFFFFFFF7,
wxOBJID_ALERT = 0xFFFFFFF6,
wxOBJID_SOUND = 0xFFFFFFF5
};
// Accessible states
#define wxACC_STATE_SYSTEM_ALERT_HIGH 0x00000001
#define wxACC_STATE_SYSTEM_ALERT_MEDIUM 0x00000002
#define wxACC_STATE_SYSTEM_ALERT_LOW 0x00000004
#define wxACC_STATE_SYSTEM_ANIMATED 0x00000008
#define wxACC_STATE_SYSTEM_BUSY 0x00000010
#define wxACC_STATE_SYSTEM_CHECKED 0x00000020
#define wxACC_STATE_SYSTEM_COLLAPSED 0x00000040
#define wxACC_STATE_SYSTEM_DEFAULT 0x00000080
#define wxACC_STATE_SYSTEM_EXPANDED 0x00000100
#define wxACC_STATE_SYSTEM_EXTSELECTABLE 0x00000200
#define wxACC_STATE_SYSTEM_FLOATING 0x00000400
#define wxACC_STATE_SYSTEM_FOCUSABLE 0x00000800
#define wxACC_STATE_SYSTEM_FOCUSED 0x00001000
#define wxACC_STATE_SYSTEM_HOTTRACKED 0x00002000
#define wxACC_STATE_SYSTEM_INVISIBLE 0x00004000
#define wxACC_STATE_SYSTEM_MARQUEED 0x00008000
#define wxACC_STATE_SYSTEM_MIXED 0x00010000
#define wxACC_STATE_SYSTEM_MULTISELECTABLE 0x00020000
#define wxACC_STATE_SYSTEM_OFFSCREEN 0x00040000
#define wxACC_STATE_SYSTEM_PRESSED 0x00080000
#define wxACC_STATE_SYSTEM_PROTECTED 0x00100000
#define wxACC_STATE_SYSTEM_READONLY 0x00200000
#define wxACC_STATE_SYSTEM_SELECTABLE 0x00400000
#define wxACC_STATE_SYSTEM_SELECTED 0x00800000
#define wxACC_STATE_SYSTEM_SELFVOICING 0x01000000
#define wxACC_STATE_SYSTEM_UNAVAILABLE 0x02000000
// Selection flag
enum wxAccSelectionFlags
{
wxACC_SEL_NONE = 0,
wxACC_SEL_TAKEFOCUS = 1,
wxACC_SEL_TAKESELECTION = 2,
wxACC_SEL_EXTENDSELECTION = 4,
wxACC_SEL_ADDSELECTION = 8,
wxACC_SEL_REMOVESELECTION = 16
};
// Accessibility event identifiers
#define wxACC_EVENT_SYSTEM_SOUND 0x0001
#define wxACC_EVENT_SYSTEM_ALERT 0x0002
#define wxACC_EVENT_SYSTEM_FOREGROUND 0x0003
#define wxACC_EVENT_SYSTEM_MENUSTART 0x0004
#define wxACC_EVENT_SYSTEM_MENUEND 0x0005
#define wxACC_EVENT_SYSTEM_MENUPOPUPSTART 0x0006
#define wxACC_EVENT_SYSTEM_MENUPOPUPEND 0x0007
#define wxACC_EVENT_SYSTEM_CAPTURESTART 0x0008
#define wxACC_EVENT_SYSTEM_CAPTUREEND 0x0009
#define wxACC_EVENT_SYSTEM_MOVESIZESTART 0x000A
#define wxACC_EVENT_SYSTEM_MOVESIZEEND 0x000B
#define wxACC_EVENT_SYSTEM_CONTEXTHELPSTART 0x000C
#define wxACC_EVENT_SYSTEM_CONTEXTHELPEND 0x000D
#define wxACC_EVENT_SYSTEM_DRAGDROPSTART 0x000E
#define wxACC_EVENT_SYSTEM_DRAGDROPEND 0x000F
#define wxACC_EVENT_SYSTEM_DIALOGSTART 0x0010
#define wxACC_EVENT_SYSTEM_DIALOGEND 0x0011
#define wxACC_EVENT_SYSTEM_SCROLLINGSTART 0x0012
#define wxACC_EVENT_SYSTEM_SCROLLINGEND 0x0013
#define wxACC_EVENT_SYSTEM_SWITCHSTART 0x0014
#define wxACC_EVENT_SYSTEM_SWITCHEND 0x0015
#define wxACC_EVENT_SYSTEM_MINIMIZESTART 0x0016
#define wxACC_EVENT_SYSTEM_MINIMIZEEND 0x0017
#define wxACC_EVENT_OBJECT_CREATE 0x8000
#define wxACC_EVENT_OBJECT_DESTROY 0x8001
#define wxACC_EVENT_OBJECT_SHOW 0x8002
#define wxACC_EVENT_OBJECT_HIDE 0x8003
#define wxACC_EVENT_OBJECT_REORDER 0x8004
#define wxACC_EVENT_OBJECT_FOCUS 0x8005
#define wxACC_EVENT_OBJECT_SELECTION 0x8006
#define wxACC_EVENT_OBJECT_SELECTIONADD 0x8007
#define wxACC_EVENT_OBJECT_SELECTIONREMOVE 0x8008
#define wxACC_EVENT_OBJECT_SELECTIONWITHIN 0x8009
#define wxACC_EVENT_OBJECT_STATECHANGE 0x800A
#define wxACC_EVENT_OBJECT_LOCATIONCHANGE 0x800B
#define wxACC_EVENT_OBJECT_NAMECHANGE 0x800C
#define wxACC_EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D
#define wxACC_EVENT_OBJECT_VALUECHANGE 0x800E
#define wxACC_EVENT_OBJECT_PARENTCHANGE 0x800F
#define wxACC_EVENT_OBJECT_HELPCHANGE 0x8010
#define wxACC_EVENT_OBJECT_DEFACTIONCHANGE 0x8011
#define wxACC_EVENT_OBJECT_ACCELERATORCHANGE 0x8012
// ----------------------------------------------------------------------------
// wxAccessible
// All functions return an indication of success, failure, or not implemented.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxAccessible;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxPoint;
class WXDLLIMPEXP_FWD_CORE wxRect;
class WXDLLIMPEXP_CORE wxAccessibleBase : public wxObject
{
wxDECLARE_NO_COPY_CLASS(wxAccessibleBase);
public:
wxAccessibleBase(wxWindow* win): m_window(win) {}
virtual ~wxAccessibleBase() = default;
// Overridables
// Can return either a child object, or an integer
// representing the child element, starting from 1.
// pt is in screen coordinates.
virtual wxAccStatus HitTest(const wxPoint& WXUNUSED(pt), int* WXUNUSED(childId), wxAccessible** WXUNUSED(childObject))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
// rect is in screen coordinates.
virtual wxAccStatus GetLocation(wxRect& WXUNUSED(rect), int WXUNUSED(elementId))
{ return wxACC_NOT_IMPLEMENTED; }
// Navigates from fromId to toId/toObject.
virtual wxAccStatus Navigate(wxNavDir WXUNUSED(navDir), int WXUNUSED(fromId),
int* WXUNUSED(toId), wxAccessible** WXUNUSED(toObject))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the name of the specified object.
virtual wxAccStatus GetName(int WXUNUSED(childId), wxString* WXUNUSED(name))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the number of children.
virtual wxAccStatus GetChildCount(int* WXUNUSED(childCount))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the specified child (starting from 1).
// If *child is null and return value is wxACC_OK,
// this means that the child is a simple element and
// not an accessible object.
virtual wxAccStatus GetChild(int WXUNUSED(childId), wxAccessible** WXUNUSED(child))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the parent, or nullptr.
virtual wxAccStatus GetParent(wxAccessible** WXUNUSED(parent))
{ return wxACC_NOT_IMPLEMENTED; }
// Performs the default action. childId is 0 (the action for this object)
// or > 0 (the action for a child).
// Return wxACC_NOT_SUPPORTED if there is no default action for this
// window (e.g. an edit control).
virtual wxAccStatus DoDefaultAction(int WXUNUSED(childId))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the default action for this object (0) or > 0 (the action for a child).
// Return wxACC_OK even if there is no action. actionName is the action, or the empty
// string if there is no action.
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
virtual wxAccStatus GetDefaultAction(int WXUNUSED(childId), wxString* WXUNUSED(actionName))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns the description for this object or a child.
virtual wxAccStatus GetDescription(int WXUNUSED(childId), wxString* WXUNUSED(description))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns help text for this object or a child, similar to tooltip text.
virtual wxAccStatus GetHelpText(int WXUNUSED(childId), wxString* WXUNUSED(helpText))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns the keyboard shortcut for this object or child.
// Return e.g. ALT+K
virtual wxAccStatus GetKeyboardShortcut(int WXUNUSED(childId), wxString* WXUNUSED(shortcut))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns a role constant.
virtual wxAccStatus GetRole(int WXUNUSED(childId), wxAccRole* WXUNUSED(role))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns a state constant.
virtual wxAccStatus GetState(int WXUNUSED(childId), long* WXUNUSED(state))
{ return wxACC_NOT_IMPLEMENTED; }
// Returns a localized string representing the value for the object
// or child.
virtual wxAccStatus GetValue(int WXUNUSED(childId), wxString* WXUNUSED(strValue))
{ return wxACC_NOT_IMPLEMENTED; }
// Selects the object or child.
virtual wxAccStatus Select(int WXUNUSED(childId), wxAccSelectionFlags WXUNUSED(selectFlags))
{ return wxACC_NOT_IMPLEMENTED; }
// Gets the window with the keyboard focus.
// If childId is 0 and child is null, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
virtual wxAccStatus GetFocus(int* WXUNUSED(childId), wxAccessible** WXUNUSED(child))
{ return wxACC_NOT_IMPLEMENTED; }
#if wxUSE_VARIANT
// Gets a variant representing the selected children
// of this object.
// Acceptable values:
// - a null variant (IsNull() returns TRUE)
// - a list variant (GetType() == wxT("list"))
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long"))
// - a "void*" pointer to a wxAccessible child object
virtual wxAccStatus GetSelections(wxVariant* WXUNUSED(selections))
{ return wxACC_NOT_IMPLEMENTED; }
#endif // wxUSE_VARIANT
// Accessors
// Returns the window associated with this object.
wxWindow* GetWindow() { return m_window; }
// Sets the window associated with this object.
void SetWindow(wxWindow* window) { m_window = window; }
// Operations
// Each platform's implementation must define this
// static void NotifyEvent(int eventType, wxWindow* window, wxAccObject objectType,
// int objectId);
private:
// Data members
wxWindow* m_window;
};
// ----------------------------------------------------------------------------
// now include the declaration of the real class
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/access.h"
#endif
#endif // wxUSE_ACCESSIBILITY
#endif // _WX_ACCESSBASE_H_

View File

@@ -0,0 +1,60 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/activityindicator.h
// Purpose: wxActivityIndicator declaration.
// Author: Vadim Zeitlin
// Created: 2015-03-05
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACTIVITYINDICATOR_H_
#define _WX_ACTIVITYINDICATOR_H_
#include "wx/defs.h"
#if wxUSE_ACTIVITYINDICATOR
#include "wx/control.h"
#define wxActivityIndicatorNameStr wxS("activityindicator")
// ----------------------------------------------------------------------------
// wxActivityIndicator: small animated indicator of some application activity.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxActivityIndicatorBase : public wxControl
{
public:
// Start or stop the activity animation (it is stopped initially).
virtual void Start() = 0;
virtual void Stop() = 0;
// Return true if the control is currently showing activity.
virtual bool IsRunning() const = 0;
// Override some base class virtual methods.
virtual bool AcceptsFocus() const override { return false; }
virtual bool HasTransparentBackground() override { return true; }
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
};
#ifndef __WXUNIVERSAL__
#if defined(__WXGTK220__)
#define wxHAS_NATIVE_ACTIVITYINDICATOR
#include "wx/gtk/activityindicator.h"
#elif defined(__WXOSX_COCOA__)
#define wxHAS_NATIVE_ACTIVITYINDICATOR
#include "wx/osx/activityindicator.h"
#endif
#endif // !__WXUNIVERSAL__
#ifndef wxHAS_NATIVE_ACTIVITYINDICATOR
#include "wx/generic/activityindicator.h"
#endif
#endif // wxUSE_ACTIVITYINDICATOR
#endif // _WX_ACTIVITYINDICATOR_H_

View File

@@ -0,0 +1,109 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/addremovectrl.h
// Purpose: wxAddRemoveCtrl declaration.
// Author: Vadim Zeitlin
// Created: 2015-01-29
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ADDREMOVECTRL_H_
#define _WX_ADDREMOVECTRL_H_
#include "wx/panel.h"
#if wxUSE_ADDREMOVECTRL
extern WXDLLIMPEXP_DATA_CORE(const char) wxAddRemoveCtrlNameStr[];
// ----------------------------------------------------------------------------
// wxAddRemoveAdaptor: used by wxAddRemoveCtrl to work with the list control
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAddRemoveAdaptor
{
public:
// Default ctor and trivial but virtual dtor.
wxAddRemoveAdaptor() = default;
virtual ~wxAddRemoveAdaptor() = default;
// Override to return the associated control.
virtual wxWindow* GetItemsCtrl() const = 0;
// Override to return whether a new item can be added to the control.
virtual bool CanAdd() const = 0;
// Override to return whether the currently selected item (if any) can be
// removed from the control.
virtual bool CanRemove() const = 0;
// Called when an item should be added, can only be called if CanAdd()
// currently returns true.
virtual void OnAdd() = 0;
// Called when the current item should be removed, can only be called if
// CanRemove() currently returns true.
virtual void OnRemove() = 0;
private:
wxDECLARE_NO_COPY_CLASS(wxAddRemoveAdaptor);
};
// ----------------------------------------------------------------------------
// wxAddRemoveCtrl: a list-like control combined with add/remove buttons
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAddRemoveCtrl : public wxPanel
{
public:
wxAddRemoveCtrl()
{
Init();
}
wxAddRemoveCtrl(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxAddRemoveCtrlNameStr))
{
Init();
Create(parent, winid, pos, size, style, name);
}
bool Create(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxAddRemoveCtrlNameStr));
virtual ~wxAddRemoveCtrl();
// Must be called for the control to be usable, takes ownership of the
// pointer.
void SetAdaptor(wxAddRemoveAdaptor* adaptor);
// Set tooltips to use for the add and remove buttons.
void SetButtonsToolTips(const wxString& addtip, const wxString& removetip);
protected:
virtual wxSize DoGetBestClientSize() const override;
private:
// Common part of all ctors.
void Init()
{
m_impl = nullptr;
}
class wxAddRemoveImpl* m_impl;
wxDECLARE_NO_COPY_CLASS(wxAddRemoveCtrl);
};
#endif // wxUSE_ADDREMOVECTRL
#endif // _WX_ADDREMOVECTRL_H_

View File

@@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/affinematrix2d.h
// Purpose: wxAffineMatrix2D class.
// Author: Based on wxTransformMatrix by Chris Breeze, Julian Smart
// Created: 2011-04-05
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AFFINEMATRIX2D_H_
#define _WX_AFFINEMATRIX2D_H_
#include "wx/defs.h"
#if wxUSE_GEOMETRY
#include "wx/affinematrix2dbase.h"
// A simple implementation of wxAffineMatrix2DBase interface done entirely in
// wxWidgets.
class WXDLLIMPEXP_CORE wxAffineMatrix2D : public wxAffineMatrix2DBase
{
public:
wxAffineMatrix2D() : m_11(1), m_12(0),
m_21(0), m_22(1),
m_tx(0), m_ty(0)
{
}
// Implement base class pure virtual methods.
virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr) override;
virtual void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const override;
virtual void Concat(const wxAffineMatrix2DBase& t) override;
virtual bool Invert() override;
virtual bool IsIdentity() const override;
virtual bool IsEqual(const wxAffineMatrix2DBase& t) const override;
virtual void Translate(wxDouble dx, wxDouble dy) override;
virtual void Scale(wxDouble xScale, wxDouble yScale) override;
virtual void Rotate(wxDouble cRadians) override;
protected:
virtual wxPoint2DDouble DoTransformPoint(const wxPoint2DDouble& p) const override;
virtual wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const override;
private:
wxDouble m_11, m_12, m_21, m_22, m_tx, m_ty;
};
#endif // wxUSE_GEOMETRY
#endif // _WX_AFFINEMATRIX2D_H_

View File

@@ -0,0 +1,127 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/affinematrix2dbase.h
// Purpose: Common interface for 2D transformation matrices.
// Author: Catalin Raceanu
// Created: 2011-04-06
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AFFINEMATRIX2DBASE_H_
#define _WX_AFFINEMATRIX2DBASE_H_
#include "wx/defs.h"
#if wxUSE_GEOMETRY
#include "wx/geometry.h"
struct wxMatrix2D
{
wxMatrix2D(wxDouble v11 = 1,
wxDouble v12 = 0,
wxDouble v21 = 0,
wxDouble v22 = 1)
{
m_11 = v11; m_12 = v12;
m_21 = v21; m_22 = v22;
}
wxDouble m_11, m_12, m_21, m_22;
};
// A 2x3 matrix representing an affine 2D transformation.
//
// This is an abstract base class implemented by wxAffineMatrix2D only so far,
// but in the future we also plan to derive wxGraphicsMatrix from it (it should
// also be documented then as currently only wxAffineMatrix2D itself is).
class WXDLLIMPEXP_CORE wxAffineMatrix2DBase
{
public:
wxAffineMatrix2DBase() = default;
virtual ~wxAffineMatrix2DBase() = default;
// sets the matrix to the respective values
virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr) = 0;
// gets the component values of the matrix
virtual void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const = 0;
// concatenates the matrix
virtual void Concat(const wxAffineMatrix2DBase& t) = 0;
// makes this the inverse matrix
virtual bool Invert() = 0;
// return true if this is the identity matrix
virtual bool IsIdentity() const = 0;
// returns true if the elements of the transformation matrix are equal ?
virtual bool IsEqual(const wxAffineMatrix2DBase& t) const = 0;
bool operator==(const wxAffineMatrix2DBase& t) const { return IsEqual(t); }
bool operator!=(const wxAffineMatrix2DBase& t) const { return !IsEqual(t); }
//
// transformations
//
// add the translation to this matrix
virtual void Translate(wxDouble dx, wxDouble dy) = 0;
// add the scale to this matrix
virtual void Scale(wxDouble xScale, wxDouble yScale) = 0;
// add the rotation to this matrix (counter clockwise, radians)
virtual void Rotate(wxDouble ccRadians) = 0;
// add mirroring to this matrix
void Mirror(int direction = wxHORIZONTAL)
{
wxDouble x = (direction & wxHORIZONTAL) ? -1 : 1;
wxDouble y = (direction & wxVERTICAL) ? -1 : 1;
Scale(x, y);
}
// applies that matrix to the point
wxPoint2DDouble TransformPoint(const wxPoint2DDouble& src) const
{
return DoTransformPoint(src);
}
void TransformPoint(wxDouble* x, wxDouble* y) const
{
wxCHECK_RET( x && y, "Can't be null" );
const wxPoint2DDouble dst = DoTransformPoint(wxPoint2DDouble(*x, *y));
*x = dst.m_x;
*y = dst.m_y;
}
// applies the matrix except for translations
wxPoint2DDouble TransformDistance(const wxPoint2DDouble& src) const
{
return DoTransformDistance(src);
}
void TransformDistance(wxDouble* dx, wxDouble* dy) const
{
wxCHECK_RET( dx && dy, "Can't be null" );
const wxPoint2DDouble
dst = DoTransformDistance(wxPoint2DDouble(*dx, *dy));
*dx = dst.m_x;
*dy = dst.m_y;
}
protected:
virtual
wxPoint2DDouble DoTransformPoint(const wxPoint2DDouble& p) const = 0;
virtual
wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const = 0;
};
#endif // wxUSE_GEOMETRY
#endif // _WX_AFFINEMATRIX2DBASE_H_

View File

@@ -0,0 +1,26 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/afterstd.h
// Purpose: #include after STL headers
// Author: Vadim Zeitlin
// Created: 07/07/03
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/**
See the comments in beforestd.h.
*/
#if defined(__WINDOWS__)
#include "wx/msw/winundef.h"
#endif
// undo what we did in wx/beforestd.h
#if defined(__VISUALC__) && __VISUALC__ >= 1910
#pragma warning(pop)
#endif // VC++ >= 14.1
// see beforestd.h for explanation
#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY)
#pragma GCC visibility pop
#endif

View File

@@ -0,0 +1,235 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/android/chkconf.h
// Purpose: Android-specific configuration options checks
// Author: Zsolt Bakcsi
// Created: 2011-12-08
// RCS-ID:
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANDROID_CHKCONF_H_
#define _WX_ANDROID_CHKCONF_H_
// For Qt under Android, use default configuration procedure as most features
// should be supported (see documentation for more information)
#ifndef __WXQT__
// ----------------------------------------------------------------------------
// Disable features which don't work (yet) or don't make sense under Android.
// ----------------------------------------------------------------------------
// please keep the list in alphabetic order except for closely related settings
// (e.g. wxUSE_ENH_METAFILE is put immediately after wxUSE_METAFILE)
// ----------------------------------------------------------------------------
// These are disabled because they are TODO. Or to decide whether to do or not.
// ----------------------------------------------------------------------------
#undef wxUSE_CONFIG
#define wxUSE_CONFIG 0
// This compiles, but not yet tested, so:
#undef wxUSE_CONSOLE_EVENTLOOP
#define wxUSE_CONSOLE_EVENTLOOP 0
#undef wxUSE_DEBUGREPORT
#define wxUSE_DEBUGREPORT 0
#undef wxUSE_DIALUP_MANAGER
#define wxUSE_DIALUP_MANAGER 0
#undef wxUSE_DISPLAY
#define wxUSE_DISPLAY 0
#undef wxUSE_DYNAMIC_LOADER
#define wxUSE_DYNAMIC_LOADER 0
#undef wxUSE_DYNLIB_CLASS
#define wxUSE_DYNLIB_CLASS 0
#undef wxUSE_FSVOLUME
#define wxUSE_FSVOLUME 0
// Compile-time errors when last tried (wxHAS_INOTIFY, wxHAS_KQUEUE)
#undef wxUSE_FSWATCHER
#define wxUSE_FSWATCHER 0
// Seems like Android lacks locale support. TODO: check!
// Hint:
// http://groups.google.com/group/android-ndk/browse_thread/thread/ffd012a047ec2392?pli=1
// "Android doesn't provide locale support in its C and C++ runtimes.
// This is handled at a higher-level in the application stack, using ICU
// (which is not exposed by the NDK, since the ABI is very volatile, and the
// set of built-in tables varies from device to device, based on customization
// / size reasons).
// You might want to use a different locale implementation. The STLport and GNU
// libstdc++ do provide then if you're using C++."
#undef wxUSE_INTL
#define wxUSE_INTL 0
#undef wxUSE_XLOCALE
#define wxUSE_XLOCALE 0
#undef wxUSE_IPC
#define wxUSE_IPC 0
#undef wxUSE_MEDIACTRL
#define wxUSE_MEDIACTRL 0
#undef wxUSE_ON_FATAL_EXCEPTION
#define wxUSE_ON_FATAL_EXCEPTION 0
#undef wxUSE_REGEX
#define wxUSE_REGEX 0
#undef wxUSE_STDPATHS
#define wxUSE_STDPATHS 0
#undef wxUSE_STACKWALKER
#define wxUSE_STACKWALKER 0
#undef wxUSE_MIMETYPE
#define wxUSE_MIMETYPE 0
#undef wxUSE_REGEX
#define wxUSE_REGEX 0
#undef wxUSE_REGKEY
#define wxUSE_REGKEY 0
#undef wxUSE_SNGLINST_CHECKER
#define wxUSE_SNGLINST_CHECKER 0
#undef wxUSE_SOUND
#define wxUSE_SOUND 0
#undef wxUSE_SYSTEM_OPTIONS
#define wxUSE_SYSTEM_OPTIONS 0
#undef wxUSE_XRC
#define wxUSE_XRC 0
// ----------------------------------------------------------------------------
// GUI is completely TODO.
// ----------------------------------------------------------------------------
#undef wxUSE_COLOURPICKERCTRL
#define wxUSE_COLOURPICKERCTRL 0
#undef wxUSE_COLOURDLG
#define wxUSE_COLOURDLG 0
#undef wxUSE_FONTENUM
#define wxUSE_FONTENUM 0
#undef wxUSE_FONTMAP
#define wxUSE_FONTMAP 0
#undef wxUSE_HELP
#define wxUSE_HELP 0
#undef wxUSE_HTML
#define wxUSE_HTML 0
#undef wxUSE_LISTBOOK
#define wxUSE_LISTBOOK 0
#undef wxUSE_OWNER_DRAWN
#define wxUSE_OWNER_DRAWN 0
#undef wxUSE_NOTEBOOK
#define wxUSE_NOTEBOOK 0
#undef wxUSE_RICHEDIT
#define wxUSE_RICHEDIT 0
#undef wxUSE_RICHEDIT2
#define wxUSE_RICHEDIT2 0
#undef wxUSE_STATUSBAR
#define wxUSE_STATUSBAR 0
// Are tooltips useful at all on a touch screen?
#undef wxUSE_TOOLTIPS
#define wxUSE_TOOLTIPS 0
#undef wxUSE_WXHTML_HELP
#define wxUSE_WXHTML_HELP 0
// ----------------------------------------------------------------------------
// All image classes are TODO.
// ----------------------------------------------------------------------------
#undef wxUSE_IMAGE
#define wxUSE_IMAGE 0
#undef wxUSE_LIBPNG
#define wxUSE_LIBPNG 0
#undef wxUSE_LIBJPEG
#define wxUSE_LIBJPEG 0
#undef wxUSE_LIBTIFF
#define wxUSE_LIBTIFF 0
#undef wxUSE_TGA
#define wxUSE_TGA 0
#undef wxUSE_GIF
#define wxUSE_GIF 0
#undef wxUSE_PNM
#define wxUSE_PNM 0
#undef wxUSE_PCX
#define wxUSE_PCX 0
#undef wxUSE_IFF
#define wxUSE_IFF 0
#undef wxUSE_XPM
#define wxUSE_XPM 0
#undef wxUSE_ICO_CUR
#define wxUSE_ICO_CUR 0
#undef wxUSE_PALETTE
#define wxUSE_PALETTE 0
// ----------------------------------------------------------------------------
// These are disabled because they don't make sense, are not supported, or
// would require too much effort.
// ----------------------------------------------------------------------------
// Unnecessary under Android, probably it doesn't even compile.
#undef wxUSE_AUI
#define wxUSE_AUI 0
// No command line on Android.
#undef wxUSE_CMDLINE_PARSER
#define wxUSE_CMDLINE_PARSER 0
// No joystick on Android devices.
// (What about using the direction sensor or the accelerometer?)
#undef wxUSE_JOYSTICK
#define wxUSE_JOYSTICK 0
// No MDI under Android. Well, no GUI at all (yet).
#undef wxUSE_MDI
#define wxUSE_MDI 0
#undef wxUSE_MDI_ARCHITECTURE
#define wxUSE_MDI_ARCHITECTURE 0
// No printing support on Android (2011).
// Although 3rd party SDKs may exist (I know of one payware).
#undef wxUSE_PRINTING_ARCHITECTURE
#define wxUSE_PRINTING_ARCHITECTURE 0
#endif // __WXQT__
#endif // _WX_ANDROID_CHKCONF_H_

View File

@@ -0,0 +1,60 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/android/config_android.h
// Purpose: configurations for Android builds
// Author: Zsolt Bakcsi
// Created: 2011-12-02
// RCS-ID:
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// Please note that most of these settings are based on config_xcode.h and
// 'fine-tuned' on a trial-and-error basis. This means, no in-depth analysis
// of Android docs / source was done.
// For Qt under Android, use the default configuration procedure as most
// features should be supported and the following fixed definitions will
// cause compiler warnings or other issues.
#if !defined(__WXQT__)
#define wxUSE_UNIX 1
#define __UNIX__ 1
#define HAVE_NANOSLEEP
#define HAVE_FCNTL 1
#define HAVE_GCC_ATOMIC_BUILTINS
#define HAVE_GETHOSTBYNAME 1
#define HAVE_GETSERVBYNAME 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_GMTIME_R 1
#define HAVE_INET_ADDR 1
#define HAVE_INET_ATON 1
#define HAVE_LOCALTIME_R 1
#define HAVE_PTHREAD_MUTEXATTR_T 1
#define HAVE_PTHREAD_MUTEXATTR_SETTYPE_DECL 1
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#define HAVE_THREAD_PRIORITY_FUNCTIONS 1
#define HAVE_SSIZE_T 1
#define HAVE_WPRINTF 1
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_SIZE_T 4
#define SIZEOF_VOID_P 4
#define SIZEOF_WCHAR_T 4
#define wxHAVE_PTHREAD_CLEANUP 1
#define wxNO_WOSTREAM
#define wxSIZE_T_IS_UINT 1
#define wxWCHAR_T_IS_REAL_TYPE 1
#define wxUSE_SELECT_DISPATCHER 1
#ifdef HAVE_PTHREAD_CANCEL
// Android doesn't support pthread_cancel().
#undef HAVE_PTHREAD_CANCEL
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/anidecod.h
// Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation
// Author: Francesco Montorsi
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANIDECOD_H
#define _WX_ANIDECOD_H
#include "wx/defs.h"
#if wxUSE_STREAMS && (wxUSE_ICO_CUR || wxUSE_GIF)
#include "wx/stream.h"
#include "wx/image.h"
#include "wx/animdecod.h"
#include "wx/dynarray.h"
class /*WXDLLIMPEXP_CORE*/ wxANIFrameInfo; // private implementation detail
// For compatibility purposes, provide wxImageArray class mimicking the legacy
// dynamic array which used to be required by wxGIFHandler::SaveAnimation():
// now we just take a vector of images there, but we want to keep the existing
// code using wxImageArray working (and keep it declared here because this is
// where it used to be, even if this doesn't make much sense).
using wxImageArray = wxBaseArray<wxImage>;
// --------------------------------------------------------------------------
// wxANIDecoder class
// --------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxANIDecoder : public wxAnimationDecoder
{
public:
// constructor, destructor, etc.
wxANIDecoder();
~wxANIDecoder();
virtual wxSize GetFrameSize(unsigned int frame) const override;
virtual wxPoint GetFramePosition(unsigned int frame) const override;
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const override;
virtual long GetDelay(unsigned int frame) const override;
virtual wxColour GetTransparentColour(unsigned int frame) const override;
// implementation of wxAnimationDecoder's pure virtuals
virtual bool Load( wxInputStream& stream ) override;
bool ConvertToImage(unsigned int frame, wxImage *image) const override;
wxNODISCARD wxAnimationDecoder *Clone() const override
{ return new wxANIDecoder; }
wxAnimationType GetType() const override
{ return wxANIMATION_TYPE_ANI; }
protected:
// wxAnimationDecoder pure virtual:
virtual bool DoCanRead( wxInputStream& stream ) const override;
// modifies current stream position (see wxAnimationDecoder::CanRead)
private:
// frames stored as wxImage(s): ANI files are meant to be used mostly for animated
// cursors and thus they do not use any optimization to encode differences between
// two frames: they are just a list of images to display sequentially.
std::vector<wxImage> m_images;
// the info about each image stored in m_images.
// NB: m_info.GetCount() may differ from m_images.GetCount()!
std::vector<wxANIFrameInfo> m_info;
// this is the wxCURHandler used to load the ICON chunk of the ANI files
static wxCURHandler sm_handler;
wxDECLARE_NO_COPY_CLASS(wxANIDecoder);
};
#endif // wxUSE_STREAMS && (wxUSE_ICO_CUR || wxUSE_GIF)
#endif // _WX_ANIDECOD_H

View File

@@ -0,0 +1,248 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/animate.h
// Purpose: wxAnimation and wxAnimationCtrl
// Author: Julian Smart and Guillermo Rodriguez Garcia
// Modified by: Francesco Montorsi
// Created: 13/8/99
// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANIMATE_H_
#define _WX_ANIMATE_H_
#include "wx/defs.h"
#if wxUSE_ANIMATIONCTRL
#include "wx/animdecod.h"
#include "wx/control.h"
#include "wx/timer.h"
#include "wx/bmpbndl.h"
#include <vector>
class WXDLLIMPEXP_FWD_CORE wxAnimation;
class wxAnimationImpl;
extern WXDLLIMPEXP_DATA_CORE(wxAnimation) wxNullAnimation;
extern WXDLLIMPEXP_DATA_CORE(const char) wxAnimationCtrlNameStr[];
WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_CORE);
// ----------------------------------------------------------------------------
// wxAnimation
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAnimation : public wxObject
{
public:
wxAnimation();
explicit wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
#ifdef wxHAS_MEMBER_DEFAULT
wxAnimation(const wxAnimation&) = default;
wxAnimation& operator=(const wxAnimation&) = default;
#endif
bool IsOk() const;
bool IsCompatibleWith(wxClassInfo* ci) const;
int GetDelay(unsigned int frame) const;
unsigned int GetFrameCount() const;
wxImage GetFrame(unsigned int frame) const;
wxSize GetSize() const;
bool LoadFile(const wxString& name, wxAnimationType type = wxANIMATION_TYPE_ANY);
bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
// Methods for managing the list of decoders
static inline wxAnimationDecoderList& GetHandlers() { return sm_handlers; }
static void AddHandler(wxAnimationDecoder *handler);
static void InsertHandler(wxAnimationDecoder *handler);
static const wxAnimationDecoder *FindHandler( wxAnimationType animType );
static void CleanUpHandlers();
static void InitStandardHandlers();
protected:
wxAnimationImpl* GetImpl() const;
private:
static wxAnimationDecoderList sm_handlers;
// Ctor used by wxAnimationCtrl::CreateAnimation() only.
explicit wxAnimation(wxAnimationImpl* impl);
// Give it permission to create objects of this class using specific impl
// and access our GetImpl().
friend class wxAnimationCtrlBase;
wxDECLARE_DYNAMIC_CLASS(wxAnimation);
};
// ----------------------------------------------------------------------------
// wxAnimationBundle is one or more animations in different resolutions
// ----------------------------------------------------------------------------
using wxAnimations = std::vector<wxAnimation>;
// This class is conceptually similar to wxBitmapBundle but much simpler.
class WXDLLIMPEXP_CORE wxAnimationBundle
{
public:
// Default ctor, call Add() later.
wxAnimationBundle() = default;
// Implicit ctor for backwards compatibility: this allows to pass a single
// wxAnimation to wxAnimationCtrl::SetAnimation(), just as before.
wxAnimationBundle(const wxAnimation& anim)
{
// Allow the animation to be invalid here, also for compatibility.
if ( anim.IsOk() )
m_animations.push_back(anim);
}
// Another implicit ctor for backwards compatibility: this one allows to
// create an animation from the given file.
wxAnimationBundle(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY)
{
wxAnimation anim(filename, type);
if ( anim.IsOk() )
m_animations.push_back(anim);
}
wxAnimationBundle(const wxAnimationBundle&) = default;
wxAnimationBundle& operator=(const wxAnimationBundle&) = default;
~wxAnimationBundle() = default;
// Add an animation in another, bigger, size.
void Add(const wxAnimation& anim);
void Add(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY)
{
Add(wxAnimation(filename, type));
}
// Check if this bundle contains any animations (if it has any, they must
// be valid).
bool IsOk() const { return !m_animations.empty(); }
// Just provide access to all the elements.
const wxAnimations& GetAll() const { return m_animations; }
private:
wxAnimations m_animations;
};
// ----------------------------------------------------------------------------
// wxAnimationCtrlBase
// ----------------------------------------------------------------------------
// do not autoresize to the animation's size when SetAnimation() is called
#define wxAC_NO_AUTORESIZE (0x0010)
// default style does not include wxAC_NO_AUTORESIZE, that is, the control
// auto-resizes by default to fit the new animation when SetAnimation() is called
#define wxAC_DEFAULT_STYLE (wxBORDER_NONE)
class WXDLLIMPEXP_CORE wxAnimationCtrlBase : public wxControl
{
public:
wxAnimationCtrlBase() = default;
// public API
virtual bool LoadFile(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
virtual bool Load(wxInputStream& stream,
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
virtual void SetAnimation(const wxAnimationBundle& animations) = 0;
wxAnimation GetAnimation() const { return m_animation; }
virtual bool Play() = 0;
virtual void Stop() = 0;
virtual bool IsPlaying() const = 0;
virtual void SetInactiveBitmap(const wxBitmapBundle &bmp);
// always return the original bitmap set in this control
wxBitmap GetInactiveBitmap() const
{ return m_bmpStatic.GetBitmapFor(this); }
wxAnimation CreateAnimation() const
{ return MakeAnimFromImpl(DoCreateAnimationImpl()); }
protected:
virtual wxAnimationImpl* DoCreateAnimationImpl() const = 0;
// These methods allow derived classes access to private wxAnimation ctor
// and wxAnimation::GetImpl(), respectively.
static wxAnimation MakeAnimFromImpl(wxAnimationImpl* impl)
{ return wxAnimation(impl); }
wxAnimationImpl* GetAnimImpl() const
{ return m_animation.GetImpl(); }
// All animations that we have.
wxAnimations m_animations;
// The animation being currently used, possibly invalid/empty.
wxAnimation m_animation;
// the inactive bitmap as it was set by the user
wxBitmapBundle m_bmpStatic;
// the inactive bitmap currently shown in the control
// (may differ in the size from m_bmpStatic)
wxBitmap m_bmpStaticReal;
// updates m_bmpStaticReal from m_bmpStatic if needed
virtual void UpdateStaticImage();
// called by SetInactiveBitmap
virtual void DisplayStaticImage() = 0;
};
// ----------------------------------------------------------------------------
// include the platform-specific version of the wxAnimationCtrl class
// ----------------------------------------------------------------------------
#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/animate.h"
#define wxHAS_NATIVE_ANIMATIONCTRL
#else
#include "wx/generic/animate.h"
class WXDLLIMPEXP_ADV wxAnimationCtrl : public wxGenericAnimationCtrl
{
public:
wxAnimationCtrl()
: wxGenericAnimationCtrl()
{}
wxAnimationCtrl(wxWindow *parent,
wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
const wxString& name = wxASCII_STR(wxAnimationCtrlNameStr))
: wxGenericAnimationCtrl(parent, id, anim, pos, size, style, name)
{}
private:
wxDECLARE_DYNAMIC_CLASS(wxAnimationCtrl);
};
#endif // defined(__WXGTK__)
#endif // wxUSE_ANIMATIONCTRL
#endif // _WX_ANIMATE_H_

View File

@@ -0,0 +1,155 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/animdecod.h
// Purpose: wxAnimationDecoder
// Author: Francesco Montorsi
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANIMDECOD_H
#define _WX_ANIMDECOD_H
#include "wx/defs.h"
#if wxUSE_STREAMS
#include "wx/colour.h"
#include "wx/gdicmn.h"
#include "wx/log.h"
#include "wx/stream.h"
class WXDLLIMPEXP_FWD_CORE wxImage;
/*
Differences between a wxAnimationDecoder and a wxImageHandler:
1) wxImageHandlers always load an input stream directly into a given wxImage
object converting from the format-specific data representation to the
wxImage native format (RGB24).
wxAnimationDecoders always load an input stream using some optimized format
to store it which is format-dependent. This allows to store a (possibly big)
animation using a format which is a good compromise between required memory
and time required to blit it on the screen.
2) wxAnimationDecoders contain the animation data in some internal variable.
That's why they derive from wxObjectRefData: they are data which can be shared.
3) wxAnimationDecoders can be used by a wxImageHandler to retrieve a frame
in wxImage format; the viceversa cannot be done.
4) wxAnimationDecoders are decoders only, thus they do not support save features.
5) wxAnimationDecoders are directly used by wxAnimation (generic implementation)
as wxObjectRefData while they need to be 'wrapped' by a wxImageHandler for
wxImage uses.
*/
// --------------------------------------------------------------------------
// Constants
// --------------------------------------------------------------------------
// NB: the values of these enum items are not casual but coincide with the
// GIF disposal codes. Do not change them !!
enum wxAnimationDisposal
{
// No disposal specified. The decoder is not required to take any action.
wxANIM_UNSPECIFIED = -1,
// Do not dispose. The graphic is to be left in place.
wxANIM_DONOTREMOVE = 0,
// Restore to background color. The area used by the graphic must be
// restored to the background color.
wxANIM_TOBACKGROUND = 1,
// Restore to previous. The decoder is required to restore the area
// overwritten by the graphic with what was there prior to rendering the graphic.
wxANIM_TOPREVIOUS = 2
};
enum wxAnimationType
{
wxANIMATION_TYPE_INVALID,
wxANIMATION_TYPE_GIF,
wxANIMATION_TYPE_ANI,
wxANIMATION_TYPE_WEBP,
wxANIMATION_TYPE_ANY
};
// --------------------------------------------------------------------------
// wxAnimationDecoder class
// --------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAnimationDecoder : public wxObjectRefData
{
public:
wxAnimationDecoder()
{
m_nFrames = 0;
}
virtual bool Load( wxInputStream& stream ) = 0;
bool CanRead( wxInputStream& stream ) const
{
return wxInputStreamPeeker(stream).
CallIfCanSeek(&wxAnimationDecoder::DoCanRead, this);
}
wxNODISCARD virtual wxAnimationDecoder *Clone() const = 0;
virtual wxAnimationType GetType() const = 0;
// convert given frame to wxImage
virtual bool ConvertToImage(unsigned int frame, wxImage *image) const = 0;
// frame specific data getters
// not all frames may be of the same size; e.g. GIF allows to
// specify that between two frames only a smaller portion of the
// entire animation has changed.
virtual wxSize GetFrameSize(unsigned int frame) const = 0;
// the position of this frame in case it's not as big as m_szAnimation
// or wxPoint(0,0) otherwise.
virtual wxPoint GetFramePosition(unsigned int frame) const = 0;
// what should be done after displaying this frame.
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const = 0;
// the number of milliseconds this frame should be displayed.
// if returns -1 then the frame must be displayed forever.
virtual long GetDelay(unsigned int frame) const = 0;
// the transparent colour for this frame if any or wxNullColour.
virtual wxColour GetTransparentColour(unsigned int frame) const = 0;
// get global data
wxSize GetAnimationSize() const { return m_szAnimation; }
wxColour GetBackgroundColour() const { return m_background; }
unsigned int GetFrameCount() const { return m_nFrames; }
protected:
// checks the signature of the data in the given stream and returns true if it
// appears to be a valid animation format recognized by the animation decoder;
// this function should modify the stream current position without taking care
// of restoring it since CanRead() will do it.
virtual bool DoCanRead(wxInputStream& stream) const = 0;
wxSize m_szAnimation;
unsigned int m_nFrames;
// this is the colour to use for the wxANIM_TOBACKGROUND disposal.
// if not specified by the animation, it's set to wxNullColour
wxColour m_background;
};
#endif // wxUSE_STREAMS
#endif // _WX_ANIMDECOD_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,195 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/anybutton.h
// Purpose: wxAnyButtonBase class
// Author: Vadim Zeitlin
// Created: 2000-08-15 (extracted from button.h)
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANYBUTTON_H_BASE_
#define _WX_ANYBUTTON_H_BASE_
#include "wx/defs.h"
#ifdef wxHAS_ANY_BUTTON
// ----------------------------------------------------------------------------
// wxAnyButton specific flags
// ----------------------------------------------------------------------------
// These flags affect label alignment
#define wxBU_LEFT 0x0040
#define wxBU_TOP 0x0080
#define wxBU_RIGHT 0x0100
#define wxBU_BOTTOM 0x0200
#define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM )
// These two flags are obsolete and have no effect any longer.
#define wxBU_NOAUTODRAW 0x0000
#define wxBU_AUTODRAW 0x0004
// by default, the buttons will be created with some (system dependent)
// minimal size to make them look nicer, giving this style will make them as
// small as possible
#define wxBU_EXACTFIT 0x0001
// this flag can be used to disable using the text label in the button: it is
// mostly useful when creating buttons showing bitmap and having stock id as
// without it both the standard label corresponding to the stock id and the
// bitmap would be shown
#define wxBU_NOTEXT 0x0002
#include "wx/bmpbndl.h"
#include "wx/control.h"
// ----------------------------------------------------------------------------
// wxAnyButton: common button functionality
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAnyButtonBase : public wxControl
{
public:
wxAnyButtonBase() = default;
// show the image in the button in addition to the label: this method is
// supported on all (major) platforms
void SetBitmap(const wxBitmapBundle& bitmap, wxDirection dir = wxLEFT)
{
SetBitmapLabel(bitmap);
SetBitmapPosition(dir);
}
wxBitmap GetBitmap() const { return DoGetBitmap(State_Normal); }
// Methods for setting individual images for different states: normal,
// selected (meaning pushed or pressed), focused (meaning normal state for
// a focused button), disabled or hover (a.k.a. hot or current).
//
// Remember that SetBitmap() itself must be called before any other
// SetBitmapXXX() methods (except for SetBitmapLabel() which is a synonym
// for it anyhow) and that all bitmaps passed to these functions should be
// of the same size.
void SetBitmapLabel(const wxBitmapBundle& bitmap)
{ DoSetBitmap(bitmap, State_Normal); }
void SetBitmapPressed(const wxBitmapBundle& bitmap)
{ DoSetBitmap(bitmap, State_Pressed); }
void SetBitmapDisabled(const wxBitmapBundle& bitmap)
{ DoSetBitmap(bitmap, State_Disabled); }
void SetBitmapCurrent(const wxBitmapBundle& bitmap)
{ DoSetBitmap(bitmap, State_Current); }
void SetBitmapFocus(const wxBitmapBundle& bitmap)
{ DoSetBitmap(bitmap, State_Focused); }
wxBitmap GetBitmapLabel() const { return DoGetBitmap(State_Normal); }
wxBitmap GetBitmapPressed() const { return DoGetBitmap(State_Pressed); }
wxBitmap GetBitmapDisabled() const { return DoGetBitmap(State_Disabled); }
wxBitmap GetBitmapCurrent() const { return DoGetBitmap(State_Current); }
wxBitmap GetBitmapFocus() const { return DoGetBitmap(State_Focused); }
// set the margins around the image
void SetBitmapMargins(wxCoord x, wxCoord y) { DoSetBitmapMargins(x, y); }
void SetBitmapMargins(const wxSize& sz) { DoSetBitmapMargins(sz.x, sz.y); }
wxSize GetBitmapMargins() { return DoGetBitmapMargins(); }
// set the image position relative to the text, i.e. wxLEFT means that the
// image is to the left of the text (this is the default)
void SetBitmapPosition(wxDirection dir);
// Buttons on MSW can look bad if they are not native colours, because
// then they become owner-drawn and not theme-drawn. Disable it here
// in wxAnyButtonBase to make it consistent.
virtual bool ShouldInheritColours() const override { return false; }
// backwards compatible names for pressed/current bitmaps: they're not
// deprecated as there is nothing really wrong with using them and no real
// advantage to using the new names but the new names are still preferred
// (and need to be used when using wxBitmapBundle and not just wxBitmap)
wxBitmap GetBitmapSelected() const { return GetBitmapPressed(); }
wxBitmap GetBitmapHover() const { return GetBitmapCurrent(); }
void SetBitmapSelected(const wxBitmap& bitmap) { SetBitmapPressed(bitmap); }
void SetBitmapHover(const wxBitmap& bitmap) { SetBitmapCurrent(bitmap); }
// this enum is not part of wx public API, it is public because it is used
// in non wxAnyButton-derived classes internally
//
// also notice that MSW code relies on the values of the enum elements, do
// not change them without revising src/msw/button.cpp
enum State
{
State_Normal,
State_Current, // a.k.a. hot or "hovering"
State_Pressed, // a.k.a. "selected" in public API for some reason
State_Disabled,
State_Focused,
State_Max
};
// return the current setting for the "normal" state of the button, it can
// be different from State_Normal for a wxToggleButton
virtual State GetNormalState() const
{
return State_Normal;
}
// return true if this button shouldn't show the text label, either because
// it doesn't have it or because it was explicitly disabled with wxBU_NOTEXT
bool DontShowLabel() const
{
return HasFlag(wxBU_NOTEXT) || GetLabel().empty();
}
// return true if we do show the label
bool ShowsLabel() const
{
return !DontShowLabel();
}
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
virtual wxBitmap DoGetBitmap(State WXUNUSED(which)) const
{ return wxBitmap(); }
virtual void DoSetBitmap(const wxBitmapBundle& WXUNUSED(bitmap),
State WXUNUSED(which))
{ }
virtual wxSize DoGetBitmapMargins() const
{ return wxSize(0, 0); }
virtual void DoSetBitmapMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
{ }
virtual void DoSetBitmapPosition(wxDirection WXUNUSED(dir))
{ }
virtual bool DoGetAuthNeeded() const { return false; }
virtual void DoSetAuthNeeded(bool WXUNUSED(show)) { }
wxDECLARE_NO_COPY_CLASS(wxAnyButtonBase);
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/anybutton.h"
#elif defined(__WXMSW__)
#include "wx/msw/anybutton.h"
#elif defined(__WXGTK__)
#include "wx/gtk/anybutton.h"
#elif defined(__WXMAC__)
#include "wx/osx/anybutton.h"
#elif defined(__WXQT__)
#include "wx/qt/anybutton.h"
#else
typedef wxAnyButtonBase wxAnyButton;
#endif
#endif // wxHAS_ANY_BUTTON
#endif // _WX_ANYBUTTON_H_BASE_

View File

@@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/anystr.h
// Purpose: wxAnyStrPtr class declaration
// Author: Vadim Zeitlin
// Created: 2009-03-23
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ANYSTR_H_
#define _WX_ANYSTR_H_
#include "wx/string.h"
// ----------------------------------------------------------------------------
// wxAnyStrPtr
//
// Notice that this is an internal and intentionally not documented class. It
// is only used by wxWidgets itself to ensure compatibility with previous
// versions and shouldn't be used by user code. When you see a function
// returning it you should just know that you can treat it as a string pointer.
// ----------------------------------------------------------------------------
// This is a helper class convertible to either narrow or wide string pointer.
// It is similar to wxCStrData but, unlike it, can be null which is required to
// represent the return value of wxDateTime::ParseXXX() methods for example.
//
// NB: this class is fully inline and so doesn't need to be DLL-exported
class wxAnyStrPtr
{
public:
// ctors: this class must be created from the associated string or using
// its default ctor for an invalid nullptr-like object; notice that it is
// immutable after creation.
// ctor for invalid pointer
wxAnyStrPtr()
: m_str(nullptr)
{
}
// ctor for valid pointer into the given string (whose lifetime must be
// greater than ours and which should remain constant while we're used)
wxAnyStrPtr(const wxString& str, const wxString::const_iterator& iter)
: m_str(&str),
m_iter(iter)
{
}
// default copy ctor is ok and so is default dtor, in particular we do not
// free the string
// various operators meant to make this class look like a superposition of
// char* and wchar_t*
// this one is needed to allow boolean expressions involving these objects,
// e.g. "if ( FuncReturningAnyStrPtr() && ... )" (unfortunately using
// unspecified_bool_type here wouldn't help with ambiguity between all the
// different conversions to pointers)
operator bool() const { return m_str != nullptr; }
// at least VC7 also needs this one or it complains about ambiguity
// for !anystr expressions
bool operator!() const { return !((bool)*this); }
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
// and these are the conversions operator which allow to assign the result
// of FuncReturningAnyStrPtr() to either char* or wxChar* (i.e. wchar_t*)
operator const char *() const
{
if ( !m_str )
return nullptr;
// check if the string is convertible to char at all
//
// notice that this pointer points into wxString internal buffer
// containing its char* representation and so it can be kept for as
// long as wxString is not modified -- which is long enough for our
// needs
const char *p = m_str->c_str().AsChar();
if ( *p )
{
// find the offset of the character corresponding to this iterator
// position in bytes: we don't have any direct way to do it so we
// need to redo the conversion again for the part of the string
// before the iterator to find its length in bytes in current
// locale
//
// NB: conversion won't fail as it succeeded for the entire string
p += strlen(wxString(m_str->begin(), m_iter).mb_str());
}
//else: conversion failed, return "" as we can't do anything else
return p;
}
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
operator const wchar_t *() const
{
if ( !m_str )
return nullptr;
// no complications with wide strings (as long as we discount
// surrogates as we do for now)
//
// just remember that this works as long as wxString keeps an internal
// buffer with its wide char representation, just as with AsChar()
// above
return m_str->c_str().AsWChar() + (m_iter - m_str->begin());
}
// Because the objects of this class are only used as return type for
// functions which can return nullptr we can skip providing dereferencing
// operators: the code using this class must test it for null first and if
// it does anything else with it has to assign it to either char* or
// wchar_t* itself, before dereferencing.
//
// IOW this
//
// if ( *FuncReturningAnyStrPtr() )
//
// is invalid because it could crash. And this
//
// const char *p = FuncReturningAnyStrPtr();
// if ( p && *p )
//
// already works fine.
private:
// the original string and the position in it we correspond to, if the
// string is null this object is null pointer-like
const wxString * const m_str;
const wxString::const_iterator m_iter;
wxDECLARE_NO_ASSIGN_DEF_COPY(wxAnyStrPtr);
};
#endif // _WX_ANYSTR_H_

View File

@@ -0,0 +1,984 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/app.h
// Purpose: wxAppBase class and macros used for declaration of wxApp
// derived class in the user code
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APP_H_BASE_
#define _WX_APP_H_BASE_
// ----------------------------------------------------------------------------
// headers we have to include here
// ----------------------------------------------------------------------------
#include "wx/event.h" // for the base class
#include "wx/eventfilter.h" // (and another one)
#include "wx/build.h"
#include "wx/cmdargs.h" // for wxCmdLineArgsArray used by wxApp::argv
#include "wx/init.h" // we must declare wxEntry()
#include "wx/intl.h" // for wxLayoutDirection
#include "wx/log.h" // for wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD()
class WXDLLIMPEXP_FWD_BASE wxAppConsole;
class WXDLLIMPEXP_FWD_BASE wxAppTraits;
class WXDLLIMPEXP_FWD_BASE wxCmdLineParser;
class WXDLLIMPEXP_FWD_BASE wxEventLoopBase;
class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
#if wxUSE_GUI
struct WXDLLIMPEXP_FWD_CORE wxVideoMode;
class WXDLLIMPEXP_FWD_CORE wxWindow;
#endif
// this macro should be used in any main() or equivalent functions defined in wx
#define wxDISABLE_DEBUG_SUPPORT() \
wxDISABLE_ASSERTS_IN_RELEASE_BUILD(); \
wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD()
// ----------------------------------------------------------------------------
// typedefs
// ----------------------------------------------------------------------------
// the type of the function used to create a wxApp object on program start up
typedef wxAppConsole* (*wxAppInitializerFunction)();
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
enum
{
wxPRINT_WINDOWS = 1,
wxPRINT_POSTSCRIPT = 2
};
// ----------------------------------------------------------------------------
// global variables
// ----------------------------------------------------------------------------
// use of this list is strongly deprecated, use wxApp ScheduleForDestruction()
// and IsScheduledForDestruction() methods instead of this list directly, it
// is here for compatibility purposes only
extern WXDLLIMPEXP_DATA_BASE(wxList) wxPendingDelete;
// ----------------------------------------------------------------------------
// wxAppConsoleBase: wxApp for non-GUI applications
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxAppConsoleBase : public wxEvtHandler,
public wxEventFilter
{
public:
// ctor and dtor
wxAppConsoleBase();
virtual ~wxAppConsoleBase();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// This is the very first function called for a newly created wxApp object,
// it is used by the library to do the global initialization. If, for some
// reason, you must override it (instead of just overriding OnInit(), as
// usual, for app-specific initializations), do not forget to call the base
// class version!
virtual bool Initialize(int& argc, wxChar **argv);
// This gives wxCocoa a chance to call OnInit() with a memory pool in place
virtual bool CallOnInit() { return OnInit(); }
// Called before OnRun(), this is a good place to do initialization -- if
// anything fails, return false from here to prevent the program from
// continuing. The command line is normally parsed here, call the base
// class OnInit() to do it.
virtual bool OnInit();
// This is the replacement for the normal main(): all program work should
// be done here. When OnRun() returns, the programs starts shutting down.
virtual int OnRun();
// Called before the first events are handled, called from within MainLoop()
virtual void OnLaunched();
// This is called by wxEventLoopBase::SetActive(): you should put the code
// which needs an active event loop here.
// Note that this function is called whenever an event loop is activated;
// you may want to use wxEventLoopBase::IsMain() to perform initialization
// specific for the app's main event loop.
virtual void OnEventLoopEnter(wxEventLoopBase* WXUNUSED(loop)) {}
// This is only called if OnInit() returned true so it's a good place to do
// any cleanup matching the initializations done there.
virtual int OnExit();
// This is called by wxEventLoopBase::OnExit() for each event loop which
// is exited.
virtual void OnEventLoopExit(wxEventLoopBase* WXUNUSED(loop)) {}
// This is the very last function called on wxApp object before it is
// destroyed. If you override it (instead of overriding OnExit() as usual)
// do not forget to call the base class version!
virtual void CleanUp();
// Called when a fatal exception occurs, this function should take care not
// to do anything which might provoke a nested exception! It may be
// overridden if you wish to react somehow in non-default way (core dump
// under Unix, application crash under Windows) to fatal program errors,
// however extreme care should be taken if you don't want this function to
// crash.
virtual void OnFatalException() { }
// Called from wxExit() function, should terminate the application a.s.a.p.
virtual void Exit();
// Allows to set a custom process exit code if a fatal error happens.
// This code is 255 by default, but can be changed if necessary, notably
// set to -1 (which still maps to 255 under most systems, but to 127 when
// using MSVC) if compatibility with the previous wx versions is important.
static void SetFatalErrorExitCode(int code) { ms_fatalErrorExitCode = code; }
static int GetFatalErrorExitCode() { return ms_fatalErrorExitCode; }
// Allows to set a custom process exit code if OnInit() returns false.
// By default, this exit code is 255, as for the fatal errors.
virtual void SetErrorExitCode(int code) { m_exitCode = code; }
int GetErrorExitCode() const { return m_exitCode; }
// application info: name, description, vendor
// -------------------------------------------
// NB: all these should be set by the application itself, there are no
// reasonable default except for the application name which is taken to
// be argv[0]
// set/get the application name
wxString GetAppName() const;
void SetAppName(const wxString& name) { m_appName = name; }
// set/get the application display name: the display name is the name
// shown to the user in titles, reports, etc while the app name is
// used for paths, config, and other places the user doesn't see
//
// by default the display name is the same as app name or a capitalized
// version of the program if app name was not set either but it's
// usually better to set it explicitly to something nicer
wxString GetAppDisplayName() const;
void SetAppDisplayName(const wxString& name) { m_appDisplayName = name; }
// set/get the app class name
wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; }
// set/get the vendor name
const wxString& GetVendorName() const { return m_vendorName; }
void SetVendorName(const wxString& name) { m_vendorName = name; }
// set/get the vendor display name: the display name is shown
// in titles/reports/dialogs to the user, while the vendor name
// is used in some areas such as wxConfig, wxStandardPaths, etc
const wxString& GetVendorDisplayName() const
{
return m_vendorDisplayName.empty() ? GetVendorName()
: m_vendorDisplayName;
}
void SetVendorDisplayName(const wxString& name)
{
m_vendorDisplayName = name;
}
// cmd line parsing stuff
// ----------------------
// all of these methods may be overridden in the derived class to
// customize the command line parsing (by default only a few standard
// options are handled)
//
// you also need to call wxApp::OnInit() from YourApp::OnInit() for all
// this to work
#if wxUSE_CMDLINE_PARSER
// this one is called from OnInit() to add all supported options
// to the given parser (don't forget to call the base class version if you
// override it!)
virtual void OnInitCmdLine(wxCmdLineParser& parser);
// called after successfully parsing the command line, return true
// to continue and false to exit (don't forget to call the base class
// version if you override it!)
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
// called if "--help" option was specified, return true to continue
// and false to exit
virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
// called if incorrect command line options were given, return
// false to abort and true to continue
virtual bool OnCmdLineError(wxCmdLineParser& parser);
#endif // wxUSE_CMDLINE_PARSER
// miscellaneous customization functions
// -------------------------------------
// create the app traits object to which we delegate for everything which
// either should be configurable by the user (then he can change the
// default behaviour simply by overriding CreateTraits() and returning his
// own traits object) or which is GUI/console dependent as then wxAppTraits
// allows us to abstract the differences behind the common facade
wxAppTraits *GetTraits();
// this function provides safer access to traits object than
// wxTheApp->GetTraits() during startup or termination when the global
// application object itself may be unavailable
//
// of course, it still returns nullptr in this case and the caller must check
// for it
static wxAppTraits *GetTraitsIfExists();
// Return some valid traits object.
//
// This method checks if we have wxTheApp and returns its traits if it does
// exist and the traits are non-null, similarly to GetTraitsIfExists(), but
// falls back to wxConsoleAppTraits to ensure that it always returns
// something valid.
static wxAppTraits& GetValidTraits();
// returns the main event loop instance, i.e. the event loop which is started
// by OnRun() and which dispatches all events sent from the native toolkit
// to the application (except when new event loops are temporarily set-up).
// The returned value maybe null. Put initialization code which needs a
// non-null main event loop into OnEventLoopEnter().
wxEventLoopBase* GetMainLoop() const
{ return m_mainLoop; }
// This function sets the C locale to the default locale for the current
// environment. It is advised to call this to ensure that the underlying
// toolkit uses the locale in which the numbers and monetary amounts are
// shown in the format expected by user and so on.
//
// Notice that this does _not_ change the global C++ locale, you need to do
// it explicitly if you want.
//
// Finally, notice that while this function is virtual, it is not supposed
// to be overridden outside of the library itself.
virtual void SetCLocale();
// event processing functions
// --------------------------
// Implement the inherited wxEventFilter method but just return -1 from it
// to indicate that default processing should take place.
virtual int FilterEvent(wxEvent& event) override;
// return true if we're running event loop, i.e. if the events can
// (already) be dispatched
static bool IsMainLoopRunning();
#if wxUSE_EXCEPTIONS
// execute the functor to handle the given event
//
// this is a generalization of HandleEvent() below and the base class
// implementation of CallEventHandler() still calls HandleEvent() for
// compatibility for functors which are just wxEventFunctions (i.e. methods
// of wxEvtHandler)
virtual void CallEventHandler(wxEvtHandler *handler,
wxEventFunctor& functor,
wxEvent& event) const;
// call the specified handler on the given object with the given event
//
// this method only exists to allow catching the exceptions thrown by any
// event handler, it would lead to an extra (useless) virtual function call
// if the exceptions were not used, so it doesn't even exist in that case
virtual void HandleEvent(wxEvtHandler *handler,
wxEventFunction func,
wxEvent& event) const;
// Called when an unhandled C++ exception occurs inside OnRun(): note that
// the main event loop has already terminated by now and the program will
// exit, if you need to really handle the exceptions you need to override
// OnExceptionInMainLoop()
virtual void OnUnhandledException();
// Call OnUnhandledException() on the current wxTheApp object if it exists.
static void CallOnUnhandledException();
// Function called if an uncaught exception is caught inside the main
// event loop: it may return true to continue running the event loop or
// false to stop it. If this function rethrows the exception, as it does by
// default, simply because there is no general way to handle exceptions,
// StoreCurrentException() will be called to store it because in any case
// the exception can't be allowed to escape.
virtual bool OnExceptionInMainLoop();
// This function can be overridden to store the current exception, in view
// of rethrowing it later when RethrowStoredException() is called. If the
// exception was stored, return true. If the exception can't be stored,
// i.e. if this function returns false, the program will abort after
// calling OnUnhandledException().
//
// The default implementation of this function when using C++98 compiler
// just returns false, as there is no generic way to store an arbitrary
// exception in C++98 and each application must do it on its own for the
// exceptions it uses in its overridden version. When using C++11, the
// default implementation uses std::current_exception() and returns true,
// so it's normally not necessary to override this method when using C++11.
virtual bool StoreCurrentException();
// If StoreCurrentException() is overridden, this function should be
// overridden as well to rethrow the exceptions stored by it when the
// control gets back to our code, i.e. when it's safe to do it.
//
// The default version does nothing when using C++98 and uses
// std::rethrow_exception() in C++11.
virtual void RethrowStoredException();
#else // !wxUSE_EXCEPTIONS
// For convenience, still define this to allow the code using it to avoid
// checking for wxUSE_EXCEPTIONS.
static void CallOnUnhandledException() { }
#endif // wxUSE_EXCEPTIONS/!wxUSE_EXCEPTIONS
// pending events
// --------------
// IMPORTANT: all these methods conceptually belong to wxEventLoopBase
// but for many reasons we need to allow queuing of events
// even when there's no event loop (e.g. in wxApp::OnInit);
// this feature is used e.g. to queue events on secondary threads
// or in wxPython to use wx.CallAfter before the GUI is initialized
// process all events in the m_handlersWithPendingEvents list -- it is necessary
// to call this function to process posted events. This happens during each
// event loop iteration in GUI mode but if there is no main loop, it may be
// also called directly.
virtual void ProcessPendingEvents();
// check if there are pending events on global pending event list
bool HasPendingEvents() const;
// temporary suspends processing of the pending events
void SuspendProcessingOfPendingEvents();
// resume processing of the pending events previously stopped because of a
// call to SuspendProcessingOfPendingEvents()
void ResumeProcessingOfPendingEvents();
// called by ~wxEvtHandler to (eventually) remove the handler from the list of
// the handlers with pending events
void RemovePendingEventHandler(wxEvtHandler* toRemove);
// adds an event handler to the list of the handlers with pending events
void AppendPendingEventHandler(wxEvtHandler* toAppend);
// moves the event handler from the list of the handlers with pending events
//to the list of the handlers with _delayed_ pending events
void DelayPendingEventHandler(wxEvtHandler* toDelay);
// deletes the current pending events
void DeletePendingEvents();
// delayed destruction
// -------------------
// If an object may have pending events for it, it shouldn't be deleted
// immediately as this would result in a crash when trying to handle these
// events: instead, it should be scheduled for destruction and really
// destroyed only after processing all pending events.
//
// Notice that this is only possible if we have a running event loop,
// otherwise the object is just deleted directly by ScheduleForDestruction()
// and IsScheduledForDestruction() always returns false.
// schedule the object for destruction in the near future
void ScheduleForDestruction(wxObject *object);
// return true if the object is scheduled for destruction
bool IsScheduledForDestruction(wxObject *object) const;
// wxEventLoop-related methods
// ---------------------------
// all these functions are forwarded to the corresponding methods of the
// currently active event loop -- and do nothing if there is none
virtual bool Pending();
virtual bool Dispatch();
virtual int MainLoop();
virtual void ExitMainLoop();
bool Yield(bool onlyIfNeeded = false);
virtual void WakeUpIdle();
// this method is called by the active event loop when there are no events
// to process
//
// by default it generates the idle events and if you override it in your
// derived class you should call the base class version to ensure that idle
// events are still sent out
virtual bool ProcessIdle();
// this virtual function is overridden in GUI wxApp to always return true
// as GUI applications always have an event loop -- but console ones may
// have it or not, so it simply returns true if already have an event loop
// running but false otherwise
virtual bool UsesEventLoop() const;
// debugging support
// -----------------
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
//
// the arguments are the location of the failed assert, the text of the
// assert itself and the user-specified message
virtual void OnAssertFailure(const wxChar *file,
int line,
const wxChar *func,
const wxChar *cond,
const wxChar *msg);
// old version of the function without func parameter, for compatibility
// only, override OnAssertFailure() in the new code
virtual void OnAssert(const wxChar *file,
int line,
const wxChar *cond,
const wxChar *msg);
// check that the wxBuildOptions object (constructed in the application
// itself, usually the one from wxIMPLEMENT_APP() macro) matches the build
// options of the library and abort if it doesn't
static bool CheckBuildOptions(const char *optionsSignature,
const char *componentName);
// implementation only from now on
// -------------------------------
// helpers for dynamic wxApp construction
static void SetInitializerFunction(wxAppInitializerFunction fn)
{ ms_appInitFn = fn; }
static wxAppInitializerFunction GetInitializerFunction()
{ return ms_appInitFn; }
// accessors for ms_appInstance field (external code might wish to modify
// it, this is why we provide a setter here as well, but you should really
// know what you're doing if you call it), wxTheApp is usually used instead
// of GetInstance()
static wxAppConsole *GetInstance() { return ms_appInstance; }
static void SetInstance(wxAppConsole *app) { ms_appInstance = app; }
// returns true for GUI wxApp subclasses
virtual bool IsGUI() const { return false; }
// command line arguments (public for backwards compatibility)
int argc;
// this object is implicitly convertible to either "char**" (traditional
// type of argv parameter of main()) or to "wchar_t **" (for compatibility
// with Unicode build in previous wx versions and because the command line
// can, in pr
wxCmdLineArgsArray argv;
protected:
// This function must be called at the end of wxApp ctor to indicate that
// wx part of the object is fully constructed.
void WXAppConstructed();
// delete all objects in wxPendingDelete list
//
// called from ProcessPendingEvents()
void DeletePendingObjects();
// the function which creates the traits object when GetTraits() needs it
// for the first time
virtual wxAppTraits *CreateTraits();
// function used for dynamic wxApp creation
static wxAppInitializerFunction ms_appInitFn;
// the one and only global application object
static wxAppConsole *ms_appInstance;
// create main loop from AppTraits or return nullptr if
// there is no main loop implementation
wxEventLoopBase *CreateMainLoop();
// application info (must be set from the user code)
wxString m_vendorName, // vendor name ("acme")
m_vendorDisplayName, // vendor display name (e.g. "ACME Inc")
m_appName, // app name ("myapp")
m_appDisplayName, // app display name ("My Application")
m_className; // class name
// allows customizing the application behaviour, created by GetTraits()
// when first needed
wxAppTraits *m_traits = nullptr;
// the main event loop of the application (may be null if the loop hasn't
// been started yet or has already terminated)
wxEventLoopBase *m_mainLoop = nullptr;
// pending events management vars:
// the array of the handlers with pending events which needs to be processed
// inside ProcessPendingEvents()
wxEvtHandlerArray m_handlersWithPendingEvents;
// helper array used by ProcessPendingEvents() to store the event handlers
// which have pending events but of these events none can be processed right now
// (because of a call to wxEventLoop::YieldFor() which asked to selectively process
// pending events)
wxEvtHandlerArray m_handlersWithPendingDelayedEvents;
#if wxUSE_THREADS
// this critical section protects both the lists above
wxCriticalSection m_handlersWithPendingEventsLocker;
#endif
// flag modified by Suspend/ResumeProcessingOfPendingEvents()
bool m_bDoPendingEventProcessing = true;
private:
// flag set to true at the end of wxApp ctor, call WXAppConstructed() to
// set it
bool m_fullyConstructed = false;
// Exit code to use if a fatal error occurs when the application object
// doesn't exist yet or is already destroyed.
static int ms_fatalErrorExitCode;
// Exit code to use if OnInit() returns false.
int m_exitCode = ms_fatalErrorExitCode;
friend class WXDLLIMPEXP_FWD_BASE wxEvtHandler;
// the application object is a singleton anyhow, there is no sense in
// copying it
wxDECLARE_NO_COPY_CLASS(wxAppConsoleBase);
};
#if defined(__UNIX__) && !defined(__WINDOWS__)
#include "wx/unix/app.h"
#else
// this has to be a class and not a typedef as we forward declare it
class wxAppConsole : public wxAppConsoleBase { };
#endif
// ----------------------------------------------------------------------------
// wxAppBase: the common part of wxApp implementations for all platforms
// ----------------------------------------------------------------------------
#if wxUSE_GUI
class WXDLLIMPEXP_CORE wxAppBase : public wxAppConsole
{
public:
wxAppBase();
virtual ~wxAppBase();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// very first initialization function
//
// Override: very rarely
virtual bool Initialize(int& argc, wxChar **argv) override;
// a platform-dependent version of OnInit(): the code here is likely to
// depend on the toolkit. default version does nothing.
//
// Override: rarely.
virtual bool OnInitGui();
// called to start program execution - the default version just enters
// the main GUI loop in which events are received and processed until
// the last window is not deleted (if GetExitOnFrameDelete) or
// ExitMainLoop() is called. In console mode programs, the execution
// of the program really starts here
//
// Override: rarely in GUI applications, always in console ones.
virtual int OnRun() override;
// a matching function for OnInit()
virtual int OnExit() override;
// very last clean up function
//
// Override: very rarely
virtual void CleanUp() override;
// the worker functions - usually not used directly by the user code
// -----------------------------------------------------------------
// safer alternatives to Yield(), using wxWindowDisabler
virtual bool SafeYield(wxWindow *win, bool onlyIfNeeded);
virtual bool SafeYieldFor(wxWindow *win, long eventsToProcess);
// this virtual function is called in the GUI mode when the application
// becomes idle and normally just sends wxIdleEvent to all interested
// parties
//
// it should return true if more idle events are needed, false if not
virtual bool ProcessIdle() override;
// override base class version: GUI apps always use an event loop
virtual bool UsesEventLoop() const override { return true; }
// top level window functions
// --------------------------
// return true if our app has focus
virtual bool IsActive() const { return m_isActive; }
// set the "main" top level window
void SetTopWindow(wxWindow *win) { m_topWindow = win; }
// return the "main" top level window (if it hadn't been set previously
// with SetTopWindow(), will return just some top level window and, if
// there are none, will return nullptr)
virtual wxWindow *GetTopWindow() const;
// convenient helper which is safe to use even if there is no wxApp at
// all, it will just return nullptr in this case
static wxWindow *GetMainTopWindow();
// control the exit behaviour: by default, the program will exit the
// main loop (and so, usually, terminate) when the last top-level
// program window is deleted. Beware that if you disable this behaviour
// (with SetExitOnFrameDelete(false)), you'll have to call
// ExitMainLoop() explicitly from somewhere.
void SetExitOnFrameDelete(bool flag)
{ m_exitOnFrameDelete = flag ? Yes : No; }
bool GetExitOnFrameDelete() const
{ return m_exitOnFrameDelete == Yes; }
// display mode, visual, printing mode, ...
// ------------------------------------------------------------------------
// Get display mode that is used use. This is only used in framebuffer
// wxWin ports such as wxDFB.
virtual wxVideoMode GetDisplayMode() const;
// Set display mode to use. This is only used in framebuffer wxWin
// ports such as wxDFB. This method should be called from
// wxApp::OnInitGui
virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; }
// set use of best visual flag (see below)
void SetUseBestVisual( bool flag, bool forceTrueColour = false )
{ m_useBestVisual = flag; m_forceTrueColour = forceTrueColour; }
bool GetUseBestVisual() const { return m_useBestVisual; }
// set/get printing mode: see wxPRINT_XXX constants.
//
// default behaviour is the normal one for Unix: always use PostScript
// printing.
virtual void SetPrintMode(int WXUNUSED(mode)) { }
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
// Return the layout direction for the current locale or wxLayout_Default
// if it's unknown
virtual wxLayoutDirection GetLayoutDirection() const;
// Change the theme used by the application, return true on success.
virtual bool SetNativeTheme(const wxString& WXUNUSED(theme)) { return false; }
// Request using system appearance (which is automatic for most platforms
// but not MSW) or explicitly request dark or light appearance for this
// application.
enum class Appearance
{
System,
Light,
Dark
};
enum class AppearanceResult
{
Failure,
Ok,
CannotChange
};
virtual AppearanceResult SetAppearance(Appearance WXUNUSED(appearance))
{ return AppearanceResult::Failure; }
// command line parsing (GUI-specific)
// ------------------------------------------------------------------------
#if wxUSE_CMDLINE_PARSER
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) override;
virtual void OnInitCmdLine(wxCmdLineParser& parser) override;
#endif
// miscellaneous other stuff
// ------------------------------------------------------------------------
// called by toolkit-specific code to set the app status: active (we have
// focus) or not and also the last window which had focus before we were
// deactivated
virtual void SetActive(bool isActive, wxWindow *lastFocus);
virtual bool IsGUI() const override { return true; }
// returns non-null pointer only if we have a GUI application object: this
// is only useful in the rare cases when the same code can be used in both
// console and GUI applications, but needs to use GUI-specific functions if
// the GUI is available
static wxAppBase *GetGUIInstance()
{
return ms_appInstance && ms_appInstance->IsGUI()
? static_cast<wxAppBase*>(ms_appInstance)
: nullptr;
}
protected:
// override base class method to use GUI traits
virtual wxAppTraits *CreateTraits() override;
// Helper method deleting all existing top level windows: this is used
// during the application shutdown.
void DeleteAllTLWs();
// the main top level window (may be null)
wxWindow *m_topWindow;
// if Yes, exit the main loop when the last top level window is deleted, if
// No don't do it and if Later -- only do it once we reach our OnRun()
//
// the explanation for using this strange scheme is given in appcmn.cpp
enum
{
Later = -1,
No,
Yes
} m_exitOnFrameDelete;
// true if the app wants to use the best visual on systems where
// more than one are available (Sun, SGI, XFree86 4.0 ?)
bool m_useBestVisual;
// force TrueColour just in case "best" isn't TrueColour
bool m_forceTrueColour;
// does any of our windows have focus?
bool m_isActive;
wxDECLARE_NO_COPY_CLASS(wxAppBase);
};
// ----------------------------------------------------------------------------
// now include the declaration of the real class
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/app.h"
#elif defined(__WXDFB__)
#include "wx/dfb/app.h"
#elif defined(__WXGTK__)
#include "wx/gtk/app.h"
#elif defined(__WXX11__)
#include "wx/x11/app.h"
#elif defined(__WXMAC__)
#include "wx/osx/app.h"
#elif defined(__WXQT__)
#include "wx/qt/app.h"
#endif
#else // !GUI
// wxApp is defined in core and we cannot define another one in wxBase,
// so use the preprocessor to allow using wxApp in console programs too
#define wxApp wxAppConsole
#endif // GUI/!GUI
// ----------------------------------------------------------------------------
// the global data
// ----------------------------------------------------------------------------
// for compatibility, we define this macro to access the global application
// object of type wxApp
//
// note that instead of using of wxTheApp in application code you should
// consider using wxDECLARE_APP() after which you may call wxGetApp() which will
// return the object of the correct type (i.e. MyApp and not wxApp)
//
// the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in
// console mode it does nothing at all (but see also wxApp::GetGUIInstance())
#define wxTheApp static_cast<wxApp*>(wxApp::GetInstance())
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
// event loop related functions only work in GUI programs
// ------------------------------------------------------
// Force an exit from main loop
WXDLLIMPEXP_BASE void wxExit();
// avoid redeclaring this function here if it had been already declared by
// wx/utils.h, this results in warnings from g++ with -Wredundant-decls
#ifndef wx_YIELD_DECLARED
#define wx_YIELD_DECLARED
// Yield to other apps/messages
WXDLLIMPEXP_CORE bool wxYield();
#endif // wx_YIELD_DECLARED
// Yield to other apps/messages
WXDLLIMPEXP_BASE void wxWakeUpIdle();
// ----------------------------------------------------------------------------
// macros for dynamic creation of the application object
// ----------------------------------------------------------------------------
// Having a global instance of this class allows wxApp to be aware of the app
// creator function. wxApp can then call this function to create a new app
// object. Convoluted, but necessary.
class WXDLLIMPEXP_BASE wxAppInitializer
{
public:
wxAppInitializer(wxAppInitializerFunction fn)
{ wxApp::SetInitializerFunction(fn); }
};
// the code below defines a wxIMPLEMENT_WXWIN_MAIN macro which you can use if
// your compiler really, really wants main() to be in your main program (e.g.
// hello.cpp). Now wxIMPLEMENT_APP should add this code if required.
// For compilers that support it, prefer to use wmain() and let the CRT parse
// the command line for us, for the others parse it ourselves under Windows to
// ensure that wxWidgets console applications accept arbitrary Unicode strings
// as command line parameters and not just those representable in the current
// locale (under Unix UTF-8, capable of representing any Unicode string, is
// almost always used and there is no way to retrieve the Unicode command line
// anyhow).
#if defined(__WINDOWS__)
#ifdef __VISUALC__
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
int wmain(int argc, wchar_t **argv) \
{ \
wxDISABLE_DEBUG_SUPPORT(); \
\
return wxEntry(argc, argv); \
}
#else // No wmain(), use main() but don't trust its arguments.
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
int main(int, char **) \
{ \
wxDISABLE_DEBUG_SUPPORT(); \
\
return wxEntry(); \
}
#endif
#else // Use standard main()
#define wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
int main(int argc, char **argv) \
{ \
wxDISABLE_DEBUG_SUPPORT(); \
\
return wxEntry(argc, argv); \
}
#endif
// port-specific header could have defined it already in some special way
#ifndef wxIMPLEMENT_WXWIN_MAIN
#define wxIMPLEMENT_WXWIN_MAIN wxIMPLEMENT_WXWIN_MAIN_CONSOLE
#endif // defined(wxIMPLEMENT_WXWIN_MAIN)
#if defined(__WXUNIVERSAL__) && wxUSE_GUI
#include "wx/univ/theme.h"
#ifdef wxUNIV_DEFAULT_THEME
#define wxIMPLEMENT_WX_THEME_SUPPORT \
WX_USE_THEME(wxUNIV_DEFAULT_THEME);
#else
#define wxIMPLEMENT_WX_THEME_SUPPORT
#endif
#else
#define wxIMPLEMENT_WX_THEME_SUPPORT
#endif
// Use this macro if you want to define your own main() or WinMain() function
// and call wxEntry() from there.
#define wxIMPLEMENT_APP_NO_MAIN(appname) \
appname& wxGetApp() { return *static_cast<appname*>(wxApp::GetInstance()); } \
wxAppConsole *wxCreateApp() \
{ \
wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
"your program"); \
return new appname; \
} \
wxAppInitializer \
wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp)
// Same as wxIMPLEMENT_APP() normally but doesn't include themes support in
// wxUniversal builds
#define wxIMPLEMENT_APP_NO_THEMES(appname) \
wxIMPLEMENT_WXWIN_MAIN \
wxIMPLEMENT_APP_NO_MAIN(appname)
// Use this macro exactly once, the argument is the name of the wxApp-derived
// class which is the class of your application.
#define wxIMPLEMENT_APP(appname) \
wxIMPLEMENT_WX_THEME_SUPPORT \
wxIMPLEMENT_APP_NO_THEMES(appname)
// Same as wxIMPLEMENT_APP(), but for console applications.
#define wxIMPLEMENT_APP_CONSOLE(appname) \
wxIMPLEMENT_WXWIN_MAIN_CONSOLE \
wxIMPLEMENT_APP_NO_MAIN(appname)
// this macro can be used multiple times and just allows you to use wxGetApp()
// function
#define wxDECLARE_APP(appname) \
extern appname& wxGetApp()
// declare the stuff defined by wxIMPLEMENT_APP() macro, it's not really needed
// anywhere else but at the very least it suppresses icc warnings about
// defining extern symbols without prior declaration, and it shouldn't do any
// harm
extern wxAppConsole *wxCreateApp();
extern wxAppInitializer wxTheAppInitializer;
// ----------------------------------------------------------------------------
// Compatibility macro aliases
// ----------------------------------------------------------------------------
// deprecated variants _not_ requiring a semicolon after them
// (note that also some wx-prefixed macro do _not_ require a semicolon because
// it's not always possible to force the compiler to require it)
#define IMPLEMENT_WXWIN_MAIN_CONSOLE wxIMPLEMENT_WXWIN_MAIN_CONSOLE
#define IMPLEMENT_WXWIN_MAIN wxIMPLEMENT_WXWIN_MAIN
#define IMPLEMENT_WX_THEME_SUPPORT wxIMPLEMENT_WX_THEME_SUPPORT
#define IMPLEMENT_APP_NO_MAIN(app) wxIMPLEMENT_APP_NO_MAIN(app);
#define IMPLEMENT_APP_NO_THEMES(app) wxIMPLEMENT_APP_NO_THEMES(app);
#define IMPLEMENT_APP(app) wxIMPLEMENT_APP(app);
#define IMPLEMENT_APP_CONSOLE(app) wxIMPLEMENT_APP_CONSOLE(app);
#define DECLARE_APP(app) wxDECLARE_APP(app);
#endif // _WX_APP_H_BASE_

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/appprogress.h
// Purpose: wxAppProgressIndicator interface.
// Author: Chaobin Zhang <zhchbin@gmail.com>
// Created: 2014-09-05
// Copyright: (c) 2014 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APPPROG_H_
#define _WX_APPPROG_H_
#include "wx/defs.h"
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_CORE wxAppProgressIndicatorBase
{
public:
wxAppProgressIndicatorBase() = default;
virtual ~wxAppProgressIndicatorBase() = default;
virtual bool IsAvailable() const = 0;
virtual void SetValue(int value) = 0;
virtual void SetRange(int range) = 0;
virtual void Pulse() = 0;
virtual void Reset() = 0;
private:
wxDECLARE_NO_COPY_CLASS(wxAppProgressIndicatorBase);
};
#if defined(__WXMSW__) && wxUSE_TASKBARBUTTON
#include "wx/msw/appprogress.h"
#elif defined(__WXOSX_COCOA__)
#include "wx/osx/appprogress.h"
#else
class wxAppProgressIndicator : public wxAppProgressIndicatorBase
{
public:
wxAppProgressIndicator(wxWindow* WXUNUSED(parent) = nullptr,
int WXUNUSED(maxValue) = 100)
{
}
virtual bool IsAvailable() const override { return false; }
virtual void SetValue(int WXUNUSED(value)) override { }
virtual void SetRange(int WXUNUSED(range)) override { }
virtual void Pulse() override { }
virtual void Reset() override { }
};
#endif
#endif // _WX_APPPROG_H_

View File

@@ -0,0 +1,312 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/apptrait.h
// Purpose: declaration of wxAppTraits and derived classes
// Author: Vadim Zeitlin
// Created: 19.06.2003
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APPTRAIT_H_
#define _WX_APPTRAIT_H_
#include "wx/string.h"
#include "wx/platinfo.h"
class WXDLLIMPEXP_FWD_BASE wxArrayString;
class WXDLLIMPEXP_FWD_BASE wxConfigBase;
class WXDLLIMPEXP_FWD_BASE wxEventLoopBase;
#if wxUSE_FONTMAP
class WXDLLIMPEXP_FWD_CORE wxFontMapper;
#endif // wxUSE_FONTMAP
class WXDLLIMPEXP_FWD_BASE wxLog;
class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
class WXDLLIMPEXP_FWD_BASE wxObject;
class WXDLLIMPEXP_FWD_CORE wxRendererNative;
class WXDLLIMPEXP_FWD_BASE wxStandardPaths;
class WXDLLIMPEXP_FWD_BASE wxString;
class WXDLLIMPEXP_FWD_BASE wxTimer;
class WXDLLIMPEXP_FWD_BASE wxTimerImpl;
class wxSocketManager;
// ----------------------------------------------------------------------------
// wxAppTraits: this class defines various configurable aspects of wxApp
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxAppTraitsBase
{
public:
// needed since this class declares virtual members
virtual ~wxAppTraitsBase() = default;
// hooks for working with the global objects, may be overridden by the user
// ------------------------------------------------------------------------
#if wxUSE_CONFIG
// create the default configuration object (base class version is
// implemented in config.cpp and creates wxRegConfig for wxMSW and
// wxFileConfig for all the other platforms)
virtual wxConfigBase *CreateConfig();
#endif // wxUSE_CONFIG
#if wxUSE_LOG
// create the default log target
virtual wxLog *CreateLogTarget() = 0;
#endif // wxUSE_LOG
// create the global object used for printing out messages
virtual wxMessageOutput *CreateMessageOutput() = 0;
#if wxUSE_FONTMAP
// create the global font mapper object used for encodings/charset mapping
virtual wxFontMapper *CreateFontMapper() = 0;
#endif // wxUSE_FONTMAP
// get the renderer to use for drawing the generic controls (return value
// may be null in which case the default renderer for the current platform
// is used); this is used in GUI only and always returns nullptr in console
//
// NB: returned pointer will be deleted by the caller
virtual wxRendererNative *CreateRenderer() = 0;
// wxStandardPaths object is normally the same for wxBase and wxGUI
virtual wxStandardPaths& GetStandardPaths();
// functions abstracting differences between GUI and console modes
// ------------------------------------------------------------------------
// show the assert dialog with the specified message in GUI or just print
// the string to stderr in console mode
//
// base class version has an implementation (in spite of being pure
// virtual) in base/appbase.cpp which can be called as last resort.
//
// return true to suppress subsequent asserts, false to continue as before
virtual bool ShowAssertDialog(const wxString& msg) = 0;
// show the message safely to the user, i.e. show it in a message box if
// possible (even in a console application!) or return false if we can't do
// it (e.g. GUI is not initialized at all)
//
// note that this function can be called even when wxApp doesn't exist, as
// it's supposed to be always safe to call -- hence the name
//
// return true if the message box was shown, false if nothing was done
virtual bool SafeMessageBox(const wxString& text, const wxString& title) = 0;
// return true if fprintf(stderr) goes somewhere, false otherwise
virtual bool HasStderr() = 0;
#if wxUSE_SOCKETS
// this function is used by wxNet library to set the default socket manager
// to use: doing it like this allows us to keep all socket-related code in
// wxNet instead of having to pull it in wxBase itself as we'd have to do
// if we really implemented wxSocketManager here
//
// we don't take ownership of this pointer, it should have a lifetime
// greater than that of any socket (e.g. be a pointer to a static object)
static void SetDefaultSocketManager(wxSocketManager *manager)
{
ms_manager = manager;
}
// return socket manager: this is usually different for console and GUI
// applications (although some ports use the same implementation for both)
virtual wxSocketManager *GetSocketManager() { return ms_manager; }
#endif
// create a new, port specific, instance of the event loop used by wxApp
virtual wxEventLoopBase *CreateEventLoop() = 0;
#if wxUSE_TIMER
// return platform and toolkit dependent wxTimer implementation
virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer) = 0;
#endif
#if wxUSE_THREADS
virtual void MutexGuiEnter();
virtual void MutexGuiLeave();
#endif
// functions returning port-specific information
// ------------------------------------------------------------------------
// return information about the (native) toolkit currently used and its
// runtime (not compile-time) version.
// returns wxPORT_BASE for console applications and one of the remaining
// wxPORT_* values for GUI applications.
virtual wxPortId GetToolkitVersion(int *majVer = nullptr,
int *minVer = nullptr,
int *microVer = nullptr) const = 0;
// return true if the port is using wxUniversal for the GUI, false if not
virtual bool IsUsingUniversalWidgets() const = 0;
// return the name of the Desktop Environment such as
// "KDE" or "GNOME". May return an empty string.
virtual wxString GetDesktopEnvironment() const = 0;
// returns a short string to identify the block of the standard command
// line options parsed automatically by current port: if this string is
// empty, there are no such options, otherwise the function also fills
// passed arrays with the names and the descriptions of those options.
virtual wxString GetStandardCmdLineOptions(wxArrayString& names,
wxArrayString& desc) const
{
wxUnusedVar(names);
wxUnusedVar(desc);
return wxEmptyString;
}
#if wxUSE_STACKWALKER
// Helper function mostly useful for derived classes ShowAssertDialog()
// implementation.
//
// Returns the stack frame as a plain (and possibly empty) wxString.
virtual wxString GetAssertStackTrace();
#endif // wxUSE_STACKWALKER
// Text to be appended to the description returned by wxGetLibraryVersionInfo().
// Currently used for getting compile-time versions of GTK+ and Qt.
virtual wxString GetPlatformDescription() const = 0;
private:
static wxSocketManager *ms_manager;
};
// ----------------------------------------------------------------------------
// include the platform-specific version of the class
// ----------------------------------------------------------------------------
// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
// Unix code (and otherwise __UNIX__ wouldn't be defined)
// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
#if defined(__WIN32__)
#include "wx/msw/apptbase.h"
#elif defined(__UNIX__)
#include "wx/unix/apptbase.h"
#else // no platform-specific methods to add to wxAppTraits
// wxAppTraits must be a class because it was forward declared as class
class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
{
};
#endif // platform
// ============================================================================
// standard traits for console and GUI applications
// ============================================================================
// ----------------------------------------------------------------------------
// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
{
public:
#if !wxUSE_CONSOLE_EVENTLOOP
virtual wxEventLoopBase *CreateEventLoop() override { return nullptr; }
#endif // !wxUSE_CONSOLE_EVENTLOOP
#if wxUSE_LOG
virtual wxLog *CreateLogTarget() override;
#endif // wxUSE_LOG
virtual wxMessageOutput *CreateMessageOutput() override;
#if wxUSE_FONTMAP
virtual wxFontMapper *CreateFontMapper() override;
#endif // wxUSE_FONTMAP
virtual wxRendererNative *CreateRenderer() override;
virtual bool ShowAssertDialog(const wxString& msg) override;
virtual bool HasStderr() override;
virtual bool SafeMessageBox(const wxString& text,
const wxString& title) override;
// the GetToolkitVersion for console application is always the same
wxPortId GetToolkitVersion(int *verMaj = nullptr,
int *verMin = nullptr,
int *verMicro = nullptr) const override
{
// no toolkits (wxBase is for console applications without GUI support)
// NB: zero means "no toolkit", -1 means "not initialized yet"
// so we must use zero here!
if (verMaj) *verMaj = 0;
if (verMin) *verMin = 0;
if (verMicro) *verMicro = 0;
return wxPORT_BASE;
}
virtual bool IsUsingUniversalWidgets() const override { return false; }
virtual wxString GetDesktopEnvironment() const override { return wxEmptyString; }
virtual wxString GetPlatformDescription() const override { return wxEmptyString; }
};
// ----------------------------------------------------------------------------
// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
// ----------------------------------------------------------------------------
#if wxUSE_GUI
class WXDLLIMPEXP_CORE wxGUIAppTraitsBase : public wxAppTraits
{
public:
#if wxUSE_LOG
virtual wxLog *CreateLogTarget() override;
#endif // wxUSE_LOG
virtual wxMessageOutput *CreateMessageOutput() override;
#if wxUSE_FONTMAP
virtual wxFontMapper *CreateFontMapper() override;
#endif // wxUSE_FONTMAP
virtual wxRendererNative *CreateRenderer() override;
virtual bool ShowAssertDialog(const wxString& msg) override;
virtual bool HasStderr() override;
// Win32 has its own implementation using native message box directly in
// the base class, don't override it.
#ifndef __WIN32__
virtual bool SafeMessageBox(const wxString& text,
const wxString& title) override;
#endif // !__WIN32__
virtual bool IsUsingUniversalWidgets() const override
{
#ifdef __WXUNIVERSAL__
return true;
#else
return false;
#endif
}
virtual wxString GetDesktopEnvironment() const override { return wxEmptyString; }
virtual wxString GetPlatformDescription() const override { return wxEmptyString; }
};
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// include the platform-specific version of the classes above
// ----------------------------------------------------------------------------
// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
#if defined(__WIN32__)
#include "wx/msw/apptrait.h"
#elif defined(__UNIX__)
#include "wx/unix/apptrait.h"
#else
#if wxUSE_GUI
class wxGUIAppTraits : public wxGUIAppTraitsBase
{
};
#endif // wxUSE_GUI
class wxConsoleAppTraits: public wxConsoleAppTraitsBase
{
};
#endif // platform
#endif // _WX_APPTRAIT_H_

View File

@@ -0,0 +1,371 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/archive.h
// Purpose: Streams for archive formats
// Author: Mike Wetherell
// Copyright: (c) 2004 Mike Wetherell
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ARCHIVE_H__
#define _WX_ARCHIVE_H__
#include "wx/defs.h"
#if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
#include "wx/stream.h"
#include "wx/filename.h"
/////////////////////////////////////////////////////////////////////////////
// wxArchiveNotifier
class WXDLLIMPEXP_BASE wxArchiveNotifier
{
public:
virtual ~wxArchiveNotifier() = default;
virtual void OnEntryUpdated(class wxArchiveEntry& entry) = 0;
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveEntry
//
// Holds an entry's meta data, such as filename and timestamp.
class WXDLLIMPEXP_BASE wxArchiveEntry : public wxObject
{
public:
virtual ~wxArchiveEntry() = default;
virtual wxDateTime GetDateTime() const = 0;
virtual wxFileOffset GetSize() const = 0;
virtual wxFileOffset GetOffset() const = 0;
virtual bool IsDir() const = 0;
virtual bool IsReadOnly() const = 0;
virtual wxString GetInternalName() const = 0;
virtual wxPathFormat GetInternalFormat() const = 0;
virtual wxString GetName(wxPathFormat format = wxPATH_NATIVE) const = 0;
virtual void SetDateTime(const wxDateTime& dt) = 0;
virtual void SetSize(wxFileOffset size) = 0;
virtual void SetIsDir(bool isDir = true) = 0;
virtual void SetIsReadOnly(bool isReadOnly = true) = 0;
virtual void SetName(const wxString& name,
wxPathFormat format = wxPATH_NATIVE) = 0;
wxNODISCARD wxArchiveEntry *Clone() const { return DoClone(); }
void SetNotifier(wxArchiveNotifier& notifier);
virtual void UnsetNotifier() { m_notifier = nullptr; }
protected:
wxArchiveEntry() : m_notifier(nullptr) { }
wxArchiveEntry(const wxArchiveEntry& e) : wxObject(e), m_notifier(nullptr) { }
virtual void SetOffset(wxFileOffset offset) = 0;
virtual wxArchiveEntry* DoClone() const = 0;
wxArchiveNotifier *GetNotifier() const { return m_notifier; }
wxArchiveEntry& operator=(const wxArchiveEntry& entry);
private:
wxArchiveNotifier *m_notifier;
wxDECLARE_ABSTRACT_CLASS(wxArchiveEntry);
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveInputStream
//
// GetNextEntry() returns a wxArchiveEntry object containing the meta-data
// for the next entry in the archive (and gives away ownership). Reading from
// the wxArchiveInputStream then returns the entry's data. Eof() becomes true
// after an attempt has been made to read past the end of the entry's data.
//
// When there are no more entries, GetNextEntry() returns nullptr and sets Eof().
class WXDLLIMPEXP_BASE wxArchiveInputStream : public wxFilterInputStream
{
public:
typedef wxArchiveEntry entry_type;
virtual ~wxArchiveInputStream() = default;
virtual bool OpenEntry(wxArchiveEntry& entry) = 0;
virtual bool CloseEntry() = 0;
wxArchiveEntry *GetNextEntry() { return DoGetNextEntry(); }
virtual char Peek() override { return wxInputStream::Peek(); }
protected:
wxArchiveInputStream(wxInputStream& stream, wxMBConv& conv);
wxArchiveInputStream(wxInputStream *stream, wxMBConv& conv);
virtual wxArchiveEntry *DoGetNextEntry() = 0;
wxMBConv& GetConv() const { return m_conv; }
private:
wxMBConv& m_conv;
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveOutputStream
//
// PutNextEntry is used to create a new entry in the output archive, then
// the entry's data is written to the wxArchiveOutputStream.
//
// Only one entry can be open for output at a time; another call to
// PutNextEntry closes the current entry and begins the next.
//
// The overload 'bool PutNextEntry(wxArchiveEntry *entry)' takes ownership
// of the entry object.
class WXDLLIMPEXP_BASE wxArchiveOutputStream : public wxFilterOutputStream
{
public:
virtual ~wxArchiveOutputStream() = default;
virtual bool PutNextEntry(wxArchiveEntry *entry) = 0;
virtual bool PutNextEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now(),
wxFileOffset size = wxInvalidOffset) = 0;
virtual bool PutNextDirEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now()) = 0;
virtual bool CopyEntry(wxArchiveEntry *entry,
wxArchiveInputStream& stream) = 0;
virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0;
virtual bool CloseEntry() = 0;
protected:
wxArchiveOutputStream(wxOutputStream& stream, wxMBConv& conv);
wxArchiveOutputStream(wxOutputStream *stream, wxMBConv& conv);
wxMBConv& GetConv() const { return m_conv; }
private:
wxMBConv& m_conv;
};
/////////////////////////////////////////////////////////////////////////////
// wxArchiveIterator
//
// An input iterator that can be used to transfer an archive's catalog to
// a container.
#include <iterator>
#include <utility>
template <class X, class Y> inline
void _wxSetArchiveIteratorValue(
X& val, Y entry, void *WXUNUSED(d))
{
val = X(entry);
}
template <class X, class Y, class Z> inline
void _wxSetArchiveIteratorValue(
std::pair<X, Y>& val, Z entry, Z WXUNUSED(d))
{
val = std::make_pair(X(entry->GetInternalName()), Y(entry));
}
template <class Arc, class T = typename Arc::entry_type*>
class wxArchiveIterator
{
public:
typedef std::input_iterator_tag iterator_category;
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef T& reference;
wxArchiveIterator() : m_rep(nullptr) { }
wxArchiveIterator(Arc& arc) {
typename Arc::entry_type* entry = arc.GetNextEntry();
m_rep = entry ? new Rep(arc, entry) : nullptr;
}
wxArchiveIterator(const wxArchiveIterator& it) : m_rep(it.m_rep) {
if (m_rep)
m_rep->AddRef();
}
~wxArchiveIterator() {
if (m_rep)
m_rep->UnRef();
}
const T& operator *() const {
return m_rep->GetValue();
}
const T* operator ->() const {
return &**this;
}
wxArchiveIterator& operator =(const wxArchiveIterator& it) {
if (it.m_rep)
it.m_rep->AddRef();
if (m_rep)
m_rep->UnRef();
m_rep = it.m_rep;
return *this;
}
wxArchiveIterator& operator ++() {
m_rep = m_rep->Next();
return *this;
}
wxArchiveIterator operator ++(int) {
wxArchiveIterator it(*this);
++(*this);
return it;
}
bool operator ==(const wxArchiveIterator& j) const {
return m_rep == j.m_rep;
}
bool operator !=(const wxArchiveIterator& j) const {
return !(*this == j);
}
private:
class Rep {
Arc& m_arc;
typename Arc::entry_type* m_entry;
T m_value;
int m_ref;
public:
Rep(Arc& arc, typename Arc::entry_type* entry)
: m_arc(arc), m_entry(entry), m_value(), m_ref(1) { }
~Rep()
{ delete m_entry; }
void AddRef() {
m_ref++;
}
void UnRef() {
if (--m_ref == 0)
delete this;
}
Rep *Next() {
typename Arc::entry_type* entry = m_arc.GetNextEntry();
if (!entry) {
UnRef();
return nullptr;
}
if (m_ref > 1) {
m_ref--;
return new Rep(m_arc, entry);
}
delete m_entry;
m_entry = entry;
m_value = T();
return this;
}
const T& GetValue() {
if (m_entry) {
_wxSetArchiveIteratorValue(m_value, m_entry, m_entry);
m_entry = nullptr;
}
return m_value;
}
} *m_rep;
};
typedef wxArchiveIterator<wxArchiveInputStream> wxArchiveIter;
typedef wxArchiveIterator<wxArchiveInputStream,
std::pair<wxString, wxArchiveEntry*> > wxArchivePairIter;
/////////////////////////////////////////////////////////////////////////////
// wxArchiveClassFactory
//
// A wxArchiveClassFactory instance for a particular archive type allows
// the creation of the other classes that may be needed.
void WXDLLIMPEXP_BASE wxUseArchiveClasses();
class WXDLLIMPEXP_BASE wxArchiveClassFactory : public wxFilterClassFactoryBase
{
public:
typedef wxArchiveEntry entry_type;
typedef wxArchiveInputStream instream_type;
typedef wxArchiveOutputStream outstream_type;
typedef wxArchiveNotifier notifier_type;
typedef wxArchiveIter iter_type;
typedef wxArchivePairIter pairiter_type;
virtual ~wxArchiveClassFactory() = default;
wxArchiveEntry *NewEntry() const
{ return DoNewEntry(); }
wxArchiveInputStream *NewStream(wxInputStream& stream) const
{ return DoNewStream(stream); }
wxArchiveOutputStream *NewStream(wxOutputStream& stream) const
{ return DoNewStream(stream); }
wxArchiveInputStream *NewStream(wxInputStream *stream) const
{ return DoNewStream(stream); }
wxArchiveOutputStream *NewStream(wxOutputStream *stream) const
{ return DoNewStream(stream); }
virtual wxString GetInternalName(
const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const = 0;
void SetConv(wxMBConv& conv) { m_pConv = &conv; }
wxMBConv& GetConv() const
{ if (m_pConv) return *m_pConv; else return wxConvLocal; }
static const wxArchiveClassFactory *Find(const wxString& protocol,
wxStreamProtocolType type
= wxSTREAM_PROTOCOL);
static const wxArchiveClassFactory *GetFirst();
const wxArchiveClassFactory *GetNext() const { return m_next; }
void PushFront() { Remove(); m_next = sm_first; sm_first = this; }
void Remove();
protected:
// old compilers don't support covariant returns, so 'Do' methods are
// used to simulate them
virtual wxArchiveEntry *DoNewEntry() const = 0;
virtual wxArchiveInputStream *DoNewStream(wxInputStream& stream) const = 0;
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream& stream) const = 0;
virtual wxArchiveInputStream *DoNewStream(wxInputStream *stream) const = 0;
virtual wxArchiveOutputStream *DoNewStream(wxOutputStream *stream) const = 0;
wxArchiveClassFactory() : m_pConv(nullptr), m_next(this) { }
wxArchiveClassFactory& operator=(const wxArchiveClassFactory& WXUNUSED(f))
{ return *this; }
private:
wxMBConv *m_pConv;
static wxArchiveClassFactory *sm_first;
wxArchiveClassFactory *m_next;
wxDECLARE_ABSTRACT_CLASS(wxArchiveClassFactory);
};
#endif // wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
#endif // _WX_ARCHIVE_H__

View File

@@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/arrimpl.cpp
// Purpose: helper file for implementation of dynamic lists
// Author: Vadim Zeitlin
// Created: 16.10.97
// Copyright: (c) 1997 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/*****************************************************************************
* Purpose: implements helper functions used by the template class used by *
* DECLARE_OBJARRAY macro and which couldn't be implemented inline *
* (because they need the full definition of type T in scope) *
* *
* Usage: 1) #include dynarray.h *
* 2) WX_DECLARE_OBJARRAY *
* 3) #include arrimpl.cpp *
* 4) WX_DEFINE_OBJARRAY *
*****************************************************************************/
#undef WX_DEFINE_OBJARRAY
#define WX_DEFINE_OBJARRAY(name) \
name::value_type* \
wxObjectArrayTraitsFor##name::Clone(const name::value_type& item) \
{ \
return new name::value_type(item); \
} \
\
void wxObjectArrayTraitsFor##name::Free(name::value_type* p) \
{ \
delete p; \
}

View File

@@ -0,0 +1,575 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/arrstr.h
// Purpose: wxArrayString class
// Author: Mattia Barbon and Vadim Zeitlin
// Created: 07/07/03
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ARRSTR_H
#define _WX_ARRSTR_H
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/dynarray.h"
// these functions are only used in STL build now but we define them in any
// case for compatibility with the existing code outside of the library which
// could be using them
inline int wxCMPFUNC_CONV wxStringSortAscending(const wxString& s1, const wxString& s2)
{
return s1.Cmp(s2);
}
inline int wxCMPFUNC_CONV wxStringSortDescending(const wxString& s1, const wxString& s2)
{
return wxStringSortAscending(s2, s1);
}
// This comparison function ignores case when comparing strings differing not
// in case only, i.e. this ensures that "Aa" comes before "AB", unlike with
// wxStringSortAscending().
inline int wxCMPFUNC_CONV
wxDictionaryStringSortAscending(const wxString& s1, const wxString& s2)
{
const int cmp = s1.CmpNoCase(s2);
return cmp ? cmp : s1.Cmp(s2);
}
inline int wxCMPFUNC_CONV
wxDictionaryStringSortDescending(const wxString& s1, const wxString& s2)
{
return wxDictionaryStringSortAscending(s2, s1);
}
WXDLLIMPEXP_BASE
int wxCMPFUNC_CONV wxCmpNatural(const wxString& s1, const wxString& s2);
WXDLLIMPEXP_BASE
int wxCMPFUNC_CONV wxCmpNaturalGeneric(const wxString& s1, const wxString& s2);
inline int wxCMPFUNC_CONV wxNaturalStringSortAscending(const wxString& s1, const wxString& s2)
{
return wxCmpNatural(s1, s2);
}
inline int wxCMPFUNC_CONV wxNaturalStringSortDescending(const wxString& s1, const wxString& s2)
{
return wxCmpNatural(s2, s1);
}
#if wxUSE_STD_CONTAINERS
typedef int (wxCMPFUNC_CONV *CMPFUNCwxString)(wxString*, wxString*);
class WXDLLIMPEXP_BASE wxWARN_UNUSED wxArrayString : public wxBaseArray<wxString>
{
public:
// type of function used by wxArrayString::Sort()
typedef int (wxCMPFUNC_CONV *CompareFunction)(const wxString& first,
const wxString& second);
wxArrayString() = default;
wxArrayString(size_t sz, const char** a);
wxArrayString(size_t sz, const wchar_t** a);
wxArrayString(size_t sz, const wxString* a);
template<typename U>
wxArrayString(std::initializer_list<U> list) : wxBaseArray<wxString>(list) { }
wxArrayString(const std::vector<wxString>& vec) : wxBaseArray<wxString>(vec) { }
wxArrayString(std::vector<wxString>&& vec) : wxBaseArray<wxString>(std::move(vec)) { }
template<typename U>
wxArrayString(const std::vector<U>& vec) : wxBaseArray<wxString>(vec.begin(), vec.end()) { }
int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
void Sort(bool reverseOrder = false);
void Sort(CompareFunction function);
void Sort(CMPFUNCwxString function) { wxBaseArray<wxString>::Sort(function); }
size_t Add(const wxString& string, size_t copies = 1)
{
wxBaseArray<wxString>::Add(string, copies);
return size() - copies;
}
const std::vector<wxString>& AsVector() const { return *this; }
};
// Unlike all the other sorted arrays, this one uses a comparison function
// taking objects by reference rather than value, so define a special functor
// wrapping it.
class wxSortedArrayString_SortFunction
{
public:
typedef int (wxCMPFUNC_CONV *CMPFUNC)(const wxString&, const wxString&);
explicit wxSortedArrayString_SortFunction(CMPFUNC f) : m_f(f) { }
bool operator()(const wxString& s1, const wxString& s2)
{ return m_f(s1, s2) < 0; }
private:
CMPFUNC m_f;
};
typedef wxBaseSortedArray<wxString, wxSortedArrayString_SortFunction>
wxSortedArrayStringBase;
class WXDLLIMPEXP_BASE wxSortedArrayString : public wxSortedArrayStringBase
{
public:
wxSortedArrayString() : wxSortedArrayStringBase(wxStringSortAscending)
{ }
wxSortedArrayString(const wxArrayString& src)
: wxSortedArrayStringBase(wxStringSortAscending)
{
reserve(src.size());
for ( size_t n = 0; n < src.size(); n++ )
Add(src[n]);
}
explicit wxSortedArrayString(wxArrayString::CompareFunction compareFunction)
: wxSortedArrayStringBase(compareFunction)
{ }
int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
private:
void Insert()
{
wxFAIL_MSG( "wxSortedArrayString::Insert() is not to be used" );
}
void Sort()
{
wxFAIL_MSG( "wxSortedArrayString::Sort() is not to be used" );
}
};
#else // if !wxUSE_STD_CONTAINERS
#include "wx/beforestd.h"
#include <iterator>
#include "wx/afterstd.h"
class WXDLLIMPEXP_BASE wxWARN_UNUSED wxArrayString
{
public:
// type of function used by wxArrayString::Sort()
typedef int (wxCMPFUNC_CONV *CompareFunction)(const wxString& first,
const wxString& second);
// type of function used by wxArrayString::Sort(), for compatibility with
// wxArray
typedef int (wxCMPFUNC_CONV *CompareFunction2)(wxString* first,
wxString* second);
// constructors and destructor
// default ctor
wxArrayString() = default;
// if autoSort is true, the array is always sorted (in alphabetical order)
//
// NB: the reason for using int and not bool is that like this we can avoid
// using this ctor for implicit conversions from "const char *" (which
// we'd like to be implicitly converted to wxString instead!). This
// wouldn't be needed if the 'explicit' keyword was supported by all
// compilers, or if this was protected ctor for wxSortedArrayString,
// but we're stuck with it now.
explicit wxArrayString(int autoSort)
{
if ( autoSort )
m_autoSort = true;
}
// C string array ctor
wxArrayString(size_t sz, const char** a);
wxArrayString(size_t sz, const wchar_t** a);
// wxString string array ctor
wxArrayString(size_t sz, const wxString* a);
// copy ctor
wxArrayString(const wxArrayString& array);
// list constructor
template<typename U>
wxArrayString(std::initializer_list<U> list) { assign(list.begin(), list.end()); }
// ctor from a std::vector
template<typename U>
wxArrayString(const std::vector<U>& vec) { assign(vec.begin(), vec.end()); }
// assignment operator
wxArrayString& operator=(const wxArrayString& src);
// not virtual, this class should not be derived from
~wxArrayString();
// memory management
// empties the list, but doesn't release memory
void Empty();
// empties the list and releases memory
void Clear();
// preallocates memory for given number of items
void Alloc(size_t nCount);
// minimizes the memory usage (by freeing all extra memory)
void Shrink();
// simple accessors
// number of elements in the array
size_t GetCount() const { return m_nCount; }
// is it empty?
bool IsEmpty() const { return m_nCount == 0; }
// number of elements in the array (GetCount is preferred API)
size_t Count() const { return m_nCount; }
// items access (range checking is done in debug version)
// get item at position uiIndex
wxString& Item(size_t nIndex)
{
wxASSERT_MSG( nIndex < m_nCount,
wxT("wxArrayString: index out of bounds") );
return m_pItems[nIndex];
}
const wxString& Item(size_t nIndex) const { return const_cast<wxArrayString*>(this)->Item(nIndex); }
// same as Item()
wxString& operator[](size_t nIndex) { return Item(nIndex); }
const wxString& operator[](size_t nIndex) const { return Item(nIndex); }
// get last item
wxString& Last()
{
wxASSERT_MSG( !IsEmpty(),
wxT("wxArrayString: index out of bounds") );
return Item(GetCount() - 1);
}
const wxString& Last() const { return const_cast<wxArrayString*>(this)->Last(); }
// get all items as a vector
std::vector<wxString> AsVector() const;
// item management
// Search the element in the array, starting from the beginning if
// bFromEnd is false or from end otherwise. If bCase, comparison is case
// sensitive (default). Returns index of the first item matched or
// wxNOT_FOUND
int Index (const wxString& str, bool bCase = true, bool bFromEnd = false) const;
// add new element at the end (if the array is not sorted), return its
// index
size_t Add(const wxString& str, size_t nInsert = 1);
// add new element at given position
void Insert(const wxString& str, size_t uiIndex, size_t nInsert = 1);
// expand the array to have count elements
void SetCount(size_t count);
// remove first item matching this value
void Remove(const wxString& sz);
// remove item by index
void RemoveAt(size_t nIndex, size_t nRemove = 1);
// sorting
// sort array elements in alphabetical order (or reversed alphabetical
// order if reverseOrder parameter is true)
void Sort(bool reverseOrder = false);
// sort array elements using specified comparison function
void Sort(CompareFunction compareFunction);
void Sort(CompareFunction2 compareFunction);
// comparison
// compare two arrays case sensitively
bool operator==(const wxArrayString& a) const;
// compare two arrays case sensitively
bool operator!=(const wxArrayString& a) const { return !(*this == a); }
// STL-like interface
typedef wxString value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef int difference_type;
typedef size_t size_type;
// TODO: this code duplicates the one in dynarray.h
class reverse_iterator
{
typedef wxString value_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef reverse_iterator itor;
friend itor operator+(int o, const itor& it);
friend itor operator+(const itor& it, int o);
friend itor operator-(const itor& it, int o);
friend difference_type operator -(const itor& i1, const itor& i2);
public:
pointer m_ptr;
reverse_iterator() : m_ptr(nullptr) { }
explicit reverse_iterator(pointer ptr) : m_ptr(ptr) { }
reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { }
reference operator*() const { return *m_ptr; }
pointer operator->() const { return m_ptr; }
itor& operator++() { --m_ptr; return *this; }
const itor operator++(int)
{ const reverse_iterator tmp = *this; --m_ptr; return tmp; }
itor& operator--() { ++m_ptr; return *this; }
const itor operator--(int) { const itor tmp = *this; ++m_ptr; return tmp; }
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
};
class const_reverse_iterator
{
typedef wxString value_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef const_reverse_iterator itor;
friend itor operator+(int o, const itor& it);
friend itor operator+(const itor& it, int o);
friend itor operator-(const itor& it, int o);
friend difference_type operator -(const itor& i1, const itor& i2);
public:
pointer m_ptr;
const_reverse_iterator() : m_ptr(nullptr) { }
explicit const_reverse_iterator(pointer ptr) : m_ptr(ptr) { }
const_reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { }
const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }
reference operator*() const { return *m_ptr; }
pointer operator->() const { return m_ptr; }
itor& operator++() { --m_ptr; return *this; }
const itor operator++(int)
{ const itor tmp = *this; --m_ptr; return tmp; }
itor& operator--() { ++m_ptr; return *this; }
const itor operator--(int) { const itor tmp = *this; ++m_ptr; return tmp; }
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
};
wxArrayString(const_iterator first, const_iterator last)
{ assign(first, last); }
wxArrayString(size_type n, const_reference v) { assign(n, v); }
template <class Iterator>
void assign(Iterator first, Iterator last)
{
clear();
reserve(std::distance(first, last));
for(; first != last; ++first)
push_back(*first);
}
void assign(size_type n, const_reference v)
{ clear(); Add(v, n); }
reference back() { return *(end() - 1); }
const_reference back() const { return *(end() - 1); }
iterator begin() { return m_pItems; }
const_iterator begin() const { return m_pItems; }
size_type capacity() const { return m_nSize; }
void clear() { Clear(); }
bool empty() const { return IsEmpty(); }
iterator end() { return begin() + GetCount(); }
const_iterator end() const { return begin() + GetCount(); }
iterator erase(iterator first, iterator last)
{
size_t idx = first - begin();
RemoveAt(idx, last - first);
return begin() + idx;
}
iterator erase(iterator it) { return erase(it, it + 1); }
reference front() { return *begin(); }
const_reference front() const { return *begin(); }
void insert(iterator it, size_type n, const_reference v)
{ Insert(v, it - begin(), n); }
iterator insert(iterator it, const_reference v = value_type())
{ size_t idx = it - begin(); Insert(v, idx); return begin() + idx; }
void insert(iterator it, const_iterator first, const_iterator last);
size_type max_size() const { return INT_MAX; }
void pop_back() { RemoveAt(GetCount() - 1); }
void push_back(const_reference v) { Add(v); }
reverse_iterator rbegin() { return reverse_iterator(end() - 1); }
const_reverse_iterator rbegin() const
{ return const_reverse_iterator(end() - 1); }
reverse_iterator rend() { return reverse_iterator(begin() - 1); }
const_reverse_iterator rend() const
{ return const_reverse_iterator(begin() - 1); }
void reserve(size_type n) /* base::reserve*/;
void resize(size_type n, value_type v = value_type());
size_type size() const { return GetCount(); }
void swap(wxArrayString& other)
{
wxSwap(m_nSize, other.m_nSize);
wxSwap(m_nCount, other.m_nCount);
wxSwap(m_pItems, other.m_pItems);
wxSwap(m_autoSort, other.m_autoSort);
}
protected:
void Copy(const wxArrayString& src); // copies the contents of another array
CompareFunction m_compareFunction = nullptr; // set only from wxSortedArrayString
private:
// Allocate the new buffer big enough to hold m_nCount + nIncrement items and
// return the pointer to the old buffer, which must be deleted by the caller
// (if the old buffer is big enough, just return nullptr).
wxString *Grow(size_t nIncrement);
// Binary search in the sorted array: return the index of the string if it's
// present, otherwise, if lowerBound is true, return the position at which
// the string should be inserted and if it's false return wxNOT_FOUND.
size_t BinarySearch(const wxString& str, bool lowerBound) const;
size_t m_nSize = 0, // current size of the array
m_nCount = 0; // current number of elements
wxString *m_pItems = nullptr; // pointer to data
bool m_autoSort = false; // if true, keep the array always sorted
};
class WXDLLIMPEXP_BASE wxSortedArrayString : public wxArrayString
{
public:
wxSortedArrayString() : wxArrayString(true)
{ }
wxSortedArrayString(const wxArrayString& array) : wxArrayString(true)
{ Copy(array); }
explicit wxSortedArrayString(CompareFunction compareFunction)
: wxArrayString(true)
{ m_compareFunction = compareFunction; }
};
#endif // !wxUSE_STD_CONTAINERS
// this class provides a temporary wxString* from a
// wxArrayString
class WXDLLIMPEXP_BASE wxCArrayString
{
public:
wxCArrayString( const wxArrayString& array )
: m_array( array ), m_strings( nullptr )
{ }
~wxCArrayString() { delete[] m_strings; }
size_t GetCount() const { return m_array.GetCount(); }
wxString* GetStrings()
{
if( m_strings ) return m_strings;
const size_t count = m_array.GetCount();
m_strings = new wxString[count];
for( size_t i = 0; i < count; ++i )
m_strings[i] = m_array[i];
return m_strings;
}
wxString* Release()
{
wxString *r = GetStrings();
m_strings = nullptr;
return r;
}
private:
const wxArrayString& m_array;
wxString* m_strings;
};
// ----------------------------------------------------------------------------
// helper functions for working with arrays
// ----------------------------------------------------------------------------
// by default, these functions use the escape character to escape the
// separators occurring inside the string to be joined, this can be disabled by
// passing '\0' as escape
WXDLLIMPEXP_BASE wxString wxJoin(const wxArrayString& arr,
const wxChar sep,
const wxChar escape = wxT('\\'));
WXDLLIMPEXP_BASE wxArrayString wxSplit(const wxString& str,
const wxChar sep,
const wxChar escape = wxT('\\'));
// ----------------------------------------------------------------------------
// This helper class allows to pass both C array of wxStrings or wxArrayString
// using the same interface.
//
// Use it when you have two methods taking wxArrayString or (int, wxString[]),
// that do the same thing. This class lets you iterate over input data in the
// same way whether it is a raw array of strings or wxArrayString.
//
// The object does not take ownership of the data -- internally it keeps
// pointers to the data, therefore the data must be disposed of by user
// and only after this object is destroyed. Usually it is not a problem as
// only temporary objects of this class are used.
// ----------------------------------------------------------------------------
class wxArrayStringsAdapter
{
public:
// construct an adapter from a wxArrayString
wxArrayStringsAdapter(const wxArrayString& strings)
: m_type(wxSTRING_ARRAY), m_size(strings.size())
{
m_data.array = &strings;
}
// construct an adapter from a wxString[]
wxArrayStringsAdapter(unsigned int n, const wxString *strings)
: m_type(wxSTRING_POINTER), m_size(n)
{
m_data.ptr = strings;
}
// construct an adapter from a vector of strings
wxArrayStringsAdapter(const std::vector<wxString>& strings)
: m_type(wxSTRING_POINTER), m_size(strings.size())
{
m_data.ptr = m_size == 0 ? nullptr : &strings[0];
}
// construct an adapter from a single wxString
wxArrayStringsAdapter(const wxString& s)
: m_type(wxSTRING_POINTER), m_size(1)
{
m_data.ptr = &s;
}
// default copy constructor is ok
// iteration interface
size_t GetCount() const { return m_size; }
bool IsEmpty() const { return GetCount() == 0; }
const wxString& operator[] (unsigned int i) const
{
wxASSERT_MSG( i < GetCount(), wxT("index out of bounds") );
if(m_type == wxSTRING_POINTER)
return m_data.ptr[i];
return m_data.array->Item(i);
}
wxArrayString AsArrayString() const
{
if(m_type == wxSTRING_ARRAY)
return *m_data.array;
return wxArrayString(GetCount(), m_data.ptr);
}
private:
// type of the data being held
enum wxStringContainerType
{
wxSTRING_ARRAY, // wxArrayString
wxSTRING_POINTER // wxString[]
};
wxStringContainerType m_type;
size_t m_size;
union
{
const wxString * ptr;
const wxArrayString * array;
} m_data;
wxDECLARE_NO_ASSIGN_CLASS(wxArrayStringsAdapter);
};
#endif // _WX_ARRSTR_H

View File

@@ -0,0 +1,289 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/artprov.h
// Purpose: wxArtProvider class
// Author: Vaclav Slavik
// Created: 18/03/2002
// Copyright: (c) Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ARTPROV_H_
#define _WX_ARTPROV_H_
#include "wx/string.h"
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/iconbndl.h"
#include "wx/bmpbndl.h"
class wxArtProvidersList;
class wxArtProviderCache;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class wxArtProviderModule;
// ----------------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------------
typedef wxString wxArtClient;
typedef wxString wxArtID;
#define wxART_MAKE_CLIENT_ID_FROM_STR(id) ((id) + wxASCII_STR("_C"))
#define wxART_MAKE_CLIENT_ID(id) (#id "_C")
#define wxART_MAKE_ART_ID_FROM_STR(id) (id)
#define wxART_MAKE_ART_ID(id) (#id)
// ----------------------------------------------------------------------------
// Art clients
// ----------------------------------------------------------------------------
#define wxART_TOOLBAR wxART_MAKE_CLIENT_ID(wxART_TOOLBAR)
#define wxART_MENU wxART_MAKE_CLIENT_ID(wxART_MENU)
#define wxART_FRAME_ICON wxART_MAKE_CLIENT_ID(wxART_FRAME_ICON)
#define wxART_CMN_DIALOG wxART_MAKE_CLIENT_ID(wxART_CMN_DIALOG)
#define wxART_HELP_BROWSER wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER)
#define wxART_MESSAGE_BOX wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX)
#define wxART_BUTTON wxART_MAKE_CLIENT_ID(wxART_BUTTON)
#define wxART_LIST wxART_MAKE_CLIENT_ID(wxART_LIST)
#define wxART_OTHER wxART_MAKE_CLIENT_ID(wxART_OTHER)
// ----------------------------------------------------------------------------
// Art IDs
// ----------------------------------------------------------------------------
#define wxART_ADD_BOOKMARK wxART_MAKE_ART_ID(wxART_ADD_BOOKMARK)
#define wxART_DEL_BOOKMARK wxART_MAKE_ART_ID(wxART_DEL_BOOKMARK)
#define wxART_HELP_SIDE_PANEL wxART_MAKE_ART_ID(wxART_HELP_SIDE_PANEL)
#define wxART_HELP_SETTINGS wxART_MAKE_ART_ID(wxART_HELP_SETTINGS)
#define wxART_HELP_BOOK wxART_MAKE_ART_ID(wxART_HELP_BOOK)
#define wxART_HELP_FOLDER wxART_MAKE_ART_ID(wxART_HELP_FOLDER)
#define wxART_HELP_PAGE wxART_MAKE_ART_ID(wxART_HELP_PAGE)
#define wxART_GO_BACK wxART_MAKE_ART_ID(wxART_GO_BACK)
#define wxART_GO_FORWARD wxART_MAKE_ART_ID(wxART_GO_FORWARD)
#define wxART_GO_UP wxART_MAKE_ART_ID(wxART_GO_UP)
#define wxART_GO_DOWN wxART_MAKE_ART_ID(wxART_GO_DOWN)
#define wxART_GO_TO_PARENT wxART_MAKE_ART_ID(wxART_GO_TO_PARENT)
#define wxART_GO_HOME wxART_MAKE_ART_ID(wxART_GO_HOME)
#define wxART_GOTO_FIRST wxART_MAKE_ART_ID(wxART_GOTO_FIRST)
#define wxART_GOTO_LAST wxART_MAKE_ART_ID(wxART_GOTO_LAST)
#define wxART_FILE_OPEN wxART_MAKE_ART_ID(wxART_FILE_OPEN)
#define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE)
#define wxART_FILE_SAVE_AS wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS)
#define wxART_PRINT wxART_MAKE_ART_ID(wxART_PRINT)
#define wxART_HELP wxART_MAKE_ART_ID(wxART_HELP)
#define wxART_TIP wxART_MAKE_ART_ID(wxART_TIP)
#define wxART_REPORT_VIEW wxART_MAKE_ART_ID(wxART_REPORT_VIEW)
#define wxART_LIST_VIEW wxART_MAKE_ART_ID(wxART_LIST_VIEW)
#define wxART_NEW_DIR wxART_MAKE_ART_ID(wxART_NEW_DIR)
#define wxART_HARDDISK wxART_MAKE_ART_ID(wxART_HARDDISK)
#define wxART_FLOPPY wxART_MAKE_ART_ID(wxART_FLOPPY)
#define wxART_CDROM wxART_MAKE_ART_ID(wxART_CDROM)
#define wxART_REMOVABLE wxART_MAKE_ART_ID(wxART_REMOVABLE)
#define wxART_FOLDER wxART_MAKE_ART_ID(wxART_FOLDER)
#define wxART_FOLDER_OPEN wxART_MAKE_ART_ID(wxART_FOLDER_OPEN)
#define wxART_GO_DIR_UP wxART_MAKE_ART_ID(wxART_GO_DIR_UP)
#define wxART_EXECUTABLE_FILE wxART_MAKE_ART_ID(wxART_EXECUTABLE_FILE)
#define wxART_NORMAL_FILE wxART_MAKE_ART_ID(wxART_NORMAL_FILE)
#define wxART_TICK_MARK wxART_MAKE_ART_ID(wxART_TICK_MARK)
#define wxART_CROSS_MARK wxART_MAKE_ART_ID(wxART_CROSS_MARK)
#define wxART_ERROR wxART_MAKE_ART_ID(wxART_ERROR)
#define wxART_QUESTION wxART_MAKE_ART_ID(wxART_QUESTION)
#define wxART_WARNING wxART_MAKE_ART_ID(wxART_WARNING)
#define wxART_INFORMATION wxART_MAKE_ART_ID(wxART_INFORMATION)
#define wxART_MISSING_IMAGE wxART_MAKE_ART_ID(wxART_MISSING_IMAGE)
#define wxART_COPY wxART_MAKE_ART_ID(wxART_COPY)
#define wxART_CUT wxART_MAKE_ART_ID(wxART_CUT)
#define wxART_PASTE wxART_MAKE_ART_ID(wxART_PASTE)
#define wxART_DELETE wxART_MAKE_ART_ID(wxART_DELETE)
#define wxART_NEW wxART_MAKE_ART_ID(wxART_NEW)
#define wxART_UNDO wxART_MAKE_ART_ID(wxART_UNDO)
#define wxART_REDO wxART_MAKE_ART_ID(wxART_REDO)
#define wxART_PLUS wxART_MAKE_ART_ID(wxART_PLUS)
#define wxART_MINUS wxART_MAKE_ART_ID(wxART_MINUS)
#define wxART_CLOSE wxART_MAKE_ART_ID(wxART_CLOSE)
#define wxART_QUIT wxART_MAKE_ART_ID(wxART_QUIT)
#define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND)
#define wxART_FIND_AND_REPLACE wxART_MAKE_ART_ID(wxART_FIND_AND_REPLACE)
#define wxART_FULL_SCREEN wxART_MAKE_ART_ID(wxART_FULL_SCREEN)
#define wxART_EDIT wxART_MAKE_ART_ID(wxART_EDIT)
#define wxART_WX_LOGO wxART_MAKE_ART_ID(wxART_WX_LOGO)
#define wxART_REFRESH wxART_MAKE_ART_ID(wxART_REFRESH)
#define wxART_STOP wxART_MAKE_ART_ID(wxART_STOP)
// ----------------------------------------------------------------------------
// wxArtProvider class
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxArtProvider : public wxObject
{
public:
// Dtor removes the provider from providers stack if it's still on it
virtual ~wxArtProvider();
// Does this platform implement native icons theme?
static bool HasNativeProvider();
// Add new provider to the top of providers stack (i.e. the provider will
// be queried first of all).
static void Push(wxArtProvider *provider);
// Add new provider to the bottom of providers stack (i.e. the provider
// will be queried as the last one).
static void PushBack(wxArtProvider *provider);
// Remove latest added provider and delete it.
static bool Pop();
// Remove provider from providers stack but don't delete it.
static bool Remove(wxArtProvider *provider);
// Delete the given provider and remove it from the providers stack.
static bool Delete(wxArtProvider *provider);
// Query the providers for bitmap with given ID and return it. Return
// wxNullBitmap if no provider provides it.
static wxBitmap GetBitmap(const wxArtID& id,
const wxArtClient& client = wxASCII_STR(wxART_OTHER),
const wxSize& size = wxDefaultSize);
// Query the providers for bitmapbundle with given ID and return it.
// If none is available, then the search for a bitmap with the same properties
// is performed. If successful, the bitmap is wrapped into a bitmap bundle.
static wxBitmapBundle
GetBitmapBundle(const wxArtID& id,
const wxArtClient& client = wxASCII_STR(wxART_OTHER),
const wxSize& size = wxDefaultSize);
// Query the providers for icon with given ID and return it. Return
// wxNullIcon if no provider provides it.
static wxIcon GetIcon(const wxArtID& id,
const wxArtClient& client = wxASCII_STR(wxART_OTHER),
const wxSize& size = wxDefaultSize);
// Helper used by GetMessageBoxIcon(): return the art id corresponding to
// the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one
// can be set)
static wxArtID GetMessageBoxIconId(int flags);
// Helper used by several generic classes: return the icon corresponding to
// the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one
// can be set)
static wxIcon GetMessageBoxIcon(int flags)
{
return GetIcon(GetMessageBoxIconId(flags), wxASCII_STR(wxART_MESSAGE_BOX));
}
// Query the providers for iconbundle with given ID and return it. Return
// wxNullIconBundle if no provider provides it.
static wxIconBundle GetIconBundle(const wxArtID& id,
const wxArtClient& client = wxASCII_STR(wxART_OTHER));
// Gets native size for given 'client' or wxDefaultSize if it doesn't
// have native equivalent. The first version returns the size in logical
// pixels while the second one returns it in DIPs.
static wxSize GetNativeSizeHint(const wxArtClient& client, wxWindow* win = nullptr);
static wxSize GetNativeDIPSizeHint(const wxArtClient& client);
// Get the size hint of an icon from a specific wxArtClient from the
// topmost (i.e. first used) provider.
static wxSize GetSizeHint(const wxArtClient& client, wxWindow* win = nullptr);
static wxSize GetDIPSizeHint(const wxArtClient& client);
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("use GetSizeHint() without bool argument or GetNativeSizeHint()")
static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent);
wxDEPRECATED_MSG("use wxBitmap::Rescale() instead.")
static void RescaleBitmap(wxBitmap& bmp, const wxSize& sizeNeeded);
#endif // WXWIN_COMPATIBILITY_3_0
protected:
friend class wxArtProviderModule;
#if wxUSE_ARTPROVIDER_STD
// Initializes default provider
static void InitStdProvider();
#endif // wxUSE_ARTPROVIDER_STD
// Initializes Tango-based icon provider
#if wxUSE_ARTPROVIDER_TANGO
static void InitTangoProvider();
#endif // wxUSE_ARTPROVIDER_TANGO
// Initializes platform's native provider, if available (e.g. GTK2)
static void InitNativeProvider();
// Destroy caches & all providers
static void CleanUpProviders();
// Get the default size of an icon for a specific client.
//
// Although this function doesn't have "DIP" in its name, it should return
// the size in DIPs.
virtual wxSize DoGetSizeHint(const wxArtClient& client);
// Derived classes must override at least one of the CreateXXX() functions
// below to create requested art resource. Overriding more than one of them
// is also possible but is usually not needed, as both GetBitmap() and
// GetBitmapBundle() will try using both CreateBitmap() and
// CreateBitmapBundle().
//
// Note that these methods are called only once per instance's lifetime for
// each requested wxArtID as the return value is cached.
virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client),
const wxSize& WXUNUSED(size))
{
return wxNullBitmap;
}
virtual wxBitmapBundle CreateBitmapBundle(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client),
const wxSize& WXUNUSED(size))
{
return wxBitmapBundle();
}
virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client))
{
return wxNullIconBundle;
}
// Helper for resizing the bitmaps to the requested size without scaling
// them up nor resizing (16, 15) bitmaps to (16, 16) -- or doing anything
// at all if the bitmap is already of the required size.
static void RescaleOrResizeIfNeeded(wxBitmap& bmp, const wxSize& sizeNeeded);
private:
static void CommonAddingProvider();
static wxIconBundle DoGetIconBundle(const wxArtID& id,
const wxArtClient& client);
private:
// list of providers:
static wxArtProvidersList *sm_providers;
// art resources cache (so that CreateXXX is not called that often):
static wxArtProviderCache *sm_cache;
wxDECLARE_ABSTRACT_CLASS(wxArtProvider);
};
#if !defined(__WXUNIVERSAL__) && \
(defined(__WXGTK__) || defined(__WXMSW__) || defined(__WXMAC__))
// *some* (partial) native implementation of wxArtProvider exists; this is
// not the same as wxArtProvider::HasNativeProvider()!
#define wxHAS_NATIVE_ART_PROVIDER_IMPL
#endif
#endif // _WX_ARTPROV_H_

View File

@@ -0,0 +1,156 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/atomic.h
// Purpose: functions to manipulate atomically integers and pointers
// Author: Armel Asselin
// Created: 12/13/2006
// Copyright: (c) Armel Asselin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ATOMIC_H_
#define _WX_ATOMIC_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// get the value of wxUSE_THREADS configuration flag
#include "wx/defs.h"
// these functions return the new value, after the operation
#if wxUSE_THREADS
#if defined(HAVE_GCC_ATOMIC_BUILTINS)
// NB: we intentionally don't use Linux's asm/atomic.h header, because it's
// an internal kernel header that doesn't always work in userspace:
// http://bugs.mysql.com/bug.php?id=28456
// http://golubenco.org/blog/atomic-operations/
inline wxUint32 wxAtomicInc (wxUint32 &value)
{
return __sync_add_and_fetch(&value, 1);
}
inline wxUint32 wxAtomicDec (wxUint32 &value)
{
return __sync_sub_and_fetch(&value, 1);
}
#elif defined(__WINDOWS__)
// include standard Windows headers
#include "wx/msw/wrapwin.h"
inline wxUint32 wxAtomicInc (wxUint32 &value)
{
return InterlockedIncrement ((LONG*)&value);
}
inline wxUint32 wxAtomicDec (wxUint32 &value)
{
return InterlockedDecrement ((LONG*)&value);
}
#elif defined(__DARWIN__)
#include "libkern/OSAtomic.h"
inline wxUint32 wxAtomicInc (wxUint32 &value)
{
return OSAtomicIncrement32 ((int32_t*)&value);
}
inline wxUint32 wxAtomicDec (wxUint32 &value)
{
return OSAtomicDecrement32 ((int32_t*)&value);
}
#elif defined (__SOLARIS__)
#include <atomic.h>
inline void wxAtomicInc (wxUint32 &value)
{
return atomic_add_32_nv ((uint32_t*)&value, 1);
}
inline wxUint32 wxAtomicDec (wxUint32 &value)
{
return atomic_add_32_nv ((uint32_t*)&value, (uint32_t)-1);
}
#else // unknown platform
// it will result in inclusion if the generic implementation code a bit later in this page
#define wxNEEDS_GENERIC_ATOMIC_OPS
#endif // unknown platform
#else // else of wxUSE_THREADS
// if no threads are used we can safely use simple ++/--
inline wxUint32 wxAtomicInc (wxUint32 &value) { return ++value; }
inline wxUint32 wxAtomicDec (wxUint32 &value) { return --value; }
#endif // !wxUSE_THREADS
// ----------------------------------------------------------------------------
// proxies to actual implementations, but for various other types with same
// behaviour
// ----------------------------------------------------------------------------
#ifdef wxNEEDS_GENERIC_ATOMIC_OPS
#include "wx/thread.h" // for wxCriticalSection
class wxAtomicInt32
{
public:
wxAtomicInt32() = default; // non initialized for consistency with basic int type
wxAtomicInt32(wxInt32 v) : m_value(v) { }
wxAtomicInt32(const wxAtomicInt32& a) : m_value(a.m_value) {}
operator wxInt32() const { return m_value; }
operator volatile wxInt32&() { return m_value; }
wxAtomicInt32& operator=(wxInt32 v) { m_value = v; return *this; }
wxInt32 Inc()
{
wxCriticalSectionLocker lock(m_locker);
return ++m_value;
}
wxInt32 Dec()
{
wxCriticalSectionLocker lock(m_locker);
return --m_value;
}
private:
volatile wxInt32 m_value;
wxCriticalSection m_locker;
};
inline wxInt32 wxAtomicInc(wxAtomicInt32 &value) { return value.Inc(); }
inline wxInt32 wxAtomicDec(wxAtomicInt32 &value) { return value.Dec(); }
#else // !wxNEEDS_GENERIC_ATOMIC_OPS
#define wxHAS_ATOMIC_OPS
inline wxInt32 wxAtomicInc(wxInt32 &value) { return wxAtomicInc((wxUint32&)value); }
inline wxInt32 wxAtomicDec(wxInt32 &value) { return wxAtomicDec((wxUint32&)value); }
typedef wxInt32 wxAtomicInt32;
#endif // wxNEEDS_GENERIC_ATOMIC_OPS
// all the native implementations use 32 bits currently
// for a 64 bits implementation we could use (a future) wxAtomicInt64 as
// default type
typedef wxAtomicInt32 wxAtomicInt;
#endif // _WX_ATOMIC_H_

View File

@@ -0,0 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/aui.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Created: 2005-05-17
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUI_H_
#define _WX_AUI_H_
#include "wx/aui/framemanager.h"
#include "wx/aui/dockart.h"
#include "wx/aui/floatpane.h"
#include "wx/aui/auibar.h"
#include "wx/aui/auibook.h"
#include "wx/aui/tabmdi.h"
#endif // _WX_AUI_H_

View File

@@ -0,0 +1,799 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/toolbar.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Created: 2008-08-04
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUIBAR_H_
#define _WX_AUIBAR_H_
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/bmpbndl.h"
#include "wx/control.h"
#include "wx/custombgwin.h"
#include "wx/sizer.h"
#include "wx/pen.h"
class WXDLLIMPEXP_FWD_CORE wxClientDC;
class WXDLLIMPEXP_FWD_CORE wxReadOnlyDC;
class WXDLLIMPEXP_FWD_AUI wxAuiPaneInfo;
enum wxAuiToolBarStyle
{
wxAUI_TB_TEXT = 1 << 0,
wxAUI_TB_NO_TOOLTIPS = 1 << 1,
wxAUI_TB_NO_AUTORESIZE = 1 << 2,
wxAUI_TB_GRIPPER = 1 << 3,
wxAUI_TB_OVERFLOW = 1 << 4,
// using this style forces the toolbar to be vertical and
// be only dockable to the left or right sides of the window
// whereas by default it can be horizontal or vertical and
// be docked anywhere
wxAUI_TB_VERTICAL = 1 << 5,
wxAUI_TB_HORZ_LAYOUT = 1 << 6,
// analogous to wxAUI_TB_VERTICAL, but forces the toolbar
// to be horizontal
wxAUI_TB_HORIZONTAL = 1 << 7,
wxAUI_TB_PLAIN_BACKGROUND = 1 << 8,
wxAUI_TB_HORZ_TEXT = (wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_TEXT),
wxAUI_ORIENTATION_MASK = (wxAUI_TB_VERTICAL | wxAUI_TB_HORIZONTAL),
wxAUI_TB_DEFAULT_STYLE = 0
};
enum wxAuiToolBarArtSetting
{
wxAUI_TBART_SEPARATOR_SIZE = 0,
wxAUI_TBART_GRIPPER_SIZE = 1,
wxAUI_TBART_OVERFLOW_SIZE = 2,
wxAUI_TBART_DROPDOWN_SIZE = 3
};
enum wxAuiToolBarToolTextOrientation
{
wxAUI_TBTOOL_TEXT_LEFT = 0, // unused/unimplemented
wxAUI_TBTOOL_TEXT_RIGHT = 1,
wxAUI_TBTOOL_TEXT_TOP = 2, // unused/unimplemented
wxAUI_TBTOOL_TEXT_BOTTOM = 3
};
// aui toolbar event class
class WXDLLIMPEXP_AUI wxAuiToolBarEvent : public wxNotifyEvent
{
public:
wxAuiToolBarEvent(wxEventType commandType = wxEVT_NULL,
int winId = 0)
: wxNotifyEvent(commandType, winId)
, m_clickPt(-1, -1)
, m_rect(-1, -1, 0, 0)
{
m_isDropdownClicked = false;
m_toolId = -1;
}
wxNODISCARD wxEvent *Clone() const override { return new wxAuiToolBarEvent(*this); }
bool IsDropDownClicked() const { return m_isDropdownClicked; }
void SetDropDownClicked(bool c) { m_isDropdownClicked = c; }
wxPoint GetClickPoint() const { return m_clickPt; }
void SetClickPoint(const wxPoint& p) { m_clickPt = p; }
wxRect GetItemRect() const { return m_rect; }
void SetItemRect(const wxRect& r) { m_rect = r; }
int GetToolId() const { return m_toolId; }
void SetToolId(int toolId) { m_toolId = toolId; }
private:
bool m_isDropdownClicked;
wxPoint m_clickPt;
wxRect m_rect;
int m_toolId;
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxAuiToolBarEvent);
};
class WXDLLIMPEXP_AUI wxAuiToolBarItem
{
friend class wxAuiToolBar;
public:
wxAuiToolBarItem()
{
m_window = nullptr;
m_sizerItem = nullptr;
m_spacerPixels = 0;
m_toolId = 0;
m_kind = wxITEM_NORMAL;
m_state = 0; // normal, enabled
m_proportion = 0;
m_active = true;
m_dropDown = true;
m_sticky = true;
m_userData = 0;
m_clientData = nullptr;
m_alignment = wxALIGN_CENTER;
}
void Assign(const wxAuiToolBarItem& c)
{
m_window = c.m_window;
m_label = c.m_label;
m_bitmap = c.m_bitmap;
m_disabledBitmap = c.m_disabledBitmap;
m_hoverBitmap = c.m_hoverBitmap;
m_shortHelp = c.m_shortHelp;
m_longHelp = c.m_longHelp;
m_sizerItem = c.m_sizerItem;
m_minSize = c.m_minSize;
m_spacerPixels = c.m_spacerPixels;
m_toolId = c.m_toolId;
m_kind = c.m_kind;
m_state = c.m_state;
m_proportion = c.m_proportion;
m_active = c.m_active;
m_dropDown = c.m_dropDown;
m_sticky = c.m_sticky;
m_userData = c.m_userData;
m_clientData = c.m_clientData;
m_alignment = c.m_alignment;
}
void SetWindow(wxWindow* w) { m_window = w; }
wxWindow* GetWindow() { return m_window; }
void SetId(int newId) { m_toolId = newId; }
int GetId() const { return m_toolId; }
void SetKind(int newKind) { m_kind = newKind; }
int GetKind() const { return m_kind; }
void SetState(int newState) { m_state = newState; }
int GetState() const { return m_state; }
void SetSizerItem(wxSizerItem* s) { m_sizerItem = s; }
wxSizerItem* GetSizerItem() const { return m_sizerItem; }
void SetLabel(const wxString& s) { m_label = s; }
const wxString& GetLabel() const { return m_label; }
void SetBitmap(const wxBitmapBundle& bmp) { m_bitmap = bmp; }
const wxBitmapBundle& GetBitmapBundle() const { return m_bitmap; }
wxBitmap GetBitmapFor(wxWindow* wnd) const { return m_bitmap.GetBitmapFor(wnd); }
wxBitmap GetBitmap() const { return GetBitmapFor(m_window); }
void SetDisabledBitmap(const wxBitmapBundle& bmp) { m_disabledBitmap = bmp; }
const wxBitmapBundle& GetDisabledBitmapBundle() const { return m_disabledBitmap; }
wxBitmap GetDisabledBitmapFor(wxWindow* wnd) const { return m_disabledBitmap.GetBitmapFor(wnd); }
wxBitmap GetDisabledBitmap() const { return GetDisabledBitmapFor(m_window); }
// Return the bitmap for the current state, normal or disabled.
wxBitmap GetCurrentBitmapFor(wxWindow* wnd) const;
void SetHoverBitmap(const wxBitmapBundle& bmp) { m_hoverBitmap = bmp; }
const wxBitmapBundle& GetHoverBitmapBundle() const { return m_hoverBitmap; }
wxBitmap GetHoverBitmap() const { return m_hoverBitmap.GetBitmapFor(m_window); }
void SetShortHelp(const wxString& s) { m_shortHelp = s; }
const wxString& GetShortHelp() const { return m_shortHelp; }
void SetLongHelp(const wxString& s) { m_longHelp = s; }
const wxString& GetLongHelp() const { return m_longHelp; }
void SetMinSize(const wxSize& s) { m_minSize = s; }
const wxSize& GetMinSize() const { return m_minSize; }
void SetSpacerPixels(int s) { m_spacerPixels = s; }
int GetSpacerPixels() const { return m_spacerPixels; }
void SetProportion(int p) { m_proportion = p; }
int GetProportion() const { return m_proportion; }
void SetActive(bool b) { m_active = b; }
bool IsActive() const { return m_active; }
void SetHasDropDown(bool b)
{
wxCHECK_RET( !b || m_kind == wxITEM_NORMAL,
wxS("Only normal tools can have drop downs") );
m_dropDown = b;
}
bool HasDropDown() const { return m_dropDown; }
void SetSticky(bool b) { m_sticky = b; }
bool IsSticky() const { return m_sticky; }
void SetUserData(long l) { m_userData = l; }
long GetUserData() const { return m_userData; }
void SetClientData(wxObject* l) { m_clientData = l; }
wxObject* GetClientData() const { return m_clientData; }
void SetAlignment(int l) { m_alignment = l; }
int GetAlignment() const { return m_alignment; }
bool CanBeToggled() const
{
return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO;
}
private:
wxWindow* m_window; // item's associated window
wxString m_label; // label displayed on the item
wxBitmapBundle m_bitmap; // item's bitmap
wxBitmapBundle m_disabledBitmap; // item's disabled bitmap
wxBitmapBundle m_hoverBitmap; // item's hover bitmap
wxString m_shortHelp; // short help (for tooltip)
wxString m_longHelp; // long help (for status bar)
wxSizerItem* m_sizerItem; // sizer item
wxSize m_minSize; // item's minimum size
int m_spacerPixels; // size of a spacer
int m_toolId; // item's id
int m_kind; // item's kind
int m_state; // state
int m_proportion; // proportion
bool m_active; // true if the item is currently active
bool m_dropDown; // true if the item has a dropdown button
bool m_sticky; // overrides button states if true (always active)
long m_userData; // number associated with the item
wxObject* m_clientData; // pointer to a wxObject associated with the item
int m_alignment; // sizer alignment flag, defaults to wxCENTER, may be wxEXPAND or any other
};
using wxAuiToolBarItemArray = wxBaseObjectArray<wxAuiToolBarItem>;
// tab art class
class WXDLLIMPEXP_AUI wxAuiToolBarArt
{
public:
wxAuiToolBarArt() = default;
virtual ~wxAuiToolBarArt() = default;
wxNODISCARD virtual wxAuiToolBarArt* Clone() = 0;
virtual void SetFlags(unsigned int flags) = 0;
virtual unsigned int GetFlags() = 0;
virtual void SetFont(const wxFont& font) = 0;
virtual wxFont GetFont() = 0;
virtual void SetTextOrientation(int orientation) = 0;
virtual int GetTextOrientation() = 0;
virtual void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawPlainBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawDropDownButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawControlLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) = 0;
virtual void DrawSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawGripper(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawOverflowButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
int state) = 0;
virtual wxSize GetLabelSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) = 0;
virtual wxSize GetToolSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) = 0;
// This function should be used for querying element sizes in the new code,
// as it scales them by the DPI of the provided window. GetElementSize()
// still exists (and is simpler to override), but is usually _not_ what you
// need.
virtual int GetElementSizeForWindow(int elementId, const wxWindow* window);
// Note that these functions work with the size in DIPs, not physical
// pixels.
virtual int GetElementSize(int elementId) = 0;
virtual void SetElementSize(int elementId, int size) = 0;
virtual int ShowDropDown(
wxWindow* wnd,
const wxAuiToolBarItemArray& items) = 0;
// Provide opportunity for subclasses to recalculate colours
virtual void UpdateColoursFromSystem() {}
};
class WXDLLIMPEXP_AUI wxAuiGenericToolBarArt : public wxAuiToolBarArt
{
public:
wxAuiGenericToolBarArt();
virtual ~wxAuiGenericToolBarArt();
wxNODISCARD virtual wxAuiToolBarArt* Clone() override;
virtual void SetFlags(unsigned int flags) override;
virtual unsigned int GetFlags() override;
virtual void SetFont(const wxFont& font) override;
virtual wxFont GetFont() override;
virtual void SetTextOrientation(int orientation) override;
virtual int GetTextOrientation() override;
virtual void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
virtual void DrawPlainBackground(wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
virtual void DrawLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawDropDownButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawControlLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
virtual void DrawGripper(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
virtual void DrawOverflowButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
int state) override;
virtual wxSize GetLabelSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) override;
virtual wxSize GetToolSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) override;
virtual int GetElementSize(int element) override;
virtual void SetElementSize(int elementId, int size) override;
virtual int ShowDropDown(wxWindow* wnd,
const wxAuiToolBarItemArray& items) override;
virtual void UpdateColoursFromSystem() override;
protected:
wxBitmapBundle m_buttonDropDownBmp;
wxBitmapBundle m_disabledButtonDropDownBmp;
wxBitmapBundle m_overflowBmp;
wxBitmapBundle m_disabledOverflowBmp;
wxColour m_baseColour;
wxColour m_highlightColour;
wxFont m_font;
unsigned int m_flags;
int m_textOrientation;
wxPen m_gripperPen1;
wxPen m_gripperPen2;
wxPen m_gripperPen3;
// These values are in DIPs and not physical pixels.
int m_separatorSize;
int m_gripperSize;
int m_overflowSize;
int m_dropdownSize;
};
class WXDLLIMPEXP_AUI wxAuiToolBar : public wxCustomBackgroundWindow<wxControl>
{
public:
wxAuiToolBar() { Init(); }
wxAuiToolBar(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAUI_TB_DEFAULT_STYLE)
{
Init();
Create(parent, id, pos, size, style);
}
virtual ~wxAuiToolBar();
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAUI_TB_DEFAULT_STYLE);
virtual void SetWindowStyleFlag(long style) override;
void SetArtProvider(wxAuiToolBarArt* art);
wxAuiToolBarArt* GetArtProvider() const;
bool SetFont(const wxFont& font) override;
wxAuiToolBarItem* AddTool(int toolId,
const wxString& label,
const wxBitmapBundle& bitmap,
const wxString& shortHelpString = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL);
wxAuiToolBarItem* AddTool(int toolId,
const wxString& label,
const wxBitmapBundle& bitmap,
const wxBitmapBundle& disabledBitmap,
wxItemKind kind,
const wxString& shortHelpString,
const wxString& longHelpString,
wxObject* clientData);
wxAuiToolBarItem* AddTool(int toolId,
const wxBitmapBundle& bitmap,
const wxBitmapBundle& disabledBitmap,
bool toggle = false,
wxObject* clientData = nullptr,
const wxString& shortHelpString = wxEmptyString,
const wxString& longHelpString = wxEmptyString)
{
return AddTool(toolId,
wxEmptyString,
bitmap,
disabledBitmap,
toggle ? wxITEM_CHECK : wxITEM_NORMAL,
shortHelpString,
longHelpString,
clientData);
}
wxAuiToolBarItem* AddLabel(int toolId,
const wxString& label = wxEmptyString,
const int width = -1);
wxAuiToolBarItem* AddControl(wxControl* control,
const wxString& label = wxEmptyString);
wxAuiToolBarItem* AddSeparator();
wxAuiToolBarItem* AddSpacer(int pixels);
wxAuiToolBarItem* AddStretchSpacer(int proportion = 1);
bool Realize();
wxControl* FindControl(int windowId);
wxAuiToolBarItem* FindToolByPosition(wxCoord x, wxCoord y) const;
wxAuiToolBarItem* FindToolByIndex(int idx) const;
wxAuiToolBarItem* FindTool(int toolId) const;
void ClearTools() { Clear() ; }
void Clear();
bool DestroyTool(int toolId);
bool DestroyToolByIndex(int idx);
// Note that these methods do _not_ delete the associated control, if any.
// Use DestroyTool() or DestroyToolByIndex() if this is wanted.
bool DeleteTool(int toolId);
bool DeleteByIndex(int toolId);
size_t GetToolCount() const;
int GetToolPos(int toolId) const { return GetToolIndex(toolId); }
int GetToolIndex(int toolId) const;
bool GetToolFits(int toolId) const;
wxRect GetToolRect(int toolId) const;
bool GetToolFitsByIndex(int toolId) const;
bool GetToolBarFits() const;
void SetMargins(const wxSize& size) { SetMargins(size.x, size.x, size.y, size.y); }
void SetMargins(int x, int y) { SetMargins(x, x, y, y); }
void SetMargins(int left, int right, int top, int bottom);
void SetToolClientData (int tool_id, wxObject* client_data);
wxObject* GetToolClientData(int tool_id) const;
void SetToolBitmapSize(const wxSize& size);
wxSize GetToolBitmapSize() const;
bool GetOverflowVisible() const;
void SetOverflowVisible(bool visible);
bool GetGripperVisible() const;
void SetGripperVisible(bool visible);
void ToggleTool(int toolId, bool state);
bool GetToolToggled(int toolId) const;
void EnableTool(int toolId, bool state);
bool GetToolEnabled(int toolId) const;
void SetToolDropDown(int toolId, bool dropdown);
bool GetToolDropDown(int toolId) const;
void SetToolBorderPadding(int padding);
int GetToolBorderPadding() const;
void SetToolTextOrientation(int orientation);
int GetToolTextOrientation() const;
void SetToolPacking(int packing);
int GetToolPacking() const;
void SetToolProportion(int toolId, int proportion);
int GetToolProportion(int toolId) const;
void SetToolSeparation(int separation);
int GetToolSeparation() const;
void SetToolSticky(int toolId, bool sticky);
bool GetToolSticky(int toolId) const;
wxString GetToolLabel(int toolId) const;
void SetToolLabel(int toolId, const wxString& label);
wxBitmap GetToolBitmap(int toolId) const;
void SetToolBitmap(int toolId, const wxBitmapBundle& bitmap);
wxString GetToolShortHelp(int toolId) const;
void SetToolShortHelp(int toolId, const wxString& helpString);
wxString GetToolLongHelp(int toolId) const;
void SetToolLongHelp(int toolId, const wxString& helpString);
void SetCustomOverflowItems(const wxAuiToolBarItemArray& prepend,
const wxAuiToolBarItemArray& append);
// get size of hint rectangle for a particular dock location
wxSize GetHintSize(int dockDirection) const;
bool IsPaneValid(const wxAuiPaneInfo& pane) const;
// Override to call DoIdleUpdate().
virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE) override;
protected:
void Init();
// Override to return the minimum acceptable size because under wxMSW this
// function returns DEFAULT_ITEM_HEIGHT (see wxControl::DoGetBestSize())
// which is not suitable as height/width for a horizontal/vertical toolbar
// if icon sizes are much smaller than DEFAULT_ITEM_HEIGHT.
virtual wxSize DoGetBestSize() const override;
virtual void OnCustomRender(wxDC& WXUNUSED(dc),
const wxAuiToolBarItem& WXUNUSED(item),
const wxRect& WXUNUSED(rect)) { }
protected:
void DoIdleUpdate();
void SetOrientation(int orientation);
void SetHoverItem(wxAuiToolBarItem* item);
void SetPressedItem(wxAuiToolBarItem* item);
void RefreshOverflowState();
int GetOverflowState() const;
wxRect GetOverflowRect() const;
wxSize GetLabelSize(const wxString& label);
wxAuiToolBarItem* FindToolByPositionWithPacking(wxCoord x, wxCoord y) const;
protected: // handlers
void OnSize(wxSizeEvent& evt);
void OnIdle(wxIdleEvent& evt);
void OnDPIChanged(wxDPIChangedEvent& evt);
void OnPaint(wxPaintEvent& evt);
void OnLeftDown(wxMouseEvent& evt);
void OnLeftUp(wxMouseEvent& evt);
void OnRightDown(wxMouseEvent& evt);
void OnRightUp(wxMouseEvent& evt);
void OnMiddleDown(wxMouseEvent& evt);
void OnMiddleUp(wxMouseEvent& evt);
void OnMotion(wxMouseEvent& evt);
void OnLeaveWindow(wxMouseEvent& evt);
void OnCaptureLost(wxMouseCaptureLostEvent& evt);
void OnSetCursor(wxSetCursorEvent& evt);
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
wxAuiToolBarItemArray m_items; // array of toolbar items
wxAuiToolBarArt* m_art; // art provider
wxBoxSizer* m_sizer; // main sizer for toolbar
wxAuiToolBarItem* m_actionItem; // item that's being acted upon (pressed)
wxAuiToolBarItem* m_tipItem; // item that has its tooltip shown
wxBitmap m_bitmap; // double-buffer bitmap
wxSizerItem* m_gripperSizerItem;
wxSizerItem* m_overflowSizerItem;
wxSize m_absoluteMinSize;
wxPoint m_actionPos; // position of left-mouse down
wxAuiToolBarItemArray m_customOverflowPrepend;
wxAuiToolBarItemArray m_customOverflowAppend;
int m_buttonWidth;
int m_buttonHeight;
int m_sizerElementCount;
int m_leftPadding;
int m_rightPadding;
int m_topPadding;
int m_bottomPadding;
int m_toolPacking;
int m_toolBorderPadding;
int m_toolTextOrientation;
int m_overflowState;
bool m_dragging;
bool m_gripperVisible;
bool m_overflowVisible;
// This function is only kept for compatibility, don't use in the new code.
bool RealizeHelper(wxClientDC& dc, bool horizontal);
static bool IsPaneValid(long style, const wxAuiPaneInfo& pane);
bool IsPaneValid(long style) const;
void SetArtFlags() const;
wxOrientation m_orientation;
wxSize m_horzHintSize;
wxSize m_vertHintSize;
private:
// Common part of OnLeaveWindow() and OnCaptureLost().
void DoResetMouseState();
wxSize RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation);
void UpdateBackgroundBitmap(const wxSize& size);
wxBitmap m_backgroundBitmap;
wxDECLARE_EVENT_TABLE();
wxDECLARE_CLASS(wxAuiToolBar);
};
// wx event machinery
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_TOOL_DROPDOWN, wxAuiToolBarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_OVERFLOW_CLICK, wxAuiToolBarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_MIDDLE_CLICK, wxAuiToolBarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUITOOLBAR_BEGIN_DRAG, wxAuiToolBarEvent );
typedef void (wxEvtHandler::*wxAuiToolBarEventFunction)(wxAuiToolBarEvent&);
#define wxAuiToolBarEventHandler(func) \
wxEVENT_HANDLER_CAST(wxAuiToolBarEventFunction, func)
#define EVT_AUITOOLBAR_TOOL_DROPDOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_TOOL_DROPDOWN, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_OVERFLOW_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_OVERFLOW_CLICK, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_RIGHT_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_RIGHT_CLICK, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_MIDDLE_CLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_MIDDLE_CLICK, winid, wxAuiToolBarEventHandler(fn))
#define EVT_AUITOOLBAR_BEGIN_DRAG(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUITOOLBAR_BEGIN_DRAG, winid, wxAuiToolBarEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_AUITOOLBAR_TOOL_DROPDOWN;
%constant wxEventType wxEVT_AUITOOLBAR_OVERFLOW_CLICK;
%constant wxEventType wxEVT_AUITOOLBAR_RIGHT_CLICK;
%constant wxEventType wxEVT_AUITOOLBAR_MIDDLE_CLICK;
%constant wxEventType wxEVT_AUITOOLBAR_BEGIN_DRAG;
%pythoncode {
EVT_AUITOOLBAR_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_AUITOOLBAR_TOOL_DROPDOWN, 1 )
EVT_AUITOOLBAR_OVERFLOW_CLICK = wx.PyEventBinder( wxEVT_AUITOOLBAR_OVERFLOW_CLICK, 1 )
EVT_AUITOOLBAR_RIGHT_CLICK = wx.PyEventBinder( wxEVT_AUITOOLBAR_RIGHT_CLICK, 1 )
EVT_AUITOOLBAR_MIDDLE_CLICK = wx.PyEventBinder( wxEVT_AUITOOLBAR_MIDDLE_CLICK, 1 )
EVT_AUITOOLBAR_BEGIN_DRAG = wx.PyEventBinder( wxEVT_AUITOOLBAR_BEGIN_DRAG, 1 )
}
#endif // SWIG
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN wxEVT_AUITOOLBAR_TOOL_DROPDOWN
#define wxEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK wxEVT_AUITOOLBAR_OVERFLOW_CLICK
#define wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK wxEVT_AUITOOLBAR_RIGHT_CLICK
#define wxEVT_COMMAND_AUITOOLBAR_MIDDLE_CLICK wxEVT_AUITOOLBAR_MIDDLE_CLICK
#define wxEVT_COMMAND_AUITOOLBAR_BEGIN_DRAG wxEVT_AUITOOLBAR_BEGIN_DRAG
#if defined(__WXMSW__) && wxUSE_UXTHEME
#define wxHAS_NATIVE_TOOLBAR_ART
#include "wx/aui/barartmsw.h"
#define wxAuiDefaultToolBarArt wxAuiMSWToolBarArt
#endif
#ifndef wxHAS_NATIVE_TOOLBAR_ART
#define wxAuiDefaultToolBarArt wxAuiGenericToolBarArt
#endif
#endif // wxUSE_AUI
#endif // _WX_AUIBAR_H_

View File

@@ -0,0 +1,810 @@
//////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/auibook.h
// Purpose: wxaui: wx advanced user interface - notebook
// Author: Benjamin I. Williams
// Modified by: Jens Lody
// Created: 2006-06-28
// Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUINOTEBOOK_H_
#define _WX_AUINOTEBOOK_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/aui/tabart.h"
#include "wx/aui/framemanager.h"
#include "wx/compositebookctrl.h"
#include <vector>
class wxAuiBookSerializer;
class wxAuiBookDeserializer;
class wxAuiNotebook;
class wxAuiTabFrame;
enum wxAuiNotebookOption
{
wxAUI_NB_TOP = 1 << 0,
wxAUI_NB_LEFT = 1 << 1, // not implemented yet
wxAUI_NB_RIGHT = 1 << 2, // not implemented yet
wxAUI_NB_BOTTOM = 1 << 3,
wxAUI_NB_TAB_SPLIT = 1 << 4,
wxAUI_NB_TAB_MOVE = 1 << 5,
wxAUI_NB_TAB_EXTERNAL_MOVE = 1 << 6,
wxAUI_NB_TAB_FIXED_WIDTH = 1 << 7,
wxAUI_NB_SCROLL_BUTTONS = 1 << 8,
wxAUI_NB_WINDOWLIST_BUTTON = 1 << 9,
wxAUI_NB_CLOSE_BUTTON = 1 << 10,
wxAUI_NB_CLOSE_ON_ACTIVE_TAB = 1 << 11,
wxAUI_NB_CLOSE_ON_ALL_TABS = 1 << 12,
wxAUI_NB_MIDDLE_CLICK_CLOSE = 1 << 13,
wxAUI_NB_MULTILINE = 1 << 14,
wxAUI_NB_PIN_ON_ACTIVE_TAB = 1 << 15,
wxAUI_NB_UNPIN_ON_ALL_PINNED = 1 << 16,
wxAUI_NB_DEFAULT_STYLE = wxAUI_NB_TOP |
wxAUI_NB_TAB_SPLIT |
wxAUI_NB_TAB_MOVE |
wxAUI_NB_SCROLL_BUTTONS |
wxAUI_NB_CLOSE_ON_ACTIVE_TAB |
wxAUI_NB_MIDDLE_CLICK_CLOSE
};
wxALLOW_COMBINING_ENUMS(wxAuiNotebookOption, wxBorder)
// aui notebook event class
class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxBookCtrlEvent
{
public:
wxAuiNotebookEvent(wxEventType commandType = wxEVT_NULL,
int winId = 0)
: wxBookCtrlEvent(commandType, winId)
{
m_dragSource = nullptr;
}
wxNODISCARD wxEvent *Clone() const override { return new wxAuiNotebookEvent(*this); }
void SetDragSource(wxAuiNotebook* s) { m_dragSource = s; }
wxAuiNotebook* GetDragSource() const { return m_dragSource; }
private:
wxAuiNotebook* m_dragSource;
#ifndef SWIG
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxAuiNotebookEvent);
#endif
};
class WXDLLIMPEXP_AUI wxAuiTabContainerButton
{
public:
wxAuiTabContainerButton() = default;
wxAuiTabContainerButton(
int id_,
int location_,
wxAuiPaneButtonState curState_ = wxAUI_BUTTON_STATE_NORMAL
) : id(id_), curState(curState_), location(location_)
{
}
int id = 0; // button's id
int curState = 0; // current state (normal, hover, pressed, etc.)
int location = 0; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
wxBitmapBundle bitmap; // button's hover bitmap
wxBitmapBundle disBitmap; // button's disabled bitmap
wxRect rect; // button's hit rectangle
};
// Possible tab states.
enum class wxAuiTabKind
{
Normal, // Can be closed and dragged by user.
Pinned, // Can be closed but can't be dragged. Can be unpinned by user.
Locked // Can't be closed, dragged nor unlocked by user.
};
class WXDLLIMPEXP_AUI wxAuiNotebookPage
{
public:
wxWindow* window = nullptr; // page's associated window
wxString caption; // caption displayed on the tab
wxString tooltip; // tooltip displayed when hovering over tab title
wxBitmapBundle bitmap;// tab's bitmap
wxAuiTabKind kind = wxAuiTabKind::Normal; // tab's kind
wxRect rect; // tab's hit rectangle (only used internally)
bool active = false; // true if the page is currently active
// These fields are internal, don't use them.
bool hover = false; // true if mouse hovering over tab
bool rowEnd = false; // true if the tab is the last in the row
// This vector contains per-page buttons, i.e. "close" and, optionally,
// "pin" buttons. It can be empty if none are used.
std::vector<wxAuiTabContainerButton> buttons;
};
// These legacy classes can't be just typedefs as they can be (and are)
// forward-declared in the existing code.
class wxAuiNotebookPageArray : public wxBaseArray<wxAuiNotebookPage>
{
public:
using wxBaseArray<wxAuiNotebookPage>::wxBaseArray;
};
class wxAuiTabContainerButtonArray : public wxBaseArray<wxAuiTabContainerButton>
{
public:
using wxBaseArray<wxAuiTabContainerButton>::wxBaseArray;
};
class WXDLLIMPEXP_AUI wxAuiTabContainer
{
public:
wxAuiTabContainer();
virtual ~wxAuiTabContainer();
void SetArtProvider(wxAuiTabArt* art);
wxAuiTabArt* GetArtProvider() const;
void SetFlags(unsigned int flags);
unsigned int GetFlags() const { return m_flags; }
bool IsFlagSet(unsigned int flag) const { return (m_flags & flag) != 0; }
bool AddPage(const wxAuiNotebookPage& info);
bool InsertPage(const wxAuiNotebookPage& info, size_t idx);
bool MovePage(wxWindow* page, size_t newIdx);
bool MovePage(size_t oldIdx, size_t newIdx);
bool RemovePage(wxWindow* page);
void RemovePageAt(size_t idx);
bool SetActivePage(const wxWindow* page);
bool SetActivePage(size_t page);
void SetNoneActive();
int GetActivePage() const;
// Struct containing the result of a tab hit test.
struct HitTestResult
{
HitTestResult() = default;
HitTestResult(wxWindow* window_, int pos_)
: window(window_), pos(pos_)
{
}
// Check if the result is valid.
explicit operator bool() const { return window != nullptr; }
// The window at the given position or null if none.
wxWindow* window = nullptr;
// The position of the tab in the tab control.
int pos = wxNOT_FOUND;
};
// Flags allowing to customize the behaviour of TabHitTest().
enum HitTestFlags
{
HitTest_Default = 0,
HitTest_AllowAfterTab = 1
};
HitTestResult TabHitTest(const wxPoint& pt, int flags = HitTest_Default) const;
wxAuiTabContainerButton* ButtonHitTest(const wxPoint& pt) const;
wxWindow* GetWindowFromIdx(size_t idx) const;
int GetIdxFromWindow(const wxWindow* page) const;
size_t GetPageCount() const;
wxAuiNotebookPage& GetPage(size_t idx);
const wxAuiNotebookPage& GetPage(size_t idx) const;
const wxAuiNotebookPageArray& GetPages() const;
void SetNormalFont(const wxFont& normalFont);
void SetSelectedFont(const wxFont& selectedFont);
void SetMeasuringFont(const wxFont& measuringFont);
void SetColour(const wxColour& colour);
void SetActiveColour(const wxColour& colour);
void DoShowHide();
void SetRect(const wxRect& rect, wxWindow* wnd = nullptr);
void SetRowHeight(int rowHeight);
void RemoveButton(int id);
void AddButton(int id,
int location,
const wxBitmapBundle& normalBitmap = wxBitmapBundle(),
const wxBitmapBundle& disabledBitmap = wxBitmapBundle());
size_t GetTabOffset() const;
void SetTabOffset(size_t offset);
// Is the tab visible?
bool IsTabVisible(int tabPage, int tabOffset, wxReadOnlyDC* dc, wxWindow* wnd);
// Make the tab visible if it wasn't already
void MakeTabVisible(int tabPage, wxWindow* win);
// Internal, don't use.
void RemoveAll();
// Backwards compatible variants of internal functions, which shouldn't be
// used anyhow.
bool AddPage(wxWindow* page, wxAuiNotebookPage info)
{
info.window = page;
return AddPage(info);
}
bool InsertPage(wxWindow* page, wxAuiNotebookPage info, size_t idx)
{
info.window = page;
return InsertPage(info, idx);
}
bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const
{
auto* const button = ButtonHitTest(wxPoint(x, y));
if ( hit )
*hit = button;
return button != nullptr;
}
bool TabHitTest(int x, int y, wxWindow** hit) const
{
auto const res = TabHitTest(wxPoint(x, y));
if ( hit )
*hit = res.window;
return res.window != nullptr;
}
// Internal functions only, don't use.
// Layout tabs in wxAUI_NB_MULTILINE case using either the width of the
// given rectangle or the current width and return the extra height needed
// for the additional rows.
//
// This function has an important side effect of updating rowEnd for all
// pages -- which defines the layout.
int LayoutMultiLineTabs(const wxRect& rect, wxWindow* wnd);
int LayoutMultiLineTabs(wxWindow* wnd)
{
return LayoutMultiLineTabs(m_rect, wnd);
}
// Get the index of the first tab of the given kind or of a different kind,
// returning GetPageCount() if there is no such tabs.
int GetFirstTabOfKind(wxAuiTabKind kind) const;
int GetFirstTabNotOfKind(wxAuiTabKind kind) const;
protected:
virtual void Render(wxDC* dc, wxWindow* wnd);
protected:
wxAuiTabArt* m_art;
// Contains pages in the display order.
wxAuiNotebookPageArray m_pages;
// This vector contains container-level buttons, e.g. left/right scroll
// buttons, close button if it's not per-tab, window list button etc.
std::vector<wxAuiTabContainerButton> m_buttons;
wxRect m_rect;
size_t m_tabOffset;
unsigned int m_flags;
private:
// Return the width that can be used for the tabs, i.e. without the space
// reserved for the buttons.
int GetAvailableForTabs(const wxRect& rect, wxReadOnlyDC& dc, wxWindow* wnd);
// Render the buttons: part of Render(), returns the extent of the buttons
// on the left and right side.
void RenderButtons(wxDC& dc, wxWindow* wnd,
int& left_buttons_width, int& right_buttons_width);
// Update the state of the page buttons depending on its state and flags.
//
// If forceActive is true, the page is always considered as active, see the
// comment in LayoutMultiLineTabs() for the reason why this is needed.
void UpdateButtonsState(wxAuiNotebookPage& page, bool forceActive = false);
int m_tabRowHeight;
};
class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
public wxAuiTabContainer
{
public:
wxAuiTabCtrl(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
~wxAuiTabCtrl();
bool IsDragging() const { return m_isDragging; }
void SetRect(const wxRect& rect) { wxAuiTabContainer::SetRect(rect, this); }
// Internal helpers.
void DoShowTab(int idx);
void DoUpdateActive();
// Internal function taking the total tab frame area and setting the size
// of the window to its sub-rectangle corresponding to tabs orientation.
//
// Also updates rowEnd for all pages in m_pages when using multiple rows.
void DoApplyRect(const wxRect& rect, int tabCtrlHeight);
// Another internal helper: return the hint rectangle corresponding to this
// tab control in screen coordinates.
wxRect GetHintScreenRect() const;
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
void OnPaint(wxPaintEvent& evt);
void OnEraseBackground(wxEraseEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnLeftDown(wxMouseEvent& evt);
void OnLeftDClick(wxMouseEvent& evt);
void OnLeftUp(wxMouseEvent& evt);
void OnMiddleDown(wxMouseEvent& evt);
void OnMiddleUp(wxMouseEvent& evt);
void OnRightDown(wxMouseEvent& evt);
void OnRightUp(wxMouseEvent& evt);
void OnMotion(wxMouseEvent& evt);
void OnLeaveWindow(wxMouseEvent& evt);
void OnButton(wxAuiNotebookEvent& evt);
void OnSetFocus(wxFocusEvent& event);
void OnKillFocus(wxFocusEvent& event);
void OnChar(wxKeyEvent& event);
void OnCaptureLost(wxMouseCaptureLostEvent& evt);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnDpiChanged(wxDPIChangedEvent& event);
protected:
wxPoint m_clickPt = wxDefaultPosition;
wxWindow* m_clickTab = nullptr;
bool m_isDragging = false;
wxAuiTabContainerButton* m_hoverButton = nullptr;
wxAuiTabContainerButton* m_pressedButton = nullptr;
void SetHoverTab(wxWindow* wnd);
private:
// Reset dragging-related fields above to their initial values.
void DoEndDragging();
#ifndef SWIG
wxDECLARE_CLASS(wxAuiTabCtrl);
wxDECLARE_EVENT_TABLE();
#endif
// Rectangle corresponding to the full tab control area, including both
// tabs (which is this window) and the page area.
wxRect m_fullRect;
};
// Simple struct combining wxAuiTabCtrl with the position inside it.
struct wxAuiNotebookPosition
{
wxAuiNotebookPosition() = default;
wxAuiNotebookPosition(wxAuiTabCtrl* tabCtrl_, int tabIdx_)
: tabCtrl(tabCtrl_), tabIdx(tabIdx_)
{
}
// Check if the position is valid.
explicit operator bool() const { return tabCtrl != nullptr; }
wxAuiTabCtrl* tabCtrl = nullptr;
int tabIdx = wxNOT_FOUND;
};
class WXDLLIMPEXP_AUI wxAuiNotebook : public wxCompositeBookCtrlBase
{
public:
wxAuiNotebook() { Init(); }
wxAuiNotebook(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAUI_NB_DEFAULT_STYLE)
{
Init();
Create(parent, id, pos, size, style);
}
virtual ~wxAuiNotebook();
bool Create(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
void SetWindowStyleFlag(long style) override;
void SetArtProvider(wxAuiTabArt* art);
wxAuiTabArt* GetArtProvider() const;
virtual void SetUniformBitmapSize(const wxSize& size);
virtual void SetTabCtrlHeight(int height);
bool AddPage(wxWindow* page,
const wxString& caption,
bool select = false,
const wxBitmapBundle& bitmap = wxBitmapBundle());
bool InsertPage(size_t pageIdx,
wxWindow* page,
const wxString& caption,
bool select = false,
const wxBitmapBundle& bitmap = wxBitmapBundle());
virtual size_t GetPageCount() const override;
virtual wxWindow* GetPage(size_t pageIdx) const override;
virtual int FindPage(const wxWindow* page) const override;
// This is wxAUI-specific equivalent of FindPage(), prefer to use the other
// function.
int GetPageIndex(wxWindow* pageWnd) const { return FindPage(pageWnd); }
bool SetPageText(size_t page, const wxString& text) override;
wxString GetPageText(size_t pageIdx) const override;
bool SetPageToolTip(size_t page, const wxString& text);
wxString GetPageToolTip(size_t pageIdx) const;
bool SetPageBitmap(size_t page, const wxBitmapBundle& bitmap);
wxBitmap GetPageBitmap(size_t pageIdx) const;
wxAuiTabKind GetPageKind(size_t pageIdx) const;
bool SetPageKind(size_t pageIdx, wxAuiTabKind kind);
int SetSelection(size_t newPage) override;
int GetSelection() const override;
// Return the tab control containing the page with the given index and its
// visual position in it (i.e. 0 for the leading one).
wxAuiNotebookPosition GetPagePosition(size_t page) const;
// Return all pages in the given tab control in display order.
std::vector<size_t> GetPagesInDisplayOrder(wxAuiTabCtrl* tabCtrl) const;
void Split(size_t page, int direction);
void UnsplitAll();
const wxAuiManager& GetAuiManager() const { return m_mgr; }
void SetManagerFlags(unsigned int flags) { m_mgr.SetFlags(flags); }
// Sets the normal font
void SetNormalFont(const wxFont& font);
// Sets the selected tab font
void SetSelectedFont(const wxFont& font);
// Sets the measuring font
void SetMeasuringFont(const wxFont& font);
// Sets the tab font
virtual bool SetFont(const wxFont& font) override;
// Gets the tab control height
int GetTabCtrlHeight() const;
// Gets the height of the notebook for a given page height
int GetHeightForPageHeight(int pageHeight);
// Shows the window menu
bool ShowWindowMenu();
//wxBookCtrlBase functions
virtual void SetPageSize (const wxSize &size) override;
virtual int HitTest (const wxPoint &pt, long *flags=nullptr) const override;
virtual int GetPageImage(size_t n) const override;
virtual bool SetPageImage(size_t n, int imageId) override;
virtual int ChangeSelection(size_t n) override;
virtual bool AddPage(wxWindow *page, const wxString &text, bool select,
int imageId) override;
virtual bool DeleteAllPages() override;
virtual bool InsertPage(size_t index, wxWindow *page, const wxString &text,
bool select, int imageId) override;
virtual wxSize DoGetBestSize() const override;
wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt);
wxAuiTabCtrl* GetActiveTabCtrl();
// Get main tab control, creating it on demand if necessary.
wxAuiTabCtrl* GetMainTabCtrl();
// Get all tab controls.
std::vector<wxAuiTabCtrl*> GetAllTabCtrls();
// Internal, don't use: use GetPagePosition() instead.
bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx) const;
// Serialization support: this is used by wxAuiManager but can also be
// called directly to save/load layout of just this notebook.
void SaveLayout(const wxString& name, wxAuiBookSerializer& serializer) const;
void LoadLayout(const wxString& name, wxAuiBookDeserializer& deserializer);
protected:
// Common part of all ctors.
void Init();
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
// Redo sizing after thawing
virtual void DoThaw() override;
// these can be overridden
// update the height, return true if it was done or false if the new height
// calculated by CalculateTabCtrlHeight() is the same as the old one
virtual bool UpdateTabCtrlHeight();
virtual int CalculateTabCtrlHeight();
virtual wxSize CalculateNewSplitSize();
// get next page in physical (display) order
virtual int GetNextPage(bool forward) const override;
// remove the page and return a pointer to it
virtual wxWindow *DoRemovePage(size_t page) override;
//A general selection function
virtual int DoModifySelection(size_t n, bool events);
protected:
void DoSizing();
void InitNotebook(long style);
wxWindow* GetTabFrameFromTabCtrl(wxWindow* tabCtrl);
void RemoveEmptyTabFrames();
void UpdateHintWindowSize();
protected:
void OnChildFocusNotebook(wxChildFocusEvent& evt);
void OnRender(wxAuiManagerEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnTabClicked(wxAuiNotebookEvent& evt);
void OnTabBeginDrag(wxAuiNotebookEvent& evt);
void OnTabDragMotion(wxAuiNotebookEvent& evt);
void OnTabEndDrag(wxAuiNotebookEvent& evt);
void OnTabCancelDrag(wxAuiNotebookEvent& evt);
void OnTabButton(wxAuiNotebookEvent& evt);
void OnTabMiddleDown(wxAuiNotebookEvent& evt);
void OnTabMiddleUp(wxAuiNotebookEvent& evt);
void OnTabRightDown(wxAuiNotebookEvent& evt);
void OnTabRightUp(wxAuiNotebookEvent& evt);
void OnTabBgDClick(wxAuiNotebookEvent& evt);
void OnNavigationKeyNotebook(wxNavigationKeyEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnDpiChanged(wxDPIChangedEvent& event);
// set selection to the given window (which must be non-null and be one of
// our pages, otherwise an assert is raised)
void SetSelectionToWindow(wxWindow *win);
void SetSelectionToPage(const wxAuiNotebookPage& page)
{
SetSelectionToWindow(page.window);
}
protected:
wxAuiManager m_mgr;
// Contains all pages in the insertion order.
wxAuiTabContainer m_tabs;
// Current page index in m_tabs or wxNOT_FOUND if none.
int m_curPage;
int m_tabIdCounter;
wxWindow* m_dummyWnd;
wxSize m_requestedBmpSize;
int m_requestedTabCtrlHeight;
wxFont m_selectedFont;
wxFont m_normalFont;
int m_tabCtrlHeight;
int m_lastDropMovePos = -1;
unsigned int m_flags;
private:
// Create a new tab frame, containing a new wxAuiTabCtrl.
wxAuiTabFrame* CreateTabFrame(wxSize size = wxSize());
// Inserts the page at the given position into the given tab control.
void InsertPageAt(wxAuiNotebookPage& info,
size_t page_idx,
wxAuiTabCtrl* tabctrl,
int tab_page_idx, // Can be -1 to append.
bool select);
struct TabInfo;
TabInfo FindTab(wxWindow* page) const;
// Return the index at which the given page should be inserted in this tab
// control if it's dropped at the given (in screen coordinates) point or
// wxNOT_FOUND if dropping it is not allowed.
int GetDropIndex(const wxAuiNotebookPage& srcPage,
wxAuiTabCtrl* tabCtrl,
const wxPoint& ptScreen) const;
#ifndef SWIG
wxDECLARE_CLASS(wxAuiNotebook);
wxDECLARE_EVENT_TABLE();
#endif
};
// wx event machinery
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_BUTTON, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_BEGIN_DRAG, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_END_DRAG, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_DRAG_MOTION, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_ALLOW_DND, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_DRAG_DONE, wxAuiNotebookEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_AUI, wxEVT_AUINOTEBOOK_BG_DCLICK, wxAuiNotebookEvent);
typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
#define wxAuiNotebookEventHandler(func) \
wxEVENT_HANDLER_CAST(wxAuiNotebookEventFunction, func)
#define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_PAGE_CLOSED, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_DRAG_DONE(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_DRAG_DONE, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_TAB_RIGHT_DOWN(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, winid, wxAuiNotebookEventHandler(fn))
#define EVT_AUINOTEBOOK_BG_DCLICK(winid, fn) \
wx__DECLARE_EVT1(wxEVT_AUINOTEBOOK_BG_DCLICK, winid, wxAuiNotebookEventHandler(fn))
#else
// wxpython/swig event work
%constant wxEventType wxEVT_AUINOTEBOOK_PAGE_CLOSE;
%constant wxEventType wxEVT_AUINOTEBOOK_PAGE_CLOSED;
%constant wxEventType wxEVT_AUINOTEBOOK_PAGE_CHANGED;
%constant wxEventType wxEVT_AUINOTEBOOK_PAGE_CHANGING;
%constant wxEventType wxEVT_AUINOTEBOOK_BUTTON;
%constant wxEventType wxEVT_AUINOTEBOOK_BEGIN_DRAG;
%constant wxEventType wxEVT_AUINOTEBOOK_END_DRAG;
%constant wxEventType wxEVT_AUINOTEBOOK_DRAG_MOTION;
%constant wxEventType wxEVT_AUINOTEBOOK_ALLOW_DND;
%constant wxEventType wxEVT_AUINOTEBOOK_DRAG_DONE;
%constant wxEventType wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN;
%constant wxEventType wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP;
%constant wxEventType wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN;
%constant wxEventType wxEVT_AUINOTEBOOK_TAB_RIGHT_UP;
%constant wxEventType wxEVT_AUINOTEBOOK_BG_DCLICK;
%pythoncode {
EVT_AUINOTEBOOK_PAGE_CLOSE = wx.PyEventBinder( wxEVT_AUINOTEBOOK_PAGE_CLOSE, 1 )
EVT_AUINOTEBOOK_PAGE_CLOSED = wx.PyEventBinder( wxEVT_AUINOTEBOOK_PAGE_CLOSED, 1 )
EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_AUINOTEBOOK_PAGE_CHANGED, 1 )
EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_AUINOTEBOOK_PAGE_CHANGING, 1 )
EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_AUINOTEBOOK_BUTTON, 1 )
EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_AUINOTEBOOK_BEGIN_DRAG, 1 )
EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_AUINOTEBOOK_END_DRAG, 1 )
EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_AUINOTEBOOK_DRAG_MOTION, 1 )
EVT_AUINOTEBOOK_ALLOW_DND = wx.PyEventBinder( wxEVT_AUINOTEBOOK_ALLOW_DND, 1 )
EVT_AUINOTEBOOK_DRAG_DONE = wx.PyEventBinder( wxEVT_AUINOTEBOOK_DRAG_DONE, 1 )
EVT__AUINOTEBOOK_TAB_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, 1 )
EVT__AUINOTEBOOK_TAB_MIDDLE_UP = wx.PyEventBinder( wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP, 1 )
EVT__AUINOTEBOOK_TAB_RIGHT_DOWN = wx.PyEventBinder( wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN, 1 )
EVT__AUINOTEBOOK_TAB_RIGHT_UP = wx.PyEventBinder( wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, 1 )
EVT_AUINOTEBOOK_BG_DCLICK = wx.PyEventBinder( wxEVT_AUINOTEBOOK_BG_DCLICK, 1 )
}
#endif
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE wxEVT_AUINOTEBOOK_PAGE_CLOSE
#define wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED wxEVT_AUINOTEBOOK_PAGE_CLOSED
#define wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED wxEVT_AUINOTEBOOK_PAGE_CHANGED
#define wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING wxEVT_AUINOTEBOOK_PAGE_CHANGING
#define wxEVT_COMMAND_AUINOTEBOOK_BUTTON wxEVT_AUINOTEBOOK_BUTTON
#define wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG wxEVT_AUINOTEBOOK_BEGIN_DRAG
#define wxEVT_COMMAND_AUINOTEBOOK_END_DRAG wxEVT_AUINOTEBOOK_END_DRAG
#define wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION wxEVT_AUINOTEBOOK_DRAG_MOTION
#define wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND wxEVT_AUINOTEBOOK_ALLOW_DND
#define wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE wxEVT_AUINOTEBOOK_DRAG_DONE
#define wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN
#define wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP
#define wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN
#define wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP wxEVT_AUINOTEBOOK_TAB_RIGHT_UP
#define wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK wxEVT_AUINOTEBOOK_BG_DCLICK
#define wxEVT_COMMAND_AUINOTEBOOK_CANCEL_DRAG wxEVT_AUINOTEBOOK_CANCEL_DRAG
#endif // wxUSE_AUI
#endif // _WX_AUINOTEBOOK_H_

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/barartmsw.h
// Purpose: Interface of wxAuiMSWToolBarArt
// Author: Tobias Taschner
// Created: 2015-09-22
// Copyright: (c) 2015 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUI_BARART_MSW_H_
#define _WX_AUI_BARART_MSW_H_
#include "wx/aui/auibar.h"
#if wxUSE_AUI
class WXDLLIMPEXP_AUI wxAuiMSWToolBarArt : public wxAuiGenericToolBarArt
{
public:
wxAuiMSWToolBarArt();
wxNODISCARD virtual wxAuiToolBarArt* Clone() override;
virtual void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
virtual void DrawLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawDropDownButton(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawControlLabel(
wxDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item,
const wxRect& rect) override;
virtual void DrawSeparator(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
virtual void DrawGripper(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
virtual void DrawOverflowButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect,
int state) override;
virtual wxSize GetLabelSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) override;
virtual wxSize GetToolSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiToolBarItem& item) override;
virtual int ShowDropDown(wxWindow* wnd,
const wxAuiToolBarItemArray& items) override;
private:
bool m_themed;
wxSize m_buttonSize;
};
#endif // wxUSE_AUI
#endif // _WX_AUI_BARART_MSW_H_

View File

@@ -0,0 +1,200 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/dockart.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Created: 2005-05-17
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DOCKART_H_
#define _WX_DOCKART_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/bmpbndl.h"
#include "wx/colour.h"
#include "wx/font.h"
class WXDLLIMPEXP_FWD_AUI wxAuiPaneInfo;
// dock art provider code - a dock provider provides all drawing
// functionality to the wxAui dock manager. This allows the dock
// manager to have pluggable look-and-feels
class WXDLLIMPEXP_AUI wxAuiDockArt
{
public:
wxAuiDockArt() = default;
virtual ~wxAuiDockArt() = default;
wxNODISCARD virtual wxAuiDockArt* Clone() = 0;
// This function should be used for querying metrics in the new code, as it
// will scale them by the DPI of the provided window if necessary. The
// older GetMetric() function is kept for compatibility and shouldn't be
// used outside of this class itself.
virtual int GetMetricForWindow(int id, wxWindow* window);
virtual int GetMetric(int id) = 0;
virtual void SetMetric(int id, int newVal) = 0;
virtual void SetFont(int id, const wxFont& font) = 0;
virtual wxFont GetFont(int id) = 0;
virtual wxColour GetColour(int id) = 0;
virtual void SetColour(int id, const wxColor& colour) = 0;
wxColour GetColor(int id) { return GetColour(id); }
void SetColor(int id, const wxColour& color) { SetColour(id, color); }
virtual void DrawSash(wxDC& dc,
wxWindow* window,
int orientation,
const wxRect& rect) = 0;
virtual void DrawBackground(wxDC& dc,
wxWindow* window,
int orientation,
const wxRect& rect) = 0;
virtual void DrawCaption(wxDC& dc,
wxWindow* window,
const wxString& text,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
virtual void DrawGripper(wxDC& dc,
wxWindow* window,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
virtual void DrawBorder(wxDC& dc,
wxWindow* window,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
virtual void DrawPaneButton(wxDC& dc,
wxWindow* window,
int button,
int buttonState,
const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
// Provide opportunity for subclasses to recalculate colours
virtual void UpdateColoursFromSystem() {}
};
// this is the default art provider for wxAuiManager. Dock art
// can be customized by creating a class derived from this one,
// or replacing this class entirely
class WXDLLIMPEXP_AUI wxAuiDefaultDockArt : public wxAuiDockArt
{
public:
wxAuiDefaultDockArt();
wxNODISCARD wxAuiDockArt* Clone() override;
int GetMetric(int metricId) override;
void SetMetric(int metricId, int newVal) override;
wxColour GetColour(int id) override;
void SetColour(int id, const wxColor& colour) override;
void SetFont(int id, const wxFont& font) override;
wxFont GetFont(int id) override;
void DrawSash(wxDC& dc,
wxWindow *window,
int orientation,
const wxRect& rect) override;
void DrawBackground(wxDC& dc,
wxWindow *window,
int orientation,
const wxRect& rect) override;
void DrawCaption(wxDC& dc,
wxWindow *window,
const wxString& text,
const wxRect& rect,
wxAuiPaneInfo& pane) override;
void DrawGripper(wxDC& dc,
wxWindow *window,
const wxRect& rect,
wxAuiPaneInfo& pane) override;
void DrawBorder(wxDC& dc,
wxWindow *window,
const wxRect& rect,
wxAuiPaneInfo& pane) override;
void DrawPaneButton(wxDC& dc,
wxWindow *window,
int button,
int buttonState,
const wxRect& rect,
wxAuiPaneInfo& pane) override;
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("This is not intended for the public API")
void DrawIcon(wxDC& dc,
const wxRect& rect,
wxAuiPaneInfo& pane);
#endif
virtual void UpdateColoursFromSystem() override;
protected:
void DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active);
void DrawIcon(wxDC& dc, wxWindow *window, const wxRect& rect, wxAuiPaneInfo& pane);
void InitBitmaps();
protected:
wxPen m_borderPen;
wxBrush m_sashBrush;
wxBrush m_backgroundBrush;
wxBrush m_gripperBrush;
wxFont m_captionFont;
wxBitmapBundle m_inactiveCloseBitmap;
wxBitmapBundle m_inactivePinBitmap;
wxBitmapBundle m_inactiveMaximizeBitmap;
wxBitmapBundle m_inactiveRestoreBitmap;
wxBitmapBundle m_activeCloseBitmap;
wxBitmapBundle m_activePinBitmap;
wxBitmapBundle m_activeMaximizeBitmap;
wxBitmapBundle m_activeRestoreBitmap;
wxPen m_gripperPen1;
wxPen m_gripperPen2;
wxPen m_gripperPen3;
wxColour m_baseColour;
wxColour m_activeCaptionColour;
wxColour m_activeCaptionGradientColour;
wxColour m_activeCaptionTextColour;
wxColour m_inactiveCaptionColour;
wxColour m_inactiveCaptionGradientColour;
wxColour m_inactiveCaptionTextColour;
int m_borderSize;
int m_captionSize;
int m_sashSize;
int m_buttonSize;
int m_gripperSize;
int m_gradientType;
};
#endif // wxUSE_AUI
#endif //_WX_DOCKART_H_

View File

@@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/floatpane.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Created: 2005-05-17
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FLOATPANE_H_
#define _WX_FLOATPANE_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/weakref.h"
#if wxUSE_MINIFRAME
#include "wx/minifram.h"
#define wxAuiFloatingFrameBaseClass wxMiniFrame
#else
#include "wx/frame.h"
#define wxAuiFloatingFrameBaseClass wxFrame
#endif
#include "wx/aui/framemanager.h"
class WXDLLIMPEXP_AUI wxAuiFloatingFrame : public wxAuiFloatingFrameBaseClass
{
public:
wxAuiFloatingFrame(wxWindow* parent,
wxAuiManager* ownerMgr,
const wxAuiPaneInfo& pane,
wxWindowID id = wxID_ANY,
long style = wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION |
wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT |
wxCLIP_CHILDREN
);
virtual ~wxAuiFloatingFrame();
void SetPaneWindow(const wxAuiPaneInfo& pane);
wxAuiManager* GetOwnerManager() const;
// Allow processing accelerators to the parent frame
virtual bool IsTopNavigationDomain(NavigationKind kind) const override;
wxAuiManager& GetAuiManager() { return m_mgr; }
protected:
virtual void OnMoveStart();
virtual void OnMoving(const wxRect& windowRect, wxDirection dir);
virtual void OnMoveFinished();
private:
void OnSize(wxSizeEvent& event);
void OnClose(wxCloseEvent& event);
void OnMoveEvent(wxMoveEvent& event);
void OnIdle(wxIdleEvent& event);
void OnActivate(wxActivateEvent& event);
static bool isMouseDown();
private:
wxWindow* m_paneWindow; // pane window being managed
bool m_solidDrag; // true if system uses solid window drag
bool m_moving;
wxRect m_lastRect;
wxRect m_last2Rect;
wxRect m_last3Rect;
wxSize m_lastSize;
wxDirection m_lastDirection;
wxWeakRef<wxAuiManager> m_ownerMgr;
wxAuiManager m_mgr;
#ifndef SWIG
wxDECLARE_EVENT_TABLE();
wxDECLARE_CLASS(wxAuiFloatingFrame);
#endif // SWIG
};
#endif // wxUSE_AUI
#endif //_WX_FLOATPANE_H_

View File

@@ -0,0 +1,837 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/framemanager.h
// Purpose: wxaui: wx advanced user interface - docking window manager
// Author: Benjamin I. Williams
// Created: 2005-05-17
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FRAMEMANAGER_H_
#define _WX_FRAMEMANAGER_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/dynarray.h"
#include "wx/gdicmn.h"
#include "wx/window.h"
#include "wx/timer.h"
#include "wx/sizer.h"
#include "wx/bmpbndl.h"
#include "wx/overlay.h"
enum wxAuiManagerDock
{
wxAUI_DOCK_NONE = 0,
wxAUI_DOCK_TOP = 1,
wxAUI_DOCK_RIGHT = 2,
wxAUI_DOCK_BOTTOM = 3,
wxAUI_DOCK_LEFT = 4,
wxAUI_DOCK_CENTER = 5,
wxAUI_DOCK_CENTRE = wxAUI_DOCK_CENTER
};
enum wxAuiManagerOption
{
wxAUI_MGR_ALLOW_FLOATING = 1 << 0,
wxAUI_MGR_ALLOW_ACTIVE_PANE = 1 << 1,
wxAUI_MGR_TRANSPARENT_DRAG = 1 << 2,
wxAUI_MGR_TRANSPARENT_HINT = 1 << 3,
wxAUI_MGR_VENETIAN_BLINDS_HINT = 1 << 4,
wxAUI_MGR_RECTANGLE_HINT = 1 << 5,
wxAUI_MGR_HINT_FADE = 1 << 6,
wxAUI_MGR_NO_VENETIAN_BLINDS_FADE = 0, // For compatibility only.
wxAUI_MGR_LIVE_RESIZE = 1 << 8,
wxAUI_MGR_DEFAULT = wxAUI_MGR_ALLOW_FLOATING |
wxAUI_MGR_TRANSPARENT_HINT |
wxAUI_MGR_LIVE_RESIZE
};
enum wxAuiPaneDockArtSetting
{
wxAUI_DOCKART_SASH_SIZE = 0,
wxAUI_DOCKART_CAPTION_SIZE = 1,
wxAUI_DOCKART_GRIPPER_SIZE = 2,
wxAUI_DOCKART_PANE_BORDER_SIZE = 3,
wxAUI_DOCKART_PANE_BUTTON_SIZE = 4,
wxAUI_DOCKART_BACKGROUND_COLOUR = 5,
wxAUI_DOCKART_SASH_COLOUR = 6,
wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR = 7,
wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR = 8,
wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR = 9,
wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR = 10,
wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR = 11,
wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR = 12,
wxAUI_DOCKART_BORDER_COLOUR = 13,
wxAUI_DOCKART_GRIPPER_COLOUR = 14,
wxAUI_DOCKART_CAPTION_FONT = 15,
wxAUI_DOCKART_GRADIENT_TYPE = 16
};
enum wxAuiPaneDockArtGradients
{
wxAUI_GRADIENT_NONE = 0,
wxAUI_GRADIENT_VERTICAL = 1,
wxAUI_GRADIENT_HORIZONTAL = 2
};
enum wxAuiPaneButtonState
{
wxAUI_BUTTON_STATE_NORMAL = 0,
wxAUI_BUTTON_STATE_HOVER = 1 << 1,
wxAUI_BUTTON_STATE_PRESSED = 1 << 2,
wxAUI_BUTTON_STATE_DISABLED = 1 << 3,
wxAUI_BUTTON_STATE_HIDDEN = 1 << 4,
wxAUI_BUTTON_STATE_CHECKED = 1 << 5
};
enum wxAuiButtonId
{
wxAUI_BUTTON_CLOSE = 101,
wxAUI_BUTTON_MAXIMIZE_RESTORE = 102,
wxAUI_BUTTON_MINIMIZE = 103,
wxAUI_BUTTON_PIN = 104,
wxAUI_BUTTON_OPTIONS = 105,
wxAUI_BUTTON_WINDOWLIST = 106,
wxAUI_BUTTON_LEFT = 107,
wxAUI_BUTTON_RIGHT = 108,
wxAUI_BUTTON_UP = 109,
wxAUI_BUTTON_DOWN = 110,
wxAUI_BUTTON_CUSTOM1 = 201,
wxAUI_BUTTON_CUSTOM2 = 202,
wxAUI_BUTTON_CUSTOM3 = 203
};
enum wxAuiPaneInsertLevel
{
wxAUI_INSERT_PANE = 0,
wxAUI_INSERT_ROW = 1,
wxAUI_INSERT_DOCK = 2
};
// forwards and array declarations
class wxAuiDockUIPart;
class wxAuiPaneInfo;
class wxAuiDockInfo;
class wxAuiDockArt;
class wxAuiManagerEvent;
class wxAuiSerializer;
class wxAuiDeserializer;
struct wxAuiDockLayoutInfo;
struct wxAuiPaneLayoutInfo;
using wxAuiDockUIPartArray = wxBaseArray<wxAuiDockUIPart>;
using wxAuiDockInfoArray = wxBaseArray<wxAuiDockInfo>;
using wxAuiDockInfoPtrArray = wxBaseArray<wxAuiDockInfo*>;
using wxAuiPaneInfoPtrArray = wxBaseArray<wxAuiPaneInfo*>;
extern WXDLLIMPEXP_AUI wxAuiDockInfo wxAuiNullDockInfo;
extern WXDLLIMPEXP_AUI wxAuiPaneInfo wxAuiNullPaneInfo;
class WXDLLIMPEXP_AUI wxAuiPaneInfo
{
public:
wxAuiPaneInfo()
: best_size(wxDefaultSize)
, min_size(wxDefaultSize)
, max_size(wxDefaultSize)
, floating_pos(wxDefaultPosition)
, floating_size(wxDefaultSize)
, floating_client_size(wxDefaultSize)
{
window = nullptr;
frame = nullptr;
state = 0;
dock_direction = wxAUI_DOCK_LEFT;
dock_layer = 0;
dock_row = 0;
dock_pos = 0;
dock_size = 0;
dock_proportion = 0;
DefaultPane();
}
~wxAuiPaneInfo() = default;
// Write the safe parts of a newly loaded PaneInfo structure "source" into "this"
// used on loading perspectives etc.
void SafeSet(wxAuiPaneInfo source)
{
// note source is not passed by reference so we can overwrite, to keep the
// unsafe bits of "dest"
source.window = window;
source.frame = frame;
wxCHECK_RET(source.IsValid(),
"window settings and pane settings are incompatible");
// now assign
*this = source;
}
bool IsOk() const { return window != nullptr; }
bool IsFixed() const { return !HasFlag(optionResizable); }
bool IsResizable() const { return HasFlag(optionResizable); }
bool IsShown() const { return !HasFlag(optionHidden); }
bool IsFloating() const { return HasFlag(optionFloating); }
bool IsDocked() const { return !HasFlag(optionFloating); }
bool IsToolbar() const { return HasFlag(optionToolbar); }
bool IsTopDockable() const { return HasFlag(optionTopDockable); }
bool IsBottomDockable() const { return HasFlag(optionBottomDockable); }
bool IsLeftDockable() const { return HasFlag(optionLeftDockable); }
bool IsRightDockable() const { return HasFlag(optionRightDockable); }
bool IsDockable() const
{
return HasFlag(optionTopDockable | optionBottomDockable |
optionLeftDockable | optionRightDockable);
}
bool IsFloatable() const { return HasFlag(optionFloatable); }
bool IsMovable() const { return HasFlag(optionMovable); }
bool IsDestroyOnClose() const { return HasFlag(optionDestroyOnClose); }
bool IsMaximized() const { return HasFlag(optionMaximized); }
bool HasCaption() const { return HasFlag(optionCaption); }
bool HasGripper() const { return HasFlag(optionGripper); }
bool HasBorder() const { return HasFlag(optionPaneBorder); }
bool HasCloseButton() const { return HasFlag(buttonClose); }
bool HasMaximizeButton() const { return HasFlag(buttonMaximize); }
bool HasMinimizeButton() const { return HasFlag(buttonMinimize); }
bool HasPinButton() const { return HasFlag(buttonPin); }
bool HasGripperTop() const { return HasFlag(optionGripperTop); }
#ifdef SWIG
%typemap(out) wxAuiPaneInfo& { $result = $self; Py_INCREF($result); }
#endif
wxAuiPaneInfo& Window(wxWindow* w)
{
wxAuiPaneInfo test(*this);
test.window = w;
wxCHECK_MSG(test.IsValid(), *this,
"window settings and pane settings are incompatible");
*this = test;
return *this;
}
wxAuiPaneInfo& Name(const wxString& n) { name = n; return *this; }
wxAuiPaneInfo& Caption(const wxString& c) { caption = c; return *this; }
wxAuiPaneInfo& Icon(const wxBitmapBundle& b) { icon = b; return *this; }
wxAuiPaneInfo& Left() { dock_direction = wxAUI_DOCK_LEFT; return *this; }
wxAuiPaneInfo& Right() { dock_direction = wxAUI_DOCK_RIGHT; return *this; }
wxAuiPaneInfo& Top() { dock_direction = wxAUI_DOCK_TOP; return *this; }
wxAuiPaneInfo& Bottom() { dock_direction = wxAUI_DOCK_BOTTOM; return *this; }
wxAuiPaneInfo& Center() { dock_direction = wxAUI_DOCK_CENTER; return *this; }
wxAuiPaneInfo& Centre() { dock_direction = wxAUI_DOCK_CENTRE; return *this; }
wxAuiPaneInfo& Direction(int direction) { dock_direction = direction; return *this; }
wxAuiPaneInfo& Layer(int layer) { dock_layer = layer; return *this; }
wxAuiPaneInfo& Row(int row) { dock_row = row; return *this; }
wxAuiPaneInfo& Position(int pos) { dock_pos = pos; return *this; }
wxAuiPaneInfo& BestSize(const wxSize& size) { best_size = size; return *this; }
wxAuiPaneInfo& MinSize(const wxSize& size) { min_size = size; return *this; }
wxAuiPaneInfo& MaxSize(const wxSize& size) { max_size = size; return *this; }
wxAuiPaneInfo& BestSize(int x, int y) { best_size.Set(x,y); return *this; }
wxAuiPaneInfo& MinSize(int x, int y) { min_size.Set(x,y); return *this; }
wxAuiPaneInfo& MaxSize(int x, int y) { max_size.Set(x,y); return *this; }
wxAuiPaneInfo& FloatingPosition(const wxPoint& pos) { floating_pos = pos; return *this; }
wxAuiPaneInfo& FloatingPosition(int x, int y) { floating_pos.x = x; floating_pos.y = y; return *this; }
wxAuiPaneInfo& FloatingSize(const wxSize& size) { floating_size = size; return *this; }
wxAuiPaneInfo& FloatingSize(int x, int y) { floating_size.Set(x,y); return *this; }
wxAuiPaneInfo& FloatingClientSize(const wxSize& size) { floating_client_size = size; return *this; }
wxAuiPaneInfo& FloatingClientSize(int x, int y) { floating_client_size.Set(x,y); return *this; }
wxAuiPaneInfo& Fixed() { return SetFlag(optionResizable, false); }
wxAuiPaneInfo& Resizable(bool resizable = true) { return SetFlag(optionResizable, resizable); }
wxAuiPaneInfo& Dock() { return SetFlag(optionFloating, false); }
wxAuiPaneInfo& Float() { return SetFlag(optionFloating, true); }
wxAuiPaneInfo& Hide() { return SetFlag(optionHidden, true); }
wxAuiPaneInfo& Show(bool show = true) { return SetFlag(optionHidden, !show); }
wxAuiPaneInfo& CaptionVisible(bool visible = true) { return SetFlag(optionCaption, visible); }
wxAuiPaneInfo& Maximize() { return SetFlag(optionMaximized, true); }
wxAuiPaneInfo& Restore() { return SetFlag(optionMaximized, false); }
wxAuiPaneInfo& PaneBorder(bool visible = true) { return SetFlag(optionPaneBorder, visible); }
wxAuiPaneInfo& Gripper(bool visible = true) { return SetFlag(optionGripper, visible); }
wxAuiPaneInfo& GripperTop(bool attop = true) { return SetFlag(optionGripperTop, attop); }
wxAuiPaneInfo& CloseButton(bool visible = true) { return SetFlag(buttonClose, visible); }
wxAuiPaneInfo& MaximizeButton(bool visible = true) { return SetFlag(buttonMaximize, visible); }
wxAuiPaneInfo& MinimizeButton(bool visible = true) { return SetFlag(buttonMinimize, visible); }
wxAuiPaneInfo& PinButton(bool visible = true) { return SetFlag(buttonPin, visible); }
wxAuiPaneInfo& DestroyOnClose(bool b = true) { return SetFlag(optionDestroyOnClose, b); }
wxAuiPaneInfo& TopDockable(bool b = true) { return SetFlag(optionTopDockable, b); }
wxAuiPaneInfo& BottomDockable(bool b = true) { return SetFlag(optionBottomDockable, b); }
wxAuiPaneInfo& LeftDockable(bool b = true) { return SetFlag(optionLeftDockable, b); }
wxAuiPaneInfo& RightDockable(bool b = true) { return SetFlag(optionRightDockable, b); }
wxAuiPaneInfo& Floatable(bool b = true) { return SetFlag(optionFloatable, b); }
wxAuiPaneInfo& Movable(bool b = true) { return SetFlag(optionMovable, b); }
wxAuiPaneInfo& DockFixed(bool b = true) { return SetFlag(optionDockFixed, b); }
wxAuiPaneInfo& Dockable(bool b = true)
{
return TopDockable(b).BottomDockable(b).LeftDockable(b).RightDockable(b);
}
wxAuiPaneInfo& DefaultPane()
{
wxAuiPaneInfo test(*this);
test.state |= optionTopDockable | optionBottomDockable |
optionLeftDockable | optionRightDockable |
optionFloatable | optionMovable | optionResizable |
optionCaption | optionPaneBorder | buttonClose;
wxCHECK_MSG(test.IsValid(), *this,
"window settings and pane settings are incompatible");
*this = test;
return *this;
}
wxAuiPaneInfo& CentrePane() { return CenterPane(); }
wxAuiPaneInfo& CenterPane()
{
state = 0;
return Center().PaneBorder().Resizable();
}
wxAuiPaneInfo& ToolbarPane()
{
DefaultPane();
state |= (optionToolbar | optionGripper);
state &= ~(optionResizable | optionCaption);
if (dock_layer == 0)
dock_layer = 10;
return *this;
}
wxAuiPaneInfo& SetFlag(int flag, bool option_state)
{
wxAuiPaneInfo test(*this);
if (option_state)
test.state |= flag;
else
test.state &= ~flag;
wxCHECK_MSG(test.IsValid(), *this,
"window settings and pane settings are incompatible");
*this = test;
return *this;
}
bool HasFlag(int flag) const
{
return (state & flag) != 0;
}
#ifdef SWIG
%typemap(out) wxAuiPaneInfo& ;
#endif
public:
// NOTE: You can add and subtract flags from this list,
// but do not change the values of the flags, because
// they are stored in a binary integer format in the
// perspective string. If you really need to change the
// values around, you'll have to ensure backwards-compatibility
// in the perspective loading code.
enum wxAuiPaneState
{
optionFloating = 1 << 0,
optionHidden = 1 << 1,
optionLeftDockable = 1 << 2,
optionRightDockable = 1 << 3,
optionTopDockable = 1 << 4,
optionBottomDockable = 1 << 5,
optionFloatable = 1 << 6,
optionMovable = 1 << 7,
optionResizable = 1 << 8,
optionPaneBorder = 1 << 9,
optionCaption = 1 << 10,
optionGripper = 1 << 11,
optionDestroyOnClose = 1 << 12,
optionToolbar = 1 << 13,
optionActive = 1 << 14,
optionGripperTop = 1 << 15,
optionMaximized = 1 << 16,
optionDockFixed = 1 << 17,
buttonClose = 1 << 21,
buttonMaximize = 1 << 22,
buttonMinimize = 1 << 23,
buttonPin = 1 << 24,
buttonCustom1 = 1 << 26,
buttonCustom2 = 1 << 27,
buttonCustom3 = 1 << 28,
savedHiddenState = 1 << 30, // used internally
actionPane = 1u << 31 // used internally
};
public:
wxString name; // name of the pane
wxString caption; // caption displayed on the window
wxBitmapBundle icon; // icon of the pane, may be invalid
wxWindow* window; // window that is in this pane
wxFrame* frame; // floating frame window that holds the pane
unsigned int state; // a combination of wxPaneState values
int dock_direction; // dock direction (top, bottom, left, right, center)
int dock_layer; // layer number (0 = innermost layer)
int dock_row; // row number on the docking bar (0 = first row)
int dock_pos; // position inside the row (0 = first position)
int dock_size; // size of the containing dock (0 if not set)
wxSize best_size; // size that the layout engine will prefer
wxSize min_size; // minimum size the pane window can tolerate
wxSize max_size; // maximum size the pane window can tolerate
wxPoint floating_pos; // position while floating
wxSize floating_size; // size while floating
// this has precedence over floating_size
wxSize floating_client_size; // client size while floating
int dock_proportion; // proportion while docked
wxRect rect; // current rectangle (populated by wxAUI)
bool IsValid() const;
};
// Note that this one must remain a wxBaseObjectArray, i.e. store pointers to
// heap-allocated objects, as it is returned by wxAuiManager::GetPane() and the
// existing code expects these pointers to remain valid even if the array is
// modified.
using wxAuiPaneInfoArray = wxBaseObjectArray<wxAuiPaneInfo>;
class WXDLLIMPEXP_FWD_AUI wxAuiFloatingFrame;
class WXDLLIMPEXP_AUI wxAuiManager : public wxEvtHandler
{
friend class wxAuiFloatingFrame;
public:
wxAuiManager(wxWindow* managedWnd = nullptr,
unsigned int flags = wxAUI_MGR_DEFAULT);
virtual ~wxAuiManager();
void UnInit();
void SetFlags(unsigned int flags);
unsigned int GetFlags() const;
static bool AlwaysUsesLiveResize(const wxWindow* window = nullptr);
bool HasLiveResize() const;
void SetManagedWindow(wxWindow* managedWnd);
wxWindow* GetManagedWindow() const;
static wxAuiManager* GetManager(wxWindow* window);
void SetArtProvider(wxAuiDockArt* artProvider);
wxAuiDockArt* GetArtProvider() const;
wxAuiPaneInfo& GetPane(wxWindow* window);
wxAuiPaneInfo& GetPane(const wxString& name);
const wxAuiPaneInfoArray& GetAllPanes() const { return m_panes; }
wxAuiPaneInfoArray& GetAllPanes() { return m_panes; }
bool AddPane(wxWindow* window,
const wxAuiPaneInfo& paneInfo);
bool AddPane(wxWindow* window,
const wxAuiPaneInfo& paneInfo,
const wxPoint& dropPos);
bool AddPane(wxWindow* window,
int direction = wxLEFT,
const wxString& caption = wxEmptyString);
bool InsertPane(wxWindow* window,
const wxAuiPaneInfo& insertLocation,
int insertLevel = wxAUI_INSERT_PANE);
bool DetachPane(wxWindow* window);
void Update();
// Serialize or restore the whole layout using the provided serializer.
void SaveLayout(wxAuiSerializer& serializer) const;
void LoadLayout(wxAuiDeserializer& deserializer);
// Older functions using bespoke text format, prefer using the ones using
// wxAuiSerializer and wxAuiDeserializer above instead in the new code.
wxString SavePaneInfo(const wxAuiPaneInfo& pane);
void LoadPaneInfo(wxString panePart, wxAuiPaneInfo &pane);
private:
bool LoadPaneInfoVersioned(wxString layoutVersion, wxString panePart, wxAuiPaneInfo& pane);
public:
wxString SavePerspective();
bool LoadPerspective(const wxString& perspective, bool update = true);
void SetDockSizeConstraint(double widthPct, double heightPct);
void GetDockSizeConstraint(double* widthPct, double* heightPct) const;
void ClosePane(wxAuiPaneInfo& paneInfo);
void MaximizePane(wxAuiPaneInfo& paneInfo);
void RestorePane(wxAuiPaneInfo& paneInfo);
void RestoreMaximizedPane();
public:
virtual wxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p);
virtual bool CanDockPanel(const wxAuiPaneInfo & p);
void StartPaneDrag(
wxWindow* paneWindow,
const wxPoint& offset);
wxRect CalculateHintRect(
wxWindow* paneWindow,
const wxPoint& pt,
const wxPoint& offset = wxPoint{});
void DrawHintRect(
wxWindow* paneWindow,
const wxPoint& pt,
const wxPoint& offset = wxPoint{});
void UpdateHint(const wxRect& rect);
// These functions are public for compatibility reasons, but should never
// be called directly, use UpdateHint() above instead.
virtual void ShowHint(const wxRect& rect);
virtual void HideHint();
// Internal functions, don't use them outside of wxWidgets itself.
void CopyDockLayoutFrom(wxAuiDockLayoutInfo& layoutInfo,
const wxAuiPaneInfo& pane) const;
void CopyDockLayoutTo(const wxAuiDockLayoutInfo& layoutInfo,
wxAuiPaneInfo& pane) const;
void CopyLayoutFrom(wxAuiPaneLayoutInfo& layoutInfo,
const wxAuiPaneInfo& pane) const;
void CopyLayoutTo(const wxAuiPaneLayoutInfo& layoutInfo,
wxAuiPaneInfo& pane) const;
public:
// deprecated -- please use SetManagedWindow()
// and GetManagedWindow() instead
wxDEPRECATED( void SetFrame(wxFrame* frame) );
wxDEPRECATED( wxFrame* GetFrame() const );
protected:
void DoFrameLayout();
void LayoutAddPane(wxSizer* container,
wxAuiDockInfo& dock,
wxAuiPaneInfo& pane,
wxAuiDockUIPartArray& uiparts,
bool spacerOnly);
void LayoutAddDock(wxSizer* container,
wxAuiDockInfo& dock,
wxAuiDockUIPartArray& uiParts,
bool spacerOnly);
wxSizer* LayoutAll(wxAuiPaneInfoArray& panes,
wxAuiDockInfoArray& docks,
wxAuiDockUIPartArray & uiParts,
bool spacerOnly = false);
virtual bool ProcessDockResult(wxAuiPaneInfo& target,
const wxAuiPaneInfo& newPos);
bool DoDrop(wxAuiDockInfoArray& docks,
wxAuiPaneInfoArray& panes,
wxAuiPaneInfo& drop,
const wxPoint& pt,
const wxPoint& actionOffset = wxPoint(0,0));
wxAuiDockUIPart* HitTest(int x, int y);
wxAuiDockUIPart* GetPanePart(wxWindow* pane);
int GetDockPixelOffset(wxAuiPaneInfo& test);
void OnFloatingPaneMoveStart(wxWindow* window);
void OnFloatingPaneMoving(wxWindow* window, wxDirection dir );
void OnFloatingPaneMoved(wxWindow* window, wxDirection dir);
void OnFloatingPaneActivated(wxWindow* window);
void OnFloatingPaneClosed(wxWindow* window, wxCloseEvent& evt);
void OnFloatingPaneResized(wxWindow* window, const wxRect& rect);
void Render(wxDC* dc);
void Repaint(wxDC* dc = nullptr);
void ProcessMgrEvent(wxAuiManagerEvent& event);
void UpdateButtonOnScreen(wxAuiDockUIPart* buttonUiPart,
const wxMouseEvent& event);
void GetPanePositionsAndSizes(wxAuiDockInfo& dock,
wxArrayInt& positions,
wxArrayInt& sizes);
/// Ends a resize action, or for live update, resizes the sash
bool DoEndResizeAction(wxMouseEvent& event);
void SetActivePane(wxWindow* active_pane);
public:
// public events (which can be invoked externally)
void OnRender(wxAuiManagerEvent& evt);
void OnPaneButton(wxAuiManagerEvent& evt);
protected:
// protected events
void OnDestroy(wxWindowDestroyEvent& evt);
void OnPaint(wxPaintEvent& evt);
void OnEraseBackground(wxEraseEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnSetCursor(wxSetCursorEvent& evt);
void OnLeftDown(wxMouseEvent& evt);
void OnLeftUp(wxMouseEvent& evt);
void OnMotion(wxMouseEvent& evt);
void OnCaptureLost(wxMouseCaptureLostEvent& evt);
void OnLeaveWindow(wxMouseEvent& evt);
void OnChildFocus(wxChildFocusEvent& evt);
void OnHintFadeTimer(wxTimerEvent& evt);
void OnFindManager(wxAuiManagerEvent& evt);
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
enum
{
actionNone = 0,
actionResize,
actionClickButton,
actionClickCaption,
actionDragToolbarPane,
actionDragFloatingPane
};
protected:
wxWindow* m_frame; // the window being managed
wxAuiDockArt* m_art; // dock art object which does all drawing
unsigned int m_flags; // manager flags wxAUI_MGR_*
wxAuiPaneInfoArray m_panes; // array of panes structures
wxAuiDockInfoArray m_docks; // array of docks structures
wxAuiDockUIPartArray m_uiParts; // array of UI parts (captions, buttons, etc)
int m_action; // current mouse action
wxPoint m_actionStart; // position where the action click started
wxPoint m_actionOffset; // offset from upper left of the item clicked
wxAuiDockUIPart* m_actionPart; // ptr to the part the action happened to
wxWindow* m_actionWindow; // action frame or window (nullptr if none)
wxRect m_actionHintRect; // hint rectangle for the action
wxRect m_lastRect;
wxAuiDockUIPart* m_hoverButton;// button uipart being hovered over
wxRect m_lastHint; // last hint rectangle
wxPoint m_lastMouseMove; // last mouse move position (see OnMotion)
int m_currentDragItem;
bool m_hasMaximized;
double m_dockConstraintX; // 0.0 .. 1.0; max pct of window width a dock can consume
double m_dockConstraintY; // 0.0 .. 1.0; max pct of window height a dock can consume
wxTimer m_hintFadeTimer; // transparent fade timer
wxByte m_hintFadeAmt; // transparent fade amount
wxByte m_hintFadeMax; // maximum value of hint fade
wxOverlay m_overlay;
void* m_reserved;
private:
// Return the index in m_uiParts corresponding to the current value of
// m_actionPart. If m_actionPart is null, returns wxNOT_FOUND.
int GetActionPartIndex() const;
// This flag is set to true if Update() is called while the window is
// minimized, in which case we postpone updating it until it is restored.
bool m_updateOnRestore = false;
#ifndef SWIG
wxDECLARE_CLASS(wxAuiManager);
#endif // SWIG
};
// event declarations/classes
class WXDLLIMPEXP_AUI wxAuiManagerEvent : public wxEvent
{
public:
wxAuiManagerEvent(wxEventType type=wxEVT_NULL) : wxEvent(0, type)
{
manager = nullptr;
pane = nullptr;
button = 0;
veto_flag = false;
canveto_flag = true;
dc = nullptr;
}
wxNODISCARD wxEvent *Clone() const override { return new wxAuiManagerEvent(*this); }
void SetManager(wxAuiManager* mgr) { manager = mgr; }
void SetPane(wxAuiPaneInfo* p) { pane = p; }
void SetButton(int b) { button = b; }
void SetDC(wxDC* pdc) { dc = pdc; }
wxAuiManager* GetManager() const { return manager; }
wxAuiPaneInfo* GetPane() const { return pane; }
int GetButton() const { return button; }
wxDC* GetDC() const { return dc; }
void Veto(bool veto = true) { veto_flag = veto; }
bool GetVeto() const { return veto_flag; }
void SetCanVeto(bool can_veto) { canveto_flag = can_veto; }
bool CanVeto() const { return canveto_flag && veto_flag; }
public:
wxAuiManager* manager;
wxAuiPaneInfo* pane;
int button;
bool veto_flag;
bool canveto_flag;
wxDC* dc;
#ifndef SWIG
private:
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxAuiManagerEvent);
#endif
};
class WXDLLIMPEXP_AUI wxAuiDockInfo
{
public:
wxAuiDockInfo()
{
dock_direction = 0;
dock_layer = 0;
dock_row = 0;
size = 0;
min_size = 0;
resizable = true;
fixed = false;
toolbar = false;
reserved1 = false;
}
bool IsOk() const { return dock_direction != 0; }
bool IsHorizontal() const { return dock_direction == wxAUI_DOCK_TOP ||
dock_direction == wxAUI_DOCK_BOTTOM; }
bool IsVertical() const { return dock_direction == wxAUI_DOCK_LEFT ||
dock_direction == wxAUI_DOCK_RIGHT ||
dock_direction == wxAUI_DOCK_CENTER; }
public:
wxAuiPaneInfoPtrArray panes; // array of panes
wxRect rect; // current rectangle
int dock_direction; // dock direction (top, bottom, left, right, center)
int dock_layer; // layer number (0 = innermost layer)
int dock_row; // row number on the docking bar (0 = first row)
int size; // size of the dock
int min_size; // minimum size of a dock (0 if there is no min)
bool resizable; // flag indicating whether the dock is resizable
bool toolbar; // flag indicating dock contains only toolbars
bool fixed; // flag indicating that the dock operates on
// absolute coordinates as opposed to proportional
bool reserved1;
};
class WXDLLIMPEXP_AUI wxAuiDockUIPart
{
public:
enum
{
typeCaption,
typeGripper,
typeDock,
typeDockSizer,
typePane,
typePaneSizer,
typeBackground,
typePaneBorder,
typePaneButton
};
int type; // ui part type (see enum above)
int orientation; // orientation (either wxHORIZONTAL or wxVERTICAL)
wxAuiDockInfo* dock; // which dock the item is associated with
wxAuiPaneInfo* pane; // which pane the item is associated with
int button; // which pane button the item is associated with
wxSizer* cont_sizer; // the part's containing sizer
wxSizerItem* sizer_item; // the sizer item of the part
wxRect rect; // client coord rectangle of the part itself
};
#ifndef SWIG
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_BUTTON, wxAuiManagerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_CLOSE, wxAuiManagerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_MAXIMIZE, wxAuiManagerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_RESTORE, wxAuiManagerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_PANE_ACTIVATED, wxAuiManagerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_RENDER, wxAuiManagerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_AUI, wxEVT_AUI_FIND_MANAGER, wxAuiManagerEvent );
typedef void (wxEvtHandler::*wxAuiManagerEventFunction)(wxAuiManagerEvent&);
#define wxAuiManagerEventHandler(func) \
wxEVENT_HANDLER_CAST(wxAuiManagerEventFunction, func)
#define EVT_AUI_PANE_BUTTON(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_BUTTON, wxAuiManagerEventHandler(func))
#define EVT_AUI_PANE_CLOSE(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler(func))
#define EVT_AUI_PANE_MAXIMIZE(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_MAXIMIZE, wxAuiManagerEventHandler(func))
#define EVT_AUI_PANE_RESTORE(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_RESTORE, wxAuiManagerEventHandler(func))
#define EVT_AUI_PANE_ACTIVATED(func) \
wx__DECLARE_EVT0(wxEVT_AUI_PANE_ACTIVATED, wxAuiManagerEventHandler(func))
#define EVT_AUI_RENDER(func) \
wx__DECLARE_EVT0(wxEVT_AUI_RENDER, wxAuiManagerEventHandler(func))
#define EVT_AUI_FIND_MANAGER(func) \
wx__DECLARE_EVT0(wxEVT_AUI_FIND_MANAGER, wxAuiManagerEventHandler(func))
#else
%constant wxEventType wxEVT_AUI_PANE_BUTTON;
%constant wxEventType wxEVT_AUI_PANE_CLOSE;
%constant wxEventType wxEVT_AUI_PANE_MAXIMIZE;
%constant wxEventType wxEVT_AUI_PANE_RESTORE;
%constant wxEventType wxEVT_AUI_PANE_ACTIVATED;
%constant wxEventType wxEVT_AUI_RENDER;
%constant wxEventType wxEVT_AUI_FIND_MANAGER;
%pythoncode {
EVT_AUI_PANE_BUTTON = wx.PyEventBinder( wxEVT_AUI_PANE_BUTTON )
EVT_AUI_PANE_CLOSE = wx.PyEventBinder( wxEVT_AUI_PANE_CLOSE )
EVT_AUI_PANE_MAXIMIZE = wx.PyEventBinder( wxEVT_AUI_PANE_MAXIMIZE )
EVT_AUI_PANE_RESTORE = wx.PyEventBinder( wxEVT_AUI_PANE_RESTORE )
EVT_AUI_PANE_ACTIVATED = wx.PyEventBinder( wxEVT_AUI_PANE_ACTIVATED )
EVT_AUI_RENDER = wx.PyEventBinder( wxEVT_AUI_RENDER )
EVT_AUI_FIND_MANAGER = wx.PyEventBinder( wxEVT_AUI_FIND_MANAGER )
}
#endif // SWIG
#endif // wxUSE_AUI
#endif //_WX_FRAMEMANAGER_H_

View File

@@ -0,0 +1,241 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/serializer.h
// Purpose: Declaration of wxAuiSerializer and wxAuiDeserializer classes.
// Author: Vadim Zeitlin
// Created: 2024-01-20
// Copyright: (c) 2024 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUI_SERIALIZER_H_
#define _WX_AUI_SERIALIZER_H_
#include "wx/aui/framemanager.h" // Just for wxAUI_DOCK_LEFT
#if wxUSE_AUI
#include <utility>
#include <vector>
class WXDLLIMPEXP_FWD_AUI wxAuiNotebook;
class WXDLLIMPEXP_FWD_AUI wxAuiTabCtrl;
// ----------------------------------------------------------------------------
// Classes used to save/load wxAuiManager layout.
// ----------------------------------------------------------------------------
// Fields common to wxAuiPaneLayoutInfo and wxAuiTabLayoutInfo containing
// information about a docked pane or tab layout.
struct wxAuiDockLayoutInfo
{
// Identifies the dock containing the pane.
int dock_direction = wxAUI_DOCK_LEFT;
int dock_layer = 0;
int dock_row = 0;
int dock_pos = 0;
int dock_proportion = 0;
// Size of the containing dock.
//
// Note that storing the dock size is redundant as it can be calculated
// from pane sizes, but storing all pane sizes would be redundant too, so
// we prefer to keep things simple and store just this size.
int dock_size = 0;
};
// This struct contains information about the layout of a tab control in a
// wxAuiNotebook, including where it is docked and the order of pages in it.
struct wxAuiTabLayoutInfo : wxAuiDockLayoutInfo
{
// If this vector is empty, it means that the tab control contains all
// notebook pages in natural order.
std::vector<int> pages;
// Vectors contain indices of pinned pages, if any, i.e. it can be empty.
std::vector<int> pinned;
// Currently active page in this tab control.
int active = 0;
};
// This struct contains the pane name and information about its layout that can
// be manipulated by the user interactively.
struct wxAuiPaneLayoutInfo : wxAuiDockLayoutInfo
{
// Ctor sets the name, which is always required.
explicit wxAuiPaneLayoutInfo(wxString name_) : name{std::move(name_)} { }
// Unique name of the pane.
wxString name;
// Floating pane geometry, may be invalid.
wxPoint floating_pos = wxDefaultPosition;
wxSize floating_size = wxDefaultSize;
wxSize floating_client_size = wxDefaultSize;
// The remaining fields correspond to individual bits of the pane state
// flags instead of corresponding to wxAuiPaneInfo fields directly because
// we prefer not storing the entire state -- this would be less readable
// and extensible.
// True if the pane is currently maximized.
bool is_maximized = false;
// True if the pane is currently hidden.
bool is_hidden = false;
};
// wxAuiBookSerializer is used for serializing wxAuiNotebook layout.
//
// This includes the tab controls layout and the order of pages in them.
//
// It can be used standalone with wxAuiNotebook::SaveLayout() or as base class
// of wxAuiSerializer for saving and restoring the entire layout.
class wxAuiBookSerializer
{
public:
// Trivial default ctor.
wxAuiBookSerializer() = default;
// Trivial but virtual dtor for a base class.
virtual ~wxAuiBookSerializer() = default;
// Called before starting to save information about the tabs in the
// notebook in the AUI pane with the given name.
virtual void BeforeSaveNotebook(const wxString& name) = 0;
// Called to save information about a single tab control in the given
// notebook.
virtual void SaveNotebookTabControl(const wxAuiTabLayoutInfo& tab) = 0;
// Called after saving information about all the pages of the notebook in
// the AUI pane with the given name, does nothing by default.
virtual void AfterSaveNotebook() { }
};
// wxAuiSerializer is used with wxAuiManager::SaveLayout().
//
// This is an abstract base class, you need to inherit from it and override its
// pure virtual functions, including those inherited from wxAuiBookSerializer,
// in your derived class.
//
// If any of the functions of the derived class throw an exception, it is
// propagated out of wxAuiManager::SaveLayout() and it's callers responsibility
// to handle it.
class wxAuiSerializer : public wxAuiBookSerializer
{
public:
// Trivial default ctor.
wxAuiSerializer() = default;
// Called before doing anything else, does nothing by default.
virtual void BeforeSave() { }
// Called before starting to save information about the panes, does nothing
// by default.
virtual void BeforeSavePanes() { }
// Save information about the given pane.
virtual void SavePane(const wxAuiPaneLayoutInfo& pane) = 0;
// Called after the last call to SavePane(), does nothing by default.
virtual void AfterSavePanes() { }
// Called before starting to save information about the notebooks, does
// nothing by default.
virtual void BeforeSaveNotebooks() { }
// Called after the last call to SaveNotebook(), does nothing by default.
virtual void AfterSaveNotebooks() { }
// Called after saving everything, does nothing by default.
virtual void AfterSave() { }
};
// wxAuiBookDeserializer is used for deserializing wxAuiNotebook layout.
//
// Similarly to wxAuiBookSerializer, it can be used standalone with
// wxAuiNotebook::LoadLayout() or as base class of wxAuiDeserializer.
class wxAuiBookDeserializer
{
public:
// Trivial default ctor.
wxAuiBookDeserializer() = default;
// Trivial but virtual dtor for a base class.
virtual ~wxAuiBookDeserializer() = default;
// Load information about all the tab controls in the pane containing
// wxAuiNotebook with the given name.
virtual std::vector<wxAuiTabLayoutInfo>
LoadNotebookTabs(const wxString& name) = 0;
// If any pages haven't been assigned to any tab control after restoring
// the pages order, they are passed to this function to determine what to
// do with them.
//
// By default, it returns true without modifying the output arguments,
// which results in the page being appended to the main tab control. It may
// also modify tabCtrl and tabIndex arguments to modify where the page
// should appear or return false to remove the page from the notebook
// completely.
virtual bool
HandleOrphanedPage(wxAuiNotebook& WXUNUSED(book),
int WXUNUSED(page),
wxAuiTabCtrl** WXUNUSED(tabCtrl),
int* WXUNUSED(tabIndex))
{ return true; }
};
// wxAuiDeserializer is used with wxAuiManager::LoadLayout().
//
// As wxAuiSerializer, this is an abstract base class, you need to inherit from
// it and override its pure virtual functions in your derived class.
//
// Derived class function also may throw and, if any of them other than
// AfterLoad() does, the existing layout is not changed, i.e.
// wxAuiManager::LoadLayout() is exception-safe.
class wxAuiDeserializer : public wxAuiBookDeserializer
{
public:
// Ctor takes the manager for which we're restoring the layout, it must
// remain valid for the lifetime of this object.
explicit wxAuiDeserializer(wxAuiManager& manager) : m_manager(manager) { }
// Called before doing anything else, does nothing by default.
virtual void BeforeLoad() { }
// Load information about all the panes previously saved with SavePane().
virtual std::vector<wxAuiPaneLayoutInfo> LoadPanes() = 0;
// Create the window to be managed by the given pane: this is called if any
// of the panes returned by LoadPanes() doesn't exist in the existing
// layout and allows to create windows on the fly.
//
// If this function returns nullptr, the pane is not added to the manager.
//
// Note that the pane info may (and usually will, if a window is created)
// be modified, to set fields such as caption or icon and any flags other
// "maximized".
virtual wxWindow* CreatePaneWindow(wxAuiPaneInfo& WXUNUSED(pane))
{
return nullptr;
}
// Called after restoring everything, calls Update() on the manager by
// default.
virtual void AfterLoad() { m_manager.Update(); }
protected:
// The manager for which we're restoring the layout.
wxAuiManager& m_manager;
};
#endif // wxUSE_AUI
#endif // _WX_AUI_SERIALIZER_H_

View File

@@ -0,0 +1,481 @@
//////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/tabart.h
// Purpose: wxaui: wx advanced user interface - notebook
// Author: Benjamin I. Williams
// Modified by: Jens Lody (extracted from wx/aui/auibook.h)
// Created: 2012-03-21
// Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUI_TABART_H_
#define _WX_AUI_TABART_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/colour.h"
#include "wx/gdicmn.h"
#include "wx/font.h"
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/bmpbndl.h"
#include "wx/aui/framemanager.h" // wxAuiPaneButtonState and wxAuiButtonId
#include <vector>
class wxAuiNotebookPage;
class wxAuiNotebookPageArray;
class wxAuiTabContainerButton;
class wxWindow;
class wxDC;
class wxReadOnlyDC;
// tab art class
class WXDLLIMPEXP_AUI wxAuiTabArt
{
public:
wxAuiTabArt() = default;
virtual ~wxAuiTabArt() = default;
wxNODISCARD virtual wxAuiTabArt* Clone() = 0;
virtual void SetFlags(unsigned int flags) = 0;
virtual void SetSizingInfo(const wxSize& tabCtrlSize,
size_t tabCount,
wxWindow* wnd = nullptr) = 0;
virtual void SetNormalFont(const wxFont& font) = 0;
virtual void SetSelectedFont(const wxFont& font) = 0;
virtual void SetMeasuringFont(const wxFont& font) = 0;
virtual void SetColour(const wxColour& colour) = 0;
virtual void SetActiveColour(const wxColour& colour) = 0;
// These functions should be overridden in the derived class to return the
// actually used fonts, but they're not pure virtual for compatibility
// reasons.
virtual wxFont GetNormalFont() const { return wxFont{}; }
virtual wxFont GetSelectedFont() const { return wxFont{}; }
virtual void DrawBorder(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
virtual void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) = 0;
// This function is not pure virtual for compatibility: if the derived
// class implements DrawTab(), then its default implementation is
// sufficient as long as pinned tabs are not used, but it must be
// overridden if the program does use them and it should be overridden
// instead of DrawTab() in the new code.
virtual int DrawPageTab(
wxDC& dc,
wxWindow* wnd,
wxAuiNotebookPage& page,
const wxRect& rect);
// Override DrawPageTab() in the new code rather than this one.
virtual void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& pane,
const wxRect& inRect,
int closeButtonState,
wxRect* outTabRect,
wxRect* outButtonRect,
int* xExtent);
virtual void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& inRect,
int bitmapId,
int buttonState,
int orientation,
wxRect* outRect) = 0;
// This function relationship with GetTabSize() is similar as for DrawTab()
// and DrawPageTab(): this one should be overridden when pinned tabs are
// used, but doesn't have to be if they are not and GetTabSize() itself is
// overridden for compatibility with the existing code.
//
// It also allows to omit "xExtent" parameter if it is not needed.
virtual wxSize GetPageTabSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& page,
int* xExtent = nullptr);
virtual wxSize GetTabSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxString& caption,
const wxBitmapBundle& bitmap,
bool active,
int closeButtonState,
int* xExtent);
// This function is not pure virtual because it is only for multi-line
// tabs, but it must be implemented if wxAUI_NB_MULTILINE is used.
//
// If specified, the returned rectangle must be filled with the same value
// as DrawButton() puts into its "outRect" but here it can also be null in
// which case just its width is returned.
virtual int GetButtonRect(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxRect& inRect,
int bitmapId,
int buttonState,
int orientation,
wxRect* outRect = nullptr) /* = 0 */;
virtual int ShowDropDown(
wxWindow* wnd,
const wxAuiNotebookPageArray& items,
int activeIdx) = 0;
virtual int GetIndentSize() = 0;
virtual int GetBorderWidth(
wxWindow* wnd) = 0;
virtual int GetAdditionalBorderSpace(
wxWindow* wnd) = 0;
virtual int GetBestTabCtrlSize(
wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& requiredBmpSize) = 0;
// Provide opportunity for subclasses to recalculate colours
virtual void UpdateColoursFromSystem() {}
virtual void UpdateDpi() {}
};
// Base, still abstract, class for the concrete tab art classes below.
class WXDLLIMPEXP_AUI wxAuiTabArtBase : public wxAuiTabArt
{
public:
void SetFlags(unsigned int flags) override;
void SetSizingInfo(const wxSize& tabCtrlSize,
size_t tabCount,
wxWindow* wnd = nullptr) override;
void SetNormalFont(const wxFont& font) override;
void SetSelectedFont(const wxFont& font) override;
void SetMeasuringFont(const wxFont& font) override;
wxFont GetNormalFont() const override;
wxFont GetSelectedFont() const override;
int GetButtonRect(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxRect& inRect,
int bitmapId,
int buttonState,
int orientation,
wxRect* outRect) override;
void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& inRect,
int bitmapId,
int buttonState,
int orientation,
wxRect* outRect) override;
int ShowDropDown(
wxWindow* wnd,
const wxAuiNotebookPageArray& items,
int activeIdx) override;
int GetBorderWidth(
wxWindow* wnd) override;
int GetAdditionalBorderSpace(
wxWindow* wnd) override;
void DrawBorder(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
protected:
// Ctor is protected, this class is only used as a base class.
//
// Remember to call InitBitmaps() after setting up the colours in the
// derived class ctor.
wxAuiTabArtBase();
// Initialize the bitmaps using the colours returned by GetButtonColour().
void InitBitmaps();
// Return pointer to our bitmap bundle corresponding to the button ID and
// state or null if we don't support this button or if it is hidden.
const wxBitmapBundle*
GetButtonBitmapBundle(const wxAuiTabContainerButton& button) const;
// Helper function for DrawButton() and GetButtonRect().
bool DoGetButtonRectAndBitmap(
wxWindow* wnd,
const wxRect& inRect,
int bitmapId,
int buttonState,
int orientation,
wxRect* outRect,
wxBitmap* outBitmap = nullptr);
// Note: all these fields are protected for compatibility reasons, but
// shouldn't be accessed directly.
wxFont m_normalFont;
wxFont m_selectedFont;
wxFont m_measuringFont;
wxBitmapBundle m_activeCloseBmp;
wxBitmapBundle m_disabledCloseBmp;
wxBitmapBundle m_activeLeftBmp;
wxBitmapBundle m_disabledLeftBmp;
wxBitmapBundle m_activeRightBmp;
wxBitmapBundle m_disabledRightBmp;
wxBitmapBundle m_activeWindowListBmp;
wxBitmapBundle m_disabledWindowListBmp;
wxBitmapBundle m_activePinBmp;
wxBitmapBundle m_disabledPinBmp;
wxBitmapBundle m_activeUnpinBmp;
wxBitmapBundle m_disabledUnpinBmp;
int m_fixedTabWidth;
int m_tabCtrlHeight; // Unused, kept only for compatibility.
unsigned int m_flags = 0;
private:
// This is called by InitBitmaps().
//
// The state parameter is currently always either wxAUI_BUTTON_STATE_NORMAL
// or wxAUI_BUTTON_STATE_DISABLED, but the function could be called with
// other values in the future.
virtual wxColour
GetButtonColour(wxAuiButtonId button, wxAuiPaneButtonState state) const = 0;
// This is called by DrawButton().
//
// By default just draws the bitmap using wxDC::DrawBitmap().
virtual void
DrawButtonBitmap(wxDC& dc,
const wxRect& rect,
const wxBitmap& bmp,
int buttonState);
};
// This tab art provider draws flat tabs with a thin border.
class WXDLLIMPEXP_AUI wxAuiFlatTabArt : public wxAuiTabArtBase
{
public:
wxAuiFlatTabArt();
virtual ~wxAuiFlatTabArt();
// Objects of this class are supposed to be used polymorphically, so
// copying them is not allowed, use Clone() instead.
wxAuiFlatTabArt(const wxAuiFlatTabArt&) = delete;
wxAuiFlatTabArt& operator=(const wxAuiFlatTabArt&) = delete;
wxNODISCARD wxAuiTabArt* Clone() override;
void SetColour(const wxColour& colour) override;
void SetActiveColour(const wxColour& colour) override;
void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
int DrawPageTab(
wxDC& dc,
wxWindow* wnd,
wxAuiNotebookPage& page,
const wxRect& rect) override;
int GetIndentSize() override;
wxSize GetPageTabSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& page,
int* xExtent = nullptr) override;
int GetBestTabCtrlSize(wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& requiredBmpSize) override;
void UpdateColoursFromSystem() override;
private:
// Private pseudo-copy ctor used by Clone().
explicit wxAuiFlatTabArt(wxAuiFlatTabArt* other);
virtual wxColour
GetButtonColour(wxAuiButtonId button,
wxAuiPaneButtonState state) const override;
struct Data;
Data* const m_data;
};
class WXDLLIMPEXP_AUI wxAuiGenericTabArt : public wxAuiTabArtBase
{
public:
wxAuiGenericTabArt();
wxNODISCARD wxAuiTabArt* Clone() override;
void SetColour(const wxColour& colour) override;
void SetActiveColour(const wxColour& colour) override;
void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
int DrawPageTab(
wxDC& dc,
wxWindow* wnd,
wxAuiNotebookPage& page,
const wxRect& rect) override;
int GetIndentSize() override;
wxSize GetPageTabSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& page,
int* xExtent = nullptr) override;
int GetBestTabCtrlSize(wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& requiredBmpSize) override;
// Provide opportunity for subclasses to recalculate colours
virtual void UpdateColoursFromSystem() override;
protected:
wxColour m_baseColour;
wxPen m_baseColourPen;
wxPen m_borderPen;
wxBrush m_baseColourBrush;
wxColour m_activeColour;
private:
// Called from ctor and UpdateColoursFromSystem().
void InitColours();
virtual wxColour
GetButtonColour(wxAuiButtonId button,
wxAuiPaneButtonState state) const override;
};
class WXDLLIMPEXP_AUI wxAuiSimpleTabArt : public wxAuiTabArtBase
{
public:
wxAuiSimpleTabArt();
wxNODISCARD wxAuiTabArt* Clone() override;
void SetColour(const wxColour& colour) override;
void SetActiveColour(const wxColour& colour) override;
void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& pane,
const wxRect& inRect,
int closeButtonState,
wxRect* outTabRect,
wxRect* outButtonRect,
int* xExtent) override;
int GetIndentSize() override;
wxSize GetTabSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxString& caption,
const wxBitmapBundle& bitmap,
bool active,
int closeButtonState,
int* xExtent) override;
int GetBestTabCtrlSize(wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& requiredBmpSize) override;
protected:
wxPen m_normalBkPen;
wxPen m_selectedBkPen;
wxBrush m_normalBkBrush;
wxBrush m_selectedBkBrush;
wxBrush m_bkBrush;
private:
virtual wxColour
GetButtonColour(wxAuiButtonId button,
wxAuiPaneButtonState state) const override;
virtual void
DrawButtonBitmap(wxDC& dc,
const wxRect& rect,
const wxBitmap& bmp,
int buttonState) override;
};
#ifndef __WXUNIVERSAL__
#if defined(__WXGTK__) && !defined(__WXGTK3__)
#define wxHAS_NATIVE_TABART
#include "wx/aui/tabartgtk.h"
using wxAuiNativeTabArt = wxAuiGtkTabArt;
#elif defined(__WXMSW__) && wxUSE_UXTHEME
#define wxHAS_NATIVE_TABART
#include "wx/aui/tabartmsw.h"
using wxAuiNativeTabArt = wxAuiMSWTabArt;
#endif
#endif // !__WXUNIVERSAL__
#ifndef wxHAS_NATIVE_TABART
using wxAuiNativeTabArt = wxAuiGenericTabArt;
#endif
#define wxAuiDefaultTabArt wxAuiFlatTabArt
#endif // wxUSE_AUI
#endif // _WX_AUI_TABART_H_

View File

@@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/aui/tabartgtk.h
// Purpose: declaration of the wxAuiGTKTabArt
// Author: Jens Lody and Teodor Petrov
// Created: 2012-03-23
// Copyright: (c) 2012 Jens Lody <jens@codeblocks.org>
// and Teodor Petrov
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUI_TABARTGTK_H_
#define _WX_AUI_TABARTGTK_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_AUI
#include "wx/aui/tabart.h"
#include "wx/gdicmn.h"
class wxWindow;
class wxDC;
class WXDLLIMPEXP_AUI wxAuiGtkTabArt : public wxAuiGenericTabArt
{
public:
wxAuiGtkTabArt();
wxNODISCARD virtual wxAuiTabArt* Clone() override;
virtual void DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) override;
virtual void DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) override;
virtual void DrawTab(wxDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& page,
const wxRect& in_rect,
int close_button_state,
wxRect* out_tab_rect,
wxRect* out_button_rect,
int* x_extent) override;
void DrawButton(wxDC& dc, wxWindow* wnd, const wxRect& in_rect, int bitmap_id,
int button_state, int orientation, wxRect* out_rect) override;
int GetBestTabCtrlSize(wxWindow* wnd, const wxAuiNotebookPageArray& pages,
const wxSize& required_bmp_size) override;
int GetBorderWidth(wxWindow* wnd) override;
int GetAdditionalBorderSpace(wxWindow* wnd) override;
virtual wxSize GetTabSize(wxReadOnlyDC& dc, wxWindow* wnd, const wxString& caption,
const wxBitmapBundle& bitmap, bool active,
int close_button_state, int* x_extent) override;
};
#endif // wxUSE_AUI
#endif // _WX_AUI_TABARTGTK_H_

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/tabartmsw.h
// Purpose: wxAuiMSWTabArt declaration
// Author: Tobias Taschner
// Created: 2015-09-26
// Copyright: (c) 2015 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUI_TABARTMSW_H_
#define _WX_AUI_TABARTMSW_H_
#include "wx/aui/tabart.h"
#if wxUSE_AUI
class WXDLLIMPEXP_AUI wxAuiMSWTabArt : public wxAuiGenericTabArt
{
public:
wxAuiMSWTabArt();
virtual ~wxAuiMSWTabArt();
wxNODISCARD wxAuiTabArt* Clone() override;
void DrawBorder(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
void DrawBackground(
wxDC& dc,
wxWindow* wnd,
const wxRect& rect) override;
int DrawPageTab(wxDC& dc,
wxWindow* wnd,
wxAuiNotebookPage& page,
const wxRect& rect) override;
void DrawButton(
wxDC& dc,
wxWindow* wnd,
const wxRect& inRect,
int bitmapId,
int buttonState,
int orientation,
wxRect* outRect) override;
int GetIndentSize() override;
int GetBorderWidth(
wxWindow* wnd) override;
int GetAdditionalBorderSpace(
wxWindow* wnd) override;
wxSize GetPageTabSize(
wxReadOnlyDC& dc,
wxWindow* wnd,
const wxAuiNotebookPage& page,
int* xExtent) override;
int ShowDropDown(
wxWindow* wnd,
const wxAuiNotebookPageArray& items,
int activeIdx) override;
int GetBestTabCtrlSize(wxWindow* wnd,
const wxAuiNotebookPageArray& pages,
const wxSize& requiredBmpSize) override;
void UpdateDpi() override;
private:
bool m_themed;
wxSize m_closeBtnSize;
wxSize m_tabSize;
int m_maxTabHeight;
void InitSizes(wxWindow* wnd, wxReadOnlyDC& dc);
bool IsThemed() const;
};
#endif // wxUSE_AUI
#endif // _WX_AUI_TABARTMSW_H_

View File

@@ -0,0 +1,223 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/tabmdi.h
// Purpose: Generic MDI (Multiple Document Interface) classes
// Author: Hans Van Leemputten
// Modified by: Benjamin I. Williams / Kirix Corporation
// Created: 29/07/2002
// Copyright: (c) Hans Van Leemputten
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_AUITABMDI_H_
#define _WX_AUITABMDI_H_
#include "wx/defs.h"
#if wxUSE_AUI && wxUSE_MDI
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/frame.h"
#include "wx/panel.h"
#include "wx/notebook.h"
#include "wx/icon.h"
#include "wx/mdi.h"
#include "wx/aui/auibook.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_AUI wxAuiMDIParentFrame;
class WXDLLIMPEXP_FWD_AUI wxAuiMDIClientWindow;
class WXDLLIMPEXP_FWD_AUI wxAuiMDIChildFrame;
//-----------------------------------------------------------------------------
// wxAuiMDIParentFrame
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_AUI wxAuiMDIParentFrame : public wxFrame
{
public:
wxAuiMDIParentFrame();
wxAuiMDIParentFrame(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxASCII_STR(wxFrameNameStr));
~wxAuiMDIParentFrame();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxASCII_STR(wxFrameNameStr) );
void SetArtProvider(wxAuiTabArt* provider);
wxAuiTabArt* GetArtProvider();
wxAuiNotebook* GetNotebook() const;
#if wxUSE_MENUS
wxMenu* GetWindowMenu() const { return m_pWindowMenu; }
void SetWindowMenu(wxMenu* pMenu);
virtual void SetMenuBar(wxMenuBar *pMenuBar) override;
#endif // wxUSE_MENUS
void SetChildMenuBar(wxAuiMDIChildFrame *pChild);
wxAuiMDIChildFrame *GetActiveChild() const;
void SetActiveChild(wxAuiMDIChildFrame* pChildFrame);
wxAuiMDIClientWindow *GetClientWindow() const;
virtual wxAuiMDIClientWindow *OnCreateClient();
virtual void Cascade() { /* Has no effect */ }
virtual void Tile(wxOrientation orient = wxHORIZONTAL);
virtual void ArrangeIcons() { /* Has no effect */ }
virtual void ActivateNext();
virtual void ActivatePrevious();
protected:
wxAuiMDIClientWindow* m_pClientWindow;
wxEvent* m_pLastEvt;
#if wxUSE_MENUS
wxMenu *m_pWindowMenu;
wxMenuBar *m_pMyMenuBar;
#endif // wxUSE_MENUS
protected:
void Init();
#if wxUSE_MENUS
void RemoveWindowMenu(wxMenuBar *pMenuBar);
void AddWindowMenu(wxMenuBar *pMenuBar);
void DoHandleMenu(wxCommandEvent &event);
void DoHandleUpdateUI(wxUpdateUIEvent &event);
#endif // wxUSE_MENUS
virtual bool ProcessEvent(wxEvent& event) override;
virtual void DoGetClientSize(int *width, int *height) const override;
private:
void OnClose(wxCloseEvent& event);
// close all children, return false if any of them vetoed it
bool CloseAll();
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxAuiMDIParentFrame);
};
//-----------------------------------------------------------------------------
// wxAuiMDIChildFrame
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_AUI wxAuiMDIChildFrame : public wxTDIChildFrame
{
public:
wxAuiMDIChildFrame();
wxAuiMDIChildFrame(wxAuiMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr));
virtual ~wxAuiMDIChildFrame();
bool Create(wxAuiMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr));
#if wxUSE_MENUS
virtual void SetMenuBar(wxMenuBar *menuBar) override;
virtual wxMenuBar *GetMenuBar() const override;
#endif // wxUSE_MENUS
virtual void SetTitle(const wxString& title) override;
virtual void SetIcons(const wxIconBundle& icons) override;
virtual void Activate() override;
virtual bool Destroy() override;
virtual bool Show(bool show = true) override;
void OnMenuHighlight(wxMenuEvent& evt);
void SetMDIParentFrame(wxAuiMDIParentFrame* parent);
wxAuiMDIParentFrame* GetMDIParentFrame() const;
protected:
void Init();
public:
// This function needs to be called when a size change is confirmed,
// we needed this function to prevent anybody from the outside
// changing the panel... it messes the UI layout when we would allow it.
void ApplyMDIChildFrameRect();
protected:
wxAuiMDIParentFrame* m_pMDIParentFrame;
bool m_activateOnCreate;
#if wxUSE_MENUS
wxMenuBar* m_pMenuBar;
#endif // wxUSE_MENUS
private:
wxDECLARE_DYNAMIC_CLASS(wxAuiMDIChildFrame);
wxDECLARE_EVENT_TABLE();
friend class wxAuiMDIClientWindow;
};
//-----------------------------------------------------------------------------
// wxAuiMDIClientWindow
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_AUI wxAuiMDIClientWindow : public wxAuiNotebook
{
public:
wxAuiMDIClientWindow();
wxAuiMDIClientWindow(wxAuiMDIParentFrame *parent, long style = 0);
virtual bool CreateClient(wxAuiMDIParentFrame *parent,
long style = wxVSCROLL | wxHSCROLL);
virtual wxAuiMDIChildFrame* GetActiveChild();
virtual void SetActiveChild(wxAuiMDIChildFrame* pChildFrame)
{
SetSelection(GetPageIndex(pChildFrame));
}
protected:
void PageChanged(int oldSelection, int newSelection);
void OnPageClose(wxAuiNotebookEvent& evt);
void OnPageChanged(wxAuiNotebookEvent& evt);
private:
wxDECLARE_DYNAMIC_CLASS(wxAuiMDIClientWindow);
wxDECLARE_EVENT_TABLE();
};
#endif // wxUSE_AUI && wxUSE_MDI
#endif // _WX_AUITABMDI_H_

View File

@@ -0,0 +1,143 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bannerwindow.h
// Purpose: wxBannerWindow class declaration
// Author: Vadim Zeitlin
// Created: 2011-08-16
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BANNERWINDOW_H_
#define _WX_BANNERWINDOW_H_
#include "wx/defs.h"
#if wxUSE_BANNERWINDOW
#include "wx/bmpbndl.h"
#include "wx/event.h"
#include "wx/window.h"
class WXDLLIMPEXP_FWD_CORE wxColour;
class WXDLLIMPEXP_FWD_CORE wxDC;
extern WXDLLIMPEXP_DATA_CORE(const char) wxBannerWindowNameStr[];
// ----------------------------------------------------------------------------
// A simple banner window showing either a bitmap or text.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBannerWindow : public wxWindow
{
public:
// Default constructor, use Create() later.
wxBannerWindow() { Init(); }
// Convenient constructor that should be used in the majority of cases.
//
// The banner orientation changes how the text in it is displayed and also
// defines where is the bitmap truncated if it's too big to fit but doesn't
// do anything for the banner position, this is supposed to be taken care
// of in the usual way, e.g. using sizers.
wxBannerWindow(wxWindow* parent, wxDirection dir = wxLEFT)
{
Init();
Create(parent, wxID_ANY, dir);
}
// Full constructor provided for consistency with the other classes only.
wxBannerWindow(wxWindow* parent,
wxWindowID winid,
wxDirection dir = wxLEFT,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxBannerWindowNameStr))
{
Init();
Create(parent, winid, dir, pos, size, style, name);
}
// Can be only called on objects created with the default constructor.
bool Create(wxWindow* parent,
wxWindowID winid,
wxDirection dir = wxLEFT,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxBannerWindowNameStr));
// Provide an existing bitmap to show. For wxLEFT orientation the bitmap is
// truncated from the top, for wxTOP and wxBOTTOM -- from the right and for
// wxRIGHT -- from the bottom, so put the most important part of the bitmap
// information in the opposite direction.
void SetBitmap(const wxBitmapBundle& bmp);
// Set the text to display. This is mutually exclusive with SetBitmap().
// Title is rendered in bold and should be single line, message can have
// multiple lines but is not wrapped automatically.
void SetText(const wxString& title, const wxString& message);
// Set the colours between which the gradient runs. This can be combined
// with SetText() but not SetBitmap().
void SetGradient(const wxColour& start, const wxColour& end);
protected:
virtual wxSize DoGetBestClientSize() const override;
private:
// Common part of all constructors.
void Init();
// Fully invalidates the window.
void OnSize(wxSizeEvent& event);
// Redraws the window using either m_bitmap or m_title/m_message.
void OnPaint(wxPaintEvent& event);
// Helper of OnPaint(): draw the bitmap at the correct position depending
// on our orientation.
void DrawBitmapBackground(wxDC& dc);
// Helper of OnPaint(): draw the text in the appropriate direction.
void DrawBannerTextLine(wxDC& dc, const wxString& str, const wxPoint& pos);
// Return the font to use for the title. Currently this is hardcoded as a
// larger bold version of the standard window font but could be made
// configurable in the future.
wxFont GetTitleFont() const;
// Return the colour to use for extending the bitmap. Non-const as it
// updates m_colBitmapBg if needed.
wxColour GetBitmapBg();
// The window side along which the banner is laid out.
wxDirection m_direction;
// If valid, this bitmap is drawn as is.
wxBitmapBundle m_bitmapBundle;
// If bitmap is valid, this is the colour we use to extend it if the bitmap
// is smaller than this window. It is computed on demand by GetBitmapBg().
wxColour m_colBitmapBg;
// The title and main message to draw, used if m_bitmap is invalid.
wxString m_title,
m_message;
// Start and stop gradient colours, only used when drawing text.
wxColour m_colStart,
m_colEnd;
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxBannerWindow);
};
#endif // wxUSE_BANNERWINDOW
#endif // _WX_BANNERWINDOW_H_

View File

@@ -0,0 +1,123 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/base64.h
// Purpose: declaration of BASE64 encoding/decoding functionality
// Author: Charles Reimers, Vadim Zeitlin
// Created: 2007-06-18
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BASE64_H_
#define _WX_BASE64_H_
#include "wx/defs.h"
#if wxUSE_BASE64
#include "wx/string.h"
#include "wx/buffer.h"
// ----------------------------------------------------------------------------
// encoding functions
// ----------------------------------------------------------------------------
// return the size needed for the buffer containing the encoded representation
// of a buffer of given length
inline size_t wxBase64EncodedSize(size_t len) { return 4*((len+2)/3); }
// raw base64 encoding function which encodes the contents of a buffer of the
// specified length into the buffer of the specified size
//
// returns the length of the encoded data or wxCONV_FAILED if the buffer is not
// large enough; to determine the needed size you can either allocate a buffer
// of wxBase64EncodedSize(srcLen) size or call the function with null buffer in
// which case the required size will be returned
WXDLLIMPEXP_BASE size_t
wxBase64Encode(char *dst, size_t dstLen, const void *src, size_t srcLen);
// encode the contents of the given buffer using base64 and return as string
// (there is no error return)
inline wxString wxBase64Encode(const void *src, size_t srcLen)
{
const size_t dstLen = wxBase64EncodedSize(srcLen);
wxCharBuffer dst(dstLen);
wxBase64Encode(dst.data(), dstLen, src, srcLen);
return wxASCII_STR(dst);
}
inline wxString wxBase64Encode(const wxMemoryBuffer& buf)
{
return wxBase64Encode(buf.GetData(), buf.GetDataLen());
}
// ----------------------------------------------------------------------------
// decoding functions
// ----------------------------------------------------------------------------
// elements of this enum specify the possible behaviours of wxBase64Decode()
// when an invalid character is encountered
enum wxBase64DecodeMode
{
// normal behaviour: stop at any invalid characters
wxBase64DecodeMode_Strict,
// skip whitespace characters
wxBase64DecodeMode_SkipWS,
// the most lenient behaviour: simply ignore all invalid characters
wxBase64DecodeMode_Relaxed
};
// return the buffer size necessary for decoding a base64 string of the given
// length
inline size_t wxBase64DecodedSize(size_t srcLen) { return 3*srcLen/4; }
// raw decoding function which decodes the contents of the string of specified
// length (or NUL-terminated by default) into the provided buffer of the given
// size
//
// the function normally stops at any character invalid inside a base64-encoded
// string (i.e. not alphanumeric nor '+' nor '/') but can be made to skip the
// whitespace or all invalid characters using its mode argument
//
// returns the length of the decoded data or wxCONV_FAILED if an error occurs
// such as the buffer is too small or the encoded string is invalid; in the
// latter case the posErr is filled with the position where the decoding
// stopped if it is not null
WXDLLIMPEXP_BASE size_t
wxBase64Decode(void *dst, size_t dstLen,
const char *src, size_t srcLen = wxNO_LEN,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr);
inline size_t
wxBase64Decode(void *dst, size_t dstLen,
const wxString& src,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr)
{
// don't use str.length() here as the ASCII buffer is shorter than it for
// strings with embedded NULs
return wxBase64Decode(dst, dstLen, src.ToAscii(), wxNO_LEN, mode, posErr);
}
// decode the contents of the given string; the returned buffer is empty if an
// error occurs during decoding
WXDLLIMPEXP_BASE wxMemoryBuffer
wxBase64Decode(const char *src, size_t srcLen = wxNO_LEN,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr);
inline wxMemoryBuffer
wxBase64Decode(const wxString& src,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr)
{
// don't use str.length() here as the ASCII buffer is shorter than it for
// strings with embedded NULs
return wxBase64Decode(src.ToAscii(), wxNO_LEN, mode, posErr);
}
#endif // wxUSE_BASE64
#endif // _WX_BASE64_H_

View File

@@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/beforestd.h
// Purpose: #include before STL headers
// Author: Vadim Zeitlin
// Created: 07/07/03
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/**
Unfortunately, when compiling at maximum warning level, the standard
headers themselves may generate warnings -- and really lots of them. So
before including them, this header should be included to temporarily
suppress the warnings and after this the header afterstd.h should be
included to enable them back again.
Note that there are intentionally no inclusion guards in this file, because
it can be included several times.
*/
#if defined(__VISUALC__) && __VISUALC__ >= 1910
#pragma warning(push, 1)
// This warning, given when a malloc.h from 10.0.240.0 version of UCRT,
// which is used when building projects targeting 8.1 SDK, compiled by MSVS
// 2017 or later, is still given even at warning level 1, in spite of it
// being level 4, so we have to explicitly disable it here (as we do it
// after the warning push pragma, it will be restored after pop).
//
// expression before comma has no effect; expected expression with side-effect
#pragma warning(disable:4548)
#endif // VC++ >= 14.1
/**
GCC's visibility support is broken for libstdc++ in some older versions
(namely Debian/Ubuntu's GCC 4.1, see
https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/109262). We fix it
here by mimicking newer versions' behaviour of using default visibility
for libstdc++ code.
*/
#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY)
#pragma GCC visibility push(default)
#endif

View File

@@ -0,0 +1,367 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bitmap.h
// Purpose: wxBitmap class interface
// Author: Vaclav Slavik
// Created: 22.04.01
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BITMAP_H_BASE_
#define _WX_BITMAP_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/string.h"
#include "wx/gdicmn.h" // for wxBitmapType
#include "wx/colour.h"
#include "wx/image.h"
#include "wx/variant.h"
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
class WXDLLIMPEXP_FWD_CORE wxCursor;
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxMask;
class WXDLLIMPEXP_FWD_CORE wxPalette;
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
// ----------------------------------------------------------------------------
// wxMask represents the transparent area of the bitmap
// ----------------------------------------------------------------------------
// TODO: all implementation of wxMask, except the generic one,
// do not derive from wxMaskBase,,, they should
class WXDLLIMPEXP_CORE wxMaskBase : public wxObject
{
public:
// create the mask from bitmap pixels of the given colour
bool Create(const wxBitmap& bitmap, const wxColour& colour);
#if wxUSE_PALETTE
// create the mask from bitmap pixels with the given palette index
bool Create(const wxBitmap& bitmap, int paletteIndex);
#endif // wxUSE_PALETTE
// create the mask from the given mono bitmap
bool Create(const wxBitmap& bitmap);
protected:
// this function is called from Create() to free the existing mask data
virtual void FreeData() = 0;
// these functions must be overridden to implement the corresponding public
// Create() methods, they shouldn't call FreeData() as it's already called
// by the public wrappers
virtual bool InitFromColour(const wxBitmap& bitmap,
const wxColour& colour) = 0;
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) = 0;
};
#if defined(__WXDFB__) || \
defined(__WXMAC__) || \
defined(__WXGTK__) || \
defined(__WXX11__) || \
defined(__WXQT__)
#define wxUSE_BITMAP_BASE 1
#else
#define wxUSE_BITMAP_BASE 0
#endif
// a more readable way to tell
#define wxBITMAP_SCREEN_DEPTH (-1)
// ----------------------------------------------------------------------------
// wxBitmapHelpers: container for various bitmap methods common to all ports.
// ----------------------------------------------------------------------------
// Unfortunately, currently wxBitmap does not inherit from wxBitmapBase on all
// platforms and this is not easy to fix. So we extract at least some common
// methods into this class from which both wxBitmapBase (and hence wxBitmap on
// all platforms where it does inherit from it) and wxBitmap in wxMSW and other
// exceptional ports (only wxPM and old wxCocoa) inherit.
class WXDLLIMPEXP_CORE wxBitmapHelpers
{
public:
// Create a new wxBitmap from the PNG data in the given buffer.
static wxBitmap NewFromPNGData(const void* data, size_t size);
// Rescale the given bitmap to the requested size.
static void Rescale(wxBitmap& bmp, const wxSize& sizeNeeded);
// wxVariant support
wxDECLARE_VARIANT_OBJECT_EXPORTED(wxBitmap, WXDLLIMPEXP_CORE);
};
// All ports except wxMSW use wxBitmapHandler and wxBitmapBase as
// base class for wxBitmapHandler; wxMSW uses wxGDIImageHandler as
// base class since it allows some code reuse there.
#if wxUSE_BITMAP_BASE
// ----------------------------------------------------------------------------
// wxBitmapHandler: class which knows how to create/load/save bitmaps in
// different formats
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapHandler : public wxObject
{
public:
wxBitmapHandler() { m_type = wxBITMAP_TYPE_INVALID; }
virtual ~wxBitmapHandler() = default;
// NOTE: the following functions should be pure virtuals, but they aren't
// because otherwise almost all ports would have to implement
// them as "return false"...
virtual bool Create(wxBitmap *WXUNUSED(bitmap), const void* WXUNUSED(data),
wxBitmapType WXUNUSED(type), int WXUNUSED(width), int WXUNUSED(height),
int WXUNUSED(depth) = 1)
{ return false; }
virtual bool LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name),
wxBitmapType WXUNUSED(type), int WXUNUSED(desiredWidth),
int WXUNUSED(desiredHeight))
{ return false; }
virtual bool SaveFile(const wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name),
wxBitmapType WXUNUSED(type), const wxPalette *WXUNUSED(palette) = nullptr) const
{ return false; }
void SetName(const wxString& name) { m_name = name; }
void SetExtension(const wxString& ext) { m_extension = ext; }
void SetType(wxBitmapType type) { m_type = type; }
const wxString& GetName() const { return m_name; }
const wxString& GetExtension() const { return m_extension; }
wxBitmapType GetType() const { return m_type; }
private:
wxString m_name;
wxString m_extension;
wxBitmapType m_type;
wxDECLARE_ABSTRACT_CLASS(wxBitmapHandler);
};
// ----------------------------------------------------------------------------
// wxBitmap: class which represents platform-dependent bitmap (unlike wxImage)
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapBase : public wxGDIObject,
public wxBitmapHelpers
{
public:
/*
Derived class must implement these:
wxBitmap();
wxBitmap(const wxBitmap& bmp);
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
wxBitmap(const char* const* bits);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH, double scale = 1.0);
static void InitStandardHandlers();
*/
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) = 0;
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) = 0;
// DIP size and logical size are the same thing for ports using scaling,
// i.e. where physical and logical sizes are different (e.g. wxGTK and
// wxOSX), but we want to have both sets of functions to use them in the
// ports where physical and logical sizes are the same (wxMSW).
bool CreateWithDIPSize(const wxSize& sz,
double scale,
int depth = wxBITMAP_SCREEN_DEPTH)
{ return DoCreate(sz, scale, depth); }
bool CreateWithDIPSize(int width, int height,
double scale,
int depth = wxBITMAP_SCREEN_DEPTH)
{ return DoCreate(wxSize(width, height), scale, depth); }
bool CreateWithLogicalSize(const wxSize& sz,
double scale,
int depth = wxBITMAP_SCREEN_DEPTH)
{ return DoCreate(sz, scale, depth); }
bool CreateWithLogicalSize(int width, int height,
double scale,
int depth = wxBITMAP_SCREEN_DEPTH)
{ return DoCreate(wxSize(width, height), scale, depth); }
virtual int GetHeight() const = 0;
virtual int GetWidth() const = 0;
virtual int GetDepth() const = 0;
wxSize GetSize() const
{ return wxSize(GetWidth(), GetHeight()); }
// Store or return the scale factor, which determines the ratio between the
// bitmap physical size and its DIP size (on all platforms). By default
// it's just 1.
virtual void SetScaleFactor(double scale);
virtual double GetScaleFactor() const;
// This function returns the size divided by the scale factor, so that a
// 64x64 bitmap with a scale factor of 2 has DIP size of 32x32 everywhere.
wxSize GetDIPSize() const;
// These functions return the corresponding metrics divided by the scale
// factor on platforms with DPI-independent pixels (e.g. GTK, Mac) and just
// return the same thing as normal accessors elsewhere (e.g. MSW).
double GetLogicalWidth() const;
double GetLogicalHeight() const;
wxSize GetLogicalSize() const;
// Old synonyms for CreateWithDIPSize() and GetLogicalXXX() functions,
// prefer the new names in the new code.
bool CreateScaled(int w, int h, int d, double logicalScale)
{ return CreateWithDIPSize(w, h, logicalScale, d); }
double GetScaledWidth() const { return GetLogicalWidth(); }
double GetScaledHeight() const { return GetLogicalHeight(); }
wxSize GetScaledSize() const { return GetLogicalSize(); }
#if wxUSE_IMAGE
virtual wxImage ConvertToImage() const = 0;
// Convert to disabled (dimmed) bitmap.
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
#endif // wxUSE_IMAGE
virtual wxMask *GetMask() const = 0;
virtual void SetMask(wxMask *mask) = 0;
virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
virtual bool SaveFile(const wxString &name, wxBitmapType type,
const wxPalette *palette = nullptr) const = 0;
virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
/*
If raw bitmap access is supported (see wx/rawbmp.h), the following
methods should be implemented:
virtual bool GetRawData(wxRawBitmapData *data) = 0;
virtual void UngetRawData(wxRawBitmapData *data) = 0;
*/
#if wxUSE_PALETTE
virtual wxPalette *GetPalette() const = 0;
virtual void SetPalette(const wxPalette& palette) = 0;
#endif // wxUSE_PALETTE
// Alpha support for 32bpp bitmaps: check if it's used, request that it be
// used or not.
virtual bool HasAlpha() const;
virtual bool UseAlpha(bool use = true);
void ResetAlpha() { UseAlpha(false); }
// copies the contents and mask of the given (colour) icon to the bitmap
bool CopyFromIcon(const wxIcon& icon);
// implementation:
#if WXWIN_COMPATIBILITY_3_0
// deprecated
virtual void SetHeight(int height) = 0;
virtual void SetWidth(int width) = 0;
virtual void SetDepth(int depth) = 0;
#endif
// Format handling
static inline wxList& GetHandlers() { return sm_handlers; }
static void AddHandler(wxBitmapHandler *handler);
static void InsertHandler(wxBitmapHandler *handler);
static bool RemoveHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType);
static wxBitmapHandler *FindHandler(wxBitmapType bitmapType);
//static void InitStandardHandlers();
// (wxBitmap must implement this one)
static void CleanUpHandlers();
// this method is only used by the generic implementation of wxMask
// currently but could be useful elsewhere in the future: it can be
// overridden to quantize the colour to correspond to bitmap colour depth
// if necessary; default implementation simply returns the colour as is
virtual wxColour QuantizeColour(const wxColour& colour) const
{
return colour;
}
protected:
virtual bool DoCreate(const wxSize& sz, double scale, int depth);
static wxList sm_handlers;
wxDECLARE_ABSTRACT_CLASS(wxBitmapBase);
};
#endif // wxUSE_BITMAP_BASE
// the wxBITMAP_DEFAULT_TYPE constant defines the default argument value
// for wxBitmap's ctor and wxBitmap::LoadFile() functions.
#if defined(__WXMSW__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#include "wx/msw/bitmap.h"
#elif defined(__WXGTK__)
#ifdef __WINDOWS__
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#else
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#endif
#include "wx/gtk/bitmap.h"
#elif defined(__WXX11__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/x11/bitmap.h"
#elif defined(__WXDFB__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#include "wx/dfb/bitmap.h"
#elif defined(__WXMAC__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_PICT_RESOURCE
#include "wx/osx/bitmap.h"
#elif defined(__WXQT__)
#ifdef __WINDOWS__
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#else
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#endif
#include "wx/qt/bitmap.h"
#endif
#if wxUSE_IMAGE
inline
wxBitmap
#if wxUSE_BITMAP_BASE
wxBitmapBase::
#else
wxBitmap::
#endif
ConvertToDisabled(unsigned char brightness) const
{
const wxImage imgDisabled = ConvertToImage().ConvertToDisabled(brightness);
return wxBitmap(imgDisabled, -1, GetScaleFactor());
}
#endif // wxUSE_IMAGE
// we must include generic mask.h after wxBitmap definition
#if defined(__WXDFB__)
#define wxUSE_GENERIC_MASK 1
#else
#define wxUSE_GENERIC_MASK 0
#endif
#if wxUSE_GENERIC_MASK
#include "wx/generic/mask.h"
#endif
#endif // _WX_BITMAP_H_BASE_

View File

@@ -0,0 +1,287 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpbndl.h
// Purpose: Declaration of wxBitmapBundle class.
// Author: Vadim Zeitlin
// Created: 2021-09-22
// Copyright: (c) 2021 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPBNDL_H_
#define _WX_BMPBNDL_H_
#include "wx/bitmap.h"
#include "wx/object.h"
#include "wx/vector.h"
class wxBitmapBundleImpl;
class WXDLLIMPEXP_FWD_CORE wxIconBundle;
class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_BASE wxVariant;
class WXDLLIMPEXP_FWD_CORE wxWindow;
// ----------------------------------------------------------------------------
// wxBitmapBundle provides 1 or more versions of a bitmap, all bundled together
// ----------------------------------------------------------------------------
// This class has value semantics and can be copied cheaply.
class WXDLLIMPEXP_CORE wxBitmapBundle
{
public:
// Default ctor constructs an empty bundle which can't be used for
// anything, but can be assigned something later.
wxBitmapBundle();
// This conversion ctor from a single bitmap does the same thing as
// FromBitmap() and only exists for interoperability with the existing code
// using wxBitmap.
wxBitmapBundle(const wxBitmap& bitmap);
// This is similar to above and also exists only for compatibility.
wxBitmapBundle(const wxIcon& icon);
// Another conversion ctor from a single image: this one is needed to allow
// passing wxImage to the functions that used to take wxBitmap but now take
// wxBitmapBundle.
wxBitmapBundle(const wxImage& image);
// And another one from XPM data, as it's relatively common to pass it to
// various functions that take wxBitmapBundle in the existing code. It is
// not formally deprecated, but should be avoided in any new code and can
// become deprecated in the future.
wxBitmapBundle(const char* const* xpm);
// Default copy ctor and assignment operator and dtor would be ok, but need
// to be defined out of line, where wxBitmapBundleImpl is fully declared.
wxBitmapBundle(const wxBitmapBundle& other);
wxBitmapBundle& operator=(const wxBitmapBundle& other);
~wxBitmapBundle();
// Create from the given collection of bitmaps (all of which must be valid,
// but if the vector itself is empty, empty bundle is returned).
wxNODISCARD static wxBitmapBundle FromBitmaps(const wxVector<wxBitmap>& bitmaps);
wxNODISCARD static wxBitmapBundle FromBitmaps(const wxBitmap& bitmap1,
const wxBitmap& bitmap2);
// Create from a single bitmap (this is only useful for compatibility
// with the existing code). Returns empty bundle if bitmap is invalid.
wxNODISCARD static wxBitmapBundle FromBitmap(const wxBitmap& bitmap);
wxNODISCARD static wxBitmapBundle FromImage(const wxImage& image);
// Create from icon bundle.
wxNODISCARD static wxBitmapBundle FromIconBundle(const wxIconBundle& iconBundle);
// It should be possible to implement SVG rasterizing without raw bitmap
// support using wxDC::DrawSpline(), but currently we don't do it and so
// FromSVG() is only available in the ports providing raw bitmap access.
#ifdef wxHAS_SVG
// Create from the SVG data (data is supposed to be in UTF-8 encoding).
// Notice that the data here is non-const because it can be temporarily
// modified while parsing it.
wxNODISCARD static wxBitmapBundle FromSVG(char* data, const wxSize& sizeDef);
// This overload currently makes a copy of the data.
wxNODISCARD static wxBitmapBundle FromSVG(const char* data, const wxSize& sizeDef);
// This overload works for data not terminated with 0
wxNODISCARD static wxBitmapBundle FromSVG(const wxByte* data, size_t len, const wxSize& sizeDef);
// Load SVG image from the given file (must be a local file, not an URL).
wxNODISCARD static wxBitmapBundle FromSVGFile(const wxString& path, const wxSize& sizeDef);
// Create from SVG image stored as an application resource.
// On Windows, name must be a resource with RT_RCDATA type.
// On MacOS, name must be a file with an extension "svg" placed in the
// "Resources" subdirectory of the application bundle.
wxNODISCARD static wxBitmapBundle FromSVGResource(const wxString& name, const wxSize& sizeDef);
#endif // wxHAS_SVG
// Create from the resources: all existing versions of the bitmap of the
// form name_2x or name@2x (and also using other factors) will be used.
wxNODISCARD static wxBitmapBundle FromResources(const wxString& name);
// Create from files: all existing versions of the bitmap of the
// form filename_2x or name@2x (and also using other factors) will be used.
wxNODISCARD static wxBitmapBundle FromFiles(const wxString& fullpathname);
wxNODISCARD static wxBitmapBundle FromFiles(const wxString& path, const wxString& filename, const wxString& extension = wxASCII_STR("png"));
// Create from existing implementation
wxNODISCARD static wxBitmapBundle FromImpl(wxBitmapBundleImpl* impl);
// Check if bitmap bundle is non-empty.
wxNODISCARD bool IsOk() const { return m_impl.get() != nullptr; }
// Clear the bundle contents, IsOk() will return false after doing this.
void Clear();
// Get the size of the bitmap represented by this bundle when using the
// default DPI, i.e. 100% scaling. Returns invalid size for empty bundle.
wxNODISCARD wxSize GetDefaultSize() const;
// Get the physical size of the preferred bitmap at the given scale.
wxNODISCARD wxSize GetPreferredBitmapSizeAtScale(double scale) const;
// Get preferred size, i.e. usually the closest size in which a bitmap is
// available to the ideal size determined from the default size and the DPI
// scaling, for the given window, in physical/logical pixels respectively.
wxNODISCARD wxSize GetPreferredBitmapSizeFor(const wxWindow* window) const;
wxNODISCARD wxSize GetPreferredLogicalSizeFor(const wxWindow* window) const;
// Get bitmap of the specified size, creating a new bitmap from the closest
// available size by rescaling it if necessary.
//
// If size == wxDefaultSize, GetDefaultSize() is used for it instead.
wxNODISCARD wxBitmap GetBitmap(const wxSize& size) const;
// Get icon of the specified size, this is just a convenient wrapper for
// GetBitmap() converting the returned bitmap to the icon.
wxNODISCARD wxIcon GetIcon(const wxSize& size) const;
// Helpers combining GetPreferredBitmapSizeFor() and GetBitmap() or
// GetIcon(): return the bitmap or icon of the size appropriate for the
// current DPI scaling of the given window.
wxNODISCARD wxBitmap GetBitmapFor(const wxWindow* window) const;
wxNODISCARD wxIcon GetIconFor(const wxWindow* window) const;
// Access implementation
wxNODISCARD wxBitmapBundleImpl* GetImpl() const { return m_impl.get(); }
// Check if two objects refer to the same bundle.
wxNODISCARD bool IsSameAs(const wxBitmapBundle& other) const
{
return GetImpl() == other.GetImpl();
}
// Allow using wxBitmapBundle with wxVariant
#if wxUSE_VARIANT
friend WXDLLIMPEXP_CORE
wxBitmapBundle& operator<<(wxBitmapBundle& value, const wxVariant& variant);
friend WXDLLIMPEXP_CORE
wxVariant& operator<<(wxVariant& variant, const wxBitmapBundle& value);
#endif // wxUSE_VARIANT
// Implementation only from now on.
// Get the bitmap size preferred by the majority of the elements of the
// bundles at the given scale or the scale appropriate for the given window.
wxNODISCARD static wxSize
GetConsensusSizeFor(double scale, const wxVector<wxBitmapBundle>& bundles);
wxNODISCARD static wxSize
GetConsensusSizeFor(const wxWindow* win, const wxVector<wxBitmapBundle>& bundles);
// Create wxImageList and fill it with the images from the given bundles in
// the sizes appropriate for the DPI scaling used for the specified window.
wxNODISCARD static wxImageList*
CreateImageList(const wxWindow* win, const wxVector<wxBitmapBundle>& bundles);
private:
typedef wxObjectDataPtr<wxBitmapBundleImpl> wxBitmapBundleImplPtr;
// Private ctor used by static factory functions to create objects of this
// class. It takes ownership of the pointer (which must be non-null).
explicit wxBitmapBundle(wxBitmapBundleImpl* impl);
wxBitmapBundleImplPtr m_impl;
};
// This macro can be used to create a bundle from resources on the platforms
// that support it and from name_png and name_2x_png on the other ones.
#ifdef wxHAS_IMAGE_RESOURCES
#define wxBITMAP_BUNDLE_2(name) wxBitmapBundle::FromResources(#name)
#else
#define wxBITMAP_BUNDLE_2(name) \
wxBitmapBundle::FromBitmaps(wxBITMAP_PNG_FROM_DATA(name), \
wxBITMAP_PNG_FROM_DATA(name##_2x))
#endif
// Inline functions implementation.
/* static */ inline
wxBitmapBundle wxBitmapBundle::FromBitmaps(const wxBitmap& bitmap1,
const wxBitmap& bitmap2)
{
wxVector<wxBitmap> bitmaps;
if ( bitmap1.IsOk() )
bitmaps.push_back(bitmap1);
if ( bitmap2.IsOk() )
bitmaps.push_back(bitmap2);
return FromBitmaps(bitmaps);
}
/* static */ inline
wxBitmapBundle wxBitmapBundle::FromBitmap(const wxBitmap& bitmap)
{
return wxBitmapBundle(bitmap);
}
/* static */ inline
wxBitmapBundle wxBitmapBundle::FromImage(const wxImage& image)
{
if ( !image.IsOk() )
return wxBitmapBundle();
return FromBitmap(wxBitmap(image));
}
// ----------------------------------------------------------------------------
// wxBitmapBundleImpl is the base class for all wxBitmapBundle implementations
// ----------------------------------------------------------------------------
// This class inherits from wxRefCounter to make it possible to use it with
// wxObjectDataPtr in wxBitmapBundle.
//
// It doesn't need to be used directly, but may be inherited from in order to
// implement custom bitmap bundles.
class WXDLLIMPEXP_CORE wxBitmapBundleImpl : public wxRefCounter
{
protected:
// Standard implementation of GetPreferredBitmapSizeAtScale(): choose the
// scale closest to the given one from the available bitmap scales.
//
// If this function is used, GetNextAvailableScale() must be overridden!
wxSize DoGetPreferredSize(double scale) const;
// Helper for implementing GetBitmap(): if we need to upscale a bitmap,
// uses GetNextAvailableScale() to find the index of the best bitmap to
// use, where "best" is defined as "using scale which is a divisor of the
// given one", as upscaling by an integer factor is strongly preferable.
size_t GetIndexToUpscale(const wxSize& size) const;
// Override this function if DoGetPreferredSize() or GetIndexToUpscale() is
// used: it can use the provided parameter as an internal index, it's
// guaranteed to be 0 when calling this function for the first time. When
// there are no more scales, return 0.
//
// This function is not pure virtual because it doesn't need to be
// implemented if DoGetPreferredSize() is never used, but it will assert if
// it's called.
virtual double GetNextAvailableScale(size_t& i) const;
virtual ~wxBitmapBundleImpl();
public:
// Return the size of the bitmaps represented by this bundle in the default
// DPI (a.k.a. 100% resolution).
//
// Must always return a valid size.
virtual wxSize GetDefaultSize() const = 0;
// Return the preferred size that should be used at the given scale.
//
// Must always return a valid size.
virtual wxSize GetPreferredBitmapSizeAtScale(double scale) const = 0;
// Retrieve the bitmap of exactly the given size.
//
// Note that this function is non-const because it may generate the bitmap
// on demand and cache it.
virtual wxBitmap GetBitmap(const wxSize& size) = 0;
};
#endif // _WX_BMPBNDL_H_

View File

@@ -0,0 +1,142 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpbuttn.h
// Purpose: wxBitmapButton class interface
// Author: Vadim Zeitlin
// Created: 25.08.00
// Copyright: (c) 2000 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPBUTTON_H_BASE_
#define _WX_BMPBUTTON_H_BASE_
#include "wx/defs.h"
#if wxUSE_BMPBUTTON
#include "wx/button.h"
// FIXME: right now only wxMSW, wxGTK and wxOSX implement bitmap support in wxButton
// itself, this shouldn't be used for the other platforms either
// when all of them do it
#if (defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXOSX__) || defined(__WXQT__)) && !defined(__WXUNIVERSAL__)
#define wxHAS_BUTTON_BITMAP
#endif
class WXDLLIMPEXP_FWD_CORE wxBitmapButton;
// ----------------------------------------------------------------------------
// wxBitmapButton: a button which shows bitmaps instead of the usual string.
// It has different bitmaps for different states (focused/disabled/pressed)
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapButtonBase : public wxButton
{
public:
wxBitmapButtonBase()
{
#ifndef wxHAS_BUTTON_BITMAP
m_marginX =
m_marginY = 0;
#endif // wxHAS_BUTTON_BITMAP
}
bool Create(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
// We use wxBU_NOTEXT to let the base class Create() know that we are
// not going to show the label: this is a hack needed for wxGTK where
// we can show both label and bitmap only with GTK 2.6+ but we always
// can show just one of them and this style allows us to choose which
// one we need.
//
// And we also use wxBU_EXACTFIT to avoid being resized up to the
// standard button size as this doesn't make sense for bitmap buttons
// which are not standard anyhow and should fit their bitmap size.
return wxButton::Create(parent, winid, wxString(),
pos, size,
style | wxBU_NOTEXT | wxBU_EXACTFIT,
validator, name);
}
/*
Derived classes also need to declare, but not define, as it's done in
common code in bmpbtncmn.cpp, the following function:
bool CreateCloseButton(wxWindow* parent,
wxWindowID winid,
const wxString& name = wxString());
which is used by NewCloseButton(), and, as Create(), must be
called on default-constructed wxBitmapButton object.
*/
// Special creation function for a standard "Close" bitmap. It allows to
// simply create a close button with the image appropriate for the current
// platform.
static wxBitmapButton*
NewCloseButton(wxWindow* parent,
wxWindowID winid,
const wxString& name = wxString());
// set/get the margins around the button
virtual void SetMargins(int x, int y)
{
DoSetBitmapMargins(x, y);
}
int GetMarginX() const { return DoGetBitmapMargins().x; }
int GetMarginY() const { return DoGetBitmapMargins().y; }
protected:
#ifndef wxHAS_BUTTON_BITMAP
// function called when any of the bitmaps changes
virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); }
virtual wxBitmap DoGetBitmap(State which) const
{ return m_bitmaps[which].GetBitmap(wxDefaultSize); }
virtual void DoSetBitmap(const wxBitmapBundle& bitmap, State which)
{ m_bitmaps[which] = bitmap; OnSetBitmap(); }
virtual wxSize DoGetBitmapMargins() const
{
return wxSize(m_marginX, m_marginY);
}
virtual void DoSetBitmapMargins(int x, int y)
{
m_marginX = x;
m_marginY = y;
}
// the bitmap bundles for various states
wxBitmapBundle m_bitmaps[State_Max];
// the margins around the bitmap
int m_marginX,
m_marginY;
#endif // !wxHAS_BUTTON_BITMAP
wxDECLARE_NO_COPY_CLASS(wxBitmapButtonBase);
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/bmpbuttn.h"
#elif defined(__WXMSW__)
#include "wx/msw/bmpbuttn.h"
#elif defined(__WXGTK__)
#include "wx/gtk/bmpbuttn.h"
#elif defined(__WXMAC__)
#include "wx/osx/bmpbuttn.h"
#elif defined(__WXQT__)
#include "wx/qt/bmpbuttn.h"
#endif
#endif // wxUSE_BMPBUTTON
#endif // _WX_BMPBUTTON_H_BASE_

View File

@@ -0,0 +1,124 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpcbox.h
// Purpose: wxBitmapComboBox base header
// Author: Jaakko Salli
// Created: Aug-31-2006
// Copyright: (c) Jaakko Salli
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPCBOX_H_BASE_
#define _WX_BMPCBOX_H_BASE_
#include "wx/defs.h"
#if wxUSE_BITMAPCOMBOBOX
#include "wx/bmpbndl.h"
#include "wx/dynarray.h"
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxItemContainer;
// Define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED for platforms which
// wxBitmapComboBox implementation utilizes ownerdrawn combobox
// (either native or generic).
#if !defined(__WXGTK__) || defined(__WXUNIVERSAL__)
#define wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
class WXDLLIMPEXP_FWD_CORE wxDC;
#endif
extern WXDLLIMPEXP_DATA_CORE(const char) wxBitmapComboBoxNameStr[];
class WXDLLIMPEXP_CORE wxBitmapComboBoxBase
{
public:
// ctors and such
wxBitmapComboBoxBase() { Init(); }
virtual ~wxBitmapComboBoxBase() = default;
// Sets the image for the given item.
virtual void SetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap) = 0;
#if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
// Returns the image of the item with the given index.
virtual wxBitmap GetItemBitmap(unsigned int n) const = 0;
// Returns size of the image used in list
virtual wxSize GetBitmapSize() const = 0;
private:
void Init() {}
#else // wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
// Returns the image of the item with the given index.
virtual wxBitmap GetItemBitmap(unsigned int n) const;
// Returns size of the image used in list
virtual wxSize GetBitmapSize() const
{
return m_usedImgSize;
}
protected:
// Returns pointer to the combobox item container
virtual wxItemContainer* GetItemContainer() = 0;
// Return pointer to the owner-drawn combobox control
virtual wxWindow* GetControl() = 0;
// wxItemContainer functions
void BCBDoClear();
void BCBDoDeleteOneItem(unsigned int n);
void DoSetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap);
void DrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const;
void DrawItem(wxDC& dc, const wxRect& rect, int item, const wxString& text,
int flags) const;
wxCoord MeasureItem(size_t item) const;
// Returns true if image size was affected
virtual bool OnAddBitmap(const wxBitmapBundle& bitmap);
// Recalculates amount of empty space needed in front of text
// in control itself. Returns number that can be passed to
// wxOwnerDrawnComboBox::SetCustomPaintWidth() and similar
// functions.
virtual int DetermineIndent();
void UpdateInternals();
wxVector<wxBitmapBundle> m_bitmapbundles;// Images associated with items
wxSize m_usedImgSize; // Size of bitmaps
int m_imgAreaWidth; // Width and height of area next to text field
int m_fontHeight;
int m_indent;
private:
void Init();
#endif // !wxBITMAPCOMBOBOX_OWNERDRAWN_BASED/wxBITMAPCOMBOBOX_OWNERDRAWN_BASED
};
#if defined(__WXUNIVERSAL__)
#include "wx/generic/bmpcbox.h"
#elif defined(__WXMSW__)
#include "wx/msw/bmpcbox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/bmpcbox.h"
#else
#include "wx/generic/bmpcbox.h"
#endif
#endif // wxUSE_BITMAPCOMBOBOX
#endif // _WX_BMPCBOX_H_BASE_

View File

@@ -0,0 +1,454 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bookctrl.h
// Purpose: wxBookCtrlBase: common base class for wxList/Tree/Notebook
// Author: Vadim Zeitlin
// Created: 19.08.03
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BOOKCTRL_H_
#define _WX_BOOKCTRL_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_BOOKCTRL
#include "wx/control.h"
#include "wx/vector.h"
#include "wx/withimages.h"
class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// wxBookCtrl hit results
enum
{
wxBK_HITTEST_NOWHERE = 1, // not on tab
wxBK_HITTEST_ONICON = 2, // on icon
wxBK_HITTEST_ONLABEL = 4, // on label
wxBK_HITTEST_ONITEM = 16, // on tab control but not on its icon or label
wxBK_HITTEST_ONPAGE = 8 // not on tab control, but over the selected page
};
// wxBookCtrl flags (common for wxNotebook, wxListbook, wxChoicebook, wxTreebook)
#define wxBK_DEFAULT 0x0000
#define wxBK_TOP 0x0010
#define wxBK_BOTTOM 0x0020
#define wxBK_LEFT 0x0040
#define wxBK_RIGHT 0x0080
#define wxBK_ALIGN_MASK (wxBK_TOP | wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT)
// ----------------------------------------------------------------------------
// wxBookCtrlBase
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBookCtrlBase : public wxControl,
public wxWithImages
{
public:
// construction
// ------------
wxBookCtrlBase()
{
Init();
}
wxBookCtrlBase(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString)
{
Init();
(void)Create(parent, winid, pos, size, style, name);
}
// quasi ctor
bool Create(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
// accessors
// ---------
// get number of pages in the dialog
virtual size_t GetPageCount() const { return m_pages.size(); }
// get the panel which represents the given page
virtual wxWindow *GetPage(size_t n) const { return m_pages.at(n); }
// get the current page or nullptr if none
wxWindow *GetCurrentPage() const
{
const int n = GetSelection();
return n == wxNOT_FOUND ? nullptr : GetPage(n);
}
// get the currently selected page or wxNOT_FOUND if none
virtual int GetSelection() const { return m_selection; }
// set/get the title of a page
virtual bool SetPageText(size_t n, const wxString& strText) = 0;
virtual wxString GetPageText(size_t n) const = 0;
// image list stuff: each page may have an image associated with it (all
// images belong to the same image list)
// ---------------------------------------------------------------------
// sets/returns item's image index in the current image list
virtual int GetPageImage(size_t n) const = 0;
virtual bool SetPageImage(size_t n, int imageId) = 0;
// geometry
// --------
// resize the notebook so that all pages will have the specified size
virtual void SetPageSize(const wxSize& size);
// return the size of the area needed to accommodate the controller
wxSize GetControllerSize() const;
// calculate the size of the control from the size of its page
//
// by default this simply returns size enough to fit both the page and the
// controller
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
// get/set size of area between book control area and page area
unsigned int GetInternalBorder() const { return m_internalBorder; }
void SetInternalBorder(unsigned int border) { m_internalBorder = border; }
// Sets/gets the margin around the controller
void SetControlMargin(int margin) { m_controlMargin = margin; }
int GetControlMargin() const { return m_controlMargin; }
// returns true if we have wxBK_TOP or wxBK_BOTTOM style
bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
// set/get option to shrink to fit current page
void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
// returns the sizer containing the control, if any
wxSizer* GetControlSizer() const { return m_controlSizer; }
// operations
// ----------
// remove one page from the control and delete it
virtual bool DeletePage(size_t n);
// remove one page from the notebook, without deleting it
virtual bool RemovePage(size_t n)
{
DoInvalidateBestSize();
return DoRemovePage(n) != nullptr;
}
// remove all pages and delete them
virtual bool DeleteAllPages()
{
m_selection = wxNOT_FOUND;
DoInvalidateBestSize();
WX_CLEAR_ARRAY(m_pages);
return true;
}
// adds a new page to the control
virtual bool AddPage(wxWindow *page,
const wxString& text,
bool bSelect = false,
int imageId = NO_IMAGE)
{
DoInvalidateBestSize();
return InsertPage(GetPageCount(), page, text, bSelect, imageId);
}
// the same as AddPage(), but adds the page at the specified position
virtual bool InsertPage(size_t n,
wxWindow *page,
const wxString& text,
bool bSelect = false,
int imageId = NO_IMAGE) = 0;
// set the currently selected page, return the index of the previously
// selected one (or wxNOT_FOUND on error)
//
// NB: this function will generate PAGE_CHANGING/ED events
virtual int SetSelection(size_t n) = 0;
// acts as SetSelection but does not generate events
virtual int ChangeSelection(size_t n) = 0;
// cycle thru the pages
void AdvanceSelection(bool forward = true)
{
int nPage = GetNextPage(forward);
if ( nPage != wxNOT_FOUND )
{
// cast is safe because of the check above
SetSelection((size_t)nPage);
}
}
// return the index of the given page or wxNOT_FOUND
virtual int FindPage(const wxWindow* page) const;
// hit test: returns which page is hit and, optionally, where (icon, label)
virtual int HitTest(const wxPoint& WXUNUSED(pt),
long * WXUNUSED(flags) = nullptr) const
{
return wxNOT_FOUND;
}
// we do have multiple pages
virtual bool HasMultiplePages() const override { return true; }
// returns true if the platform should explicitly apply a theme border
virtual bool CanApplyThemeBorder() const override { return false; }
// Implementation only from now on.
// Returns an empty bundle if no image is specified for this page.
wxBitmapBundle GetPageBitmapBundle(size_t n) const
{
return GetBitmapBundle(GetPageImage(n));
}
protected:
// flags for DoSetSelection()
enum
{
SetSelection_SendEvent = 1
};
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
// After the insertion of the page in the method InsertPage, calling this
// method sets the selection to the given page or the first one if there is
// still no selection. The "selection changed" event is sent only if
// bSelect is true, so when it is false, no event is sent even if the
// selection changed from wxNOT_FOUND to 0 when inserting the first page.
//
// Returns true if the selection was set to the specified page (explicitly
// because of bSelect == true or implicitly because it's the first page) or
// false otherwise.
bool DoSetSelectionAfterInsertion(size_t n, bool bSelect);
// Update the selection after removing the page at the given index,
// typically called from the derived class overridden DoRemovePage().
void DoSetSelectionAfterRemoval(size_t n);
// set the selection to the given page, sending the events (which can
// possibly prevent the page change from taking place) if SendEvent flag is
// included
virtual int DoSetSelection(size_t nPage, int flags = 0);
// if the derived class uses DoSetSelection() for implementing
// [Set|Change]Selection, it must override UpdateSelectedPage(),
// CreatePageChangingEvent() and MakeChangedEvent(), but as it might not
// use it, these functions are not pure virtual
// called to notify the control about a new current page
virtual void UpdateSelectedPage(size_t WXUNUSED(newsel))
{ wxFAIL_MSG(wxT("Override this function!")); }
// create a new "page changing" event
virtual wxBookCtrlEvent* CreatePageChangingEvent() const
{ wxFAIL_MSG(wxT("Override this function!")); return nullptr; }
// modify the event created by CreatePageChangingEvent() to "page changed"
// event, usually by just calling SetEventType() on it
virtual void MakeChangedEvent(wxBookCtrlEvent& WXUNUSED(event))
{ wxFAIL_MSG(wxT("Override this function!")); }
// The derived class also may override the following method, also called
// from DoSetSelection(), to show/hide pages differently.
virtual void DoShowPage(wxWindow* page, bool show) { page->Show(show); }
// Should we accept null page pointers in Add/InsertPage()?
//
// Default is no but derived classes may override it if they can treat null
// pages in some sensible way (e.g. wxTreebook overrides this to allow
// having nodes without any associated page)
virtual bool AllowNullPage() const { return false; }
// For classes that allow null pages, we also need a way to find the
// closest non-null page corresponding to the given index, e.g. the first
// leaf item in wxTreebook tree and this method must be overridden to
// return it if AllowNullPage() is overridden. Note that it can still
// return null if there are no valid pages after this one.
virtual wxWindow *TryGetNonNullPage(size_t page) { return GetPage(page); }
// Remove the page and return a pointer to it.
//
// It also needs to update the current selection if necessary, i.e. if the
// page being removed comes before the selected one and the helper method
// DoSetSelectionAfterRemoval() can be used for this.
virtual wxWindow *DoRemovePage(size_t page) = 0;
// our best size is the size which fits all our pages
virtual wxSize DoGetBestSize() const override;
// helper: get the next page wrapping if we reached the end
virtual int GetNextPage(bool forward) const;
// Lay out controls
virtual void DoSize();
// It is better to make this control transparent so that by default the controls on
// its pages are on the same colour background as the rest of the window. If the user
// prefers a coloured background they can set the background colour on the page panel
virtual bool HasTransparentBackground() override { return true; }
// This method also invalidates the size of the controller and should be
// called instead of just InvalidateBestSize() whenever pages are added or
// removed as this also affects the controller
void DoInvalidateBestSize();
#if wxUSE_HELP
// Show the help for the corresponding page
void OnHelp(wxHelpEvent& event);
#endif // wxUSE_HELP
// the array of all pages of this control: this is used in most, but not
// all derived classes, notable wxAuiNotebook doesn't store its page here
// and so must override all virtual methods of this class using m_pages
wxVector<wxWindow*> m_pages;
// get the page area
virtual wxRect GetPageRect() const;
// event handlers
void OnSize(wxSizeEvent& event);
// controller buddy if available, nullptr otherwise (usually for native book controls like wxNotebook)
wxWindow *m_bookctrl;
// Whether to shrink to fit current page
bool m_fitToCurrentPage;
// the sizer containing the choice control
wxSizer *m_controlSizer;
// the margin around the choice control
int m_controlMargin;
// The currently selected page (in range 0..m_pages.size()-1 inclusive) or
// wxNOT_FOUND if none (this can normally only be the case for an empty
// control without any pages).
int m_selection;
private:
// common part of all ctors
void Init();
// internal border
unsigned int m_internalBorder;
wxDECLARE_ABSTRACT_CLASS(wxBookCtrlBase);
wxDECLARE_NO_COPY_CLASS(wxBookCtrlBase);
wxDECLARE_EVENT_TABLE();
};
// ----------------------------------------------------------------------------
// wxBookCtrlEvent: page changing events generated by book classes
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBookCtrlEvent : public wxNotifyEvent
{
public:
wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
: wxNotifyEvent(commandType, winid)
{
m_nSel = nSel;
m_nOldSel = nOldSel;
}
wxBookCtrlEvent(const wxBookCtrlEvent& event)
: wxNotifyEvent(event)
{
m_nSel = event.m_nSel;
m_nOldSel = event.m_nOldSel;
}
wxNODISCARD virtual wxEvent *Clone() const override { return new wxBookCtrlEvent(*this); }
// accessors
// the currently selected page (wxNOT_FOUND if none)
int GetSelection() const { return m_nSel; }
void SetSelection(int nSel) { m_nSel = nSel; }
// the page that was selected before the change (wxNOT_FOUND if none)
int GetOldSelection() const { return m_nOldSel; }
void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
private:
int m_nSel, // currently selected page
m_nOldSel; // previously selected page
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxBookCtrlEvent);
};
typedef void (wxEvtHandler::*wxBookCtrlEventFunction)(wxBookCtrlEvent&);
#define wxBookCtrlEventHandler(func) \
wxEVENT_HANDLER_CAST(wxBookCtrlEventFunction, func)
// obsolete name, defined for compatibility only
#define wxBookCtrlBaseEvent wxBookCtrlEvent
// make a default book control for given platform
#if wxUSE_NOTEBOOK
// dedicated to majority of desktops
#include "wx/notebook.h"
#define wxBookCtrl wxNotebook
#define wxEVT_BOOKCTRL_PAGE_CHANGED wxEVT_NOTEBOOK_PAGE_CHANGED
#define wxEVT_BOOKCTRL_PAGE_CHANGING wxEVT_NOTEBOOK_PAGE_CHANGING
#define EVT_BOOKCTRL_PAGE_CHANGED(id, fn) EVT_NOTEBOOK_PAGE_CHANGED(id, fn)
#define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_NOTEBOOK_PAGE_CHANGING(id, fn)
#else
// dedicated to Smartphones
#include "wx/choicebk.h"
#define wxBookCtrl wxChoicebook
#define wxEVT_BOOKCTRL_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED
#define wxEVT_BOOKCTRL_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING
#define EVT_BOOKCTRL_PAGE_CHANGED(id, fn) EVT_CHOICEBOOK_PAGE_CHANGED(id, fn)
#define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_CHOICEBOOK_PAGE_CHANGING(id, fn)
#endif
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED wxEVT_BOOKCTRL_PAGE_CHANGED
#define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING wxEVT_BOOKCTRL_PAGE_CHANGING
#endif // wxUSE_BOOKCTRL
#endif // _WX_BOOKCTRL_H_

View File

@@ -0,0 +1,121 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/brush.h
// Purpose: Includes platform-specific wxBrush file
// Author: Julian Smart
// Created:
// Copyright: Julian Smart
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BRUSH_H_BASE_
#define _WX_BRUSH_H_BASE_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h" // for wxGDIObjListBase
// NOTE: these values cannot be combined together!
enum wxBrushStyle
{
wxBRUSHSTYLE_INVALID = -1,
wxBRUSHSTYLE_SOLID = wxSOLID,
wxBRUSHSTYLE_TRANSPARENT = wxTRANSPARENT,
wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE,
wxBRUSHSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
wxBRUSHSTYLE_STIPPLE = wxSTIPPLE,
wxBRUSHSTYLE_BDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL,
wxBRUSHSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG,
wxBRUSHSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL,
wxBRUSHSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS,
wxBRUSHSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL,
wxBRUSHSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL,
wxBRUSHSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST,
wxBRUSHSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST
};
// wxBrushBase
class WXDLLIMPEXP_CORE wxBrushBase: public wxGDIObject
{
public:
virtual ~wxBrushBase() = default;
virtual void SetColour(const wxColour& col) = 0;
virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) = 0;
virtual void SetStyle(wxBrushStyle style) = 0;
virtual void SetStipple(const wxBitmap& stipple) = 0;
virtual wxColour GetColour() const = 0;
virtual wxBrushStyle GetStyle() const = 0;
virtual wxBitmap *GetStipple() const = 0;
virtual bool IsHatch() const
{ return (GetStyle()>=wxBRUSHSTYLE_FIRST_HATCH) && (GetStyle()<=wxBRUSHSTYLE_LAST_HATCH); }
// Convenient helpers for testing whether the brush is a transparent one:
// unlike GetStyle() == wxBRUSHSTYLE_TRANSPARENT, they work correctly even
// if the brush is invalid (they both return false in this case).
bool IsTransparent() const
{
return IsOk() && GetStyle() == wxBRUSHSTYLE_TRANSPARENT;
}
bool IsNonTransparent() const
{
return IsOk() && GetStyle() != wxBRUSHSTYLE_TRANSPARENT;
}
};
#if defined(__WXMSW__)
#include "wx/msw/brush.h"
#elif defined(__WXX11__)
#include "wx/x11/brush.h"
#elif defined(__WXGTK__)
#include "wx/gtk/brush.h"
#elif defined(__WXDFB__)
#include "wx/dfb/brush.h"
#elif defined(__WXMAC__)
#include "wx/osx/brush.h"
#elif defined(__WXQT__)
#include "wx/qt/brush.h"
#endif
class WXDLLIMPEXP_CORE wxBrushList: public wxGDIObjListBase
{
public:
wxBrush *FindOrCreateBrush(const wxColour& colour,
wxBrushStyle style = wxBRUSHSTYLE_SOLID);
wxDEPRECATED_MSG("use wxBRUSHSTYLE_XXX constants")
wxBrush *FindOrCreateBrush(const wxColour& colour, int style)
{ return FindOrCreateBrush(colour, (wxBrushStyle)style); }
};
extern WXDLLIMPEXP_DATA_CORE(wxBrushList*) wxTheBrushList;
// provide comparison operators to allow code such as
//
// if ( brush.GetStyle() == wxTRANSPARENT )
//
// to compile without warnings which it would otherwise provoke from some
// compilers as it compares elements of different enums
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("use wxBRUSHSTYLE_XXX constants only")
inline bool operator==(wxBrushStyle s, wxDeprecatedGUIConstants t)
{
return static_cast<int>(s) == static_cast<int>(t);
}
wxDEPRECATED_MSG("use wxBRUSHSTYLE_XXX constants only")
inline bool operator!=(wxBrushStyle s, wxDeprecatedGUIConstants t)
{
return static_cast<int>(s) != static_cast<int>(t);
}
#endif // WXWIN_COMPATIBILITY_3_2
#endif // _WX_BRUSH_H_BASE_

View File

@@ -0,0 +1,700 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/buffer.h
// Purpose: auto buffer classes: buffers which automatically free memory
// Author: Vadim Zeitlin
// Created: 12.04.99
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUFFER_H
#define _WX_BUFFER_H
#include "wx/defs.h"
#include "wx/wxcrtbase.h"
#if wxUSE_STD_IOSTREAM
#include "wx/iosfwrap.h"
#endif
#include <stdlib.h> // malloc() and free()
class WXDLLIMPEXP_FWD_BASE wxCStrData;
// ----------------------------------------------------------------------------
// Special classes for (wide) character strings: they use malloc/free instead
// of new/delete
// ----------------------------------------------------------------------------
// helpers used by wxCharTypeBuffer
namespace wxPrivate
{
struct UntypedBufferData
{
enum Kind
{
Owned,
NonOwned
};
UntypedBufferData(void *str, size_t len, Kind kind = Owned)
: m_str(str), m_length(len), m_ref(1), m_owned(kind == Owned) {}
~UntypedBufferData()
{
if ( m_owned )
free(m_str);
}
void *m_str;
size_t m_length;
// "short" to have sizeof(Data)=12 on 32bit archs
unsigned short m_ref;
bool m_owned;
};
// NB: this is defined in string.cpp and not the (non-existent) buffer.cpp
WXDLLIMPEXP_BASE UntypedBufferData * GetUntypedNullData();
// Implementation of stream insertion operators: they can't be inline because
// we don't have full std::ostream declaration here.
#if wxUSE_STD_IOSTREAM
WXDLLIMPEXP_BASE std::ostream& OutputCharBuffer(std::ostream&, const char* s);
WXDLLIMPEXP_BASE std::ostream& OutputWCharBuffer(std::ostream&, const wchar_t* ws);
#if defined(HAVE_WOSTREAM)
WXDLLIMPEXP_BASE std::wostream& OutputWCharBuffer(std::wostream&, const wchar_t* ws);
#endif // defined(HAVE_WOSTREAM)
#endif // wxUSE_STD_IOSTREAM
} // namespace wxPrivate
// Template used as CRTP base class for wxScopedCharTypeBuffer in order to
// define overloaded operator<<() for it.
//
// By default we don't define any operators, but we do define them for the
// usual char and wchar_t specializations below.
template <typename T, typename Buffer>
struct wxScopedCharTypeBufferStreamSupport
{
};
// Suppress the warning about declaring a non-template friend because this is
// exactly what we want to do here.
wxGCC_ONLY_WARNING_SUPPRESS(non-template-friend)
template <typename Buffer>
struct wxScopedCharTypeBufferStreamSupport<char, Buffer>
{
#if wxUSE_STD_IOSTREAM
friend std::ostream& operator<<(std::ostream& oss, const Buffer& buf)
{
return wxPrivate::OutputCharBuffer(oss, buf.data());
}
#endif // wxUSE_STD_IOSTREAM
};
template <typename Buffer>
struct wxScopedCharTypeBufferStreamSupport<wchar_t, Buffer>
{
#if wxUSE_STD_IOSTREAM
friend std::ostream& operator<<(std::ostream& oss, const Buffer& buf)
{
return wxPrivate::OutputWCharBuffer(oss, buf.data());
}
#if defined(HAVE_WOSTREAM)
friend std::wostream& operator<<(std::wostream& woss, const Buffer& buf)
{
return wxPrivate::OutputWCharBuffer(woss, buf.data());
}
#endif // defined(HAVE_WOSTREAM)
#endif // wxUSE_STD_IOSTREAM
};
wxGCC_ONLY_WARNING_RESTORE(non-template-friend)
// Reference-counted character buffer for storing string data. The buffer
// is only valid for as long as the "parent" object that provided the data
// is valid; see wxCharTypeBuffer<T> for persistent variant.
template <typename T>
class wxScopedCharTypeBuffer
: wxScopedCharTypeBufferStreamSupport<T, wxScopedCharTypeBuffer<T>>
{
public:
typedef T CharType;
wxScopedCharTypeBuffer()
{
m_data = GetNullData();
}
// Creates "non-owned" buffer, i.e. 'str' is not owned by the buffer
// and doesn't get freed by dtor. Used e.g. to point to wxString's internal
// storage.
static
const wxScopedCharTypeBuffer CreateNonOwned(const CharType *str,
size_t len = wxNO_LEN)
{
if ( len == wxNO_LEN )
len = wxStrlen(str);
wxScopedCharTypeBuffer buf;
if ( str )
buf.m_data = new Data(const_cast<CharType*>(str), len, Data::NonOwned);
return buf;
}
// Creates "owned" buffer, i.e. takes over ownership of 'str' and frees it
// in dtor (if ref.count reaches 0).
static
const wxScopedCharTypeBuffer CreateOwned(CharType *str,
size_t len = wxNO_LEN )
{
if ( len == wxNO_LEN )
len = wxStrlen(str);
wxScopedCharTypeBuffer buf;
if ( str )
buf.m_data = new Data(str, len);
return buf;
}
wxScopedCharTypeBuffer(const wxScopedCharTypeBuffer& src)
{
m_data = src.m_data;
IncRef();
}
wxScopedCharTypeBuffer& operator=(const wxScopedCharTypeBuffer& src)
{
if ( &src == this )
return *this;
DecRef();
m_data = src.m_data;
IncRef();
return *this;
}
~wxScopedCharTypeBuffer()
{
DecRef();
}
// NB: this method is only const for backward compatibility. It used to
// be needed for auto_ptr-like semantics of the copy ctor, but now
// that ref-counting is used, it's not really needed.
CharType *release() const
{
if ( m_data == GetNullData() )
return nullptr;
wxASSERT_MSG( m_data->m_owned, wxT("can't release non-owned buffer") );
wxASSERT_MSG( m_data->m_ref == 1, wxT("can't release shared buffer") );
CharType * const p = m_data->Get();
wxScopedCharTypeBuffer *self = const_cast<wxScopedCharTypeBuffer*>(this);
self->m_data->Set(nullptr, 0);
self->DecRef();
return p;
}
void reset()
{
DecRef();
}
// For some reasong clang-tidy gives a warning about using freed memory
// here even when this is not at all the case, seemingly because it doesn't
// follow reference counting logic, i.e. it assumes that it's possible to
// delete the data even when it's still referenced.
//
// Suppress the warning as it's extremely annoying to get it for every use
// of wxCharBuffer.
//
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete)
CharType *data() { return m_data->Get(); }
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete)
const CharType *data() const { return m_data->Get(); }
operator const CharType *() const { return data(); }
CharType operator[](size_t n) const { return data()[n]; }
size_t length() const { return m_data->m_length; }
protected:
// reference-counted data
struct Data : public wxPrivate::UntypedBufferData
{
Data(CharType *str, size_t len, Kind kind = Owned)
: wxPrivate::UntypedBufferData(str, len, kind)
{
}
CharType *Get() const { return static_cast<CharType *>(m_str); }
void Set(CharType *str, size_t len)
{
m_str = str;
m_length = len;
}
};
// placeholder for null string, to simplify this code
static Data *GetNullData()
{
return static_cast<Data *>(wxPrivate::GetUntypedNullData());
}
void IncRef()
{
if ( m_data == GetNullData() ) // exception, not ref-counted
return;
m_data->m_ref++;
}
void DecRef()
{
if ( m_data == GetNullData() ) // exception, not ref-counted
return;
if ( --m_data->m_ref == 0 )
delete m_data;
m_data = GetNullData();
}
// sets this object to a be copy of 'other'; if 'src' is non-owned,
// a deep copy is made and 'this' will contain new instance of the data
void MakeOwnedCopyOf(const wxScopedCharTypeBuffer& src)
{
this->DecRef();
if ( src.m_data == this->GetNullData() )
{
this->m_data = this->GetNullData();
}
else if ( src.m_data->m_owned )
{
this->m_data = src.m_data;
this->IncRef();
}
else
{
// if the scoped buffer had non-owned data, we have to make
// a copy here, because src.m_data->m_str is valid only for as long
// as 'src' exists
this->m_data = new Data
(
StrCopy(src.data(), src.length()),
src.length()
);
}
}
static CharType *StrCopy(const CharType *src, size_t len)
{
CharType *dst = (CharType*)malloc(sizeof(CharType) * (len + 1));
if ( dst )
memcpy(dst, src, sizeof(CharType) * (len + 1));
return dst;
}
protected:
Data *m_data;
};
typedef wxScopedCharTypeBuffer<char> wxScopedCharBuffer;
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedWCharBuffer;
// this buffer class always stores data in "owned" (persistent) manner
template <typename T>
class wxCharTypeBuffer : public wxScopedCharTypeBuffer<T>
{
protected:
typedef typename wxScopedCharTypeBuffer<T>::Data Data;
public:
typedef T CharType;
wxCharTypeBuffer(const CharType *str = nullptr, size_t len = wxNO_LEN)
{
if ( str )
{
if ( len == wxNO_LEN )
len = wxStrlen(str);
this->m_data = new Data(this->StrCopy(str, len), len);
}
else
{
this->m_data = this->GetNullData();
}
}
wxCharTypeBuffer(size_t len)
{
CharType* const str = (CharType *)malloc((len + 1)*sizeof(CharType));
if ( str )
{
str[len] = (CharType)0;
// There is a potential memory leak here if new throws because it
// fails to allocate Data, we ought to use new(nothrow) here, but
// this might fail to compile under some platforms so until this
// can be fully tested, just live with this (rather unlikely, as
// Data is a small object) potential leak.
this->m_data = new Data(str, len);
}
else
{
this->m_data = this->GetNullData();
}
}
wxCharTypeBuffer(const wxCharTypeBuffer& src)
: wxScopedCharTypeBuffer<T>(src) {}
wxCharTypeBuffer& operator=(const CharType *str)
{
this->DecRef();
if ( str )
this->m_data = new Data(wxStrdup(str), wxStrlen(str));
return *this;
}
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src)
{
wxScopedCharTypeBuffer<T>::operator=(src);
return *this;
}
wxCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src)
{
this->MakeOwnedCopyOf(src);
}
wxCharTypeBuffer& operator=(const wxScopedCharTypeBuffer<T>& src)
{
MakeOwnedCopyOf(src);
return *this;
}
bool extend(size_t len)
{
wxASSERT_MSG( this->m_data->m_owned, "cannot extend non-owned buffer" );
wxASSERT_MSG( this->m_data->m_ref == 1, "can't extend shared buffer" );
CharType *str =
(CharType *)realloc(this->data(), (len + 1) * sizeof(CharType));
if ( !str )
return false;
// For consistency with the ctor taking just the length, NUL-terminate
// the buffer.
str[len] = (CharType)0;
if ( this->m_data == this->GetNullData() )
{
this->m_data = new Data(str, len);
}
else
{
this->m_data->Set(str, len);
this->m_data->m_owned = true;
}
return true;
}
void shrink(size_t len)
{
wxASSERT_MSG( this->m_data->m_owned, "cannot shrink non-owned buffer" );
wxASSERT_MSG( this->m_data->m_ref == 1, "can't shrink shared buffer" );
wxASSERT( len <= this->length() );
this->m_data->m_length = len;
this->data()[len] = 0;
}
};
class wxCharBuffer : public wxCharTypeBuffer<char>
{
public:
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
typedef wxScopedCharTypeBuffer<char> wxScopedCharTypeBufferBase;
wxCharBuffer(const wxCharTypeBufferBase& buf)
: wxCharTypeBufferBase(buf) {}
wxCharBuffer(const wxScopedCharTypeBufferBase& buf)
: wxCharTypeBufferBase(buf) {}
wxCharBuffer(const CharType *str = nullptr) : wxCharTypeBufferBase(str) {}
wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
wxCharBuffer(const wxCStrData& cstr);
#if wxUSE_STD_IOSTREAM
// Define this to disambiguate between converting to the base class or to
// wxString when using operator<<() with the objects of this class.
friend WXDLLIMPEXP_BASE
std::ostream& operator<<(std::ostream& oss, const wxCharBuffer& buf);
#endif // wxUSE_STD_IOSTREAM
};
class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
{
public:
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedCharTypeBufferBase;
wxWCharBuffer(const wxCharTypeBufferBase& buf)
: wxCharTypeBufferBase(buf) {}
wxWCharBuffer(const wxScopedCharTypeBufferBase& buf)
: wxCharTypeBufferBase(buf) {}
wxWCharBuffer(const CharType *str = nullptr) : wxCharTypeBufferBase(str) {}
wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
wxWCharBuffer(const wxCStrData& cstr);
#if wxUSE_STD_IOSTREAM
// See wxCharBuffer for why this is needed.
friend WXDLLIMPEXP_BASE
std::ostream& operator<<(std::ostream& oss, const wxWCharBuffer& buf);
#if defined(HAVE_WOSTREAM)
friend WXDLLIMPEXP_BASE
std::wostream& operator<<(std::wostream& woss, const wxWCharBuffer& buf);
#endif // defined(HAVE_WOSTREAM)
#endif // wxUSE_STD_IOSTREAM
};
// wxCharTypeBuffer<T> implicitly convertible to T*, for char and wchar_t,
// implemented slightly differently because in one case we must be
// constructible from a buffer and in another -- from a raw pointer.
class wxWritableCharBuffer : public wxScopedCharTypeBuffer<char>
{
public:
explicit wxWritableCharBuffer(const wxScopedCharTypeBuffer<char>& src)
: wxScopedCharTypeBuffer<char>(src) {}
operator char*() { return data(); }
};
class wxWritableWCharBuffer : public wxCharTypeBuffer<wchar_t>
{
public:
explicit wxWritableWCharBuffer(const CharType *str)
: wxCharTypeBuffer<wchar_t>(str) {}
operator wchar_t*() { return data(); }
};
// Compatibility defines, don't use them in the new code.
#define wxWxCharBuffer wxWCharBuffer
#define wxMB2WXbuf wxWCharBuffer
#define wxWX2MBbuf wxCharBuffer
#if wxUSE_UNICODE_WCHAR
#define wxWC2WXbuf wxChar*
#define wxWX2WCbuf wxChar*
#else /* wxUSE_UNICODE_UTF8 */
#define wxWC2WXbuf wxWCharBuffer
#define wxWX2WCbuf wxWCharBuffer
#endif
// ----------------------------------------------------------------------------
// A class for holding growable data buffers (not necessarily strings)
// ----------------------------------------------------------------------------
// This class manages the actual data buffer pointer and is ref-counted.
class wxMemoryBufferData
{
public:
// the initial size and also the size added by ResizeIfNeeded()
enum { DefBufSize = 1024 };
friend class wxMemoryBuffer;
// everything is private as it can only be used by wxMemoryBuffer
private:
wxMemoryBufferData(size_t size = wxMemoryBufferData::DefBufSize)
: m_data(size ? malloc(size) : nullptr), m_size(size), m_len(0), m_ref(0)
{
}
~wxMemoryBufferData() { free(m_data); }
void ResizeIfNeeded(size_t newSize)
{
if (newSize > m_size)
{
void* const data = realloc(m_data, newSize + wxMemoryBufferData::DefBufSize);
if ( !data )
{
// It's better to crash immediately dereferencing a null
// pointer in the function calling us than overflowing the
// buffer which couldn't be made big enough.
free(release());
return;
}
m_data = data;
m_size = newSize + wxMemoryBufferData::DefBufSize;
}
}
void IncRef() { m_ref += 1; }
void DecRef()
{
m_ref -= 1;
if (m_ref == 0) // are there no more references?
delete this;
}
void *release()
{
if ( m_data == nullptr )
return nullptr;
wxASSERT_MSG( m_ref == 1, "can't release shared buffer" );
void *p = m_data;
m_data = nullptr;
m_len =
m_size = 0;
return p;
}
// the buffer containing the data
void *m_data;
// the size of the buffer
size_t m_size;
// the amount of data currently in the buffer
size_t m_len;
// the reference count
size_t m_ref;
wxDECLARE_NO_COPY_CLASS(wxMemoryBufferData);
};
class wxMemoryBuffer
{
public:
// ctor and dtor
wxMemoryBuffer(size_t size = wxMemoryBufferData::DefBufSize)
{
m_bufdata = new wxMemoryBufferData(size);
m_bufdata->IncRef();
}
~wxMemoryBuffer() { m_bufdata->DecRef(); }
// copy and assignment
wxMemoryBuffer(const wxMemoryBuffer& src)
: m_bufdata(src.m_bufdata)
{
m_bufdata->IncRef();
}
wxMemoryBuffer& operator=(const wxMemoryBuffer& src)
{
if (&src != this)
{
m_bufdata->DecRef();
m_bufdata = src.m_bufdata;
m_bufdata->IncRef();
}
return *this;
}
// Accessors
void *GetData() const { return m_bufdata->m_data; }
size_t GetBufSize() const { return m_bufdata->m_size; }
size_t GetDataLen() const { return m_bufdata->m_len; }
bool IsEmpty() const { return GetDataLen() == 0; }
void SetBufSize(size_t size) { m_bufdata->ResizeIfNeeded(size); }
void SetDataLen(size_t len)
{
wxASSERT(len <= m_bufdata->m_size);
m_bufdata->m_len = len;
}
void Clear() { SetDataLen(0); }
// Ensure the buffer is big enough and return a pointer to it
void *GetWriteBuf(size_t sizeNeeded)
{
m_bufdata->ResizeIfNeeded(sizeNeeded);
return m_bufdata->m_data;
}
// Update the length after the write
void UngetWriteBuf(size_t sizeUsed) { SetDataLen(sizeUsed); }
// Like the above, but appends to the buffer
void *GetAppendBuf(size_t sizeNeeded)
{
m_bufdata->ResizeIfNeeded(m_bufdata->m_len + sizeNeeded);
return (char*)m_bufdata->m_data + m_bufdata->m_len;
}
// Update the length after the append
void UngetAppendBuf(size_t sizeUsed)
{
SetDataLen(m_bufdata->m_len + sizeUsed);
}
// Other ways to append to the buffer
void AppendByte(char data)
{
wxCHECK_RET( m_bufdata->m_data, wxT("invalid wxMemoryBuffer") );
m_bufdata->ResizeIfNeeded(m_bufdata->m_len + 1);
*(((char*)m_bufdata->m_data) + m_bufdata->m_len) = data;
m_bufdata->m_len += 1;
}
void AppendData(const void *data, size_t len)
{
memcpy(GetAppendBuf(len), data, len);
UngetAppendBuf(len);
}
operator const char *() const { return (const char*)GetData(); }
// gives up ownership of data, returns the pointer; after this call,
// data isn't freed by the buffer and its content is resent to empty
void *release()
{
return m_bufdata->release();
}
private:
wxMemoryBufferData* m_bufdata;
};
// ----------------------------------------------------------------------------
// template class for any kind of data
// ----------------------------------------------------------------------------
// TODO
#endif // _WX_BUFFER_H

View File

@@ -0,0 +1,133 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/build.h
// Purpose: Runtime build options checking
// Author: Vadim Zeitlin, Vaclav Slavik
// Created: 07.05.02
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUILD_H_
#define _WX_BUILD_H_
#include "wx/version.h"
// NB: This file contains macros for checking binary compatibility of libraries
// in multilib builds, plugins and user components.
// The WX_BUILD_OPTIONS_SIGNATURE macro expands into string that should
// uniquely identify binary compatible builds: i.e. if two builds of the
// library are binary compatible, their signature string should be the
// same; if two builds are binary incompatible, their signatures should
// be different.
//
// Therefore, wxUSE_XXX flags that affect binary compatibility (vtables,
// function signatures) should be accounted for here. So should compilers
// and compiler versions (but note that binary compatible compiler versions
// such as gcc-2.95.2 and gcc-2.95.3 should have same signature!).
// ----------------------------------------------------------------------------
// WX_BUILD_OPTIONS_SIGNATURE
// ----------------------------------------------------------------------------
#define __WX_BO_STRINGIZE(x) __WX_BO_STRINGIZE0(x)
#define __WX_BO_STRINGIZE0(x) #x
#if (wxMINOR_VERSION % 2) == 0
#define __WX_BO_VERSION(x,y,z) \
__WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y)
#else
#define __WX_BO_VERSION(x,y,z) \
__WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y) "." __WX_BO_STRINGIZE(z)
#endif
#if wxUSE_UNICODE_UTF8
#define __WX_BO_UNICODE "UTF-8"
#elif wxUSE_UNICODE_WCHAR
#define __WX_BO_UNICODE "wchar_t"
#else
#error "Either wxUSE_UNICODE_UTF8 or wxUSE_UNICODE_WCHAR must be 1"
#endif
// GCC and Intel C++ share same C++ ABI (and possibly others in the future),
// check if compiler versions are compatible:
#if defined(__GXX_ABI_VERSION)
// All the changes since ABI version 1002 so far have been insignificant,
// so just check for this value, first used for g++ 3.4 and used by default
// by all g++ 4 versions, as checking for the exact ABI version simply
// results in run-time breakage whenever a new gcc version is released,
// even if there are no real problems.
#if __GXX_ABI_VERSION >= 1002
#define __WX_BO_COMPILER \
",compiler with C++ ABI compatible with gcc 4"
#else
#define __WX_BO_COMPILER \
",compiler with C++ ABI " __WX_BO_STRINGIZE(__GXX_ABI_VERSION)
#endif
#elif defined(__GNUG__)
#define __WX_BO_COMPILER ",GCC " \
__WX_BO_STRINGIZE(__GNUC__) "." __WX_BO_STRINGIZE(__GNUC_MINOR__)
#elif defined(__VISUALC__)
// VC15 (a.k.a. MSVS 2017) is ABI-compatible with VC14 (MSVS 2015), so use
// the same ABI version for both of them.
#if _MSC_VER >= 1900 && _MSC_VER < 2000
#define wxMSVC_ABI_VERSION 1900
#else
#define wxMSVC_ABI_VERSION _MSC_VER
#endif
#define __WX_BO_COMPILER ",Visual C++ " __WX_BO_STRINGIZE(wxMSVC_ABI_VERSION)
#elif defined(__INTEL_COMPILER)
// Notice that this must come after MSVC check as ICC under Windows is
// ABI-compatible with the corresponding version of the MSVC and we want to
// allow using it compile the application code using MSVC-built DLLs.
#define __WX_BO_COMPILER ",Intel C++"
#else
#define __WX_BO_COMPILER
#endif
// WXWIN_COMPATIBILITY macros affect presence of virtual functions
#if WXWIN_COMPATIBILITY_3_0
#define __WX_BO_WXWIN_COMPAT_3_0 ",compatible with 3.0"
#else
#define __WX_BO_WXWIN_COMPAT_3_0
#endif
#if WXWIN_COMPATIBILITY_3_2
#define __WX_BO_WXWIN_COMPAT_3_2 ",compatible with 3.2"
#else
#define __WX_BO_WXWIN_COMPAT_3_2
#endif
// deriving wxWin containers from STL ones changes them completely:
#if wxUSE_STD_CONTAINERS
#define __WX_BO_STL ",STL containers"
#else
#define __WX_BO_STL ",wx containers"
#endif
// This macro is passed as argument to wxAppConsole::CheckBuildOptions()
#define WX_BUILD_OPTIONS_SIGNATURE \
__WX_BO_VERSION(wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) \
" (" __WX_BO_UNICODE \
__WX_BO_COMPILER \
__WX_BO_STL \
__WX_BO_WXWIN_COMPAT_3_0 __WX_BO_WXWIN_COMPAT_3_2 \
")"
// ----------------------------------------------------------------------------
// WX_CHECK_BUILD_OPTIONS
// ----------------------------------------------------------------------------
// Use this macro to check build options. Adding it to a file in DLL will
// ensure that the DLL checks build options in same way wxIMPLEMENT_APP() does.
#define WX_CHECK_BUILD_OPTIONS(libName) \
static struct wxBuildOptionsChecker \
{ \
wxBuildOptionsChecker() \
{ \
wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
libName); \
} \
} gs_buildOptionsCheck;
#endif // _WX_BUILD_H_

View File

@@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/busycursor.h
// Purpose: Functions and class for showing/hiding busy cursor.
// Author: Vadim Zeitlin
// Created: 2025-05-08 (extracted from wx/utils.h)
// Copyright: (c) 2025 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUSYCURSOR_H_
#define _WX_BUSYCURSOR_H_
#include "wx/gdicmn.h"
// Set the cursor to the busy cursor for all windows
WXDLLIMPEXP_CORE void wxBeginBusyCursor(const wxCursor *cursor = wxHOURGLASS_CURSOR);
WXDLLIMPEXP_CORE void wxBeginBusyCursor(const wxCursorBundle& cursors);
// Restore cursor to normal
WXDLLIMPEXP_CORE void wxEndBusyCursor();
// true if we're between the above two calls
WXDLLIMPEXP_CORE bool wxIsBusy();
// Convenience class so we can just create a wxBusyCursor object on the stack
class WXDLLIMPEXP_CORE wxBusyCursor
{
public:
explicit wxBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR)
{ wxBeginBusyCursor(cursor); }
explicit wxBusyCursor(const wxCursorBundle& cursors)
{ wxBeginBusyCursor(cursors); }
~wxBusyCursor()
{ wxEndBusyCursor(); }
#if WXWIN_COMPATIBILITY_3_2
// These functions are kept only for compatibility, they were never
// available in all ports and never did anything really useful.
wxDEPRECATED_MSG("Returns invalid cursor, don't use it")
static wxCursor GetStoredCursor();
wxDEPRECATED_MSG("Returns invalid cursor, don't use it")
static wxCursor GetBusyCursor();
#endif // WXWIN_COMPATIBILITY_3_2
};
// This class only exists for compatibility, it never did anything really
// useful and now doesn't do anything at all.
class wxDEPRECATED_MSG("Does nothing, stop using it") wxBusyCursorSuspender
{
public:
wxBusyCursorSuspender() = default;
~wxBusyCursorSuspender() = default;
};
#endif // _WX_BUSYCURSOR_H_

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/busyinfo.h
// Purpose: Information window (when app is busy)
// Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __BUSYINFO_H_BASE__
#define __BUSYINFO_H_BASE__
#include "wx/defs.h"
#if wxUSE_BUSYINFO
#include "wx/bmpbndl.h"
#include "wx/colour.h"
class WXDLLIMPEXP_FWD_CORE wxWindow;
// This class is used to pass all the various parameters to wxBusyInfo ctor.
// According to the usual naming conventions (see wxAboutDialogInfo,
// wxFontInfo, ...) it would be called wxBusyInfoInfo, but this would have been
// rather strange, so we call it wxBusyInfoFlags instead.
//
// Methods are mostly self-explanatory except for the difference between "Text"
// and "Label": the former can contain markup, while the latter is just plain
// string which is not parsed in any way.
class wxBusyInfoFlags
{
public:
wxBusyInfoFlags()
{
m_parent = nullptr;
m_alpha = wxALPHA_OPAQUE;
}
wxBusyInfoFlags& Parent(wxWindow* parent)
{ m_parent = parent; return *this; }
wxBusyInfoFlags& Icon(const wxBitmapBundle& icon)
{ m_icon = icon; return *this; }
wxBusyInfoFlags& Title(const wxString& title)
{ m_title = title; return *this; }
wxBusyInfoFlags& Text(const wxString& text)
{ m_text = text; return *this; }
wxBusyInfoFlags& Label(const wxString& label)
{ m_label = label; return *this; }
wxBusyInfoFlags& Foreground(const wxColour& foreground)
{ m_foreground = foreground; return *this; }
wxBusyInfoFlags& Background(const wxColour& background)
{ m_background = background; return *this; }
wxBusyInfoFlags& Transparency(wxByte alpha)
{ m_alpha = alpha; return *this; }
private:
wxWindow* m_parent;
wxBitmapBundle m_icon;
wxString m_title,
m_text,
m_label;
wxColour m_foreground,
m_background;
wxByte m_alpha;
friend class wxBusyInfo;
};
#include "wx/generic/busyinfo.h"
#endif // wxUSE_BUSYINFO
#endif // __BUSYINFO_H_BASE__

View File

@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/button.h
// Purpose: wxButtonBase class
// Author: Vadim Zeitlin
// Created: 15.08.00
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUTTON_H_BASE_
#define _WX_BUTTON_H_BASE_
#include "wx/defs.h"
#if wxUSE_BUTTON
#include "wx/anybutton.h"
extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[];
// ----------------------------------------------------------------------------
// wxButton: a push button
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxButtonBase : public wxAnyButton
{
public:
wxButtonBase() = default;
// show the authentication needed symbol on the button: this is currently
// only implemented in wxMSW where it shows the UAC shield symbol
void SetAuthNeeded(bool show = true) { DoSetAuthNeeded(show); }
bool GetAuthNeeded() const { return DoGetAuthNeeded(); }
// make this button the default button in its top level window
//
// returns the old default item (possibly null)
virtual wxWindow *SetDefault();
// returns the default button size for this platform, and optionally for a
// specific window when the platform supports per-monitor DPI
static wxSize GetDefaultSize(wxWindow* win = nullptr);
protected:
wxDECLARE_NO_COPY_CLASS(wxButtonBase);
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/button.h"
#elif defined(__WXMSW__)
#include "wx/msw/button.h"
#elif defined(__WXGTK__)
#include "wx/gtk/button.h"
#elif defined(__WXMAC__)
#include "wx/osx/button.h"
#elif defined(__WXQT__)
#include "wx/qt/button.h"
#endif
#endif // wxUSE_BUTTON
#endif // _WX_BUTTON_H_BASE_

View File

@@ -0,0 +1,401 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/calctrl.h
// Purpose: date-picker control
// Author: Vadim Zeitlin
// Created: 29.12.99
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CALCTRL_H_
#define _WX_CALCTRL_H_
#include "wx/defs.h"
#if wxUSE_CALENDARCTRL
#include "wx/dateevt.h"
#include "wx/colour.h"
#include "wx/font.h"
#include "wx/control.h"
// ----------------------------------------------------------------------------
// wxCalendarCtrl flags
// ----------------------------------------------------------------------------
enum
{
// show Sunday as the first day of the week (default)
wxCAL_SUNDAY_FIRST = 0x0080,
// show Monday as the first day of the week
wxCAL_MONDAY_FIRST = 0x0001,
// highlight holidays
wxCAL_SHOW_HOLIDAYS = 0x0002,
// disable the year change control, show only the month change one
// deprecated
wxCAL_NO_YEAR_CHANGE = 0x0004,
// don't allow changing either month or year (implies
// wxCAL_NO_YEAR_CHANGE)
wxCAL_NO_MONTH_CHANGE = 0x000c,
// use MS-style month-selection instead of combo-spin combination
wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010,
// show the neighbouring weeks in the previous and next month
wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020,
// show week numbers on the left side of the calendar.
wxCAL_SHOW_WEEK_NUMBERS = 0x0040
};
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// return values for the HitTest() method
enum wxCalendarHitTestResult
{
wxCAL_HITTEST_NOWHERE, // outside of anything
wxCAL_HITTEST_HEADER, // on the header (weekdays)
wxCAL_HITTEST_DAY, // on a day in the calendar
wxCAL_HITTEST_INCMONTH,
wxCAL_HITTEST_DECMONTH,
wxCAL_HITTEST_SURROUNDING_WEEK,
wxCAL_HITTEST_WEEK
};
// border types for a date
enum wxCalendarDateBorder
{
wxCAL_BORDER_NONE, // no border (default)
wxCAL_BORDER_SQUARE, // a rectangular border
wxCAL_BORDER_ROUND // a round border
};
// ----------------------------------------------------------------------------
// wxCalendarDateAttr: custom attributes for a calendar date
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCalendarDateAttr
{
public:
// ctors
wxCalendarDateAttr(const wxColour& colText = wxNullColour,
const wxColour& colBack = wxNullColour,
const wxColour& colBorder = wxNullColour,
const wxFont& font = wxNullFont,
wxCalendarDateBorder border = wxCAL_BORDER_NONE)
: m_colText(colText), m_colBack(colBack),
m_colBorder(colBorder), m_font(font)
{
Init(border);
}
wxCalendarDateAttr(wxCalendarDateBorder border,
const wxColour& colBorder = wxNullColour)
: m_colBorder(colBorder)
{
Init(border);
}
// setters
void SetTextColour(const wxColour& colText) { m_colText = colText; }
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
void SetBorderColour(const wxColour& col) { m_colBorder = col; }
void SetFont(const wxFont& font) { m_font = font; }
void SetBorder(wxCalendarDateBorder border) { m_border = border; }
void SetHoliday(bool holiday) { m_holiday = holiday; }
// accessors
bool HasTextColour() const { return m_colText.IsOk(); }
bool HasBackgroundColour() const { return m_colBack.IsOk(); }
bool HasBorderColour() const { return m_colBorder.IsOk(); }
bool HasFont() const { return m_font.IsOk(); }
bool HasBorder() const { return m_border != wxCAL_BORDER_NONE; }
bool IsHoliday() const { return m_holiday; }
const wxColour& GetTextColour() const { return m_colText; }
const wxColour& GetBackgroundColour() const { return m_colBack; }
const wxColour& GetBorderColour() const { return m_colBorder; }
const wxFont& GetFont() const { return m_font; }
wxCalendarDateBorder GetBorder() const { return m_border; }
// get or change the "mark" attribute, i.e. the one used for the items
// marked with wxCalendarCtrl::Mark()
static const wxCalendarDateAttr& GetMark() { return m_mark; }
static void SetMark(wxCalendarDateAttr const& m) { m_mark = m; }
protected:
void Init(wxCalendarDateBorder border = wxCAL_BORDER_NONE)
{
m_border = border;
m_holiday = false;
}
private:
static wxCalendarDateAttr m_mark;
wxColour m_colText,
m_colBack,
m_colBorder;
wxFont m_font;
wxCalendarDateBorder m_border;
bool m_holiday;
};
// ----------------------------------------------------------------------------
// wxCalendarCtrl events
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxCalendarCtrl;
class WXDLLIMPEXP_CORE wxCalendarEvent : public wxDateEvent
{
public:
wxCalendarEvent() : m_wday(wxDateTime::Inv_WeekDay) { }
wxCalendarEvent(wxWindow *win, const wxDateTime& dt, wxEventType type)
: wxDateEvent(win, dt, type),
m_wday(wxDateTime::Inv_WeekDay) { }
wxCalendarEvent(const wxCalendarEvent& event)
: wxDateEvent(event), m_wday(event.m_wday) { }
void SetWeekDay(wxDateTime::WeekDay wd) { m_wday = wd; }
wxDateTime::WeekDay GetWeekDay() const { return m_wday; }
wxNODISCARD virtual wxEvent *Clone() const override { return new wxCalendarEvent(*this); }
private:
wxDateTime::WeekDay m_wday;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCalendarEvent);
};
// ----------------------------------------------------------------------------
// wxCalendarCtrlBase
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCalendarCtrlBase : public wxControl
{
public:
// do we allow changing the month/year?
bool AllowMonthChange() const { return !HasFlag(wxCAL_NO_MONTH_CHANGE); }
// get/set the current date
virtual wxDateTime GetDate() const = 0;
virtual bool SetDate(const wxDateTime& date) = 0;
// restricting the dates shown by the control to the specified range: only
// implemented in the generic and MSW versions for now
// if either date is set, the corresponding limit will be enforced and true
// returned; if none are set, the existing restrictions are removed and
// false is returned
virtual bool
SetDateRange(const wxDateTime& WXUNUSED(lowerdate) = wxDefaultDateTime,
const wxDateTime& WXUNUSED(upperdate) = wxDefaultDateTime)
{
return false;
}
// retrieves the limits currently in use (wxDefaultDateTime if none) in the
// provided pointers (which may be null) and returns true if there are any
// limits or false if none
virtual bool
GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const
{
if ( lowerdate )
*lowerdate = wxDefaultDateTime;
if ( upperdate )
*upperdate = wxDefaultDateTime;
return false;
}
// returns one of wxCAL_HITTEST_XXX constants and fills either date or wd
// with the corresponding value (none for NOWHERE, the date for DAY and wd
// for HEADER)
//
// notice that this is not implemented in all versions
virtual wxCalendarHitTestResult
HitTest(const wxPoint& WXUNUSED(pos),
wxDateTime* WXUNUSED(date) = nullptr,
wxDateTime::WeekDay* WXUNUSED(wd) = nullptr)
{
return wxCAL_HITTEST_NOWHERE;
}
// allow or disable changing the current month (and year), return true if
// the value of this option really changed or false if it was already set
// to the required value
//
// NB: we provide implementation for this pure virtual function, derived
// classes should call it
virtual bool EnableMonthChange(bool enable = true) = 0;
// an item without custom attributes is drawn with the default colours and
// font and without border, setting custom attributes allows to modify this
//
// the day parameter should be in 1..31 range, for days 29, 30, 31 the
// corresponding attribute is just unused if there is no such day in the
// current month
//
// notice that currently arbitrary attributes are supported only in the
// generic version, the native controls only support Mark() which assigns
// some special appearance (which can be customized using SetMark() for the
// generic version) to the given day
virtual void Mark(size_t day, bool mark) = 0;
virtual wxCalendarDateAttr *GetAttr(size_t WXUNUSED(day)) const
{ return nullptr; }
virtual void SetAttr(size_t WXUNUSED(day), wxCalendarDateAttr *attr)
{ delete attr; }
virtual void ResetAttr(size_t WXUNUSED(day)) { }
// holidays support
//
// currently only the generic version implements all functions in this
// section; wxMSW implements simple support for holidays (they can be
// just enabled or disabled) and wxGTK doesn't support them at all
// equivalent to changing wxCAL_SHOW_HOLIDAYS flag but should be called
// instead of just changing it
virtual void EnableHolidayDisplay(bool display = true);
// set/get the colours to use for holidays (if they're enabled)
virtual void SetHolidayColours(const wxColour& WXUNUSED(colFg),
const wxColour& WXUNUSED(colBg)) { }
virtual const wxColour& GetHolidayColourFg() const { return wxNullColour; }
virtual const wxColour& GetHolidayColourBg() const { return wxNullColour; }
// mark the given day of the current month as being a holiday
virtual void SetHoliday(size_t WXUNUSED(day)) { }
// customizing the colours of the controls
//
// most of the methods in this section are only implemented by the native
// version of the control and do nothing in the native ones
// set/get the colours to use for the display of the week day names at the
// top of the controls
virtual void SetHeaderColours(const wxColour& WXUNUSED(colFg),
const wxColour& WXUNUSED(colBg)) { }
virtual const wxColour& GetHeaderColourFg() const { return wxNullColour; }
virtual const wxColour& GetHeaderColourBg() const { return wxNullColour; }
// set/get the colours used for the currently selected date
virtual void SetHighlightColours(const wxColour& WXUNUSED(colFg),
const wxColour& WXUNUSED(colBg)) { }
virtual const wxColour& GetHighlightColourFg() const { return wxNullColour; }
virtual const wxColour& GetHighlightColourBg() const { return wxNullColour; }
// implementation only from now on
// generate the given calendar event, return true if it was processed
//
// NB: this is public because it's used from GTK+ callbacks
bool GenerateEvent(wxEventType type)
{
wxCalendarEvent event(this, GetDate(), type);
return HandleWindowEvent(event);
}
protected:
// generate all the events for the selection change from dateOld to current
// date: SEL_CHANGED, PAGE_CHANGED if necessary and also one of (deprecated)
// YEAR/MONTH/DAY_CHANGED ones
//
// returns true if page changed event was generated, false if the new date
// is still in the same month as before
bool GenerateAllChangeEvents(const wxDateTime& dateOld);
// call SetHoliday() for all holidays in the current month
//
// should be called on month change, does nothing if wxCAL_SHOW_HOLIDAYS is
// not set and returns false in this case, true if we do show them
bool SetHolidayAttrs();
// called by SetHolidayAttrs() to forget the previously set holidays
virtual void ResetHolidayAttrs() { }
// called by EnableHolidayDisplay()
virtual void RefreshHolidays() { }
// does the week start on monday based on flags and OS settings?
bool WeekStartsOnMonday() const;
};
// ----------------------------------------------------------------------------
// wxCalendarCtrl
// ----------------------------------------------------------------------------
#define wxCalendarNameStr "CalendarCtrl"
#ifndef __WXUNIVERSAL__
#if defined(__WXGTK__)
#define wxHAS_NATIVE_CALENDARCTRL
#include "wx/gtk/calctrl.h"
#define wxCalendarCtrl wxGtkCalendarCtrl
#elif defined(__WXMSW__)
#define wxHAS_NATIVE_CALENDARCTRL
#include "wx/msw/calctrl.h"
#elif defined(__WXQT__)
#define wxHAS_NATIVE_CALENDARCTRL
#include "wx/qt/calctrl.h"
#endif
#endif // !__WXUNIVERSAL__
#ifndef wxHAS_NATIVE_CALENDARCTRL
#include "wx/generic/calctrlg.h"
#define wxCalendarCtrl wxGenericCalendarCtrl
#endif
// ----------------------------------------------------------------------------
// calendar event types and macros for handling them
// ----------------------------------------------------------------------------
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_SEL_CHANGED, wxCalendarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_PAGE_CHANGED, wxCalendarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_DOUBLECLICKED, wxCalendarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_WEEKDAY_CLICKED, wxCalendarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_WEEK_CLICKED, wxCalendarEvent );
// deprecated events
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_DAY_CHANGED, wxCalendarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_MONTH_CHANGED, wxCalendarEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CALENDAR_YEAR_CHANGED, wxCalendarEvent );
typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&);
#define wxCalendarEventHandler(func) \
wxEVENT_HANDLER_CAST(wxCalendarEventFunction, func)
#define wx__DECLARE_CALEVT(evt, id, fn) \
wx__DECLARE_EVT1(wxEVT_CALENDAR_ ## evt, id, wxCalendarEventHandler(fn))
#define EVT_CALENDAR(id, fn) wx__DECLARE_CALEVT(DOUBLECLICKED, id, fn)
#define EVT_CALENDAR_SEL_CHANGED(id, fn) wx__DECLARE_CALEVT(SEL_CHANGED, id, fn)
#define EVT_CALENDAR_PAGE_CHANGED(id, fn) wx__DECLARE_CALEVT(PAGE_CHANGED, id, fn)
#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) wx__DECLARE_CALEVT(WEEKDAY_CLICKED, id, fn)
#define EVT_CALENDAR_WEEK_CLICKED(id, fn) wx__DECLARE_CALEVT(WEEK_CLICKED, id, fn)
// deprecated events
#define EVT_CALENDAR_DAY(id, fn) wx__DECLARE_CALEVT(DAY_CHANGED, id, fn)
#define EVT_CALENDAR_MONTH(id, fn) wx__DECLARE_CALEVT(MONTH_CHANGED, id, fn)
#define EVT_CALENDAR_YEAR(id, fn) wx__DECLARE_CALEVT(YEAR_CHANGED, id, fn)
#endif // wxUSE_CALENDARCTRL
#endif // _WX_CALCTRL_H_

View File

@@ -0,0 +1,244 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/caret.h
// Purpose: wxCaretBase class - the interface of wxCaret
// Author: Vadim Zeitlin
// Created: 23.05.99
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CARET_H_BASE_
#define _WX_CARET_H_BASE_
#include "wx/defs.h"
#if wxUSE_CARET
// ----------------------------------------------------------------------------
// headers we have to include
// ----------------------------------------------------------------------------
#include "wx/gdicmn.h" // for wxPoint, wxSize
#include "wx/window.h"
// ----------------------------------------------------------------------------
// A caret is a blinking cursor showing the position where the typed text will
// appear. It can be either a solid block or a custom bitmap (TODO)
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCaretBase
{
public:
// ctors
// -----
// default - use Create
wxCaretBase() { Init(); }
// create the caret of given (in pixels) width and height and associate
// with the given window
wxCaretBase(wxWindowBase *window, int width, int height)
{
Init();
(void)Create(window, width, height);
}
// same as above
wxCaretBase(wxWindowBase *window, const wxSize& size)
{
Init();
(void)Create(window, size);
}
// a virtual dtor has been provided since this class has virtual members
virtual ~wxCaretBase() = default;
// Create() functions - same as ctor but returns the success code
// --------------------------------------------------------------
// same as ctor
bool Create(wxWindowBase *window, int width, int height)
{ return DoCreate(window, width, height); }
// same as ctor
bool Create(wxWindowBase *window, const wxSize& size)
{ return DoCreate(window, size.x, size.y); }
// accessors
// ---------
// is the caret valid?
bool IsOk() const { return m_width != 0 && m_height != 0; }
// is the caret currently shown?
bool IsVisible() const { return m_countVisible > 0; }
// get the caret position
void GetPosition(int *x, int *y) const
{
if ( x ) *x = m_x;
if ( y ) *y = m_y;
}
wxPoint GetPosition() const { return wxPoint(m_x, m_y); }
// get the caret size
void GetSize(int *width, int *height) const
{
if ( width ) *width = m_width;
if ( height ) *height = m_height;
}
wxSize GetSize() const { return wxSize(m_width, m_height); }
// get the window we're associated with
wxWindow *GetWindow() const { return static_cast<wxWindow *>(m_window); }
// change the size of the caret
void SetSize(int width, int height) {
m_width = width;
m_height = height;
DoSize();
}
void SetSize(const wxSize& size) { SetSize(size.x, size.y); }
// operations
// ----------
// move the caret to given position (in logical coords)
void Move(int x, int y) { m_x = x; m_y = y; DoMove(); }
void Move(const wxPoint& pt) { m_x = pt.x; m_y = pt.y; DoMove(); }
// show/hide the caret (should be called by wxWindow when needed):
// Show() must be called as many times as Hide() + 1 to make the caret
// visible
virtual void Show(bool show = true)
{
if ( show )
{
if ( m_countVisible++ == 0 )
DoShow();
}
else
{
if ( --m_countVisible == 0 )
DoHide();
}
}
virtual void Hide() { Show(false); }
// blink time is measured in milliseconds and is the time elapsed
// between 2 inversions of the caret (blink time of the caret is common
// to all carets in the Universe, so these functions are static)
static int GetBlinkTime();
static void SetBlinkTime(int milliseconds);
// implementation from now on
// --------------------------
// these functions should be called by wxWindow when the window gets/loses
// the focus - we create/show and hide/destroy the caret here
virtual void OnSetFocus() { }
virtual void OnKillFocus() { }
protected:
// these functions may be overridden in the derived classes, but they
// should call the base class version first
virtual bool DoCreate(wxWindowBase *window, int width, int height)
{
m_window = window;
m_width = width;
m_height = height;
DoSize();
return true;
}
// pure virtuals to implement in the derived class
virtual void DoShow() = 0;
virtual void DoHide() = 0;
virtual void DoMove() = 0;
virtual void DoSize() { }
// the size of the caret
int m_width, m_height;
// the position of the caret
int m_x, m_y;
// the window we're associated with
wxWindowBase *m_window;
// visibility count: the caret is visible only if it's positive
int m_countVisible;
private:
void Init()
{
m_window = nullptr;
m_x = m_y = 0;
m_width = m_height = 0;
m_countVisible = 0;
}
wxDECLARE_NO_COPY_CLASS(wxCaretBase);
};
// ---------------------------------------------------------------------------
// now include the real thing
// ---------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/caret.h"
#else
#include "wx/generic/caret.h"
#endif // platform
// ----------------------------------------------------------------------------
// wxCaretSuspend: a simple class which hides the caret in its ctor and
// restores it in the dtor, this should be used when drawing on the screen to
// avoid overdrawing the caret
// ----------------------------------------------------------------------------
#ifdef wxHAS_CARET_USING_OVERLAYS
// we don't need to hide the caret if it's rendered using overlays
class WXDLLIMPEXP_CORE wxCaretSuspend
{
public:
wxCaretSuspend(wxWindow *WXUNUSED(win)) {}
wxDECLARE_NO_COPY_CLASS(wxCaretSuspend);
};
#else // !wxHAS_CARET_USING_OVERLAYS
class WXDLLIMPEXP_CORE wxCaretSuspend
{
public:
wxCaretSuspend(wxWindow *win)
{
m_caret = win->GetCaret();
m_show = false;
if ( m_caret && m_caret->IsVisible() )
{
m_caret->Hide();
m_show = true;
}
}
~wxCaretSuspend()
{
if ( m_caret && m_show )
m_caret->Show();
}
private:
wxCaret *m_caret;
bool m_show;
wxDECLARE_NO_COPY_CLASS(wxCaretSuspend);
};
#endif // wxHAS_CARET_USING_OVERLAYS/!wxHAS_CARET_USING_OVERLAYS
#endif // wxUSE_CARET
#endif // _WX_CARET_H_BASE_

View File

@@ -0,0 +1,291 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/catch_cppunit.h
// Purpose: Reimplementation of CppUnit macros in terms of CATCH
// Author: Vadim Zeitlin
// Created: 2017-10-30
// Copyright: (c) 2017 Vadim Zeitlin <vadim@wxwidgets.org>
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CATCH_CPPUNIT_H_
#define _WX_CATCH_CPPUNIT_H_
#include "catch2/catch.hpp"
// CppUnit-compatible macros.
// CPPUNIT_ASSERTs are mapped to REQUIRE(), not CHECK(), as this is how CppUnit
// works but in many cases they really should be CHECK()s instead, i.e. the
// test should continue to run even if one assert failed. Unfortunately there
// is no automatic way to know it, so the existing code will need to be
// reviewed and CHECK() used explicitly where appropriate.
//
// Also notice that we don't use parentheses around x and y macro arguments in
// the macro expansion, as usual. This is because these parentheses would then
// appear in CATCH error messages if the assertion fails, making them much less
// readable and omitting should be fine here, exceptionally, as the arguments
// of these macros are usually just simple expressions.
#define CPPUNIT_ASSERT(cond) REQUIRE(cond)
#define CPPUNIT_ASSERT_EQUAL(x, y) REQUIRE(x == y)
// Using INFO() disallows putting more than one of these macros on the same
// line but this can happen if they're used inside another macro, so wrap it
// inside a scope.
#define CPPUNIT_ASSERT_MESSAGE(msg, cond) \
wxSTATEMENT_MACRO_BEGIN \
INFO(msg); \
REQUIRE(cond); \
wxSTATEMENT_MACRO_END
#define CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, x, y) \
wxSTATEMENT_MACRO_BEGIN \
INFO(msg); \
REQUIRE(x == y); \
wxSTATEMENT_MACRO_END
// CATCH Approx class uses the upper bound of "epsilon*(scale + max(|x|, |y|))"
// for |x - y| which is not really compatible with our fixed delta, so we can't
// use it here.
#define CPPUNIT_ASSERT_DOUBLES_EQUAL(x, y, delta) \
REQUIRE(std::abs(x - y) < delta)
#define CPPUNIT_FAIL(msg) FAIL(msg)
#define CPPUNIT_ASSERT_THROW(expr, exception) \
try \
{ \
expr; \
FAIL("Expected exception of type " #exception \
" not thrown by " #expr); \
} \
catch ( exception& ) {}
// Define conversions to strings for some common wxWidgets types.
namespace Catch
{
template <>
struct StringMaker<wxUniChar>
{
static std::string convert(wxUniChar uc)
{
return wxString(uc).ToStdString(wxConvUTF8);
}
};
template <>
struct StringMaker<wxUniCharRef>
{
static std::string convert(wxUniCharRef ucr)
{
return wxString(ucr).ToStdString(wxConvUTF8);
}
};
// While this conversion already works due to the existence of the stream
// insertion operator for wxString, define a custom one making it more
// obvious when strings containing non-printable characters differ.
template <>
struct StringMaker<wxString>
{
static std::string convert(const wxString& wxs)
{
std::string s;
s.reserve(wxs.length() + 2);
s += '"';
for ( auto c : wxs )
{
if ( c >= 128 || !iswprint(c) )
s += wxString::Format(wxASCII_STR("\\u%04X"), c).ToAscii();
else
s += c;
}
s += '"';
return s;
}
};
}
// Use a different namespace for our mock ups of the real declarations in
// CppUnit namespace to avoid clashes if we end up being linked with the real
// CppUnit library, but bring it into scope with a using directive below to
// make it possible to compile the original code using CppUnit unmodified.
namespace CatchCppUnit
{
namespace CppUnit
{
// These classes don't really correspond to the real CppUnit ones, but contain
// just the minimum we need to make CPPUNIT_TEST() macro and our mock up of
// TestSuite class work.
class Test
{
public:
// Name argument exists only for compatibility with the real CppUnit but is
// not used here.
explicit Test(const std::string& name = std::string()) : m_name(name) { }
virtual ~Test() = default;
virtual void runTest() = 0;
const std::string& getName() const { return m_name; }
private:
std::string m_name;
};
class TestCase : public Test
{
public:
explicit TestCase(const std::string& name = std::string()) : Test(name) { }
virtual void setUp() {}
virtual void tearDown() {}
};
class TestSuite : public Test
{
public:
explicit TestSuite(const std::string& name = std::string()) : Test(name) { }
~TestSuite()
{
for ( size_t n = 0; n < m_tests.size(); ++n )
{
delete m_tests[n];
}
}
void addTest(Test* test) { m_tests.push_back(test); }
size_t getChildTestCount() const { return m_tests.size(); }
void runTest() override
{
for ( size_t n = 0; n < m_tests.size(); ++n )
{
m_tests[n]->runTest();
}
}
private:
std::vector<Test*> m_tests;
wxDECLARE_NO_COPY_CLASS(TestSuite);
};
} // namespace CppUnit
} // namespace CatchCppUnit
using namespace CatchCppUnit;
// Helpers used in the implementation of the macros below.
namespace wxPrivate
{
// An object which resets a string to its old value when going out of scope.
class TempStringAssign
{
public:
explicit TempStringAssign(std::string& str, const char* value)
: m_str(str),
m_orig(str)
{
str = value;
}
~TempStringAssign()
{
m_str = m_orig;
}
private:
std::string& m_str;
const std::string m_orig;
wxDECLARE_NO_COPY_CLASS(TempStringAssign);
};
// These two strings are used to implement wxGetCurrentTestName() and must be
// defined in the test driver.
extern std::string wxTheCurrentTestClass, wxTheCurrentTestMethod;
} // namespace wxPrivate
inline std::string wxGetCurrentTestName()
{
std::string s = wxPrivate::wxTheCurrentTestClass;
if ( !s.empty() && !wxPrivate::wxTheCurrentTestMethod.empty() )
s += "::";
s += wxPrivate::wxTheCurrentTestMethod;
return s;
}
// Notice that the use of this macro unconditionally changes the protection for
// everything that follows it to "public". This is necessary to allow taking
// the address of the runTest() method in CPPUNIT_TEST_SUITE_REGISTRATION()
// below and there just doesn't seem to be any way around it.
#define CPPUNIT_TEST_SUITE(testclass) \
public: \
void runTest() override \
{ \
using namespace wxPrivate; \
TempStringAssign setClass(wxTheCurrentTestClass, #testclass)
#define CPPUNIT_TEST(testname) \
SECTION(#testname) \
{ \
TempStringAssign setMethod(wxTheCurrentTestMethod, #testname); \
setUp(); \
try \
{ \
testname(); \
} \
catch ( ... ) \
{ \
tearDown(); \
throw; \
} \
tearDown(); \
}
#define CPPUNIT_TEST_SUITE_END() \
} \
struct EatNextSemicolon
#define wxREGISTER_UNIT_TEST_WITH_TAGS(testclass, tags) \
METHOD_AS_TEST_CASE(testclass::runTest, #testclass, tags) \
struct EatNextSemicolon
#define CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testclass, suitename) \
wxREGISTER_UNIT_TEST_WITH_TAGS(testclass, "[" suitename "]")
// Existings tests always use both this macro and the named registration one
// above, but we can't register the same test case twice with CATCH, so simply
// ignore this one.
#define CPPUNIT_TEST_SUITE_REGISTRATION(testclass) \
struct EatNextSemicolon
// ----------------------------------------------------------------------------
// wxWidgets-specific macros
// ----------------------------------------------------------------------------
// Convenient variant of INFO() which uses wxString::Format() internally.
#define wxINFO_FMT_HELPER(fmt, ...) \
wxString::Format(fmt, __VA_ARGS__).ToStdString(wxConvUTF8)
#define wxINFO_FMT(...) INFO(wxINFO_FMT_HELPER(__VA_ARGS__))
// Use this macro to assert with the given formatted message (it should contain
// the format string and arguments in a separate pair of parentheses)
#define WX_ASSERT_MESSAGE(msg, cond) \
CPPUNIT_ASSERT_MESSAGE(std::string(wxString::Format msg .mb_str(wxConvLibc)), (cond))
#define WX_ASSERT_EQUAL_MESSAGE(msg, expected, actual) \
CPPUNIT_ASSERT_EQUAL_MESSAGE(std::string(wxString::Format msg .mb_str(wxConvLibc)), \
(expected), (actual))
#endif // _WX_CATCH_CPPUNIT_H_

View File

@@ -0,0 +1,264 @@
/*
* Name: wx/chartype.h
* Purpose: Declarations of wxChar and related types
* Author: Joel Farley, Ove Kåven
* Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
* Created: 1998/06/12
* Copyright: (c) 1998-2006 wxWidgets dev team
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_WXCHARTYPE_H_
#define _WX_WXCHARTYPE_H_
/*
wx/defs.h indirectly includes this file, so we can't include it here,
include just its subset which defines SIZEOF_WCHAR_T that is used here
(under Unix it's in configure-generated setup.h, so including wx/platform.h
would have been enough, but this is not the case under other platforms).
*/
#include "wx/types.h"
/* This is kept only for backwards compatibility, in case some application code
checks for it. It's always 1 and can't be changed. */
#define wxUSE_WCHAR_T 1
/*
non Unix compilers which do have wchar.h (but not tchar.h which is included
below and which includes wchar.h anyhow).
Actually MinGW has tchar.h, but it does not include wchar.h
*/
#if defined(__MINGW32__)
#ifndef HAVE_WCHAR_H
#define HAVE_WCHAR_H
#endif
#endif
#ifdef HAVE_WCHAR_H
/* the current (as of Nov 2002) version of cygwin has a bug in its */
/* wchar.h -- there is no extern "C" around the declarations in it */
/* and this results in linking errors later; also, at least on some */
/* Cygwin versions, wchar.h requires sys/types.h */
#ifdef __CYGWIN__
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#endif /* Cygwin */
#include <wchar.h>
#if defined(__CYGWIN__) && defined(__cplusplus)
}
#endif /* Cygwin and C++ */
/* the current (as of Mar 2014) version of Android (up to api level 19) */
/* doesn't include some declarations (wscdup, wcslen, wcscasecmp, etc.) */
/* (moved out from __CYGWIN__ block) */
#if defined(__WXQT__) && !defined(wcsdup) && defined(__ANDROID__)
#ifdef __cplusplus
extern "C" {
#endif
extern wchar_t *wcsdup(const wchar_t *);
extern size_t wcslen (const wchar_t *);
extern size_t wcsnlen (const wchar_t *, size_t );
extern int wcscasecmp (const wchar_t *, const wchar_t *);
extern int wcsncasecmp (const wchar_t *, const wchar_t *, size_t);
#ifdef __cplusplus
}
#endif
#endif /* Android */
#elif defined(HAVE_WCSTR_H)
/* old compilers have relevant declarations here */
#include <wcstr.h>
#elif defined(__FreeBSD__) || defined(__DARWIN__)
/* include stdlib.h for wchar_t */
#include <stdlib.h>
#endif /* HAVE_WCHAR_H */
#ifdef HAVE_WIDEC_H
#include <widec.h>
#endif
/* -------------------------------------------------------------------------- */
/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and */
/* have the function mapping _tfoo() -> foo() or wfoo() */
/* -------------------------------------------------------------------------- */
/* VC++ and BC++ starting with 5.2 have TCHAR support */
#ifdef __VISUALC__
#define wxHAVE_TCHAR_SUPPORT
#elif defined(__MINGW32__)
#define wxHAVE_TCHAR_SUPPORT
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#endif /* compilers with (good) TCHAR support */
#ifdef wxHAVE_TCHAR_SUPPORT
/* get TCHAR definition if we've got it */
#include <tchar.h>
#endif /* wxHAVE_TCHAR_SUPPORT */
/* ------------------------------------------------------------------------- */
/* define wxChar type for compatibility only */
/* ------------------------------------------------------------------------- */
typedef wchar_t wxChar;
typedef wchar_t wxSChar;
typedef wchar_t wxUChar;
/* ------------------------------------------------------------------------- */
/* define wxStringCharType */
/* ------------------------------------------------------------------------- */
/* depending on the build options, strings can store their data either as
wchar_t* or UTF-8 encoded char*: */
#if defined(wxUSE_UTF8_LOCALE_ONLY) && !defined(wxUSE_UNICODE_UTF8)
#error "wxUSE_UTF8_LOCALE_ONLY only makes sense with wxUSE_UNICODE_UTF8"
#endif
#ifndef wxUSE_UTF8_LOCALE_ONLY
#define wxUSE_UTF8_LOCALE_ONLY 0
#endif
#ifndef wxUSE_UNICODE_UTF8
#define wxUSE_UNICODE_UTF8 0
#endif
#if wxUSE_UNICODE_UTF8
#define wxUSE_UNICODE_WCHAR 0
#else
#define wxUSE_UNICODE_WCHAR 1
#endif
#ifndef SIZEOF_WCHAR_T
#error "SIZEOF_WCHAR_T must be defined before including this file in wx/defs.h"
#endif
#if wxUSE_UNICODE_WCHAR && SIZEOF_WCHAR_T == 2
#define wxUSE_UNICODE_UTF16 1
#else
#define wxUSE_UNICODE_UTF16 0
#endif
/* define char type used by wxString internal representation: */
#if wxUSE_UNICODE_WCHAR
typedef wchar_t wxStringCharType;
#else /* wxUSE_UNICODE_UTF8 */
typedef char wxStringCharType;
#endif
/* Define wxChar16 and wxChar32 */
#ifdef __cplusplus
#if SIZEOF_WCHAR_T == 2
#define wxWCHAR_T_IS_WXCHAR16
typedef wchar_t wxChar16;
#else
typedef char16_t wxChar16;
#endif
#if SIZEOF_WCHAR_T == 4
#define wxWCHAR_T_IS_WXCHAR32
typedef wchar_t wxChar32;
#else
typedef char32_t wxChar32;
#endif
#endif /* __cplusplus */
/* ------------------------------------------------------------------------- */
/* define wxT() and related macros */
/* ------------------------------------------------------------------------- */
/* BSD systems define _T() to be something different in ctype.h, override it */
#if defined(__FreeBSD__) || defined(__DARWIN__)
#include <ctype.h>
#undef _T
#endif
/*
wxT ("wx text") macro turns a literal string constant into a wide char
constant. It is mostly unnecessary with wx 2.9 but defined for
compatibility.
*/
#ifndef wxT
/*
Notice that we use an intermediate macro to allow x to be expanded
if it's a macro itself.
*/
#define wxT(x) wxCONCAT_HELPER(L, x)
#endif /* !defined(wxT) */
/*
wxT_2 exists only for compatibility with wx 2.x and is the same as wxT() in
that version but nothing in the newer ones.
*/
#define wxT_2(x) x
/*
wxS ("wx string") macro can be used to create literals using the same
representation as wxString does internally, i.e. wchar_t by default
char in UTF-8-based builds.
*/
#if wxUSE_UNICODE_WCHAR
/*
As above with wxT(), wxS() argument is expanded if it's a macro.
*/
#define wxS(x) wxCONCAT_HELPER(L, x)
#else /* wxUSE_UNICODE_UTF8 */
#define wxS(x) x
#endif
/*
_T() is a synonym for wxT() familiar to Windows programmers. As this macro
has even higher risk of conflicting with system headers, its use is
discouraged and you may predefine wxNO__T to disable it. Additionally, we
do it ourselves for Sun CC which is known to use it in its standard headers
(see #10660).
*/
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#ifndef wxNO__T
#define wxNO__T
#endif
#endif
#if !defined(_T) && !defined(wxNO__T)
#define _T(x) wxT(x)
#endif
/* a helper macro allowing to make another macro Unicode-friendly, see below */
#define wxAPPLY_T(x) wxT(x)
/*
Unicode-friendly analogs of the standard __FILE__, DATE and TIME macros.
These macros exist only for backwards compatibility, there should be no
reason to use them in the new code, just use the standard macros instead.
Also note that we must not use the actual macro names for the two latter
ones, as doing this would prevent ccache from caching the results of
compiling any file including this header by default, rendering ccache
ineffective for wxWidgets programs. Hence the use of "##" below and avoiding
naming these macros in this comment.
*/
#ifndef __TFILE__
#define __TFILE__ wxAPPLY_T(__FILE__)
#endif
#ifndef __TDATE__
#define __TDATE__ wxAPPLY_T(__ ## DATE__)
#endif
#ifndef __TTIME__
#define __TTIME__ wxAPPLY_T(__ ## TIME__)
#endif
#endif /* _WX_WXCHARTYPE_H_ */

View File

@@ -0,0 +1,200 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/checkbox.h
// Purpose: wxCheckBox class interface
// Author: Vadim Zeitlin
// Created: 07.09.00
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKBOX_H_BASE_
#define _WX_CHECKBOX_H_BASE_
#include "wx/defs.h"
#if wxUSE_CHECKBOX
#include "wx/control.h"
/*
* wxCheckBox style flags
* (Using wxCHK_* because wxCB_* is used by wxComboBox).
* Determine whether to use a 3-state or 2-state
* checkbox. 3-state enables to differentiate
* between 'unchecked', 'checked' and 'undetermined'.
*
* In addition to the styles here it is also possible to specify just 0 which
* is treated the same as wxCHK_2STATE for compatibility (but using explicit
* flag is preferred).
*/
#define wxCHK_2STATE 0x4000
#define wxCHK_3STATE 0x1000
/*
* If this style is set the user can set the checkbox to the
* undetermined state. If not set the undetermined set can only
* be set programmatically.
* This style can only be used with 3 state checkboxes.
*/
#define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
extern WXDLLIMPEXP_DATA_CORE(const char) wxCheckBoxNameStr[];
// ----------------------------------------------------------------------------
// wxCheckBox: a control which shows a label and a box which may be checked
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCheckBoxBase : public wxControl
{
public:
wxCheckBoxBase() = default;
// set/get the checked status of the listbox
virtual void SetValue(bool value) = 0;
virtual bool GetValue() const = 0;
bool IsChecked() const
{
wxASSERT_MSG( !Is3State(), wxT("Calling IsChecked() doesn't make sense for")
wxT(" a three state checkbox, Use Get3StateValue() instead") );
return GetValue();
}
wxCheckBoxState Get3StateValue() const
{
wxCheckBoxState state = DoGet3StateValue();
if ( state == wxCHK_UNDETERMINED && !Is3State() )
{
// Undetermined state with a 2-state checkbox??
wxFAIL_MSG( wxT("DoGet3StateValue() says the 2-state checkbox is ")
wxT("in an undetermined/third state") );
state = wxCHK_UNCHECKED;
}
return state;
}
void Set3StateValue(wxCheckBoxState state)
{
if ( state == wxCHK_UNDETERMINED && !Is3State() )
{
wxFAIL_MSG(wxT("Setting a 2-state checkbox to undetermined state"));
state = wxCHK_UNCHECKED;
}
DoSet3StateValue(state);
}
bool Is3State() const { return HasFlag(wxCHK_3STATE); }
bool Is3rdStateAllowedForUser() const
{
return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER);
}
virtual bool HasTransparentBackground() override { return true; }
// This semi-private function is currently used to allow wxMSW checkbox to
// blend in with its parent background colour without changing the
// background colour of the checkbox itself under the other platforms.
virtual void SetTransparentPartColour(const wxColour& WXUNUSED(col)) { }
// do the window-specific processing before processing the update event
// (mainly for deciding whether wxUpdateUIEvent::Is3State() is set)
virtual void DoPrepareUpdateWindowUI(wxUpdateUIEvent& event) const override
{ event.Allow3rdState(Is3State()); }
// wxCheckBox-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) override
{
wxControl::DoUpdateWindowUI(event);
if ( event.GetSetChecked() )
{
if ( Is3State() )
{
Set3StateValue(event.Get3StateValue());
}
else
{
SetValue(event.GetChecked());
}
}
}
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const override { return wxBORDER_NONE; }
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
virtual wxCheckBoxState DoGet3StateValue() const
{
wxFAIL;
return wxCHK_UNCHECKED;
}
// Helper function to be called from derived classes Create()
// implementations: it checks that the style doesn't contain any
// incompatible bits and modifies it to be sane if it does.
static void WXValidateStyle(long *stylePtr)
{
long& style = *stylePtr;
if ( !(style & (wxCHK_2STATE | wxCHK_3STATE)) )
{
// For compatibility we use absence of style flags as wxCHK_2STATE
// because wxCHK_2STATE used to have the value of 0 and some
// existing code uses 0 instead of it. Moreover, some code even
// uses some non-0 style, e.g. wxBORDER_XXX, but specifies
// neither wxCHK_2STATE nor wxCHK_3STATE -- to avoid breaking it,
// assume (much more common) 2 state checkbox by default.
style |= wxCHK_2STATE;
}
if ( style & wxCHK_3STATE )
{
if ( style & wxCHK_2STATE )
{
wxFAIL_MSG( "wxCHK_2STATE and wxCHK_3STATE can't be used "
"together" );
style &= ~wxCHK_3STATE;
}
}
else // No wxCHK_3STATE
{
if ( style & wxCHK_ALLOW_3RD_STATE_FOR_USER )
{
wxFAIL_MSG( "wxCHK_ALLOW_3RD_STATE_FOR_USER doesn't make sense "
"without wxCHK_3STATE" );
style &= ~wxCHK_ALLOW_3RD_STATE_FOR_USER;
}
}
}
private:
wxDECLARE_NO_COPY_CLASS(wxCheckBoxBase);
};
// All still supported ports support 3 state checkboxes.
#define wxHAS_3STATE_CHECKBOX
#if defined(__WXUNIVERSAL__)
#include "wx/univ/checkbox.h"
#elif defined(__WXMSW__)
#include "wx/msw/checkbox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/checkbox.h"
#elif defined(__WXMAC__)
#include "wx/osx/checkbox.h"
#elif defined(__WXQT__)
#include "wx/qt/checkbox.h"
#endif
#endif // wxUSE_CHECKBOX
#endif // _WX_CHECKBOX_H_BASE_

View File

@@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/checkeddelete.h
// Purpose: wxCHECKED_DELETE() macro
// Author: Vadim Zeitlin
// Created: 2009-02-03
// Copyright: (c) 2002-2009 wxWidgets dev team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKEDDELETE_H_
#define _WX_CHECKEDDELETE_H_
#include "wx/cpp.h"
// TODO: provide wxCheckedDelete[Array]() template functions too
// ----------------------------------------------------------------------------
// wxCHECKED_DELETE and wxCHECKED_DELETE_ARRAY macros
// ----------------------------------------------------------------------------
/*
checked deleters are used to make sure that the type being deleted is really
a complete type.: otherwise sizeof() would result in a compile-time error
do { ... } while ( 0 ) construct is used to have an anonymous scope
(otherwise we could have name clashes between different "complete"s) but
still force a semicolon after the macro
*/
#define wxCHECKED_DELETE(ptr) \
wxSTATEMENT_MACRO_BEGIN \
typedef char complete[sizeof(*ptr)] WX_ATTRIBUTE_UNUSED; \
delete ptr; \
wxSTATEMENT_MACRO_END
#define wxCHECKED_DELETE_ARRAY(ptr) \
wxSTATEMENT_MACRO_BEGIN \
typedef char complete[sizeof(*ptr)] WX_ATTRIBUTE_UNUSED; \
delete [] ptr; \
wxSTATEMENT_MACRO_END
#endif // _WX_CHECKEDDELETE_H_

View File

@@ -0,0 +1,52 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/checklst.h
// Purpose: wxCheckListBox class interface
// Author: Vadim Zeitlin
// Created: 12.09.00
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKLST_H_BASE_
#define _WX_CHECKLST_H_BASE_
#include "wx/defs.h"
#if wxUSE_CHECKLISTBOX
#include "wx/listbox.h"
// ----------------------------------------------------------------------------
// wxCheckListBox: a listbox whose items may be checked
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCheckListBoxBase : public wxListBox
{
public:
wxCheckListBoxBase() = default;
// check list box specific methods
virtual bool IsChecked(unsigned int item) const = 0;
virtual void Check(unsigned int item, bool check = true) = 0;
virtual unsigned int GetCheckedItems(wxArrayInt& checkedItems) const;
wxDECLARE_NO_COPY_CLASS(wxCheckListBoxBase);
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/checklst.h"
#elif defined(__WXMSW__)
#include "wx/msw/checklst.h"
#elif defined(__WXGTK__)
#include "wx/gtk/checklst.h"
#elif defined(__WXMAC__)
#include "wx/osx/checklst.h"
#elif defined(__WXQT__)
#include "wx/qt/checklst.h"
#endif
#endif // wxUSE_CHECKLISTBOX
#endif
// _WX_CHECKLST_H_BASE_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/choicdlg.h
// Purpose: Includes generic choice dialog file
// Author: Julian Smart
// Created:
// Copyright: Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICDLG_H_BASE_
#define _WX_CHOICDLG_H_BASE_
#include "wx/defs.h"
#if wxUSE_CHOICEDLG
#include "wx/generic/choicdgg.h"
#endif
#endif // _WX_CHOICDLG_H_BASE_

View File

@@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/choice.h
// Purpose: wxChoice class interface
// Author: Vadim Zeitlin
// Created: 26.07.99
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICE_H_BASE_
#define _WX_CHOICE_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_CHOICE
#include "wx/ctrlsub.h" // the base class
// ----------------------------------------------------------------------------
// global data
// ----------------------------------------------------------------------------
extern WXDLLIMPEXP_DATA_CORE(const char) wxChoiceNameStr[];
// ----------------------------------------------------------------------------
// wxChoice allows to select one of a non-modifiable list of strings
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxChoiceBase : public wxControlWithItems
{
public:
wxChoiceBase() = default;
virtual ~wxChoiceBase();
// all generic methods are in wxControlWithItems
// get the current selection: this can only be different from the normal
// selection if the popup items list is currently opened and the user
// selected some item in it but didn't close the list yet; otherwise (and
// currently always on platforms other than MSW) this is the same as
// GetSelection()
virtual int GetCurrentSelection() const { return GetSelection(); }
// set/get the number of columns in the control (as they're not supported on
// most platforms, they do nothing by default)
virtual void SetColumns(int WXUNUSED(n) = 1 ) { }
virtual int GetColumns() const { return 1 ; }
// emulate selecting the item event.GetInt()
void Command(wxCommandEvent& event) override;
// override wxItemContainer::IsSorted
virtual bool IsSorted() const override { return HasFlag(wxCB_SORT); }
protected:
// The generic implementation doesn't determine the height correctly and
// doesn't account for the width of the arrow but does take into account
// the string widths, so the derived classes should override it and set the
// height and add the arrow width to the size returned by this version.
virtual wxSize DoGetBestSize() const override;
private:
wxDECLARE_NO_COPY_CLASS(wxChoiceBase);
};
// ----------------------------------------------------------------------------
// include the platform-dependent class definition
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/choice.h"
#elif defined(__WXMSW__)
#include "wx/msw/choice.h"
#elif defined(__WXGTK__)
#include "wx/gtk/choice.h"
#elif defined(__WXMAC__)
#include "wx/osx/choice.h"
#elif defined(__WXQT__)
#include "wx/qt/choice.h"
#endif
#endif // wxUSE_CHOICE
#endif // _WX_CHOICE_H_BASE_

View File

@@ -0,0 +1,123 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/choicebk.h
// Purpose: wxChoicebook: wxChoice and wxNotebook combination
// Author: Vadim Zeitlin
// Modified by: Wlodzimierz ABX Skiba from wx/listbook.h
// Created: 15.09.04
// Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICEBOOK_H_
#define _WX_CHOICEBOOK_H_
#include "wx/defs.h"
#if wxUSE_CHOICEBOOK
#include "wx/compositebookctrl.h"
#include "wx/choice.h"
class WXDLLIMPEXP_FWD_CORE wxChoice;
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
// wxChoicebook flags
#define wxCHB_DEFAULT wxBK_DEFAULT
#define wxCHB_TOP wxBK_TOP
#define wxCHB_BOTTOM wxBK_BOTTOM
#define wxCHB_LEFT wxBK_LEFT
#define wxCHB_RIGHT wxBK_RIGHT
#define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK
// ----------------------------------------------------------------------------
// wxChoicebook
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxChoicebook : public wxCompositeBookCtrlBase
{
public:
wxChoicebook() = default;
wxChoicebook(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString)
{
(void)Create(parent, id, pos, size, style, name);
}
// quasi ctor
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
virtual bool SetPageText(size_t n, const wxString& strText) override;
virtual wxString GetPageText(size_t n) const override;
virtual int GetPageImage(size_t n) const override;
virtual bool SetPageImage(size_t n, int imageId) override;
virtual bool InsertPage(size_t n,
wxWindow *page,
const wxString& text,
bool bSelect = false,
int imageId = NO_IMAGE) override;
virtual int SetSelection(size_t n) override
{ return DoSetSelection(n, SetSelection_SendEvent); }
virtual int ChangeSelection(size_t n) override { return DoSetSelection(n); }
virtual void SetImageList(wxImageList *imageList) override;
virtual bool DeleteAllPages() override;
// returns the choice control
wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
protected:
virtual void DoSetWindowVariant(wxWindowVariant variant) override;
virtual wxWindow *DoRemovePage(size_t page) override;
void UpdateSelectedPage(size_t newsel) override
{
GetChoiceCtrl()->Select(static_cast<int>(newsel));
}
wxBookCtrlEvent* CreatePageChangingEvent() const override;
void MakeChangedEvent(wxBookCtrlEvent &event) override;
// event handlers
void OnChoiceSelected(wxCommandEvent& event);
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook);
};
// ----------------------------------------------------------------------------
// choicebook event class and related stuff
// ----------------------------------------------------------------------------
// wxChoicebookEvent is obsolete and defined for compatibility only
#define wxChoicebookEvent wxBookCtrlEvent
typedef wxBookCtrlEventFunction wxChoicebookEventFunction;
#define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func)
#define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
#define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
// old wxEVT_COMMAND_* constants
#define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED
#define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING
#endif // wxUSE_CHOICEBOOK
#endif // _WX_CHOICEBOOK_H_

View File

@@ -0,0 +1,197 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/clipbrd.h
// Purpose: wxClipboard class and clipboard functions
// Author: Vadim Zeitlin
// Created: 19.10.99
// Copyright: (c) wxWidgets Team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLIPBRD_H_BASE_
#define _WX_CLIPBRD_H_BASE_
#include "wx/defs.h"
#if wxUSE_CLIPBOARD
#include "wx/event.h"
#include "wx/chartype.h"
#include "wx/dataobj.h" // for wxDataFormat
#include "wx/vector.h"
class WXDLLIMPEXP_FWD_CORE wxClipboard;
// ----------------------------------------------------------------------------
// wxClipboard represents the system clipboard. Normally, you should use
// wxTheClipboard which is a global pointer to the (unique) clipboard.
//
// Clipboard can be used to copy data to/paste data from. It works together
// with wxDataObject.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClipboardBase : public wxObject
{
public:
wxClipboardBase() { m_usePrimary = false; }
// open the clipboard before Add/SetData() and GetData()
virtual bool Open() = 0;
// close the clipboard after Add/SetData() and GetData()
virtual void Close() = 0;
// query whether the clipboard is opened
virtual bool IsOpened() const = 0;
// add to the clipboard data
//
// NB: the clipboard owns the pointer and will delete it, so data must be
// allocated on the heap
virtual bool AddData( wxDataObject *data ) = 0;
// set the clipboard data, this is the same as Clear() followed by
// AddData()
virtual bool SetData( wxDataObject *data ) = 0;
// ask if data in correct format is available
virtual bool IsSupported( const wxDataFormat& format ) = 0;
// ask if data in correct format is available
virtual bool IsSupportedAsync( wxEvtHandler *sink );
// fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject& data ) = 0;
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear() = 0;
// flushes the clipboard: this means that the data which is currently on
// clipboard will stay available even after the application exits (possibly
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush() { return false; }
// this allows to choose whether we work with CLIPBOARD (default) or
// PRIMARY selection on X11-based systems
//
// on the other ones, working with primary selection does nothing: this
// allows to write code which sets the primary selection when something is
// selected without any ill effects (i.e. without overwriting the
// clipboard which would be wrong on the platforms without X11 PRIMARY)
virtual void UsePrimarySelection(bool usePrimary = false)
{
m_usePrimary = usePrimary;
}
// return true if we're using primary selection
bool IsUsingPrimarySelection() const { return m_usePrimary; }
// Returns global instance (wxTheClipboard) of the object:
static wxClipboard *Get();
// don't use this directly, it is public for compatibility with some ports
// (wxX11) only
bool m_usePrimary;
};
// ----------------------------------------------------------------------------
// asynchronous clipboard event
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClipboardEvent : public wxEvent
{
public:
wxClipboardEvent(wxEventType evtType = wxEVT_NULL)
: wxEvent(0, evtType)
{
}
wxClipboardEvent(const wxClipboardEvent& event)
: wxEvent(event),
m_formats(event.m_formats)
{
}
bool SupportsFormat(const wxDataFormat& format) const;
void AddFormat(const wxDataFormat& format);
wxNODISCARD virtual wxEvent *Clone() const override
{
return new wxClipboardEvent(*this);
}
protected:
wxVector<wxDataFormat> m_formats;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardEvent);
};
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent );
typedef void (wxEvtHandler::*wxClipboardEventFunction)(wxClipboardEvent&);
#define wxClipboardEventHandler(func) \
wxEVENT_HANDLER_CAST(wxClipboardEventFunction, func)
#define EVT_CLIPBOARD_CHANGED(func) wx__DECLARE_EVT0(wxEVT_CLIPBOARD_CHANGED, wxClipboardEventHandler(func))
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
// The global clipboard object - backward compatible access macro:
#define wxTheClipboard (wxClipboard::Get())
// ----------------------------------------------------------------------------
// include platform-specific class declaration
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/clipbrd.h"
#elif defined(__WXGTK__)
#include "wx/gtk/clipbrd.h"
#elif defined(__WXX11__)
#include "wx/x11/clipbrd.h"
#elif defined(__WXMAC__)
#include "wx/osx/clipbrd.h"
#elif defined(__WXQT__)
#include "wx/qt/clipbrd.h"
#endif
// ----------------------------------------------------------------------------
// helpful class for opening the clipboard and automatically closing it
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClipboardLocker
{
public:
wxClipboardLocker(wxClipboard *clipboard = nullptr)
{
m_clipboard = clipboard ? clipboard : wxTheClipboard;
if ( m_clipboard )
{
m_clipboard->Open();
}
}
bool operator!() const { return !m_clipboard->IsOpened(); }
~wxClipboardLocker()
{
if ( m_clipboard )
{
m_clipboard->Close();
}
}
private:
wxClipboard *m_clipboard;
wxDECLARE_NO_COPY_CLASS(wxClipboardLocker);
};
#endif // wxUSE_CLIPBOARD
#endif // _WX_CLIPBRD_H_BASE_

View File

@@ -0,0 +1,198 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/clntdata.h
// Purpose: A mixin class for holding a wxClientData or void pointer
// Author: Robin Dunn
// Created: 9-Oct-2001
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLNTDATAH__
#define _WX_CLNTDATAH__
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/object.h"
#include <unordered_map>
typedef int (*wxShadowObjectMethod)(void*, void*);
using wxShadowObjectMethods = std::unordered_map<wxString, wxShadowObjectMethod>;
using wxShadowObjectFields = std::unordered_map<wxString, void*>;
class WXDLLIMPEXP_BASE wxShadowObject
{
public:
wxShadowObject() = default;
void AddMethod( const wxString &name, wxShadowObjectMethod method )
{
const auto it = m_methods.find( name );
if (it == m_methods.end())
m_methods[ name ] = method;
else
it->second = method;
}
bool InvokeMethod( const wxString &name, void* window, void* param, int* returnValue )
{
const auto it = m_methods.find( name );
if (it == m_methods.end())
return false;
wxShadowObjectMethod method = it->second;
const int ret = (*method)(window, param);
if (returnValue)
*returnValue = ret;
return true;
}
void AddField( const wxString &name, void* initialValue = nullptr )
{
const auto it = m_fields.find( name );
if (it == m_fields.end())
m_fields[ name ] = initialValue;
else
it->second = initialValue;
}
void SetField( const wxString &name, void* value )
{
const auto it = m_fields.find( name );
if (it == m_fields.end())
return;
it->second = value;
}
void* GetField( const wxString &name, void *defaultValue = nullptr )
{
const auto it = m_fields.find( name );
if (it == m_fields.end())
return defaultValue;
return it->second;
}
private:
wxShadowObjectMethods m_methods;
wxShadowObjectFields m_fields;
};
// ----------------------------------------------------------------------------
// what kind of client data do we have?
enum wxClientDataType
{
wxClientData_None, // we don't know yet because we don't have it at all
wxClientData_Object, // our client data is typed and we own it
wxClientData_Void // client data is untyped and we don't own it
};
class WXDLLIMPEXP_BASE wxClientData
{
public:
wxClientData() = default;
virtual ~wxClientData() = default;
};
class WXDLLIMPEXP_BASE wxStringClientData : public wxClientData
{
public:
wxStringClientData() : m_data() { }
wxStringClientData( const wxString &data ) : m_data(data) { }
void SetData( const wxString &data ) { m_data = data; }
const wxString& GetData() const { return m_data; }
private:
wxString m_data;
};
// This class is a mixin that provides storage and management of "client
// data." The client data stored can either be a pointer to a wxClientData
// object in which case it is managed by the container (i.e. it will delete
// the data when it's destroyed) or an untyped pointer which won't be deleted
// by the container - but not both of them
//
// NOTE: This functionality is currently duplicated in wxEvtHandler in order
// to avoid having more than one vtable in that class hierarchy.
class WXDLLIMPEXP_BASE wxClientDataContainer
{
public:
wxClientDataContainer();
virtual ~wxClientDataContainer();
void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
wxClientData *GetClientObject() const { return DoGetClientObject(); }
void SetClientData( void *data ) { DoSetClientData(data); }
void *GetClientData() const { return DoGetClientData(); }
protected:
// The user data: either an object which will be deleted by the container
// when it's deleted or some raw pointer which we do nothing with. Only
// one type of data can be used with the given window, i.e. you cannot set
// the void data and then associate the container with wxClientData or vice
// versa.
union
{
wxClientData *m_clientObject;
void *m_clientData;
};
// client data accessors
virtual void DoSetClientObject( wxClientData *data );
virtual wxClientData *DoGetClientObject() const;
virtual void DoSetClientData( void *data );
virtual void *DoGetClientData() const;
// what kind of data do we have?
wxClientDataType m_clientDataType;
};
// This class is a replacement for wxClientDataContainer, and unlike
// wxClientDataContainer the wxSharedClientDataContainer client data is
// copiable, so it can be copied when objects containing it are cloned.
// Like wxClientDataContainer, wxSharedClientDataContainer is a mixin
// that provides storage and management of "client data.". The client data
// is reference counted and managed by the container.
//
// NOTE: If your class has a clone function and needs to store client data,
// use wxSharedClientDataContainer and not wxClientDataContainer!
class WXDLLIMPEXP_BASE wxSharedClientDataContainer
{
public:
// Provide the same functions as in wxClientDataContainer, so that objects
// using it and this class could be used in exactly the same way.
void SetClientObject(wxClientData *data);
wxClientData *GetClientObject() const;
void SetClientData(void *data);
void *GetClientData() const;
protected:
bool HasClientDataContainer() const { return m_data.get() != nullptr; }
void CopyClientDataContainer(const wxSharedClientDataContainer& other)
{
m_data = other.m_data;
}
private:
class wxRefCountedClientDataContainer : public wxClientDataContainer,
public wxRefCounter
{
};
// Helper function that will create m_data if it is currently null
wxClientDataContainer *GetValidClientData();
// m_data is shared, not deep copied, when cloned. If you make changes to
// the data in one instance of your class, you change it for all cloned
// instances!
wxObjectDataPtr<wxRefCountedClientDataContainer> m_data;
};
#endif // _WX_CLNTDATAH__

View File

@@ -0,0 +1,212 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/clrpicker.h
// Purpose: wxColourPickerCtrl base header
// Author: Francesco Montorsi (based on Vadim Zeitlin's code)
// Created: 14/4/2006
// Copyright: (c) Vadim Zeitlin, Francesco Montorsi
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLRPICKER_H_BASE_
#define _WX_CLRPICKER_H_BASE_
#include "wx/defs.h"
#if wxUSE_COLOURPICKERCTRL
#include "wx/pickerbase.h"
class WXDLLIMPEXP_FWD_CORE wxColourPickerEvent;
extern WXDLLIMPEXP_DATA_CORE(const char) wxColourPickerWidgetNameStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxColourPickerCtrlNameStr[];
// show the colour in HTML form (#AABBCC) as colour button label
#define wxCLRBTN_SHOW_LABEL 100
// the default style
#define wxCLRBTN_DEFAULT_STYLE (wxCLRBTN_SHOW_LABEL)
// ----------------------------------------------------------------------------
// wxColourPickerWidgetBase: a generic abstract interface which must be
// implemented by controls used by wxColourPickerCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxColourPickerWidgetBase
{
public:
wxColourPickerWidgetBase() : m_colour(*wxBLACK) { }
virtual ~wxColourPickerWidgetBase() = default;
wxColour GetColour() const
{ return m_colour; }
virtual void SetColour(const wxColour &col)
{ m_colour = col; UpdateColour(); }
virtual void SetColour(const wxString &col)
{ m_colour.Set(col); UpdateColour(); }
protected:
virtual void UpdateColour() = 0;
// the current colour (may be invalid if none)
wxColour m_colour;
};
// Styles which must be supported by all controls implementing wxColourPickerWidgetBase
// NB: these styles must be defined to carefully-chosen values to
// avoid conflicts with wxButton's styles
// show the colour in HTML form (#AABBCC) as colour button label
// (instead of no label at all)
// NOTE: this style is supported just by wxColourButtonGeneric and
// thus is not exposed in wxColourPickerCtrl
#define wxCLRP_SHOW_LABEL 0x0008
#define wxCLRP_SHOW_ALPHA 0x0010
// map platform-dependent controls which implement the wxColourPickerWidgetBase
// under the name "wxColourPickerWidget".
// NOTE: wxColourPickerCtrl allocates a wxColourPickerWidget and relies on the
// fact that all classes being mapped as wxColourPickerWidget have the
// same prototype for their constructor (and also explains why we use
// define instead of a typedef)
// since GTK > 2.4, there is GtkColorButton
#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/clrpicker.h"
#define wxColourPickerWidget wxColourButton
#elif defined(__WXQT__) && !defined(__WXUNIVERSAL__)
#include "wx/qt/clrpicker.h"
#else
#include "wx/generic/clrpickerg.h"
#define wxColourPickerWidget wxGenericColourButton
#endif
// ----------------------------------------------------------------------------
// wxColourPickerCtrl: platform-independent class which embeds a
// platform-dependent wxColourPickerWidget and, if wxCLRP_USE_TEXTCTRL style is
// used, a textctrl next to it.
// ----------------------------------------------------------------------------
#define wxCLRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
#define wxCLRP_DEFAULT_STYLE 0
class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase
{
public:
wxColourPickerCtrl() = default;
virtual ~wxColourPickerCtrl() = default;
wxColourPickerCtrl(wxWindow *parent, wxWindowID id,
const wxColour& col = *wxBLACK, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxCLRP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxColourPickerCtrlNameStr))
{ Create(parent, id, col, pos, size, style, validator, name); }
bool Create(wxWindow *parent, wxWindowID id,
const wxColour& col = *wxBLACK,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCLRP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxColourPickerCtrlNameStr));
public: // public API
// get the colour chosen
wxColour GetColour() const
{ return ((wxColourPickerWidget *)m_picker)->GetColour(); }
// set currently displayed color
void SetColour(const wxColour& col);
// set colour using RGB(r,g,b) syntax or considering given text as a colour name;
// returns true if the given text was successfully recognized.
bool SetColour(const wxString& text);
public: // internal functions
// update the button colour to match the text control contents
void UpdatePickerFromTextCtrl() override;
// update the text control to match the button's colour
void UpdateTextCtrlFromPicker() override;
// event handler for our picker
void OnColourChange(wxColourPickerEvent &);
protected:
virtual long GetPickerStyle(long style) const override
{ return (style & (wxCLRP_SHOW_LABEL | wxCLRP_SHOW_ALPHA)); }
private:
wxDECLARE_DYNAMIC_CLASS(wxColourPickerCtrl);
};
// ----------------------------------------------------------------------------
// wxColourPickerEvent: used by wxColourPickerCtrl only
// ----------------------------------------------------------------------------
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLOURPICKER_CHANGED, wxColourPickerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLOURPICKER_CURRENT_CHANGED, wxColourPickerEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLOURPICKER_DIALOG_CANCELLED, wxColourPickerEvent );
class WXDLLIMPEXP_CORE wxColourPickerEvent : public wxCommandEvent
{
public:
wxColourPickerEvent() = default;
wxColourPickerEvent(wxObject *generator, int id, const wxColour &col, wxEventType commandType = wxEVT_COLOURPICKER_CHANGED)
: wxCommandEvent(commandType, id),
m_colour(col)
{
SetEventObject(generator);
}
wxColour GetColour() const { return m_colour; }
void SetColour(const wxColour &c) { m_colour = c; }
// default copy ctor, assignment operator and dtor are ok
wxNODISCARD virtual wxEvent *Clone() const override { return new wxColourPickerEvent(*this); }
private:
wxColour m_colour;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxColourPickerEvent);
};
// ----------------------------------------------------------------------------
// event types and macros
// ----------------------------------------------------------------------------
typedef void (wxEvtHandler::*wxColourPickerEventFunction)(wxColourPickerEvent&);
#define wxColourPickerEventHandler(func) \
wxEVENT_HANDLER_CAST(wxColourPickerEventFunction, func)
#define EVT_COLOURPICKER_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COLOURPICKER_CHANGED, id, wxColourPickerEventHandler(fn))
#define EVT_COLOURPICKER_CURRENT_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COLOURPICKER_CURRENT_CHANGED, id, wxColourPickerEventHandler(fn))
#define EVT_COLOURPICKER_DIALOG_CANCELLED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COLOURPICKER_DIALOG_CANCELLED, id, wxColourPickerEventHandler(fn))
// old wxEVT_COMMAND_* constant
#define wxEVT_COMMAND_COLOURPICKER_CHANGED wxEVT_COLOURPICKER_CHANGED
#endif // wxUSE_COLOURPICKERCTRL
#endif // _WX_CLRPICKER_H_BASE_

View File

@@ -0,0 +1,150 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cmdargs.h
// Purpose: declaration of wxCmdLineArgsArray helper class
// Author: Vadim Zeitlin
// Created: 2007-11-12
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMDARGS_H_
#define _WX_CMDARGS_H_
#include "wx/arrstr.h"
// ----------------------------------------------------------------------------
// wxCmdLineArgsArray: helper class used by wxApp::argv
// ----------------------------------------------------------------------------
// this class is used instead of either "char **" or "wchar_t **" (neither of
// which would be backwards compatible with all the existing code) for argv
// field of wxApp
//
// as it's used for compatibility, it tries to look as much as traditional
// (char **) argv as possible, in particular it provides implicit conversions
// to "char **" and also array-like operator[]
class WXDLLIMPEXP_BASE wxCmdLineArgsArray
{
public:
wxCmdLineArgsArray() { m_argsA = nullptr; m_argsW = nullptr; }
template <typename T>
void Init(int argc, T **argv)
{
FreeArgs();
m_args.clear();
m_args.reserve(argc);
for ( int i = 0; i < argc; i++ )
{
m_args.push_back(argv[i]);
}
}
operator char**() const
{
if ( !m_argsA )
{
const size_t count = m_args.size();
m_argsA = new char *[count + 1];
for ( size_t n = 0; n < count; n++ )
m_argsA[n] = wxStrdup(m_args[n].ToAscii());
m_argsA[count] = nullptr;
}
return m_argsA;
}
operator wchar_t**() const
{
if ( !m_argsW )
{
const size_t count = m_args.size();
m_argsW = new wchar_t *[count + 1];
for ( size_t n = 0; n < count; n++ )
m_argsW[n] = wxStrdup(m_args[n].wc_str());
m_argsW[count] = nullptr;
}
return m_argsW;
}
// existing code does checks like "if ( argv )" and we want it to continue
// to compile, so provide this conversion even if it is pretty dangerous
operator bool() const
{
return !m_args.empty();
}
// and the same for "if ( !argv )" checks
bool operator!() const
{
return m_args.empty();
}
wxString operator[](size_t n) const
{
return m_args[n];
}
// we must provide this overload for g++ 3.4 which can't choose between
// our operator[](size_t) and ::operator[](char**, int) otherwise
wxString operator[](int n) const
{
return m_args[n];
}
// convenience methods, i.e. not existing only for backwards compatibility
// do we have any arguments at all?
bool IsEmpty() const { return m_args.empty(); }
// access the arguments as a convenient array of wxStrings
const wxArrayString& GetArguments() const { return m_args; }
~wxCmdLineArgsArray()
{
FreeArgs();
}
private:
template <typename T>
void Free(T**& args)
{
if ( !args )
return;
const size_t count = m_args.size();
for ( size_t n = 0; n < count; n++ )
free(args[n]);
delete [] args;
args = nullptr;
}
void FreeArgs()
{
Free(m_argsA);
Free(m_argsW);
}
wxArrayString m_args;
mutable char **m_argsA;
mutable wchar_t **m_argsW;
wxDECLARE_NO_COPY_CLASS(wxCmdLineArgsArray);
};
// provide global operator overload for compatibility with the existing code
// doing things like "if ( condition && argv )"
inline bool operator&&(bool cond, const wxCmdLineArgsArray& array)
{
return cond && !array.IsEmpty();
}
#endif // _WX_CMDARGS_H_

View File

@@ -0,0 +1,385 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cmdline.h
// Purpose: wxCmdLineParser and related classes for parsing the command
// line options
// Author: Vadim Zeitlin
// Created: 04.01.00
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMDLINE_H_
#define _WX_CMDLINE_H_
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/arrstr.h"
#include "wx/cmdargs.h"
// determines ConvertStringToArgs() behaviour
enum wxCmdLineSplitType
{
wxCMD_LINE_SPLIT_DOS,
wxCMD_LINE_SPLIT_UNIX
};
#if wxUSE_CMDLINE_PARSER
class WXDLLIMPEXP_FWD_BASE wxCmdLineParser;
class WXDLLIMPEXP_FWD_BASE wxDateTime;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// by default, options are optional (sic) and each call to AddParam() allows
// one more parameter - this may be changed by giving non-default flags to it
enum wxCmdLineEntryFlags
{
wxCMD_LINE_OPTION_MANDATORY = 0x01, // this option must be given
wxCMD_LINE_PARAM_OPTIONAL = 0x02, // the parameter may be omitted
wxCMD_LINE_PARAM_MULTIPLE = 0x04, // the parameter may be repeated
wxCMD_LINE_OPTION_HELP = 0x08, // this option is a help request
wxCMD_LINE_NEEDS_SEPARATOR = 0x10, // must have sep before the value
wxCMD_LINE_SWITCH_NEGATABLE = 0x20, // this switch can be negated (e.g. /S-)
wxCMD_LINE_HIDDEN = 0x40 // this switch is not listed by Usage()
};
// an option value or parameter may be a string (the most common case), a
// number or a date
enum wxCmdLineParamType
{
wxCMD_LINE_VAL_STRING, // should be 0 (default)
wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_VAL_DATE,
wxCMD_LINE_VAL_DOUBLE,
wxCMD_LINE_VAL_NONE
};
// for constructing the cmd line description using Init()
enum wxCmdLineEntryType
{
wxCMD_LINE_SWITCH,
wxCMD_LINE_OPTION,
wxCMD_LINE_PARAM,
wxCMD_LINE_USAGE_TEXT,
wxCMD_LINE_NONE // to terminate the list
};
// Possible return values of wxCmdLineParser::FoundSwitch()
enum wxCmdLineSwitchState
{
wxCMD_SWITCH_OFF = -1, // Found but turned off/negated.
wxCMD_SWITCH_NOT_FOUND, // Not found at all.
wxCMD_SWITCH_ON // Found in normal state.
};
// Constants determining how (and if) to wrap the usage message
constexpr int wxCMD_LINE_WRAP_AUTO = -1;
constexpr int wxCMD_LINE_WRAP_NONE = 0;
// ----------------------------------------------------------------------------
// wxCmdLineEntryDesc is a description of one command line
// switch/option/parameter
// ----------------------------------------------------------------------------
struct wxCmdLineEntryDesc
{
wxCmdLineEntryType kind;
const char *shortName;
const char *longName;
const char *description;
wxCmdLineParamType type;
int flags;
};
// the list of wxCmdLineEntryDesc objects should be terminated with this one
#define wxCMD_LINE_DESC_END \
{ wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0x0 }
// ----------------------------------------------------------------------------
// wxCmdLineArg contains the value for one command line argument
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxCmdLineArg
{
public:
virtual ~wxCmdLineArg() = default;
virtual double GetDoubleVal() const = 0;
virtual long GetLongVal() const = 0;
virtual const wxString& GetStrVal() const = 0;
#if wxUSE_DATETIME
virtual const wxDateTime& GetDateVal() const = 0;
#endif // wxUSE_DATETIME
virtual bool IsNegated() const = 0;
virtual wxCmdLineEntryType GetKind() const = 0;
virtual wxString GetShortName() const = 0;
virtual wxString GetLongName() const = 0;
virtual wxCmdLineParamType GetType() const = 0;
};
// ----------------------------------------------------------------------------
// wxCmdLineArgs is a container of command line arguments actually parsed and
// allows enumerating them using the standard iterator-based approach.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxCmdLineArgs
{
public:
class WXDLLIMPEXP_BASE const_iterator
{
public:
typedef int difference_type;
typedef wxCmdLineArg value_type;
typedef const wxCmdLineArg* pointer;
typedef const wxCmdLineArg& reference;
typedef std::bidirectional_iterator_tag iterator_category;
const_iterator() : m_parser(nullptr), m_index(0) {}
reference operator *() const;
pointer operator ->() const;
const_iterator &operator ++ ();
const_iterator operator ++ (int);
const_iterator &operator -- ();
const_iterator operator -- (int);
bool operator == (const const_iterator &other) const {
return m_parser==other.m_parser && m_index==other.m_index;
}
bool operator != (const const_iterator &other) const {
return !operator==(other);
}
private:
const_iterator (const wxCmdLineParser& parser, size_t index)
: m_parser(&parser), m_index(index) {
}
const wxCmdLineParser* m_parser;
size_t m_index;
friend class wxCmdLineArgs;
};
wxCmdLineArgs (const wxCmdLineParser& parser) : m_parser(parser) {}
const_iterator begin() const { return const_iterator(m_parser, 0); }
const_iterator end() const { return const_iterator(m_parser, size()); }
size_t size() const;
private:
const wxCmdLineParser& m_parser;
wxDECLARE_NO_ASSIGN_DEF_COPY(wxCmdLineArgs);
};
// ----------------------------------------------------------------------------
// wxCmdLineParser is a class for parsing command line.
//
// It has the following features:
//
// 1. distinguishes options, switches and parameters; allows option grouping
// 2. allows both short and long options
// 3. automatically generates the usage message from the cmd line description
// 4. does type checks on the options values (number, date, ...)
//
// To use it you should:
//
// 1. construct it giving it the cmd line to parse and optionally its desc
// 2. construct the cmd line description using AddXXX() if not done in (1)
// 3. call Parse()
// 4. use GetXXX() to retrieve the parsed info
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxCmdLineParser
{
public:
// ctors and initializers
// ----------------------
// default ctor or ctor giving the cmd line in either Unix or Win form
wxCmdLineParser() { Init(); }
wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); }
wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); }
wxCmdLineParser(int argc, const wxCmdLineArgsArray& argv)
{ Init(); SetCmdLine(argc, argv); }
wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); }
// the same as above, but also gives the cmd line description - otherwise,
// use AddXXX() later
wxCmdLineParser(const wxCmdLineEntryDesc *desc)
{ Init(); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, char **argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc,
int argc,
const wxCmdLineArgsArray& argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline)
{ Init(); SetCmdLine(cmdline); SetDesc(desc); }
// set cmd line to parse after using one of the ctors which don't do it
void SetCmdLine(int argc, char **argv);
void SetCmdLine(int argc, wxChar **argv);
void SetCmdLine(int argc, const wxCmdLineArgsArray& argv);
void SetCmdLine(const wxString& cmdline);
// not virtual, don't use this class polymorphically
~wxCmdLineParser();
// set different parser options
// ----------------------------
// by default, '-' is switch char under Unix, '-' or '/' under Win:
// switchChars contains all characters with which an option or switch may
// start
void SetSwitchChars(const wxString& switchChars);
// long options are not POSIX-compliant, this option allows to disable them
void EnableLongOptions(bool enable = true);
void DisableLongOptions() { EnableLongOptions(false); }
bool AreLongOptionsEnabled() const;
// extra text may be shown by Usage() method if set by this function
void SetLogo(const wxString& logo);
// set the brief usage string instead of constructing it automatically
void SetUsageSynopsis(const wxString& synopsis);
// construct the cmd line description
// ----------------------------------
// take the cmd line description from the wxCMD_LINE_NONE terminated table
void SetDesc(const wxCmdLineEntryDesc *desc);
// a switch: i.e. an option without value
void AddSwitch(const wxString& name, const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString,
int flags = 0);
void AddLongSwitch(const wxString& lng,
const wxString& desc = wxEmptyString,
int flags = 0)
{
AddSwitch(wxString(), lng, desc, flags);
}
// an option taking a value of the given type
void AddOption(const wxString& name, const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0);
void AddLongOption(const wxString& lng,
const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0)
{
AddOption(wxString(), lng, desc, type, flags);
}
// a parameter
void AddParam(const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0);
// add an explanatory text to be shown to the user in help
void AddUsageText(const wxString& text);
// actions
// -------
// parse the command line, return 0 if ok, -1 if "-h" or "--help" option
// was encountered and the help message was given or a positive value if a
// syntax error occurred
//
// if showUsage is true, Usage() is called in case of syntax error or if
// help was requested and if wrapColumn is not 0, the usage message is
// wrapped at the specified column, which will be the terminal width for
// its default value
int Parse(bool showUsage = true, int wrapColumn = wxCMD_LINE_WRAP_AUTO);
// give the usage message describing all program options
void Usage(int wrapColumn = wxCMD_LINE_WRAP_AUTO) const;
// return the usage string, call Usage() to directly show it to the user
wxString GetUsageString(int wrapColumn = wxCMD_LINE_WRAP_AUTO) const;
// get the command line arguments
// ------------------------------
// returns true if the given switch was found
bool Found(const wxString& name) const;
// Returns wxCMD_SWITCH_NOT_FOUND if the switch was not found at all,
// wxCMD_SWITCH_ON if it was found in normal state and wxCMD_SWITCH_OFF if
// it was found but negated (i.e. followed by "-", this can only happen for
// the switches with wxCMD_LINE_SWITCH_NEGATABLE flag).
wxCmdLineSwitchState FoundSwitch(const wxString& name) const;
// returns true if an option taking a string value was found and stores the
// value in the provided pointer
bool Found(const wxString& name, wxString *value) const;
// returns true if an option taking an integer value was found and stores
// the value in the provided pointer
bool Found(const wxString& name, long *value) const;
// returns true if an option taking a double value was found and stores
// the value in the provided pointer
bool Found(const wxString& name, double *value) const;
#if wxUSE_DATETIME
// returns true if an option taking a date value was found and stores the
// value in the provided pointer
bool Found(const wxString& name, wxDateTime *value) const;
#endif // wxUSE_DATETIME
// gets the number of parameters found
size_t GetParamCount() const;
// gets the value of Nth parameter (as string only for now)
wxString GetParam(size_t n = 0u) const;
// returns a reference to the container of all command line arguments
wxCmdLineArgs GetArguments() const { return wxCmdLineArgs(*this); }
// Resets switches and options
void Reset();
// break down the command line in arguments
static wxArrayString
ConvertStringToArgs(const wxString& cmdline,
wxCmdLineSplitType type = wxCMD_LINE_SPLIT_DOS);
private:
// common part of all ctors
void Init();
struct wxCmdLineParserData *m_data;
friend class wxCmdLineArgs;
friend class wxCmdLineArgs::const_iterator;
wxDECLARE_NO_COPY_CLASS(wxCmdLineParser);
};
#else // !wxUSE_CMDLINE_PARSER
// this function is always available (even if !wxUSE_CMDLINE_PARSER) because it
// is used by wxWin itself under Windows
class WXDLLIMPEXP_BASE wxCmdLineParser
{
public:
static wxArrayString
ConvertStringToArgs(const wxString& cmdline,
wxCmdLineSplitType type = wxCMD_LINE_SPLIT_DOS);
};
#endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
#endif // _WX_CMDLINE_H_

View File

@@ -0,0 +1,139 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cmdproc.h
// Purpose: undo/redo capable command processing framework
// Author: Julian Smart (extracted from docview.h by VZ)
// Created: 05.11.00
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMDPROC_H_
#define _WX_CMDPROC_H_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/list.h"
class WXDLLIMPEXP_FWD_CORE wxMenu;
// ----------------------------------------------------------------------------
// wxCommand: a single command capable of performing itself
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCommand : public wxObject
{
public:
wxCommand(bool canUndoIt = false, const wxString& name = wxEmptyString);
virtual ~wxCommand() = default;
// Override this to perform a command
virtual bool Do() = 0;
// Override this to undo a command
virtual bool Undo() = 0;
virtual bool CanUndo() const { return m_canUndo; }
virtual wxString GetName() const { return m_commandName; }
protected:
bool m_canUndo;
wxString m_commandName;
private:
wxDECLARE_CLASS(wxCommand);
};
// ----------------------------------------------------------------------------
// wxCommandProcessor: wxCommand manager
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCommandProcessor : public wxObject
{
public:
// if max number of commands is -1, it is unlimited
wxCommandProcessor(int maxCommands = -1);
virtual ~wxCommandProcessor();
// Pass a command to the processor. The processor calls Do(); if
// successful, is appended to the command history unless storeIt is false.
virtual bool Submit(wxCommand *command, bool storeIt = true);
// just store the command without executing it
virtual void Store(wxCommand *command);
virtual bool Undo();
virtual bool Redo();
virtual bool CanUndo() const;
virtual bool CanRedo() const;
// Initialises the current command and menu strings.
virtual void Initialize();
// Sets the Undo/Redo menu strings for the current menu.
virtual void SetMenuStrings();
// Gets the current Undo menu label.
wxString GetUndoMenuLabel() const;
// Gets the current Undo menu label.
wxString GetRedoMenuLabel() const;
#if wxUSE_MENUS
// Call this to manage an edit menu.
void SetEditMenu(wxMenu *menu) { m_commandEditMenu = menu; }
wxMenu *GetEditMenu() const { return m_commandEditMenu; }
#endif // wxUSE_MENUS
// command list access
wxList& GetCommands() { return m_commands; }
const wxList& GetCommands() const { return m_commands; }
wxCommand *GetCurrentCommand() const
{
return (wxCommand *)(m_currentCommand ? m_currentCommand->GetData() : nullptr);
}
int GetMaxCommands() const { return m_maxNoCommands; }
virtual void ClearCommands();
// Has the current project been changed?
virtual bool IsDirty() const;
// Mark the current command as the one where the last save took place
void MarkAsSaved()
{
m_lastSavedCommand = m_currentCommand;
}
// By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
const wxString& GetUndoAccelerator() const { return m_undoAccelerator; }
const wxString& GetRedoAccelerator() const { return m_redoAccelerator; }
void SetUndoAccelerator(const wxString& accel) { m_undoAccelerator = accel; }
void SetRedoAccelerator(const wxString& accel) { m_redoAccelerator = accel; }
protected:
// for further flexibility, command processor doesn't call wxCommand::Do()
// and Undo() directly but uses these functions which can be overridden in
// the derived class
virtual bool DoCommand(wxCommand& cmd);
virtual bool UndoCommand(wxCommand& cmd);
int m_maxNoCommands;
wxList m_commands;
wxList::compatibility_iterator m_currentCommand,
m_lastSavedCommand;
#if wxUSE_MENUS
wxMenu* m_commandEditMenu;
#endif // wxUSE_MENUS
wxString m_undoAccelerator;
wxString m_redoAccelerator;
private:
wxDECLARE_DYNAMIC_CLASS(wxCommandProcessor);
wxDECLARE_NO_COPY_CLASS(wxCommandProcessor);
};
#endif // _WX_CMDPROC_H_

View File

@@ -0,0 +1,381 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cmndata.h
// Purpose: Common GDI data classes
// Author: Julian Smart and others
// Created: 01/02/97
// Copyright: (c)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CMNDATA_H_BASE_
#define _WX_CMNDATA_H_BASE_
#include "wx/defs.h"
#if wxUSE_PRINTING_ARCHITECTURE
#include "wx/gdicmn.h"
#if wxUSE_STREAMS
#include "wx/stream.h"
#endif
#include <vector>
class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
/*
* wxPrintData
* Encapsulates printer information (not printer dialog information)
*/
enum wxPrintBin
{
wxPRINTBIN_DEFAULT,
wxPRINTBIN_ONLYONE,
wxPRINTBIN_LOWER,
wxPRINTBIN_MIDDLE,
wxPRINTBIN_MANUAL,
wxPRINTBIN_ENVELOPE,
wxPRINTBIN_ENVMANUAL,
wxPRINTBIN_AUTO,
wxPRINTBIN_TRACTOR,
wxPRINTBIN_SMALLFMT,
wxPRINTBIN_LARGEFMT,
wxPRINTBIN_LARGECAPACITY,
wxPRINTBIN_CASSETTE,
wxPRINTBIN_FORMSOURCE,
wxPRINTBIN_USER
};
const int wxPRINTMEDIA_DEFAULT = 0;
class WXDLLIMPEXP_CORE wxPrintData: public wxObject
{
public:
wxPrintData();
wxPrintData(const wxPrintData& printData);
virtual ~wxPrintData();
int GetNoCopies() const { return m_printNoCopies; }
bool GetCollate() const { return m_printCollate; }
wxPrintOrientation GetOrientation() const { return m_printOrientation; }
bool IsOrientationReversed() const { return m_printOrientationReversed; }
// Is this data OK for showing the print dialog?
bool Ok() const { return IsOk(); }
bool IsOk() const ;
const wxString& GetPrinterName() const { return m_printerName; }
bool GetColour() const { return m_colour; }
wxDuplexMode GetDuplex() const { return m_duplexMode; }
wxPaperSize GetPaperId() const { return m_paperId; }
const wxSize& GetPaperSize() const { return m_paperSize; }
wxPrintQuality GetQuality() const { return m_printQuality; }
wxPrintBin GetBin() const { return m_bin; }
wxPrintMode GetPrintMode() const { return m_printMode; }
int GetMedia() const { return m_media; }
void SetNoCopies(int v) { m_printNoCopies = v; }
void SetCollate(bool flag) { m_printCollate = flag; }
// Please use the overloaded method below
wxDEPRECATED_INLINE(void SetOrientation(int orient),
m_printOrientation = (wxPrintOrientation)orient; )
void SetOrientation(wxPrintOrientation orient) { m_printOrientation = orient; }
void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; }
void SetPrinterName(const wxString& name) { m_printerName = name; }
void SetColour(bool colour) { m_colour = colour; }
void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
void SetBin(wxPrintBin bin) { m_bin = bin; }
void SetMedia(int media) { m_media = media; }
void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
wxString GetFilename() const { return m_filename; }
void SetFilename( const wxString &filename ) { m_filename = filename; }
wxPrintData& operator=(const wxPrintData& data);
char* GetPrivData() { return m_privData.empty() ? nullptr : &m_privData[0]; }
const char* GetPrivData() const { return m_privData.empty() ? nullptr : &m_privData[0]; }
int GetPrivDataLen() const { return wxSsize(m_privData); }
void SetPrivData( char *privData, int len );
// Convert between wxPrintData and native data
void ConvertToNative();
void ConvertFromNative();
// Holds the native print data
wxPrintNativeDataBase *GetNativeData() const { return m_nativeData.get(); }
private:
wxPrintBin m_bin = wxPRINTBIN_DEFAULT;
int m_media = wxPRINTMEDIA_DEFAULT;
wxPrintMode m_printMode = wxPRINT_MODE_PRINTER;
int m_printNoCopies = 1;
wxPrintOrientation m_printOrientation = wxPORTRAIT;
bool m_printOrientationReversed = false;
bool m_printCollate = false;
wxString m_printerName;
bool m_colour = true;
wxDuplexMode m_duplexMode = wxDUPLEX_SIMPLEX;
wxPrintQuality m_printQuality = wxPRINT_QUALITY_HIGH;
// we intentionally don't initialize paper id and size at all, like this
// the default system settings will be used for them
wxPaperSize m_paperId = wxPAPER_NONE;
wxSize m_paperSize = wxDefaultSize;
wxString m_filename;
std::vector<char> m_privData;
wxObjectDataPtr<wxPrintNativeDataBase> m_nativeData;
private:
wxDECLARE_DYNAMIC_CLASS(wxPrintData);
};
/*
* wxPrintPageRange
* Defines a range of pages to be printed.
*/
class wxPrintPageRange
{
public:
wxPrintPageRange() = default;
wxPrintPageRange(int from, int to) : fromPage(from), toPage(to)
{
wxASSERT_MSG( IsValid(), "Invalid page range values" );
}
// check if both components are set/initialized correctly
bool IsValid() const { return fromPage > 0 && fromPage <= toPage; }
// get the number of pages in the range
int GetNumberOfPages() const { return toPage - fromPage + 1; }
int fromPage = 0;
int toPage = 0;
};
using wxPrintPageRanges = std::vector<wxPrintPageRange>;
/*
* wxPrintDialogData
* Encapsulates information displayed and edited in the printer dialog box.
* Contains a wxPrintData object which is filled in according to the values retrieved
* from the dialog.
*/
class WXDLLIMPEXP_CORE wxPrintDialogData: public wxObject
{
public:
wxPrintDialogData();
wxPrintDialogData(const wxPrintDialogData& dialogData) = default;
wxPrintDialogData(const wxPrintData& printData);
virtual ~wxPrintDialogData();
// These functions can be used only when printing all pages or a single
// continuous range of pages, use GetPageRanges() to support multiple
// ranges.
int GetFromPage() const;
int GetToPage() const;
int GetMinPage() const { return m_printMinPage; }
int GetMaxPage() const { return m_printMaxPage; }
int GetNoCopies() const { return m_printNoCopies; }
bool GetAllPages() const { return m_printWhat == Print::AllPages; }
bool GetSelection() const { return m_printWhat == Print::Selection; }
bool GetCurrentPage() const { return m_printWhat == Print::CurrentPage; }
bool GetSpecifiedPages() const { return m_printWhat == Print::SpecifiedPages; }
bool GetCollate() const { return m_printCollate; }
bool GetPrintToFile() const { return m_printToFile; }
// Similarly to the getters above, these functions can be used only to
// define a single continuous range of pages to print, use SetPageRanges()
// for anything else. Note that if you do use SetPageRanges() to specify
// multiple ranges, then these functions cannot be used.
void SetFromPage(int v);
void SetToPage(int v);
void SetMinPage(int v) { m_printMinPage = v; }
void SetMaxPage(int v) { m_printMaxPage = v; }
void SetNoCopies(int v) { m_printNoCopies = v; }
// Avoid calling these functions with flag == false as it's not really
// obvious what they do in this case.
void SetAllPages(bool flag = true) { DoSetWhat(Print::AllPages, flag); }
void SetSelection(bool flag = true) { DoSetWhat(Print::Selection, flag); }
void SetCurrentPage(bool flag = true) { DoSetWhat(Print::CurrentPage, flag); }
void SetCollate(bool flag) { m_printCollate = flag; }
void SetPrintToFile(bool flag) { m_printToFile = flag; }
void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }
void EnableSelection(bool flag) { m_printEnableSelection = flag; }
void EnableCurrentPage(bool flag) { m_printEnableCurrentPage = flag; }
void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }
void EnableHelp(bool flag) { m_printEnableHelp = flag; }
bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; }
bool GetEnableSelection() const { return m_printEnableSelection; }
bool GetEnableCurrentPage() const { return m_printEnableCurrentPage; }
bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }
bool GetEnableHelp() const { return m_printEnableHelp; }
// Is this data OK for showing the print dialog?
bool Ok() const { return IsOk(); }
bool IsOk() const { return m_printData.IsOk() ; }
wxPrintData& GetPrintData() { return m_printData; }
void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
void SetPageRanges(const wxPrintPageRanges& pageRanges) { m_printPageRanges = pageRanges; }
const wxPrintPageRanges& GetPageRanges() const { return m_printPageRanges; }
void SetMaxPageRanges(int maxPageRanges) { m_maxPageRanges = maxPageRanges; }
int GetMaxPageRanges() const { return m_maxPageRanges; }
wxPrintDialogData& operator=(const wxPrintDialogData& data) = default;
void operator=(const wxPrintData& data); // Sets internal m_printData member
private:
enum class Print
{
SpecifiedPages, // Default used if none of the other flags are selected.
AllPages,
Selection,
CurrentPage
};
void DoSetWhat(Print what, bool flag);
Print m_printWhat = Print::AllPages;
int m_printMinPage = 0;
int m_printMaxPage = 0;
int m_printNoCopies = 1;
bool m_printCollate = false;
bool m_printToFile = false;
bool m_printEnableSelection = false;
bool m_printEnableCurrentPage = false;
bool m_printEnablePageNumbers = true;
bool m_printEnableHelp = false;
bool m_printEnablePrintToFile = true;
wxPrintData m_printData;
// Maximum number of page ranges that the user can specify via the print dialog.
int m_maxPageRanges = 64;
// The page ranges to print. If this vector contains more then m_maxPageRanges
// elements, then the maximum number of page ranges that the user can specify
// via the print dialog is the size of this vector.
wxPrintPageRanges m_printPageRanges;
private:
wxDECLARE_DYNAMIC_CLASS(wxPrintDialogData);
};
/*
* This is the data used (and returned) by the wxPageSetupDialog.
*/
// Compatibility with old name
#define wxPageSetupData wxPageSetupDialogData
class WXDLLIMPEXP_CORE wxPageSetupDialogData: public wxObject
{
public:
wxPageSetupDialogData();
wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) = default;
wxPageSetupDialogData(const wxPrintData& printData);
wxSize GetPaperSize() const { return m_paperSize; }
wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); }
wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; }
wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; }
wxPoint GetMarginTopLeft() const { return m_marginTopLeft; }
wxPoint GetMarginBottomRight() const { return m_marginBottomRight; }
bool GetDefaultMinMargins() const { return m_defaultMinMargins; }
bool GetEnableMargins() const { return m_enableMargins; }
bool GetEnableOrientation() const { return m_enableOrientation; }
bool GetEnablePaper() const { return m_enablePaper; }
bool GetEnablePrinter() const { return m_enablePrinter; }
bool GetDefaultInfo() const { return m_getDefaultInfo; }
bool GetEnableHelp() const { return m_enableHelp; }
// Is this data OK for showing the page setup dialog?
bool Ok() const { return IsOk(); }
bool IsOk() const { return m_printData.IsOk() ; }
// If a corresponding paper type is found in the paper database, will set the m_printData
// paper size id member as well.
void SetPaperSize(const wxSize& sz);
void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); }
// Sets the wxPrintData id, plus the paper width/height if found in the paper database.
void SetPaperSize(wxPaperSize id);
void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; }
void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; }
void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; }
void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; }
void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; }
void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; }
void EnableMargins(bool flag) { m_enableMargins = flag; }
void EnableOrientation(bool flag) { m_enableOrientation = flag; }
void EnablePaper(bool flag) { m_enablePaper = flag; }
void EnablePrinter(bool flag) { m_enablePrinter = flag; }
void EnableHelp(bool flag) { m_enableHelp = flag; }
// Use paper size defined in this object to set the wxPrintData
// paper id
void CalculateIdFromPaperSize();
// Use paper id in wxPrintData to set this object's paper size
void CalculatePaperSizeFromId();
wxPageSetupDialogData& operator=(const wxPageSetupDialogData& data) = default;
wxPageSetupDialogData& operator=(const wxPrintData& data);
wxPrintData& GetPrintData() { return m_printData; }
const wxPrintData& GetPrintData() const { return m_printData; }
void SetPrintData(const wxPrintData& printData);
private:
wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
wxPoint m_minMarginTopLeft;
wxPoint m_minMarginBottomRight;
wxPoint m_marginTopLeft;
wxPoint m_marginBottomRight;
bool m_defaultMinMargins = false;
bool m_enableMargins = true;
bool m_enableOrientation = true;
bool m_enablePaper = true;
bool m_enablePrinter = true;
bool m_getDefaultInfo = false; // Equiv. to PSD_RETURNDEFAULT
bool m_enableHelp = false;
wxPrintData m_printData;
private:
wxDECLARE_DYNAMIC_CLASS(wxPageSetupDialogData);
};
#endif // wxUSE_PRINTING_ARCHITECTURE
#endif
// _WX_CMNDATA_H_BASE_

View File

@@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/collheaderctrl.h
// Purpose: wxCollapsibleHeaderCtrl
// Author: Tobias Taschner
// Created: 2015-09-19
// Copyright: (c) 2015 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLLAPSIBLEHEADER_CTRL_H_
#define _WX_COLLAPSIBLEHEADER_CTRL_H_
#include "wx/defs.h"
#if wxUSE_COLLPANE
#include "wx/control.h"
// class name
extern WXDLLIMPEXP_DATA_CORE(const char) wxCollapsibleHeaderCtrlNameStr[];
//
// wxGenericCollapsibleHeaderCtrl
//
class WXDLLIMPEXP_CORE wxCollapsibleHeaderCtrlBase : public wxControl
{
public:
wxCollapsibleHeaderCtrlBase() = default;
wxCollapsibleHeaderCtrlBase(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_NONE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCollapsibleHeaderCtrlNameStr))
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_NONE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCollapsibleHeaderCtrlNameStr))
{
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
SetLabel(label);
return true;
}
virtual void SetCollapsed(bool collapsed = true) = 0;
virtual bool IsCollapsed() const = 0;
private:
wxDECLARE_NO_COPY_CLASS(wxCollapsibleHeaderCtrlBase);
};
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COLLAPSIBLEHEADER_CHANGED, wxCommandEvent);
#define wxCollapsibleHeaderChangedHandler(func) \
wxEVENT_HANDLER_CAST(wxCommandEventFunction, func)
#define EVT_COLLAPSIBLEHEADER_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COLLAPSIBLEHEADER_CHANGED, id, wxCollapsibleHeaderChangedHandler(fn))
// Currently there is only the native implementation, use it for all ports.
#include "wx/generic/collheaderctrl.h"
class WXDLLIMPEXP_CORE wxCollapsibleHeaderCtrl
: public wxGenericCollapsibleHeaderCtrl
{
public:
wxCollapsibleHeaderCtrl() = default;
wxCollapsibleHeaderCtrl(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_NONE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCollapsibleHeaderCtrlNameStr))
{
Create(parent, id, label, pos, size, style, validator, name);
}
private:
wxDECLARE_NO_COPY_CLASS(wxCollapsibleHeaderCtrl);
};
#endif // wxUSE_COLLPANE
#endif // _WX_COLLAPSIBLEHEADER_CTRL_H_

View File

@@ -0,0 +1,124 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/collpane.h
// Purpose: wxCollapsiblePane
// Author: Francesco Montorsi
// Created: 8/10/2006
// Copyright: (c) Francesco Montorsi
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLLAPSABLE_PANE_H_BASE_
#define _WX_COLLAPSABLE_PANE_H_BASE_
#include "wx/defs.h"
#if wxUSE_COLLPANE
#include "wx/control.h"
// class name
extern WXDLLIMPEXP_DATA_CORE(const char) wxCollapsiblePaneNameStr[];
// ----------------------------------------------------------------------------
// wxCollapsiblePaneBase: interface for wxCollapsiblePane
// ----------------------------------------------------------------------------
#define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
#define wxCP_NO_TLW_RESIZE (0x0002)
class WXDLLIMPEXP_CORE wxCollapsiblePaneBase : public wxControl
{
public:
wxCollapsiblePaneBase() = default;
virtual void Collapse(bool collapse = true) = 0;
void Expand() { Collapse(false); }
virtual bool IsCollapsed() const = 0;
bool IsExpanded() const { return !IsCollapsed(); }
virtual wxWindow *GetPane() const = 0;
virtual wxString GetLabel() const override = 0;
virtual void SetLabel(const wxString& label) override = 0;
virtual bool
InformFirstDirection(int direction,
int size,
int availableOtherDir) override
{
wxWindow* const p = GetPane();
if ( !p )
return false;
if ( !p->InformFirstDirection(direction, size, availableOtherDir) )
return false;
InvalidateBestSize();
return true;
}
};
// ----------------------------------------------------------------------------
// event types and macros
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxCollapsiblePaneEvent;
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEvent );
class WXDLLIMPEXP_CORE wxCollapsiblePaneEvent : public wxCommandEvent
{
public:
wxCollapsiblePaneEvent() = default;
wxCollapsiblePaneEvent(wxObject *generator, int id, bool collapsed)
: wxCommandEvent(wxEVT_COLLAPSIBLEPANE_CHANGED, id),
m_bCollapsed(collapsed)
{
SetEventObject(generator);
}
bool GetCollapsed() const { return m_bCollapsed; }
void SetCollapsed(bool c) { m_bCollapsed = c; }
// default copy ctor, assignment operator and dtor are ok
wxNODISCARD virtual wxEvent *Clone() const override { return new wxCollapsiblePaneEvent(*this); }
private:
bool m_bCollapsed;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxCollapsiblePaneEvent);
};
// ----------------------------------------------------------------------------
// event types and macros
// ----------------------------------------------------------------------------
typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEvent&);
#define wxCollapsiblePaneEventHandler(func) \
wxEVENT_HANDLER_CAST(wxCollapsiblePaneEventFunction, func)
#define EVT_COLLAPSIBLEPANE_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COLLAPSIBLEPANE_CHANGED, id, wxCollapsiblePaneEventHandler(fn))
#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/collpane.h"
#else
#include "wx/generic/collpaneg.h"
// use #define and not a typedef to allow forward declaring the class
#define wxCollapsiblePane wxGenericCollapsiblePane
#endif
// old wxEVT_COMMAND_* constant
#define wxEVT_COMMAND_COLLPANE_CHANGED wxEVT_COLLAPSIBLEPANE_CHANGED
#endif // wxUSE_COLLPANE
#endif // _WX_COLLAPSABLE_PANE_H_BASE_

View File

@@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/colordlg.h
// Purpose: wxColourDialog
// Author: Vadim Zeitlin
// Created: 01/02/97
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLORDLG_H_BASE_
#define _WX_COLORDLG_H_BASE_
#include "wx/defs.h"
#if wxUSE_COLOURDLG
#include "wx/colourdata.h"
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/colordlg.h"
#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
#include "wx/osx/colordlg.h"
#elif defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/colordlg.h"
#elif defined(__WXQT__)
#include "wx/qt/colordlg.h"
#else
#include "wx/generic/colrdlgg.h"
#define wxColourDialog wxGenericColourDialog
#endif
// Under some platforms (currently only wxMSW) wxColourDialog can send events
// of this type while it is shown.
//
// Notice that this class is almost identical to wxColourPickerEvent but it
// doesn't really sense to reuse the same class for both controls.
class WXDLLIMPEXP_CORE wxColourDialogEvent : public wxCommandEvent
{
public:
wxColourDialogEvent()
{
}
wxColourDialogEvent(wxEventType evtType,
wxColourDialog* dialog,
const wxColour& colour)
: wxCommandEvent(evtType, dialog->GetId()),
m_colour(colour)
{
SetEventObject(dialog);
}
// default copy ctor and dtor are ok
wxColour GetColour() const { return m_colour; }
void SetColour(const wxColour& colour) { m_colour = colour; }
wxNODISCARD virtual wxEvent *Clone() const override
{
return new wxColourDialogEvent(*this);
}
private:
wxColour m_colour;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxColourDialogEvent);
};
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COLOUR_CHANGED, wxColourDialogEvent);
#define wxColourDialogEventHandler(func) \
wxEVENT_HANDLER_CAST(wxColourDialogEventFunction, func)
#define EVT_COLOUR_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_COLOUR_CHANGED, id, wxColourDialogEventHandler(fn))
// get the colour from user and return it
WXDLLIMPEXP_CORE wxColour wxGetColourFromUser(wxWindow *parent = nullptr,
const wxColour& colInit = wxNullColour,
const wxString& caption = wxEmptyString,
wxColourData *data = nullptr);
#endif // wxUSE_COLOURDLG
#endif
// _WX_COLORDLG_H_BASE_

View File

@@ -0,0 +1,247 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/colour.h
// Purpose: wxColourBase definition
// Author: Julian Smart
// Modified by: Francesco Montorsi
// Created:
// Copyright: Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLOUR_H_BASE_
#define _WX_COLOUR_H_BASE_
#include "wx/defs.h"
#include "wx/gdiobj.h"
#include "wx/variant.h"
class WXDLLIMPEXP_FWD_CORE wxColour;
// A macro to define the standard wxColour constructors:
//
// It avoids the need to repeat these lines across all colour.h files, since
// Set() is a virtual function and thus cannot be called by wxColourBase ctors
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
#define wxWXCOLOUR_CTOR_FROM_CHAR \
wxColour(const char *colourName) { Init(); Set(colourName); }
#else // wxNO_IMPLICIT_WXSTRING_ENCODING
#define wxWXCOLOUR_CTOR_FROM_CHAR
#endif
#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
wxColour() { Init(); } \
wxColour(ChannelType red, \
ChannelType green, \
ChannelType blue, \
ChannelType alpha = wxALPHA_OPAQUE) \
{ Init(); Set(red, green, blue, alpha); } \
wxColour(unsigned long colRGB) { Init(); Set(colRGB ); } \
wxColour(const wxString& colourName) { Init(); Set(colourName); } \
wxWXCOLOUR_CTOR_FROM_CHAR \
wxColour(const wchar_t *colourName) { Init(); Set(colourName); }
// flags for wxColour -> wxString conversion (see wxColour::GetAsString)
enum {
wxC2S_NAME = 1, // return colour name, when possible
wxC2S_CSS_SYNTAX = 2, // return colour in rgb(r,g,b) syntax
wxC2S_HTML_SYNTAX = 4 // return colour in #rrggbb syntax
};
const unsigned char wxALPHA_TRANSPARENT = 0;
const unsigned char wxALPHA_OPAQUE = 0xff;
// a valid but fully transparent colour
#define wxTransparentColour wxColour(0, 0, 0, wxALPHA_TRANSPARENT)
#define wxTransparentColor wxTransparentColour
//-----------------------------------------------------------------------------
// wxColourBase: this class has no data members, just some functions to avoid
// code redundancy in all native wxColour implementations
//-----------------------------------------------------------------------------
/* Transition from wxGDIObject to wxObject is incomplete. If your port does
not need the wxGDIObject machinery to handle colors, please add it to the
list of ports which do not need it.
*/
#if defined( __WXMSW__ ) || defined( __WXQT__ )
#define wxCOLOUR_IS_GDIOBJECT 0
#else
#define wxCOLOUR_IS_GDIOBJECT 1
#endif
class WXDLLIMPEXP_CORE wxColourBase : public
#if wxCOLOUR_IS_GDIOBJECT
wxGDIObject
#else
wxObject
#endif
{
public:
// type of a single colour component
typedef unsigned char ChannelType;
wxColourBase() = default;
virtual ~wxColourBase() = default;
// Set() functions
// ---------------
void Set(ChannelType red,
ChannelType green,
ChannelType blue,
ChannelType alpha = wxALPHA_OPAQUE)
{ InitRGBA(red, green, blue, alpha); }
// implemented in colourcmn.cpp
bool Set(const wxString &str)
{ return FromString(str); }
void Set(unsigned long colRGB)
{
// we don't need to know sizeof(long) here because we assume that the three
// least significant bytes contain the R, G and B values
Set((ChannelType)(0xFF & colRGB),
(ChannelType)(0xFF & (colRGB >> 8)),
(ChannelType)(0xFF & (colRGB >> 16)));
}
// accessors
// ---------
virtual ChannelType Red() const = 0;
virtual ChannelType Green() const = 0;
virtual ChannelType Blue() const = 0;
virtual ChannelType Alpha() const
{ return wxALPHA_OPAQUE ; }
// These getters return the values as unsigned int, which avoids promoting
// them to (signed) int in arithmetic expressions, unlike the ones above.
unsigned int GetRed() const { return Red(); }
unsigned int GetGreen() const { return Green(); }
unsigned int GetBlue() const { return Blue(); }
unsigned int GetAlpha() const { return Alpha(); }
virtual bool IsSolid() const
{ return true; }
bool IsTransparent() const
{ return GetAlpha() == wxALPHA_TRANSPARENT; }
bool IsOpaque() const
{ return GetAlpha() == wxALPHA_OPAQUE; }
bool IsTranslucent() const
{ return GetAlpha() > wxALPHA_TRANSPARENT && GetAlpha() < wxALPHA_OPAQUE; }
// implemented in colourcmn.cpp
virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const;
void SetRGB(wxUint32 colRGB)
{
Set((ChannelType)(0xFF & colRGB),
(ChannelType)(0xFF & (colRGB >> 8)),
(ChannelType)(0xFF & (colRGB >> 16)));
}
void SetRGBA(wxUint32 colRGBA)
{
Set((ChannelType)(0xFF & colRGBA),
(ChannelType)(0xFF & (colRGBA >> 8)),
(ChannelType)(0xFF & (colRGBA >> 16)),
(ChannelType)(0xFF & (colRGBA >> 24)));
}
wxUint32 GetRGB() const
{ return GetRed() | (GetGreen() << 8) | (GetBlue() << 16); }
wxUint32 GetRGBA() const
{ return GetRed() | (GetGreen() << 8) | (GetBlue() << 16) | (GetAlpha() << 24); }
#if !wxCOLOUR_IS_GDIOBJECT
virtual bool IsOk() const= 0;
// older version, for backwards compatibility only (but not deprecated
// because it's still widely used)
bool Ok() const { return IsOk(); }
#endif
// Return the perceived brightness of the colour, with 0 for black and 1
// for white.
double GetLuminance() const;
// manipulation
// ------------
// These methods are static because they are mostly used
// within tight loops (where we don't want to instantiate wxColour's)
static void MakeMono (unsigned char* r, unsigned char* g, unsigned char* b, bool on);
static void MakeDisabled(unsigned char* r, unsigned char* g, unsigned char* b, unsigned char brightness = 255);
static void MakeGrey (unsigned char* r, unsigned char* g, unsigned char* b); // integer version
static void MakeGrey (unsigned char* r, unsigned char* g, unsigned char* b,
double weight_r, double weight_g, double weight_b); // floating point version
static unsigned char AlphaBlend (unsigned char fg, unsigned char bg, double alpha);
static void ChangeLightness(unsigned char* r, unsigned char* g, unsigned char* b, int ialpha);
wxColour ChangeLightness(int ialpha) const;
wxColour& MakeDisabled(unsigned char brightness = 255);
wxDECLARE_VARIANT_OBJECT_EXPORTED(wxColour, WXDLLIMPEXP_CORE);
protected:
// Some ports need Init() and while we don't, provide a stub so that the
// ports which don't need it are not forced to define it
void Init() { }
virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;
virtual bool FromString(const wxString& s);
#if wxCOLOUR_IS_GDIOBJECT
// wxColour doesn't use reference counted data (at least not in all ports)
// so provide stubs for the functions which need to be defined if we do use
// them
virtual wxGDIRefData *CreateGDIRefData() const override
{
wxFAIL_MSG( "must be overridden if used" );
return nullptr;
}
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *WXUNUSED(data)) const override
{
wxFAIL_MSG( "must be overridden if used" );
return nullptr;
}
#endif
};
// wxColour <-> wxString utilities, used by wxConfig, defined in colourcmn.cpp
WXDLLIMPEXP_CORE wxString wxToString(const wxColourBase& col);
WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxColourBase* col);
#if defined(__WXMSW__)
#include "wx/msw/colour.h"
#elif defined(__WXGTK__)
#include "wx/gtk/colour.h"
#elif defined(__WXDFB__)
#include "wx/generic/colour.h"
#elif defined(__WXX11__)
#include "wx/x11/colour.h"
#elif defined(__WXMAC__)
#include "wx/osx/colour.h"
#elif defined(__WXQT__)
#include "wx/qt/colour.h"
#endif
#define wxColor wxColour
#endif // _WX_COLOUR_H_BASE_

View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/colourdata.h
// Author: Julian Smart
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLOURDATA_H_
#define _WX_COLOURDATA_H_
#include "wx/colour.h"
class WXDLLIMPEXP_CORE wxColourData : public wxObject
{
public:
// number of custom colours we store
enum
{
NUM_CUSTOM = 16
};
wxColourData();
wxColourData(const wxColourData& data);
wxColourData& operator=(const wxColourData& data);
virtual ~wxColourData();
void SetChooseFull(bool flag) { m_chooseFull = flag; }
bool GetChooseFull() const { return m_chooseFull; }
void SetChooseAlpha(bool flag) { m_chooseAlpha = flag; }
bool GetChooseAlpha() const { return m_chooseAlpha; }
void SetColour(const wxColour& colour) { m_dataColour = colour; }
const wxColour& GetColour() const { return m_dataColour; }
wxColour& GetColour() { return m_dataColour; }
// SetCustomColour() modifies colours in an internal array of NUM_CUSTOM
// custom colours;
void SetCustomColour(int i, const wxColour& colour);
wxColour GetCustomColour(int i) const;
// Serialize the object to a string and restore it from it
wxString ToString() const;
bool FromString(const wxString& str);
// public for backwards compatibility only: don't use directly
wxColour m_dataColour;
wxColour m_custColours[NUM_CUSTOM];
bool m_chooseFull;
protected:
bool m_chooseAlpha;
wxDECLARE_DYNAMIC_CLASS(wxColourData);
};
#endif // _WX_COLOURDATA_H_

View File

@@ -0,0 +1,879 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/combo.h
// Purpose: wxComboCtrl declaration
// Author: Jaakko Salli
// Created: Apr-30-2006
// Copyright: (c) Jaakko Salli
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOCONTROL_H_BASE_
#define _WX_COMBOCONTROL_H_BASE_
/*
A few words about all the classes defined in this file are probably in
order: why do we need extra wxComboCtrl and wxComboPopup classes?
This is because a traditional combobox is a combination of a text control
(with a button allowing to open the pop down list) with a listbox and
wxComboBox class is exactly such control, however we want to also have other
combinations - in fact, we want to allow anything at all to be used as pop
down list, not just a wxListBox.
So we define a base wxComboCtrl which can use any control as pop down
list and wxComboBox deriving from it which implements the standard wxWidgets
combobox API. wxComboCtrl needs to be told somehow which control to use
and this is done by SetPopupControl(). However, we need something more than
just a wxControl in this method as, for example, we need to call
SetSelection("initial text value") and wxControl doesn't have such method.
So we also need a wxComboPopup which is just a very simple interface which
must be implemented by a control to be usable as a popup.
We couldn't derive wxComboPopup from wxControl as this would make it
impossible to have a class deriving from both wxListBx and from it, so
instead it is just a mix-in.
*/
#include "wx/defs.h"
#if wxUSE_COMBOCTRL
#include "wx/control.h"
#include "wx/renderer.h" // this is needed for wxCONTROL_XXX flags
#include "wx/bmpbndl.h"
#include "wx/textentry.h"
#include "wx/time.h" // needed for wxMilliClock_t
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_CORE wxComboPopup;
//
// New window styles for wxComboCtrlBase
//
enum
{
// Double-clicking a read-only combo triggers call to popup's OnComboPopup.
// In wxOwnerDrawnComboBox, for instance, it cycles item.
wxCC_SPECIAL_DCLICK = 0x0100,
// Dropbutton acts like standard push button.
wxCC_STD_BUTTON = 0x0200
};
// wxComboCtrl internal flags
enum
{
// First those that can be passed to Customize.
// It is Windows style for all flags to be clear.
// Button is preferred outside the border (GTK style)
wxCC_BUTTON_OUTSIDE_BORDER = 0x0001,
// Show popup on mouse up instead of mouse down (which is the Windows style)
wxCC_POPUP_ON_MOUSE_UP = 0x0002,
// All text is not automatically selected on click
wxCC_NO_TEXT_AUTO_SELECT = 0x0004,
// Drop-button stays down as long as popup is displayed.
wxCC_BUTTON_STAYS_DOWN = 0x0008,
// Drop-button covers the entire control.
wxCC_FULL_BUTTON = 0x0010,
// Drop-button goes over the custom-border (used under Windows).
wxCC_BUTTON_COVERS_BORDER = 0x0020,
// Internal use: signals creation is complete
wxCC_IFLAG_CREATED = 0x0100,
// Internal use: really put button outside
wxCC_IFLAG_BUTTON_OUTSIDE = 0x0200,
// Internal use: SetMargins has been successfully called
wxCC_IFLAG_LEFT_MARGIN_SET = 0x0400,
// Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed
wxCC_IFLAG_PARENT_TAB_TRAVERSAL = 0x0800,
// Internal use: Secondary popup window type should be used (if available).
wxCC_IFLAG_USE_ALT_POPUP = 0x1000,
// Internal use: Skip popup animation.
wxCC_IFLAG_DISABLE_POPUP_ANIM = 0x2000,
// Internal use: Drop-button is a bitmap button or has non-default size
// (but can still be on either side of the control), regardless whether
// specified by the platform or the application.
wxCC_IFLAG_HAS_NONSTANDARD_BUTTON = 0x4000
};
// Flags used by PreprocessMouseEvent and HandleButtonMouseEvent
enum
{
wxCC_MF_ON_BUTTON = 0x0001, // cursor is on dropbutton area
wxCC_MF_ON_CLICK_AREA = 0x0002 // cursor is on dropbutton or other area
// that can be clicked to show the popup.
};
// Namespace for wxComboCtrl feature flags
struct wxComboCtrlFeatures
{
enum
{
MovableButton = 0x0001, // Button can be on either side of control
BitmapButton = 0x0002, // Button may be replaced with bitmap
ButtonSpacing = 0x0004, // Button can have spacing from the edge
// of the control
TextIndent = 0x0008, // SetMargins can be used to control
// left margin.
PaintControl = 0x0010, // Combo control itself can be custom painted
PaintWritable = 0x0020, // A variable-width area in front of writable
// combo control's textctrl can be custom
// painted
Borderless = 0x0040, // wxNO_BORDER window style works
// There are no feature flags for...
// PushButtonBitmapBackground - if its in wxRendererNative, then it should be
// not an issue to have it automatically under the bitmap.
All = MovableButton|BitmapButton|
ButtonSpacing|TextIndent|
PaintControl|PaintWritable|
Borderless
};
};
class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxControl,
public wxTextEntry
{
friend class wxComboPopup;
friend class wxComboPopupEvtHandler;
public:
// ctors and such
wxComboCtrlBase() : wxControl(), wxTextEntry() { Init(); }
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name);
virtual ~wxComboCtrlBase();
// Show/hide popup window (wxComboBox-compatible methods)
virtual void Popup();
virtual void Dismiss()
{
HidePopup(true);
}
// Show/hide popup window.
// TODO: Maybe deprecate in favor of Popup()/Dismiss().
// However, these functions are still called internally
// so it is not straightforward.
virtual void ShowPopup();
virtual void HidePopup(bool generateEvent=false);
// Override for totally custom combo action
virtual void OnButtonClick();
// return true if the popup is currently shown
bool IsPopupShown() const { return m_popupWinState == Visible; }
// set interface class instance derived from wxComboPopup
// null popup can be used to indicate default in a derived class
void SetPopupControl( wxComboPopup* popup )
{
DoSetPopupControl(popup);
}
// get interface class instance derived from wxComboPopup
wxComboPopup* GetPopupControl()
{
EnsurePopupControl();
return m_popupInterface;
}
// get the popup window containing the popup control
wxWindow *GetPopupWindow() const { return m_winPopup; }
// Set the control to use instead of the default text control for the main
// (always visible) part of the combobox.
void SetMainControl(wxWindow* win);
// Get the text control which is part of the combobox.
wxTextCtrl *GetTextCtrl() const { return m_text; }
// get the dropdown button which is part of the combobox
// note: its not necessarily a wxButton or wxBitmapButton
wxWindow *GetButton() const { return m_btn; }
// forward these methods to all subcontrols
virtual bool Enable(bool enable = true) override;
virtual bool Show(bool show = true) override;
virtual bool SetFont(const wxFont& font) override;
//
// wxTextEntry methods
//
// NB: We basically need to override all of them because there is
// no guarantee how platform-specific wxTextEntry is implemented.
//
virtual void SetValue(const wxString& value) override
{ wxTextEntryBase::SetValue(value); }
virtual void ChangeValue(const wxString& value) override
{ wxTextEntryBase::ChangeValue(value); }
virtual void WriteText(const wxString& text) override;
virtual void AppendText(const wxString& text) override
{ wxTextEntryBase::AppendText(text); }
virtual wxString GetValue() const override
{ return wxTextEntryBase::GetValue(); }
virtual wxString GetRange(long from, long to) const override
{ return wxTextEntryBase::GetRange(from, to); }
// Replace() and DoSetValue() need to be fully re-implemented since
// EventSuppressor utility class does not work with the way
// wxComboCtrl is implemented.
virtual void Replace(long from, long to, const wxString& value) override;
virtual void Remove(long from, long to) override;
virtual void Copy() override;
virtual void Cut() override;
virtual void Paste() override;
virtual void Undo() override;
virtual void Redo() override;
virtual bool CanUndo() const override;
virtual bool CanRedo() const override;
virtual void SetInsertionPoint(long pos) override;
virtual long GetInsertionPoint() const override;
virtual long GetLastPosition() const override;
virtual void SetSelection(long from, long to) override;
virtual void GetSelection(long *from, long *to) const override;
virtual bool IsEditable() const override;
virtual void SetEditable(bool editable) override;
virtual bool SetHint(const wxString& hint) override;
virtual wxString GetHint() const override;
// This method sets the text without affecting list selection
// (ie. wxComboPopup::SetStringValue doesn't get called).
void SetText(const wxString& value);
// This method sets value and also optionally sends EVT_TEXT
// (needed by combo popups)
wxDEPRECATED( void SetValueWithEvent(const wxString& value,
bool withEvent = true) );
// Changes value of the control as if user had done it by selecting an
// item from a combo box drop-down list. Needs to be public so that
// derived popup classes can call it.
void SetValueByUser(const wxString& value);
//
// Popup customization methods
//
// Sets minimum width of the popup. If wider than combo control, it will extend to the left.
// Remarks:
// * Value -1 indicates the default.
// * Custom popup may choose to ignore this (wxOwnerDrawnComboBox does not).
void SetPopupMinWidth( int width )
{
m_widthMinPopup = width;
}
// Sets preferred maximum height of the popup.
// Remarks:
// * Value -1 indicates the default.
// * Custom popup may choose to ignore this (wxOwnerDrawnComboBox does not).
void SetPopupMaxHeight( int height )
{
m_heightPopup = height;
}
// Extends popup size horizontally, relative to the edges of the combo control.
// Remarks:
// * Popup minimum width may override extLeft (ie. it has higher precedence).
// * Values 0 indicate default.
// * Custom popup may not take this fully into account (wxOwnerDrawnComboBox takes).
void SetPopupExtents( int extLeft, int extRight )
{
m_extLeft = extLeft;
m_extRight = extRight;
}
// Set width, in pixels, of custom paint area in writable combo.
// In read-only, used to indicate area that is not covered by the
// focus rectangle (which may or may not be drawn, depending on the
// popup type).
void SetCustomPaintWidth( int width );
int GetCustomPaintWidth() const { return m_widthCustomPaint; }
// Set side of the control to which the popup will align itself.
// Valid values are wxLEFT, wxRIGHT and 0. The default value 0 wmeans
// that the side of the button will be used.
void SetPopupAnchor( int anchorSide )
{
m_anchorSide = anchorSide;
}
// Set position of dropdown button.
// width: button width. <= 0 for default.
// height: button height. <= 0 for default.
// side: wxLEFT or wxRIGHT, indicates on which side the button will be placed.
// spacingX: empty space on sides of the button. Default is 0.
// Remarks:
// There is no spacingY - the button will be centred vertically.
void SetButtonPosition( int width = -1,
int height = -1,
int side = wxRIGHT,
int spacingX = 0 );
// Returns current size of the dropdown button.
wxSize GetButtonSize();
//
// Sets dropbutton to be drawn with custom bitmaps.
//
// bmpNormal: drawn when cursor is not on button
// pushButtonBg: Draw push button background below the image.
// NOTE! This is usually only properly supported on platforms with appropriate
// method in wxRendererNative.
// bmpPressed: drawn when button is depressed
// bmpHover: drawn when cursor hovers on button. This is ignored on platforms
// that do not generally display hover differently.
// bmpDisabled: drawn when combobox is disabled.
void SetButtonBitmaps( const wxBitmapBundle& bmpNormal,
bool pushButtonBg = false,
const wxBitmapBundle& bmpPressed = wxBitmapBundle(),
const wxBitmapBundle& bmpHover = wxBitmapBundle(),
const wxBitmapBundle& bmpDisabled = wxBitmapBundle() );
// Returns area covered by the text field.
const wxRect& GetTextRect() const
{
return m_tcArea;
}
// Call with enable as true to use a type of popup window that guarantees ability
// to focus the popup control, and normal function of common native controls.
// This alternative popup window is usually a wxDialog, and as such its parent
// frame will appear as if the focus has been lost from it.
void UseAltPopupWindow( bool enable = true )
{
wxASSERT_MSG( !m_winPopup,
wxT("call this only before SetPopupControl") );
if ( enable )
m_iFlags |= wxCC_IFLAG_USE_ALT_POPUP;
else
m_iFlags &= ~wxCC_IFLAG_USE_ALT_POPUP;
}
// Call with false to disable popup animation, if any.
void EnablePopupAnimation( bool enable = true )
{
if ( enable )
m_iFlags &= ~wxCC_IFLAG_DISABLE_POPUP_ANIM;
else
m_iFlags |= wxCC_IFLAG_DISABLE_POPUP_ANIM;
}
//
// Utilities needed by the popups or native implementations
//
// Returns true if given key combination should toggle the popup.
// NB: This is a separate from other keyboard handling because:
// 1) Replaceability.
// 2) Centralized code (otherwise it'd be split up between
// wxComboCtrl key handler and wxVListBoxComboPopup's
// key handler).
virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const = 0;
// Prepare background of combo control or an item in a dropdown list
// in a way typical on platform. This includes painting the focus/disabled
// background and setting the clipping region.
// Unless you plan to paint your own focus indicator, you should always call this
// in your wxComboPopup::PaintComboControl implementation.
// In addition, it sets pen and text colour to what looks good and proper
// against the background.
// flags: wxRendererNative flags: wxCONTROL_ISSUBMENU: is drawing a list item instead of combo control
// wxCONTROL_SELECTED: list item is selected
// wxCONTROL_DISABLED: control/item is disabled
virtual void PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const;
// Returns true if focus indicator should be drawn in the control.
bool ShouldDrawFocus() const
{
const wxWindow* curFocus = FindFocus();
return ( IsPopupWindowState(Hidden) &&
(curFocus == m_mainCtrlWnd || (m_btn && curFocus == m_btn)) &&
(m_windowStyle & wxCB_READONLY) );
}
// These methods return appropriate dropbutton bitmaps
wxBitmap GetBitmapNormal() const { return m_bmpNormal.GetBitmapFor(this); }
wxBitmap GetBitmapPressed() const { return m_bmpPressed.GetBitmapFor(this); }
wxBitmap GetBitmapHover() const { return m_bmpHover.GetBitmapFor(this); }
wxBitmap GetBitmapDisabled() const { return m_bmpDisabled.GetBitmapFor(this); }
// Set custom style flags for embedded wxTextCtrl. Usually must be used
// with two-step creation, before Create() call.
void SetTextCtrlStyle( int style );
// Return internal flags
wxUint32 GetInternalFlags() const { return m_iFlags; }
// Return true if Create has finished
bool IsCreated() const { return m_iFlags & wxCC_IFLAG_CREATED ? true : false; }
// common code to be called on popup hide/dismiss
void OnPopupDismiss(bool generateEvent);
// called if popup is destroyed not by wxComboCtrl itself
void OnPopupDestroy();
// PopupShown states
enum
{
Hidden = 0,
Closing = 1,
Animating = 2,
Visible = 3
};
bool IsPopupWindowState( int state ) const { return (state == m_popupWinState) ? true : false; }
wxByte GetPopupWindowState() const { return m_popupWinState; }
// Set value returned by GetMainWindowOfCompositeControl
void SetCtrlMainWnd( wxWindow* wnd ) { m_mainCtrlWnd = wnd; }
// This is public so we can access it from wxComboCtrlTextCtrl
virtual wxWindow *GetMainWindowOfCompositeControl() override
{ return m_mainCtrlWnd; }
// also set the embedded wxTextCtrl colours
virtual bool SetForegroundColour(const wxColour& colour) override;
virtual bool SetBackgroundColour(const wxColour& colour) override;
protected:
// Returns true if hint text should be drawn in the control
bool ShouldUseHintText(int flags = 0) const
{
return ( !m_text &&
!(flags & wxCONTROL_ISSUBMENU) &&
m_valueString.empty() &&
!m_hintText.empty() &&
!ShouldDrawFocus() );
}
//
// Override these for customization purposes
//
// called from wxSizeEvent handler
virtual void OnResize() = 0;
// Return native text indentation
// (i.e. text margin, for pure text, not textctrl)
virtual wxCoord GetNativeTextIndent() const;
// Called in syscolourchanged handler and base create
virtual void OnThemeChange();
// Creates wxTextCtrl.
// extraStyle: Extra style parameters
void CreateTextCtrl( int extraStyle );
// Called when text was changed programmatically
// (e.g. from WriteText())
void OnSetValue(const wxString& value);
// Flags for DrawButton
enum
{
Button_PaintBackground = 0x0001, // Paints control background below the button
Button_BitmapOnly = 0x0002 // Only paints the bitmap
};
// Draws dropbutton. Using wxRenderer or bitmaps, as appropriate.
// Flags are defined above.
virtual void DrawButton( wxDC& dc, const wxRect& rect, int flags = Button_PaintBackground );
// Call if cursor is on button area or mouse is captured for the button.
//bool HandleButtonMouseEvent( wxMouseEvent& event, bool isInside );
bool HandleButtonMouseEvent( wxMouseEvent& event, int flags );
// returns true if event was consumed or filtered (event type is also set to 0 in this case)
bool PreprocessMouseEvent( wxMouseEvent& event, int flags );
//
// This will handle left_down and left_dclick events outside button in a Windows-like manner.
// If you need alternate behaviour, it is recommended you manipulate and filter events to it
// instead of building your own handling routine (for reference, on wxEVT_LEFT_DOWN it will
// toggle popup and on wxEVT_LEFT_DCLICK it will do the same or run the popup's dclick method,
// if defined - you should pass events of other types of it for common processing).
void HandleNormalMouseEvent( wxMouseEvent& event );
// Creates popup window, calls interface->Create(), etc
void CreatePopup();
// Destroy popup window and all related constructs
void DestroyPopup();
// override the base class virtuals involved in geometry calculations
// The common version only sets a default width, so the derived classes
// should override it and set the height and change the width as needed.
virtual wxSize DoGetBestSize() const override;
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const override;
// null popup can be used to indicate default in a derived class
virtual void DoSetPopupControl(wxComboPopup* popup);
// ensures there is at least the default popup
void EnsurePopupControl();
// Recalculates button and textctrl areas. Called when size or button setup change.
// btnWidth: default/calculated width of the dropbutton. 0 means unchanged,
// just recalculate.
void CalculateAreas( int btnWidth = 0 );
// Standard textctrl positioning routine. Just give it platform-dependent
// textctrl coordinate adjustment.
virtual void PositionTextCtrl( int textCtrlXAdjust = 0,
int textCtrlYAdjust = 0);
// event handlers
void OnSizeEvent( wxSizeEvent& event );
void OnFocusEvent(wxFocusEvent& event);
void OnIdleEvent(wxIdleEvent& event);
void OnTextCtrlEvent(wxCommandEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnKeyEvent(wxKeyEvent& event);
void OnCharEvent(wxKeyEvent& event);
void OnTextFocus(wxFocusEvent& event);
void OnTextKey(wxKeyEvent& event);
void OnPopupActivate(wxActivateEvent& event);
void OnPopupKey(wxKeyEvent& event);
void OnPopupSize(wxSizeEvent& event);
void OnPopupMouseEvent(wxMouseEvent& event);
// This function can be used as event handle for wxEVT_DPI_CHANGED event
// and simply recalculates button size when it happens.
void WXHandleDPIChanged(wxDPIChangedEvent& event);
// Set customization flags (directs how wxComboCtrlBase helpers behave)
void Customize( wxUint32 flags ) { m_iFlags |= flags; }
// Dispatches size event and refreshes
void RecalcAndRefresh();
// Flags for DoShowPopup and AnimateShow
enum
{
ShowBelow = 0x0000, // Showing popup below the control
ShowAbove = 0x0001, // Showing popup above the control
CanDeferShow = 0x0002 // Can only return true from AnimateShow if this is set
};
// Shows and positions the popup.
virtual void DoShowPopup( const wxRect& rect, int flags );
// Implement in derived class to create a drop-down animation.
// Return true if finished immediately. Otherwise popup is only
// shown when the derived class call DoShowPopup.
// Flags are same as for DoShowPopup.
virtual bool AnimateShow( const wxRect& rect, int flags );
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip ) override;
#endif
// protected wxTextEntry methods
virtual void DoSetValue(const wxString& value, int flags) override;
virtual wxString DoGetValue() const override;
virtual wxWindow *GetEditableWindow() override { return this; }
// margins functions
virtual bool DoSetMargins(const wxPoint& pt) override;
virtual wxPoint DoGetMargins() const override;
// This is used when m_text is hidden (readonly).
wxString m_valueString;
// This is used when control is unfocused and m_valueString is empty
wxString m_hintText;
// This pointer is non-null if we use a text control, and not some other
// window, as the main control.
wxTextCtrl* m_text;
// the window and button we show all the time
wxWindow* m_mainWindow;
wxWindow* m_btn;
// wxPopupWindow or similar containing the window managed by the interface.
wxWindow* m_winPopup;
// the popup control/panel
wxWindow* m_popup;
// popup interface
wxComboPopup* m_popupInterface;
// this is for the top level window
wxEvtHandler* m_toplevEvtHandler;
// main (ie. topmost) window of a composite control (default = this)
wxWindow* m_mainCtrlWnd;
// used to prevent immediate re-popupping in case closed popup
// by clicking on the combo control (needed because of inconsistent
// transient implementation across platforms).
wxMilliClock_t m_timeCanAcceptClick;
// how much popup should expand to the left/right of the control
wxCoord m_extLeft;
wxCoord m_extRight;
// minimum popup width
wxCoord m_widthMinPopup;
// preferred popup height
wxCoord m_heightPopup;
// how much of writable combo is custom-paint by callback?
// also used to indicate area that is not covered by "blue"
// selection indicator.
wxCoord m_widthCustomPaint;
// left margin, in pixels
wxCoord m_marginLeft;
// side on which the popup is aligned
int m_anchorSide;
// Width of the "fake" border
wxCoord m_widthCustomBorder;
// The button and textctrl click/paint areas
wxRect m_tcArea;
wxRect m_btnArea;
// Colour of the text area, in case m_text is null
wxColour m_tcBgCol;
// current button state (uses renderer flags)
int m_btnState;
// button position
int m_btnWid;
int m_btnHei;
int m_btnSide;
int m_btnSpacingX;
// last default button width
int m_btnWidDefault;
// custom dropbutton bitmaps
wxBitmapBundle m_bmpNormal;
wxBitmapBundle m_bmpPressed;
wxBitmapBundle m_bmpHover;
wxBitmapBundle m_bmpDisabled;
// area used by the button
wxSize m_btnSize;
// platform-dependent customization and other flags
wxUint32 m_iFlags;
// custom style for m_text
int m_textCtrlStyle;
// draw blank button background under bitmap?
bool m_blankButtonBg;
// is the popup window currently shown?
wxByte m_popupWinState;
// should the focus be reset to the textctrl in idle time?
bool m_resetFocus;
// is the text-area background colour overridden?
bool m_hasTcBgCol;
// flags used while popup is shown
bool m_beenInsidePopup;
bool m_blockEventsToPopup;
private:
void Init();
wxByte m_ignoreEvtText; // Number of next EVT_TEXTs to ignore
wxDECLARE_EVENT_TABLE();
wxDECLARE_ABSTRACT_CLASS(wxComboCtrlBase);
};
// ----------------------------------------------------------------------------
// wxComboPopup is the interface which must be implemented by a control to be
// used as a popup by wxComboCtrl
// ----------------------------------------------------------------------------
// wxComboPopup internal flags
enum
{
wxCP_IFLAG_CREATED = 0x0001 // Set by wxComboCtrlBase after Create is called
};
class WXDLLIMPEXP_FWD_CORE wxComboCtrl;
class WXDLLIMPEXP_CORE wxComboPopup
{
friend class wxComboCtrlBase;
public:
wxComboPopup()
{
m_combo = nullptr;
m_iFlags = 0;
}
// This is called immediately after construction finishes. m_combo member
// variable has been initialized before the call.
// NOTE: It is not in constructor so the derived class doesn't need to redefine
// a default constructor of its own.
virtual void Init() { }
virtual ~wxComboPopup();
// Create the popup child control.
// Return true for success.
virtual bool Create(wxWindow* parent) = 0;
// Calls Destroy() for the popup control (i.e. one returned by
// GetControl()) and makes sure that 'this' is deleted at the end.
// Default implementation works for both cases where popup control
// class is multiple inherited or created on heap as a separate
// object.
virtual void DestroyPopup();
// We must have an associated control which is subclassed by the combobox.
virtual wxWindow *GetControl() = 0;
// Called immediately after the popup is shown
virtual void OnPopup();
// Called when popup is dismissed
virtual void OnDismiss();
// Called just prior to displaying popup.
// Default implementation does nothing.
virtual void SetStringValue( const wxString& value );
// Gets displayed string representation of the value.
virtual wxString GetStringValue() const = 0;
// Called to check if the popup - when an item container - actually
// has matching item. Case-sensitivity checking etc. is up to the
// implementation. If the found item matched the string, but is
// different, it should be written back to pItem. Default implementation
// always return true and does not alter trueItem.
virtual bool FindItem(const wxString& item, wxString* trueItem=nullptr);
// This is called to custom paint in the combo control itself (ie. not the popup).
// Default implementation draws value as string.
virtual void PaintComboControl( wxDC& dc, const wxRect& rect );
// Receives wxEVT_KEY_DOWN key events from the parent wxComboCtrl.
// Events not handled should be skipped, as usual.
virtual void OnComboKeyEvent( wxKeyEvent& event );
// Receives wxEVT_CHAR key events from the parent wxComboCtrl.
// Events not handled should be skipped, as usual.
virtual void OnComboCharEvent( wxKeyEvent& event );
// Implement if you need to support special action when user
// double-clicks on the parent wxComboCtrl.
virtual void OnComboDoubleClick();
// Return final size of popup. Called on every popup, just prior to OnShow.
// minWidth = preferred minimum width for window
// prefHeight = preferred height. Only applies if > 0,
// maxHeight = max height for window, as limited by screen size
// and should only be rounded down, if necessary.
virtual wxSize GetAdjustedSize( int minWidth, int prefHeight, int maxHeight );
// Return true if you want delay call to Create until the popup is shown
// for the first time. It is more efficient, but note that it is often
// more convenient to have the control created immediately.
// Default returns false.
virtual bool LazyCreate();
//
// Utilities
//
// Hides the popup
void Dismiss();
// Returns true if Create has been called.
bool IsCreated() const
{
return (m_iFlags & wxCP_IFLAG_CREATED) ? true : false;
}
// Returns pointer to the associated parent wxComboCtrl.
wxComboCtrl* GetComboCtrl() const;
// Default PaintComboControl behaviour
static void DefaultPaintComboControl( wxComboCtrlBase* combo,
wxDC& dc,
const wxRect& rect );
protected:
wxComboCtrlBase* m_combo;
wxUint32 m_iFlags;
private:
// Called in wxComboCtrlBase::SetPopupControl
void InitBase(wxComboCtrlBase *combo)
{
m_combo = combo;
}
};
// ----------------------------------------------------------------------------
// include the platform-dependent header defining the real class
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
// No native universal (but it must still be first in the list)
#elif defined(__WXMSW__)
#include "wx/msw/combo.h"
#endif
// Any ports may need generic as an alternative
#include "wx/generic/combo.h"
#endif // wxUSE_COMBOCTRL
#endif
// _WX_COMBOCONTROL_H_BASE_

View File

@@ -0,0 +1,85 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/combobox.h
// Purpose: wxComboBox declaration
// Author: Vadim Zeitlin
// Created: 24.12.00
// Copyright: (c) 1996-2000 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOBOX_H_BASE_
#define _WX_COMBOBOX_H_BASE_
#include "wx/defs.h"
#if wxUSE_COMBOBOX
// For compatibility with 2.8 include this header to allow using wxTE_XXX
// styles with wxComboBox without explicitly including it in the user code.
#include "wx/textctrl.h"
extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[];
// ----------------------------------------------------------------------------
// wxComboBoxBase: this interface defines the methods wxComboBox must implement
// ----------------------------------------------------------------------------
#include "wx/ctrlsub.h"
#include "wx/textentry.h"
class WXDLLIMPEXP_CORE wxComboBoxBase : public wxItemContainer,
public wxTextEntry
{
public:
// override these methods to disambiguate between two base classes versions
virtual void Clear() override
{
wxItemContainer::Clear();
wxTextEntry::Clear();
}
// IsEmpty() is ambiguous because we inherit it from both wxItemContainer
// and wxTextEntry, and even if defined it here to help the compiler with
// choosing one of them, it would still be confusing for the human users of
// this class. So instead define the clearly named methods below and leave
// IsEmpty() ambiguous to trigger a compilation error if it's used.
bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
// also bring in GetSelection() versions of both base classes in scope
//
// NB: GetSelection(from, to) could be already implemented in wxTextEntry
// but still make it pure virtual because for some platforms it's not
// implemented there and also because the derived class has to override
// it anyhow to avoid ambiguity with the other GetSelection()
virtual int GetSelection() const override = 0;
virtual void GetSelection(long *from, long *to) const override = 0;
virtual void Popup() { wxFAIL_MSG( wxT("Not implemented") ); }
virtual void Dismiss() { wxFAIL_MSG( wxT("Not implemented") ); }
// may return value different from GetSelection() when the combobox
// dropdown is shown and the user selected, but not yet accepted, a value
// different from the old one in it
virtual int GetCurrentSelection() const { return GetSelection(); }
};
// ----------------------------------------------------------------------------
// include the platform-dependent header defining the real class
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/combobox.h"
#elif defined(__WXMSW__)
#include "wx/msw/combobox.h"
#elif defined(__WXGTK__)
#include "wx/gtk/combobox.h"
#elif defined(__WXMAC__)
#include "wx/osx/combobox.h"
#elif defined(__WXQT__)
#include "wx/qt/combobox.h"
#endif
#endif // wxUSE_COMBOBOX
#endif // _WX_COMBOBOX_H_BASE_

View File

@@ -0,0 +1,169 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/commandlinkbutton.h
// Purpose: wxCommandLinkButtonBase and wxGenericCommandLinkButton classes
// Author: Rickard Westerlund
// Created: 2010-06-11
// Copyright: (c) 2010 wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMMANDLINKBUTTON_H_
#define _WX_COMMANDLINKBUTTON_H_
#include "wx/defs.h"
#if wxUSE_COMMANDLINKBUTTON
#include "wx/button.h"
// ----------------------------------------------------------------------------
// Command link button common base class
// ----------------------------------------------------------------------------
// This class has separate "main label" (title-like string) and (possibly
// multiline) "note" which can be set and queried separately but can also be
// set both at once by joining them with a new line and setting them as a
// label and queried by breaking the label into the parts before the first new
// line and after it.
class WXDLLIMPEXP_ADV wxCommandLinkButtonBase : public wxButton
{
public:
wxCommandLinkButtonBase() : wxButton() { }
wxCommandLinkButtonBase(wxWindow *parent,
wxWindowID id,
const wxString& mainLabel = wxEmptyString,
const wxString& note = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator =
wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr))
: wxButton(parent,
id,
mainLabel + '\n' + note,
pos,
size,
style,
validator,
name)
{ }
virtual void SetMainLabelAndNote(const wxString& mainLabel,
const wxString& note) = 0;
virtual void SetMainLabel(const wxString& mainLabel)
{
SetMainLabelAndNote(mainLabel, GetNote());
}
virtual void SetNote(const wxString& note)
{
SetMainLabelAndNote(GetMainLabel(), note);
}
virtual wxString GetMainLabel() const
{
return GetLabel().BeforeFirst('\n');
}
virtual wxString GetNote() const
{
return GetLabel().AfterFirst('\n');
}
protected:
virtual bool HasNativeBitmap() const { return false; }
private:
wxDECLARE_NO_COPY_CLASS(wxCommandLinkButtonBase);
};
// ----------------------------------------------------------------------------
// Generic command link button
// ----------------------------------------------------------------------------
// Trivial generic implementation simply using a multiline label to show both
// the main label and the note.
class WXDLLIMPEXP_ADV wxGenericCommandLinkButton
: public wxCommandLinkButtonBase
{
public:
wxGenericCommandLinkButton() : wxCommandLinkButtonBase() { }
wxGenericCommandLinkButton(wxWindow *parent,
wxWindowID id,
const wxString& mainLabel = wxEmptyString,
const wxString& note = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr))
: wxCommandLinkButtonBase()
{
Create(parent, id, mainLabel, note, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& mainLabel = wxEmptyString,
const wxString& note = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr));
virtual void SetMainLabelAndNote(const wxString& mainLabel,
const wxString& note) override
{
wxButton::SetLabel(mainLabel + '\n' + note);
}
private:
void SetDefaultBitmap();
wxDECLARE_NO_COPY_CLASS(wxGenericCommandLinkButton);
};
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/commandlinkbutton.h"
#else
class WXDLLIMPEXP_ADV wxCommandLinkButton : public wxGenericCommandLinkButton
{
public:
wxCommandLinkButton() : wxGenericCommandLinkButton() { }
wxCommandLinkButton(wxWindow *parent,
wxWindowID id,
const wxString& mainLabel = wxEmptyString,
const wxString& note = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr))
: wxGenericCommandLinkButton(parent,
id,
mainLabel,
note,
pos,
size,
style,
validator,
name)
{ }
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxCommandLinkButton);
};
#endif // __WXMSW__/!__WXMSW__
#endif // wxUSE_COMMANDLINKBUTTON
#endif // _WX_COMMANDLINKBUTTON_H_

View File

@@ -0,0 +1,131 @@
/*
* Name: wx/compiler.h
* Purpose: Compiler-specific macro definitions.
* Author: Vadim Zeitlin
* Created: 2013-07-13 (extracted from wx/platform.h)
* Copyright: (c) 1997-2013 Vadim Zeitlin <vadim@wxwidgets.org>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_COMPILER_H_
#define _WX_COMPILER_H_
/*
Compiler detection and related helpers.
*/
/*
Notice that Intel compiler can be used as Microsoft Visual C++ add-on and
so we should define both __INTELC__ and __VISUALC__ for it.
*/
#ifdef __INTEL_COMPILER
# define __INTELC__
#endif
#if defined(_MSC_VER)
/*
define another standard symbol for Microsoft Visual C++: the standard
one (_MSC_VER) is also defined by some other compilers.
*/
# define __VISUALC__ _MSC_VER
/*
define special symbols for different VC version instead of writing tests
for magic numbers such as 1200, 1300 &c repeatedly
*/
#if __VISUALC__ < 1900
# error "This Visual C++ version is not supported any longer (at least MSVC 2015 required)."
#elif __VISUALC__ < 2000
/* There is no __VISUALC13__! */
# define __VISUALC14__
#else
/*
Don't forget to update include/msvc/wx/setup.h as well when adding
support for a newer MSVC version here.
*/
# pragma message("Please update wx/compiler.h to recognize this VC++ version")
#endif
#elif defined(__SUNPRO_CC)
# ifndef __SUNCC__
# define __SUNCC__ __SUNPRO_CC
# endif /* Sun CC */
#endif /* compiler */
/*
Macros for checking compiler version.
*/
/*
This macro can be used to test the gcc version and can be used like this:
# if wxCHECK_GCC_VERSION(3, 1)
... we have gcc 3.1 or later ...
# else
... no gcc at all or gcc < 3.1 ...
# endif
*/
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define wxCHECK_GCC_VERSION( major, minor ) \
( ( __GNUC__ > (major) ) \
|| ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) )
/*
clang predefines __GNUC__ and __GNUC_MINOR__ as 4 and 6, don't give an
error below for it.
*/
#if defined(__clang__)
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
#error "This clang version is not supported any longer (at least clang 3.4 required)."
#endif
#else
#if !wxCHECK_GCC_VERSION(4, 8)
#error "This gcc version is not supported any longer (at least gcc 4.8 required, gcc 6 or later recommended)."
#endif
/* Define a special symbol used to work around 4.8 problems. */
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8
#define wxGCC_4_8
#endif
#endif
#else
#define wxCHECK_GCC_VERSION( major, minor ) 0
#endif
/*
This macro can be used to test the Visual C++ version.
*/
#ifndef __VISUALC__
# define wxVISUALC_VERSION(major) 0
# define wxCHECK_VISUALC_VERSION(major) 0
#else
/*
Things used to be simple with the _MSC_VER value and the version number
increasing in lock step, but _MSC_VER value of 1900 is VC14 and not the
non existing (presumably for the superstitious reasons) VC13, so we now
need to account for this with an extra offset.
*/
# define wxVISUALC_VERSION(major) ( (6 - (major >= 14 ? 1 : 0) + major) * 100 )
# define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) )
#endif
/**
This is similar to wxCHECK_GCC_VERSION but for Sun CC compiler.
*/
#ifdef __SUNCC__
/*
__SUNCC__ is 0xVRP where V is major version, R release and P patch level
*/
#define wxCHECK_SUNCC_VERSION(maj, min) (__SUNCC__ >= (((maj)<<8) | ((min)<<4)))
#else
#define wxCHECK_SUNCC_VERSION(maj, min) (0)
#endif
/*
wxCHECK_MINGW32_VERSION() is defined in wx/msw/gccpriv.h which is included
later, see comments there.
*/
#endif // _WX_COMPILER_H_

View File

@@ -0,0 +1,33 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/custombookctrl.h
// Purpose: Helper for wxBookCtrlBase subclasses composed of several windows
// Author: Vadim Zeitlin
// Created: 2023-01-29
// Copyright: (c) 2023 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMPOSITEBOOKCTRL_H_
#define _WX_COMPOSITEBOOKCTRL_H_
#include "wx/bookctrl.h"
#if wxUSE_BOOKCTRL
#include "wx/containr.h"
// ----------------------------------------------------------------------------
// wxCompositeBookCtrlBase
// ----------------------------------------------------------------------------
// This class is specifically DLL-exported, even though it's trivial, in order
// to ensure that there is only a single copy of it in the wx DLL.
class WXDLLIMPEXP_CORE wxCompositeBookCtrlBase : public wxNavigationEnabled<wxBookCtrlBase>
{
public:
wxCompositeBookCtrlBase();
};
#endif // wxUSE_BOOKCTRL
#endif // _WX_COMPOSITEBOOKCTRL_H_

View File

@@ -0,0 +1,295 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/compositewin.h
// Purpose: wxCompositeWindow<> declaration
// Author: Vadim Zeitlin
// Created: 2011-01-02
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMPOSITEWIN_H_
#define _WX_COMPOSITEWIN_H_
#include "wx/window.h"
#include "wx/containr.h"
class WXDLLIMPEXP_FWD_CORE wxToolTip;
// NB: This is an experimental and, as for now, undocumented class used only by
// wxWidgets itself internally. Don't use it in your code until its API is
// officially stabilized unless you are ready to change it with the next
// wxWidgets release.
// ----------------------------------------------------------------------------
// wxCompositeWindow is a helper for implementing composite windows: to define
// a class using subwindows, simply inherit from it specialized with the real
// base class name and implement GetCompositeWindowParts() pure virtual method.
// ----------------------------------------------------------------------------
// This is the base class of wxCompositeWindow which takes care of propagating
// colours, fonts etc changes to all the children, but doesn't bother with
// handling their events or focus. There should be rarely any need to use it
// rather than the full wxCompositeWindow.
// The template parameter W must be a wxWindow-derived class.
template <class W>
class wxCompositeWindowSettersOnly : public W
{
public:
typedef W BaseWindowClass;
// Override all wxWindow methods which must be forwarded to the composite
// window parts.
// Attribute setters group.
//
// NB: Unfortunately we can't factor out the call for the setter itself
// into DoSetForAllParts() because we can't call the function passed to
// it non-virtually and we need to do this to avoid infinite recursion,
// so we work around this by calling the method of this object itself
// manually in each function.
virtual bool SetForegroundColour(const wxColour& colour) override
{
if ( !BaseWindowClass::SetForegroundColour(colour) )
return false;
SetForAllParts(&wxWindowBase::SetForegroundColour, colour);
return true;
}
virtual bool SetBackgroundColour(const wxColour& colour) override
{
if ( !BaseWindowClass::SetBackgroundColour(colour) )
return false;
SetForAllParts(&wxWindowBase::SetBackgroundColour, colour);
return true;
}
virtual bool SetFont(const wxFont& font) override
{
if ( !BaseWindowClass::SetFont(font) )
return false;
SetForAllParts(&wxWindowBase::SetFont, font);
return true;
}
virtual bool SetCursor(const wxCursor& cursor) override
{
if ( !BaseWindowClass::SetCursor(cursor) )
return false;
SetForAllParts(&wxWindowBase::SetCursor, cursor);
return true;
}
virtual void SetLayoutDirection(wxLayoutDirection dir) override
{
BaseWindowClass::SetLayoutDirection(dir);
SetForAllParts(&wxWindowBase::SetLayoutDirection, dir);
// The child layout almost invariably depends on the layout direction,
// so redo it when it changes.
//
// However avoid doing it when we're called from wxWindow::Create() in
// wxGTK as the derived window is not fully created yet and calling its
// SetSize() may be unexpected. This does mean that any future calls to
// SetLayoutDirection(wxLayout_Default) wouldn't result in a re-layout
// either, but then we're not supposed to be called with it at all.
if ( dir != wxLayout_Default )
this->SetSize(-1, -1, -1, -1, wxSIZE_FORCE);
}
#if wxUSE_TOOLTIPS
virtual void DoSetToolTipText(const wxString &tip) override
{
BaseWindowClass::DoSetToolTipText(tip);
// Use a variable to disambiguate between SetToolTip() overloads.
void (wxWindowBase::*func)(const wxString&) = &wxWindowBase::SetToolTip;
SetForAllParts(func, tip);
}
virtual void DoSetToolTip(wxToolTip *tip) override
{
BaseWindowClass::DoSetToolTip(tip);
SetForAllParts(&wxWindowBase::CopyToolTip, tip);
}
#endif // wxUSE_TOOLTIPS
protected:
// Trivial but necessary default ctor.
wxCompositeWindowSettersOnly()
{
}
private:
// It may happen that we the base class W already is a wxCompositeWindow
// and so already has GetCompositeWindowParts(). This actually works fine,
// as it just gets overridden by the most derived class, but triggers a
// warning, so disable this warning explicitly as we can't do anything else
// about it here (as actually using "override" here would result in an
// error for the first class in the hierarchy using wxCompositeWindow).
wxWARNING_SUPPRESS_MISSING_OVERRIDE()
// Must be implemented by the derived class to return all children to which
// the public methods we override should forward to.
virtual wxWindowList GetCompositeWindowParts() const = 0;
wxWARNING_RESTORE_MISSING_OVERRIDE()
template <class T, class TArg, class R>
void SetForAllParts(R (wxWindowBase::*func)(TArg), T arg)
{
// Simply call the setters for all parts of this composite window.
const wxWindowList parts = GetCompositeWindowParts();
for ( wxWindowList::const_iterator i = parts.begin();
i != parts.end();
++i )
{
wxWindow * const child = *i;
// Allow null elements in the list, this makes the code of derived
// composite controls which may have optionally shown children
// simpler and it doesn't cost us much here.
if ( child )
(child->*func)(arg);
}
}
wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCompositeWindowSettersOnly, W);
};
// The real wxCompositeWindow itself, inheriting all the setters defined above.
template <class W>
class wxCompositeWindow : public wxCompositeWindowSettersOnly<W>
{
public:
virtual void SetFocus() override
{
wxSetFocusToChild(this, nullptr);
}
protected:
// Default ctor sets things up for handling children events correctly.
wxCompositeWindow()
{
this->Bind(wxEVT_CREATE, &wxCompositeWindow::OnWindowCreate, this);
}
private:
void OnWindowCreate(wxWindowCreateEvent& event)
{
event.Skip();
// Attach a few event handlers to all parts of the composite window.
// This makes the composite window behave more like a simple control
// and allows other code (such as wxDataViewCtrl's inline editing
// support) to hook into its event processing.
wxWindow *child = event.GetWindow();
// Check that it's one of our children: it could also be this window
// itself (for which we don't need to handle focus at all) or one of
// its grandchildren and we don't want to bind to those as child
// controls are supposed to be well-behaved and get their own focus
// event if any of their children get focus anyhow, so binding to them
// would only result in duplicate events.
//
// Notice that we can't use GetCompositeWindowParts() here because the
// member variables that are typically used in its implementation in
// the derived classes would typically not be initialized yet, as this
// event is generated by "m_child = new wxChildControl(this, ...)" code
// before "m_child" is assigned.
if ( child->GetParent() != this )
return;
child->Bind(wxEVT_SET_FOCUS, &wxCompositeWindow::OnSetFocus, this);
child->Bind(wxEVT_KILL_FOCUS, &wxCompositeWindow::OnKillFocus, this);
// Some events should be only handled for non-toplevel children. For
// example, we want to close the control in wxDataViewCtrl when Enter
// is pressed in the inline editor, but not when it's pressed in a
// popup dialog it opens.
wxWindow *win = child;
while ( win && win != this )
{
if ( win->IsTopLevel() )
return;
win = win->GetParent();
}
// Make all keyboard events occurring in sub-windows appear as coming
// from the main window itself.
child->Bind(wxEVT_KEY_DOWN, &wxCompositeWindow::OnKeyEvent, this);
child->Bind(wxEVT_CHAR, &wxCompositeWindow::OnKeyEvent, this);
child->Bind(wxEVT_KEY_UP, &wxCompositeWindow::OnKeyEvent, this);
}
void OnKeyEvent(wxKeyEvent& event)
{
wxEventObjectOriginSetter setThis(event, this, this->GetId());
if ( !this->ProcessWindowEvent(event) )
event.Skip();
}
void OnSetFocus(wxFocusEvent& event)
{
event.Skip();
// When a child of a composite window gains focus, the entire composite
// focus gains focus as well -- unless it had it already.
//
// We suppose that we hadn't had focus if the event doesn't carry the
// previously focused window as it normally means that it comes from
// outside of this program.
wxWindow* const oldFocus = event.GetWindow();
if ( !oldFocus || oldFocus->GetMainWindowOfCompositeControl() != this )
{
wxFocusEvent eventThis(wxEVT_SET_FOCUS, this->GetId());
eventThis.SetEventObject(this);
eventThis.SetWindow(event.GetWindow());
this->ProcessWindowEvent(eventThis);
}
}
void OnKillFocus(wxFocusEvent& event)
{
// Ignore focus changes within the composite control:
wxWindow *win = event.GetWindow();
while ( win )
{
if ( win == this )
{
event.Skip();
return;
}
// Note that we don't use IsTopLevel() check here, because we do
// want to ignore focus changes going to toplevel window that have
// the composite control as its parent; these would typically be
// some kind of control's popup window.
win = win->GetParent();
}
// The event shouldn't be ignored, forward it to the main control:
if ( !this->ProcessWindowEvent(event) )
event.Skip();
}
wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCompositeWindow, W);
};
#endif // _WX_COMPOSITEWIN_H_

View File

@@ -0,0 +1,487 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/confbase.h
// Purpose: declaration of the base class of all config implementations
// (see also: fileconf.h and msw/regconf.h and iniconf.h)
// Author: Karsten Ballueder & Vadim Zeitlin
// Created: 07.04.98 (adapted from appconf.h)
// Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net
// Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONFBASE_H_
#define _WX_CONFBASE_H_
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/object.h"
#include "wx/base64.h"
class WXDLLIMPEXP_FWD_BASE wxArrayString;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
/// shall we be case sensitive in parsing variable names?
#ifndef wxCONFIG_CASE_SENSITIVE
#define wxCONFIG_CASE_SENSITIVE 0
#endif
/// separates group and entry names (probably shouldn't be changed)
#ifndef wxCONFIG_PATH_SEPARATOR
#define wxCONFIG_PATH_SEPARATOR wxT('/')
#endif
/// introduces immutable entries
// (i.e. the ones which can't be changed from the local config file)
#ifndef wxCONFIG_IMMUTABLE_PREFIX
#define wxCONFIG_IMMUTABLE_PREFIX wxT('!')
#endif
#if wxUSE_CONFIG
/// should we use registry instead of configuration files under Windows?
// (i.e. whether wxConfigBase::Create() will create a wxFileConfig (if it's
// false) or wxRegConfig (if it's true and we're under Win32))
#ifndef wxUSE_CONFIG_NATIVE
#define wxUSE_CONFIG_NATIVE 1
#endif
// not all compilers can deal with template Read/Write() methods, define this
// symbol if the template functions are available
#if !defined( __VMS ) && \
!(defined(__HP_aCC) && defined(__hppa))
#define wxHAS_CONFIG_TEMPLATE_RW
#endif
// Style flags for constructor style parameter
enum
{
wxCONFIG_USE_LOCAL_FILE = 1,
wxCONFIG_USE_GLOBAL_FILE = 2,
wxCONFIG_USE_RELATIVE_PATH = 4,
wxCONFIG_USE_NO_ESCAPE_CHARACTERS = 8,
wxCONFIG_USE_SUBDIR = 16,
wxCONFIG_USE_XDG = 32,
wxCONFIG_USE_HOME = 64
};
// ----------------------------------------------------------------------------
// abstract base class wxConfigBase which defines the interface for derived
// classes
//
// wxConfig organizes the items in a tree-like structure (modelled after the
// Unix/Dos filesystem). There are groups (directories) and keys (files).
// There is always one current group given by the current path.
//
// Keys are pairs "key_name = value" where value may be of string or integer
// (long) type (TODO doubles and other types such as wxDate coming soon).
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxConfigBase : public wxObject
{
public:
// constants
// the type of an entry
enum EntryType
{
Type_Unknown,
Type_String,
Type_Boolean,
Type_Integer, // use Read(long *)
Type_Float // use Read(double *)
};
// static functions
// sets the config object, returns the previous pointer
static wxConfigBase *Set(wxConfigBase *pConfig);
// get the config object, creates it on demand unless DontCreateOnDemand
// was called
static wxConfigBase *Get(bool createOnDemand = true)
{ if ( createOnDemand && (!ms_pConfig) ) Create(); return ms_pConfig; }
// create a new config object: this function will create the "best"
// implementation of wxConfig available for the current platform, see
// comments near definition wxUSE_CONFIG_NATIVE for details. It returns
// the created object and also sets it as ms_pConfig.
static wxConfigBase *Create();
// should Get() try to create a new log object if the current one is null?
static void DontCreateOnDemand() { ms_bAutoCreate = false; }
// ctor & virtual dtor
// ctor (can be used as default ctor too)
//
// Not all args will always be used by derived classes, but including
// them all in each class ensures compatibility. If appName is empty,
// uses wxApp name
wxConfigBase(const wxString& appName = wxEmptyString,
const wxString& vendorName = wxEmptyString,
const wxString& localFilename = wxEmptyString,
const wxString& globalFilename = wxEmptyString,
long style = 0);
// empty but ensures that dtor of all derived classes is virtual
virtual ~wxConfigBase();
// path management
// set current path: if the first character is '/', it's the absolute path,
// otherwise it's a relative path. '..' is supported. If the strPath
// doesn't exist it is created.
virtual void SetPath(const wxString& strPath) = 0;
// retrieve the current path (always as absolute path)
virtual const wxString& GetPath() const = 0;
// enumeration: all functions here return false when there are no more items.
// you must pass the same lIndex to GetNext and GetFirst (don't modify it)
// enumerate subgroups
virtual bool GetFirstGroup(wxString& str, long& lIndex) const = 0;
virtual bool GetNextGroup (wxString& str, long& lIndex) const = 0;
// enumerate entries
virtual bool GetFirstEntry(wxString& str, long& lIndex) const = 0;
virtual bool GetNextEntry (wxString& str, long& lIndex) const = 0;
// get number of entries/subgroups in the current group, with or without
// its subgroups
virtual size_t GetNumberOfEntries(bool bRecursive = false) const = 0;
virtual size_t GetNumberOfGroups(bool bRecursive = false) const = 0;
// tests of existence
// returns true if the group by this name exists
virtual bool HasGroup(const wxString& strName) const = 0;
// same as above, but for an entry
virtual bool HasEntry(const wxString& strName) const = 0;
// returns true if either a group or an entry with a given name exist
bool Exists(const wxString& strName) const
{ return HasGroup(strName) || HasEntry(strName); }
// get the entry type
virtual EntryType GetEntryType(const wxString& name) const
{
// by default all entries are strings
return HasEntry(name) ? Type_String : Type_Unknown;
}
// key access: returns true if value was really read, false if default used
// (and if the key is not found the default value is returned.)
// read a string from the key
bool Read(const wxString& key, wxString *pStr) const;
bool Read(const wxString& key, wxString *pStr, const wxString& defVal) const;
// read a number (long)
bool Read(const wxString& key, long *pl) const;
bool Read(const wxString& key, long *pl, long defVal) const;
// read an int (wrapper around `long' version)
bool Read(const wxString& key, int *pi) const;
bool Read(const wxString& key, int *pi, int defVal) const;
// read a double
bool Read(const wxString& key, double* val) const;
bool Read(const wxString& key, double* val, double defVal) const;
// read a float
bool Read(const wxString& key, float* val) const;
bool Read(const wxString& key, float* val, float defVal) const;
// read a bool
bool Read(const wxString& key, bool* val) const;
bool Read(const wxString& key, bool* val, bool defVal) const;
// read a 64-bit number when long is 32 bits
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Read(const wxString& key, wxLongLong_t *pl) const;
bool Read(const wxString& key, wxLongLong_t *pl, wxLongLong_t defVal) const;
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Read(const wxString& key, size_t* val) const;
bool Read(const wxString& key, size_t* val, size_t defVal) const;
#if wxUSE_BASE64
// read a binary data block
bool Read(const wxString& key, wxMemoryBuffer* data) const
{ return DoReadBinary(key, data); }
// no default version since it does not make sense for binary data
#endif // wxUSE_BASE64
#ifdef wxHAS_CONFIG_TEMPLATE_RW
// read other types, for which wxFromString is defined
template <typename T>
bool Read(const wxString& key, T* value) const
{
wxString s;
if ( !Read(key, &s) )
return false;
return wxFromString(s, value);
}
template <typename T>
bool Read(const wxString& key, T* value, const T& defVal) const
{
const bool found = Read(key, value);
if ( !found )
{
if (IsRecordingDefaults())
const_cast<wxConfigBase*>(this)->Write(key, defVal);
*value = defVal;
}
return found;
}
#endif // wxHAS_CONFIG_TEMPLATE_RW
// convenience functions returning directly the value
wxString Read(const wxString& key,
const wxString& defVal = wxEmptyString) const
{ wxString s; (void)Read(key, &s, defVal); return s; }
// we have to provide a separate version for C strings as otherwise the
// template Read() would be used
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
wxString Read(const wxString& key, const char* defVal) const
{ return Read(key, wxString(defVal)); }
#endif
wxString Read(const wxString& key, const wchar_t* defVal) const
{ return Read(key, wxString(defVal)); }
long ReadLong(const wxString& key, long defVal) const
{ long l; (void)Read(key, &l, defVal); return l; }
wxLongLong_t ReadLongLong(const wxString& key, wxLongLong_t defVal) const
{ wxLongLong_t ll; (void)Read(key, &ll, defVal); return ll; }
double ReadDouble(const wxString& key, double defVal) const
{ double d; (void)Read(key, &d, defVal); return d; }
bool ReadBool(const wxString& key, bool defVal) const
{ bool b; (void)Read(key, &b, defVal); return b; }
template <typename T>
T ReadObject(const wxString& key, T const& defVal) const
{ T t; (void)Read(key, &t, defVal); return t; }
// for compatibility with wx 2.8
long Read(const wxString& key, long defVal) const
{ return ReadLong(key, defVal); }
// write the value (return true on success)
bool Write(const wxString& key, const wxString& value)
{ return DoWriteString(key, value); }
bool Write(const wxString& key, long value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, double value)
{ return DoWriteDouble(key, value); }
bool Write(const wxString& key, bool value)
{ return DoWriteBool(key, value); }
#if wxUSE_BASE64
bool Write(const wxString& key, const wxMemoryBuffer& buf)
{ return DoWriteBinary(key, buf); }
#endif // wxUSE_BASE64
// we have to provide a separate version for C strings as otherwise they
// would be converted to bool and not to wxString as expected!
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
bool Write(const wxString& key, const char *value)
{ return Write(key, wxString(value)); }
bool Write(const wxString& key, const unsigned char *value)
{ return Write(key, wxString(value)); }
#endif
bool Write(const wxString& key, const wchar_t *value)
{ return Write(key, wxString(value)); }
// we also have to provide specializations for other types which we want to
// handle using the specialized DoWriteXXX() instead of the generic template
// version below
bool Write(const wxString& key, char value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, unsigned char value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, short value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, unsigned short value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, unsigned int value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, int value)
{ return DoWriteLong(key, value); }
bool Write(const wxString& key, unsigned long value)
{ return DoWriteLong(key, value); }
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Write(const wxString& key, wxLongLong_t value)
{ return DoWriteLongLong(key, value); }
bool Write(const wxString& key, wxULongLong_t value)
{ return DoWriteLongLong(key, value); }
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
bool Write(const wxString& key, float value)
{ return DoWriteDouble(key, double(value)); }
// Causes ambiguities in under OpenVMS
#if !defined( __VMS )
// for other types, use wxToString()
template <typename T>
bool Write(const wxString& key, T const& value)
{ return Write(key, wxToString(value)); }
#endif
// permanently writes all changes
virtual bool Flush(bool bCurrentOnly = false) = 0;
// renaming, all functions return false on failure (probably because the new
// name is already taken by an existing entry)
// rename an entry
virtual bool RenameEntry(const wxString& oldName,
const wxString& newName) = 0;
// rename a group
virtual bool RenameGroup(const wxString& oldName,
const wxString& newName) = 0;
// delete entries/groups
// deletes the specified entry and the group it belongs to if
// it was the last key in it and the second parameter is true
virtual bool DeleteEntry(const wxString& key,
bool bDeleteGroupIfEmpty = true) = 0;
// delete the group (with all subgroups)
virtual bool DeleteGroup(const wxString& key) = 0;
// delete the whole underlying object (disk file, registry key, ...)
// primarily for use by uninstallation routine.
virtual bool DeleteAll() = 0;
// options
// we can automatically expand environment variables in the config entries
// (this option is on by default, you can turn it on/off at any time)
bool IsExpandingEnvVars() const { return m_bExpandEnvVars; }
void SetExpandEnvVars(bool bDoIt = true) { m_bExpandEnvVars = bDoIt; }
// recording of default values
void SetRecordDefaults(bool bDoIt = true) { m_bRecordDefaults = bDoIt; }
bool IsRecordingDefaults() const { return m_bRecordDefaults; }
// does expansion only if needed
wxString ExpandEnvVars(const wxString& str) const;
// misc accessors
wxString GetAppName() const { return m_appName; }
wxString GetVendorName() const { return m_vendorName; }
// Used wxIniConfig to set members in constructor
void SetAppName(const wxString& appName) { m_appName = appName; }
void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
void SetStyle(long style) { m_style = style; }
long GetStyle() const { return m_style; }
protected:
static bool IsImmutable(const wxString& key)
{ return !key.IsEmpty() && key[0] == wxCONFIG_IMMUTABLE_PREFIX; }
// return the path without trailing separator, if any: this should be called
// to sanitize paths referring to the group names before passing them to
// wxConfigPathChanger as "/foo/bar/" should be the same as "/foo/bar" and it
// isn't interpreted in the same way by it (and this can't be changed there
// as it's not the same for the entries names)
static wxString RemoveTrailingSeparator(const wxString& key);
// do read/write the values of different types
virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0;
virtual bool DoReadLong(const wxString& key, long *pl) const = 0;
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoReadLongLong(const wxString& key, wxLongLong_t *pll) const;
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoReadDouble(const wxString& key, double* val) const;
virtual bool DoReadBool(const wxString& key, bool* val) const;
#if wxUSE_BASE64
virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const = 0;
#endif // wxUSE_BASE64
virtual bool DoWriteString(const wxString& key, const wxString& value) = 0;
virtual bool DoWriteLong(const wxString& key, long value) = 0;
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoWriteLongLong(const wxString& key, wxLongLong_t value);
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
virtual bool DoWriteDouble(const wxString& key, double value);
virtual bool DoWriteBool(const wxString& key, bool value);
#if wxUSE_BASE64
virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf) = 0;
#endif // wxUSE_BASE64
private:
// are we doing automatic environment variable expansion?
bool m_bExpandEnvVars;
// do we record default values?
bool m_bRecordDefaults;
// static variables
static wxConfigBase *ms_pConfig;
static bool ms_bAutoCreate;
// Application name and organisation name
wxString m_appName;
wxString m_vendorName;
// Style flag
long m_style;
wxDECLARE_ABSTRACT_CLASS(wxConfigBase);
};
// a handy little class which changes current path to the path of given entry
// and restores it in dtor: so if you declare a local variable of this type,
// you work in the entry directory and the path is automatically restored
// when the function returns
// Taken out of wxConfig since not all compilers can cope with nested classes.
class WXDLLIMPEXP_BASE wxConfigPathChanger
{
public:
// ctor/dtor do path changing/restoring of the path
wxConfigPathChanger(const wxConfigBase *pContainer, const wxString& strEntry);
~wxConfigPathChanger();
// get the key name
const wxString& Name() const { return m_strName; }
// this method must be called if the original path (i.e. the current path at
// the moment of creation of this object) could have been deleted to prevent
// us from restoring the not existing (any more) path
//
// if the original path doesn't exist any more, the path will be restored to
// the deepest still existing component of the old path
void UpdateIfDeleted();
private:
wxConfigBase *m_pContainer; // object we live in
wxString m_strName, // name of entry (i.e. name only)
m_strOldPath; // saved path
bool m_bChanged; // was the path changed?
wxDECLARE_NO_COPY_CLASS(wxConfigPathChanger);
};
#endif // wxUSE_CONFIG
/*
Replace environment variables ($SOMETHING) with their values. The format is
$VARNAME or ${VARNAME} where VARNAME contains alphanumeric characters and
'_' only. '$' must be escaped ('\$') in order to be taken literally.
*/
WXDLLIMPEXP_BASE wxString wxExpandEnvVars(const wxString &sz);
/*
Split path into parts removing '..' in progress
*/
WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxString& path);
#endif // _WX_CONFBASE_H_

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/config.h
// Purpose: wxConfig base header
// Author: Julian Smart
// Created:
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONFIG_H_BASE_
#define _WX_CONFIG_H_BASE_
#include "wx/confbase.h"
#if wxUSE_CONFIG
// ----------------------------------------------------------------------------
// define the native wxConfigBase implementation
// ----------------------------------------------------------------------------
// under Windows we prefer to use the native implementation but can be forced
// to use the file-based one
#if defined(__WINDOWS__) && wxUSE_CONFIG_NATIVE
#include "wx/msw/regconf.h"
#define wxConfig wxRegConfig
#define wxHAS_CONFIG_AS_REGCONFIG
#else // either we're under Unix or wish to always use config files
#include "wx/fileconf.h"
#define wxConfig wxFileConfig
#define wxHAS_CONFIG_AS_FILECONFIG
#endif
#endif // wxUSE_CONFIG
#endif // _WX_CONFIG_H_BASE_

View File

@@ -0,0 +1,298 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/containr.h
// Purpose: wxControlContainer and wxNavigationEnabled declarations
// Author: Vadim Zeitlin
// Created: 06.08.01
// Copyright: (c) 2001, 2011 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTAINR_H_
#define _WX_CONTAINR_H_
#include "wx/defs.h"
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
// We need wxEVT_XXX declarations in this case.
#include "wx/event.h"
#endif
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxWindowBase;
/*
This header declares wxControlContainer class however it's not a real
container of controls but rather just a helper used to implement TAB
navigation among the window children. You should rarely need to use it
directly, derive from the documented public wxNavigationEnabled<> class to
implement TAB navigation in a custom composite window.
*/
// ----------------------------------------------------------------------------
// wxControlContainerBase: common part used in both native and generic cases
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxControlContainerBase
{
public:
// default ctor, SetContainerWindow() must be called later
wxControlContainerBase()
{
m_winParent = nullptr;
// By default, we accept focus ourselves.
m_acceptsFocusSelf = true;
m_inSetFocus = false;
m_winLastFocused = nullptr;
}
virtual ~wxControlContainerBase() = default;
void SetContainerWindow(wxWindow *winParent)
{
wxASSERT_MSG( !m_winParent, wxT("shouldn't be called twice") );
m_winParent = winParent;
}
// This can be called by the window to indicate that it never wants to have
// the focus for itself.
void DisableSelfFocus()
{ m_acceptsFocusSelf = false; UpdateParentCanFocus(); }
// This can be called to undo the effect of a previous DisableSelfFocus()
// (otherwise calling it is not necessary as the window does accept focus
// by default).
void EnableSelfFocus()
{ m_acceptsFocusSelf = true; UpdateParentCanFocus(); }
// should be called from SetFocus(), returns false if we did nothing with
// the focus and the default processing should take place
bool DoSetFocus();
// returns whether we should accept focus ourselves or not
bool AcceptsFocus() const;
// Returns whether we or one of our children accepts focus.
bool AcceptsFocusRecursively() const
{ return AcceptsFocus() || HasAnyChildrenAcceptingFocus(); }
// We accept focus from keyboard if we accept it at all.
bool AcceptsFocusFromKeyboard() const { return AcceptsFocusRecursively(); }
// Call this when the number of children of the window changes.
//
// Returns true if we have any focusable children, false otherwise.
bool UpdateCanFocusChildren();
#ifdef __WXMSW__
// This is not strictly related to navigation, but all windows containing
// more than one children controls need to return from this method if any
// of their parents has an inheritable background, so do this automatically
// for all of them (another alternative could be to do it in wxWindow
// itself but this would be potentially more backwards incompatible and
// could conceivably break some custom windows).
bool HasTransparentBackground() const;
#endif // __WXMSW__
protected:
// set the focus to the child which had it the last time
virtual bool SetFocusToChild();
// return true if we have any children accepting focus
bool HasAnyFocusableChildren() const;
// return true if we have any children that do accept focus right now
bool HasAnyChildrenAcceptingFocus() const;
// the parent window we manage the children for
wxWindow *m_winParent;
// the child which had the focus last time this panel was activated
wxWindow *m_winLastFocused;
private:
// Update the window status to reflect whether it is getting focus or not.
void UpdateParentCanFocus(bool acceptsFocusChildren);
void UpdateParentCanFocus()
{
UpdateParentCanFocus(HasAnyFocusableChildren());
}
// Indicates whether the associated window can ever have focus itself.
//
// Usually this is the case, e.g. a wxPanel can be used either as a
// container for its children or just as a normal window which can be
// focused. But sometimes, e.g. for wxStaticBox, we can never have focus
// ourselves and can only get it if we have any focusable children.
bool m_acceptsFocusSelf;
// a guard against infinite recursion
bool m_inSetFocus;
};
#ifdef wxHAS_NATIVE_TAB_TRAVERSAL
// ----------------------------------------------------------------------------
// wxControlContainer for native TAB navigation
// ----------------------------------------------------------------------------
// this must be a real class as we forward-declare it elsewhere
class WXDLLIMPEXP_CORE wxControlContainer : public wxControlContainerBase
{
protected:
// set the focus to the child which had it the last time
virtual bool SetFocusToChild() override;
};
#else // !wxHAS_NATIVE_TAB_TRAVERSAL
// ----------------------------------------------------------------------------
// wxControlContainer for TAB navigation implemented in wx itself
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxControlContainer : public wxControlContainerBase
{
public:
// default ctor, SetContainerWindow() must be called later
wxControlContainer();
// the methods to be called from the window event handlers
void HandleOnNavigationKey(wxNavigationKeyEvent& event);
void HandleOnFocus(wxFocusEvent& event);
void HandleOnWindowDestroy(wxWindowBase *child);
// called from OnChildFocus() handler, i.e. when one of our (grand)
// children gets the focus
void SetLastFocus(wxWindow *win);
protected:
wxDECLARE_NO_COPY_CLASS(wxControlContainer);
};
#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
// this function is for wxWidgets internal use only
extern WXDLLIMPEXP_CORE bool wxSetFocusToChild(wxWindow *win, wxWindow **child);
// ----------------------------------------------------------------------------
// wxNavigationEnabled: Derive from this class to support keyboard navigation
// among window children in a wxWindow-derived class. The details of this class
// don't matter, you just need to derive from it to make navigation work.
// ----------------------------------------------------------------------------
// The template parameter W must be a wxWindow-derived class.
template <class W>
class wxNavigationEnabled : public W
{
public:
typedef W BaseWindowClass;
wxNavigationEnabled()
{
m_container.SetContainerWindow(this);
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
BaseWindowClass::Bind(wxEVT_NAVIGATION_KEY,
&wxNavigationEnabled::OnNavigationKey, this);
BaseWindowClass::Bind(wxEVT_SET_FOCUS,
&wxNavigationEnabled::OnFocus, this);
BaseWindowClass::Bind(wxEVT_CHILD_FOCUS,
&wxNavigationEnabled::OnChildFocus, this);
#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
}
WXDLLIMPEXP_INLINE_CORE virtual bool AcceptsFocus() const override
{
return m_container.AcceptsFocus();
}
WXDLLIMPEXP_INLINE_CORE virtual bool AcceptsFocusRecursively() const override
{
return m_container.AcceptsFocusRecursively();
}
WXDLLIMPEXP_INLINE_CORE virtual bool AcceptsFocusFromKeyboard() const override
{
return m_container.AcceptsFocusFromKeyboard();
}
WXDLLIMPEXP_INLINE_CORE virtual void AddChild(wxWindowBase *child) override
{
BaseWindowClass::AddChild(child);
if ( m_container.UpdateCanFocusChildren() )
{
// Under MSW we must have wxTAB_TRAVERSAL style for TAB navigation
// to work.
if ( !BaseWindowClass::HasFlag(wxTAB_TRAVERSAL) )
BaseWindowClass::ToggleWindowStyle(wxTAB_TRAVERSAL);
}
}
WXDLLIMPEXP_INLINE_CORE virtual void RemoveChild(wxWindowBase *child) override
{
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
m_container.HandleOnWindowDestroy(child);
#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
BaseWindowClass::RemoveChild(child);
// We could reset wxTAB_TRAVERSAL here but it doesn't seem to do any
// harm to keep it.
m_container.UpdateCanFocusChildren();
}
WXDLLIMPEXP_INLINE_CORE virtual void SetFocus() override
{
if ( !m_container.DoSetFocus() )
BaseWindowClass::SetFocus();
}
void SetFocusIgnoringChildren()
{
BaseWindowClass::SetFocus();
}
#ifdef __WXMSW__
WXDLLIMPEXP_INLINE_CORE virtual bool HasTransparentBackground() override
{
return m_container.HasTransparentBackground();
}
WXDLLIMPEXP_INLINE_CORE
virtual void WXSetPendingFocus(wxWindow* win) override
{
return m_container.SetLastFocus(win);
}
#endif // __WXMSW__
protected:
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
void OnNavigationKey(wxNavigationKeyEvent& event)
{
m_container.HandleOnNavigationKey(event);
}
void OnFocus(wxFocusEvent& event)
{
m_container.HandleOnFocus(event);
}
void OnChildFocus(wxChildFocusEvent& event)
{
m_container.SetLastFocus(event.GetWindow());
event.Skip();
}
#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
wxControlContainer m_container;
wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxNavigationEnabled, W);
};
#endif // _WX_CONTAINR_H_

View File

@@ -0,0 +1,218 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/control.h
// Purpose: wxControl common interface
// Author: Vadim Zeitlin
// Created: 26.07.99
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTROL_H_BASE_
#define _WX_CONTROL_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_CONTROLS
#include "wx/window.h" // base class
#include "wx/gdicmn.h" // wxEllipsize...
extern WXDLLIMPEXP_DATA_CORE(const char) wxControlNameStr[];
// ----------------------------------------------------------------------------
// wxControl is the base class for all controls
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxControlBase : public wxWindow
{
public:
wxControlBase() = default;
virtual ~wxControlBase();
// Create() function adds the validator parameter
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxControlNameStr));
// get the control alignment (left/right/centre, top/bottom/centre)
int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; }
// set label with mnemonics
virtual void SetLabel(const wxString& label) override
{
m_labelOrig = label;
InvalidateBestSize();
wxWindow::SetLabel(label);
}
// return the original string, as it was passed to SetLabel()
// (i.e. with wx-style mnemonics)
virtual wxString GetLabel() const override { return m_labelOrig; }
// set label text (mnemonics will be escaped)
virtual void SetLabelText(const wxString& text)
{
SetLabel(EscapeMnemonics(text));
}
// get just the text of the label, without mnemonic characters ('&')
virtual wxString GetLabelText() const { return GetLabelText(GetLabel()); }
#if wxUSE_MARKUP
// Set the label with markup (and mnemonics). Markup is a simple subset of
// HTML with tags such as <b>, <i> and <span>. By default it is not
// supported i.e. all the markup is simply stripped and SetLabel() is
// called but some controls in some ports do support this already and in
// the future most of them should.
//
// Notice that, being HTML-like, markup also supports XML entities so '<'
// should be encoded as "&lt;" and so on, a bare '<' in the input will
// likely result in an error. As an exception, a bare '&' is allowed and
// indicates that the next character is a mnemonic. To insert a literal '&'
// in the control you need to use "&amp;" in the input string.
//
// Returns true if the label was set, even if the markup in it was ignored.
// False is only returned if we failed to parse the label.
bool SetLabelMarkup(const wxString& markup)
{
return DoSetLabelMarkup(markup);
}
#endif // wxUSE_MARKUP
// controls by default inherit the colours of their parents, if a
// particular control class doesn't want to do it, it can override
// ShouldInheritColours() to return false
virtual bool ShouldInheritColours() const override { return true; }
// WARNING: this doesn't work for all controls nor all platforms!
//
// simulates the event of given type (i.e. wxButton::Command() is just as
// if the button was clicked)
virtual void Command(wxCommandEvent &event);
virtual bool SetFont(const wxFont& font) override;
// wxControl-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) override;
wxSize GetSizeFromTextSize(int xlen, int ylen = -1) const
{ return DoGetSizeFromTextSize(xlen, ylen); }
wxSize GetSizeFromTextSize(const wxSize& tsize) const
{ return DoGetSizeFromTextSize(tsize.x, tsize.y); }
wxSize GetSizeFromText(const wxString& text) const
{
return GetSizeFromTextSize(GetTextExtent(text).GetWidth());
}
// static utilities for mnemonics char (&) handling
// ------------------------------------------------
// returns the given string without mnemonic characters ('&')
static wxString GetLabelText(const wxString& label);
// returns the given string without mnemonic characters ('&')
// this function is identic to GetLabelText() and is provided for clarity
// and for symmetry with the wxStaticText::RemoveMarkup() function.
static wxString RemoveMnemonics(const wxString& str);
// escapes (by doubling them) the mnemonics
static wxString EscapeMnemonics(const wxString& str);
// miscellaneous static utilities
// ------------------------------
// replaces parts of the given (multiline) string with an ellipsis if needed
static wxString Ellipsize(const wxString& label, const wxReadOnlyDC& dc,
wxEllipsizeMode mode, int maxWidth,
int flags = wxELLIPSIZE_FLAGS_DEFAULT);
// return the accel index in the string or -1 if none and puts the modified
// string into second parameter if non-null
static int FindAccelIndex(const wxString& label,
wxString *labelOnly = nullptr);
// this is a helper for the derived class GetClassDefaultAttributes()
// implementation: it returns the right colours for the classes which
// contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
// being simple controls (such as wxButton, wxCheckBox, ...)
static wxVisualAttributes
GetCompositeControlsDefaultAttributes(wxWindowVariant variant);
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const override;
// creates the control (calls wxWindowBase::CreateBase inside) and adds it
// to the list of parents children
bool CreateControl(wxWindowBase *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name);
#if wxUSE_MARKUP
// This function may be overridden in the derived classes to implement
// support for labels with markup. The base class version simply strips the
// markup and calls SetLabel() with the remaining text.
virtual bool DoSetLabelMarkup(const wxString& markup);
#endif // wxUSE_MARKUP
// override this to return the total control's size from a string size
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
// initialize the common fields of wxCommandEvent
void InitCommandEvent(wxCommandEvent& event) const;
#if wxUSE_MARKUP
// Remove markup from the given string, returns empty string on error i.e.
// if markup was syntactically invalid.
static wxString RemoveMarkup(const wxString& markup);
#endif // wxUSE_MARKUP
// this field contains the label in wx format, i.e. with '&' mnemonics,
// as it was passed to the last SetLabel() call
wxString m_labelOrig;
wxDECLARE_NO_COPY_CLASS(wxControlBase);
};
// ----------------------------------------------------------------------------
// include platform-dependent wxControl declarations
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/univ/control.h"
#elif defined(__WXMSW__)
#include "wx/msw/control.h"
#elif defined(__WXGTK__)
#include "wx/gtk/control.h"
#elif defined(__WXMAC__)
#include "wx/osx/control.h"
#elif defined(__WXQT__)
#include "wx/qt/control.h"
#endif
#endif // wxUSE_CONTROLS
#endif
// _WX_CONTROL_H_BASE_

View File

@@ -0,0 +1,165 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/convauto.h
// Purpose: wxConvAuto class declaration
// Author: Vadim Zeitlin
// Created: 2006-04-03
// Copyright: (c) 2006 Vadim Zeitlin
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONVAUTO_H_
#define _WX_CONVAUTO_H_
#include "wx/strconv.h"
#include "wx/fontenc.h"
// ----------------------------------------------------------------------------
// wxConvAuto: uses BOM to automatically detect input encoding
// ----------------------------------------------------------------------------
// All currently recognized BOM values.
enum wxBOM
{
wxBOM_Unknown = -1,
wxBOM_None,
wxBOM_UTF32BE,
wxBOM_UTF32LE,
wxBOM_UTF16BE,
wxBOM_UTF16LE,
wxBOM_UTF8
};
class WXDLLIMPEXP_BASE wxConvAuto : public wxMBConv
{
public:
// default ctor, the real conversion will be created on demand
wxConvAuto(wxFontEncoding enc = wxFONTENCODING_DEFAULT)
{
Init();
m_encDefault = enc;
}
// copy ctor doesn't initialize anything either as conversion can only be
// deduced on first use
wxConvAuto(const wxConvAuto& other) : wxMBConv()
{
Init();
m_encDefault = other.m_encDefault;
}
virtual ~wxConvAuto()
{
if ( m_ownsConv )
delete m_conv;
}
// get/set the fall-back encoding used when the input text doesn't have BOM
// and isn't UTF-8
//
// special values are wxFONTENCODING_MAX meaning not to use any fall back
// at all (but just fail to convert in this case) and wxFONTENCODING_SYSTEM
// meaning to use the encoding of the system locale
static wxFontEncoding GetFallbackEncoding() { return ms_defaultMBEncoding; }
static void SetFallbackEncoding(wxFontEncoding enc);
static void DisableFallbackEncoding()
{
SetFallbackEncoding(wxFONTENCODING_MAX);
}
// override the base class virtual function(s) to use our m_conv
virtual size_t ToWChar(wchar_t *dst, size_t dstLen,
const char *src, size_t srcLen = wxNO_LEN) const override;
virtual size_t FromWChar(char *dst, size_t dstLen,
const wchar_t *src, size_t srcLen = wxNO_LEN) const override;
virtual size_t GetMBNulLen() const override { return m_conv->GetMBNulLen(); }
virtual bool IsUTF8() const override { return m_conv && m_conv->IsUTF8(); }
wxNODISCARD virtual wxMBConv *Clone() const override { return new wxConvAuto(*this); }
// return the BOM type of this buffer
static wxBOM DetectBOM(const char *src, size_t srcLen);
// return the characters composing the given BOM.
static const char* GetBOMChars(wxBOM bomType, size_t* count);
wxBOM GetBOM() const
{
return m_bomType;
}
wxFontEncoding GetEncoding() const;
// Return true if the fall-back encoding is used
bool IsUsingFallbackEncoding() const
{
return m_ownsConv && m_bomType == wxBOM_None;
}
private:
// common part of all ctors
void Init()
{
// We don't initialize m_encDefault here as different ctors do it
// differently.
m_conv = nullptr;
m_bomType = wxBOM_Unknown;
m_ownsConv = false;
m_consumedBOM = false;
}
// initialize m_conv with the UTF-8 conversion
void InitWithUTF8()
{
m_conv = &wxConvUTF8;
m_ownsConv = false;
}
// create the correct conversion object for the given BOM type
void InitFromBOM(wxBOM bomType);
// create the correct conversion object for the BOM present in the
// beginning of the buffer
//
// return false if the buffer is too short to allow us to determine if we
// have BOM or not
bool InitFromInput(const char *src, size_t len);
// adjust src and len to skip over the BOM (identified by m_bomType) at the
// start of the buffer
void SkipBOM(const char **src, size_t *len) const;
// fall-back multibyte encoding to use, may be wxFONTENCODING_SYSTEM or
// wxFONTENCODING_MAX but not wxFONTENCODING_DEFAULT
static wxFontEncoding ms_defaultMBEncoding;
// conversion object which we really use, null until the first call to
// either ToWChar() or FromWChar()
wxMBConv *m_conv;
// the multibyte encoding to use by default if input isn't Unicode
wxFontEncoding m_encDefault;
// our BOM type
wxBOM m_bomType;
// true if we allocated m_conv ourselves, false if we just use an existing
// global conversion
bool m_ownsConv;
// true if we already skipped BOM when converting (and not just calculating
// the size)
bool m_consumedBOM;
wxDECLARE_NO_ASSIGN_CLASS(wxConvAuto);
};
#endif // _WX_CONVAUTO_H_

View File

@@ -0,0 +1,178 @@
/*
* Name: wx/cpp.h
* Purpose: Various preprocessor helpers
* Author: Vadim Zeitlin
* Created: 2006-09-30
* Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_CPP_H_
#define _WX_CPP_H_
#include "wx/compiler.h" /* wxCHECK_XXX_VERSION() macros */
/* wxCONCAT works like preprocessor ## operator but also works with macros */
#define wxCONCAT_HELPER(text, line) text ## line
#define wxCONCAT(x1, x2) \
wxCONCAT_HELPER(x1, x2)
#define wxCONCAT3(x1, x2, x3) \
wxCONCAT(wxCONCAT(x1, x2), x3)
#define wxCONCAT4(x1, x2, x3, x4) \
wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
#define wxCONCAT5(x1, x2, x3, x4, x5) \
wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
#define wxCONCAT6(x1, x2, x3, x4, x5, x6) \
wxCONCAT(wxCONCAT5(x1, x2, x3, x4, x5), x6)
#define wxCONCAT7(x1, x2, x3, x4, x5, x6, x7) \
wxCONCAT(wxCONCAT6(x1, x2, x3, x4, x5, x6), x7)
#define wxCONCAT8(x1, x2, x3, x4, x5, x6, x7, x8) \
wxCONCAT(wxCONCAT7(x1, x2, x3, x4, x5, x6, x7), x8)
#define wxCONCAT9(x1, x2, x3, x4, x5, x6, x7, x8, x9) \
wxCONCAT(wxCONCAT8(x1, x2, x3, x4, x5, x6, x7, x8), x9)
/* wxSTRINGIZE works as the preprocessor # operator but also works with macros */
#define wxSTRINGIZE_HELPER(x) #x
#define wxSTRINGIZE(x) wxSTRINGIZE_HELPER(x)
/* a Unicode-friendly version of wxSTRINGIZE_T */
#define wxSTRINGIZE_T(x) wxAPPLY_T(wxSTRINGIZE(x))
/*
Helper macros for wxMAKE_UNIQUE_NAME: normally this works by appending the
current line number to the given identifier to reduce the probability of the
conflict (it may still happen if this is used in the headers, hence you
should avoid doing it or provide unique prefixes then) but we have to do it
differently for VC++
*/
#if defined(__VISUALC__)
/*
__LINE__ handling is completely broken in VC++ when using "Edit and
Continue" (/ZI option) and results in preprocessor errors if we use it
inside the macros. Luckily VC7 has another standard macro which can be
used like this and is even better than __LINE__ because it is globally
unique.
*/
# define wxCONCAT_LINE(text) wxCONCAT(text, __COUNTER__)
#else /* normal compilers */
# define wxCONCAT_LINE(text) wxCONCAT(text, __LINE__)
#endif
/* Create a "unique" name with the given prefix */
#define wxMAKE_UNIQUE_NAME(text) wxCONCAT_LINE(text)
/*
This macro can be passed as argument to another macro when you don't have
anything to pass in fact.
*/
#define wxEMPTY_PARAMETER_VALUE /* Fake macro parameter value */
/*
Helpers for defining macros that expand into a single statement.
The standard solution is to use "do { ... } while (0)" statement but MSVC
generates a C4127 "condition expression is constant" warning for it so we
use something which is just complicated enough to not be recognized as a
constant but still simple enough to be optimized away.
Another solution would be to use __pragma() to temporarily disable C4127.
Notice that wxASSERT_ARG_TYPE in wx/strvargarg.h relies on these macros
creating some kind of a loop because it uses "break".
*/
#define wxSTATEMENT_MACRO_BEGIN do {
#define wxSTATEMENT_MACRO_END } while ( (void)0, 0 )
/*
Helper for executing the following statement conditionally without using
conditional statements.
This strange macro is needed in the first place to avoid the problems due
to nested if/else inside macros. E.g. if some MACRO started with "if", then
if ( cond )
MACRO();
else
...
would be broken because "..." would bind to the wrong "if" inside the macro
rather than the visible one. So we use wxDO_IF() inside the macro instead
to avoid this problem.
*/
#define wxDO_IF_HELPER(loopvar, condition) \
for ( bool loopvar = false; !loopvar && condition; loopvar = true )
#define wxDO_IF(condition) wxDO_IF_HELPER(wxMAKE_UNIQUE_NAME(wxdoif), condition)
/*
This macro is obsolete, use standard __func__ instead.
*/
#ifndef __WXFUNCTION__
#define __WXFUNCTION__ __func__
#endif /* __WXFUNCTION__ already defined */
/*
Expands to the current function's full signature, if available.
Falls back to the function name (i.e., __func__) if not available.
*/
#ifndef __WXFUNCTION_SIG__
#if defined(__VISUALC__)
#define __WXFUNCTION_SIG__ __FUNCSIG__
#elif defined(__GNUG__)
#define __WXFUNCTION_SIG__ __PRETTY_FUNCTION__
#else
#define __WXFUNCTION_SIG__ __func__
#endif
#endif /* __WXFUNCTION_SIG__ already defined */
/*
wxCALL_FOR_EACH(what, ...) calls the macro from its first argument, what(pos, x),
for every remaining argument 'x', with 'pos' being its 1-based index in
*reverse* order (with the last argument being numbered 1).
For example, wxCALL_FOR_EACH(test, a, b, c) expands into this:
test(3, a) \
test(2, b) \
test(1, c)
Up to eight arguments are supported.
(With thanks to https://groups.google.com/d/topic/comp.std.c/d-6Mj5Lko_s/discussion
and https://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros)
*/
#define wxCALL_FOR_EACH_NARG(...) wxCALL_FOR_EACH_NARG_((__VA_ARGS__, wxCALL_FOR_EACH_RSEQ_N()))
#define wxCALL_FOR_EACH_NARG_(args) wxCALL_FOR_EACH_ARG_N args
#define wxCALL_FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
#define wxCALL_FOR_EACH_RSEQ_N() 8, 7, 6, 5, 4, 3, 2, 1, 0
#define wxCALL_FOR_EACH_1_(args) wxCALL_FOR_EACH_1 args
#define wxCALL_FOR_EACH_2_(args) wxCALL_FOR_EACH_2 args
#define wxCALL_FOR_EACH_3_(args) wxCALL_FOR_EACH_3 args
#define wxCALL_FOR_EACH_4_(args) wxCALL_FOR_EACH_4 args
#define wxCALL_FOR_EACH_5_(args) wxCALL_FOR_EACH_5 args
#define wxCALL_FOR_EACH_6_(args) wxCALL_FOR_EACH_6 args
#define wxCALL_FOR_EACH_7_(args) wxCALL_FOR_EACH_7 args
#define wxCALL_FOR_EACH_8_(args) wxCALL_FOR_EACH_8 args
#define wxCALL_FOR_EACH_1(what, x) what(1, x)
#define wxCALL_FOR_EACH_2(what, x, ...) what(2, x) wxCALL_FOR_EACH_1_((what, __VA_ARGS__))
#define wxCALL_FOR_EACH_3(what, x, ...) what(3, x) wxCALL_FOR_EACH_2_((what, __VA_ARGS__))
#define wxCALL_FOR_EACH_4(what, x, ...) what(4, x) wxCALL_FOR_EACH_3_((what, __VA_ARGS__))
#define wxCALL_FOR_EACH_5(what, x, ...) what(5, x) wxCALL_FOR_EACH_4_((what, __VA_ARGS__))
#define wxCALL_FOR_EACH_6(what, x, ...) what(6, x) wxCALL_FOR_EACH_5_((what, __VA_ARGS__))
#define wxCALL_FOR_EACH_7(what, x, ...) what(7, x) wxCALL_FOR_EACH_6_((what, __VA_ARGS__))
#define wxCALL_FOR_EACH_8(what, x, ...) what(8, x) wxCALL_FOR_EACH_7_((what, __VA_ARGS__))
#define wxCALL_FOR_EACH_(N, args) \
wxCONCAT(wxCALL_FOR_EACH_, N) args
#define wxCALL_FOR_EACH(what, ...) \
wxCALL_FOR_EACH_(wxCALL_FOR_EACH_NARG(__VA_ARGS__), (what, __VA_ARGS__))
#endif /* _WX_CPP_H_ */

View File

@@ -0,0 +1,15 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/creddlg.h
// Purpose: wxCredentialEntryDialog interface
// Author: Tobias Taschner
// Created: 2018-10-23
// Copyright: (c) 2018 wxWidgets development team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CREDDLG_H_BASE
#define _WX_CREDDLG_H_BASE
#include "wx/generic/creddlgg.h"
#endif // _WX_CREDDLG_H_BASE

View File

@@ -0,0 +1,22 @@
//////////////////////////////////////////////////////////////////////////////
// Name: wx/crt.h
// Purpose: Header to include all headers with wrappers for CRT functions
// Author: Robert Roebling
// Created: 2007-05-30
// Copyright: (c) 2007 wxWidgets dev team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CRT_H_
#define _WX_CRT_H_
#include "wx/defs.h"
// include wxChar type definition:
#include "wx/chartype.h"
// and wrappers for CRT functions:
#include "wx/wxcrt.h"
#include "wx/wxcrtvararg.h"
#endif // _WX_CRT_H_

View File

@@ -0,0 +1,253 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cshelp.h
// Purpose: Context-sensitive help support classes
// Author: Julian Smart, Vadim Zeitlin
// Created: 08/09/2000
// Copyright: (c) 2000 Julian Smart, Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CSHELP_H_
#define _WX_CSHELP_H_
#include "wx/defs.h"
#if wxUSE_HELP
#include "wx/help.h"
#if wxUSE_BMPBUTTON
#include "wx/bmpbuttn.h"
#endif
#include "wx/event.h"
#include <unordered_map>
// ----------------------------------------------------------------------------
// classes used to implement context help UI
// ----------------------------------------------------------------------------
/*
* wxContextHelp
* Invokes context-sensitive help. When the user
* clicks on a window, a wxEVT_HELP event will be sent to that
* window for the application to display help for.
*/
class WXDLLIMPEXP_CORE wxContextHelp : public wxObject
{
public:
wxContextHelp(wxWindow* win = nullptr, bool beginHelp = true);
virtual ~wxContextHelp();
bool BeginContextHelp(wxWindow* win);
bool EndContextHelp();
bool EventLoop();
bool DispatchEvent(wxWindow* win, const wxPoint& pt);
void SetStatus(bool status) { m_status = status; }
protected:
bool m_inHelp;
bool m_status; // true if the user left-clicked
private:
wxDECLARE_DYNAMIC_CLASS(wxContextHelp);
};
#if wxUSE_BMPBUTTON
/*
* wxContextHelpButton
* You can add this to your dialogs (especially on non-Windows platforms)
* to put the application into context help mode.
*/
class WXDLLIMPEXP_CORE wxContextHelpButton : public wxBitmapButton
{
public:
wxContextHelpButton() = default;
wxContextHelpButton(wxWindow* parent,
wxWindowID id = wxID_CONTEXT_HELP,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0)
{
Create(parent, id, pos, size, style);
}
bool Create(wxWindow* parent,
wxWindowID id = wxID_CONTEXT_HELP,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
void OnContextHelp(wxCommandEvent& event);
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxContextHelpButton);
wxDECLARE_EVENT_TABLE();
};
#endif
// ----------------------------------------------------------------------------
// classes used to implement context help support
// ----------------------------------------------------------------------------
// wxHelpProvider is an abstract class used by the program implementing context help to
// show the help text (or whatever: it may be HTML page or anything else) for
// the given window.
//
// The current help provider must be explicitly set by the application using
// wxHelpProvider::Set().
//
// Special note about ShowHelpAtPoint() and ShowHelp(): we want to be able to
// override ShowHelpAtPoint() when we need to use different help messages for
// different parts of the window, but it should also be possible to override
// just ShowHelp() both for backwards compatibility and just because most
// often the help does not, in fact, depend on the position and so
// implementing just ShowHelp() is simpler and more natural, so by default
// ShowHelpAtPoint() forwards to ShowHelp(). But this means that
// wxSimpleHelpProvider has to override ShowHelp() and not ShowHelpAtPoint()
// for backwards compatibility as otherwise the existing code deriving from it
// and overriding ShowHelp() but calling the base class version wouldn't work
// any more, which forces us to use a rather ugly hack and pass the extra
// parameters of ShowHelpAtPoint() to ShowHelp() via member variables.
class WXDLLIMPEXP_CORE wxHelpProvider
{
public:
// get/set the current (application-global) help provider (Set() returns
// the previous one)
static wxHelpProvider *Set(wxHelpProvider *helpProvider)
{
wxHelpProvider *helpProviderOld = ms_helpProvider;
ms_helpProvider = helpProvider;
return helpProviderOld;
}
// unlike some other class, the help provider is not created on demand,
// this must be explicitly done by the application
static wxHelpProvider *Get() { return ms_helpProvider; }
// get the help string (whose interpretation is help provider dependent
// except that empty string always means that no help is associated with
// the window) for this window
virtual wxString GetHelp(const wxWindowBase *window) = 0;
// do show help for the given window (uses window->GetHelpAtPoint()
// internally if applicable), return true if it was done or false
// if no help available for this window
virtual bool ShowHelpAtPoint(wxWindowBase *window,
const wxPoint& pt,
wxHelpEvent::Origin origin)
{
wxCHECK_MSG( window, false, wxT("window must not be null") );
m_helptextAtPoint = pt;
m_helptextOrigin = origin;
return ShowHelp(window);
}
// show help for the given window, see ShowHelpAtPoint() above
virtual bool ShowHelp(wxWindowBase * WXUNUSED(window)) { return false; }
// associate the text with the given window or id: although all help
// providers have these functions to allow making wxWindow::SetHelpText()
// work, not all of them implement them
virtual void AddHelp(wxWindowBase *window, const wxString& text);
// this version associates the given text with all window with this id
// (may be used to set the same help string for all [Cancel] buttons in
// the application, for example)
virtual void AddHelp(wxWindowID id, const wxString& text);
// removes the association
virtual void RemoveHelp(wxWindowBase* window);
// virtual dtor for any base class
virtual ~wxHelpProvider();
protected:
wxHelpProvider()
: m_helptextAtPoint(wxDefaultPosition),
m_helptextOrigin(wxHelpEvent::Origin_Unknown)
{
}
// helper method used by ShowHelp(): returns the help string to use by
// using m_helptextAtPoint/m_helptextOrigin if they're set or just GetHelp
// otherwise
wxString GetHelpTextMaybeAtPoint(wxWindowBase *window);
// parameters of the last ShowHelpAtPoint() call, used by ShowHelp()
wxPoint m_helptextAtPoint;
wxHelpEvent::Origin m_helptextOrigin;
private:
static wxHelpProvider *ms_helpProvider;
};
// wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
// only plain text help strings and shows the string associated with the
// control (if any) in a tooltip
class WXDLLIMPEXP_CORE wxSimpleHelpProvider : public wxHelpProvider
{
public:
// implement wxHelpProvider methods
virtual wxString GetHelp(const wxWindowBase *window) override;
// override ShowHelp() and not ShowHelpAtPoint() as explained above
virtual bool ShowHelp(wxWindowBase *window) override;
virtual void AddHelp(wxWindowBase *window, const wxString& text) override;
virtual void AddHelp(wxWindowID id, const wxString& text) override;
virtual void RemoveHelp(wxWindowBase* window) override;
private:
// we use 2 hashes for storing the help strings associated with windows
// and the ids
std::unordered_map<const wxWindowBase*, wxString> m_hashWindows;
std::unordered_map<wxWindowID, wxString> m_hashIds;
};
// wxHelpControllerHelpProvider is an implementation of wxHelpProvider which supports
// both context identifiers and plain text help strings. If the help text is an integer,
// it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the string
// in a tooltip as per wxSimpleHelpProvider.
class WXDLLIMPEXP_CORE wxHelpControllerHelpProvider : public wxSimpleHelpProvider
{
public:
// Note that it doesn't own the help controller. The help controller
// should be deleted separately.
wxHelpControllerHelpProvider(wxHelpControllerBase* hc = nullptr);
// implement wxHelpProvider methods
// again (see above): this should be ShowHelpAtPoint() but we need to
// override ShowHelp() to avoid breaking existing code
virtual bool ShowHelp(wxWindowBase *window) override;
// Other accessors
void SetHelpController(wxHelpControllerBase* hc) { m_helpController = hc; }
wxHelpControllerBase* GetHelpController() const { return m_helpController; }
protected:
wxHelpControllerBase* m_helpController;
wxDECLARE_NO_COPY_CLASS(wxHelpControllerHelpProvider);
};
// Convenience function for turning context id into wxString
WXDLLIMPEXP_CORE wxString wxContextId(int id);
#endif // wxUSE_HELP
#endif // _WX_CSHELP_H_

View File

@@ -0,0 +1,485 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/ctrlsub.h (read: "wxConTRoL with SUBitems")
// Purpose: wxControlWithItems interface
// Author: Vadim Zeitlin
// Created: 22.10.99
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CTRLSUB_H_BASE_
#define _WX_CTRLSUB_H_BASE_
#include "wx/defs.h"
#if wxUSE_CONTROLS
#include "wx/arrstr.h"
#include "wx/control.h" // base class
#include <vector>
// ----------------------------------------------------------------------------
// wxItemContainer defines an interface which is implemented by all controls
// which have string subitems each of which may be selected.
//
// It is decomposed in wxItemContainerImmutable which omits all methods
// adding/removing items and is used by wxRadioBox and wxItemContainer itself.
//
// Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox (which
// implements an extended interface deriving from this one)
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxItemContainerImmutable
{
public:
wxItemContainerImmutable() = default;
virtual ~wxItemContainerImmutable();
// accessing strings
// -----------------
virtual unsigned int GetCount() const = 0;
bool IsEmpty() const { return GetCount() == 0; }
virtual wxString GetString(unsigned int n) const = 0;
wxArrayString GetStrings() const;
virtual void SetString(unsigned int n, const wxString& s) = 0;
// finding string natively is either case sensitive or insensitive
// but never both so fall back to this base version for not
// supported search type
virtual int FindString(const wxString& s, bool bCase = false) const
{
unsigned int count = GetCount();
for ( unsigned int i = 0; i < count ; ++i )
{
if (GetString(i).IsSameAs( s , bCase ))
return (int)i;
}
return wxNOT_FOUND;
}
// selection
// ---------
virtual void SetSelection(int n) = 0;
virtual int GetSelection() const = 0;
// set selection to the specified string, return false if not found
bool SetStringSelection(const wxString& s);
// return the selected string or empty string if none
virtual wxString GetStringSelection() const;
// this is the same as SetSelection( for single-selection controls but
// reads better for multi-selection ones
void Select(int n) { SetSelection(n); }
protected:
// check that the index is valid
bool IsValid(unsigned int n) const { return n < GetCount(); }
bool IsValidInsert(unsigned int n) const { return n <= GetCount(); }
};
// ----------------------------------------------------------------------------
// wxItemContainer extends wxItemContainerImmutable interface with methods
// for adding/removing items.
//
// Classes deriving from this one must override DoInsertItems() to implement
// adding items to the control. This can often be implemented more efficiently
// than simply looping over the elements and inserting them but if this is not
// the case, the generic DoInsertItemsInLoop can be used in implementation, but
// in this case DoInsertItem() needs to be overridden.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxItemContainer : public wxItemContainerImmutable
{
private:
// AppendItems() and InsertItems() helpers just call DoAppend/InsertItems()
// after doing some checks
//
// NB: they're defined here so that they're inlined when used in public part
int AppendItems(const wxArrayStringsAdapter& items,
void **clientData,
wxClientDataType type)
{
if ( items.IsEmpty() )
return wxNOT_FOUND;
return DoAppendItems(items, clientData, type);
}
int AppendItems(const wxArrayStringsAdapter& items)
{
return AppendItems(items, nullptr, wxClientData_None);
}
int AppendItems(const wxArrayStringsAdapter& items, void **clientData)
{
wxASSERT_MSG( GetClientDataType() != wxClientData_Object,
wxT("can't mix different types of client data") );
return AppendItems(items, clientData, wxClientData_Void);
}
int AppendItems(const wxArrayStringsAdapter& items,
wxClientData **clientData)
{
wxASSERT_MSG( GetClientDataType() != wxClientData_Void,
wxT("can't mix different types of client data") );
return AppendItems(items, reinterpret_cast<void **>(clientData),
wxClientData_Object);
}
int InsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData,
wxClientDataType type)
{
wxASSERT_MSG( !IsSorted(), wxT("can't insert items in sorted control") );
wxCHECK_MSG( pos <= GetCount(), wxNOT_FOUND,
wxT("position out of range") );
// not all derived classes handle empty arrays correctly in
// DoInsertItems() and besides it really doesn't make much sense to do
// this (for append it could correspond to creating an initially empty
// control but why would anybody need to insert 0 items?)
wxCHECK_MSG( !items.IsEmpty(), wxNOT_FOUND,
wxT("need something to insert") );
return DoInsertItems(items, pos, clientData, type);
}
int InsertItems(const wxArrayStringsAdapter& items, unsigned int pos)
{
return InsertItems(items, pos, nullptr, wxClientData_None);
}
int InsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData)
{
wxASSERT_MSG( GetClientDataType() != wxClientData_Object,
wxT("can't mix different types of client data") );
return InsertItems(items, pos, clientData, wxClientData_Void);
}
int InsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
wxClientData **clientData)
{
wxASSERT_MSG( GetClientDataType() != wxClientData_Void,
wxT("can't mix different types of client data") );
return InsertItems(items, pos,
reinterpret_cast<void **>(clientData),
wxClientData_Object);
}
public:
wxItemContainer() { m_clientDataItemsType = wxClientData_None; }
virtual ~wxItemContainer();
// adding items
// ------------
// append single item, return its position in the control (which can be
// different from the last one if the control is sorted)
int Append(const wxString& item)
{ return AppendItems(item); }
int Append(const wxString& item, void *clientData)
{ return AppendItems(item, &clientData); }
int Append(const wxString& item, wxClientData *clientData)
{ return AppendItems(item, &clientData); }
// append several items at once to the control, return the position of the
// last item appended
int Append(const wxArrayString& items)
{ return AppendItems(items); }
int Append(const wxArrayString& items, void **clientData)
{ return AppendItems(items, clientData); }
int Append(const wxArrayString& items, wxClientData **clientData)
{ return AppendItems(items, clientData); }
int Append(unsigned int n, const wxString *items)
{ return AppendItems(wxArrayStringsAdapter(n, items)); }
int Append(unsigned int n, const wxString *items, void **clientData)
{ return AppendItems(wxArrayStringsAdapter(n, items), clientData); }
int Append(unsigned int n,
const wxString *items,
wxClientData **clientData)
{ return AppendItems(wxArrayStringsAdapter(n, items), clientData); }
int Append(const std::vector<wxString>& items)
{ return AppendItems(items); }
// only for RTTI needs (separate name)
void AppendString(const wxString& item)
{ Append(item); }
// inserting items: not for sorted controls!
// -----------------------------------------
// insert single item at the given position, return its effective position
int Insert(const wxString& item, unsigned int pos)
{ return InsertItems(item, pos); }
int Insert(const wxString& item, unsigned int pos, void *clientData)
{ return InsertItems(item, pos, &clientData); }
int Insert(const wxString& item, unsigned int pos, wxClientData *clientData)
{ return InsertItems(item, pos, &clientData); }
// insert several items at once into the control, return the index of the
// last item inserted
int Insert(const wxArrayString& items, unsigned int pos)
{ return InsertItems(items, pos); }
int Insert(const wxArrayString& items, unsigned int pos, void **clientData)
{ return InsertItems(items, pos, clientData); }
int Insert(const wxArrayString& items,
unsigned int pos,
wxClientData **clientData)
{ return InsertItems(items, pos, clientData); }
int Insert(unsigned int n, const wxString *items, unsigned int pos)
{ return InsertItems(wxArrayStringsAdapter(n, items), pos); }
int Insert(unsigned int n,
const wxString *items,
unsigned int pos,
void **clientData)
{ return InsertItems(wxArrayStringsAdapter(n, items), pos, clientData); }
int Insert(unsigned int n,
const wxString *items,
unsigned int pos,
wxClientData **clientData)
{ return InsertItems(wxArrayStringsAdapter(n, items), pos, clientData); }
int Insert(const std::vector<wxString>& items, unsigned int pos)
{ return InsertItems(items, pos); }
// replacing items
// ---------------
void Set(const wxArrayString& items)
{ Clear(); Append(items); }
void Set(const wxArrayString& items, void **clientData)
{ Clear(); Append(items, clientData); }
void Set(const wxArrayString& items, wxClientData **clientData)
{ Clear(); Append(items, clientData); }
void Set(unsigned int n, const wxString *items)
{ Clear(); Append(n, items); }
void Set(unsigned int n, const wxString *items, void **clientData)
{ Clear(); Append(n, items, clientData); }
void Set(unsigned int n, const wxString *items, wxClientData **clientData)
{ Clear(); Append(n, items, clientData); }
void Set(const std::vector<wxString>& items)
{ Clear(); Append(items); }
// deleting items
// --------------
virtual void Clear();
void Delete(unsigned int pos);
// various accessors
// -----------------
// The control may maintain its items in a sorted order in which case
// items are automatically inserted at the right position when they are
// inserted or appended. Derived classes have to override this method if
// they implement sorting, typically by returning HasFlag(wxXX_SORT)
virtual bool IsSorted() const { return false; }
// client data stuff
// -----------------
void SetClientData(unsigned int n, void* clientData);
void* GetClientData(unsigned int n) const;
// SetClientObject() takes ownership of the pointer, GetClientObject()
// returns it but keeps the ownership while DetachClientObject() expects
// the caller to delete the pointer and also resets the internally stored
// one to nullptr for this item
void SetClientObject(unsigned int n, wxClientData* clientData);
wxClientData* GetClientObject(unsigned int n) const;
wxClientData* DetachClientObject(unsigned int n);
// return the type of client data stored in this control: usually it just
// returns m_clientDataItemsType but must be overridden in the controls
// which delegate their client data storage to another one (e.g. wxChoice
// in wxUniv which stores data in wxListBox which it uses anyhow); don't
// forget to override SetClientDataType() if you override this one
//
// NB: for this to work no code should ever access m_clientDataItemsType
// directly but only via this function!
virtual wxClientDataType GetClientDataType() const
{ return m_clientDataItemsType; }
bool HasClientData() const
{ return GetClientDataType() != wxClientData_None; }
bool HasClientObjectData() const
{ return GetClientDataType() == wxClientData_Object; }
bool HasClientUntypedData() const
{ return GetClientDataType() == wxClientData_Void; }
protected:
// there is usually no need to override this method but you can do it if it
// is more convenient to only do "real" insertions in DoInsertItems() and
// to implement items appending here (in which case DoInsertItems() should
// call this method if pos == GetCount() as it can still be called in this
// case if public Insert() is called with such position)
virtual int DoAppendItems(const wxArrayStringsAdapter& items,
void **clientData,
wxClientDataType type)
{
return DoInsertItems(items, GetCount(), clientData, type);
}
// this method must be implemented to insert the items into the control at
// position pos which can be GetCount() meaning that the items should be
// appended; for the sorted controls the position can be ignored
//
// the derived classes typically use AssignNewItemClientData() to
// associate the data with the items as they're being inserted
//
// the method should return the index of the position the last item was
// inserted into or wxNOT_FOUND if an error occurred
virtual int DoInsertItems(const wxArrayStringsAdapter & items,
unsigned int pos,
void **clientData,
wxClientDataType type) = 0;
// before the client data is set for the first time for the control which
// hadn't had it before, DoInitItemClientData() is called which gives the
// derived class the possibility to initialize its client data storage only
// when client data is really used
virtual void DoInitItemClientData() { }
virtual void DoSetItemClientData(unsigned int n, void *clientData) = 0;
virtual void *DoGetItemClientData(unsigned int n) const = 0;
virtual void DoClear() = 0;
virtual void DoDeleteOneItem(unsigned int pos) = 0;
// methods useful for the derived classes which don't have any better way
// of adding multiple items to the control than doing it one by one: such
// classes should call DoInsertItemsInLoop() from their DoInsert() and
// override DoInsertOneItem() to perform the real insertion
virtual int DoInsertOneItem(const wxString& item, unsigned int pos);
int DoInsertItemsInLoop(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData,
wxClientDataType type);
// helper for DoInsertItems(): n is the index into clientData, pos is the
// position of the item in the control
void AssignNewItemClientData(unsigned int pos,
void **clientData,
unsigned int n,
wxClientDataType type);
// free the client object associated with the item at given position and
// set it to nullptr (must only be called if HasClientObjectData())
void ResetItemClientObject(unsigned int n);
// set the type of the client data stored in this control: override this if
// you override GetClientDataType()
virtual void SetClientDataType(wxClientDataType clientDataItemsType)
{
m_clientDataItemsType = clientDataItemsType;
}
private:
// the type of the client data for the items
wxClientDataType m_clientDataItemsType;
};
// Inheriting directly from a wxWindow-derived class and wxItemContainer
// unfortunately introduces an ambiguity for all GetClientXXX() methods as they
// are inherited twice: the "global" versions from wxWindow and the per-item
// versions taking the index from wxItemContainer.
//
// So we need to explicitly resolve them and this helper template class is
// provided to do it. To use it, simply inherit from wxWindowWithItems<Window,
// Container> instead of Window and Container interface directly.
template <class W, class C>
class wxWindowWithItems : public W, public C
{
public:
typedef W BaseWindowClass;
typedef C BaseContainerInterface;
wxWindowWithItems() = default;
void SetClientData(void *data)
{ BaseWindowClass::SetClientData(data); }
void *GetClientData() const
{ return BaseWindowClass::GetClientData(); }
void SetClientObject(wxClientData *data)
{ BaseWindowClass::SetClientObject(data); }
wxClientData *GetClientObject() const
{ return BaseWindowClass::GetClientObject(); }
void SetClientData(unsigned int n, void* clientData)
{ wxItemContainer::SetClientData(n, clientData); }
void* GetClientData(unsigned int n) const
{ return wxItemContainer::GetClientData(n); }
void SetClientObject(unsigned int n, wxClientData* clientData)
{ wxItemContainer::SetClientObject(n, clientData); }
wxClientData* GetClientObject(unsigned int n) const
{ return wxItemContainer::GetClientObject(n); }
};
class WXDLLIMPEXP_CORE wxControlWithItemsBase :
public wxWindowWithItems<wxControl, wxItemContainer>
{
public:
wxControlWithItemsBase() = default;
// usually the controls like list/combo boxes have their own background
// colour
virtual bool ShouldInheritColours() const override { return false; }
// Implementation only from now on.
// Generate an event of the given type for the selection change.
void SendSelectionChangedEvent(wxEventType eventType);
protected:
// fill in the client object or data field of the event as appropriate
//
// calls InitCommandEvent() and, if n != wxNOT_FOUND, also sets the per
// item client data
void InitCommandEventWithItems(wxCommandEvent& event, int n);
private:
wxDECLARE_NO_COPY_CLASS(wxControlWithItemsBase);
};
// define the platform-specific wxControlWithItems class
#if defined(__WXMSW__)
#include "wx/msw/ctrlsub.h"
#elif defined(__WXQT__)
#include "wx/qt/ctrlsub.h"
#else
class WXDLLIMPEXP_CORE wxControlWithItems : public wxControlWithItemsBase
{
public:
wxControlWithItems() = default;
private:
wxDECLARE_ABSTRACT_CLASS(wxControlWithItems);
wxDECLARE_NO_COPY_CLASS(wxControlWithItems);
};
#endif
#endif // wxUSE_CONTROLS
#endif // _WX_CTRLSUB_H_BASE_

View File

@@ -0,0 +1,153 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cursor.h
// Purpose: wxCursor base header
// Author: Julian Smart, Vadim Zeitlin
// Created:
// Copyright: (c) Julian Smart
// (c) 2014 Vadim Zeitlin (wxCursorBase)
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CURSOR_H_BASE_
#define _WX_CURSOR_H_BASE_
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
// Under most ports, wxCursor derives directly from wxGDIObject, but in wxMSW
// there is an intermediate wxGDIImage class.
#ifdef __WXMSW__
#include "wx/msw/gdiimage.h"
#else
typedef wxGDIObject wxGDIImage;
#endif
class WXDLLIMPEXP_FWD_CORE wxBitmapBundle;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_CORE wxCursorBase : public wxGDIImage
{
public:
/*
wxCursor classes should provide the following ctors:
wxCursor();
wxCursor(const wxImage& image);
wxCursor(const wxBitmap& bitmap, const wxPoint& hotSpot);
wxCursor(const wxBitmap& bitmap, int hotSpotX = 0, int hotSpotY = 0);
wxCursor(const wxString& name, wxBitmapType type, const wxPoint& hotSpot);
wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor id) { InitFromStock(id); }
*/
virtual wxPoint GetHotSpot() const { return wxDefaultPosition; }
};
#if defined(__WXMSW__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/msw/cursor.h"
#elif defined(__WXGTK__)
#ifdef __WINDOWS__
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#else
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#endif
#include "wx/gtk/cursor.h"
#elif defined(__WXX11__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/x11/cursor.h"
#elif defined(__WXDFB__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/dfb/cursor.h"
#elif defined(__WXMAC__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE
#include "wx/osx/cursor.h"
#elif defined(__WXQT__)
#ifdef __WINDOWS__
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#else
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR
#endif
#include "wx/qt/cursor.h"
#endif
// ----------------------------------------------------------------------------
// wxCursorBundle stores 1 or more versions of the same cursor, to be used at
// different DPI scaling levels.
// ----------------------------------------------------------------------------
class wxCursorBundleImpl;
class WXDLLIMPEXP_CORE wxCursorBundle
{
public:
// Default ctor constructs an empty bundle which can't be used for
// anything, but can be assigned something later.
wxCursorBundle();
// Create a cursor bundle from the given bitmap bundle.
//
// Note that the hotspot coordinates must be relative to the default size
// of the bitmap bundle and are scaled for other sizes.
explicit wxCursorBundle(const wxBitmapBundle& bitmaps,
const wxPoint& hotSpot);
explicit wxCursorBundle(const wxBitmapBundle& bitmaps,
int hotSpotX = 0, int hotSpotY = 0)
: wxCursorBundle(bitmaps, wxPoint(hotSpotX, hotSpotY))
{
}
// This conversion ctor from a single cursor only exists for
// interoperability with the existing code using wxCursor.
wxCursorBundle(const wxCursor& cursor);
// This is another conversion ctor existing to allow existing code using
// wxCursor to work without changes with wxCursorBundle.
wxCursorBundle(wxStockCursor id);
// Default copy ctor and assignment operator and dtor would be ok, but need
// to be defined out of line, where wxCursorBundleImpl is fully declared.
wxCursorBundle(const wxCursorBundle& other);
wxCursorBundle& operator=(const wxCursorBundle& other);
~wxCursorBundle();
// Check if cursor bundle is non-empty.
wxNODISCARD bool IsOk() const { return m_impl.get() != nullptr; }
// Clear the bundle contents, IsOk() will return false after doing this.
void Clear();
// Get the cursor of the size suitable for the DPI used by the given window.
wxNODISCARD wxCursor GetCursorFor(const wxWindow* window) const;
// Get the cursor of the default size: prefer to use GetCursorFor() instead
// if there is a suitable window available, this function only exists as
// last resort.
wxNODISCARD wxCursor GetCursorForMainWindow() const;
// Check if two objects refer to the same bundle.
wxNODISCARD bool IsSameAs(const wxCursorBundle& other) const
{
return m_impl == other.m_impl;
}
private:
using ImplPtr = wxObjectDataPtr<wxCursorBundleImpl>;
// Private ctor used by static factory functions to create objects of this
// class. It takes ownership of the pointer (which must be non-null).
explicit wxCursorBundle(const ImplPtr& impl);
ImplPtr m_impl;
};
// For compatibility, include busy cursor-related stuff which used to be pulled
// in by this header via wx/utils.h.
#include "wx/busycursor.h"
#endif // _WX_CURSOR_H_BASE_

View File

@@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/custombgwin.h
// Purpose: Class adding support for custom window backgrounds.
// Author: Vadim Zeitlin
// Created: 2011-10-10
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CUSTOMBGWIN_H_
#define _WX_CUSTOMBGWIN_H_
#include "wx/defs.h"
class WXDLLIMPEXP_FWD_CORE wxBitmap;
// ----------------------------------------------------------------------------
// wxCustomBackgroundWindow: Adds support for custom backgrounds to any
// wxWindow-derived class.
// ----------------------------------------------------------------------------
class wxCustomBackgroundWindowBase
{
public:
// Trivial default ctor.
wxCustomBackgroundWindowBase() = default;
// Also a trivial but virtual -- to suppress g++ warnings -- dtor.
virtual ~wxCustomBackgroundWindowBase() = default;
// Use the given bitmap to tile the background of this window. This bitmap
// will show through any transparent children.
//
// Notice that you must not prevent the base class EVT_ERASE_BACKGROUND
// handler from running (i.e. not to handle this event yourself) for this
// to work.
void SetBackgroundBitmap(const wxBitmap& bmp)
{
DoSetBackgroundBitmap(bmp);
}
protected:
virtual void DoSetBackgroundBitmap(const wxBitmap& bmp) = 0;
wxDECLARE_NO_COPY_CLASS(wxCustomBackgroundWindowBase);
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/custombgwin.h"
#elif defined(__WXMSW__)
#include "wx/msw/custombgwin.h"
#else
#include "wx/generic/custombgwin.h"
#endif
#endif // _WX_CUSTOMBGWIN_H_

View File

@@ -0,0 +1,591 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dataobj.h
// Purpose: common data object classes
// Author: Vadim Zeitlin, Robert Roebling
// Created: 26.05.99
// Copyright: (c) wxWidgets Team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAOBJ_H_BASE_
#define _WX_DATAOBJ_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#if wxUSE_DATAOBJ
#include "wx/string.h"
#include "wx/bitmap.h"
#include "wx/arrstr.h"
#include <memory>
#include <vector>
// ============================================================================
/*
Generic data transfer related classes. The class hierarchy is as follows:
- wxDataObject-
/ \
/ \
wxDataObjectSimple wxDataObjectComposite
/ | \
/ | \
wxTextDataObject | wxBitmapDataObject
|
wxCustomDataObject
|
|
wxImageDataObject
*/
// ============================================================================
// ----------------------------------------------------------------------------
// wxDataFormat class is declared in platform-specific headers: it represents
// a format for data which may be either one of the standard ones (text,
// bitmap, ...) or a custom one which is then identified by a unique string.
// ----------------------------------------------------------------------------
/* the class interface looks like this (pseudo code):
class wxDataFormat
{
public:
typedef <integral type> NativeFormat;
wxDataFormat(NativeFormat format = wxDF_INVALID);
wxDataFormat(const wxString& format);
wxDataFormat& operator=(NativeFormat format);
wxDataFormat& operator=(const wxDataFormat& format);
bool operator==(NativeFormat format) const;
bool operator!=(NativeFormat format) const;
void SetType(NativeFormat format);
NativeFormat GetType() const;
wxString GetId() const;
void SetId(const wxString& format);
};
*/
#if defined(__WXMSW__)
#include "wx/msw/ole/dataform.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dataform.h"
#elif defined(__WXX11__)
#include "wx/x11/dataform.h"
#elif defined(__WXMAC__)
#include "wx/osx/dataform.h"
#elif defined(__WXQT__)
#include "wx/qt/dataform.h"
#endif
// the value for default argument to some functions (corresponds to
// wxDF_INVALID)
extern WXDLLIMPEXP_CORE const wxDataFormat& wxFormatInvalid;
// ----------------------------------------------------------------------------
// wxDataObject represents a piece of data which knows which formats it
// supports and knows how to render itself in each of them - GetDataHere(),
// and how to restore data from the buffer (SetData()).
//
// Although this class may be used directly (i.e. custom classes may be
// derived from it), in many cases it might be simpler to use either
// wxDataObjectSimple or wxDataObjectComposite classes.
//
// A data object may be "read only", i.e. support only GetData() functions or
// "read-write", i.e. support both GetData() and SetData() (in principle, it
// might be "write only" too, but this is rare). Moreover, it doesn't have to
// support the same formats in Get() and Set() directions: for example, a data
// object containing JPEG image might accept BMPs in GetData() because JPEG
// image may be easily transformed into BMP but not in SetData(). Accordingly,
// all methods dealing with formats take an additional "direction" argument
// which is either SET or GET and which tells the function if the format needs
// to be supported by SetData() or GetDataHere().
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataObjectBase
{
public:
enum Direction
{
Get = 0x01, // format is supported by GetDataHere()
Set = 0x02, // format is supported by SetData()
Both = 0x03 // format is supported by both (unused currently)
};
// this class is polymorphic, hence it needs a virtual dtor
virtual ~wxDataObjectBase();
// get the best suited format for rendering our data
virtual wxDataFormat GetPreferredFormat(Direction dir = Get) const = 0;
// get the number of formats we support
virtual size_t GetFormatCount(Direction dir = Get) const = 0;
// return all formats in the provided array (of size GetFormatCount())
virtual void GetAllFormats(wxDataFormat *formats,
Direction dir = Get) const = 0;
// get the (total) size of data for the given format
virtual size_t GetDataSize(const wxDataFormat& format) const = 0;
// copy raw data (in the specified format) to the provided buffer, return
// true if data copied successfully, false otherwise
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const = 0;
// get data from the buffer of specified length (in the given format),
// return true if the data was read successfully, false otherwise
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t WXUNUSED(len), const void * WXUNUSED(buf))
{
return false;
}
// returns true if this format is supported
bool IsSupported(const wxDataFormat& format, Direction dir = Get) const;
};
// ----------------------------------------------------------------------------
// include the platform-specific declarations of wxDataObject
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/dataobj.h"
#elif defined(__WXX11__)
#include "wx/x11/dataobj.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dataobj.h"
#elif defined(__WXMAC__)
#include "wx/osx/dataobj.h"
#elif defined(__WXQT__)
#include "wx/qt/dataobj.h"
#endif
// ----------------------------------------------------------------------------
// wxDataObjectSimple is a wxDataObject which only supports one format (in
// both Get and Set directions, but you may return false from GetDataHere() or
// SetData() if one of them is not supported). This is the simplest possible
// wxDataObject implementation.
//
// This is still an "abstract base class" (although it doesn't have any pure
// virtual functions), to use it you should derive from it and implement
// GetDataSize(), GetDataHere() and SetData() functions because the base class
// versions don't do anything - they just return "not implemented".
//
// This class should be used when you provide data in only one format (no
// conversion to/from other formats), either a standard or a custom one.
// Otherwise, you should use wxDataObjectComposite or wxDataObject directly.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataObjectSimple : public wxDataObject
{
public:
// ctor takes the format we support, but it can also be set later with
// SetFormat()
wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid)
: m_format(format)
{
}
// get/set the format we support
const wxDataFormat& GetFormat() const { return m_format; }
void SetFormat(const wxDataFormat& format) { m_format = format; }
// virtual functions to override in derived class (the base class versions
// just return "not implemented")
// -----------------------------------------------------------------------
// get the size of our data
virtual size_t GetDataSize() const
{ return 0; }
// copy our data to the buffer
virtual bool GetDataHere(void *WXUNUSED(buf)) const
{ return false; }
// copy data from buffer to our data
virtual bool SetData(size_t WXUNUSED(len), const void *WXUNUSED(buf))
{ return false; }
// implement base class pure virtuals
// ----------------------------------
virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const override
{ return m_format; }
virtual size_t GetFormatCount(wxDataObjectBase::Direction WXUNUSED(dir) = Get) const override
{ return 1; }
virtual void GetAllFormats(wxDataFormat *formats,
wxDataObjectBase::Direction WXUNUSED(dir) = Get) const override
{ *formats = m_format; }
virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const override
{ return GetDataSize(); }
virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
void *buf) const override
{ return GetDataHere(buf); }
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t len, const void *buf) override
{ return SetData(len, buf); }
private:
// the one and only format we support
wxDataFormat m_format;
wxDECLARE_NO_COPY_CLASS(wxDataObjectSimple);
};
// ----------------------------------------------------------------------------
// wxDataObjectComposite is the simplest way to implement wxDataObject
// supporting multiple formats. It contains several wxDataObjectSimple and
// supports all formats supported by any of them.
//
// This class shouldn't be (normally) derived from, but may be used directly.
// If you need more flexibility than what it provides, you should probably use
// wxDataObject directly.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataObjectComposite : public wxDataObject
{
public:
// ctor
wxDataObjectComposite();
virtual ~wxDataObjectComposite();
// add data object (it will be deleted by wxDataObjectComposite, hence it
// must be allocated on the heap) whose format will become the preferred
// one if preferred == true
void Add(wxDataObjectSimple *dataObject, bool preferred = false);
// Report the format passed to the SetData method. This should be the
// format of the data object within the composite that received data from
// the clipboard or the DnD operation. You can use this method to find
// out what kind of data object was received.
wxDataFormat GetReceivedFormat() const;
// Returns the pointer to the object which supports this format or nullptr.
// The returned pointer is owned by wxDataObjectComposite and must
// therefore not be destroyed by the caller.
wxDataObjectSimple *GetObject(const wxDataFormat& format,
wxDataObjectBase::Direction dir = Get) const;
// implement base class pure virtuals
// ----------------------------------
virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction dir = Get) const override;
virtual size_t GetFormatCount(wxDataObjectBase::Direction dir = Get) const override;
virtual void GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction dir = Get) const override;
virtual size_t GetDataSize(const wxDataFormat& format) const override;
virtual bool GetDataHere(const wxDataFormat& format, void *buf) const override;
virtual bool SetData(const wxDataFormat& format, size_t len, const void *buf) override;
#if defined(__WXMSW__)
virtual const void* GetSizeFromBuffer( const void* buffer, size_t* size,
const wxDataFormat& format ) override;
virtual void* SetSizeInBuffer( void* buffer, size_t size,
const wxDataFormat& format ) override;
virtual size_t GetBufferOffset( const wxDataFormat& format ) override;
#endif
private:
// all (simple) data objects whose formats we support
std::vector<std::unique_ptr<wxDataObjectSimple>> m_dataObjects;
// the index of the preferred one (0 initially, so by default the first
// one is the preferred)
size_t m_preferred;
wxDataFormat m_receivedFormat;
wxDECLARE_NO_COPY_CLASS(wxDataObjectComposite);
};
// ============================================================================
// Standard implementations of wxDataObjectSimple which can be used directly
// (i.e. without having to derive from them) for standard data type transfers.
//
// Note that although all of them can work with provided data, you can also
// override their virtual GetXXX() functions to only provide data on demand.
// ============================================================================
// ----------------------------------------------------------------------------
// wxTextDataObject contains text data
// ----------------------------------------------------------------------------
#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXQT__)
#define wxNEEDS_UTF8_FOR_TEXT_DATAOBJ
#elif defined(__WXMAC__)
#define wxNEEDS_UTF16_FOR_TEXT_DATAOBJ
#endif
class WXDLLIMPEXP_CORE wxHTMLDataObject : public wxDataObjectSimple
{
public:
// ctor: you can specify the text here or in SetText(), or override
// GetText()
wxHTMLDataObject(const wxString& html = wxEmptyString)
: wxDataObjectSimple(wxDF_HTML),
m_html(html)
{
}
// virtual functions which you may override if you want to provide text on
// demand only - otherwise, the trivial default versions will be used
virtual size_t GetLength() const { return m_html.Len() + 1; }
virtual wxString GetHTML() const { return m_html; }
virtual void SetHTML(const wxString& html) { m_html = html; }
virtual size_t GetDataSize() const override;
virtual bool GetDataHere(void *buf) const override;
virtual bool SetData(size_t len, const void *buf) override;
// Must provide overloads to avoid hiding them (and warnings about it)
virtual size_t GetDataSize(const wxDataFormat&) const override
{
return GetDataSize();
}
virtual bool GetDataHere(const wxDataFormat&, void *buf) const override
{
return GetDataHere(buf);
}
virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) override
{
return SetData(len, buf);
}
private:
wxString m_html;
};
class WXDLLIMPEXP_CORE wxTextDataObject : public wxDataObjectSimple
{
public:
// ctor: you can specify the text here or in SetText(), or override
// GetText()
wxTextDataObject(const wxString& text = wxEmptyString)
: wxDataObjectSimple(wxDF_UNICODETEXT),
m_text(text)
{
}
// virtual functions which you may override if you want to provide text on
// demand only - otherwise, the trivial default versions will be used
virtual wxString GetText() const { return m_text; }
virtual void SetText(const wxString& text) { m_text = text; }
// implement base class pure virtuals
// ----------------------------------
// non-MSW platforms need to support wxDF_TEXT in addition to wxDF_UNICODETEXT
#if defined(wxNEEDS_UTF8_FOR_TEXT_DATAOBJ) || defined(wxNEEDS_UTF16_FOR_TEXT_DATAOBJ)
virtual size_t GetFormatCount(Direction WXUNUSED(dir) = Get) const override { return 2; }
virtual void GetAllFormats(wxDataFormat *formats,
wxDataObjectBase::Direction WXUNUSED(dir) = Get) const override
{
*formats++ = wxDataFormat(wxDF_UNICODETEXT);
*formats = wxDataFormat(wxDF_TEXT);
}
virtual size_t GetDataSize() const override { return GetDataSize(GetPreferredFormat()); }
virtual bool GetDataHere(void *buf) const override { return GetDataHere(GetPreferredFormat(), buf); }
virtual bool SetData(size_t len, const void *buf) override { return SetData(GetPreferredFormat(), len, buf); }
size_t GetDataSize(const wxDataFormat& format) const override;
bool GetDataHere(const wxDataFormat& format, void *pBuf) const override;
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf) override;
#else // !wxNEEDS_UTF{8,16}_FOR_TEXT_DATAOBJ
virtual size_t GetDataSize() const override;
virtual bool GetDataHere(void *buf) const override;
virtual bool SetData(size_t len, const void *buf) override;
// Must provide overloads to avoid hiding them (and warnings about it)
virtual size_t GetDataSize(const wxDataFormat&) const override
{
return GetDataSize();
}
virtual bool GetDataHere(const wxDataFormat&, void *buf) const override
{
return GetDataHere(buf);
}
virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) override
{
return SetData(len, buf);
}
#endif // different wxTextDataObject implementations
wxDEPRECATED_MSG("Don't call nor override this function")
size_t GetTextLength() const { return m_text.Len() + 1; }
private:
#if defined(__WXQT__)
// Overridden to set text directly instead of extracting byte array
void QtSetDataSingleFormat(const class QMimeData &mimeData, const wxDataFormat &format) override;
#endif
wxString m_text;
wxDECLARE_NO_COPY_CLASS(wxTextDataObject);
};
// ----------------------------------------------------------------------------
// wxBitmapDataObject contains a bitmap
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapDataObjectBase : public wxDataObjectSimple
{
public:
// ctor: you can specify the bitmap here or in SetBitmap(), or override
// GetBitmap()
wxBitmapDataObjectBase(const wxBitmap& bitmap = wxNullBitmap)
: wxDataObjectSimple(wxDF_BITMAP), m_bitmap(bitmap)
{
}
// virtual functions which you may override if you want to provide data on
// demand only - otherwise, the trivial default versions will be used
virtual wxBitmap GetBitmap() const { return m_bitmap; }
virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
protected:
wxBitmap m_bitmap;
wxDECLARE_NO_COPY_CLASS(wxBitmapDataObjectBase);
};
// ----------------------------------------------------------------------------
// wxFileDataObject contains a list of filenames
//
// NB: notice that this is a "write only" object, it can only be filled with
// data from drag and drop operation.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileDataObjectBase : public wxDataObjectSimple
{
public:
// ctor: use AddFile() later to fill the array
wxFileDataObjectBase() : wxDataObjectSimple(wxDF_FILENAME) { }
// get a reference to our array
const wxArrayString& GetFilenames() const { return m_filenames; }
protected:
wxArrayString m_filenames;
wxDECLARE_NO_COPY_CLASS(wxFileDataObjectBase);
};
// ----------------------------------------------------------------------------
// wxCustomDataObject contains arbitrary untyped user data.
//
// It is understood that this data can be copied bitwise.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCustomDataObject : public wxDataObjectSimple
{
public:
// if you don't specify the format in the ctor, you can still use
// SetFormat() later
wxCustomDataObject(const wxDataFormat& format = wxFormatInvalid);
// the dtor calls Free()
virtual ~wxCustomDataObject();
// you can call SetData() to set m_data: it will make a copy of the data
// you pass - or you can use TakeData() which won't copy anything, but
// will take ownership of data (i.e. will call Free() on it later)
void TakeData(size_t size, void *data);
// this function is called to allocate "size" bytes of memory from
// SetData(). The default version uses operator new[].
virtual void *Alloc(size_t size);
// this function is called when the data is freed, you may override it to
// anything you want (or may be nothing at all). The default version calls
// operator delete[] on m_data
virtual void Free();
// get data: you may override these functions if you wish to provide data
// only when it's requested
virtual size_t GetSize() const { return m_size; }
virtual void *GetData() const { return m_data; }
// implement base class pure virtuals
// ----------------------------------
virtual size_t GetDataSize() const override;
virtual bool GetDataHere(void *buf) const override;
virtual bool SetData(size_t size, const void *buf) override;
// Must provide overloads to avoid hiding them (and warnings about it)
virtual size_t GetDataSize(const wxDataFormat&) const override
{
return GetDataSize();
}
virtual bool GetDataHere(const wxDataFormat&, void *buf) const override
{
return GetDataHere(buf);
}
virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) override
{
return SetData(len, buf);
}
private:
size_t m_size;
void *m_data;
wxDECLARE_NO_COPY_CLASS(wxCustomDataObject);
};
// ----------------------------------------------------------------------------
// wxImageDataObject - data object for wxImage
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxImageDataObject : public wxCustomDataObject
{
public:
explicit wxImageDataObject(const wxImage& image = wxNullImage);
void SetImage(const wxImage& image);
wxImage GetImage() const;
private:
wxDECLARE_NO_COPY_CLASS(wxImageDataObject);
};
// ----------------------------------------------------------------------------
// include platform-specific declarations of wxXXXBase classes
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ole/dataobj2.h"
// wxURLDataObject defined in msw/ole/dataobj2.h
#elif defined(__WXGTK__)
#include "wx/gtk/dataobj2.h"
// wxURLDataObject defined in gtk/dataobj2.h
#else
#if defined(__WXX11__)
#include "wx/x11/dataobj2.h"
#elif defined(__WXMAC__)
#include "wx/osx/dataobj2.h"
#elif defined(__WXQT__)
#include "wx/qt/dataobj2.h"
#endif
// wxURLDataObject is simply wxTextDataObject with a different name
class WXDLLIMPEXP_CORE wxURLDataObject : public wxTextDataObject
{
public:
wxURLDataObject(const wxString& url = wxEmptyString)
: wxTextDataObject(url)
{
}
wxString GetURL() const { return GetText(); }
void SetURL(const wxString& url) { SetText(url); }
};
#endif
#endif // wxUSE_DATAOBJ
#endif // _WX_DATAOBJ_H_BASE_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,123 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/datectrl.h
// Purpose: implements wxDatePickerCtrl
// Author: Vadim Zeitlin
// Created: 2005-01-09
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATECTRL_H_
#define _WX_DATECTRL_H_
#include "wx/defs.h"
#if wxUSE_DATEPICKCTRL
#include "wx/datetimectrl.h" // the base class
#define wxDatePickerCtrlNameStr wxT("datectrl")
// wxDatePickerCtrl styles
enum
{
// default style on this platform, either wxDP_SPIN or wxDP_DROPDOWN
wxDP_DEFAULT = 0,
// a spin control-like date picker (not supported in generic version)
wxDP_SPIN = 1,
// a combobox-like date picker (not supported on macOS <10.15.4)
wxDP_DROPDOWN = 2,
// always show century in the default date display (otherwise it depends on
// the system date format which may include the century or not)
wxDP_SHOWCENTURY = 4,
// allow not having any valid date in the control (by default it always has
// some date, today initially if no valid date specified in ctor)
wxDP_ALLOWNONE = 8
};
// ----------------------------------------------------------------------------
// wxDatePickerCtrl: allow the user to enter the date
// ----------------------------------------------------------------------------
// The template argument must be a class deriving from wxDateTimePickerCtrlBase
// (i.e. in practice either this class itself or wxDateTimePickerCtrl).
template <typename Base>
class WXDLLIMPEXP_ADV wxDatePickerCtrlCommonBase : public Base
{
public:
/*
The derived classes should implement ctor and Create() method with the
following signature:
bool Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& dt = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr);
*/
/*
We inherit the methods to set/get the date from the base class.
virtual void SetValue(const wxDateTime& dt) = 0;
virtual wxDateTime GetValue() const = 0;
*/
// And add methods to set/get the allowed valid range for the dates. If
// either/both of them are invalid, there is no corresponding limit and if
// neither is set, GetRange() returns false.
virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0;
virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0;
};
// This class is defined mostly for compatibility and is used as the base class
// by native wxDatePickerCtrl implementations.
typedef wxDatePickerCtrlCommonBase<wxDateTimePickerCtrl> wxDatePickerCtrlBase;
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/datectrl.h"
#define wxHAS_NATIVE_DATEPICKCTRL
#elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__)
#include "wx/osx/datectrl.h"
#define wxHAS_NATIVE_DATEPICKCTRL
#elif defined(__WXQT__) && !defined(__WXUNIVERSAL__)
#include "wx/qt/datectrl.h"
#define wxHAS_NATIVE_DATEPICKCTRL
#else
#include "wx/generic/datectrl.h"
class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlGeneric
{
public:
wxDatePickerCtrl() = default;
wxDatePickerCtrl(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr)
: wxDatePickerCtrlGeneric(parent, id, date, pos, size, style, validator, name)
{
}
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl);
};
#endif
#endif // wxUSE_DATEPICKCTRL
#endif // _WX_DATECTRL_H_

View File

@@ -0,0 +1,63 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/dateevt.h
// Purpose: declares wxDateEvent class
// Author: Vadim Zeitlin
// Created: 2005-01-10
// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATEEVT_H_
#define _WX_DATEEVT_H_
#include "wx/event.h"
#include "wx/datetime.h"
#include "wx/window.h"
// ----------------------------------------------------------------------------
// wxDateEvent: used by wxCalendarCtrl, wxDatePickerCtrl and wxTimePickerCtrl.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDateEvent : public wxCommandEvent
{
public:
wxDateEvent() = default;
wxDateEvent(wxWindow *win, const wxDateTime& dt, wxEventType type)
: wxCommandEvent(type, win->GetId()),
m_date(dt)
{
SetEventObject(win);
}
const wxDateTime& GetDate() const { return m_date; }
void SetDate(const wxDateTime &date) { m_date = date; }
// default copy ctor, assignment operator and dtor are ok
wxNODISCARD virtual wxEvent *Clone() const override { return new wxDateEvent(*this); }
private:
wxDateTime m_date;
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxDateEvent);
};
// ----------------------------------------------------------------------------
// event types and macros for handling them
// ----------------------------------------------------------------------------
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_ADV, wxEVT_DATE_CHANGED, wxDateEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_ADV, wxEVT_TIME_CHANGED, wxDateEvent);
typedef void (wxEvtHandler::*wxDateEventFunction)(wxDateEvent&);
#define wxDateEventHandler(func) \
wxEVENT_HANDLER_CAST(wxDateEventFunction, func)
#define EVT_DATE_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_DATE_CHANGED, id, wxDateEventHandler(fn))
#define EVT_TIME_CHANGED(id, fn) \
wx__DECLARE_EVT1(wxEVT_TIME_CHANGED, id, wxDateEventHandler(fn))
#endif // _WX_DATEEVT_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/timectrl.h
// Purpose: Declaration of wxDateTimePickerCtrl class.
// Author: Vadim Zeitlin
// Created: 2011-09-22
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATETIME_CTRL_H_
#define _WX_DATETIME_CTRL_H_
#include "wx/defs.h"
#if wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL
#define wxNEEDS_DATETIMEPICKCTRL
#include "wx/control.h" // the base class
#include "wx/datetime.h"
// ----------------------------------------------------------------------------
// wxDateTimePickerCtrl: Private common base class of wx{Date,Time}PickerCtrl.
// ----------------------------------------------------------------------------
// This class is an implementation detail and should not be used directly, only
// use the documented API of wxDateTimePickerCtrl and wxTimePickerCtrl.
class WXDLLIMPEXP_ADV wxDateTimePickerCtrlBase : public wxControl
{
public:
// Set/get the date or time (in the latter case, time part is ignored).
virtual void SetValue(const wxDateTime& dt) = 0;
virtual wxDateTime GetValue() const = 0;
// For the controls with wxDP_ALLOWNONE style, set the string displayed
// when the control doesn't have any valid value. Currently this is only
// actually used under MSW, where it can be used to override the previous
// value which is still displayed by the control in this case, and ignored
// elsewhere.
virtual void SetNullText(const wxString& WXUNUSED(text)) { }
};
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/datetimectrl.h"
#elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__)
#include "wx/osx/datetimectrl.h"
#else
typedef wxDateTimePickerCtrlBase wxDateTimePickerCtrl;
#endif
#endif // wxUSE_DATEPICKCTRL || wxUSE_TIMEPICKCTRL
#endif // _WX_DATETIME_CTRL_H_

View File

@@ -0,0 +1,172 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/datstrm.h
// Purpose: Data stream classes
// Author: Guilhem Lavaux
// Modified by: Mickael Gilabert
// Created: 28/06/1998
// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATSTREAM_H_
#define _WX_DATSTREAM_H_
#include "wx/stream.h"
#include "wx/longlong.h"
#include "wx/convauto.h"
#if wxUSE_STREAMS
// Common wxDataInputStream and wxDataOutputStream parameters.
class WXDLLIMPEXP_BASE wxDataStreamBase
{
public:
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
// By default we use extended precision (80 bit) format for both float and
// doubles. Call this function to switch to alternative representation in
// which IEEE 754 single precision (32 bits) is used for floats and double
// precision (64 bits) is used for doubles.
void UseBasicPrecisions()
{
#if wxUSE_APPLE_IEEE
m_useExtendedPrecision = false;
#endif // wxUSE_APPLE_IEEE
}
// UseExtendedPrecision() is not very useful as it corresponds to the
// default value, only call it in your code if you want the compilation
// fail with the error when using wxWidgets library compiled without
// extended precision support.
#if wxUSE_APPLE_IEEE
void UseExtendedPrecision()
{
m_useExtendedPrecision = true;
}
#endif // wxUSE_APPLE_IEEE
void SetConv( const wxMBConv &conv );
wxMBConv *GetConv() const { return m_conv; }
protected:
// Ctor and dtor are both protected, this class is never used directly but
// only by its derived classes.
wxDataStreamBase(const wxMBConv& conv);
~wxDataStreamBase();
bool m_be_order;
#if wxUSE_APPLE_IEEE
bool m_useExtendedPrecision;
#endif // wxUSE_APPLE_IEEE
wxMBConv *m_conv;
wxDECLARE_NO_COPY_CLASS(wxDataStreamBase);
};
class WXDLLIMPEXP_BASE wxDataInputStream : public wxDataStreamBase
{
public:
wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8);
bool IsOk() { return m_input->IsOk(); }
wxUint64 Read64();
wxLongLong ReadLL();
wxUint32 Read32();
wxUint16 Read16();
wxUint8 Read8();
double ReadDouble();
float ReadFloat();
wxString ReadString();
void Read64(wxUint64 *buffer, size_t size);
void Read64(wxInt64 *buffer, size_t size);
void Read64(wxULongLong *buffer, size_t size);
void Read64(wxLongLong *buffer, size_t size);
void ReadLL(wxULongLong *buffer, size_t size);
void ReadLL(wxLongLong *buffer, size_t size);
void Read32(wxUint32 *buffer, size_t size);
void Read16(wxUint16 *buffer, size_t size);
void Read8(wxUint8 *buffer, size_t size);
void ReadDouble(double *buffer, size_t size);
void ReadFloat(float *buffer, size_t size);
wxDataInputStream& operator>>(wxString& s);
wxDataInputStream& operator>>(wxInt8& c);
wxDataInputStream& operator>>(wxInt16& i);
wxDataInputStream& operator>>(wxInt32& i);
wxDataInputStream& operator>>(wxUint8& c);
wxDataInputStream& operator>>(wxUint16& i);
wxDataInputStream& operator>>(wxUint32& i);
wxDataInputStream& operator>>(wxUint64& i);
wxDataInputStream& operator>>(wxInt64& i);
wxDataInputStream& operator>>(wxULongLong& i);
wxDataInputStream& operator>>(wxLongLong& i);
wxDataInputStream& operator>>(double& d);
wxDataInputStream& operator>>(float& f);
protected:
wxInputStream *m_input;
wxDECLARE_NO_COPY_CLASS(wxDataInputStream);
};
class WXDLLIMPEXP_BASE wxDataOutputStream : public wxDataStreamBase
{
public:
wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8);
bool IsOk() { return m_output->IsOk(); }
void Write64(wxUint64 i);
void Write64(wxInt64 i);
void WriteLL(const wxLongLong &ll);
void WriteLL(const wxULongLong &ll);
void Write32(wxUint32 i);
void Write16(wxUint16 i);
void Write8(wxUint8 i);
void WriteDouble(double d);
void WriteFloat(float f);
void WriteString(const wxString& string);
void Write64(const wxUint64 *buffer, size_t size);
void Write64(const wxInt64 *buffer, size_t size);
void Write64(const wxULongLong *buffer, size_t size);
void Write64(const wxLongLong *buffer, size_t size);
void WriteLL(const wxULongLong *buffer, size_t size);
void WriteLL(const wxLongLong *buffer, size_t size);
void Write32(const wxUint32 *buffer, size_t size);
void Write16(const wxUint16 *buffer, size_t size);
void Write8(const wxUint8 *buffer, size_t size);
void WriteDouble(const double *buffer, size_t size);
void WriteFloat(const float *buffer, size_t size);
wxDataOutputStream& operator<<(const wxString& string);
wxDataOutputStream& operator<<(wxInt8 c);
wxDataOutputStream& operator<<(wxInt16 i);
wxDataOutputStream& operator<<(wxInt32 i);
wxDataOutputStream& operator<<(wxUint8 c);
wxDataOutputStream& operator<<(wxUint16 i);
wxDataOutputStream& operator<<(wxUint32 i);
wxDataOutputStream& operator<<(wxUint64 i);
wxDataOutputStream& operator<<(wxInt64 i);
wxDataOutputStream& operator<<(const wxULongLong &i);
wxDataOutputStream& operator<<(const wxLongLong &i);
wxDataOutputStream& operator<<(double d);
wxDataOutputStream& operator<<(float f);
protected:
wxOutputStream *m_output;
wxDECLARE_NO_COPY_CLASS(wxDataOutputStream);
};
#endif
// wxUSE_STREAMS
#endif
// _WX_DATSTREAM_H_

Some files were not shown because too many files have changed in this diff Show More