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,33 @@
#!/bin/bash
# check_syntax.sh - a small script to search for interface headers with
# missing semicolons (they give troubles to Doxygen).
# Author: Francesco Montorsi
rm -f missing_semicolons
# the preprocessor will remove comments and all #preprocessor #stuff;
# we then remove the empty lines
for iface in wx/*h; do
echo "--- $iface ---" >>missing_semicolons
gcc -E $iface | grep -v '#' | grep -v '^[[:space:]]*$' >temp
# now remove the lines which ends with a comma or a semicolon; they're ok
cat temp | grep -v '.*;$' | grep -v '.*,$' >temp2
# now search for methods; we know they should always contain at least two () brackets!
cat temp2 | grep '(' >>missing_semicolons
# now remove the lines which shouldn't have final comma or semicolon:
# cat temp2 | grep -v '^[[:space:]]*wx[A-Z]*[[:space:]]*$' >temp
# cat temp | grep -v 'class' | grep -v 'enum' | grep -v 'template' | \
# grep -v 'struct' | grep -v 'typedef' | \
# grep -v 'public:' | grep -v 'protected:' | grep -v 'private:' | \
# grep -v '{' | grep -v '}' >>missing_semicolons
done
rm temp temp2

View File

@@ -0,0 +1,388 @@
/////////////////////////////////////////////////////////////////////////////
// Name: aboutdlg.h
// Purpose: interface of wxAboutDialogInfo
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxAboutDialogInfo
wxAboutDialogInfo contains information shown in the standard @e About
dialog displayed by the wxAboutBox() function.
This class contains the general information about the program, such as its
name, version, copyright and so on, as well as lists of the program developers,
documentation writers, artists and translators. The simple properties from the
former group are represented as a string with the exception of the program icon
and the program web site, while the lists from the latter group are stored as
wxArrayString and can be either set entirely at once using
wxAboutDialogInfo::SetDevelopers and similar functions or built one by one using
wxAboutDialogInfo::AddDeveloper etc.
Please also notice that while all the main platforms have the native
implementation of the about dialog, they are often more limited than the
generic version provided by wxWidgets and so the generic version is used if
wxAboutDialogInfo has any fields not supported by the native version. Currently
GTK+ version supports all the possible fields natively but MSW and Mac versions
don't support URLs, licence text nor custom icons in the about dialog and if
either of those is used, wxAboutBox() will automatically use the generic version
so you should avoid specifying these fields to achieve more native look and feel.
Example of usage:
@code
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxAboutDialogInfo aboutInfo;
aboutInfo.SetName("MyApp");
aboutInfo.SetVersion(MY_APP_VERSION_STRING);
aboutInfo.SetDescription(_("My wxWidgets-based application!"));
aboutInfo.SetCopyright("(C) 1992-2025");
aboutInfo.SetWebSite("http://myapp.org");
aboutInfo.AddDeveloper("My Self");
wxAboutBox(aboutInfo);
}
@endcode
Example of appearance of a simple about dialog:
@appearance{about-simple}
And that of a dialog using a web site link, which results in using the
generic version under MSW and Mac:
@appearance{about-with-url}
@library{wxcore}
@category{cmndlg,data}
@see wxAboutDialogInfo::SetArtists
*/
class wxAboutDialogInfo
{
public:
/**
Default constructor leaves all fields are initially uninitialized, in general
you should call at least SetVersion(), SetCopyright() and SetDescription().
*/
wxAboutDialogInfo();
/**
Adds an artist name to be shown in the program credits.
@see SetArtists()
*/
void AddArtist(const wxString& artist);
/**
Adds a developer name to be shown in the program credits.
@see SetDevelopers()
*/
void AddDeveloper(const wxString& developer);
/**
Adds a documentation writer name to be shown in the program credits.
@see SetDocWriters()
*/
void AddDocWriter(const wxString& docwriter);
/**
Adds a translator name to be shown in the program credits. Notice that if no
translator names are specified explicitly, wxAboutBox() will try to use the
translation of the string @c translator-credits from the currently used message
catalog -- this can be used to show just the name of the translator of the
program in the current language.
@see SetTranslators()
*/
void AddTranslator(const wxString& translator);
/**
Get the name of the program.
@return Name of the program
@see SetName()
*/
wxString GetName() const;
/**
Returns @true if a description string has been specified.
@see GetDescription()
*/
bool HasDescription() const;
/**
Get the description string.
@return The description string, free-form.
*/
const wxString& GetDescription();
/**
Returns @true if a copyright string has been specified.
@see GetCopyright()
*/
bool HasCopyright() const;
/**
Get the copyright string.
@return The copyright string
*/
const wxString& GetCopyright() const;
/**
Sets the list of artists to be shown in the program credits.
@see AddArtist()
*/
void SetArtists(const wxArrayString& artists);
/**
Set the short string containing the program copyright information. Notice that
any occurrences of @c "(C)" in @a copyright will be replaced by the
copyright symbol (circled C) automatically, which means that you can avoid
using this symbol in the program source code which can be problematic,
Also note that under MSW platform the word "Copyright" itself will be
removed from the string if it is followed by the copyright symbol, to
follow the platform convention.
*/
void SetCopyright(const wxString& copyright);
/**
Set brief, but possibly multiline, description of the program.
*/
void SetDescription(const wxString& desc);
/**
Set the list of developers of the program.
@see AddDeveloper()
*/
void SetDevelopers(const wxArrayString& developers);
/**
Set the list of documentation writers.
@see AddDocWriter()
*/
void SetDocWriters(const wxArrayString& docwriters);
/**
Returns @true if an icon has been set for the about dialog.
*/
bool HasIcon() const;
/**
Returns the icon set by SetIcon().
*/
wxIcon GetIcon() const;
/**
Set the icon to be shown in the dialog. By default the icon of the main frame
will be shown if the native about dialog supports custom icons. If it doesn't
but a valid icon is specified using this method, the generic about dialog is
used instead so you should avoid calling this function for maximally native
look and feel.
*/
void SetIcon(const wxIcon& icon);
/**
Returns @true if the licence string has been set.
*/
bool HasLicence() const;
/**
Returns the licence string.
@see SetLicence()
*/
const wxString& GetLicence() const;
/**
Set the long, multiline string containing the text of the program licence.
Only GTK+ version supports showing the licence text in the native about dialog
currently so the generic version will be used under all the other platforms if
this method is called. To preserve the native look and feel it is advised that
you do not call this method but provide a separate menu item in the
@c "Help" menu for displaying the text of your program licence.
*/
void SetLicence(const wxString& licence);
/**
This is the same as SetLicence().
*/
void SetLicense(const wxString& licence);
/**
Set the name of the program. If this method is not called, the string returned
by wxApp::GetAppName will be shown in the dialog.
*/
void SetName(const wxString& name);
/**
Set the list of translators. Please see AddTranslator() for additional
discussion.
*/
void SetTranslators(const wxArrayString& translators);
/**
Set the version of the program. The word "version" shouldn't be included
in @a version. Example @a version values: "1.2" and "RC2". In about dialogs
with more space set aside for version information, @a longVersion is used.
Example @a longVersion values: "Version 1.2" and "Release Candidate 2".
If @a version is non-empty but @a longVersion is empty, a long version
is constructed automatically, using @a version (by simply prepending
"Version " to @a version).
The generic about dialog and native GTK+ dialog use @a version only,
as a suffix to the program name. The native MSW and macOS about dialogs
use the long version.
*/
void SetVersion(const wxString& version, const wxString& longVersion = wxString());
/**
Return the short version string.
@see SetVersion()
*/
const wxString& GetVersion() const;
/**
Return the long version string if set.
@see SetVersion()
*/
const wxString& GetLongVersion() const;
/**
Returns @true if the website info has been set.
*/
bool HasWebSite() const;
/**
Returns the website URL set for the dialog.
*/
const wxString& GetWebSiteURL() const;
/**
Returns the description of the website URL set for the dialog.
*/
const wxString& GetWebSiteDescription() const;
/**
Set the web site for the program and its description (which defaults to @a url
itself if empty).
Please notice that only GTK+ version currently supports showing the link in the
native about dialog so if this method is called, the generic version will be
used under all the other platforms.
*/
void SetWebSite(const wxString& url,
const wxString& desc = wxEmptyString);
/**
Returns @true if developers have been set in the dialog info.
*/
bool HasDevelopers() const;
/**
Returns an array of the developer strings set in the dialog info.
*/
const wxArrayString& GetDevelopers() const;
/**
Returns @true if writers have been set in the dialog info.
*/
bool HasDocWriters() const;
/**
Returns an array of the writer strings set in the dialog info.
*/
const wxArrayString& GetDocWriters() const;
/**
Returns @true if artists have been set in the dialog info.
*/
bool HasArtists() const;
/**
Returns an array of the artist strings set in the dialog info.
*/
const wxArrayString& GetArtists() const;
/**
Returns @true if translators have been set in the dialog info.
*/
bool HasTranslators() const;
/**
Returns an array of the translator strings set in the dialog info.
*/
const wxArrayString& GetTranslators() const;
};
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_dialog */
///@{
/**
This function shows the standard about dialog containing the information
specified in @a info. If the current platform has a native about dialog
which is capable of showing all the fields in @a info, the native dialog is
used, otherwise the function falls back to the generic wxWidgets version of
the dialog, i.e. does the same thing as wxGenericAboutBox.
Here is an example of how this function may be used:
@code
void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event))
{
wxAboutDialogInfo info;
info.SetName(_("My Program"));
info.SetVersion(_("1.2.3 Beta"));
info.SetDescription(_("This program does something great."));
info.SetCopyright("(C) 2007 Me <my@email.addre.ss>");
wxAboutBox(info);
}
@endcode
Please see the @ref page_samples_dialogs for more examples of using this
function and wxAboutDialogInfo for the description of the information which
can be shown in the about dialog.
@header{wx/aboutdlg.h}
*/
void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = nullptr);
/**
This function does the same thing as wxAboutBox() except that it always uses
the generic wxWidgets version of the dialog instead of the native one.
This is mainly useful if you need to customize the dialog by e.g. adding
custom controls to it (customizing the native dialog is not currently
supported).
See the @ref page_samples_dialogs for an example of about dialog
customization.
@see wxAboutDialogInfo
@header{wx/aboutdlg.h}
*/
void wxGenericAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = nullptr);
///@}

View File

@@ -0,0 +1,241 @@
/////////////////////////////////////////////////////////////////////////////
// Name: accel.h
// Purpose: interface of wxAccelerator* classes
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/** wxAcceleratorEntry flags */
enum wxAcceleratorEntryFlags
{
/** no modifiers */
wxACCEL_NORMAL,
/** hold Alt key down */
wxACCEL_ALT,
/** hold Ctrl key down, corresponds to Command key on macOS */
wxACCEL_CTRL,
/** hold Shift key down */
wxACCEL_SHIFT,
/** corresponds to real Ctrl key on macOS, identic to @c wxACCEL_CTRL on other platforms */
wxACCEL_RAW_CTRL,
/** deprecated, identic to @c wxACCEL_CTRL on all platforms. */
wxACCEL_CMD
};
/**
@class wxAcceleratorEntry
An object used by an application wishing to create an accelerator table
(see wxAcceleratorTable).
@library{wxcore}
@category{data}
@see wxAcceleratorTable, wxWindow::SetAcceleratorTable
*/
class wxAcceleratorEntry
{
public:
/**
Constructor.
@param flags
A combination of the ::wxAcceleratorEntryFlags values, which
indicates which modifier keys are held down.
@param keyCode
The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
@param cmd
The menu or control command identifier (ID).
@param item
The menu item associated with this accelerator.
*/
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
wxMenuItem *item = nullptr);
/**
Copy ctor.
*/
wxAcceleratorEntry(const wxAcceleratorEntry& entry);
/**
Returns the command identifier for the accelerator table entry.
*/
int GetCommand() const;
/**
Returns the flags for the accelerator table entry.
*/
int GetFlags() const;
/**
Returns the keycode for the accelerator table entry.
*/
int GetKeyCode() const;
/**
Returns the menu item associated with this accelerator entry.
*/
wxMenuItem *GetMenuItem() const;
/**
Sets the accelerator entry parameters.
@param flags
A combination of the ::wxAcceleratorEntryFlags values, which
indicates which modifier keys are held down.
@param keyCode
The keycode to be detected. See ::wxKeyCode for a full list of keycodes.
@param cmd
The menu or control command identifier (ID).
@param item
The menu item associated with this accelerator.
*/
void Set(int flags, int keyCode, int cmd, wxMenuItem *item = nullptr);
/**
Returns @true if this object is correctly initialized.
*/
bool IsOk() const;
/**
Returns a textual representation of this accelerator.
The returned string is of the form <code>[Alt+][Ctrl+][RawCtrl+][Shift+]Key</code>
where the modifier keys are present only if the corresponding flag is
set.
*/
wxString ToString() const;
/**
Returns a textual representation of this accelerator which is
appropriate for saving in configuration files.
Unlike the string returned by ToString(), this one is never translated
so, while it's not suitable for showing to the user, it can be used to
uniquely identify the accelerator independently of the user language.
The returned string can still be parsed by FromString().
@since 2.9.4
*/
wxString ToRawString() const;
/**
Parses the given string and sets the accelerator accordingly.
@param str
This string may be either in the same format as returned by
ToString(), i.e. contain the accelerator itself only, or have the
format of a full menu item text with i.e. <code>Label TAB
Accelerator</code>. In the latter case, the part of the string
before the TAB is ignored. Notice that the latter format is only
supported for the compatibility with the previous wxWidgets
versions and the new code should pass only the accelerator string
itself to this function.
@return @true if the given string correctly initialized this object
(i.e. if IsOk() returns true after this call)
*/
bool FromString(const wxString& str);
wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry);
bool operator==(const wxAcceleratorEntry& entry) const;
bool operator!=(const wxAcceleratorEntry& entry) const;
};
/**
@class wxAcceleratorTable
An accelerator table allows the application to specify a table of keyboard
shortcuts for menu or button commands.
The object ::wxNullAcceleratorTable is defined to be a table with no data, and
is the initial accelerator table for a window.
Example:
@code
wxAcceleratorEntry entries[4];
entries[0].Set(wxACCEL_CTRL, (int) 'N', ID_NEW_WINDOW);
entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_EXIT);
entries[2].Set(wxACCEL_SHIFT, (int) 'A', ID_ABOUT);
entries[3].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CUT);
wxAcceleratorTable accel(4, entries);
frame->SetAcceleratorTable(accel);
@endcode
@remarks
An accelerator takes precedence over normal processing and can be a convenient
way to program some event handling. For example, you can use an accelerator table
to enable a dialog with a multi-line text control to accept CTRL-Enter as meaning
'OK'.
@library{wxcore}
@category{data}
@stdobjects
::wxNullAcceleratorTable
@see wxAcceleratorEntry, wxWindow::SetAcceleratorTable
*/
class wxAcceleratorTable : public wxObject
{
public:
/**
Default ctor.
*/
wxAcceleratorTable();
/**
Initializes the accelerator table from an array of wxAcceleratorEntry.
@param n
Number of accelerator entries. If this parameter is 0, invalid
accelerator table is created, i.e. IsOk() will return @false.
@param entries
The array of entries.
@beginWxPerlOnly
The wxPerl constructor accepts a list of either
Wx::AcceleratorEntry objects or references to 3-element arrays
[flags, keyCode, cmd] , like the parameters of
Wx::AcceleratorEntry::new.
@endWxPerlOnly
*/
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
/**
Loads the accelerator table from a Windows resource (Windows only).
@onlyfor{wxmsw}
@param resource
Name of a Windows accelerator.
*/
wxAcceleratorTable(const wxString& resource);
/**
Returns @true if the accelerator table is valid.
*/
bool IsOk() const;
};
// ============================================================================
// Global functions/macros
// ============================================================================
/**
An empty accelerator table.
*/
wxAcceleratorTable wxNullAcceleratorTable;

View File

@@ -0,0 +1,517 @@
/////////////////////////////////////////////////////////////////////////////
// Name: access.h
// Purpose: interface of wxAccessible
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
wxAccessible functions return a wxAccStatus error code,
which may be one of this enum's values.
*/
enum wxAccStatus
{
wxACC_FAIL, //!< The function failed.
wxACC_FALSE, //!< The function returned false.
wxACC_OK, //!< The function completed successfully.
wxACC_NOT_IMPLEMENTED, //!< The function is not implemented.
wxACC_NOT_SUPPORTED, //!< The function is not supported.
/**
An argument is not valid (e.g. it does not make sense for the specified
object).
*/
wxACC_INVALID_ARG
};
/** Child ids are integer identifiers from 1 up.
So zero represents 'this' object.
*/
#define wxACC_SELF 0
/**
This enum represents directions of navigation used in
wxAccessible::Navigate().
*/
enum wxNavDir
{
/**
Navigate to the first child of the object. When this flag is used, the
@c fromId parameter must be @c wxACC_SELF.
*/
wxNAVDIR_FIRSTCHILD,
/**
Navigate to the last child of the object. When this flag is used, the
@c fromId parameter must be @c wxACC_SELF.
*/
wxNAVDIR_LASTCHILD,
wxNAVDIR_DOWN,
wxNAVDIR_LEFT,
wxNAVDIR_NEXT,
wxNAVDIR_PREVIOUS,
wxNAVDIR_RIGHT,
wxNAVDIR_UP
};
/**
The role of a user interface element is represented by the values of this enum.
*/
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
};
/**
Objects are represented by a wxAccObject enum value.
*/
enum wxAccObject {
/**
@hideinitializer
*/
wxOBJID_WINDOW = 0x00000000,
/**
@hideinitializer
*/
wxOBJID_SYSMENU = 0xFFFFFFFF,
/**
@hideinitializer
*/
wxOBJID_TITLEBAR = 0xFFFFFFFE,
/**
@hideinitializer
*/
wxOBJID_MENU = 0xFFFFFFFD,
/**
@hideinitializer
*/
wxOBJID_CLIENT = 0xFFFFFFFC,
/**
@hideinitializer
*/
wxOBJID_VSCROLL = 0xFFFFFFFB,
/**
@hideinitializer
*/
wxOBJID_HSCROLL = 0xFFFFFFFA,
/**
@hideinitializer
*/
wxOBJID_SIZEGRIP = 0xFFFFFFF9,
/**
@hideinitializer
*/
wxOBJID_CARET = 0xFFFFFFF8,
/**
@hideinitializer
*/
wxOBJID_CURSOR = 0xFFFFFFF7,
/**
@hideinitializer
*/
wxOBJID_ALERT = 0xFFFFFFF6,
/**
@hideinitializer
*/
wxOBJID_SOUND = 0xFFFFFFF5
};
/**
Selection actions are identified by the wxAccSelectionFlags values.
*/
enum wxAccSelectionFlags
{
/**
No action is performed. Neither the selection nor focus is changed.
@hideinitializer
*/
wxACC_SEL_NONE = 0,
/**
The object is focused and becomes the selection anchor.
@hideinitializer
*/
wxACC_SEL_TAKEFOCUS = 1,
/**
The object is selected and all other objects are removed from the
current selection.
@hideinitializer
*/
wxACC_SEL_TAKESELECTION = 2,
/**
All objects between the selection anchor and this object are added to
the current selection if the anchor object's is selected or they are
removed from the current selection otherwise.
If this flag is combined with @c wxACC_SEL_ADDSELECTION, the objects
are added to the current selection regardless of the anchor object's
state.
If this flag is combined with @c wxACC_SEL_REMOVESELECTION, the objects
are removed from the current selection regardless of the anchor
object's state.
@hideinitializer
*/
wxACC_SEL_EXTENDSELECTION = 4,
/**
The object is added to the current selection. A noncontiguous selection
can be a result of this operation.
@hideinitializer
*/
wxACC_SEL_ADDSELECTION = 8,
/**
The object is removed from the current selection. A noncontiguous
selection can be a result of this operation.
@hideinitializer
*/
wxACC_SEL_REMOVESELECTION = 16
};
///@{
/**
Represents a status of the system.
*/
#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
///@}
///@{
/**
An event identifier that can be sent via wxAccessible::NotifyEvent.
*/
#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
///@}
/**
@class wxAccessible
The wxAccessible class allows wxWidgets applications, and wxWidgets itself,
to return extended information about user interface elements to client
applications such as screen readers. This is the main way in which wxWidgets
implements accessibility features.
At present, only Microsoft Active Accessibility is supported by this class.
To use this class, derive from wxAccessible, implement appropriate
functions, and associate an object of the class with a window using
wxWindow::SetAccessible.
All functions return an indication of success, failure, or not implemented
using values of the wxAccStatus enum type.
If you return @c wxACC_NOT_IMPLEMENTED from any function, the system will try
to implement the appropriate functionality. However this will not work with
all functions.
Most functions work with an object @e id, which can be zero to refer to
'this' UI element, or greater than zero to refer to the nth child element.
This allows you to specify elements that don't have a corresponding wxWindow or
wxAccessible; for example, the sash of a splitter window.
For details on the semantics of functions and types, please refer to the
Microsoft Active Accessibility 1.2 documentation.
This class is compiled into wxWidgets only if the @c wxUSE_ACCESSIBILITY setup
symbol is set to 1.
@onlyfor{wxmsw}
@library{wxcore}
@category{misc}
@see @sample{access}
*/
class wxAccessible : public wxObject
{
public:
/**
Constructor, taking an optional window. The object can be associated with
a window later.
*/
wxAccessible(wxWindow* win = nullptr);
/**
Destructor.
*/
~wxAccessible();
/**
Performs the default action for the object.
@a childId is 0 (the action for this object) or greater than 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 childId);
/**
Gets the specified child (starting from 1). If @a child is @NULL and the return
value is wxACC_OK, this means that the child is a simple element and not an
accessible object.
*/
virtual wxAccStatus GetChild(int childId, wxAccessible** child);
/**
Returns the number of children in @a childCount.
*/
virtual wxAccStatus GetChildCount(int* childCount);
/**
Gets the default action for this object (0) or a child (greater than 0).
Return wxACC_OK even if there is no action. @a 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 childId,
wxString* actionName);
/**
Returns the description for this object or a child.
*/
virtual wxAccStatus GetDescription(int childId,
wxString* description);
/**
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* childId, wxAccessible** child);
/**
Returns help text for this object or a child, similar to tooltip text.
*/
virtual wxAccStatus GetHelpText(int childId, wxString* helpText);
/**
Returns the keyboard shortcut for this object or child.
Returns e.g. ALT+K.
*/
virtual wxAccStatus GetKeyboardShortcut(int childId,
wxString* shortcut);
/**
Returns the rectangle for this object (id is 0) or a child element (id is
greater than 0).
@a rect is in screen coordinates.
*/
virtual wxAccStatus GetLocation(wxRect& rect, int elementId);
/**
Gets the name of the specified object.
*/
virtual wxAccStatus GetName(int childId, wxString* name);
/**
Returns the parent of this object, or @NULL.
*/
virtual wxAccStatus GetParent(wxAccessible** parent);
/**
Returns a role constant describing this object. See wxAccRole for a list
of these roles.
*/
virtual wxAccStatus GetRole(int childId, wxAccRole* role);
/**
Gets a variant representing the selected children of this object.
Acceptable values are:
@li a null variant (@c IsNull() returns @true) if no children
are selected
@li a @c void* pointer to a wxAccessible of selected child object
@li an integer representing the selected child element,
or 0 if this object is selected (@c GetType() @c == @c "long")
@li a list variant (@c GetType() @c == @c "list") if multiple child
objects are selected
*/
virtual wxAccStatus GetSelections(wxVariant* selections);
/**
Returns a state constant. See wxAccStatus for a list of these states.
*/
virtual wxAccStatus GetState(int childId, long* state);
/**
Returns a localized string representing the value for the object
or child.
*/
virtual wxAccStatus GetValue(int childId, wxString* strValue);
/**
Returns the window associated with this object.
*/
wxWindow* GetWindow();
/**
Returns a status value and object id to indicate whether the given point
was on this or a child object. Can return either a child object, or an
integer representing the child element, starting from 1.
@a pt is in screen coordinates.
*/
virtual wxAccStatus HitTest(const wxPoint& pt, int* childId,
wxAccessible** childObject);
/**
Navigates from @a fromId to @a toId or to @a toObject.
*/
virtual wxAccStatus Navigate(wxNavDir navDir, int fromId,
int* toId,
wxAccessible** toObject);
/**
Allows the application to send an event when something changes in
an accessible object.
*/
static void NotifyEvent(int eventType, wxWindow* window,
wxAccObject objectType,
int objectId);
/**
Selects the object or child. See wxAccSelectionFlags for a list
of the selection actions.
*/
virtual wxAccStatus Select(int childId,
wxAccSelectionFlags selectFlags);
/**
Sets the window associated with this object.
*/
void SetWindow(wxWindow* window);
};

View File

@@ -0,0 +1,80 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/activityindicator.h
// Purpose: wxActivityIndicator documentation.
// Author: Vadim Zeitlin
// Created: 2015-03-05
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/**
@class wxActivityIndicator
Small control showing an animation indicating that the program is currently
busy performing some background task.
@since 3.1.0
@library{wxcore}
@category{ctrl}
@appearance{activityindicator}
*/
class wxActivityIndicator : public wxControl
{
public:
/**
Default constructor.
Use Create() to really create the control after using this constructor.
*/
wxActivityIndicator();
/**
Constructor fully creating the control.
The arguments have the usual meanings and only @a parent is typically
required.
*/
explicit wxActivityIndicator(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "activityindicator");
/**
Create the control initialized using the default constructor.
This method can be used to finish the control creation if it hadn't
been done already by using the non-default constructor.
*/
bool Create(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = "activityindicator");
/**
Starts animation of the indicator.
Does nothing if the indicator is already running.
*/
void Start();
/**
Stops the animation of the indicator.
Notice that the animation is stopped even if Start() had been called
multiple times before, i.e. the calls are not cumulative.
*/
void Stop();
/**
Returns true if the control is currently showing activity.
Returns @false initially, @true once Start() is called and @false again
after calling Stop().
*/
bool IsRunning() const;
};

View File

@@ -0,0 +1,201 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/addremovectrl.h
// Purpose: documentation of wxAddRemoveCtrl
// Author: Vadim Zeitlin
// Created: 2015-02-04
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxAddRemoveAdaptor
Object used to mediate between wxAddRemoveCtrl and the control showing the
list of items which can be added or removed.
This is a base class from which custom classes used with
wxAddRemoveCtrl::SetAdaptor() must be derived. Object of this class are
typically associated with the control showing the list of items on
creation, i.e. the derived class constructor would normally take a pointer
to the control which will be returned from GetItemsCtrl() later.
@since 3.1.0
@library{wxcore}
*/
class wxAddRemoveAdaptor
{
public:
/// Default and trivial constructor.
wxAddRemoveAdaptor();
/// Trivial but virtual destructor.
virtual ~wxAddRemoveAdaptor();
/**
Override to return the associated control.
The control must be a child of the associated wxAddRemoveCtrl.
*/
virtual wxWindow* GetItemsCtrl() const = 0;
/**
Override to return whether a new item can be added to the control.
A typical implementation would simply always return @true, but it is
also possible to return @false if the list is "full" and can't contain
any more elements.
*/
virtual bool CanAdd() const = 0;
/**
Override to return whether the currently selected item (if any) can be
removed from the control.
The implementation should check if there is a currently selected item
and possibly if the user is allowed to remove this item.
*/
virtual bool CanRemove() const = 0;
/**
Called when an item should be added.
A typical implementation would either add a new item to the list
control and start editing it in place or ask the user for the item to
add first and then add it to the control returned by GetItemsCtrl().
Notice that this method can only be called if CanAdd() currently
returns @true.
*/
virtual void OnAdd() = 0;
/**
Called when the current item should be removed.
The implementation should remove the currently selected item from the
control and update the selection.
Notice that this method can only be called if CanRemove() currently
returns @true.
*/
virtual void OnRemove() = 0;
};
/**
@class wxAddRemoveCtrl
A class adding buttons to add and remove items to a list-like child
control.
This class represents a composite control which combines any control
capable of showing multiple items, such as wxListBox, wxListCtrl,
wxTreeCtrl, wxDataViewCtrl or a custom control, with two buttons allowing
to add items and remove items from this list-like control. The advantage of
using this control instead of just creating and managing the buttons
directly is that the correct buttons and layout for the current platform
are used by this class. E.g. the buttons are positioned under the list
control under macOS and GTK+ but to its right under MSW and the buttons
themselves use system-specific bitmaps under macOS.
This class is always used in conjunction with wxAddRemoveAdaptor which is
used to actually add items to or remove them from the control containing
the items when the corresponding button is pressed. The
@ref page_samples_dialogs "dialogs sample" shows how to do it: first you
need to derive a new class from wxAddRemoveAdaptor and implement its pure
virtual methods and then you must call SetAdaptor() with a newly allocated
object of this class. You also must create the control containing the items
with wxAddRemoveCtrl as parent. Here are the different steps in pseudocode:
@code
wxAddRemoveCtrl* ctrl = new wxAddRemoveCtrl(parent);
// This can be any kind of control for which OnAdd() and OnRemove()
// below can be made to work.
wxListBox* lbox = new wxListBox(ctrl, ...);
class ListBoxAdaptor : public wxAddRemoveAdaptor
{
public:
explicit ListBoxAdaptor(wxListBox* lbox) : m_lbox(lbox) { }
virtual wxWindow* GetItemsCtrl() const { return m_lbox; }
virtual bool CanAdd() const { return true; }
virtual bool CanRemove() const { return m_lbox->GetSelection() != wxNOT_FOUND; }
virtual void OnAdd() { ... get the new item from user and add it ... }
virtual void OnRemove() { m_lbox->Delete(m_lbox->GetSelection()); }
private:
wxListBox* m_lbox;
};
ctrl->SetAdaptor(new ListBoxAdaptor(lbox));
@endcode
@since 3.1.0
@library{wxcore}
@category{ctrl}
*/
class wxAddRemoveCtrl : public wxPanel
{
public:
/**
Default constructor.
Use Create() later.
*/
wxAddRemoveCtrl();
/**
Constructor really creating the control window.
SetAdaptor() still must be called later to finish initializing the
control.
Parameters have the same meaning as in wxPanel::Create().
*/
wxAddRemoveCtrl(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxAddRemoveCtrlNameStr);
/**
Create the control window after using the default constructor.
Parameters have the same meaning as in wxPanel::Create().
*/
bool Create(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxAddRemoveCtrlNameStr);
/**
Associate the control with the specified adaptor object.
This method must be called exactly once to finish initializing this
object.
The adapter object must correspond to a control created as a child of
this window, i.e. wxAddRemoveAdaptor::GetItemsCtrl() must return a
pointer to an existing child of this control.
The @a adaptor pointer must be non-null and heap-allocated as the
control takes ownership of it and will delete it later.
*/
void SetAdaptor(wxAddRemoveAdaptor* adaptor);
/**
Sets the tooltips used for the add and remove buttons.
Show the specified tooltips when the mouse hovers over the buttons used
to add and remove items, respectively.
This method can only be used after calling SetAdaptor().
*/
void SetButtonsToolTips(const wxString& addtip, const wxString& removetip);
};

View File

@@ -0,0 +1,191 @@
/////////////////////////////////////////////////////////////////////////////
// Name: affinematrix2d.h
// Purpose: interface of wxAffineMatrix2D
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxAffineMatrix2D
A 3x2 matrix representing an affine 2D transformation.
@library{wxcore}
@category{misc}
@since 2.9.2
*/
class wxAffineMatrix2D : public wxAffineMatrix2DBase
{
public:
/**
Default constructor.
The matrix elements are initialize to the identity matrix.
*/
wxAffineMatrix2D();
/**
Get the component values of the matrix.
@param mat2D
The rotational components of the matrix (upper 2 x 2), must be
non-null.
@param tr
The translational components of the matrix, may be @NULL.
*/
void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const;
/**
Set all elements of this matrix.
@param mat2D
The rotational components of the matrix (upper 2 x 2).
@param tr
The translational components of the matrix.
*/
void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr);
/**
Concatenate this matrix with another one.
The parameter matrix is the multiplicand.
@param t
The multiplicand.
@code
// | t.m_11 t.m_12 0 | | m_11 m_12 0 |
// matrix' = | t.m_21 t.m_22 0 | x | m_21 m_22 0 |
// | t.m_tx t.m_ty 1 | | m_tx m_ty 1 |
@endcode
*/
void Concat(const wxAffineMatrix2DBase& t);
/**
Invert this matrix.
If the matrix is not invertible, i.e. if its determinant is 0, returns
false and doesn't modify it.
@code
// | m_11 m_12 0 |
// Invert | m_21 m_22 0 |
// | m_tx m_ty 1 |
@endcode
*/
bool Invert();
/**
Check if this is the identity matrix.
*/
bool IsIdentity() const;
///@{
/**
Check that this matrix is identical with @a t.
@param t
The matrix compared with this.
*/
void IsEqual(const wxAffineMatrix2DBase& t);
bool operator==(const wxAffineMatrix2DBase& t) const;
///@}
/**
Check that this matrix differs from @a t.
@param t
The matrix compared with this.
*/
bool operator!=(const wxAffineMatrix2DBase& t) const;
/**
Add the translation to this matrix.
@param dx
The translation in x direction.
@param dy
The translation in y direction.
@code
// | 1 0 0 | | m_11 m_12 0 |
// matrix' = | 0 1 0 | x | m_21 m_22 0 |
// | dx dy 1 | | m_tx m_ty 1 |
@endcode
*/
void Translate(wxDouble dx, wxDouble dy);
/**
Add scaling to this matrix.
@param xScale
Scaling in x direction.
@param yScale
Scaling in y direction.
@code
// | xScale 0 0 | | m_11 m_12 0 |
// matrix' = | 0 yScale 0 | x | m_21 m_22 0 |
// | 0 0 1 | | m_tx m_ty 1 |
@endcode
*/
void Scale(wxDouble xScale, wxDouble yScale);
/**
Add mirroring to this matrix.
@param direction
The direction(s) used for mirroring. One of wxHORIZONTAL,
wxVERTICAL or their combination wxBOTH.
*/
void Mirror(int direction = wxHORIZONTAL);
/**
Add clockwise rotation to this matrix.
@param cRadians
Rotation angle in radians, clockwise.
@code
// | cos sin 0 | | m_11 m_12 0 |
// matrix' = | -sin cos 0 | x | m_21 m_22 0 |
// | 0 0 1 | | m_tx m_ty 1 |
@endcode
*/
void Rotate(wxDouble cRadians);
/**
Applies this matrix to the point.
@param p
The point receiving the transformations.
@return The point with the transformations applied.
@code
// | m_11 m_12 0 |
// point' = | src.m_x src._my 1 | x | m_21 m_22 0 |
// | m_tx m_ty 1 |
@endcode
*/
wxPoint2DDouble TransformPoint(const wxPoint2DDouble& p) const;
void TransformPoint(wxDouble* x, wxDouble* y) const;
/**
Applies the linear part of this matrix, i.e.\ without translation.
@param p
The source receiving the transformations.
@return The source with the transformations applied.
@code
// | m_11 m_12 0 |
// dist' = | src.m_x src._my 0 | x | m_21 m_22 0 |
// | m_tx m_ty 1 |
@endcode
*/
wxPoint2DDouble TransformDistance(const wxPoint2DDouble& p) const;
void TransformDistance(wxDouble* dx, wxDouble* dy) const;
};

View File

@@ -0,0 +1,198 @@
/////////////////////////////////////////////////////////////////////////////
// Name: affinematrix2dbase.h
// Purpose: wxMatrix2D documentation
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxMatrix2D
A simple container for 2x2 matrix.
This simple structure is used with wxAffineMatrix2D.
@library{wxcore}
@category{misc}
@since 2.9.2
*/
struct wxMatrix2D
{
/**
Default constructor.
Initializes the matrix elements to the identity.
*/
wxMatrix2D(wxDouble v11 = 1,
wxDouble v12 = 0,
wxDouble v21 = 0,
wxDouble v22 = 1);
/// The matrix elements in the usual mathematical notation.
wxDouble m_11, m_12, m_21, m_22;
};
/**
@class wxAffineMatrix2DBase
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.
@library{wxcore}
@category{misc}
@since 2.9.2
*/
class wxAffineMatrix2DBase
{
public:
/**
Default constructor.
The matrix elements are initialize to the identity matrix.
*/
wxAffineMatrix2DBase();
virtual ~wxAffineMatrix2DBase();
/**
Set all elements of this matrix.
@param mat2D
The rotational components of the matrix (upper 2 x 2).
@param tr
The translational components of the matrix.
*/
virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr) = 0;
/**
Get the component values of the matrix.
@param mat2D
The rotational components of the matrix (upper 2 x 2), must be
non-null.
@param tr
The translational components of the matrix, may be @NULL.
*/
virtual void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const = 0;
/**
Concatenate this matrix with another one.
The parameter matrix is the multiplicand.
@param t
The multiplicand.
@code
// | t.m_11 t.m_12 0 | | m_11 m_12 0 |
// matrix' = | t.m_21 t.m_22 0 | x | m_21 m_22 0 |
// | t.m_tx t.m_ty 1 | | m_tx m_ty 1 |
@endcode
*/
virtual void Concat(const wxAffineMatrix2DBase& t) = 0;
/**
Invert this matrix.
If the matrix is not invertible, i.e. if its determinant is 0, returns
false and doesn't modify it.
@code
// | m_11 m_12 0 |
// Invert | m_21 m_22 0 |
// | m_tx m_ty 1 |
@endcode
*/
virtual bool Invert() = 0;
/**
Check if this is the identity matrix.
*/
virtual bool IsIdentity() const = 0;
///@{
/**
Check that this matrix is identical with @a t.
@param t
The matrix compared with this.
*/
virtual bool IsEqual(const wxAffineMatrix2DBase& t) const = 0;
bool operator==(const wxAffineMatrix2DBase& t) const;
///@}
/**
Check that this matrix differs from @a t.
@param t
The matrix compared with this.
*/
bool operator!=(const wxAffineMatrix2DBase& t) const;
/**
Add the translation to this matrix.
@param dx
The translation in x direction.
@param dy
The translation in y direction.
*/
virtual void Translate(wxDouble dx, wxDouble dy) = 0;
/**
Add scaling to this matrix.
@param xScale
Scaling in x direction.
@param yScale
Scaling in y direction.
*/
virtual void Scale(wxDouble xScale, wxDouble yScale) = 0;
/**
Add clockwise rotation to this matrix.
@param cRadians
Rotation angle in radians, clockwise.
*/
virtual void Rotate(wxDouble cRadians) = 0;
/**
Add mirroring to this matrix.
@param direction
The direction(s) used for mirroring. One of wxHORIZONTAL,
wxVERTICAL or their combination wxBOTH.
*/
void Mirror(int direction = wxHORIZONTAL);
/**
Applies this matrix to the point.
@param p
The point receiving the transformations.
@return The point with the transformations applied.
*/
wxPoint2DDouble TransformPoint(const wxPoint2DDouble& p) const;
void TransformPoint(wxDouble* x, wxDouble* y) const;
/**
Applies the linear part of this matrix, i.e.\ without translation.
@param p
The source receiving the transformations.
@return The source with the transformations applied.
*/
wxPoint2DDouble TransformDistance(const wxPoint2DDouble& p) const;
void TransformDistance(wxDouble* dx, wxDouble* dy) const;
};

View File

@@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/anidecod.h
// Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation
// Author: Francesco Montorsi
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxANIDecoder
An animation decoder supporting animated cursor (.ani) files.
*/
class wxANIDecoder : public wxAnimationDecoder
{
public:
wxANIDecoder();
~wxANIDecoder();
virtual bool Load( wxInputStream& stream );
virtual wxAnimationDecoder *Clone() const;
virtual wxAnimationType GetType() const;
virtual bool ConvertToImage(unsigned int frame, wxImage *image) const;
virtual wxSize GetFrameSize(unsigned int frame) const;
virtual wxPoint GetFramePosition(unsigned int frame) const;
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
virtual long GetDelay(unsigned int frame) const;
virtual wxColour GetTransparentColour(unsigned int frame) const;
protected:
virtual bool DoCanRead(wxInputStream& stream) const;
};

View File

@@ -0,0 +1,557 @@
/////////////////////////////////////////////////////////////////////////////
// Name: animate.h
// Purpose: interface of wxAnimation* classes
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Supported animation types.
*/
enum wxAnimationType
{
wxANIMATION_TYPE_INVALID,
/** represents an animated GIF file. */
wxANIMATION_TYPE_GIF,
/** represents an ANI file. */
wxANIMATION_TYPE_ANI,
/** represents an animated WebP file. */
wxANIMATION_TYPE_WEBP, ///< @since 3.3.0
/** autodetect the filetype. */
wxANIMATION_TYPE_ANY
};
#define wxAC_NO_AUTORESIZE (0x0010)
#define wxAC_DEFAULT_STYLE (wxBORDER_NONE)
/**
Container for possible multiple versions of the same animation in different
resolutions.
This class is used to pass either one or multiple animations to use in
wxAnimationCtrl. If it contains multiple elements, they must be added to it
using its Add() function in ascending size order and, in particular, the
first element defines the size of the animation in standard DPI, with the
other elements containing versions of the animation to use in higher DPI.
Example of using this class to pass a normal and high DPI version of a
"throbbing" animation to the control and let it choose the one most
appropriate to the current resolution automatically:
@code
auto animationCtrl = new wxAnimationCtrl(parent, wxID_ANY);
wxAnimationBundle animations;
animations.Add("throbber.gif");
animations.Add("throbber_2x.gif");
if ( animationCtrl->SetAnimation(animations) )
animationCtrl->Play();
@endcode
@since 3.3.0
*/
class wxAnimationBundle
{
public:
/**
Default constructor creates an empty bundle.
Call Add() later.
*/
wxAnimationBundle() = default;
/**
Implicit ctor from wxAnimation for backwards compatibility.
*/
wxAnimationBundle(const wxAnimation& anim);
/**
Implicit ctor from animation file name for backwards compatibility.
*/
wxAnimationBundle(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY);
wxAnimationBundle(const wxAnimationBundle&) = default;
wxAnimationBundle& operator=(const wxAnimationBundle&) = default;
~wxAnimationBundle() = default;
/**
Add an animation in another, bigger, size.
*/
void Add(const wxAnimation& anim);
/// @overload
void Add(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY);
/**
Get vector containing all animations in this bundle.
The vector can be empty.
*/
const std::vector<wxAnimation>& GetAll() const;
/**
Return true if this animation bundle is not empty.
Notice that any elements of the bundle are always valid animations.
*/
bool IsOk() const;
};
/**
@class wxAnimationCtrl
This is a static control which displays an animation.
wxAnimationCtrl API is as simple as possible and won't give you full control
on the animation; if you need it then use wxMediaCtrl.
This control is useful to display a (small) animation while doing a long task
(e.g. a "throbber").
It is only available if @c wxUSE_ANIMATIONCTRL is set to 1 (the default).
For the platforms where this control has a native implementation, it may
have only limited support for the animation types, see @c
wxGenericAnimationCtrl if you need to support all of them.
@beginStyleTable
@style{wxAC_DEFAULT_STYLE}
The default style: wxBORDER_NONE.
@style{wxAC_NO_AUTORESIZE}
By default, the control will adjust its size to exactly fit to the
size of the animation when SetAnimation is called. If this style
flag is given, the control will not change its size
@endStyleTable
@library{wxcore}
@category{ctrl}
@nativeimpl{wxgtk,wxmsw}
@appearance{animationctrl}
@see wxAnimation, @sample{animate}
*/
class wxAnimationCtrl : public wxControl
{
public:
/**
Initializes the object and calls Create() with
all the parameters.
*/
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 = wxAnimationCtrlNameStr);
/**
Creates the control with the given @a anim animation.
After control creation you must explicitly call Play() to start to play
the animation. Until that function won't be called, the first frame
of the animation is displayed.
@param parent
Parent window, must be non-null.
@param id
The identifier for the control.
@param anim
The initial animation shown in the control.
@param pos
Initial position.
@param size
Initial size.
@param style
The window style, see wxAC_* flags.
@param name
Control name.
@return @true if the control was successfully created or @false if
creation failed.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
const wxString& name = wxAnimationCtrlNameStr);
/**
Create a new animation object compatible with this control.
A wxAnimation object created using this function is always compatible
with controls of this type, see wxAnimation::IsCompatibleWith().
@see CreateCompatibleAnimation()
@since 3.1.4
*/
wxAnimation CreateAnimation() const;
/**
Create a new animation object compatible with this control.
This method does the same thing as CreateAnimation() but is static,
i.e. can be called without creating any wxAnimationCtrl objects.
@since 3.1.4
*/
static wxAnimation CreateCompatibleAnimation();
/**
Returns the animation associated with this control.
*/
virtual wxAnimation GetAnimation() const;
/**
Returns the inactive bitmap shown in this control when the;
see SetInactiveBitmap() for more info.
*/
wxBitmap GetInactiveBitmap() const;
/**
Returns @true if the animation is being played.
*/
virtual bool IsPlaying() const;
/**
Loads the animation from the given file and calls SetAnimation().
See wxAnimation::LoadFile for more info.
*/
virtual bool LoadFile(const wxString& file,
wxAnimationType animType = wxANIMATION_TYPE_ANY);
/**
Loads the animation from the given stream and calls SetAnimation().
See wxAnimation::Load() for more info.
*/
virtual bool Load(wxInputStream& file,
wxAnimationType animType = wxANIMATION_TYPE_ANY);
/**
Starts playing the animation.
The animation is always played in loop mode (unless the last frame of the
animation has an infinite delay time) and always start from the first frame
even if you @ref Stop "stopped" it while some other frame was displayed.
*/
virtual bool Play();
/**
Sets the animation to play in this control.
If the previous animation is being played, it's @ref Stop() stopped.
Until Play() isn't called, a static image, the first frame of the given
animation or the background colour will be shown
(see SetInactiveBitmap() for more info).
Note that while this function takes wxAnimationBundle parameter, it is
possible to pass just a single wxAnimation to it too, as it is
implicitly converted to a bundle. Moreover, is it also possible to call
this function with just the name of the animation file, e.g.
@code
animationCtrl->SetAnimation("progress.gif");
@endcode
due to the existence of another implicit constructor, however this
doesn't allow to check for errors when creating the animation and is
not recommended.
If the animation bundle contains more than one animation, the one
appropriate for the current display resolution is chosen.
*/
virtual void SetAnimation(const wxAnimationBundle& animations);
/**
Sets the bitmap to show on the control when it's not playing an animation.
If you set as inactive bitmap ::wxNullBitmap (which is the default), then the
first frame of the animation is instead shown when the control is inactive;
in this case, if there's no valid animation associated with the control
(see SetAnimation()), then the background colour of the window is shown.
If the control is not playing the animation, the given bitmap will be
immediately shown, otherwise it will be shown as soon as Stop() is called.
Note that the inactive bitmap, if smaller than the control's size, will be
centered in the control; if bigger, it will be stretched to fit it.
*/
virtual void SetInactiveBitmap(const wxBitmapBundle& bmp);
/**
Stops playing the animation.
The control will show the first frame of the animation, a custom static image or
the window's background colour as specified by the last SetInactiveBitmap() call.
*/
virtual void Stop();
};
/**
@class wxGenericAnimationCtrl
Generic implementation of wxAnimationCtrl interface.
If the platform supports a native animation control (currently just wxGTK)
then this class implements the same interface internally in wxWidgets.
One advantage of using this class instead of the native version is that
this version of the control is capable of using animations in other formats
than the ones supported by the @c gdk-pixbuf library used by wxGTK, which
typically only supports @c wxANIMATION_TYPE_GIF.
Note that to use this class you need to explicitly include the generic
header after including the main one before using it, i.e.
@code
#include <wx/animate.h>
#include <wx/generic/animate.h>
@endcode
@library{wxcore}
@category{gdi}
*/
class wxGenericAnimationCtrl : public wxAnimationCtrl
{
public:
/**
Initializes the object and calls Create() with
all the parameters.
*/
wxGenericAnimationCtrl(wxWindow* parent, wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
const wxString& name = wxAnimationCtrlNameStr);
/**
Creates the control with the given @a anim animation.
After control creation you must explicitly call Play() to start to play
the animation. Until that function won't be called, the first frame
of the animation is displayed.
@param parent
Parent window, must be non-null.
@param id
The identifier for the control.
@param anim
The initial animation shown in the control.
@param pos
Initial position.
@param size
Initial size.
@param style
The window style, see wxAC_* flags.
@param name
Control name.
@return @true if the control was successfully created or @false if
creation failed.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
const wxString& name = wxAnimationCtrlNameStr);
/**
Draw the current frame of the animation into given DC.
This is fast as current frame is always cached.
*/
void DrawCurrentFrame(wxDC& dc);
/**
Returns a wxBitmap with the current frame drawn in it.
*/
wxBitmap& GetBackingStore();
/**
This overload of Play() lets you specify if the animation must loop or not
*/
bool Play(bool looped);
/**
Specify whether the animation's background colour is to be shown (the default),
or whether the window background should show through
*/
void SetUseWindowBackgroundColour(bool useWinBackground = true);
/**
Returns @c true if the window's background colour is being used.
*/
bool IsUsingWindowBackgroundColour() const;
};
/**
@class wxAnimation
The @c wxAnimation class handles the interface between the animation
control and the details of the animation image or data.
@stdobjects
::wxNullAnimation
@see wxAnimationCtrl, @sample{animate}
*/
class wxAnimation : public wxObject
{
public:
/**
Constructs a new empty animation object.
Call Load() to initialize it.
@see wxAnimationCtrl::CreateAnimation()
*/
wxAnimation();
/**
Constructs a new animation object and load the animation data from the
given filename.
@param name
A filename.
@param type
One of the ::wxAnimationType values; wxANIMATION_TYPE_ANY
means that the function should try to autodetect the filetype.
@see wxAnimationCtrl::CreateAnimation()
*/
wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
/**
Copy constructor.
*/
wxAnimation(const wxAnimation& other);
/**
Returns @true if animation data is present.
*/
bool IsOk() const;
/**
Returns @true if animation can be used with controls of the given type.
This function checks if this animation object can be used with
wxAnimationCtrl of particular type. This will be always the case for
the platforms where only a single wxAnimationCtrl implementation is
available, but not necessarily under e.g. wxGTK where both native (but
limited) GTK implementation and generic implementation can be used.
@since 3.1.4
*/
bool IsCompatibleWith(wxClassInfo* ci) const;
/**
Returns the delay for the i-th frame in milliseconds.
If @c -1 is returned the frame is to be displayed forever.
*/
int GetDelay(unsigned int frame) const;
/**
Returns the number of frames for this animation.
This method is not implemented in the native wxGTK implementation of
this class and always returns 0 there.
*/
unsigned int GetFrameCount() const;
/**
Returns the i-th frame as a wxImage.
This method is not implemented in the native wxGTK implementation of
this class and always returns an invalid image there.
*/
wxImage GetFrame(unsigned int frame) const;
/**
Returns the size of the animation.
*/
wxSize GetSize() const;
/**
Loads an animation from a file.
@param name
A filename.
@param type
One of the ::wxAnimationType values; wxANIMATION_TYPE_ANY
means that the function should try to autodetect the filetype.
@return @true if the operation succeeded, @false otherwise.
*/
bool LoadFile(const wxString& name, wxAnimationType type = wxANIMATION_TYPE_ANY);
/**
Loads an animation from the given stream.
@param stream
The stream to use to load the animation.
Under wxGTK may be any kind of stream; under other platforms
this must be a seekable stream.
@param type
One of the ::wxAnimationType enumeration values.
@return @true if the operation succeeded, @false otherwise.
*/
bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
/**
Returns the list of animation decoders used by the generic animation
and @c wxGenericAnimationCtrl.
*/
static inline wxAnimationDecoderList& GetHandlers();
/**
Add a new decoder to the list of animation decoders.
*/
static void AddHandler(wxAnimationDecoder *handler);
/**
Insert a new decoder to the front of the list of animation decoders.
*/
static void InsertHandler(wxAnimationDecoder *handler);
/**
Search for an animation decoder by type.
*/
static const wxAnimationDecoder *FindHandler( wxAnimationType animType );
/**
Load the stock animation decoders (currently GIF, ANI and WebP) into the
list of decoders. This is called automatically at program startup.
*/
static void InitStandardHandlers();
/**
Clear out the animation decoder list. This is called automatically at
program shutdown.
*/
static void CleanUpHandlers();
};
// ============================================================================
// Global functions/macros
// ============================================================================
/**
An empty animation object.
*/
wxAnimation wxNullAnimation;

View File

@@ -0,0 +1,111 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/animdecod.h
// Purpose: wxAnimationDecoder
// Author: Francesco Montorsi
// Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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
};
/**
@class wxAnimationDecoder
wxAnimationDecoder is used by @c wxAnimation for loading frames and other
information for the animation from the animation image file.
*/
class wxAnimationDecoder : public wxObjectRefData
{
public:
wxAnimationDecoder();
/**
Load the animation image frames from the given stream.
*/
virtual bool Load( wxInputStream& stream ) = 0;
/**
Returns @true if this decoder supports loading from the given stream.
*/
bool CanRead( wxInputStream& stream ) const;
/**
Create a copy of this decoder.
*/
virtual wxAnimationDecoder *Clone() const = 0;
/**
Return the animation type this decoder implements.
*/
virtual wxAnimationType GetType() const = 0;
/**
Convert given frame to @c wxImage.
*/
virtual bool ConvertToImage(unsigned int frame, wxImage *image) const = 0;
/*
Get the size of the given animation frame.
It's possible that not all frames are 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;
/*
Returns the position of the frame, in case it's not as big as the animation size,
or @c 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;
/**
Return the number of milliseconds this frame should be displayed.
If -1 is returned then the frame must be displayed forever.
*/
virtual long GetDelay(unsigned int frame) const = 0;
/**
The transparent colour for this frame, if any, or @c wxNullColour.
*/
virtual wxColour GetTransparentColour(unsigned int frame) const = 0;
wxSize GetAnimationSize() const;
wxColour GetBackgroundColour() const;
unsigned int GetFrameCount() const;
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 @c CanRead() will do it.
*/
virtual bool DoCanRead(wxInputStream& stream) const = 0;
};

View File

@@ -0,0 +1,435 @@
/////////////////////////////////////////////////////////////////////////////
// Name: any.h
// Purpose: interface of wxAny
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxAny
The wxAny class represents a container for any type. Its value
can be changed at run time, possibly to a different type of value.
wxAny is a backwards-incompatible (but convertible) successor class for
wxVariant, essentially doing the same thing in a more modern, template-
based manner and with transparent support for any user data type.
Some pseudo-code'ish example of use with arbitrary user data:
@code
void SomeFunction()
{
MyClass myObject;
wxAny any = myObject;
// Do something
// ...
// Let's do a sanity check to make sure that any still holds
// data of correct type.
if ( any.CheckType<MyClass>() )
{
// Thank goodness, still a correct type.
MyClass myObject2 = any.As<MyClass>();
}
else
{
// Something has gone horribly wrong!
wxFAIL();
}
}
@endcode
When compared to wxVariant, there are various internal implementation
differences as well. For instance, wxAny only allocates separate data
object in heap for large objects (i.e. ones with size more than
WX_ANY_VALUE_BUFFER_SIZE, which at the time of writing is 16 bytes).
@note When performing conversions between strings and floating point
numbers, the representation of numbers in C locale is always used.
I.e. @code wxAny("1.23").GetAs<double>() @endcode will always work,
even if the current locale uses comma as decimal separator.
@library{wxbase}
@category{data}
@see wxAnyValueType, wxVariant, @ref overview_cpp_rtti_disabled
*/
class wxAny
{
public:
/**
Default constructor. It seeds the object with a null value.
*/
wxAny();
/**
Constructs wxAny from data.
*/
template<typename T>
wxAny(const T& value);
/**
Constructs wxAny from another wxAny.
*/
wxAny(const wxAny& any);
/**
Constructs wxAny, converting value from wxVariant.
@remarks Because of this conversion, it is not usually possible to
have wxAny that actually holds a wxVariant. If wxVariant
cannot be converted to a specific data type, wxAny will then
hold and manage reference to wxVariantData* similar to how
wxVariant does.
Note that objects constructed from list-valued variants
require the list to be explicitly cleared using wxClearList()
to avoid leaking memory. This unfortunate behaviour will not
be changed to prevent breaking the existing code relying on it.
@code
wxVariant vList;
vList.NullList();
vList.Append(15);
vList.Append("abc");
// Create wxAny from the list variant.
wxAny any = wxAny(vList);
// Clear the list to avoid the memory leak.
wxAnyList anyList = any.As<wxAnyList>();
wxClearList(anyList);
@endcode
*/
wxAny(const wxVariant& variant);
/**
Destructor.
*/
~wxAny();
/**
This template function converts wxAny into given type. In most cases
no type conversion is performed, so if the type is incorrect an
assertion failure will occur.
@remarks For convenience, conversion is done when T is wxString. This
is useful when a string literal (which are treated as
const char* and const wchar_t*) has been assigned to wxAny.
*/
template<typename T>
T As() const;
/**
Use this template function for checking if this wxAny holds
a specific C++ data type.
@see wxAnyValueType::CheckType()
*/
template<typename T>
bool CheckType() const;
/**
Template function that retrieves and converts the value of this
wxAny to the type that T* value is.
@return Returns @true if conversion was successful.
*/
template<typename T>
bool GetAs(T* value) const;
/**
Specialization of GetAs() that allows conversion of wxAny into
wxVariant.
@return Returns @true if conversion was successful. Conversion usually
only fails if variant used custom wxVariantData that did not
implement the wxAny to wxVariant conversion functions.
*/
bool GetAs(wxVariant* value) const;
/**
Returns the value type as wxAnyValueType instance.
@remarks You cannot reliably test whether two wxAnys are of
same value type by simply comparing return values
of wxAny::GetType(). Instead, use wxAny::HasSameType().
@see HasSameType()
*/
const wxAnyValueType* GetType() const;
/**
Returns @true if this and another wxAny have the same
value type.
*/
bool HasSameType(const wxAny& other) const;
/**
Tests if wxAny is null (that is, whether there is no data).
*/
bool IsNull() const;
/**
Makes wxAny null (that is, clears it).
*/
void MakeNull();
///@{
/**
@name Assignment operators
*/
template<typename T>
wxAny& operator=(const T &value);
wxAny& operator=(const wxAny &any);
wxAny& operator=(const wxVariant &variant);
///@}
///@{
/**
@name Equality operators
@remarks Generic template-based comparison operators have not been
provided for various code consistency reasons, so for custom
data types you have do something like this:
@code
if ( any.CheckType<MyClass*>() &&
any.As<MyClass*>() == myObjectPtr )
{
// Do something if any stores myObjectPtr
}
@endcode
*/
bool operator==(signed char value) const;
bool operator==(signed short value) const;
bool operator==(signed int value) const;
bool operator==(signed long value) const;
bool operator==(wxLongLong_t value) const;
bool operator==(unsigned char value) const;
bool operator==(unsigned short value) const;
bool operator==(unsigned int value) const;
bool operator==(unsigned long value) const;
bool operator==(wxULongLong_t value) const;
bool operator==(float value) const;
bool operator==(double value) const;
bool operator==(bool value) const;
bool operator==(const char* value) const;
bool operator==(const wchar_t* value) const;
bool operator==(const wxString& value) const;
///@}
///@{
/**
@name Inequality operators
*/
bool operator!=(signed char value) const;
bool operator!=(signed short value) const;
bool operator!=(signed int value) const;
bool operator!=(signed long value) const;
bool operator!=(wxLongLong_t value) const;
bool operator!=(unsigned char value) const;
bool operator!=(unsigned short value) const;
bool operator!=(unsigned int value) const;
bool operator!=(unsigned long value) const;
bool operator!=(wxULongLong_t value) const;
bool operator!=(float value) const;
bool operator!=(double value) const;
bool operator!=(bool value) const;
bool operator!=(const char* value) const;
bool operator!=(const wchar_t* value) const;
bool operator!=(const wxString& value) const;
///@}
};
/**
Size of the wxAny value buffer.
*/
enum
{
WX_ANY_VALUE_BUFFER_SIZE = 16
};
/**
Type for buffer within wxAny for holding data.
*/
union wxAnyValueBuffer
{
void* m_ptr;
wxByte m_buffer[WX_ANY_VALUE_BUFFER_SIZE];
};
/**
@class wxAnyValueType
wxAnyValueType is base class for value type functionality for C++ data
types used with wxAny. Usually the default template will create a
satisfactory wxAnyValueType implementation for a data type, but
sometimes you may need to add some customization. To do this you will need
to add specialized template of wxAnyValueTypeImpl<>. Often your only
need may be to add dynamic type conversion which would be done like
this:
@code
template<>
class wxAnyValueTypeImpl<MyClass> :
public wxAnyValueTypeImplBase<MyClass>
{
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
public:
wxAnyValueTypeImpl() :
wxAnyValueTypeImplBase<MyClass>() { }
virtual ~wxAnyValueTypeImpl() = default;
virtual bool ConvertValue(const wxAnyValueBuffer& src,
wxAnyValueType* dstType,
wxAnyValueBuffer& dst) const
{
// GetValue() is a static member function implemented
// in wxAnyValueTypeImplBase<>.
MyClass value = GetValue(src);
// TODO: Convert value from src buffer to destination
// type and buffer. If cannot be done, return
// false. This is a simple sample.
if ( dstType->CheckType<wxString>() )
{
wxString s = value.ToString();
wxAnyValueTypeImpl<wxString>::SetValue(s, dst);
}
else
{
return false;
}
}
};
//
// Following must be placed somewhere in your source code
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
@endcode
wxAnyValueTypeImplBase<> template, from which we inherit in the above
example, contains the bulk of the default wxAnyValueTypeImpl<> template
implementation, and as such allows you to easily add some minor
customization.
If you need a have complete control over the type interpretation, you
will need to derive a class directly from wxAnyValueType, like this:
@code
template <>
class wxAnyValueTypeImpl<MyClass> : public wxAnyValueType
{
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
public:
virtual void DeleteValue(wxAnyValueBuffer& buf) const
{
// TODO: Free the data in buffer
// It is important to clear the buffer like this
// at the end of DeleteValue().
buf.m_ptr = nullptr;
}
virtual void CopyBuffer(const wxAnyValueBuffer& src,
wxAnyValueBuffer& dst) const
{
// TODO: Copy value from one buffer to another.
// dst is already uninitialized and does not
// need to be freed.
}
virtual bool ConvertValue(const wxAnyValueBuffer& src,
wxAnyValueType* dstType,
wxAnyValueBuffer& dst) const
{
// TODO: Convert value from src buffer to destination
// type and buffer.
}
//
// Following static functions must be implemented
//
static void SetValue(const T& value,
wxAnyValueBuffer& buf)
{
// TODO: Store value into buf.
}
static const T& GetValue(const wxAnyValueBuffer& buf)
{
// TODO: Return reference to value stored in buffer.
}
};
//
// Following must be placed somewhere in your source code
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
@endcode
@library{wxbase}
@category{data}
@see wxAny
*/
class wxAnyValueType
{
public:
/**
Default constructor.
*/
wxAnyValueType();
/**
Destructor.
*/
virtual ~wxAnyValueType();
/**
Use this template function for checking if wxAnyValueType represents
a specific C++ data type.
@see wxAny::CheckType()
*/
template <typename T>
bool CheckType() const;
/**
Convert value into buffer of different type. Return false if
not possible.
*/
virtual bool ConvertValue(const wxAnyValueBuffer& src,
wxAnyValueType* dstType,
wxAnyValueBuffer& dst) const = 0;
/**
Implement this for buffer-to-buffer copy.
@param src
This is the source data buffer.
@param dst
This is the destination data buffer that is in either
uninitialized or freed state.
*/
virtual void CopyBuffer(const wxAnyValueBuffer& src,
wxAnyValueBuffer& dst) const = 0;
/**
This function is called every time the data in wxAny
buffer needs to be freed.
*/
virtual void DeleteValue(wxAnyValueBuffer& buf) const = 0;
/**
This function is used for internal type matching.
*/
virtual bool IsSameType(const wxAnyValueType* otherType) const = 0;
};

View File

@@ -0,0 +1,226 @@
/////////////////////////////////////////////////////////////////////////////
// Name: anybutton.h
// Purpose: interface of wxAnyButton
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#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 )
#define wxBU_EXACTFIT 0x0001
#define wxBU_NOTEXT 0x0002
#define wxBU_AUTODRAW 0x0004 ///< Obsolete, has no effect.
/**
@class wxAnyButton
A class for common button functionality used as the base for the
various button classes.
*/
class wxAnyButton : public wxControl
{
public:
wxAnyButton();
~wxAnyButton();
/**
Return the bitmap shown by the button.
The returned bitmap may be invalid only if the button doesn't show any
images.
@see SetBitmap()
@since 2.9.1
*/
wxBitmap GetBitmap() const;
/**
Returns the bitmap used when the mouse is over the button.
The returned bitmap is only valid if SetBitmapCurrent() had been
previously called.
@since 2.9.1 (available as wxBitmapButton::GetBitmapHover() in previous
versions)
*/
wxBitmap GetBitmapCurrent() const;
/**
Returns the bitmap used for the disabled state.
The returned bitmap is only valid if SetBitmapDisabled() had been
previously called.
@since 2.9.1 (available in wxBitmapButton only in previous versions)
*/
wxBitmap GetBitmapDisabled() const;
/**
Returns the bitmap used for the focused state.
The returned bitmap is only valid if SetBitmapFocus() had been
previously called.
@since 2.9.1 (available in wxBitmapButton only in previous versions)
*/
wxBitmap GetBitmapFocus() const;
/**
Returns the bitmap for the normal state.
This is exactly the same as GetBitmap() but uses a name
backwards-compatible with wxBitmapButton.
@see SetBitmap(), SetBitmapLabel()
@since 2.9.1 (available in wxBitmapButton only in previous versions)
*/
wxBitmap GetBitmapLabel() const;
/**
Returns the bitmap used when the button is pressed.
The returned bitmap is only valid if SetBitmapPressed() had been
previously called.
@since 2.9.1 (available as wxBitmapButton::GetBitmapSelected() in
previous versions)
*/
wxBitmap GetBitmapPressed() const;
/**
Sets the bitmap to display in the button.
The bitmap is displayed together with the button label. This method
sets up a single bitmap which is used in all button states, use
SetBitmapDisabled(), SetBitmapPressed(), SetBitmapCurrent() or
SetBitmapFocus() to change the individual images used in different
states.
@param bitmap
The bitmap bundle containing the resolution-dependent bitmaps to
display in the button. At default DPI, the size of the bitmap is
determined by the default bundle size, i.e. the value returned from
wxBitmapBundle::GetDefaultSize(). If the bitmap bundle is invalid,
any currently shown bitmaps are removed from the button.
@param dir
The position of the bitmap inside the button. By default it is
positioned to the left of the text, near to the left button border.
Other possible values include wxRIGHT, wxTOP and wxBOTTOM.
@see SetBitmapPosition(), SetBitmapMargins()
@since 2.9.1
*/
void SetBitmap(const wxBitmapBundle& bitmap, wxDirection dir = wxLEFT);
/**
Sets the bitmap to be shown when the mouse is over the button.
If @a bitmap is invalid, the normal bitmap will be used in the current
state.
@see GetBitmapCurrent()
@since 2.9.1 (available as wxBitmapButton::SetBitmapHover() in previous
versions)
*/
void SetBitmapCurrent(const wxBitmapBundle& bitmap);
/**
Sets the bitmap for the disabled button appearance.
If @a bitmap is invalid, the disabled bitmap is set to the
automatically generated greyed out version of the normal bitmap, i.e.
the same bitmap as is used by default if this method is not called at
all. Use SetBitmap() with an invalid bitmap to remove the bitmap
completely (for all states).
@see GetBitmapDisabled(), SetBitmapLabel(),
SetBitmapPressed(), SetBitmapFocus()
@since 2.9.1 (available in wxBitmapButton only in previous versions)
*/
void SetBitmapDisabled(const wxBitmapBundle& bitmap);
/**
Sets the bitmap for the button appearance when it has the keyboard
focus.
If @a bitmap is invalid, the normal bitmap will be used in the focused
state.
@see GetBitmapFocus(), SetBitmapLabel(),
SetBitmapPressed(), SetBitmapDisabled()
@since 2.9.1 (available in wxBitmapButton only in previous versions)
*/
void SetBitmapFocus(const wxBitmapBundle& bitmap);
/**
Sets the bitmap label for the button.
@remarks This is the bitmap used for the unselected state, and for all
other states if no other bitmaps are provided.
@see SetBitmap(), GetBitmapLabel()
@since 2.9.1 (available in wxBitmapButton only in previous versions)
*/
void SetBitmapLabel(const wxBitmapBundle& bitmap);
/**
Sets the bitmap for the selected (depressed) button appearance.
@since 2.9.1 (available as wxBitmapButton::SetBitmapSelected() in
previous versions)
*/
void SetBitmapPressed(const wxBitmapBundle& bitmap);
/**
Get the margins between the bitmap and the text of the button.
@see SetBitmapMargins()
@since 2.9.1
*/
wxSize GetBitmapMargins();
/**
Set the margins between the bitmap and the text of the button.
This method is currently only implemented under MSW. If it is not
called, default margin is used around the bitmap.
@see SetBitmap(), SetBitmapPosition()
@since 2.9.1
*/
///@{
void SetBitmapMargins(wxCoord x, wxCoord y);
void SetBitmapMargins(const wxSize& sz);
///@}
/**
Set the position at which the bitmap is displayed.
This method should only be called if the button does have an associated
bitmap.
@since 2.9.1
@param dir
Direction in which the bitmap should be positioned, one of wxLEFT,
wxRIGHT, wxTOP or wxBOTTOM.
*/
void SetBitmapPosition(wxDirection dir);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////
// Name: interface/wx/appprogress.h
// Purpose: interface of wxAppProgressIndicator
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxAppProgressIndicator
A helper class that can be used to update the progress bar in the taskbar
button on Windows and the dock icon on macOS.
@library{wxcore}
@category{misc}
@onlyfor{wxmsw,wxosx}
@see wxTaskBarButton
@since 3.1.0
*/
class WXDLLIMPEXP_CORE wxAppProgressIndicator
{
public:
/**
Constructs the wxAppProgressIndicator.
@param parent
The parent window of wxAppProgressIndicator. Note that the
window should have its taskbar button showing. If parent is @NULL,
the progress will reflect on the taskbar buttons of all the
top level windows.
@param maxValue
Integer range (maximum value) of the progress indicator.
*/
wxAppProgressIndicator(wxWindow* parent = nullptr, int maxValue = 100);
/**
Destructor, stops displaying progress and returns the indicator to its
normal state.
*/
virtual ~wxAppProgressIndicator();
/**
Check if the application progress display is available.
Currently, this only returns @true under wxMSW or wxOSX.
If this method returns @false, no other methods of this class will do
anything, but they may still be called without any ill effects.
*/
bool IsAvailable() const;
/**
Set the progress value in taskbar button of parent window.
@param value
The new value of the progress meter. It should be less than or equal
to the range.
*/
void SetValue(int value);
/**
Set the progress range in taskbar button of parent window.
*/
void SetRange(int range);
/**
Makes the progress bar run in indeterminate mode.
*/
bool Pulse();
};

View File

@@ -0,0 +1,170 @@
/////////////////////////////////////////////////////////////////////////////
// Name: apptrait.h
// Purpose: interface of wxAppTraits
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxAppTraits
The wxAppTraits class defines various configurable aspects of a wxApp.
You can access it using wxApp::GetTraits() function and you can create your
own wxAppTraits overriding the wxApp::CreateTraits() function.
Note that wxAppTraits is an abstract class since it contains many
pure virtual functions.
In fact, by default, wxWidgets creates a @c wxConsoleAppTraits object for
console applications (i.e. those applications linked against wxBase library
only - see the @ref page_libs page) and a @c wxGUIAppTraits object for GUI
applications.
Both these classes are derived by wxAppTraits and represent concrete
implementation of the wxAppTraits interface.
@library{wxbase}
@category{cfg}
@see @ref overview_app, wxApp
*/
class wxAppTraits
{
public:
/**
Called by wxWidgets to create the default configuration object for the
application. The default version creates a registry-based wxRegConfig
class under MSW and wxFileConfig under all other platforms.
The wxApp::GetAppName and wxApp::GetVendorName methods are used to
determine the registry key or file name.
*/
virtual wxConfigBase* CreateConfig();
/**
Used by wxWidgets to create the main event loop used by wxApp::OnRun().
The default implementation of this method in wxGUIAppTraits returns the
usual platform-specific GUI event loop. The version in wxConsoleAppTraits
returns a console-specific event loop which can be used to handle timer
and socket events in console programs under Unix and MSW or @NULL under
the other platforms where console event loops are not supported yet.
*/
virtual wxEventLoopBase *CreateEventLoop() = 0;
/**
Creates the global font mapper object used for encodings/charset mapping.
*/
virtual wxFontMapper* CreateFontMapper() = 0;
/**
Creates a wxLog class for the application to use for logging errors.
The default implementation returns a new wxLogGui class.
@see wxLog
*/
virtual wxLog* CreateLogTarget() = 0;
/**
Creates the global object used for printing out messages.
*/
virtual wxMessageOutput* CreateMessageOutput() = 0;
/**
Returns 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 mode only and always returns @NULL
in console.
@note the returned pointer needs to be deleted by the caller.
*/
virtual wxRendererNative* CreateRenderer() = 0;
/**
Returns the name of the desktop environment currently running on a Unix
desktop. It returns an empty string for platforms other than wxGTK, or
if the desktop environment could not be determined.
*/
virtual wxString GetDesktopEnvironment() const = 0;
/**
Returns the wxStandardPaths object for the application.
It's normally the same for wxBase and wxGUI except in the case of wxMac
and wxCocoa.
@note
The returned reference is to a @c wxStandardPathsBase class but you
can consider it to be equivalent to wxStandardPaths (which is documented).
*/
virtual wxStandardPaths& GetStandardPaths();
/**
Returns the wxWidgets port ID used by the running program and eventually
fills the given pointers with the values of the major, minor, and micro
digits of the native toolkit currently used.
The version numbers returned are thus detected at run-time and not compile-time
if possible.
E.g. if your program is using wxGTK port this function will return wxPORT_GTK
and put in given pointers the versions of the GTK library in use.
See wxPlatformInfo for more details.
If a micro version is not available it will have a value of 0.
*/
virtual wxPortId GetToolkitVersion(int* major = nullptr,
int* minor = nullptr,
int* micro = nullptr) const = 0;
/**
Returns @true if @c fprintf(stderr) goes somewhere, @false otherwise.
*/
virtual bool HasStderr() = 0;
/**
Returns @true if the library was built as wxUniversal.
Always returns @false for wxBase-only apps.
*/
virtual bool IsUsingUniversalWidgets() const = 0;
/**
Shows the assert dialog with the specified message in GUI mode or just prints
the string to stderr in console mode.
Returns @true to suppress subsequent asserts, @false to continue as before.
*/
virtual bool ShowAssertDialog(const wxString& msg) = 0;
/**
Shows a message box with the given text and title if possible.
In some ports, e.g. wxMSW, a message box will always be shown, while in
the other ones it will be only done if the GUI is available (e.g. X11
display was successfully opened for X11-based ports) and the function
simply returns @false without doing anything otherwise.
This function is safe in the sense that it can always be called, even
before creating wxApp, similarly to wxSafeShowMessage() which is
implemented by calling this function and then logging the message to
standard error stream if it returned @false.
@since 3.1.5
@param text
The text to show to the user.
@param title
The title of the message box shown to the user.
@return @true if the message box was shown or @false otherwise.
*/
virtual bool SafeMessageBox(const wxString& text, const wxString& title) = 0;
/**
Helper function mostly useful for derived classes ShowAssertDialog()
implementation.
Returns the stack frame as a plain (and possibly empty) wxString.
This function is only available when @c wxUSE_STACKWALKER is 1.
@since 3.1.5
*/
virtual wxString GetAssertStackTrace();
};

View File

@@ -0,0 +1,619 @@
/////////////////////////////////////////////////////////////////////////////
// Name: archive.h
// Purpose: interface of wxArchive* classes
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxArchiveInputStream
This is an abstract base class which serves as a common interface to
archive input streams such as wxZipInputStream.
wxArchiveInputStream::GetNextEntry returns an 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 @NULL and sets Eof().
@library{wxbase}
@category{archive,streams}
@see @ref overview_archive, wxArchiveEntry, wxArchiveOutputStream
*/
class wxArchiveInputStream : public wxFilterInputStream
{
public:
/**
Closes the current entry. On a non-seekable stream reads to the end of
the current entry first.
*/
virtual bool CloseEntry() = 0;
/**
Closes the current entry if one is open, then reads the meta-data for
the next entry and returns it in a wxArchiveEntry object, giving away
ownership. Reading this wxArchiveInputStream then returns the entry's data.
*/
wxArchiveEntry* GetNextEntry();
/**
Closes the current entry if one is open, then opens the entry specified
by the wxArchiveEntry object.
@a entry must be from the same archive file that this wxArchiveInputStream
is reading, and it must be reading it from a seekable stream.
*/
virtual bool OpenEntry(wxArchiveEntry& entry) = 0;
};
/**
@class wxArchiveOutputStream
This is an abstract base class which serves as a common interface to
archive output streams such as wxZipOutputStream.
wxArchiveOutputStream::PutNextEntry is used to create a new entry in the
output archive, then the entry's data is written to the wxArchiveOutputStream.
Another call to PutNextEntry() closes the current entry and begins the next.
@library{wxbase}
@category{archive,streams}
@see @ref overview_archive, wxArchiveEntry, wxArchiveInputStream
*/
class wxArchiveOutputStream : public wxFilterOutputStream
{
public:
/**
Calls Close() if it has not already been called.
*/
virtual ~wxArchiveOutputStream();
/**
Closes the archive, returning @true if it was successfully written.
Called by the destructor if not called explicitly.
@see wxOutputStream::Close()
*/
virtual bool Close();
/**
Close the current entry.
It is called implicitly whenever another new entry is created with CopyEntry()
or PutNextEntry(), or when the archive is closed.
*/
virtual bool CloseEntry() = 0;
/**
Some archive formats have additional meta-data that applies to the archive
as a whole.
For example in the case of zip there is a comment, which is stored at the end
of the zip file. CopyArchiveMetaData() can be used to transfer such information
when writing a modified copy of an archive.
Since the position of the meta-data can vary between the various archive
formats, it is best to call CopyArchiveMetaData() before transferring
the entries. The wxArchiveOutputStream will then hold on to the meta-data
and write it at the correct point in the output file.
When the input archive is being read from a non-seekable stream, the
meta-data may not be available when CopyArchiveMetaData() is called,
in which case the two streams set up a link and transfer the data
when it becomes available.
*/
virtual bool CopyArchiveMetaData(wxArchiveInputStream& stream) = 0;
/**
Takes ownership of @a entry and uses it to create a new entry in the
archive. @a entry is then opened in the input stream @a stream
and its contents copied to this stream.
For archive types which compress entry data, CopyEntry() is likely to be
much more efficient than transferring the data using Read() and Write()
since it will copy them without decompressing and recompressing them.
@a entry must be from the same archive file that @a stream is
accessing. For non-seekable streams, @a entry must also be the last
thing read from @a stream.
*/
virtual bool CopyEntry(wxArchiveEntry* entry,
wxArchiveInputStream& stream) = 0;
/**
Create a new directory entry (see wxArchiveEntry::IsDir) with the given
name and timestamp.
PutNextEntry() can also be used to create directory entries, by supplying
a name with a trailing path separator.
*/
virtual bool PutNextDirEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now()) = 0;
/**
Takes ownership of entry and uses it to create a new entry in the archive.
The entry's data can then be written by writing to this wxArchiveOutputStream.
*/
virtual bool PutNextEntry(wxArchiveEntry* entry) = 0;
/**
Create a new entry with the given name, timestamp and size. The entry's
data can then be written by writing to this wxArchiveOutputStream.
*/
virtual bool PutNextEntry(const wxString& name,
const wxDateTime& dt = wxDateTime::Now(),
wxFileOffset size = wxInvalidOffset) = 0;
};
/**
@class wxArchiveEntry
This is an abstract base class which serves as a common interface to
archive entry classes such as wxZipEntry.
These hold the meta-data (filename, timestamp, etc.), for entries
in archive files such as zips and tars.
@section archiveentry_nonseekable About non-seekable streams
This information applies only when reading archives from non-seekable streams.
When the stream is seekable GetNextEntry() returns a fully populated wxArchiveEntry.
See @ref overview_archive_noseek for more information.
For generic programming, when the worst case must be assumed, you can rely on
all the fields of wxArchiveEntry being fully populated when
wxArchiveInputStream::GetNextEntry() returns, with the following exceptions:
@li GetSize(): guaranteed to be available after the entry has been read to Eof(),
or CloseEntry() has been called;
@li IsReadOnly(): guaranteed to be available after the end of the archive has
been reached, i.e. after GetNextEntry() returns @NULL and Eof() is true.
@library{wxbase}
@category{archive,streams}
@see @ref overview_archive, @ref overview_archive_generic,
wxArchiveInputStream, wxArchiveOutputStream, wxArchiveNotifier
*/
class wxArchiveEntry : public wxObject
{
public:
/**
Returns a copy of this entry object.
*/
wxArchiveEntry* Clone() const;
/**
Gets the entry's timestamp.
*/
virtual wxDateTime GetDateTime() const = 0;
/**
Sets the entry's timestamp.
*/
virtual void SetDateTime(const wxDateTime& dt) = 0;
/**
Returns the entry's name, by default in the native format.
The name can include directory components, i.e. it can be a full path.
If this is a directory entry, (i.e. if IsDir() is @true) then the
returned string is the name with a trailing path separator.
*/
virtual wxString GetName(wxPathFormat format = wxPATH_NATIVE) const = 0;
/**
Sets the entry's name.
Setting a name with a trailing path separator sets IsDir().
@see GetName()
*/
virtual void SetName(const wxString& name,
wxPathFormat format = wxPATH_NATIVE) = 0;
/**
Returns the size of the entry's data in bytes.
*/
virtual wxFileOffset GetSize() const = 0;
/**
Sets the size of the entry's data in bytes.
*/
virtual void SetSize(wxFileOffset size) = 0;
/**
Returns the path format used internally within the archive to store
filenames.
*/
virtual wxPathFormat GetInternalFormat() const = 0;
/**
Returns the entry's filename in the internal format used within the
archive. The name can include directory components, i.e. it can be a
full path.
The names of directory entries are returned without any trailing path
separator. This gives a canonical name that can be used in comparisons.
@see @ref overview_archive_byname
*/
virtual wxString GetInternalName() const = 0;
/**
Returns a numeric value unique to the entry within the archive.
*/
virtual wxFileOffset GetOffset() const = 0;
/**
Returns @true if this is a directory entry.
Directory entries are entries with no data, which are used to store
the meta-data of directories. They also make it possible for completely
empty directories to be stored.
@note
The names of entries within an archive can be complete paths, and
unarchivers typically create whatever directories are necessary as they
restore files, even if the archive contains no explicit directory entries.
*/
virtual bool IsDir() const = 0;
/**
Marks this entry as a directory if @a isDir is @true. See IsDir() for more info.
*/
virtual void SetIsDir(bool isDir = true) = 0;
/**
Returns @true if the entry is a read-only file.
*/
virtual bool IsReadOnly() const = 0;
/**
Sets this entry as a read-only file.
*/
virtual void SetIsReadOnly(bool isReadOnly = true) = 0;
/**
Sets the notifier (see wxArchiveNotifier) for this entry.
Whenever the wxArchiveInputStream updates this entry, it will then invoke
the associated notifier's wxArchiveNotifier::OnEntryUpdated method.
Setting a notifier is not usually necessary. It is used to handle
certain cases when modifying an archive in a pipeline (i.e. between
non-seekable streams).
*/
void SetNotifier(wxArchiveNotifier& notifier);
/**
Unsets the notifier eventually attached to this entry.
*/
virtual void UnsetNotifier();
};
/**
@class wxArchiveClassFactory
Allows the creation of streams to handle archive formats such as zip and tar.
For example, given a filename you can search for a factory that will
handle it and create a stream to read it:
@code
factory = wxArchiveClassFactory::Find(filename, wxSTREAM_FILEEXT);
if (factory)
stream = factory->NewStream(new wxFFileInputStream(filename));
@endcode
wxArchiveClassFactory::Find can also search for a factory by MIME type
or wxFileSystem protocol.
The available factories can be enumerated using
wxArchiveClassFactory::GetFirst() and wxArchiveClassFactory::GetNext().
@library{wxbase}
@category{archive,streams}
@see @ref overview_archive, @ref overview_archive_generic, wxArchiveEntry,
wxArchiveInputStream, wxArchiveOutputStream, wxFilterClassFactory
*/
class wxArchiveClassFactory : public wxObject
{
public:
/**
Returns @true if this factory can handle the given protocol, MIME type
or file extension.
When using wxSTREAM_FILEEXT for the second parameter, the first parameter
can be a complete filename rather than just an extension.
*/
bool CanHandle(const wxString& protocol,
wxStreamProtocolType type = wxSTREAM_PROTOCOL) const;
/**
A static member that finds a factory that can handle a given protocol, MIME
type or file extension. Returns a pointer to the class factory if found, or
@NULL otherwise. It does not give away ownership of the factory.
When using wxSTREAM_FILEEXT for the second parameter, the first parameter
can be a complete filename rather than just an extension.
*/
static const wxArchiveClassFactory* Find(const wxString& protocol,
wxStreamProtocolType type = wxSTREAM_PROTOCOL);
/**
Returns the wxMBConv object that the created streams will use when
translating meta-data. The initial default, set by the constructor,
is wxConvLocal.
*/
wxMBConv& GetConv() const;
/**
Sets the wxMBConv object that the created streams will use when
translating meta-data.
*/
void SetConv(wxMBConv& conv);
///@{
/**
GetFirst and GetNext can be used to enumerate the available factories.
For example, to list them:
@code
wxString list;
const wxArchiveClassFactory *factory = wxArchiveClassFactory::GetFirst();
while (factory) {
list << factory->GetProtocol() << "\n";
factory = factory->GetNext();
}
@endcode
GetFirst() and GetNext() return a pointer to a factory or @NULL if no more
are available. They do not give away ownership of the factory.
*/
static const wxArchiveClassFactory* GetFirst();
const wxArchiveClassFactory* GetNext() const;
///@}
/**
Calls the static GetInternalName() function for the archive entry type,
for example wxZipEntry::GetInternalName.
*/
virtual wxString GetInternalName(const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const = 0;
/**
Returns the wxFileSystem protocol supported by this factory.
Equivalent to @code wxString(*GetProtocols()) @endcode.
*/
wxString GetProtocol() const;
/**
Returns the protocols, MIME types or file extensions supported by this
factory, as an array of null terminated strings.
It does not give away ownership of the array or strings.
For example, to list the file extensions a factory supports:
@code
wxString list;
const wxChar *const *p;
for (p = factory->GetProtocols(wxSTREAM_FILEEXT); *p; p++)
list << *p << "\n";
@endcode
*/
virtual const wxChar** GetProtocols(wxStreamProtocolType type = wxSTREAM_PROTOCOL) const = 0;
/**
Create a new wxArchiveEntry object of the appropriate type.
*/
wxArchiveEntry* NewEntry() const;
///@{
/**
Create a new input or output stream to read or write an archive.
If the parent stream is passed as a pointer then the new archive stream
takes ownership of it. If it is passed by reference then it does not.
*/
wxArchiveInputStream* NewStream(wxInputStream& stream) const;
wxArchiveOutputStream* NewStream(wxOutputStream& stream) const;
wxArchiveInputStream* NewStream(wxInputStream* stream) const;
wxArchiveOutputStream* NewStream(wxOutputStream* stream) const;
///@}
/**
Adds this class factory to the list returned by GetFirst() or GetNext().
It is not necessary to do this to use the archive streams. It is usually
used when implementing streams, typically the implementation will
add a static instance of its factory class.
It can also be used to change the order of a factory already in the list,
bringing it to the front. This isn't a thread safe operation
so can't be done when other threads are running that will be using the list.
The list does not take ownership of the factory.
*/
void PushFront();
/**
Removes this class factory from the list returned by GetFirst() and GetNext().
Removing from the list isn't a thread safe operation so can't be done when
other threads are running that will be using the list.
The list does not own the factories, so removing a factory does not delete it.
*/
void Remove();
};
/**
@class wxArchiveNotifier
If you need to know when a wxArchiveInputStream updates a wxArchiveEntry
object, you can create a notifier by deriving from this abstract base class,
overriding wxArchiveNotifier::OnEntryUpdated.
An instance of your notifier class can then be assigned to the wxArchiveEntry
object using wxArchiveEntry::SetNotifier.
Your OnEntryUpdated() method will then be invoked whenever the input
stream updates the entry.
Setting a notifier is not usually necessary. It is used to handle
certain cases when modifying an archive in a pipeline (i.e. between
non-seekable streams).
See @ref overview_archive_noseek.
@library{wxbase}
@category{archive,streams}
@see @ref overview_archive_noseek, wxArchiveEntry, wxArchiveInputStream,
wxArchiveOutputStream
*/
class wxArchiveNotifier
{
public:
/**
This method must be overridden in your derived class.
*/
virtual void OnEntryUpdated(wxArchiveEntry& entry) = 0;
};
/**
@class wxArchiveIterator
An input iterator template class that can be used to transfer an archive's
catalogue to a container.
@code
template<class Arc, class T = typename Arc::entry_type*>
class wxArchiveIterator
{
// this constructor creates an 'end of sequence' object
wxArchiveIterator();
// template parameter 'Arc' should be the type of an archive input stream
wxArchiveIterator(Arc& arc) {
// ...
}
};
@endcode
The first template parameter should be the type of archive input stream
(e.g. wxArchiveInputStream) and the second can either be a pointer to an entry
(e.g. wxArchiveEntry*), or a string/pointer pair
(e.g. std::pair<wxString,wxArchiveEntry*>).
The @c wx/archive.h header defines the following typedefs:
@code
typedef wxArchiveIterator<wxArchiveInputStream> wxArchiveIter;
typedef wxArchiveIterator<wxArchiveInputStream,
std::pair<wxString, wxArchiveEntry*> > wxArchivePairIter;
@endcode
The header for any implementation of this interface should define similar
typedefs for its types, for example in @c wx/zipstrm.h there is:
@code
typedef wxArchiveIterator<wxZipInputStream> wxZipIter;
typedef wxArchiveIterator<wxZipInputStream,
std::pair<wxString, wxZipEntry*> > wxZipPairIter;
@endcode
Transferring the catalogue of an archive @e arc to a vector @e cat,
can then be done something like this:
@code
std::vector<wxArchiveEntry*> cat((wxArchiveIter)arc, wxArchiveIter());
@endcode
When the iterator is dereferenced, it gives away ownership of an entry
object. So in the above example, when you have finished with @e cat
you must delete the pointers it contains.
If you have smart pointers with normal copy semantics (i.e. not auto_ptr
or wxScopedPtr), then you can create an iterator which uses them instead.
For example, with a smart pointer class for zip entries @e ZipEntryPtr:
@code
typedef std::vector<ZipEntryPtr> ZipCatalog;
typedef wxArchiveIterator<wxZipInputStream, ZipEntryPtr> ZipIter;
ZipCatalog cat((ZipIter)zip, ZipIter());
@endcode
Iterators that return std::pair objects can be used to populate a std::multimap,
to allow entries to be looked up by name.
The string is initialised using the wxArchiveEntry object's
wxArchiveEntry::GetInternalName function.
@code
typedef std::multimap<wxString, wxZipEntry*> ZipCatalog;
ZipCatalog cat((wxZipPairIter)zip, wxZipPairIter());
@endcode
Note that this iterator also gives away ownership of an entry
object each time it is dereferenced. So in the above example, when
you have finished with @e cat you must delete the pointers it contains.
Or if you have them, a pair containing a smart pointer can be used
(again @e ZipEntryPtr), no worries about ownership:
@code
typedef std::multimap<wxString, ZipEntryPtr> ZipCatalog;
typedef wxArchiveIterator<wxZipInputStream,
std::pair<wxString, ZipEntryPtr> > ZipPairIter;
ZipCatalog cat((ZipPairIter)zip, ZipPairIter());
@endcode
@library{wxbase}
@category{archive,streams}
@see wxArchiveEntry, wxArchiveInputStream, wxArchiveOutputStream
*/
class wxArchiveIterator
{
public:
/**
Default constructor.
*/
wxArchiveIterator();
/**
Construct the iterator that returns all the entries in the archive input
stream @a arc.
*/
wxArchiveIterator(Arc& arc);
/**
Returns an entry object from the archive input stream, giving away
ownership.
*/
const T operator*() const;
///@{
/**
Position the input iterator at the next entry in the archive input stream.
*/
wxArchiveIterator operator++();
wxArchiveIterator operator++(int);
///@}
};

View File

@@ -0,0 +1,616 @@
/////////////////////////////////////////////////////////////////////////////
// Name: arrstr.h
// Purpose: interface of wxArrayString
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxArrayString
wxArrayString is a legacy class similar to std::vector<wxString>.
As all the other legacy @ref overview_container "container classes",
this class shouldn't normally be used in the new code, but is still needed
when passing multiple items to various functions in wxWidgets API, notably
the constructors of various GUI control classes. Usually, even in this case
it doesn't need to be used explicitly, as wxArrayString will be implicitly
created if you use either an initializer list or a vector of strings, e.g.
you can just pass either of those instead of wxArrayString, for example
@code
// wxListBox ctor is documented as taking wxArrayString but you can
// pass an initializer_list to it directly:
auto listbox = new wxListBox(parent, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
{ "some", "items", "for", "the", "listbox" });
// Similarly, if you already have a vector filled with strings
// elsewhere in your program, you can just pass it instead:
std::vector<std::string> countries = GetListOfCountries();
auto choices = new wxChoice(parent, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
countries);
@endcode
When using a wxWidgets function returning an object of this class, you can
either use it as if it were a `std::vector<wxString>`, as this class has
all vector methods, or actually convert it to such vector using its
AsVector(), e.g.
@code
wxArrayString files;
wxDir::GetAllFiles("/some/path", &files);
// Can use the usual accessors:
if ( !files.empty() ) {
auto first = files[0];
auto total = files.size();
...
}
// Can iterate over it like over a vector, too.
for ( const wxString& file: files ) {
...
}
// Or can just convert it to the "real" vector:
const std::vector<wxString>& vec = files.AsVector();
@endcode
@library{wxbase}
@category{containers}
@see wxSortedArrayString, wxArray<T>, wxString, @ref overview_string
*/
class wxArrayString : public wxArray
{
public:
/**
The function type used with wxArrayString::Sort().
This function uses the same conventions as the standard @c qsort()
comparison function, that is it should return a negative value if the
first argument is less than the second one, a positive value if the
first argument is greater than the second one and 0 if the arguments
are equal.
@since 3.1.0
*/
typedef int (*CompareFunction)(const wxString& first, const wxString& second);
/**
Default constructor.
*/
wxArrayString();
/**
Copy constructor.
*/
wxArrayString(const wxArrayString& array);
/**
Constructor from a C string array. Pass a size @a sz and an array @a arr.
*/
wxArrayString(size_t sz, const char** arr);
/**
Constructor from a C wide string array. Pass a size @a sz and an array @a arr.
*/
wxArrayString(size_t sz, const wchar_t** arr);
/**
Constructor from a wxString array. Pass a size @a sz and array @a arr.
*/
wxArrayString(size_t sz, const wxString* arr);
/**
Constructs the container with the contents of the initializer_list @a list.
@since 3.2.3
*/
template<typename T>
wxArrayString(std::initializer_list<T> list);
/**
Constructs the container with the contents of the vector @a vec.
Template parameter `T` must be convertible to wxString, i.e. it can be
wxString itself or `std::string`, `std::wstring` etc.
@since 3.3.0
*/
template<typename T>
wxArrayString(const std::vector<T>& vec);
/**
Constructs the container with the contents of the vector @a vec.
In the default build, in which wxArrayString is implemented using
`std::vector<>` internally, this constructor is more efficient than the
overload taking const reference to the vector, as it reuses the
existing vector data instead of copying it.
Otherwise it is identical to the other overload, see its documentation
for more details.
@since 3.3.0
*/
template<typename T>
wxArrayString(std::vector<T>&& vec);
/**
Destructor frees memory occupied by the array strings. For performance
reasons it is not virtual, so this class should not be derived from.
*/
~wxArrayString();
/**
Appends the given number of @a copies of the new item @a str to the
array and returns the index of the first new item in the array.
@see Insert()
*/
size_t Add(const wxString& str, size_t copies = 1);
/**
Preallocates enough memory to store @a nCount items.
This function may be used to improve array class performance before
adding a known number of items consecutively.
*/
void Alloc(size_t nCount);
/**
Constructs a std::vector containing the same strings as this array.
In the default build configuration, this function returns a const
reference to this object itself, without making a copy. But when using
the legacy implementation of wxArrayString not based on `std::vector`,
it has to copy all the strings, making it expensive to call for big
arrays.
Note that using it like this:
@code
const std::vector<wxString>& vec = array.AsVector();
@endcode
works in all build variants as long as you don't need to modify the
returned vector and doesn't impose any extra overhead.
@since 3.3.0
*/
std::vector<wxString> AsVector() const;
/**
Clears the array contents and frees memory.
@see Empty()
*/
void Clear();
/**
Empties the array: after a call to this function GetCount() will return 0.
However, this function does not free the memory used by the array and so
should be used when the array is going to be reused for storing other strings.
Otherwise, you should use Clear() to empty the array and free memory.
*/
void Empty();
/**
Returns the number of items in the array.
*/
size_t GetCount() const;
/**
Searches the array for @a str, starting from the beginning if @a bFromEnd
is @false or from the end otherwise. If @a bCase, comparison is case sensitive
(default), otherwise the case is ignored.
This function uses linear search for wxArrayString.
Returns the index of the first item matched or @c wxNOT_FOUND if there is no match.
*/
int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
/**
Inserts the given number of @a copies of @a str in the array before the
array element at the position @a nIndex. Thus, for example, to insert
the string in the beginning of the array you would write:
@code
Insert("foo", 0);
@endcode
If @a nIndex is equal to GetCount() this function behaves as Add().
*/
void Insert(const wxString& str, size_t nIndex, size_t copies = 1);
/**
Returns @true if the array is empty, @false otherwise. This function returns the
same result as GetCount() == 0 but is probably easier to read.
*/
bool IsEmpty() const;
/**
Return the array element at position @a nIndex. An assert failure will
result from an attempt to access an element beyond the end of array in debug
mode, but no check is done in release mode.
@see operator[] for the operator version.
*/
///@{
wxString& Item(size_t nIndex);
const wxString& Item(size_t nIndex) const;
///@}
/**
Returns the last element of the array. Attempt to access the last element of
an empty array will result in assert failure in debug build, however no checks
are done in release mode.
*/
///@{
wxString& Last();
const wxString& Last() const;
///@}
/**
Removes the first item matching this value. An assert failure is provoked by
an attempt to remove an element which does not exist in debug build.
@see Index()
*/
void Remove(const wxString& sz);
/**
Removes @a count items starting at position @a nIndex from the array.
*/
void RemoveAt(size_t nIndex, size_t count = 1);
/**
Releases the extra memory allocated by the array.
This function is useful to minimize the array memory consumption.
@see Alloc()
*/
void Shrink();
/**
Sorts the array in alphabetical order or in reverse alphabetical order if
@a reverseOrder is @true. The sort is case-sensitive.
*/
void Sort(bool reverseOrder = false);
/**
Sorts the array using the specified @a compareFunction for item comparison.
@a CompareFunction is defined as a function taking two <em>const wxString&</em>
parameters and returning an @e int value less than, equal to or greater
than 0 if the first string is less than, equal to or greater than the
second one.
Example:
The following example sorts strings by their length.
@code
static int CompareStringLen(const wxString& first, const wxString& second)
{
return first.length() - second.length();
}
...
wxArrayString array;
array.Add("one");
array.Add("two");
array.Add("three");
array.Add("four");
array.Sort(CompareStringLen);
@endcode
*/
void Sort(CompareFunction compareFunction);
/**
Compares 2 arrays respecting the case. Returns @true if the arrays have
different number of elements or if the elements don't match pairwise.
*/
bool operator !=(const wxArrayString& array) const;
/**
Assignment operator.
*/
wxArrayString& operator=(const wxArrayString&);
/**
Compares 2 arrays respecting the case. Returns @true only if the arrays have
the same number of elements and the same strings in the same order.
*/
bool operator ==(const wxArrayString& array) const;
/**
Returns the array element at position @a nIndex. An assert failure will
result from an attempt to access an element beyond the end of array in
debug mode, but no check is done in release mode.
This is the operator version of the Item() method.
*/
wxString& operator[](size_t nIndex) const;
};
/**
@class wxSortedArrayString
wxSortedArrayString is an efficient container for storing wxString objects
which always keeps the strings in alphabetical order.
wxSortedArrayString uses binary search in its wxSortedArrayString::Index() method
(instead of linear search for wxArrayString::Index()) which makes it much more
efficient if you add strings to the array rarely (because, of course, you have
to pay for Index() efficiency by having Add() be slower) but search for them
often. Several methods should not be used with sorted array (basically, all
those which break the order of items) which is mentioned in their description.
@library{wxbase}
@category{containers}
@see wxArray, wxString, @ref overview_string
*/
class wxSortedArrayString : public wxArray
{
public:
/**
Default constructor.
The elements of the array are kept sorted in alphabetical order.
*/
wxSortedArrayString();
/**
Constructs a sorted array using the specified @a compareFunction for
item comparison.
@see wxStringSortAscending(), wxDictionaryStringSortAscending()
@since 3.1.0
*/
wxSortedArrayString(CompareFunction compareFunction);
/**
Conversion constructor.
Constructs a sorted array with the same contents as the (possibly
unsorted) @a array argument.
*/
wxSortedArrayString(const wxArrayString& array);
/**
@copydoc wxArrayString::Add()
@warning
For sorted arrays, the index of the inserted item will not be, in general,
equal to GetCount() - 1 because the item is inserted at the correct position
to keep the array sorted and not appended.
*/
size_t Add(const wxString& str, size_t copies = 1);
/**
@copydoc wxArrayString::Index()
This function uses binary search for wxSortedArrayString, but it ignores
the @a bCase and @a bFromEnd parameters.
*/
int Index(const wxString& str, bool bCase = true,
bool bFromEnd = false) const;
/**
@warning This function should not be used with sorted arrays because it
could break the order of items and, for example, subsequent calls
to Index() would then not work!
@warning In STL mode, Insert is private and simply invokes wxFAIL_MSG.
*/
void Insert(const wxString& str, size_t nIndex,
size_t copies = 1);
///@{
/**
@warning This function should not be used with sorted array because it could
break the order of items and, for example, subsequent calls to Index()
would then not work! Also, sorting a wxSortedArrayString doesn't make
sense because its elements are always already sorted.
@warning In STL mode, Sort is private and simply invokes wxFAIL_MSG.
*/
void Sort(bool reverseOrder = false);
void Sort(CompareFunction compareFunction);
///@}
};
/**
Comparison function comparing strings in alphabetical order.
This function can be used with wxSortedArrayString::Sort() or passed as an
argument to wxSortedArrayString constructor.
@see wxStringSortDescending(), wxDictionaryStringSortAscending(),
wxNaturalStringSortAscending()
@since 3.1.0
*/
int wxStringSortAscending(const wxString& s1, const wxString& s2);
/**
Comparison function comparing strings in reverse alphabetical order.
This function can be used with wxSortedArrayString::Sort() or passed as an
argument to wxSortedArrayString constructor.
@see wxStringSortAscending(), wxDictionaryStringSortDescending(),
wxNaturalStringSortDescending()
@since 3.1.0
*/
int wxStringSortDescending(const wxString& s1, const wxString& s2);
/**
Comparison function comparing strings in dictionary order.
The "dictionary order" differs from the alphabetical order in that the
strings differing not only in case are compared case-insensitively to
ensure that "Aa" comes before "AB" in the sorted array, unlike with
wxStringSortAscending().
This function can be used with wxSortedArrayString::Sort() or passed as an
argument to wxSortedArrayString constructor.
@see wxDictionaryStringSortDescending(),
wxStringSortAscending(),
wxNaturalStringSortAscending()
@since 3.1.0
*/
int wxDictionaryStringSortAscending(const wxString& s1, const wxString& s2);
/**
Comparison function comparing strings in reverse dictionary order.
See wxDictionaryStringSortAscending() for the dictionary sort description.
@see wxDictionaryStringSortAscending(),
wxStringSortDescending(),
wxNaturalStringSortDescending()
@since 3.1.0
*/
int wxDictionaryStringSortDescending(const wxString& s1, const wxString& s2);
/**
Comparison function comparing strings in natural order.
This function can be used with wxSortedArrayString::Sort()
or passed as an argument to wxSortedArrayString constructor.
See wxCmpNatural() for more information about how natural
sort order is implemented.
@see wxNaturalStringSortDescending(),
wxStringSortAscending(), wxDictionaryStringSortAscending()
@since 3.1.4
*/
int wxNaturalStringSortAscending(const wxString& s1, const wxString& s2);
/**
Comparison function comparing strings in reverse natural order.
This function can be used with wxSortedArrayString::Sort()
or passed as an argument to wxSortedArrayString constructor.
See wxCmpNatural() for more information about how natural
sort order is implemented.
@see wxNaturalStringSortAscending(),
wxStringSortDescending(), wxDictionaryStringSortDescending()
@since 3.1.4
*/
int wxNaturalStringSortDescending(const wxString& s1, const wxString& s2);
/**
This function compares strings using case-insensitive collation and
additionally, numbers within strings are recognised and compared
numerically, rather than alphabetically. When used for sorting,
the result is that e.g. file names containing numbers are sorted
in a natural way.
For example, sorting with a simple string comparison results in:
- file1.txt
- file10.txt
- file100.txt
- file2.txt
- file20.txt
- file3.txt
But sorting the same strings in natural sort order results in:
- file1.txt
- file2.txt
- file3.txt
- file10.txt
- file20.txt
- file100.txt
wxCmpNatural() uses an OS native natural sort function when available
(currently only under Microsoft Windows), wxCmpNaturalGeneric() otherwise.
Be aware that OS native implementations might differ from each other,
and might change behaviour from release to release.
@see wxNaturalStringSortAscending(), wxNaturalStringSortDescending()
@since 3.1.4
*/
int wxCmpNatural(const wxString& s1, const wxString& s2);
/**
This is wxWidgets' own implementation of the natural sort comparison function.
@see wxCmpNatural()
@since 3.1.4
*/
int wxCmpNaturalGeneric(const wxString& s1, const wxString& s2);
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_string */
///@{
/**
Splits the given wxString object using the separator @a sep and returns the
result as a wxArrayString.
If the @a escape character is non-null, then the occurrences of @a sep
immediately prefixed with @a escape are not considered as separators.
Note that empty tokens will be generated if there are two or more adjacent
separators.
@see wxJoin()
@header{wx/arrstr.h}
*/
wxArrayString wxSplit(const wxString& str, const wxChar sep,
const wxChar escape = '\\');
/**
Concatenate all lines of the given wxArrayString object using the separator
@a sep and returns the result as a wxString.
If the @a escape character is non-null, then it's used as prefix for each
occurrence of @a sep in the strings contained in @a arr before joining them
which is necessary in order to be able to recover the original array
contents from the string later using wxSplit(). The @a escape characters
themselves are @e not escaped when they occur in the middle of the @a arr
elements, but @e are escaped when they occur at the end, i.e.
@code
wxArrayString arr;
arr.push_back("foo^");
arr.push_back("bar^baz");
wxPuts(wxJoin(arr, ':', '^')); // prints "foo^^:bar^baz"
@endcode
In any case, applying wxSplit() to the result of wxJoin() is guaranteed to
recover the original array.
@see wxSplit()
@header{wx/arrstr.h}
*/
wxString wxJoin(const wxArrayString& arr, const wxChar sep,
const wxChar escape = '\\');
///@}

View File

@@ -0,0 +1,542 @@
/////////////////////////////////////////////////////////////////////////////
// Name: artprov.h
// Purpose: interface of wxArtProvider
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
This type identifies the client of the art objects requested to wxArtProvider.
*/
typedef wxString wxArtClient;
/**
This type identifies a specific art object which can be requested to wxArtProvider.
*/
typedef wxString wxArtID;
const char* wxART_TOOLBAR;
const char* wxART_MENU;
const char* wxART_FRAME_ICON;
const char* wxART_CMN_DIALOG;
const char* wxART_HELP_BROWSER;
const char* wxART_MESSAGE_BOX;
const char* wxART_BUTTON;
const char* wxART_LIST;
const char* wxART_OTHER;
const char* wxART_ADD_BOOKMARK;
const char* wxART_DEL_BOOKMARK;
const char* wxART_HELP_SIDE_PANEL;
const char* wxART_HELP_SETTINGS;
const char* wxART_HELP_BOOK;
const char* wxART_HELP_FOLDER;
const char* wxART_HELP_PAGE;
const char* wxART_GO_BACK;
const char* wxART_GO_FORWARD;
const char* wxART_GO_UP;
const char* wxART_GO_DOWN;
const char* wxART_GO_TO_PARENT;
const char* wxART_GO_HOME;
const char* wxART_GOTO_FIRST;
const char* wxART_GOTO_LAST;
const char* wxART_FILE_OPEN;
const char* wxART_FILE_SAVE;
const char* wxART_FILE_SAVE_AS;
const char* wxART_PRINT;
const char* wxART_HELP;
const char* wxART_TIP;
const char* wxART_REPORT_VIEW;
const char* wxART_LIST_VIEW;
const char* wxART_NEW_DIR;
const char* wxART_HARDDISK;
const char* wxART_FLOPPY;
const char* wxART_CDROM;
const char* wxART_REMOVABLE;
const char* wxART_FOLDER;
const char* wxART_FOLDER_OPEN;
const char* wxART_GO_DIR_UP;
const char* wxART_EXECUTABLE_FILE;
const char* wxART_NORMAL_FILE;
const char* wxART_TICK_MARK;
const char* wxART_CROSS_MARK;
const char* wxART_ERROR;
const char* wxART_QUESTION;
const char* wxART_WARNING;
const char* wxART_INFORMATION;
const char* wxART_MISSING_IMAGE;
const char* wxART_COPY;
const char* wxART_CUT;
const char* wxART_PASTE;
const char* wxART_DELETE;
const char* wxART_NEW;
const char* wxART_UNDO;
const char* wxART_REDO;
const char* wxART_PLUS;
const char* wxART_MINUS;
const char* wxART_CLOSE;
const char* wxART_QUIT;
const char* wxART_FIND;
const char* wxART_FIND_AND_REPLACE;
const char* wxART_FULL_SCREEN;
const char* wxART_EDIT;
const char* wxART_WX_LOGO;
/**
@class wxArtProvider
wxArtProvider class is used to customize the look of wxWidgets application.
When wxWidgets needs to display an icon or a bitmap (e.g. in the standard file
dialog), it does not use a hard-coded resource but asks wxArtProvider for it
instead. This way users can plug in their own wxArtProvider class and easily
replace standard art with their own version.
All that is needed is to derive a class from wxArtProvider, override either its
wxArtProvider::CreateBitmap() and/or its wxArtProvider::CreateIconBundle() methods
and register the provider with wxArtProvider::Push():
@code
class MyProvider : public wxArtProvider
{
protected:
// Override this method to return a bundle containing the required
// bitmap in all available sizes.
wxBitmapBundle CreateBitmapBundle(const wxArtID& id,
const wxArtClient& client,
const wxSize& size) override;
// If all bitmaps are available in a single size only, it may be
// simpler to override just this one.
wxBitmap CreateBitmap(const wxArtID& id,
const wxArtClient& client,
const wxSize& size) override;
// optionally override this one as well
wxIconBundle CreateIconBundle(const wxArtID& id,
const wxArtClient& client) override;
{ ... }
};
...
wxArtProvider::Push(new MyProvider);
@endcode
Note that, as usual in wxWidgets API, wxArtProvider takes ownership of the
pointer and will destroy it on program shutdown. In particular, you should
not delete this pointer in your own code.
If you need bitmap images (of the same artwork) that should be displayed at
different sizes you should probably consider overriding wxArtProvider::CreateIconBundle
and supplying icon bundles that contain different bitmap sizes.
There's another way of taking advantage of this class: you can use it in your
code and use platform native icons as provided by wxArtProvider::GetBitmapBundle
or wxArtProvider::GetIcon.
@section artprovider_identify Identifying art resources
Every bitmap and icon bundle are known to wxArtProvider under a unique ID that
is used when requesting a resource from it. The ID is represented by the ::wxArtID type
and can have one of these predefined values (you can see bitmaps represented by these
constants in the @ref page_samples_artprov):
<table>
<tr><td>
@li @c wxART_ERROR
@li @c wxART_QUESTION
@li @c wxART_WARNING
@li @c wxART_INFORMATION
@li @c wxART_ADD_BOOKMARK
@li @c wxART_DEL_BOOKMARK
@li @c wxART_HELP_SIDE_PANEL
@li @c wxART_HELP_SETTINGS
@li @c wxART_HELP_BOOK
@li @c wxART_HELP_FOLDER
@li @c wxART_HELP_PAGE
@li @c wxART_GO_BACK
@li @c wxART_GO_FORWARD
@li @c wxART_GO_UP
@li @c wxART_GO_DOWN
@li @c wxART_GO_TO_PARENT
@li @c wxART_GO_HOME
@li @c wxART_GOTO_FIRST (since 2.9.2)
</td><td>
@li @c wxART_GOTO_LAST (since 2.9.2)
@li @c wxART_PRINT
@li @c wxART_HELP
@li @c wxART_TIP
@li @c wxART_REPORT_VIEW
@li @c wxART_LIST_VIEW
@li @c wxART_NEW_DIR
@li @c wxART_FOLDER
@li @c wxART_FOLDER_OPEN
@li @c wxART_GO_DIR_UP
@li @c wxART_EXECUTABLE_FILE
@li @c wxART_NORMAL_FILE
@li @c wxART_TICK_MARK
@li @c wxART_CROSS_MARK
@li @c wxART_MISSING_IMAGE
@li @c wxART_NEW
@li @c wxART_FILE_OPEN
@li @c wxART_FILE_SAVE
</td><td>
@li @c wxART_FILE_SAVE_AS
@li @c wxART_DELETE
@li @c wxART_COPY
@li @c wxART_CUT
@li @c wxART_PASTE
@li @c wxART_UNDO
@li @c wxART_REDO
@li @c wxART_PLUS (since 2.9.2)
@li @c wxART_MINUS (since 2.9.2)
@li @c wxART_CLOSE
@li @c wxART_QUIT
@li @c wxART_FIND
@li @c wxART_FIND_AND_REPLACE
@li @c wxART_FULL_SCREEN (since 3.1.0)
@li @c wxART_EDIT (since 3.1.0)
@li @c wxART_HARDDISK
@li @c wxART_FLOPPY
@li @c wxART_CDROM
@li @c wxART_REMOVABLE
@li @c wxART_WX_LOGO (since 3.1.6)
</td></tr>
</table>
@note When building with @c wxNO_IMPLICIT_WXSTRING_ENCODING defined (see
@ref overview_string for more details), you need to explicitly use
wxASCII_STR() around these constants.
Additionally, any string recognized by custom art providers registered using
wxArtProvider::Push may be used.
@note
When running under GTK+ 2, GTK+ stock item IDs (e.g. @c "gtk-cdrom") may be used
as well:
@code
#ifdef __WXGTK__
wxBitmap bmp = wxArtProvider::GetBitmap("gtk-cdrom", wxART_MENU);
#endif
@endcode
For a list of the GTK+ stock items please refer to the
<a href="https://developer-old.gnome.org/gtk3/stable/gtk3-Stock-Items.html">GTK+ documentation
page</a>.
It is also possible to load icons from the current icon theme by specifying their name
(without extension and directory components).
Icon themes recognized by GTK+ follow the freedesktop.org
<a href="http://freedesktop.org/Standards/icon-theme-spec">Icon Themes specification</a>.
Note that themes are not guaranteed to contain all icons, so wxArtProvider may
return ::wxNullBitmap or ::wxNullIcon.
The default theme is typically installed in @c /usr/share/icons/hicolor.
@section artprovider_clients Clients
The @e client is the entity that calls wxArtProvider's GetBitmap() or GetIcon() function.
It is represented by wxClientID type and can have one of these values:
@li @c wxART_TOOLBAR
@li @c wxART_MENU
@li @c wxART_BUTTON
@li @c wxART_FRAME_ICON
@li @c wxART_CMN_DIALOG
@li @c wxART_HELP_BROWSER
@li @c wxART_MESSAGE_BOX
@li @c wxART_OTHER (used for all requests that don't fit into any of the
categories above)
Client ID serve as a hint to wxArtProvider that is supposed to help it to
choose the best looking bitmap. For example it is often desirable to use
slightly different icons in menus and toolbars even though they represent
the same action (e.g. wxART_FILE_OPEN). Remember that this is really only a
hint for wxArtProvider -- it is common that wxArtProvider::GetBitmap returns
identical bitmap for different client values!
@library{wxcore}
@category{misc}
@see @ref page_samples_artprov for an example of wxArtProvider usage;
@ref page_stockitems "stock ID list"
*/
class wxArtProvider : public wxObject
{
public:
/**
The destructor automatically removes the provider from the provider stack used
by GetBitmap().
*/
virtual ~wxArtProvider();
/**
Delete the given @a provider.
*/
static bool Delete(wxArtProvider* provider);
/**
Query registered providers for bitmap with given ID.
Note that applications using wxWidgets 3.1.6 or later should prefer
calling GetBitmapBundle().
@param id
wxArtID unique identifier of the bitmap.
@param client
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
@param size
Size of the returned bitmap or wxDefaultSize if size doesn't matter.
@return The bitmap if one of registered providers recognizes the ID or
wxNullBitmap otherwise.
*/
static wxBitmap GetBitmap(const wxArtID& id,
const wxArtClient& client = wxART_OTHER,
const wxSize& size = wxDefaultSize);
/**
Query registered providers for a bundle of bitmaps with given ID.
@since 3.1.6
@param id
wxArtID unique identifier of the bitmap.
@param client
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
@param size
Default size for the returned bundle, i.e. the size of the bitmap
in normal DPI (this implies that wxWindow::FromDIP() must @e not be
used with it).
@return If any of the registered providers recognizes the ID in its
CreateBitmapBundle(), this bundle is returned. Otherwise, if any of
providers returns a valid bitmap from CreateBitmap(), the bundle
containing only this bitmap is returned. Otherwise, an empty bundle
is returned.
*/
static wxBitmapBundle GetBitmapBundle(const wxArtID& id,
const wxArtClient& client = wxART_OTHER,
const wxSize& size = wxDefaultSize);
/**
Same as wxArtProvider::GetBitmap, but return a wxIcon object
(or ::wxNullIcon on failure).
*/
static wxIcon GetIcon(const wxArtID& id,
const wxArtClient& client = wxART_OTHER,
const wxSize& size = wxDefaultSize);
/**
Returns native icon size for use specified by @a client hint in DIPs.
If the platform has no commonly used default for this use or if
@a client is not recognized, returns wxDefaultSize.
@note In some cases, a platform may have @em several appropriate
native sizes (for example, wxART_FRAME_ICON for frame icons).
In that case, this method returns only one of them, picked
reasonably.
@since 3.1.6
*/
static wxSize GetNativeDIPSizeHint(const wxArtClient& client);
/**
Returns native icon size for use specified by @a client hint.
This function does the same thing as GetNativeDIPSizeHint(), but uses
@a win to convert the returned value to logical pixels. If @a win is
@NULL, default DPI scaling (i.e. that of the primary display) is used.
@since 2.9.0 (@a win parameter is available only since 3.1.6)
*/
static wxSize GetNativeSizeHint(const wxArtClient& client, wxWindow* win = nullptr);
/**
Returns a suitable size hint for the given @e wxArtClient in DIPs.
Return the size used by the topmost wxArtProvider for the given @a
client. @e wxDefaultSize may be returned if the client doesn't have a
specified size, like wxART_OTHER for example.
@see GetNativeDIPSizeHint()
*/
static wxSize GetDIPSizeHint(const wxArtClient& client);
/**
Returns a suitable size hint for the given @e wxArtClient.
This function does the same thing as GetDIPSizeHint(), but uses @a win
to convert the returned value to logical pixels. If @a win is @NULL,
default DPI scaling (i.e. that of the primary display) is used.
Note that @a win parameter is only available since wxWidgets 3.1.6.
*/
static wxSize GetSizeHint(const wxArtClient& client, wxWindow* win = nullptr);
/**
Query registered providers for icon bundle with given ID.
@param id
wxArtID unique identifier of the icon bundle.
@param client
wxArtClient identifier of the client (i.e. who is asking for the icon
bundle).
@return The icon bundle if one of registered providers recognizes the ID
or wxNullIconBundle otherwise.
*/
static wxIconBundle GetIconBundle(const wxArtID& id,
const wxArtClient& client = wxART_OTHER);
/**
Returns true if the platform uses native icons provider that should
take precedence over any customizations.
This is true for any platform that has user-customizable icon themes,
currently only wxGTK.
A typical use for this method is to decide whether a custom art provider
should be plugged in using Push() or PushBack().
@since 2.9.0
*/
static bool HasNativeProvider();
/**
@deprecated Use PushBack() instead.
*/
static void Insert(wxArtProvider* provider);
/**
Remove latest added provider and delete it.
*/
static bool Pop();
/**
Register new art provider and add it to the top of providers stack
(i.e. it will be queried as the first provider).
@param provider A valid pointer that becomes owned by wxArtProvider.
@see PushBack()
*/
static void Push(wxArtProvider* provider);
/**
Register new art provider and add it to the bottom of providers stack.
In other words, it will be queried as the last one, after all others,
including the default provider.
@param provider A valid pointer that becomes owned by wxArtProvider.
@see Push()
@since 2.9.0
*/
static void PushBack(wxArtProvider* provider);
/**
Remove a provider from the stack if it is on it. The provider is not
deleted, unlike when using Delete().
*/
static bool Remove(wxArtProvider* provider);
/**
* 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);
protected:
/**
Derived art provider classes may override this method to return the
size of the images used by this provider.
Note that the returned size should be in DPI-independent pixels, i.e.
DIPs. The default implementation returns the result of
GetNativeDIPSizeHint().
*/
virtual wxSize DoGetSizeHint(const wxArtClient& client);
/**
Derived art provider classes may override this method to create requested art
resource.
For bitmaps available in more than one size, CreateBitmapBundle()
should be overridden instead.
Note that returned bitmaps are cached by wxArtProvider and it is
therefore not necessary to optimize CreateBitmap() for speed (e.g. you may
create wxBitmap objects from XPMs here).
@param id
wxArtID unique identifier of the bitmap.
@param client
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
This only serves as a hint.
@param size
Preferred size of the bitmap. The function may return a bitmap of different
dimensions, it will be automatically rescaled to meet client's request.
@note
This is not part of wxArtProvider's public API, use wxArtProvider::GetBitmap
or wxArtProvider::GetIconBundle or wxArtProvider::GetIcon to query wxArtProvider
for a resource.
@see CreateIconBundle()
*/
virtual wxBitmap CreateBitmap(const wxArtID& id,
const wxArtClient& client,
const wxSize& size);
/**
Override this method to create the requested art resources available in
more than one size.
Unlike CreateBitmap(), this method can be overridden to return the same
bitmap in several (or all, if wxBitmapBundle::FromSVG() is used) sizes
at once, which will allow selecting the size best suited for the
current display resolution automatically.
@param id
wxArtID unique identifier of the bitmap.
@param client
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
This only serves as a hint.
@param size
Default size of the bitmaps returned by the bundle.
@since 3.1.6
*/
virtual wxBitmapBundle CreateBitmapBundle(const wxArtID& id,
const wxArtClient& client,
const wxSize& size);
/**
This method is similar to CreateBitmap() but can be used when a bitmap
(or an icon) exists in several sizes.
*/
virtual wxIconBundle CreateIconBundle(const wxArtID& id,
const wxArtClient& client);
};

View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
// Name: atomic.h
// Purpose: interface of global functions
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_atomic */
///@{
/**
This function increments @a value in an atomic manner.
@note It is recommended to use @c std::atomic instead of this function in
any new code.
Whenever possible wxWidgets provides an efficient, CPU-specific,
implementation of this function. If such implementation is available, the
symbol wxHAS_ATOMIC_OPS is defined. Otherwise this function still exists
but is implemented in a generic way using a critical section which can be
prohibitively expensive for use in performance-sensitive code.
Returns the new value after the increment (the return value is only
available since wxWidgets 3.1.7, this function doesn't return anything in
previous versions of the library).
@header{wx/atomic.h}
*/
wxInt32 wxAtomicInc(wxAtomicInt& value);
/**
This function decrements value in an atomic manner.
Returns the new value after decrementing it.
@see wxAtomicInc
@header{wx/atomic.h}
*/
wxInt32 wxAtomicDec(wxAtomicInt& value);
///@}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,422 @@
/////////////////////////////////////////////////////////////////////////////
// Name: aui/dockart.h
// Purpose: interface of wxAuiDockArt
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
These are the possible pane dock art settings for wxAuiDefaultDockArt.
@library{wxaui}
@category{aui}
*/
enum wxAuiPaneDockArtSetting
{
/// Customizes the sash size
wxAUI_DOCKART_SASH_SIZE = 0,
/// Customizes the caption size
wxAUI_DOCKART_CAPTION_SIZE = 1,
/// Customizes the gripper size
wxAUI_DOCKART_GRIPPER_SIZE = 2,
/// Customizes the pane border size
wxAUI_DOCKART_PANE_BORDER_SIZE = 3,
/// Customizes the pane button size
wxAUI_DOCKART_PANE_BUTTON_SIZE = 4,
/// Customizes the background colour, which corresponds to the client area.
wxAUI_DOCKART_BACKGROUND_COLOUR = 5,
/// Customizes the sash colour
wxAUI_DOCKART_SASH_COLOUR = 6,
/// Customizes the active caption colour
wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR = 7,
/// Customizes the active caption gradient colour
wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR = 8,
/// Customizes the inactive caption colour
wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR = 9,
/// Customizes the inactive gradient caption colour
wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR = 10,
/// Customizes the active caption text colour
wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR = 11,
/// Customizes the inactive caption text colour
wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR = 12,
/// Customizes the border colour
wxAUI_DOCKART_BORDER_COLOUR = 13,
/// Customizes the gripper colour
wxAUI_DOCKART_GRIPPER_COLOUR = 14,
/// Customizes the caption font
wxAUI_DOCKART_CAPTION_FONT = 15,
/// Customizes the gradient type (no gradient, vertical or horizontal)
wxAUI_DOCKART_GRADIENT_TYPE = 16
};
/**
These are the possible gradient dock art settings for wxAuiDefaultDockArt
*/
enum wxAuiPaneDockArtGradients
{
/// No gradient on the captions, in other words a solid colour
wxAUI_GRADIENT_NONE = 0,
/// Vertical gradient on the captions, in other words a gradual change in colours from top to bottom
wxAUI_GRADIENT_VERTICAL = 1,
/// Horizontal gradient on the captions, in other words a gradual change in colours from left to right
wxAUI_GRADIENT_HORIZONTAL = 2
};
/**
These are the possible pane button / wxAuiNotebook button / wxAuiToolBar button states.
*/
enum wxAuiPaneButtonState
{
/// Normal button state
wxAUI_BUTTON_STATE_NORMAL = 0,
/// Hovered button state
wxAUI_BUTTON_STATE_HOVER = 1 << 1,
/// Pressed button state
wxAUI_BUTTON_STATE_PRESSED = 1 << 2,
/// Disabled button state
wxAUI_BUTTON_STATE_DISABLED = 1 << 3,
/// Hidden button state
wxAUI_BUTTON_STATE_HIDDEN = 1 << 4,
/// Checked button state
wxAUI_BUTTON_STATE_CHECKED = 1 << 5
};
/**
These are the possible pane button / wxAuiNotebook button / wxAuiToolBar button identifiers.
*/
enum wxAuiButtonId
{
/// Shows a close button on the pane
wxAUI_BUTTON_CLOSE = 101,
/// Shows a maximize/restore button on the pane
wxAUI_BUTTON_MAXIMIZE_RESTORE = 102,
/// Shows a minimize button on the pane
wxAUI_BUTTON_MINIMIZE = 103,
/**
Shows a pin button on the pane
*/
wxAUI_BUTTON_PIN = 104,
/**
Shows an option button on the pane (not implemented)
*/
wxAUI_BUTTON_OPTIONS = 105,
/**
Shows a window list button on the pane (for wxAuiNotebook)
*/
wxAUI_BUTTON_WINDOWLIST = 106,
/**
Shows a left button on the pane (for wxAuiNotebook)
*/
wxAUI_BUTTON_LEFT = 107,
/**
Shows a right button on the pane (for wxAuiNotebook)
*/
wxAUI_BUTTON_RIGHT = 108,
/**
Shows an up button on the pane (not implemented)
*/
wxAUI_BUTTON_UP = 109,
/**
Shows a down button on the pane (not implemented)
*/
wxAUI_BUTTON_DOWN = 110,
/**
Shows one of three possible custom buttons on the pane (not implemented)
*/
wxAUI_BUTTON_CUSTOM1 = 201,
/**
Shows one of three possible custom buttons on the pane (not implemented)
*/
wxAUI_BUTTON_CUSTOM2 = 202,
/**
Shows one of three possible custom buttons on the pane (not implemented)
*/
wxAUI_BUTTON_CUSTOM3 = 203
};
/**
@class wxAuiDockArt
wxAuiDockArt is part of the wxAUI class framework.
See also @ref overview_aui.
wxAuiDockArt is the art provider: provides all drawing functionality to the
wxAui dock manager. This allows the dock manager to have a pluggable look-and-feel.
By default, a wxAuiManager uses an instance of this class called
wxAuiDefaultDockArt which provides bitmap art and a colour scheme that is
adapted to the major platforms' look. You can either derive from that class
to alter its behaviour or write a completely new dock art class.
Call wxAuiManager::SetArtProvider to force wxAUI to use your new dock art provider.
@library{wxaui}
@category{aui}
@see wxAuiManager, wxAuiPaneInfo
*/
class wxAuiDockArt
{
public:
/**
Constructor.
*/
wxAuiDockArt();
/**
Destructor.
*/
virtual ~wxAuiDockArt();
/**
Create a copy of this wxAuiDockArt instance.
*/
virtual wxAuiDockArt* Clone() = 0;
/**
Draws a background.
*/
virtual void DrawBackground(wxDC& dc, wxWindow* window, int orientation,
const wxRect& rect) = 0;
/**
Draws a border.
*/
virtual void DrawBorder(wxDC& dc, wxWindow* window, const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
/**
Draws a caption.
*/
virtual void DrawCaption(wxDC& dc, wxWindow* window, const wxString& text,
const wxRect& rect, wxAuiPaneInfo& pane) = 0;
/**
Draws a gripper.
*/
virtual void DrawGripper(wxDC& dc, wxWindow* window, const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
/**
Draws a button in the pane's title bar.
@a button can be one of the values of @b wxAuiButtonId.
@a button_state can be one of the values of @b wxAuiPaneButtonState.
*/
virtual void DrawPaneButton(wxDC& dc, wxWindow* window, int button,
int button_state, const wxRect& rect,
wxAuiPaneInfo& pane) = 0;
/**
Draws a sash between two windows.
*/
virtual void DrawSash(wxDC& dc, wxWindow* window, int orientation,
const wxRect& rect) = 0;
/**
Get the colour of a certain setting.
@a id can be one of the colour values of @b wxAuiPaneDockArtSetting.
*/
virtual wxColour GetColour(int id) = 0;
/**
Get a font setting.
*/
virtual wxFont GetFont(int id) = 0;
/**
Get the value of a certain setting.
@a id can be one of the size values of @b wxAuiPaneDockArtSetting.
This function returns the same value that was set by SetMetric(), use
GetMetricForWindow() to get the value appropriate for the given window
for metrics that express sizes.
*/
virtual int GetMetric(int id) = 0;
/**
Get metric value scaled by the DPI of the given window if appropriate.
Call this function instead of GetMetric() to get the metric value
scaled by the window DPI for the metrics that are expressed in pixels
and must be scaled.
The default implementation doesn't scale ::wxAUI_DOCKART_SASH_SIZE and
::wxAUI_DOCKART_PANE_BORDER_SIZE metrics in order to allow setting them
to just a single pixel (which is the default value for the latter in
wxAuiDefaultDockArt) even in high DPI. You may override this function
in your custom art implementation to scale these metrics too if you
prefer to have thicker borders in high DPI.
Note that values of ::wxAUI_DOCKART_GRADIENT_TYPE are not expressed in
pixels and so should never be scaled by this function.
@since 3.3.0
*/
virtual int GetMetricForWindow(int id, wxWindow* window);
/**
Set a certain setting with the value @e colour.
@a id can be one of the colour values of @b wxAuiPaneDockArtSetting.
*/
virtual void SetColour(int id, const wxColour& colour) = 0;
/**
Set a font setting.
*/
virtual void SetFont(int id, const wxFont& font) = 0;
/**
Set a certain setting with the value @e new_val.
@a id can be one of the size values of @b wxAuiPaneDockArtSetting.
The interpretation of @a new_val depends on the metric being set, see
GetMetricForWindow().
*/
virtual void SetMetric(int id, int new_val) = 0;
};
/**
@class wxAuiDefaultDockArt
This is the default art provider for @ref wxAuiManager. Dock art
can be customized by creating a class derived from this one,
or replacing this class entirely.
*/
class wxAuiDefaultDockArt : public wxAuiDockArt
{
public:
wxAuiDefaultDockArt();
virtual wxAuiDockArt* Clone();
int GetMetric(int metricId);
void SetMetric(int metricId, int newVal);
wxColour GetColour(int id);
void SetColour(int id, const wxColour& colour);
void SetFont(int id, const wxFont& font);
wxFont GetFont(int id);
void DrawSash(wxDC& dc,
wxWindow *window,
int orientation,
const wxRect& rect);
void DrawBackground(wxDC& dc,
wxWindow *window,
int orientation,
const wxRect& rect);
void DrawCaption(wxDC& dc,
wxWindow *window,
const wxString& text,
const wxRect& rect,
wxAuiPaneInfo& pane);
void DrawGripper(wxDC& dc,
wxWindow *window,
const wxRect& rect,
wxAuiPaneInfo& pane);
void DrawBorder(wxDC& dc,
wxWindow *window,
const wxRect& rect,
wxAuiPaneInfo& pane);
void DrawPaneButton(wxDC& dc,
wxWindow *window,
int button,
int buttonState,
const wxRect& rect,
wxAuiPaneInfo& pane);
/**
@deprecated Not intended for the public API.
*/
void DrawIcon(wxDC& dc,
const wxRect& rect,
wxAuiPaneInfo& pane);
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;
};

View File

@@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// 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
///////////////////////////////////////////////////////////////////////////////
class wxAuiFloatingFrame : public wxFrame
{
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;
/**
Returns the embedded wxAuiManager managing this floating pane's contents.
@since 3.1.5
*/
wxAuiManager& GetAuiManager();
protected:
virtual void OnMoveStart();
virtual void OnMoving(const wxRect& windowRect, wxDirection dir);
virtual void OnMoveFinished();
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,437 @@
/////////////////////////////////////////////////////////////////////////////
// Name: aui/serializer.h
// Purpose: Documentation of wxAuiSerializer and wxAuiDeserializer.
// Author: Vadim Zeitlin
// Created: 2024-02-20
// Copyright: (c) 2024 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Description of a docked element layout.
The fields in this struct are shared by wxAuiPaneLayoutInfo and
wxAuiTabLayoutInfo and contain information about the layout of a docked
pane or tab layout.
Note that when saving the objects of this type, fields that have the value
of 0 can be omitted, as this is their default value in any case (except for
`dock_direction` which is never 0), to make the serialized representation
more compact.
@since 3.3.0
*/
struct wxAuiDockLayoutInfo
{
/// Direction of the dock containing the pane.
int dock_direction = wxAUI_DOCK_LEFT;
/// Layer of the dock containing the pane.
int dock_layer = 0;
/// Row of the dock containing the pane.
int dock_row = 0;
/// Position of the pane in the dock containing it.
int dock_pos = 0;
/// Relative proportion of the dock allocated to this pane.
int dock_proportion = 0;
/// Size of the containing dock.
int dock_size = 0;
};
/**
Contains information about the layout of a tab control in a wxAuiNotebook.
This includes where it is docked, via the fields inherited from
wxAuiDockLayoutInfo, and, optionally, the order of pages in it if it was
changed as well as pinned pages indices, if any.
@since 3.3.0
*/
struct wxAuiTabLayoutInfo : wxAuiDockLayoutInfo
{
/**
Indices of the pages in this tab control in their order on screen.
If this vector is empty, it means that the tab control contains all
notebook pages in natural order.
*/
std::vector<int> pages;
/**
Indices of the pinned pages in this tab control.
This vector can be empty if there are no pinned pages in this tab
control. Otherwise it should be a subset of the `pages` vector if it is
not empty.
*/
std::vector<int> pinned;
/**
Index of the currently selected page in this tab control.
Note that the value of this field is a page index in the notebook, not
the position of the active tab in this tab control, and should be one
of the elements of the `pages` vector if it is not empty.
*/
int active = 0;
};
/**
Description of user-modifiable pane layout information.
This struct is used with wxAuiSerializer and wxAuiDeserializer to store the
pane layout. Its fields, including the inherited ones from
wxAuiDockLayoutInfo, have the same meaning as the corresponding fields in
wxAuiPaneInfo (with the exception of `is_maximized` and `is_hidden`, which
rather correspond to the individual bits of its state field), but it
doesn't contain the fields that it wouldn't make sense to serialize.
@since 3.3.0
*/
struct wxAuiPaneLayoutInfo : wxAuiDockLayoutInfo
{
/**
Ctor sets the name, which is always required.
*/
explicit wxAuiPaneLayoutInfo(wxString name);
/// Unique name of the pane.
wxString name;
/// Position of the pane when floating, may be invalid.
wxPoint floating_pos = wxDefaultPosition;
/// Size of the pane when floating, may be invalid.
wxSize floating_size = wxDefaultSize;
/// True if the pane is currently maximized.
bool is_maximized = false;
/// True if the pane is currently hidden.
bool is_hidden = false;
};
/**
@class wxAuiBookSerializer
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.
@library{wxaui}
@category{aui}
@since 3.3.0
*/
class wxAuiBookSerializer
{
public:
/// Trivial default ctor.
wxAuiBookSerializer() = default;
/// Trivial but virtual destructor.
virtual ~wxAuiBookSerializer() = default;
/**
Called before starting to save information about the tabs in the
notebook in the AUI pane with the given name.
This function needs to be overridden to keep record of the notebook for
which SaveNotebookTabControl() will be called next.
If this class is used as a base class of wxAuiSerializer, saving
notebook layout may be unnecessary, e.g. because the program doesn't
use wxAuiNotebook at all, and the implementation can be trivial and
just do nothing because it is not going to be called at all if there
are no notebooks in the full layout.
When using wxAuiNotebook::SaveLayout() directly, this function is
always called and is the first function of this class to be called.
*/
virtual void BeforeSaveNotebook(const wxString& name) = 0;
/**
Called to save information about a single tab control in the given
notebook.
This function will be called for all tab controls in the notebook after
BeforeSaveNotebook().
As with that function, it has to be implemented, but can simply do
nothing if saving notebook layout is not necessary.
*/
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();
};
/**
@class wxAuiSerializer
wxAuiSerializer is used by wxAuiManager::SaveLayout() to store layout
information.
This is an abstract base class, you need to inherit from it and override its
pure virtual functions, including those inherited from its base
wxAuiBookSerializer class, in your derived class.
In particular, SavePane() must be overridden and will be called by
wxAuiManager for each pane and dock present in the layout. Most of the
other functions don't need to be overridden, but it is often convenient to
perform some actions before or after starting to save the objects of the
given type or at the beginning or end of the whole saving process, so this
class provides hooks for doing it.
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.
@library{wxaui}
@category{aui}
@since 3.3.0
*/
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.
This function will be called for all panes and must be implemented to
save their data in a format from which it can be restored later using a
matching wxAuiDeserializer implementation.
Note that all sizes and positions in @a pane are using DIPs, i.e.
resolution-independent pixels, when it is passed to this function, so
it does _not_ need to perform any scaling itself to ensure that the
stored values are restored correctly if the resolution changes.
*/
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.
Note that this function is called after AfterSavePanes() but may not be
called at all if there are no panes containing wxAuiNotebook.
wxAuiBookSerializer member functions will be called after this function
if it is called at all.
*/
virtual void BeforeSaveNotebooks();
/**
Called after the last call to SaveNotebook().
Does nothing by default.
This function is called after all wxAuiBookSerializer member functions
*/
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.
@library{wxaui}
@category{aui}
@since 3.3.0
*/
class wxAuiBookDeserializer
{
public:
/// Trivial default ctor.
wxAuiBookDeserializer() = default;
/// Trivial but virtual destructor.
virtual ~wxAuiBookDeserializer() = default;
/**
Load information about the notebook tabs previously saved by
wxAuiBookSerializer::SaveNotebookTabControl().
When using this class as a base class of wxAuiDeserializer, this
function is called by wxAuiManager::LoadLayout() after loading the pane
with the name @a name if it is a wxAuiNotebook. Otherwise, i.e. when
using wxAuiNotebook::LoadLayout() directly, this function is called
with the same @a name as was passed to that function.
If restoring the notebook layout is not necessary, this function can
just return an empty vector which is interpreted as meaning that the
default notebook layout should be used.
*/
virtual std::vector<wxAuiTabLayoutInfo>
LoadNotebookTabs(const wxString& name) = 0;
/**
Determine what should be done with the pages not attached to any tab
control after restoring the pages order.
It is possible that the data returned by LoadNotebookTabs() doesn't
contain the layout information for all the currently existing pages,
e.g. because data saved by an earlier program version is being loaded
into a newer version in which new pages were added. In this case, this
function is called for each @a page that wasn't assigned to any tab
after restoring the pages order and can be overridden to determine what
should be done with it.
The default implementation of this function just returns @true without
modifying the output arguments, which results in the page being
appended to the main tab control. The overridden version may return
@true but modify @a tabCtrl and @a tabIndex arguments to change where
the page should be inserted, e.g. by setting @a tabIndex to 0 to insert
the new pages at the beginning instead of appending them.
Finally, the overridden function may return @false to indicate that the
page should be removed from the notebook.
@note The @a book parameter can be used to retrieve the total number of
pages or to call functions such as wxAuiNotebook::GetMainTabCtrl()
or wxAuiNotebook::GetAllTabCtrls() on it, but this function must
not attempt to modify it by adding or removing pages to/from it.
*/
virtual bool
HandleOrphanedPage(wxAuiNotebook& book,
int page,
wxAuiTabCtrl** tabCtrl,
int* tabIndex);
};
/**
@class wxAuiDeserializer
wxAuiDeserializer is used by wxAuiManager::LoadLayout() to restore layout
information saved by wxAuiManager::SaveLayout().
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.
@library{wxaui}
@category{aui}
@since 3.3.0
*/
class wxAuiDeserializer : public wxAuiBookDeserializer
{
public:
/**
Constructor taking the manager for which we're restoring the layout.
The manager remains valid for the lifetime of this object.
*/
explicit wxAuiDeserializer(wxAuiManager& manager);
/// Trivial but virtual destructor.
virtual ~wxAuiDeserializer() = default;
/**
Called before doing anything else.
Does nothing by default.
*/
virtual void BeforeLoad();
/**
Load information about all the panes previously saved by
wxAuiSerializer::SavePane().
Unlike the serializer function, this one is called only once and should
return all the panes in the layout.
Just as the serializer function, this one doesn't need to perform any
scaling itself as this will be done, if necessary, by wxAuiManager
itself.
If some pane in the returned vector doesn't already exist, i.e. there
is no pane with the matching name, CreatePaneWindow() is called to
allow creating it on the fly.
*/
virtual std::vector<wxAuiPaneLayoutInfo> LoadPanes() = 0;
/**
Create the window to be managed by the given pane if necessary.
This function 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 @NULL, as it does by default, the pane is not
added to the manager.
If the function does create a new window, it should typically modify @a
pane parameter to fill in the fields such as `caption` or `icon` that
wouldn't normally be serialized and so wouldn't be restored by
LoadPanes().
*/
virtual wxWindow* CreatePaneWindow(wxAuiPaneInfo& pane);
/**
Called after restoring everything.
Default implementation calls wxAuiManager::Update(). Override this
function and do _not_ call the base class version if you want to
prevent this from happening, e.g. if you need to make further changes
to the restored layout before updating it.
*/
virtual void AfterLoad();
protected:
/// The manager for which we're restoring the layout.
wxAuiManager& m_manager;
};

View File

@@ -0,0 +1,140 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/aui/tabmdi.h
// Purpose: Documentation of wxAui MDI classes.
// Created: 2016-10-27
// Copyright: (c) 2016 wxWidgets development team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
class 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 = 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 = wxFrameNameStr );
void SetArtProvider(wxAuiTabArt* provider);
wxAuiTabArt* GetArtProvider();
wxAuiNotebook* GetNotebook() const;
wxMenu* GetWindowMenu() const;
void SetWindowMenu(wxMenu* pMenu);
virtual void SetMenuBar(wxMenuBar *pMenuBar);
void SetChildMenuBar(wxAuiMDIChildFrame *pChild);
wxAuiMDIChildFrame *GetActiveChild() const;
void SetActiveChild(wxAuiMDIChildFrame* pChildFrame);
wxAuiMDIClientWindow *GetClientWindow() const;
virtual wxAuiMDIClientWindow *OnCreateClient();
virtual void Cascade();
virtual void Tile(wxOrientation orient = wxHORIZONTAL);
virtual void ArrangeIcons();
virtual void ActivateNext();
virtual void ActivatePrevious();
};
class wxAuiMDIChildFrame : public wxPanel
{
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 = 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 = wxFrameNameStr);
virtual void SetMenuBar(wxMenuBar *menuBar);
virtual wxMenuBar *GetMenuBar() const;
virtual void SetTitle(const wxString& title);
virtual wxString GetTitle() const;
virtual void SetIcons(const wxIconBundle& icons);
virtual const wxIconBundle& GetIcons() const;
virtual void SetIcon(const wxIcon& icon);
virtual const wxIcon& GetIcon() const;
virtual void Activate();
virtual bool Destroy();
virtual bool Show(bool show = true);
// no status bars
virtual wxStatusBar* CreateStatusBar(int number = 1,
long style = 1,
wxWindowID winid = 1,
const wxString& name = wxEmptyString);
virtual wxStatusBar *GetStatusBar() const;
virtual void SetStatusText( const wxString &text, int number=0 );
virtual void SetStatusWidths( int n, const int widths_field[] );
// no toolbar bars
virtual wxToolBar* CreateToolBar(long style,
wxWindowID winid,
const wxString& name);
virtual wxToolBar *GetToolBar() const;
// no maximize etc
virtual void Maximize(bool maximize = true);
virtual void Restore();
virtual void Iconize(bool iconize = true);
virtual bool IsMaximized() const;
virtual bool IsIconized() const;
virtual bool ShowFullScreen(bool show, long style);
virtual bool IsFullScreen() const;
virtual bool IsTopLevel() const;
void SetMDIParentFrame(wxAuiMDIParentFrame* parent);
wxAuiMDIParentFrame* GetMDIParentFrame() const;
};
class wxAuiMDIClientWindow : public wxAuiNotebook
{
public:
wxAuiMDIClientWindow();
wxAuiMDIClientWindow(wxAuiMDIParentFrame *parent, long style = 0);
virtual bool CreateClient(wxAuiMDIParentFrame *parent,
long style = wxVSCROLL | wxHSCROLL);
virtual int SetSelection(size_t page);
virtual wxAuiMDIChildFrame* GetActiveChild();
virtual void SetActiveChild(wxAuiMDIChildFrame* pChildFrame);
};

View File

@@ -0,0 +1,156 @@
///////////////////////////////////////////////////////////////////////////////
// Name: interface/wx/bannerwindow.h
// Purpose: wxBannerWindow class documentation
// Author: Vadim Zeitlin
// Created: 2011-08-16
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/**
A simple banner window showing either a bitmap or text.
Banner windows can be used to present some overview of the current window
contents to the user in an aesthetically pleasant way. They are typically
positioned along the left or top edge of the window (although this class
also supports right- and bottom-aligned banners) and show either a bitmap
with a logo or a few lines of text on a gradient-filled background.
Using this class is very simple, e.g.:
@code
MyFrame::MyFrame(...)
{
... create the frame itself ...
// Create and initialize the banner.
wxBannerWindow* banner = new wxBannerWindow(this, wxTOP);
banner->SetText("Welcome to my wonderful program",
" Before doing anything else, you need to connect to "
"the online server.\n"
" Please enter your credentials in the controls below.");
// And position it along the top edge of the window.
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(banner, wxSizerFlags().Expand());
... add the rest of the window contents to the same sizer ...
SetSizerAndFit(sizer);
}
@endcode
This class is currently implemented generically and so looks the same under
all platforms.
@library{wxcore}
@category{miscwnd}
@genericAppearance{bannerwindow}
@since 2.9.3
*/
class wxBannerWindow : public wxWindow
{
public:
/**
Default constructor, use Create() later.
This constructor is only used for two-step creation, if possible,
prefer using the constructor below directly instead of using this one
and calling Create() later.
*/
wxBannerWindow();
/**
Convenient constructor that should be used in the majority of cases.
The only really important arguments of the full constructor below are
@a parent and @a dir so this class provides a convenient constructor
taking only them.
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);
/**
Full constructor provided for consistency with the other classes only.
Prefer to use the shorter constructor documented above. You should
rarely, if ever, need to use non-default values for any other
parameters: as the banner window doesn't generate any events, its
identifier is not particularly useful; its position and size will be
almost always managed by the containing sizer and it doesn't have any
specific styles. So only the parent and the banner direction need to be
specified.
*/
wxBannerWindow(wxWindow* parent,
wxWindowID winid,
wxDirection dir = wxLEFT,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxBannerWindowNameStr);
/**
Really create the banner window for the objects created using the
default constructor.
It's an error to call Create() for the objects created using
non-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 = wxBannerWindowNameStr);
/**
Provide the bitmap to use as background.
Notice that ideally the bitmap should be big enough to always cover the
entire banner, e.g. for a horizontal banner with wxTOP style its width
should be bigger than any reasonable window size. Otherwise the bitmap
is extended to cover the entire window area with a solid colour taken
from the bitmap pixel on the edge in which direction the extension
occurs so all bitmap pixels on this edge (top for wxLEFT, right for
wxTOP and wxBOTTOM and bottom for wxRIGHT) should have the same colour
to avoid jarring discontinuity.
If, on the other hand, the bitmap is bigger than the window size, then
it is truncated. 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 where it will never be truncated.
If no valid background bitmap is specified, the banner draws gradient
background but if a valid bitmap is given here, the gradient is not
draw and the start and end colours specified for it are ignored.
@param bmp Bitmap to use as background. May be invalid to indicate
that no background bitmap should be used.
*/
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, include explicit line
breaks in the string if you want to have multiple lines.
*/
void SetText(const wxString& title, const wxString& message);
/**
Set the colours between which the gradient runs.
The gradient colours are ignored if SetBitmap() is used.
*/
void SetGradient(const wxColour& start, const wxColour& end);
};

View File

@@ -0,0 +1,191 @@
/////////////////////////////////////////////////////////////////////////////
// Name: base64.h
// Purpose: interface of global functions
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_misc */
///@{
/**
Elements of this enum specify the possible behaviours of wxBase64Decode
when an invalid character is encountered.
*/
enum wxBase64DecodeMode
{
wxBase64DecodeMode_Strict, ///< Normal behaviour: stop at any invalid characters.
wxBase64DecodeMode_SkipWS, ///< Skip whitespace characters.
wxBase64DecodeMode_Relaxed ///< The most lenient behaviour: simply ignore all invalid characters.
};
/**
This function encodes the given data using base64.
To allocate the buffer of the correct size, use wxBase64EncodedSize() or
call this function with @a dst set to @NULL -- it will then return the
necessary buffer size.
This raw encoding function overload writes the output string into the
provided buffer; the other overloads return it as a wxString.
@param dst
The output buffer, may be @NULL to retrieve the needed buffer size.
@param dstLen
The output buffer size, ignored if dst is @NULL.
@param src
The input buffer, must not be @NULL.
@param srcLen
The length of the input data.
@return @c wxCONV_FAILED if the output buffer is too small.
@header{wx/base64.h}
*/
size_t wxBase64Encode(char* dst, size_t dstLen,
const void* src,
size_t srcLen);
/**
This function encodes the given data using base64 and returns the output as
a wxString.
There is no error return.
@param src
The input buffer, must not be @NULL.
@param srcLen
The length of the input data.
@header{wx/base64.h}
*/
wxString wxBase64Encode(const void* src, size_t srcLen);
/**
This function encodes the given data using base64 and returns the output as
a wxString.
There is no error return.
@header{wx/base64.h}
*/
wxString wxBase64Encode(const wxMemoryBuffer& buf);
/**
Returns the size of the buffer necessary to contain the data encoded in a
base64 string of length @e srcLen. This can be useful for allocating a
buffer to be passed to wxBase64Decode().
@header{wx/base64.h}
*/
size_t wxBase64DecodedSize(size_t srcLen);
/**
Returns the length of the string with base64 representation of a buffer of
specified size @e len. This can be useful for allocating the buffer passed
to wxBase64Encode().
@header{wx/base64.h}
*/
size_t wxBase64EncodedSize(size_t len);
/**
This function decodes a Base64-encoded string.
This overload is a raw decoding function and decodes the data into the
provided buffer @a dst of the given size @e dstLen. An error is returned if
the buffer is not large enough -- that is not at least
wxBase64DecodedSize(srcLen) bytes. Notice that the buffer will @e not be
@NULL-terminated.
This overload returns the number of bytes written to the buffer or the
necessary buffer size if @a dst was @NULL or @c wxCONV_FAILED on error,
e.g. if the output buffer is too small or invalid characters were
encountered in the input string.
@param dst
Pointer to output buffer, may be @NULL to just compute the necessary
buffer size.
@param dstLen
The size of the output buffer, ignored if dst is @NULL.
@param src
The input string, must not be @NULL. For the version using wxString,
the input string should contain only ASCII characters.
@param srcLen
The length of the input string or special value wxNO_LEN if the string
is @NULL-terminated and the length should be computed by this function
itself.
@param mode
This parameter specifies the function behaviour when invalid characters
are encountered in input. By default, any such character stops the
decoding with error. If the mode is wxBase64DecodeMode_SkipWS, then the
white space characters are silently skipped instead. And if it is
wxBase64DecodeMode_Relaxed, then all invalid characters are skipped.
@param posErr
If this pointer is non-null and an error occurs during decoding, it is
filled with the index of the invalid character.
@header{wx/base64.h}
*/
size_t wxBase64Decode(void* dst, size_t dstLen,
const char* src,
size_t srcLen = wxNO_LEN,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr);
/**
Decode a Base64-encoded wxString.
See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t*)
overload for more information about the parameters of this function, the
only difference between it and this one is that a wxString is used instead
of a @c char* pointer and its length.
@since 2.9.1
@header{wx/base64.h}
*/
size_t wxBase64Decode(void* dst, size_t dstLen,
const wxString& str,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr);
/**
Decode a Base64-encoded string and return decoded contents in a buffer.
See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t*)
overload for more information about the parameters of this function. The
difference of this overload is that it allocates a buffer of necessary size
on its own and returns it, freeing you from the need to do it manually.
Because of this, it is simpler to use and is recommended for normal use.
@header{wx/base64.h}
*/
wxMemoryBuffer wxBase64Decode(const char* src,
size_t srcLen = wxNO_LEN,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr);
/**
Decode a Base64-encoded wxString and return decoded contents in a buffer.
See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t*)
overload for more information about the parameters of this function.
This overload takes as input a wxString and returns the internally-allocated
memory as a wxMemoryBuffer, containing the Base64-decoded data.
@header{wx/base64.h}
*/
wxMemoryBuffer wxBase64Decode(const wxString& src,
wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
size_t *posErr = nullptr);
///@}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,656 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpbndl.h
// Purpose: Interface of wxBitmapBundle.
// Author: Vadim Zeitlin
// Created: 2021-09-24
// Copyright: (c) 2021 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Contains representations of the same bitmap in different resolutions.
This class generalizes wxBitmap for applications supporting multiple DPIs
and allows to operate with multiple versions of the same bitmap, in the
sizes appropriate to the currently used display resolution, as a single
unit. Notably, an entire wxBitmapBundle can be passed to functions such as
wxToolBar::AddTool() to allow toolbar to select the best available bitmap
to be shown.
Objects of this class are typically created by the application and then
passed to wxWidgets functions, but not used by the application itself.
Currently bitmap bundles can be created from:
- A vector of bitmaps, of any provenance.
- An SVG (as memory block, file, or resource) which will be rasterized at required resolutions.
- A custom bitmap source using wxBitmapBundleImpl.
- A single wxBitmap or wxImage for backwards compatibility.
Objects of wxBitmapBundle class have value-like semantics, i.e. they can be
copied around freely (and cheaply) and don't need to be allocated on the
heap. However they usually are created using static factory functions
(known as "pseudo-constructors") such as FromBitmaps() instead of using the
real constructors.
Example of using this class to initialize a toolbar in a frame constructor:
@code
MyFrame::MyFrame()
: wxFrame(nullptr, wxID_ANY, "My frame")
{
...
wxToolBar* toolBar = CreateToolBar();
wxVector<wxBitmap> bitmaps;
bitmaps.push_back(wxBITMAP_PNG(open_32x32));
bitmaps.push_back(wxBITMAP_PNG(open_48x48));
bitmaps.push_back(wxBITMAP_PNG(open_64x64));
toolBar->AddTool(wxID_OPEN, "Open", wxBitmapBundle::FromBitmaps(bitmaps));
}
@endcode
The code shown above will use 32 pixel bitmap in normal DPI, 64 pixel
bitmap in "high DPI", i.e. pixel-doubling or 200% resolution, and 48 pixel
bitmap in 150% resolution. For all the other resolutions, the bitmap with
the "best" matching size will be used, where "best" is deemed to be the
bitmap with the closest size if it can be used without scaling (so that in
this example the 64px bitmap will be used at 175% resolution because it
typically looks much better than either downscaling it or upscaling the
48px bitmap to 56px) or, if there is no bitmap with close enough size, a
bitmap upscaled by an integer scaling factor is used. Note that custom
bitmap bundles can use a different algorithm for selecting the best match
by overriding wxBitmapBundleImpl::GetPreferredBitmapSizeAtScale().
Of course, this code relies on actually having the resources with the
corresponding names (i.e. @c open_NxN) in MSW .rc file or Mac application
bundle and @c open_NxN_png arrays being defined in the program code, e.g.
by including a file generated with @c bin2c (see wxBITMAP_PNG_FROM_DATA()),
on the other platforms.
For the platforms with resources support, you can also create the bundle
from the bitmaps defined in the resources, which has the advantage of not
having to explicitly list all the bitmaps, e.g. the code above becomes
@code
#ifdef wxHAS_IMAGE_RESOURCES
toolBar->AddTool(wxID_OPEN, "Open", wxBitmapBundle::FromResources("open"));
#else
... same code as shown above ...
#endif
@endcode
and will load all resources called @c open, @c open_2x, @c open_1_5x etc
(at least the first one of them must be available). See also
wxBITMAP_BUNDLE_2() macro which can avoid the need to check for
wxHAS_IMAGE_RESOURCES explicitly in the code in a common case of having
only 2 embedded resources (for standard and high DPI).
See also FromSVGResource().
Also note that the existing code using wxBitmap is compatible with the
functions taking wxBitmapBundle in wxWidgets 3.1.6 and later because
bitmaps are implicitly convertible to the objects of this class, so just
passing wxBitmap to the functions taking wxBitmapBundle continues to work
and if high resolution versions of bitmap are not (yet) available for the
other toolbar tools, single bitmaps can continue to be used instead.
@library{wxcore}
@category{gdi}
@since 3.1.6
*/
class wxBitmapBundle
{
public:
/**
Default constructor constructs an empty bundle.
An empty bundle can't be used for anything, but can be assigned
something else later.
*/
wxBitmapBundle();
/**
Conversion constructor from a single bitmap.
This constructor does the same thing as FromBitmap() and only exists
for interoperability with the existing code using wxBitmap.
*/
wxBitmapBundle(const wxBitmap& bitmap);
/**
Conversion constructor from a single icon.
This constructor does the same thing as FromBitmap() and only exists
for interoperability with the existing code using wxIcon.
*/
wxBitmapBundle(const wxIcon& icon);
/**
Conversion constructor from a single image.
Similarly to the constructor from wxBitmap, this constructor only
exists for interoperability with the existing code using wxImage and
can be replaced with more readable FromImage() in the new code.
*/
wxBitmapBundle(const wxImage& image);
/**
Conversion constructor from XPM data.
This constructor overload exists only for compatibility with the
existing code passing XPM data (e.g. @c foo_xpm after including @c
foo.xpm) directly to the functions expecting a bitmap. Don't use it in
the new code, as it is likely to be deprecated in the future.
@since 3.2.0
*/
wxBitmapBundle(const char* const* xpm);
/**
Copy constructor creates a copy of another bundle.
*/
wxBitmapBundle(const wxBitmapBundle& other);
/**
Assignment operator makes this bundle a copy of another bundle.
*/
wxBitmapBundle& operator=(const wxBitmapBundle& other);
/**
Create a bundle from the given collection of bitmaps.
If the @a bitmaps vector is empty, an invalid, empty bundle is
returned, otherwise initialize the bundle with all the bitmaps in this
vector which must be themselves valid.
*/
static wxBitmapBundle FromBitmaps(const wxVector<wxBitmap>& bitmaps);
/// @overload
static wxBitmapBundle FromBitmaps(const wxBitmap& bitmap1,
const wxBitmap& bitmap2);
/**
Create a bundle from a single bitmap.
This is only useful for compatibility with the existing code using
wxBitmap.
If @a bitmap is invalid, empty bundle is returned.
*/
static wxBitmapBundle FromBitmap(const wxBitmap& bitmap);
/**
Create a bundle from an icon bundle.
If @a iconBundle is invalid or empty, empty bundle is returned.
@since 3.1.7
*/
static wxBitmapBundle FromIconBundle(const wxIconBundle& iconBundle);
/**
Create a bundle from a single image.
This is only useful for compatibility with the existing code using
wxImage.
If @a image is invalid, empty bundle is returned.
*/
static wxBitmapBundle FromImage(const wxImage& image);
/**
Create a bundle from a custom bitmap bundle implementation.
This function can be used to create bundles implementing custom logic
for creating the bitmaps, e.g. creating them on the fly rather than
using predefined bitmaps.
See wxBitmapBundleImpl.
@param impl A valid, i.e. non-null, pointer. This function takes
ownership of it, so the caller must @e not call DecRef() on it.
*/
static wxBitmapBundle FromImpl(wxBitmapBundleImpl* impl);
/**
Create a bundle from the bitmaps in the application resources.
This function can only be used on the platforms supporting storing
bitmaps in resources, and currently only works under MSW and MacOS
and returns an empty bundle on the other platforms.
Under MSW, for this function to create a valid bundle, you must have @c
RCDATA resource with the given @a name in your application resource
file (with the extension @c .rc) containing PNG file, and any other
resources using @a name as prefix and suffix with the scale, e.g. "_2x"
or "_1_5x" (for 150% DPI) will be also loaded as part of the bundle.
@see FromSVGResource()
*/
static wxBitmapBundle FromResources(const wxString& name);
/**
Create a bundle from bitmaps stored as files.
Looking in @a path for files using @a filename as prefix and potentionally a
suffix with scale, e.g. "_2x" or "@2x"
@param path Path of the directory containing the files
@param filename Bitmap's filename without any scale suffix
@param extension File extension, without leading dot (`png` by default)
*/
static wxBitmapBundle FromFiles(const wxString& path, const wxString& filename, const wxString& extension = "png");
/// @overload
static wxBitmapBundle FromFiles(const wxString& fullpathname);
/**
Create a bundle from the SVG image.
Please note that the current implementation uses NanoSVG library
(https://github.com/memononen/nanosvg) for parsing and rasterizing SVG
images which imposes the following limitations:
- Text elements are not supported at all (see note for workaround).
- SVG 1.1 filters are not supported.
- Embedded images are not supported (see note for workaround).
These limitations will be relaxed in the future wxWidgets versions.
Please also note that this method is only available in the ports
providing raw bitmap access via wxPixelData. This is the case for all
tier-1 ports, but not all of them, check if @c wxHAS_SVG is defined
before using this method if for maximum portability.
@param data This data may, or not, have the XML document preamble, i.e.
it can start either with @c "<?xml" processing instruction or
directly with @c svg tag. For NUL-terminated string, two overloads
of this function, taking const and non-const data, are provided: as
the current implementation modifies the data while parsing, using
the non-const variant is more efficient, as it avoids making copy
of the data, but the data is consumed by it and can't be reused any
more. For non-NUL-terminated data, the third overload, taking an
extra parameter explicitly specifying the length of the input data,
@e must be used.
@param sizeDef The default size to return from GetDefaultSize() for
this bundle. As SVG images usually don't have any natural
default size, it should be provided when creating the bundle.
@note Converting text objects to path objects will allow them to be
rasterized as expected. This can be done in an SVG editor such as
Inkscape. (In Inkscape, select a text object and choose
"Object to Path" from the "Path" menu.)\n
Converting embedded images to paths from an SVG editor will
allow them to be rasterized. For example, selecting "Trace Bitmap"
from the "Path" menu in Inkscape can perform this. This is only
recommended for simple images, however, as more complex images
may not rasterize well.
*/
static wxBitmapBundle FromSVG(char* data, const wxSize& sizeDef);
/// @overload
static wxBitmapBundle FromSVG(const char* data, const wxSize& sizeDef);
/// @overload
static wxBitmapBundle FromSVG(const wxByte* data, size_t len, const wxSize& sizeDef);
/**
Create a bundle from the SVG image loaded from the given file.
This function loads the SVG data from the given @a path and calls
FromSVG() with it. As it is just a wrapper for FromSVG(), please see
that function documentation for more information about SVG support.
@param path Path to the SVG file. Notice that it should a local file,
not an URL.
@param sizeDef The default size to return from GetDefaultSize() for
this bundle.
*/
static wxBitmapBundle FromSVGFile(const wxString& path, const wxSize& sizeDef);
/**
Create a bundle from the SVG image loaded from an application resource.
Available only on the platforms supporting images in resources, i.e.,
MSW and MacOS.
@param name On MSW, it must be a resource with @c RT_RCDATA type.
On MacOS, it must be a file with an extension "svg" placed in
the "Resources" subdirectory of the application bundle.
@param sizeDef The default size to return from GetDefaultSize() for
this bundle.
@see FromResources(), FromSVGFile()
*/
static wxBitmapBundle FromSVGResource(const wxString& name, const wxSize& sizeDef);
/**
Clear the existing bundle contents.
After calling this function IsOk() returns @false.
This is the same as assigning a default-constructed bitmap bundle to
this object but slightly more explicit.
@since 3.1.7
*/
void Clear();
/**
Check if bitmap bundle is non-empty.
Return @true if the bundle contains any bitmaps or @false if it is
empty.
*/
bool IsOk() const;
/**
Get the size of the bitmap represented by this bundle in default
resolution or, equivalently, at 100% scaling.
When creating the bundle from a number of bitmaps, this will be just
the size of the smallest bitmap in it.
Note that this function is mostly used by wxWidgets itself and not the
application.
*/
wxSize GetDefaultSize() const;
/**
Get the size that would be best to use for this bundle at the given DPI
scaling factor.
For bundles containing some number of the fixed-size bitmaps, this
function returns the size of an existing bitmap closest to the ideal
size at the given scale, i.e. GetDefaultSize() multiplied by @a scale.
Passing a size returned by this function to GetBitmap() ensures that
bitmap doesn't need to be rescaled, which typically significantly
lowers its quality.
*/
wxSize GetPreferredBitmapSizeAtScale(double scale) const;
/**
Get the size that would be best to use for this bundle at the DPI
scaling factor used by the given window.
This is just a convenient wrapper for GetPreferredBitmapSizeAtScale() calling
that function with the result of wxWindow::GetDPIScaleFactor().
@param window Non-null and fully created window.
*/
wxSize GetPreferredBitmapSizeFor(const wxWindow* window) const;
/**
Get the size that would be best to use for this bundle at the DPI
scaling factor used by the given window in logical size.
This is just call GetPreferredBitmapSizeAtScale() with the result of
wxWindow::GetDPIScaleFactor() and convert returned value with
wxWindow::FromPhys().
@param window Non-null and fully created window.
*/
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.
This function is mostly used by wxWidgets itself and not the
application. As all bitmaps created by it dynamically are currently
cached, avoid calling it for many different sizes if you do use it, as
this will create many bitmaps that will never be deleted and will
consume resources until the application termination.
@param size The size of the bitmap to return, in physical pixels. If
this parameter is wxDefaultSize, default bundle size is used.
*/
wxBitmap GetBitmap(const wxSize& size) const;
/**
Get bitmap of the size appropriate for the DPI scaling used by the
given window.
This helper function simply combines GetPreferredBitmapSizeFor() and
GetBitmap(), i.e. it returns a (normally unscaled) bitmap
from the bundle of the closest size to the size that should be used at
the DPI scaling of the provided window.
@param window Non-null and fully created window.
*/
wxBitmap GetBitmapFor(const wxWindow* window) const;
/**
Get icon of the specified size.
This is just a convenient wrapper for GetBitmap() and simply converts
the returned bitmap to wxIcon.
*/
wxIcon GetIcon(const wxSize& size) const;
/**
Get icon of the size appropriate for the DPI scaling used by the
given window.
This is similar to GetBitmapFor(), but returns a wxIcon, as GetIcon()
does.
@param window Non-null and fully created window.
*/
wxIcon GetIconFor(const wxWindow* window) const;
/**
Check if the two bundles refer to the same object.
Bundles are considered to be same only if they actually use the same
underlying object, i.e. are copies of each other. If the two bundles
were independently constructed, they're @e not considered to be the
same, even if they were created from the same bitmap.
*/
bool IsSameAs(const wxBitmapBundle& other) const;
};
/**
Base class for custom implementations of wxBitmapBundle.
This class shouldn't be used directly in the application code, but may be
derived from to implement custom bitmap bundles.
Example of use:
@code
class MyCustomBitmapBundleImpl : public wxBitmapBundleImpl
{
public:
MyCustomBitmapBundleImpl()
{
}
wxSize GetDefaultSize() const override
{
... determine the minimum/default size for bitmap to use ...
}
wxSize GetPreferredBitmapSizeAtScale(double scale) const override
{
// If it's ok to scale the bitmap, just use the standard size
// at the given scale:
return GetDefaultSize()*scale;
... otherwise, an existing bitmap of the size closest to the
one above would need to be found and its size returned,
possibly by letting DoGetPreferredSize() choose it ...
}
wxBitmap GetBitmap(const wxSize& size) override
{
... get the bitmap of the requested size from somewhere and
cache it if necessary, i.e. if getting it is expensive ...
}
};
toolBar->AddTool(wxID_OPEN, wxBitmapBundle::FromImpl(new MyCustomBitmapBundleImpl());
@endcode
Full (but still very simple) example of using it can be found in the
toolbar sample code.
@library{wxcore}
@category{gdi}
@since 3.1.6
*/
class wxBitmapBundleImpl : public wxRefCounter
{
public:
/**
Return the size of the bitmaps represented by this bundle in the default
DPI.
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;
protected:
/**
Helper for implementing GetPreferredBitmapSizeAtScale() in the derived
classes.
This function implements the standard algorithm used inside wxWidgets
itself and tries to find the scale closest to the given one, while also
trying to choose one of the available scales, to avoid actually
rescaling the bitmaps.
It relies on GetNextAvailableScale() to get information about the
available bitmaps, so that function must be overridden if this one is
used.
Typically this function is used in the derived classes implementation
to forward GetPreferredBitmapSizeAtScale() to it and when this is done,
GetBitmap() may also use GetIndexToUpscale() to choose the bitmap to
upscale if necessary:
@code
class MyCustomBitmapBundleImpl : public wxBitmapBundleImpl
{
public:
wxSize GetDefaultSize() const
{
return wxSize(32, 32);
}
wxSize GetPreferredBitmapSizeAtScale(double scale) const override
{
return DoGetPreferredSize(scale);
}
wxBitmap GetBitmap(const wxSize& size) override
{
// For consistency with GetNextAvailableScale(), we must have
// bitmap variants for 32, 48 and 64px sizes.
const wxSize availableSizes[] = { 32, 48, 64 };
if ( size.y <= 64 )
{
... get the bitmap from somewhere ...
}
else
{
size_t n = GetIndexToUpscale(size);
bitmap = ... get bitmap for availableSizes[n] ...;
wxBitmap::Rescale(bitmap, size);
}
return bitmap;
}
protected:
double GetNextAvailableScale(size_t& i) const override
{
const double availableScales[] = { 1, 1.5, 2, 0 };
// We can rely on not being called again once we return 0.
return availableScales[i++];
}
...
};
@endcode
@param scale The required scale, typically the same one as passed to
GetPreferredBitmapSizeAtScale().
@since 3.1.7
*/
wxSize DoGetPreferredSize(double scale) const;
/**
Return the index of the available scale most suitable to be upscaled to
the given size.
See DoGetPreferredSize() for an example of using this function.
@param size The required size, typically the same one as passed to
GetBitmap()
@since 3.1.7
*/
size_t GetIndexToUpscale(const wxSize& size) const;
/**
Return information about the available bitmaps.
Overriding this function is optional and only needs to be done if
either DoGetPreferredSize() or GetIndexToUpscale() are called. If you
do override it, this function must return the next available scale or
0.0 if there are no more.
The returned scales must be in ascending order and the first returned
scale, for the initial @a i value of 0, should be 1. The function must
change @a i, but the values of this index don't have to be consecutive
and it's only used by this function itself, the caller only initializes
it to 0 before the first call.
See DoGetPreferredSize() for an example of implementing this function.
@since 3.1.7
*/
virtual double GetNextAvailableScale(size_t& i) const;
};
/**
Creates a wxBitmapBundle from resources on the platforms supporting them or
from two embedded bitmaps otherwise.
This macro use wxBitmapBundle::FromResources() with the provide @a name,
which must be an @e identifier and not a string, i.e. used without quotes,
on the platforms where it works and wxBitmapBundle::FromBitmaps() with @c
name_png and @c name_2x_png arrays containing PNG data elsewhere.
Using it allows to avoid using preprocessor checks in the common case when
just two bitmaps (for standard and high DPI) are embedded in the
application code. Note that all bitmaps defined in the resources, even if
there are more than 2 of them.
Example of use:
@code
toolBar->AddTool(wxID_OPEN, wxBITMAP_BUNDLE_2(open));
@endcode
@header{wx/bmpbndl.h}
@since 3.1.6
*/
#define wxBITMAP_BUNDLE_2(name)

View File

@@ -0,0 +1,139 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpbuttn.h
// Purpose: interface of wxBitmapButton
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxBitmapButton
A bitmap button is a control that contains a bitmap.
Notice that since wxWidgets 2.9.1 bitmap display is supported by the base
wxButton class itself and the only tiny advantage of using this class is
that it allows specifying the bitmap in its constructor, unlike wxButton.
Please see the base class documentation for more information about images
support in wxButton.
@beginStyleTable
@style{wxBU_LEFT}
Left-justifies the bitmap label.
@style{wxBU_TOP}
Aligns the bitmap label to the top of the button.
@style{wxBU_RIGHT}
Right-justifies the bitmap label.
@style{wxBU_BOTTOM}
Aligns the bitmap label to the bottom of the button.
@endStyleTable
Note that the wxBU_EXACTFIT style supported by wxButton is not used by this
class as bitmap buttons don't have any minimal standard size by default.
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_BUTTON(id, func)}
Process a @c wxEVT_BUTTON event, when the button is clicked.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{bitmapbutton}
@see wxButton
*/
class wxBitmapButton : public wxButton
{
public:
/**
Default ctor.
*/
wxBitmapButton();
/**
Constructor, creating and showing a button.
@param parent
Parent window. Must not be @NULL.
@param id
Button identifier. The value wxID_ANY indicates a default value.
@param bitmap
Bitmap to be displayed.
@param pos
Button position.
If ::wxDefaultPosition is specified then a default position is chosen.
@param size
Button size.
If ::wxDefaultSize is specified then the button is sized appropriately
for the bitmap.
@param style
Window style. See wxBitmapButton.
@param validator
Window validator.
@param name
Window name.
@remarks The bitmap parameter is normally the only bitmap you need to provide,
and wxWidgets will draw the button correctly in its different states.
If you want more control, call any of the functions SetBitmapPressed(),
SetBitmapFocus(), SetBitmapDisabled().
@see Create(), wxValidator
*/
wxBitmapButton(wxWindow* parent, wxWindowID id,
const wxBitmapBundle& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
/**
Button creation function for two-step creation.
For more details, see wxBitmapButton().
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxBitmapBundle& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
/**
Creation function for two-step creation of "Close" button.
It is usually not necessary to use this function directly as
NewCloseButton() is more convenient, but, if required, it can be called
on a default-constructed wxBitmapButton object to achieve the same
effect.
@param parent The button parent window, must be non-null.
@param winid The identifier for the new button.
@param name The name for the new button.
@since 3.1.5
*/
bool CreateCloseButton(wxWindow* parent,
wxWindowID winid,
const wxString& name = wxString());
/**
Helper function creating a standard-looking "Close" button.
To get the best results, platform-specific code may need to be used to
create a small, title bar-like "Close" button. This function is
provided to avoid the need to test for the current platform and creates
the button with as native look as possible.
@param parent The button parent window, must be non-null.
@param winid The identifier for the new button.
@param name The name for the new button (available since wxWidgets 3.1.5)
@return The new button.
@since 2.9.5
*/
static wxBitmapButton* NewCloseButton(wxWindow* parent,
wxWindowID winid,
const wxString& name = wxString());
};

View File

@@ -0,0 +1,222 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpcbox.h
// Purpose: interface of wxBitmapComboBox
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxBitmapComboBox
A combobox that displays bitmap in front of the list items.
It currently only allows using bitmaps of one size, and resizes itself
so that a bitmap can be shown next to the text field.
@remarks
While wxBitmapComboBox contains the wxComboBox API, but it might not actually
be derived from that class. In fact, if the platform does not have a native
implementation, wxBitmapComboBox will inherit from wxOwnerDrawnComboBox.
You can determine if the implementation is generic by checking whether
@c wxGENERIC_BITMAPCOMBOBOX is defined. Currently wxBitmapComboBox is
implemented natively for MSW and GTK+.
@beginStyleTable
@style{wxCB_READONLY}
Creates a combobox without a text editor. On some platforms the
control may appear very different when this style is used.
@style{wxCB_SORT}
Sorts the entries in the list alphabetically.
@style{wxTE_PROCESS_ENTER}
The control will generate the event wxEVT_TEXT_ENTER
(otherwise pressing Enter key is either processed internally by the
control or used for navigation between dialog controls).
Windows only.
@endStyleTable
@todo create wxCB_PROCESS_ENTER rather than reusing wxTE_PROCESS_ENTER!
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_COMBOBOX(id, func)}
Process a @c wxEVT_COMBOBOX event, when an item on
the list is selected.
@event{EVT_TEXT(id, func)}
Process a @c wxEVT_TEXT event, when the combobox text changes.
@event{EVT_TEXT_ENTER(id, func)}
Process a @c wxEVT_TEXT_ENTER event, when RETURN is pressed in
the combobox.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{bitmapcombobox}
@see wxComboBox, wxChoice, wxOwnerDrawnComboBox, wxCommandEvent
*/
class wxBitmapComboBox : public wxComboBox
{
public:
/**
Default ctor.
*/
wxBitmapComboBox();
/**
Constructor, creating and showing a combobox.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param value
Initial selection string. An empty string indicates no selection.
@param pos
Initial position.
@param size
Initial size.
@param n
Number of strings with which to initialise the control.
@param choices
An array of strings with which to initialise the control.
@param style
The window style, see wxCB_* flags.
@param validator
Validator which can be used for additional data checks.
@param name
Control name.
@see Create(), wxValidator
*/
wxBitmapComboBox(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0,
const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxBitmapComboBoxNameStr);
/**
Constructor, creating and showing a combobox.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param value
Initial selection string. An empty string indicates no selection.
@param pos
Initial position.
@param size
Initial size.
@param choices
A wxArrayString with which to initialise the control.
@param style
The window style, see wxCB_* flags.
@param validator
Validator which can be used for additional data checks.
@param name
Control name.
@see Create(), wxValidator
*/
wxBitmapComboBox(wxWindow* parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxBitmapComboBoxNameStr);
/**
Destructor, destroying the combobox.
*/
virtual ~wxBitmapComboBox();
/**
Adds the item to the end of the combo box.
*/
int Append(const wxString& item,
const wxBitmapBundle& bitmap = wxBitmapBundle());
/**
Adds the item to the end of the combo box, associating the given
untyped, client data pointer @a clientData with the item.
*/
int Append(const wxString& item, const wxBitmapBundle& bitmap,
void* clientData);
/**
Adds the item to the end of the combo box, associating the given typed
client data pointer @a clientData with the item.
*/
int Append(const wxString& item, const wxBitmapBundle& bitmap,
wxClientData* clientData);
/**
Creates the combobox for two-step construction.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxBitmapComboBoxNameStr);
/**
Creates the combobox for two-step construction.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxBitmapComboBoxNameStr);
/**
Returns the size of the bitmaps used in the combo box.
If the combo box is empty, then ::wxDefaultSize is returned.
*/
virtual wxSize GetBitmapSize() const;
/**
Returns the bitmap of the item with the given index.
*/
virtual wxBitmap GetItemBitmap(unsigned int n) const;
/**
Inserts the item into the list before @a pos.
Not valid for @c wxCB_SORT style, use Append() instead.
*/
int Insert(const wxString& item, const wxBitmapBundle& bitmap,
unsigned int pos);
/**
Inserts the item into the list before pos, associating the given
untyped, client data pointer with the item.
Not valid for @c wxCB_SORT style, use Append() instead.
*/
int Insert(const wxString& item, const wxBitmapBundle& bitmap,
unsigned int pos,
void* clientData);
/**
Inserts the item into the list before pos, associating the given typed
client data pointer with the item.
Not valid for @c wxCB_SORT style, use Append() instead.
*/
int Insert(const wxString& item, const wxBitmapBundle& bitmap,
unsigned int pos,
wxClientData* clientData);
/**
Sets the bitmap for the given item.
*/
virtual void SetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap);
};

View File

@@ -0,0 +1,463 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bookctrl.h
// Purpose: interface of wxBookCtrlBase
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Bit flags returned by wxBookCtrl::HitTest().
Only one of wxBK_HITTEST_ONICON, wxBK_HITTEST_ONLABEL, wxBK_HITTEST_ONITEM
bits is set if point is over a tab.
Notice that wxOSX currently only returns wxBK_HITTEST_ONLABEL or
wxBK_HITTEST_NOWHERE and never the other values, so you should only test
for these two in the code that should be portable under macOS.
*/
enum
{
/// No tab at the specified point.
wxBK_HITTEST_NOWHERE = 1,
/// The point is over an icon.
wxBK_HITTEST_ONICON = 2,
/// The point is over a tab label.
wxBK_HITTEST_ONLABEL = 4,
/// The point if over a tab item but not over its icon or label.
wxBK_HITTEST_ONITEM = 16,
/// The point is over the page area.
wxBK_HITTEST_ONPAGE = 8
};
/**
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)
/**
@class wxBookCtrlBase
A book control is a convenient way of displaying multiple pages of information,
displayed one page at a time. wxWidgets has five variants of this control:
@li wxChoicebook: controlled by a wxChoice
@li wxListbook: controlled by a wxListCtrl
@li wxNotebook: uses a row of tabs
@li wxTreebook: controlled by a wxTreeCtrl
@li wxToolbook: controlled by a wxToolBar
This abstract class is the parent of all these book controls, and provides
their basic interface.
This is a pure virtual class so you cannot allocate it directly.
@library{wxcore}
@category{bookctrl}
@see @ref overview_bookctrl
*/
class wxBookCtrlBase : public wxControl, public wxWithImages
{
public:
enum
{
/// Symbolic constant indicating that no image should be used.
NO_IMAGE = -1
};
/**
Default ctor.
*/
wxBookCtrlBase();
/**
Constructs the book control with the given parameters.
See Create() for two-step construction.
*/
wxBookCtrlBase(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
/**
Constructs the book control with the given parameters.
*/
bool Create(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
/**
@name Image list functions
Each page may have an attached image.
The functions of this group manipulate that image.
*/
///@{
/**
Returns the image index for the given page.
*/
virtual int GetPageImage(size_t nPage) const = 0;
/**
Sets the image index for the given page. @a image is an index into
the image list which was set with SetImageList().
*/
virtual bool SetPageImage(size_t page, int image) = 0;
///@}
/**
@name Page text functions
Each page has a text string attached.
The functions of this group manipulate that text.
*/
///@{
/**
Returns the string for the given page.
*/
virtual wxString GetPageText(size_t nPage) const = 0;
/**
Sets the text for the given page.
The text may contain mnemonics, i.e. accelerator characters preceded by
the ampersand (`&`) character. If you need to include a literal
ampersand in the text, you need to double it, i.e. use `&&`.
*/
virtual bool SetPageText(size_t page, const wxString& text) = 0;
///@}
/**
@name Selection functions
The functions of this group manipulate the selection.
*/
///@{
/**
Returns the currently selected page, or @c wxNOT_FOUND if none was selected.
Note that this method may return either the previously or newly
selected page when called from the @c EVT_BOOKCTRL_PAGE_CHANGED handler
depending on the platform and so wxBookCtrlEvent::GetSelection should be
used instead in this case.
*/
virtual int GetSelection() const = 0;
/**
Returns the currently selected page or @NULL.
*/
wxWindow* GetCurrentPage() const;
/**
Sets the selection to the given page, returning the previous selection.
Notice that the call to this function generates the page changing
events, use the ChangeSelection() function if you don't want these
events to be generated.
@see GetSelection()
*/
virtual int SetSelection(size_t page) = 0;
/**
Cycles through the tabs.
The call to this function generates the page changing events.
*/
void AdvanceSelection(bool forward = true);
/**
Changes the selection to the given page, returning the previous selection.
This function behaves as SetSelection() but does @em not generate the
page changing events.
See @ref overview_events_prog for more information.
*/
virtual int ChangeSelection(size_t page) = 0;
/**
Returns the index of the specified tab window or @c wxNOT_FOUND
if not found.
@param page One of the control pages.
@return The zero-based tab index or @c wxNOT_FOUND if not found.
@since 2.9.5
*/
int FindPage(const wxWindow* page) const;
///@}
/**
Sets the width and height of the pages.
@note This method is currently not implemented for wxGTK.
*/
virtual void SetPageSize(const wxSize& size);
/**
Returns the index of the tab at the specified position or @c wxNOT_FOUND
if none. If @a flags parameter is non-null, the position of the point
inside the tab is returned as well.
@param pt
Specifies the point for the hit test.
@param flags
Return more details about the point, see returned value is a
combination of ::wxBK_HITTEST_NOWHERE, ::wxBK_HITTEST_ONICON,
::wxBK_HITTEST_ONLABEL, ::wxBK_HITTEST_ONITEM,
::wxBK_HITTEST_ONPAGE.
@return Returns the zero-based tab index or @c wxNOT_FOUND if there is no
tab at the specified position.
*/
virtual int HitTest(const wxPoint& pt, long* flags = nullptr) const;
/**
@name Page management functions
Functions for adding/removing pages from this control.
*/
///@{
/**
Adds a new page.
The page must have the book control itself as the parent and must not
have been added to this control previously.
The call to this function will generate the page changing and page
changed events if @a select is true, but not when inserting the very
first page (as there is no previous page selection to switch from in
this case and so it wouldn't make sense to e.g. veto such event).
@param page
Specifies the new page.
@param text
Specifies the text of the new page. Note that it may contain
mnemonic characters, see SetPageText() for more information.
@param select
Specifies whether the page should be selected.
@param imageId
Specifies the optional image index for the new page.
@return @true if successful, @false otherwise.
@remarks Do not delete the page, it will be deleted by the book control.
@see InsertPage()
*/
virtual bool AddPage(wxWindow* page, const wxString& text,
bool select = false, int imageId = NO_IMAGE);
/**
Deletes all pages.
*/
virtual bool DeleteAllPages();
/**
Deletes the specified page, and the associated window.
The call to this function generates the page changing events when
deleting the currently selected page or a page preceding it in the
index order, but it does @e not send any events when deleting the last
page: while in this case the selection also changes, it becomes invalid
and for compatibility reasons the control never generates events with
the invalid selection index.
*/
virtual bool DeletePage(size_t page);
/**
Inserts a new page at the specified position.
@param index
Specifies the position for the new page.
@param page
Specifies the new page.
@param text
Specifies the text of the new page. Note that it may contain
mnemonic characters, see SetPageText() for more information.
@param select
Specifies whether the page should be selected.
@param imageId
Specifies the optional image index for the new page.
@return @true if successful, @false otherwise.
@remarks Do not delete the page, it will be deleted by the book control.
@see AddPage()
*/
virtual bool InsertPage(size_t index,
wxWindow* page,
const wxString& text,
bool select = false,
int imageId = NO_IMAGE) = 0;
/**
Deletes the specified page, without deleting the associated window.
See DeletePage() for a note about the events generated by this
function.
*/
virtual bool RemovePage(size_t page);
/**
Returns the number of pages in the control.
*/
virtual size_t GetPageCount() const;
/**
Returns the window at the given page position.
*/
wxWindow* GetPage(size_t page) const;
/**
Returns the sizer containing the control for page selection, if any.
Some derived classes, e.g. wxChoicebook, use a separate control for
switching the currently selected page and this function returns the
sizer used for positioning this control and the pages themselves inside
the book control.
Note that many classes, notably wxNotebook, do not use any such
control, and this function simply returns @NULL for them.
@return Non-owning pointer to the sizer or @NULL.
*/
wxSizer* GetControlSizer() const;
///@}
/*
other functions which may be worth documenting:
// geometry
// --------
// calculate the size of the control from the size of its page
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
// 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; }
// we do have multiple pages
virtual bool HasMultiplePages() const { return true; }
// we don't want focus for ourselves
virtual bool AcceptsFocus() const { return false; }
// returns true if the platform should explicitly apply a theme border
virtual bool CanApplyThemeBorder() const { return false; }
*/
};
/**
wxBookCtrl is defined to one of the 'real' book controls.
See @ref overview_bookctrl for more info.
*/
#define wxBookCtrl TheBestBookCtrlForTheCurrentPlatform
/**
@class wxBookCtrlEvent
This class represents the events generated by book controls (wxNotebook,
wxListbook, wxChoicebook, wxTreebook, wxAuiNotebook).
The PAGE_CHANGING events are sent before the current page is changed.
It allows the program to examine the current page (which can be retrieved
with wxBookCtrlEvent::GetOldSelection) and to veto the page change by calling
wxNotifyEvent::Veto if, for example, the current values in the controls
of the old page are invalid.
The PAGE_CHANGED events are sent after the page has been changed and the
program cannot veto it any more, it just informs it about the page change.
To summarize, if the program is interested in validating the page values
before allowing the user to change it, it should process the PAGE_CHANGING
event, otherwise PAGE_CHANGED is probably enough. In any case, it is
probably unnecessary to process both events at once.
@library{wxcore}
@category{events,bookctrl}
@see wxNotebook, wxListbook, wxChoicebook, wxTreebook, wxToolbook, wxAuiNotebook
*/
class wxBookCtrlEvent : public wxNotifyEvent
{
public:
/**
Constructor (used internally by wxWidgets only).
*/
wxBookCtrlEvent(wxEventType eventType = wxEVT_NULL, int id = 0,
int sel = wxNOT_FOUND, int oldSel = wxNOT_FOUND);
/**
Returns the page that was selected before the change, @c wxNOT_FOUND if
none was selected.
*/
int GetOldSelection() const;
/**
Returns the currently selected page, or @c wxNOT_FOUND if none was
selected.
@note under Windows, GetSelection() will return the same value as
GetOldSelection() when called from the @c EVT_BOOKCTRL_PAGE_CHANGING
handler and not the page which is going to be selected.
*/
int GetSelection() const;
/**
Sets the id of the page selected before the change.
*/
void SetOldSelection(int page);
/**
Sets the selection member variable.
*/
void SetSelection(int page);
};

View File

@@ -0,0 +1,369 @@
/////////////////////////////////////////////////////////////////////////////
// Name: brush.h
// Purpose: interface of wxBrush
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
The possible brush styles.
*/
enum wxBrushStyle
{
wxBRUSHSTYLE_INVALID = -1,
wxBRUSHSTYLE_SOLID = wxSOLID,
/**< Solid. */
wxBRUSHSTYLE_TRANSPARENT = wxTRANSPARENT,
/**< Transparent (no fill). */
wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE,
/**< Uses a bitmap as a stipple; the mask is used for blitting monochrome
using text foreground and background colors. */
wxBRUSHSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
/**< Uses a bitmap as a stipple; mask is used for masking areas in the
stipple bitmap. */
wxBRUSHSTYLE_STIPPLE = wxSTIPPLE,
/**< Uses a bitmap as a stipple. */
wxBRUSHSTYLE_BDIAGONAL_HATCH,
/**< Backward diagonal hatch. */
wxBRUSHSTYLE_CROSSDIAG_HATCH,
/**< Cross-diagonal hatch. */
wxBRUSHSTYLE_FDIAGONAL_HATCH,
/**< Forward diagonal hatch. */
wxBRUSHSTYLE_CROSS_HATCH,
/**< Cross hatch. */
wxBRUSHSTYLE_HORIZONTAL_HATCH,
/**< Horizontal hatch. */
wxBRUSHSTYLE_VERTICAL_HATCH,
/**< Vertical hatch. */
wxBRUSHSTYLE_FIRST_HATCH,
/**< First of the hatch styles (inclusive). */
wxBRUSHSTYLE_LAST_HATCH
/**< Last of the hatch styles (inclusive). */
};
/**
@class wxBrush
A brush is a drawing tool for filling in areas. It is used for painting
the background of rectangles, ellipses, etc. It has a colour and a style.
On a monochrome display, wxWidgets shows all brushes as white unless the
colour is really black.
Do not initialize objects on the stack before the program commences, since
other required structures may not have been set up yet. Instead, define
global pointers to objects and create them in wxApp::OnInit or when required.
An application may wish to create brushes with different characteristics
dynamically, and there is the consequent danger that a large number of
duplicate brushes will be created. Therefore an application may wish to
get a pointer to a brush by using the global list of brushes ::wxTheBrushList,
and calling the member function wxBrushList::FindOrCreateBrush().
This class uses reference counting and copy-on-write internally so that
assignments between two instances of this class are very cheap.
You can therefore use actual objects instead of pointers without efficiency problems.
If an instance of this class is changed it will create its own data internally
so that other instances, which previously shared the data using the reference
counting, are not affected.
@library{wxcore}
@category{gdi}
@stdobjects
@li ::wxNullBrush
@li ::wxBLACK_BRUSH
@li ::wxBLUE_BRUSH
@li ::wxCYAN_BRUSH
@li ::wxGREEN_BRUSH
@li ::wxYELLOW_BRUSH
@li ::wxGREY_BRUSH
@li ::wxLIGHT_GREY_BRUSH
@li ::wxMEDIUM_GREY_BRUSH
@li ::wxRED_BRUSH
@li ::wxTRANSPARENT_BRUSH
@li ::wxWHITE_BRUSH
@see wxBrushList, wxDC, wxDC::SetBrush
*/
class wxBrush : public wxGDIObject
{
public:
/**
Default constructor.
The brush will be uninitialised, and wxBrush:IsOk() will return @false.
*/
wxBrush();
/**
Constructs a brush from a colour object and @a style.
@param colour
Colour object.
@param style
One of the ::wxBrushStyle enumeration values.
*/
wxBrush(const wxColour& colour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
/**
Constructs a stippled brush using a bitmap.
The brush style will be set to @c wxBRUSHSTYLE_STIPPLE.
*/
wxBrush(const wxBitmap& stippleBitmap);
/**
Copy constructor, uses @ref overview_refcount "reference counting".
*/
wxBrush(const wxBrush& brush);
/**
Returns a reference to the brush colour.
@see SetColour()
*/
virtual wxColour GetColour() const;
/**
Gets a pointer to the stipple bitmap. If the brush does not have a @c wxBRUSHSTYLE_STIPPLE
style, this bitmap may be non-null but uninitialised (i.e. wxBitmap:IsOk() returns @false).
@see SetStipple()
*/
virtual wxBitmap* GetStipple() const;
/**
Returns the brush style, one of the ::wxBrushStyle values.
@see SetStyle(), SetColour(), SetStipple()
*/
virtual wxBrushStyle GetStyle() const;
/**
Returns @true if the style of the brush is any of hatched fills.
@see GetStyle()
*/
virtual bool IsHatch() const;
/**
Returns @true if the brush is initialised.
Notice that an uninitialized brush object can't be queried for any
brush properties and all calls to the accessor methods on it will
result in an assert failure.
*/
virtual bool IsOk() const;
/**
Returns @true if the brush is a valid non-transparent brush.
This method returns @true if the brush object is initialized and has a
non-transparent style. Notice that this should be used instead of
simply testing whether GetStyle() returns a style different from
wxBRUSHSTYLE_TRANSPARENT if the brush may be invalid as GetStyle()
would assert in this case.
@see IsTransparent()
@since 2.9.2.
*/
bool IsNonTransparent() const;
/**
Returns @true if the brush is transparent.
A transparent brush is simply a brush with wxBRUSHSTYLE_TRANSPARENT
style.
Notice that this function works even for non-initialized brushes (for
which it returns @false) unlike tests of the form <code>GetStyle() ==
wxBRUSHSTYLE_TRANSPARENT</code> which would assert if the brush is
invalid.
@see IsNonTransparent()
@since 2.9.2.
*/
bool IsTransparent() const;
///@{
/**
Sets the brush colour using red, green and blue values.
@see GetColour()
*/
virtual void SetColour(const wxColour& colour);
virtual void SetColour(unsigned char red, unsigned char green, unsigned char blue);
///@}
/**
Sets the stipple bitmap.
@param bitmap
The bitmap to use for stippling.
@remarks The style will be set to @c wxBRUSHSTYLE_STIPPLE, unless the bitmap
has a mask associated to it, in which case the style will be set
to @c wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE.
@see wxBitmap
*/
virtual void SetStipple(const wxBitmap& bitmap);
/**
Sets the brush style.
@param style
One of the ::wxBrushStyle values.
@see GetStyle()
*/
virtual void SetStyle(wxBrushStyle style);
/**
Inequality operator.
See @ref overview_refcount_equality for more info.
*/
bool operator !=(const wxBrush& brush) const;
/**
Equality operator.
See @ref overview_refcount_equality for more info.
*/
bool operator ==(const wxBrush& brush) const;
};
/**
An empty brush.
wxBrush::IsOk() always returns @false for this object.
*/
wxBrush wxNullBrush;
/**
Blue brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxBLUE_BRUSH;
/**
Green brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxGREEN_BRUSH;
/**
Yellow brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxYELLOW_BRUSH;
/**
White brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxWHITE_BRUSH;
/**
Black brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxBLACK_BRUSH;
/**
Grey brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxGREY_BRUSH;
/**
Medium grey brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxMEDIUM_GREY_BRUSH;
/**
Light grey brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxLIGHT_GREY_BRUSH;
/**
Transparent brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxTRANSPARENT_BRUSH;
/**
Cyan brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxCYAN_BRUSH;
/**
Red brush.
Except for the color it has all standard attributes
(@c wxBRUSHSTYLE_SOLID, no stipple bitmap, etc...).
*/
wxBrush* wxRED_BRUSH;
/**
@class wxBrushList
A brush list is a list containing all brushes which have been created.
The application should not construct its own brush list: it should use the
object pointer ::wxTheBrushList.
@library{wxcore}
@category{gdi}
@see wxBrush
*/
class wxBrushList
{
public:
/**
Finds a brush with the specified attributes and returns it, else creates a new
brush, adds it to the brush list, and returns it.
@param colour
Colour object.
@param style
Brush style. See ::wxBrushStyle for a list of styles.
*/
wxBrush* FindOrCreateBrush(const wxColour& colour,
wxBrushStyle style = wxBRUSHSTYLE_SOLID);
};
/**
The global wxBrushList instance.
*/
wxBrushList* wxTheBrushList;

View File

@@ -0,0 +1,414 @@
/////////////////////////////////////////////////////////////////////////////
// Name: buffer.h
// Purpose: interface of wxMemoryBuffer
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
wxScopedCharTypeBuffer<T> is a template class for storing characters.
Data are stored in reference-counted buffer. In other words, making a copy
of wxScopedCharTypeBuffer<T> will @em not make another copy of the stored
string data, it will still point to the same location in memory.
wxScopedCharTypeBuffer<T> supports two storage modes: owned and non-owned.
"Owned" data buffer (created with CreateOwned() or wxCharTypeBuffer<T>
derived class) owns the data and frees them when the last buffer pointing
to them is destroyed.
"Non-owned" buffer (created with CreateNonOwned()), on the other hand,
references data owned by somebody else -- typical use is by
wxString::mb_str() or wxString::wc_str(), which may return non-owned buffer
pointing to wxString's internal store.
Because of this, the validity of data stored in wxScopedCharTypeBuffer<T>
is limited by the lifetime of the "parent" object that created the
buffer (e.g. the wxString on which mb_str() was called).
If you need to preserve the data for longer, assign it to
wxCharTypeBuffer<T> instead of wxScopedCharTypeBuffer<T>. On the other
hand, use wxScopedCharTypeBuffer<T> if the buffer is to be destroyed before
the "parent" object -- typical use would be creating it on the stack and
destroying when it goes out of scope (hence the class' name).
@tparam T
The type of the characters stored in this class.
@since 2.9.0
@nolibrary
@category{data}
*/
template <typename T>
class wxScopedCharTypeBuffer
{
public:
/// Stored characters type.
typedef T CharType;
/// Default constructor, creates null, empty buffer.
wxScopedCharTypeBuffer();
/**
Creates non-owned buffer from string data @a str.
The buffer's destructor will not destroy @a str. The returned buffer's
data is valid only as long as @a str is valid.
@param str String data.
@param len If specified, length of the string, otherwise the string
is considered to be NUL-terminated.
*/
static const wxScopedCharTypeBuffer CreateNonOwned(const CharType *str, size_t len = wxNO_LEN);
/**
Creates owned buffer from @a str and takes ownership of it.
The buffer's destructor will free @a str when its reference count
reaches zero (initial count is 1).
@param str String data.
@param len If specified, length of the string, otherwise the string
is considered to be NUL-terminated.
*/
static const wxScopedCharTypeBuffer CreateOwned(CharType *str, size_t len = wxNO_LEN);
/**
Copy constructor.
Increases reference count on the data, does @em not make wxStrdup()
copy of the data.
*/
wxScopedCharTypeBuffer(const wxScopedCharTypeBuffer& src);
/// Assignment operator behaves in the same way as the copy constructor.
wxScopedCharTypeBuffer& operator=(const wxScopedCharTypeBuffer& src);
/**
Destructor. Frees stored data if it is in "owned" mode and data's
reference count reaches zero.
*/
~wxScopedCharTypeBuffer();
/**
Returns the internal pointer and resets the buffer.
It's the caller responsibility to deallocate the returned pointer using
@c free() function.
Notice that this method is dangerous because it can only be called on a
non-shared owning buffer. Calling it on any other kind of buffer object
will result in a crash after the pointer is freed, so avoid using it
unless absolutely necessary and you are absolutely certain that the
buffer is not shared.
*/
CharType* release() const;
/// Resets the buffer to empty, freeing the data if necessary.
void reset();
/// Returns pointer to the stored data.
CharType *data();
/// Returns const pointer to the stored data.
const CharType *data() const;
/// Returns length of the string stored.
size_t length() const;
/// Implicit conversion to C string.
operator const CharType *() const;
/// Random access to the stored C string.
CharType operator[](size_t n) const;
};
/// Scoped char buffer.
typedef wxScopedCharTypeBuffer<char> wxScopedCharBuffer;
/// Scoped wchar_t buffer.
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedWCharBuffer;
/**
wxCharTypeBuffer<T> is a template class for storing characters.
The difference from wxScopedCharTypeBuffer<T> is that this class
doesn't have non-owned mode and the data stored in it are valid for
as long as the buffer instance exists. Other than that, this class'
behaviour is the same as wxScopedCharTypeBuffer<T>'s -- in particular,
the data are reference-counted and copying the buffer is cheap.
wxScopedCharTypeBuffer<T> buffers can be converted into wxCharTypeBuffer<T>.
@tparam T
The type of the characters stored in this class.
@since 2.9.0
@nolibrary
@category{data}
*/
template <typename T>
class wxCharTypeBuffer : public wxScopedCharTypeBuffer<T>
{
public:
/**
Creates (owned) buffer from @a str and takes ownership of it.
@param str String data.
@param len If specified, length of the string, otherwise the string
is considered to be NUL-terminated.
@see wxScopedCharTypeBuffer<T>::CreateOwned()
*/
wxCharTypeBuffer(const CharType *str = nullptr, size_t len = wxNO_LEN);
/**
Creates (owned) buffer of size @a len.
@see wxScopedCharTypeBuffer<T>::CreateOwned()
*/
wxCharTypeBuffer(size_t len);
/**
Copy constructor.
Increases reference count on the data, does @em not make wxStrdup()
copy of the data.
*/
wxCharTypeBuffer(const wxCharTypeBuffer& src);
/**
Makes a copy of scoped buffer @a src.
If @a src is a non-owned buffer, a copy of its data is made using
wxStrdup(). If @a src is an owned buffer, this constructor behaves
in the usual way (reference count on buffer data is incremented).
*/
wxCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src);
/**
Assigns @a str to this buffer and takes ownership of it (i.e.\ the
buffer becomes "owned").
*/
wxCharTypeBuffer& operator=(const CharType *str);
/// Assignment operator behaves in the same way as the copy constructor.
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src);
/**
Assigns a scoped buffer to this buffer.
If @a src is a non-owned buffer, a copy of its data is made using
wxStrdup(). If @a src is an owned buffer, the assignment behaves
in the usual way (reference count on buffer data is incremented).
*/
wxCharTypeBuffer& operator=(const wxScopedCharTypeBuffer<T>& src);
/**
Extends the buffer to have size @a len.
Can only be called on buffers that don't share data with another
buffer (i.e. reference count of the data is 1).
@see shrink()
*/
bool extend(size_t len);
/**
Shrinks the buffer to have size @a len and NUL-terminates the string
at this length.
Can only be called on buffers that don't share data with another
buffer (i.e. reference count of the data is 1).
@param len Length to shrink to. Must not be larger than current length.
@note The string is not reallocated to take less memory.
@since 2.9.0
@see extend()
*/
bool shrink(size_t len);
};
/**
This is a specialization of wxCharTypeBuffer<T> for @c char type.
@nolibrary
@category{data}
*/
class wxCharBuffer : public wxCharTypeBuffer<char>
{
public:
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
typedef wxScopedCharTypeBuffer<char> wxScopedCharTypeBufferBase;
wxCharBuffer(const wxCharTypeBufferBase& buf);
wxCharBuffer(const wxScopedCharTypeBufferBase& buf);
wxCharBuffer(const CharType *str = nullptr);
wxCharBuffer(size_t len);
wxCharBuffer(const wxCStrData& cstr);
};
/**
This is a specialization of wxCharTypeBuffer<T> for @c wchar_t type.
@nolibrary
@category{data}
*/
class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
{
public:
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedCharTypeBufferBase;
wxWCharBuffer(const wxCharTypeBufferBase& buf);
wxWCharBuffer(const wxScopedCharTypeBufferBase& buf);
wxWCharBuffer(const CharType *str = nullptr);
wxWCharBuffer(size_t len);
wxWCharBuffer(const wxCStrData& cstr);
};
/**
@class wxMemoryBuffer
A @b wxMemoryBuffer is a useful data structure for storing arbitrary sized
blocks of memory. wxMemoryBuffer guarantees deletion of the memory block when
the object is destroyed.
@library{wxbase}
@category{data}
*/
class wxMemoryBuffer
{
public:
/**
Copy constructor, refcounting is used for performance, but wxMemoryBuffer
is not a copy-on-write structure so changes made to one buffer effect all
copies made from it.
@see @ref overview_refcount
*/
wxMemoryBuffer(const wxMemoryBuffer& src);
/**
Create a new buffer.
@param size
size of the new buffer, 1KiB by default.
*/
wxMemoryBuffer(size_t size = 1024);
/**
Append a single byte to the buffer.
@param data
New byte to append to the buffer.
*/
void AppendByte(char data);
/**
Single call to append a data block to the buffer.
@param data
Pointer to block to append to the buffer.
@param len
Length of data to append.
*/
void AppendData(const void *data, size_t len);
/**
Clear the buffer contents.
The buffer won't contain any data after this method is called.
@see IsEmpty()
@since 2.9.4
*/
void Clear();
/**
Ensure that the buffer is big enough and return a pointer to the start
of the empty space in the buffer. This pointer can be used to directly
write data into the buffer, this new data will be appended to the
existing data.
@param sizeNeeded
Amount of extra space required in the buffer for
the append operation
*/
void* GetAppendBuf(size_t sizeNeeded);
/**
Returns the size of the buffer.
*/
size_t GetBufSize() const;
/**
Return a pointer to the data in the buffer.
*/
void* GetData() const;
/**
Returns the length of the valid data in the buffer.
*/
size_t GetDataLen() const;
/**
Ensure the buffer is big enough and return a pointer to the
buffer which can be used to directly write into the buffer
up to @a sizeNeeded bytes.
*/
void* GetWriteBuf(size_t sizeNeeded);
/**
Returns true if the buffer contains no data.
@see Clear()
@since 2.9.4
*/
bool IsEmpty() const;
/**
Ensures the buffer has at least @a size bytes available.
*/
void SetBufSize(size_t size);
/**
Sets the length of the data stored in the buffer.
Mainly useful for truncating existing data.
@param size
New length of the valid data in the buffer. This is
distinct from the allocated size
*/
void SetDataLen(size_t size);
/**
Update the length after completing a direct append, which
you must have used GetAppendBuf() to initialise.
@param sizeUsed
This is the amount of new data that has been
appended.
*/
void UngetAppendBuf(size_t sizeUsed);
/**
Update the buffer after completing a direct write, which
you must have used GetWriteBuf() to initialise.
@param sizeUsed
The amount of data written in to buffer
by the direct write
*/
void UngetWriteBuf(size_t sizeUsed);
};

View File

@@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/busycursor.h
// Purpose: Busy cursor-related stuff
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/** @addtogroup group_funcmacro_dialog */
///@{
/**
Changes the cursor to the given cursor for all windows in the application.
Use wxEndBusyCursor() to revert the cursor back to its previous state.
These two calls can be nested, and a counter ensures that only the outer
calls take effect.
Prefer using wxBusyCursor to using this function directly.
@see wxIsBusy(), wxBusyCursor
@header{wx/busycursor.h}
@library{wxcore}
*/
void wxBeginBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR);
/**
Overload of wxBeginBusyCursor() taking a cursor bundle.
This overload selects the cursor of the appropriate size from @a cursors.
As with wxSetCursor(), the busy cursor is currently not updated
automatically if the DPI or preferred cursor size changes because this is
considered to be unlikely to happen during the brief time while the busy
cursor is shown.
@since 3.3.0
*/
void wxBeginBusyCursor(const wxCursorBundle& cursors);
/**
Changes the cursor back to the original cursor, for all windows in the
application. Use with wxBeginBusyCursor().
@see wxIsBusy(), wxBusyCursor
@header{wx/busycursor.h}
@library{wxcore}
*/
void wxEndBusyCursor();
/**
Returns @true if between two wxBeginBusyCursor() and wxEndBusyCursor()
calls.
@see wxBusyCursor.
@header{wx/busycursor.h}
@library{wxcore}
*/
bool wxIsBusy();
///@}
/**
@class wxBusyCursor
This class makes it easy to tell your user that the program is temporarily
busy. Just create a wxBusyCursor object on the stack, and within the
current scope, the hourglass will be shown.
For example:
@code
wxBusyCursor wait;
for (int i = 0; i < 100000; i++)
DoACalculation();
@endcode
It works by calling wxBeginBusyCursor() in the constructor, and
wxEndBusyCursor() in the destructor.
@library{wxcore}
@category{misc}
@see wxBeginBusyCursor(), wxEndBusyCursor(), wxWindowDisabler, wxBusyInfo
*/
class wxBusyCursor
{
public:
/**
Constructs a busy cursor object, calling wxBeginBusyCursor().
*/
explicit wxBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR);
/**
Constructs a busy cursor object, calling wxBeginBusyCursor() with the
given cursor bundle.
@since 3.3.0
*/
explicit wxBusyCursor(const wxCursorBundle& cursors);
/**
Destroys the busy cursor object, calling wxEndBusyCursor().
*/
~wxBusyCursor();
};

View File

@@ -0,0 +1,226 @@
/////////////////////////////////////////////////////////////////////////////
// Name: busyinfo.h
// Purpose: interface of wxBusyInfo
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxBusyInfo
This class makes it easy to tell your user that the program is temporarily busy.
Normally the main thread should always return to the main loop to continue
dispatching events as quickly as possible, hence this class shouldn't be
needed. However if the main thread does need to block, this class provides
a simple way to at least show this to the user: just create a wxBusyInfo
object on the stack, and within the current scope, a message window will be
shown.
For example:
@code
wxBusyInfo wait("Please wait, working...");
for (int i = 0; i < 100000; i++)
{
DoACalculation();
}
@endcode
It works by creating a window in the constructor, and deleting it
in the destructor.
This window is rather plain by default but can be customized by passing
wxBusyInfo constructor an object of wxBusyInfoFlags class instead of a
simple message. Here is an example from the dialogs sample:
@code
wxBusyInfo info
(
wxBusyInfoFlags()
.Parent(this)
.Icon(wxArtProvider::GetBitmapBundle(wxART_PRINT,
wxART_OTHER,
wxSize(128, 128)))
.Title("<b>Printing your document</b>")
.Text("Please wait...")
.Foreground(*wxWHITE)
.Background(*wxBLACK)
.Transparency(4*wxALPHA_OPAQUE/5)
);
@endcode
This shows that separate title and text can be set, and that simple markup
(@ref wxControl::SetLabelMarkup()) can be used in them, and that it's also
possible to add an icon and customize the colours and transparency of the
window.
You may also want to call wxTheApp->Yield() to refresh the window
periodically (in case it had been obscured by other windows, for
example) like this:
@code
wxWindowDisabler disableAll;
wxBusyInfo wait("Please wait, working...");
for (int i = 0; i < 100000; i++)
{
DoACalculation();
if ( !(i % 1000) )
wxTheApp->Yield();
}
@endcode
but take care to not cause undesirable reentrancies when doing it (see
wxApp::Yield for more details). The simplest way to do it is to use
wxWindowDisabler class as illustrated in the above example.
Note that a wxBusyInfo is always built with the @c wxSTAY_ON_TOP window style
(see wxFrame window styles for more info).
@library{wxcore}
@category{cmndlg}
*/
class wxBusyInfo
{
public:
/**
General constructor.
This constructor allows specifying all supported attributes by calling
the appropriate methods on wxBusyInfoFlags object passed to it as
parameter. All of them are optional but usually at least the message
should be specified.
@since 3.1.0
*/
wxBusyInfo(const wxBusyInfoFlags& flags);
/**
Simple constructor specifying only the message and the parent.
This constructs a busy info window as child of @a parent and displays
@a msg in it. It is exactly equivalent to using
@code
wxBusyInfo(wxBusyInfoFlags().Parent(parent).Label(message))
@endcode
@note If @a parent is not @NULL you must ensure that it is not
closed while the busy info is shown.
*/
wxBusyInfo(const wxString& msg, wxWindow* parent = nullptr);
/**
Update the information text.
The @a text string may contain markup as described in
wxControl::SetLabelMarkup().
@since 3.1.3
*/
void UpdateText(const wxString& str);
/**
Same as UpdateText() but doesn't interpret the string as containing markup.
@since 3.1.3
*/
void UpdateLabel(const wxString& str);
/**
Hides and closes the window containing the information text.
*/
virtual ~wxBusyInfo();
};
/**
Parameters for wxBusyInfo.
This class exists only in order to make passing attributes to wxBusyInfo
constructor easier and the code doing it more readable.
All methods of this class return the reference to the object on which they
are called, making it possible to chain them together, e.g. typically you
would just create a temporary wxBusyInfoFlags object and then call the
methods corresponding to the attributes you want to set, before finally
passing the result to wxBusyInfo constructor, e.g.:
@code
wxBusyInfo info
(
wxBusyInfoFlags()
.Parent(window)
.Icon(icon)
.Title("Some text")
.Text("Some more text")
.Foreground(wxColour(...))
.Background(wxColour(...))
);
@endcode
@since 3.1.0
*/
class wxBusyInfoFlags
{
public:
/**
Default constructor initializes all attributes to default values.
Call the other methods to really fill in the object.
*/
wxBusyInfoFlags();
/// Sets the parent for wxBusyInfo.
wxBusyInfoFlags& Parent(wxWindow* parent);
/**
Sets the icon to show in wxBusyInfo.
@a icon can contain multiple versions of the bitmap in different
resolutions since wxWidgets 3.3.0, in the earlier versions this
parameter was just a single wxIcon.
*/
wxBusyInfoFlags& Icon(const wxBitmapBundle& icon);
/**
Sets the title, shown prominently in wxBusyInfo window.
The @a title string may contain markup as described in
wxControl::SetLabelMarkup().
*/
wxBusyInfoFlags& Title(const wxString& title);
/**
Sets the more detailed text, shown under the title, if any.
The @a text string may contain markup as described in
wxControl::SetLabelMarkup().
*/
wxBusyInfoFlags& Text(const wxString& text);
/**
Same as Text() but doesn't interpret the string as containing markup.
This method should be used if the text shown in wxBusyInfo comes from
external source and so may contain characters having special meaning in
simple markup, e.g. '<'.
*/
wxBusyInfoFlags& Label(const wxString& label);
/// Sets the foreground colour of the title and text strings.
wxBusyInfoFlags& Foreground(const wxColour& foreground);
/// Sets the background colour of wxBusyInfo window.
wxBusyInfoFlags& Background(const wxColour& background);
/**
Sets the transparency of wxBusyInfo window.
@param alpha Value in wxALPHA_TRANSPARENT (0) to wxALPHA_OPAQUE (255)
range.
@see wxTopLevelWindow::SetTransparent()
*/
wxBusyInfoFlags& Transparency(wxByte alpha);
};

View File

@@ -0,0 +1,235 @@
/////////////////////////////////////////////////////////////////////////////
// Name: button.h
// Purpose: interface of wxButton
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxButton
A button is a control that contains a text string, and is one of the most
common elements of a GUI.
It may be placed on a @ref wxDialog "dialog box" or on a @ref wxPanel panel,
or indeed on almost any other window.
By default, i.e. if none of the alignment styles are specified, the label
is centered both horizontally and vertically. If the button has both a
label and a bitmap, the alignment styles above specify the location of the
rectangle combining both the label and the bitmap and the bitmap position
set with wxButton::SetBitmapPosition() defines the relative position of the
bitmap with respect to the label (however currently non-default alignment
combinations are not implemented on all platforms).
Since version 2.9.1 wxButton supports showing both text and an image
(currently only when using wxMSW, wxGTK or wxOSX/Cocoa ports), see
SetBitmap() and SetBitmapLabel(), SetBitmapDisabled() &c methods. In the
previous wxWidgets versions this functionality was only available in (the
now trivial) wxBitmapButton class which was only capable of showing an
image without text.
A button may have either a single image for all states or different images
for the following states (different images are not currently supported
under macOS where the normal image is used for all states):
@li @b normal: the default state
@li @b disabled: bitmap shown when the button is disabled.
@li @b pressed: bitmap shown when the button is pushed (e.g. while the user
keeps the mouse button pressed on it)
@li @b focus: bitmap shown when the button has keyboard focus (but is not
pressed as in this case the button is in the pressed state)
@li @b current: bitmap shown when the mouse is over the button (but it is
not pressed although it may have focus). Notice that if current bitmap
is not specified but the current platform UI uses hover images for the
buttons (such as Windows or GTK+), then the focus bitmap is used for
hover state as well. This makes it possible to set focus bitmap only to
get reasonably good behaviour on all platforms.
All of the bitmaps must be of the same size and the normal bitmap must be
set first (to a valid bitmap), before setting any other ones. Also, if the
size of the bitmaps is changed later, you need to change the size of the
normal bitmap before setting any other bitmaps with the new size (and you
do need to reset all of them as their original values can be lost when the
normal bitmap size changes).
The position of the image inside the button be configured using
SetBitmapPosition(). By default the image is on the left of the text.
Please also notice that GTK+ uses a global setting called @c gtk-button-images
to determine if the images should be shown in the buttons
at all. If it is off (which is the case in e.g. Gnome 2.28 by default), no
images will be shown, consistently with the native behaviour.
@beginStyleTable
@style{wxBU_LEFT}
Left-justifies the label. Windows and GTK+ only.
@style{wxBU_TOP}
Aligns the label to the top of the button. Windows and GTK+ only.
@style{wxBU_RIGHT}
Right-justifies the bitmap label. Windows and GTK+ only.
@style{wxBU_BOTTOM}
Aligns the label to the bottom of the button. Windows and GTK+ only.
@style{wxBU_EXACTFIT}
By default, all buttons are made of at least the standard button size,
even if their contents is small enough to fit into a smaller size. This
is done for consistency as most platforms use buttons of the same size
in the native dialogs, but can be overridden by specifying this flag.
If it is given, the button will be made just big enough for its
contents. Notice that under MSW the button will still have at least the
standard height, even with this style, if it has a non-empty label.
@style{wxBU_NOTEXT}
Disables the display of the text label in the button even if it has one
or its id is one of the standard stock ids with an associated label:
without using this style a button which is only supposed to show a
bitmap but uses a standard id would display a label too.
@style{wxBORDER_NONE}
Creates a button without border. This is currently implemented in MSW,
GTK2 and OSX/Cocoa.
@endStyleTable
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_BUTTON(id, func)}
Process a @c wxEVT_BUTTON event, when the button is clicked.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{button}
@see wxBitmapButton
*/
class wxButton : public wxAnyButton
{
public:
/**
Default ctor.
*/
wxButton();
/**
Constructor, creating and showing a button.
The preferred way to create standard buttons is to use default value of
@a label. If no label is supplied and @a id is one of standard IDs from
@ref page_stockitems "this list", a standard label will be used. In
other words, if you use a predefined @c wxID_XXX constant, just omit
the label completely rather than specifying it. In particular, help
buttons (the ones with @a id of @c wxID_HELP) under macOS can't
display any label at all and while wxButton will detect if the standard
"Help" label is used and ignore it, using any other label will prevent
the button from correctly appearing as a help button and so should be
avoided.
In addition to that, the button will be decorated with stock icons under GTK+ 2.
@param parent
Parent window. Must not be @NULL.
@param id
Button identifier. A value of @c wxID_ANY indicates a default value.
@param label
Text to be displayed on the button.
@param pos
Button position.
@param size
Button size. If the default size is specified then the button is sized
appropriately for the text.
@param style
Window style. See wxButton class description.
@param validator
Window validator.
@param name
Window name.
@see Create(), wxValidator
*/
wxButton(wxWindow* parent, wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
/**
Button creation function for two-step creation.
For more details, see wxButton().
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
/**
Returns @true if an authentication needed symbol is displayed on the
button.
@remarks This method always returns @false on non-Windows platforms.
@see SetAuthNeeded()
@since 2.9.1
*/
bool GetAuthNeeded() const;
/**
Returns the default size for the buttons. It is advised to make all the
dialog buttons of the same size and this function allows retrieving the
(platform, and current font dependent) size which should be the best
suited for this.
The optional @a win argument is new since wxWidgets 3.1.3 and allows to
get a per-monitor DPI specific size.
*/
static wxSize GetDefaultSize(wxWindow* win = nullptr);
/**
Returns the string label for the button.
@see SetLabel()
*/
wxString GetLabel() const;
/**
Sets whether an authentication needed symbol should be displayed on the
button.
@remarks This method doesn't do anything on non-Windows platforms.
@see GetAuthNeeded()
@since 2.9.1
*/
void SetAuthNeeded(bool needed = true);
/**
This sets the button to be the default item in its top-level window
(e.g. the panel or the dialog box containing it).
As normal, pressing return causes the default button to be depressed when
the return key is pressed.
See also wxWindow::SetFocus() which sets the keyboard focus for windows
and text panel items, and wxTopLevelWindow::SetDefaultItem().
@remarks Under Windows, only dialog box buttons respond to this function.
@return the old default item (possibly @NULL)
*/
virtual wxWindow* SetDefault();
/**
Sets the string label for the button.
@param label
The label to set.
*/
void SetLabel(const wxString& label);
};

View File

@@ -0,0 +1,577 @@
/////////////////////////////////////////////////////////////////////////////
// Name: calctrl.h
// Purpose: interface of wxCalendarCtrl
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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
};
/**
@class wxCalendarEvent
The wxCalendarEvent class is used together with wxCalendarCtrl.
@library{wxcore}
@category{events}
@see wxCalendarCtrl
*/
class wxCalendarEvent : public wxDateEvent
{
public:
wxCalendarEvent();
wxCalendarEvent(wxWindow *win, const wxDateTime& dt, wxEventType type);
/**
Returns the week day on which the user clicked in
@c EVT_CALENDAR_WEEKDAY_CLICKED handler. It doesn't make sense to call
this function in other handlers.
*/
wxDateTime::WeekDay GetWeekDay() const;
/**
Sets the week day carried by the event, normally only used by the
library internally.
*/
void SetWeekDay(wxDateTime::WeekDay day);
};
wxEventType wxEVT_CALENDAR_SEL_CHANGED;
wxEventType wxEVT_CALENDAR_PAGE_CHANGED;
wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
wxEventType wxEVT_CALENDAR_WEEK_CLICKED;
/**
Possible kinds of borders which may be used to decorate a date using
wxCalendarDateAttr.
*/
enum wxCalendarDateBorder
{
wxCAL_BORDER_NONE, ///< No Border (Default)
wxCAL_BORDER_SQUARE, ///< Rectangular Border
wxCAL_BORDER_ROUND ///< Round Border
};
/**
@class wxCalendarDateAttr
wxCalendarDateAttr is a custom attributes for a calendar date. The objects
of this class are used with wxCalendarCtrl.
@library{wxcore}
@category{data}
@see wxCalendarCtrl
*/
class wxCalendarDateAttr
{
public:
/**
Constructor for specifying all wxCalendarDateAttr properties.
*/
wxCalendarDateAttr(const wxColour& colText = wxNullColour,
const wxColour& colBack = wxNullColour,
const wxColour& colBorder = wxNullColour,
const wxFont& font = wxNullFont,
wxCalendarDateBorder border = wxCAL_BORDER_NONE);
/**
Constructor using default properties except the given border.
*/
wxCalendarDateAttr(wxCalendarDateBorder border,
const wxColour& colBorder = wxNullColour);
/**
Returns the background colour set for the calendar date.
*/
const wxColour& GetBackgroundColour() const;
/**
Returns the border set for the calendar date.
*/
wxCalendarDateBorder GetBorder() const;
/**
Returns the border colour set for the calendar date.
*/
const wxColour& GetBorderColour() const;
/**
Returns the font set for the calendar date.
*/
const wxFont& GetFont() const;
/**
Returns the text colour set for the calendar date.
*/
const wxColour& GetTextColour() const;
/**
Returns @true if a non-default text background colour is set.
*/
bool HasBackgroundColour() const;
/**
Returns @true if a non-default (i.e.\ any) border is set.
*/
bool HasBorder() const;
/**
Returns @true if a non-default border colour is set.
*/
bool HasBorderColour() const;
/**
Returns @true if a non-default font is set.
*/
bool HasFont() const;
/**
Returns @true if a non-default text foreground colour is set.
*/
bool HasTextColour() const;
/**
Returns @true if this calendar day is displayed as a holiday.
*/
bool IsHoliday() const;
/**
Sets the text background colour to use.
*/
void SetBackgroundColour(const wxColour& colBack);
/**
Sets the border to use.
*/
void SetBorder(wxCalendarDateBorder border);
/**
Sets the border colour to use.
*/
void SetBorderColour(const wxColour& col);
/**
Sets the font to use.
*/
void SetFont(const wxFont& font);
/**
If @a holiday is @true, this calendar day will be displayed as a
holiday.
*/
void SetHoliday(bool holiday);
/**
Sets the text (foreground) colour to use.
*/
void SetTextColour(const wxColour& colText);
/**
Used (internally) by the generic wxCalendarCtrl::Mark().
*/
static const wxCalendarDateAttr& GetMark();
/**
Set the attributes that will be used to Mark() days on the generic
wxCalendarCtrl.
*/
static void SetMark(const wxCalendarDateAttr& m);
};
/**
Possible return values from wxCalendarCtrl::HitTest().
*/
enum wxCalendarHitTestResult
{
wxCAL_HITTEST_NOWHERE, ///< Hit outside of anything.
wxCAL_HITTEST_HEADER, ///< Hit on the header (weekdays).
wxCAL_HITTEST_DAY, ///< Hit on a day in the calendar.
wxCAL_HITTEST_INCMONTH, ///< Hit on next month arrow (in alternate month selector mode).
wxCAL_HITTEST_DECMONTH, ///< Hit on previous month arrow (in alternate month selector mode).
wxCAL_HITTEST_SURROUNDING_WEEK, ///< Hit on surrounding week of previous/next month (if shown).
wxCAL_HITTEST_WEEK ///< Hit on week of the year number (if shown).
};
/**
@class wxCalendarCtrl
The calendar control allows the user to pick a date. The user can move the
current selection using the keyboard and select the date (generating
@c EVT_CALENDAR event) by pressing @c @<Return@> or double clicking it.
Generic calendar has advanced possibilities for the customization of its
display, described below. If you want to use these possibilities on every
platform, use wxGenericCalendarCtrl instead of wxCalendarCtrl.
All global settings (such as colours and fonts used) can, of course, be
changed. But also, the display style for each day in the month can be set
independently using wxCalendarDateAttr class.
An item without custom attributes is drawn with the default colours and
font and without border, but setting custom attributes with SetAttr()
allows modifying its appearance. Just create a custom attribute object and
set it for the day you want to be displayed specially (note that the
control will take ownership of the pointer, i.e. it will delete it itself).
A day may be marked as being a holiday, even if it is not recognized as
one by wxDateTime using the wxCalendarDateAttr::SetHoliday() method.
As the attributes are specified for each day, they may change when the
month is changed, so you will often want to update them in
@c EVT_CALENDAR_PAGE_CHANGED event handler.
If neither the @c wxCAL_SUNDAY_FIRST or @c wxCAL_MONDAY_FIRST style is given,
the first day of the week is determined from operating system's settings,
if possible. The native wxGTK calendar chooses the first weekday based on
locale, and these styles have no effect on it.
@beginStyleTable
@style{wxCAL_SUNDAY_FIRST}
Show Sunday as the first day in the week (not in wxGTK)
@style{wxCAL_MONDAY_FIRST}
Show Monday as the first day in the week (not in wxGTK)
@style{wxCAL_SHOW_HOLIDAYS}
Highlight holidays in the calendar (only generic)
@style{wxCAL_NO_YEAR_CHANGE}
Disable the year changing (deprecated, only generic)
@style{wxCAL_NO_MONTH_CHANGE}
Disable the month (and, implicitly, the year) changing
@style{wxCAL_SHOW_SURROUNDING_WEEKS}
Show the neighbouring weeks in the previous and next months
(only generic, always on for the native controls)
@style{wxCAL_SEQUENTIAL_MONTH_SELECTION}
Use alternative, more compact, style for the month and year
selection controls. (only generic)
@style{wxCAL_SHOW_WEEK_NUMBERS}
Show week numbers on the left side of the calendar. (not in generic)
@endStyleTable
@beginEventEmissionTable{wxCalendarEvent}
@event{EVT_CALENDAR(id, func)}
A day was double clicked in the calendar.
@event{EVT_CALENDAR_SEL_CHANGED(id, func)}
The selected date changed.
@event{EVT_CALENDAR_PAGE_CHANGED(id, func)}
The selected month (and/or year) changed.
@event{EVT_CALENDAR_WEEKDAY_CLICKED(id, func)}
User clicked on the week day header (only generic).
@event{EVT_CALENDAR_WEEK_CLICKED(id, func)}
User clicked on the week of the year number (only generic).
@endEventTable
@note Changing the selected date will trigger an EVT_CALENDAR_DAY, MONTH or
YEAR event as well as an EVT_CALENDAR_SEL_CHANGED event.
@note In wxMSW this control always uses the default user locale, i.e. the
month and weekday names are always displayed in the Windows display
language and are not affected by wxUILocale. This is a limitation of
the native control and wxGenericCalendarCtrl must be used if this is
undesirable.
@library{wxcore}
@category{ctrl}
@appearance{calendarctrl}
@nativeimpl{wxgtk,wxmsw}
@see @ref page_samples_calendar, wxCalendarDateAttr, wxCalendarEvent,
wxDatePickerCtrl
*/
class wxCalendarCtrl : public wxControl
{
public:
/**
Default constructor.
*/
wxCalendarCtrl();
/**
Does the same as Create() method.
*/
wxCalendarCtrl(wxWindow* parent, wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAL_SHOW_HOLIDAYS,
const wxString& name = wxCalendarNameStr);
/**
Destroys the control.
*/
~wxCalendarCtrl();
/**
Creates the control. See wxWindow::wxWindow() for the meaning of the
parameters and the control overview for the possible styles.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAL_SHOW_HOLIDAYS,
const wxString& name = wxCalendarNameStr);
/**
This function should be used instead of changing @c wxCAL_SHOW_HOLIDAYS
style bit directly. It enables or disables the special highlighting of
the holidays.
*/
virtual void EnableHolidayDisplay(bool display = true);
/**
This function should be used instead of changing
@c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to
change the month interactively. Note that if the month cannot be
changed, the year cannot be changed either.
@return @true if the value of this option really changed or @false if
it was already set to the requested value.
*/
virtual bool EnableMonthChange(bool enable = true);
/**
@deprecated
This function should be used instead of changing
@c wxCAL_NO_YEAR_CHANGE style bit directly. It allows or disallows the
user to change the year interactively. Only in generic wxCalendarCtrl.
*/
virtual void EnableYearChange(bool enable = true);
/**
Returns the attribute for the given date (should be in the range
1...31). The returned pointer may be @NULL. Only in generic
wxCalendarCtrl.
*/
virtual wxCalendarDateAttr* GetAttr(size_t day) const;
/**
Gets the currently selected date.
*/
virtual wxDateTime GetDate() const;
/**
Gets the background colour of the header part of the calendar window.
This method is currently only implemented in generic wxCalendarCtrl and
always returns @c wxNullColour in the native versions.
@see SetHeaderColours()
*/
virtual const wxColour& GetHeaderColourBg() const;
/**
Gets the foreground colour of the header part of the calendar window.
This method is currently only implemented in generic wxCalendarCtrl and
always returns @c wxNullColour in the native versions.
@see SetHeaderColours()
*/
virtual const wxColour& GetHeaderColourFg() const;
/**
Gets the background highlight colour. Only in generic wxCalendarCtrl.
This method is currently only implemented in generic wxCalendarCtrl and
always returns @c wxNullColour in the native versions.
@see SetHighlightColours()
*/
virtual const wxColour& GetHighlightColourBg() const;
/**
Gets the foreground highlight colour. Only in generic wxCalendarCtrl.
This method is currently only implemented in generic wxCalendarCtrl and
always returns @c wxNullColour in the native versions.
@see SetHighlightColours()
*/
virtual const wxColour& GetHighlightColourFg() const;
/**
Return the background colour currently used for holiday highlighting.
Only useful with generic wxCalendarCtrl as native versions currently
don't support holidays display at all and always return
@c wxNullColour.
@see SetHolidayColours()
*/
virtual const wxColour& GetHolidayColourBg() const;
/**
Return the foreground colour currently used for holiday highlighting.
Only useful with generic wxCalendarCtrl as native versions currently
don't support holidays display at all and always return
@c wxNullColour.
@see SetHolidayColours()
*/
virtual const wxColour& GetHolidayColourFg() const;
/**
Returns one of wxCalendarHitTestResult constants and fills either
@a date or @a wd pointer with the corresponding value depending on the
hit test code.
Not implemented in wxGTK currently.
*/
virtual wxCalendarHitTestResult HitTest(const wxPoint& pos,
wxDateTime* date = nullptr,
wxDateTime::WeekDay* wd = nullptr);
/**
Clears any attributes associated with the given day (in the range
1...31). Only in generic wxCalendarCtrl.
*/
virtual void ResetAttr(size_t day);
/**
Associates the attribute with the specified date (in the range 1...31).
If the pointer is @NULL, the items attribute is cleared. Only in
generic wxCalendarCtrl.
*/
virtual void SetAttr(size_t day, wxCalendarDateAttr* attr);
/**
Sets the current date.
The @a date parameter must be valid and in the currently valid range as
set by SetDateRange(), otherwise the current date is not changed and
the function returns @false and, additionally, triggers an assertion
failure if the date is invalid.
*/
virtual bool SetDate(const wxDateTime& date);
/**
Set the colours used for painting the weekdays at the top of the
control.
This method is currently only implemented in generic wxCalendarCtrl and
does nothing in the native versions.
*/
virtual void SetHeaderColours(const wxColour& colFg,
const wxColour& colBg);
/**
Set the colours to be used for highlighting the currently selected
date.
This method is currently only implemented in generic wxCalendarCtrl and
does nothing in the native versions.
*/
virtual void SetHighlightColours(const wxColour& colFg,
const wxColour& colBg);
/**
Marks the specified day as being a holiday in the current month.
This method is only implemented in the generic version of the control
and does nothing in the native ones.
*/
virtual void SetHoliday(size_t day);
/**
Sets the colours to be used for the holidays highlighting.
This method is only implemented in the generic version of the control
and does nothing in the native ones. It should also only be called if
the window style includes @c wxCAL_SHOW_HOLIDAYS flag or
EnableHolidayDisplay() had been called.
*/
virtual void SetHolidayColours(const wxColour& colFg,
const wxColour& colBg);
/**
Mark or unmark the day. This day of month will be marked in every
month. In generic wxCalendarCtrl,
*/
virtual void Mark(size_t day, bool mark);
/**
@name Date Range Functions
*/
///@{
/**
Restrict the dates that can be selected in the control to the specified
range.
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.
@see GetDateRange()
@param lowerdate
The low limit for the dates shown by the control or
::wxDefaultDateTime.
@param upperdate
The high limit for the dates shown by the control or
::wxDefaultDateTime.
@return
@true if either limit is valid, @false otherwise
*/
virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
const wxDateTime& upperdate = wxDefaultDateTime);
/**
Returns the limits currently being used.
@see SetDateRange()
@param lowerdate
If non-null, the value of the low limit for the dates shown by the
control is returned (which may be ::wxDefaultDateTime if no limit
is set).
@param upperdate
If non-null, the value of the upper limit for the dates shown by
the control is returned (which may be ::wxDefaultDateTime if no
limit is set).
@return
@true if either limit is set, @false otherwise
*/
virtual bool GetDateRange(wxDateTime *lowerdate,
wxDateTime *upperdate) const;
///@}
};

View File

@@ -0,0 +1,144 @@
/////////////////////////////////////////////////////////////////////////////
// Name: caret.h
// Purpose: interface of wxCaret
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxCaret
A caret is a blinking cursor showing the position where the typed text will
appear. Text controls usually have their own caret but wxCaret provides a
way to use a caret in other windows.
Currently, the caret appears as a rectangle of the given size. In the
future, it will be possible to specify a bitmap to be used for the caret
shape.
A caret is always associated with a window and the current caret can be
retrieved using wxWindow::GetCaret(). The same caret can't be reused in two
different windows.
@library{wxcore}
@category{misc}
*/
class wxCaret
{
public:
/**
Default constructor.
*/
wxCaret();
///@{
/**
Creates a caret with the given size (in pixels) and associates it with
the @a window.
*/
wxCaret(wxWindow* window, int width, int height);
wxCaret(wxWindow* window, const wxSize& size);
///@}
///@{
/**
Creates a caret with the given size (in pixels) and associates it with
the @a window (same as the equivalent constructors).
*/
bool Create(wxWindow* window, int width, int height);
bool Create(wxWindow* window, const wxSize& size);
///@}
/**
Returns the blink time which is measured in milliseconds and is the
time elapsed between 2 inversions of the caret (blink time of the caret
is the same for all carets, so this functions is static).
*/
static int GetBlinkTime();
///@{
/**
Get the caret position (in pixels).
@beginWxPerlOnly
In wxPerl there are two methods instead of a single overloaded
method:
- GetPosition(): returns a Wx::Point object.
- GetPositionXY(): returns a 2-element list (x, y).
@endWxPerlOnly
*/
void GetPosition(int* x, int* y) const;
wxPoint GetPosition() const;
///@}
///@{
/**
Get the caret size.
@beginWxPerlOnly
In wxPerl there are two methods instead of a single overloaded
method:
- GetSize(): returns a Wx::Size object.
- GetSizeWH(): returns a 2-element list (width, height).
@endWxPerlOnly
*/
void GetSize(int* width, int* height) const;
wxSize GetSize() const;
///@}
/**
Get the window the caret is associated with.
*/
wxWindow* GetWindow() const;
/**
Hides the caret, same as Show(@false).
*/
virtual void Hide();
/**
Returns @true if the caret was created successfully.
*/
bool IsOk() const;
/**
Returns @true if the caret is visible and @false if it is permanently
hidden (if it is blinking and not shown currently but will be after
the next blink, this method still returns @true).
*/
bool IsVisible() const;
///@{
/**
Move the caret to given position (in logical coordinates).
*/
void Move(int x, int y);
void Move(const wxPoint& pt);
///@}
/**
Sets the blink time for all the carets.
@warning Under Windows, this function will change the blink time for
all carets permanently (until the next time it is called),
even for carets in other applications.
@see GetBlinkTime()
*/
static void SetBlinkTime(int milliseconds);
///@{
/**
Changes the size of the caret.
*/
void SetSize(int width, int height);
void SetSize(const wxSize& size);
///@}
/**
Shows or hides the caret. Notice that if the caret was hidden N times,
it must be shown N times as well to reappear on the screen.
*/
virtual void Show(bool show = true);
};

View File

@@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////
// Name: chartype.h
// Purpose: interface of global functions
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/** @addtogroup group_funcmacro_string */
///@{
/**
Macro taking a literal string and expanding into a wide string.
This macro should not be used in the new code any more as it is simply
equivalent to using `L` string prefix now, i.e. its simplified definition
could be just
@code
#define wxT(x) L##x
@endcode
It used to be required when converting literal strings to wxString in
wxWidgets versions prior to 2.9.0, and so can be found in a lot of existing
code, but can be simply removed in any code using more recent versions of
wxWidgets.
@see @ref overview_unicode, wxS()
@header{wx/chartype.h}
*/
#define wxT(string)
/**
Obsolete macro which simply expands to its argument.
This macro could be used in the code which needed to compile with both
wxWidgets 2 and 3 versions in some rare circumstances. It is still provided
for compatibility but serves no purpose any longer.
@see wxT()
@since 2.8.12, 2.9.2
@header{wx/chartype.h}
*/
#define wxT_2(string)
/**
wxS is a macro which can be used with character and string literals (in other words,
@c 'x' or @c "foo") to convert them either to wide characters or wide strings
in @c wchar_t-based (UTF-16) builds, or to keep them unchanged in @c char-based
(UTF-8) builds.
Basically this macro produces characters or strings of type wxStringCharType.
The use of this macro is optional as the translation will always be done at
run-time even if there is a mismatch between the kind of the literal used
and the string or character type used in the current build.
However using it can be beneficial in <b>performance-sensitive code</b> to
do the conversion at compile-time instead.
@see @ref overview_unicode, wxT()
@header{wx/chartype.h}
*/
#define wxS(string)
/**
This macro is exactly the same as wxT() and is defined in wxWidgets simply
because it may be more intuitive for Windows programmers as the standard
Win32 headers also define it (as well as yet another name for the same
macro which is _TEXT()).
Don't confuse this macro with _()!
Note that since wxWidgets 2.9.0 the use of _T() is discouraged just like
for wxT() and also that this macro may conflict with identifiers defined in
standard headers of some compilers (such as Sun CC) so its use should
really be avoided.
@header{wx/chartype.h}
*/
#define _T(string)
/**
wxChar is a compatibility typedef always defined as @c wchar_t now.
Note that it is not affected by @c wxUSE_UNICODE_UTF8 option.
*/
typedef wchar_t wxChar;
/**
wxSChar is a compatibility typedef always defined as @c wchar_t now.
*/
typedef wchar_t wxSChar;
/**
wxUChar is a compatibility typedef always defined as @c wchar_t now.
*/
typedef wchar_t wxUChar;
/**
wxStringCharType is defined to be:
\- @c char when <tt>wxUSE_UNICODE_WCHAR==0</tt>
\- @c wchar_t when <tt>wxUSE_UNICODE_WCHAR==1</tt>
The @c wxUSE_UNICODE_WCHAR symbol is defined by default, but may be turned
off in which case @c wxUSE_UNICODE_UTF8 is turned on.
Note that wxStringCharType (as the name says) is the type used by wxString
for internal storage of the characters.
*/
typedef wxUSE_UNICODE_WCHAR_dependent wxStringCharType;
///@}

View File

@@ -0,0 +1,187 @@
/////////////////////////////////////////////////////////////////////////////
// Name: checkbox.h
// Purpose: interface of wxCheckBox
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*
* 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
/**
The possible states of a 3-state wxCheckBox (Compatible with the 2-state
wxCheckBox).
*/
enum wxCheckBoxState
{
wxCHK_UNCHECKED,
wxCHK_CHECKED,
wxCHK_UNDETERMINED ///< 3-state checkbox only
};
/**
@class wxCheckBox
A checkbox is a labelled box which by default is either on (checkmark is
visible) or off (no checkmark). Optionally (when the wxCHK_3STATE style
flag is set) it can have a third state, called the mixed or undetermined
state. Often this is used as a "Does Not Apply" state.
@beginStyleTable
@style{wxCHK_2STATE}
Create a 2-state checkbox. This is the default.
@style{wxCHK_3STATE}
Create a 3-state checkbox.
@style{wxCHK_ALLOW_3RD_STATE_FOR_USER}
By default a user can't set a 3-state checkbox to the third state.
It can only be done from code. Using this flags allows the user to
set the checkbox to the third state by clicking.
@style{wxALIGN_RIGHT}
Makes the text appear on the left of the checkbox.
@endStyleTable
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_CHECKBOX(id, func)}
Process a @c wxEVT_CHECKBOX event, when the checkbox
is clicked.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{checkbox}
@see wxRadioButton, wxCommandEvent
*/
class wxCheckBox : public wxControl
{
public:
/**
Default constructor.
@see Create(), wxValidator
*/
wxCheckBox();
/**
Constructor, creating and showing a checkbox.
@param parent
Parent window. Must not be @NULL.
@param id
Checkbox identifier. The value wxID_ANY indicates a default value.
@param label
Text to be displayed next to the checkbox.
@param pos
Checkbox position.
If ::wxDefaultPosition is specified then a default position is chosen.
@param size
Checkbox size.
If ::wxDefaultSize is specified then a default size is chosen.
@param style
Window style. See wxCheckBox.
@param validator
Window validator.
@param name
Window name.
@see Create(), wxValidator
*/
wxCheckBox(wxWindow* parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
/**
Destructor, destroying the checkbox.
*/
virtual ~wxCheckBox();
/**
Creates the checkbox for two-step construction. See wxCheckBox()
for details.
*/
bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
/**
Gets the state of a 2-state checkbox.
@return Returns @true if it is checked, @false otherwise.
*/
virtual bool GetValue() const;
/**
Gets the state of a 3-state checkbox. Asserts when the function is used
with a 2-state checkbox.
*/
wxCheckBoxState Get3StateValue() const;
/**
Returns whether or not the checkbox is a 3-state checkbox.
@return @true if this checkbox is a 3-state checkbox, @false if it's
a 2-state checkbox.
*/
bool Is3State() const;
/**
Returns whether or not the user can set the checkbox to the third
state.
@return @true if the user can set the third state of this checkbox,
@false if it can only be set programmatically or if it's a
2-state checkbox.
*/
bool Is3rdStateAllowedForUser() const;
/**
This is just a maybe more readable synonym for GetValue(): just as the
latter, it returns @true if the checkbox is checked and @false
otherwise.
*/
bool IsChecked() const;
/**
Sets the checkbox to the given state. This does not cause a
@c wxEVT_CHECKBOX event to get emitted.
@param state
If @true, the check is on, otherwise it is off.
*/
virtual void SetValue(bool state);
/**
Sets the checkbox to the given state. This does not cause a
@c wxEVT_CHECKBOX event to get emitted.
Asserts when the checkbox is a 2-state checkbox and setting the state
to wxCHK_UNDETERMINED.
*/
void Set3StateValue(wxCheckBoxState state);
};

View File

@@ -0,0 +1,168 @@
/////////////////////////////////////////////////////////////////////////////
// Name: checklst.h
// Purpose: interface of wxCheckListBox
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxCheckListBox
A wxCheckListBox is like a wxListBox, but allows items to be checked or
unchecked.
When using this class under Windows wxWidgets must be compiled with
wxUSE_OWNER_DRAWN set to 1.
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_CHECKLISTBOX(id, func)}
Process a @c wxEVT_CHECKLISTBOX event, when an item in
the check list box is checked or unchecked. wxCommandEvent::GetInt()
will contain the index of the item that was checked or unchecked.
wxCommandEvent::IsChecked() is not valid! Use wxCheckListBox::IsChecked()
instead.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{checklistbox}
@see wxListBox, wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
*/
class wxCheckListBox : public wxListBox
{
public:
/**
Default constructor.
*/
wxCheckListBox();
///@{
/**
Constructor, creating and showing a list box.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param pos
Window position.
If ::wxDefaultPosition is specified then a default position is chosen.
@param size
Window size.
If ::wxDefaultSize is specified then the window is sized appropriately.
@param n
Number of strings with which to initialise the control.
@param choices
An array of strings with which to initialise the control.
@param style
Window style. See wxCheckListBox.
@param validator
Window validator.
@param name
Window name.
@beginWxPerlOnly
Not supported by wxPerl.
@endWxPerlOnly
*/
wxCheckListBox(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0,
const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = "listBox");
/**
Constructor, creating and showing a list box.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param pos
Window position.
@param size
Window size. If wxDefaultSize is specified then the window is sized
appropriately.
@param choices
An array of strings with which to initialise the control.
@param style
Window style. See wxCheckListBox.
@param validator
Window validator.
@param name
Window name.
@beginWxPerlOnly
Use an array reference for the @a choices parameter.
@endWxPerlOnly
*/
wxCheckListBox(wxWindow* parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = "listBox");
///@}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int nStrings = 0,
const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
/**
Destructor, destroying the list box.
*/
virtual ~wxCheckListBox();
/**
Checks the given item. Note that calling this method does not result in
a @c wxEVT_CHECKLISTBOX event being emitted.
@param item
Index of item to check.
@param check
@true if the item is to be checked, @false otherwise.
*/
void Check(unsigned int item, bool check = true);
/**
Returns @true if the given item is checked, @false otherwise.
@param item
Index of item whose check status is to be returned.
*/
bool IsChecked(unsigned int item) const;
/**
Return the indices of the checked items.
@param checkedItems
A reference to the array that is filled with the indices of the
checked items.
@return The number of checked items.
@see Check(), IsChecked()
@since 2.9.5
*/
unsigned int GetCheckedItems(wxArrayInt& checkedItems) const;
};

View File

@@ -0,0 +1,483 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choicdlg.h
// Purpose: interface of wx[Multi|Single]ChoiceDialog
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Default style of the choice dialog.
*/
#define wxCHOICEDLG_STYLE (wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE | wxRESIZE_BORDER)
/**
@class wxMultiChoiceDialog
This class represents a dialog that shows a list of strings, and allows the
user to select one or more.
@beginStyleTable
@style{wxOK}
Show an OK button.
@style{wxCANCEL}
Show a Cancel button.
@style{wxCENTRE}
Centre the message.
@endStyleTable
@library{wxbase}
@category{cmndlg}
@see @ref overview_cmndlg_multichoice, wxSingleChoiceDialog
*/
class wxMultiChoiceDialog : public wxDialog
{
public:
///@{
/**
Constructor taking an array of wxString choices.
@param parent
Parent window.
@param message
Message to show on the dialog.
@param caption
The dialog caption.
@param n
The number of choices.
@param choices
An array of strings, or a string list, containing the choices.
@param style
A dialog style (bitlist) containing flags chosen from standard
dialog styles and the ones listed in the class documentation. The
default value is equivalent to wxDEFAULT_DIALOG_STYLE |
wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE.
@param pos
Dialog position.
@remarks Use ShowModal() to show the dialog.
@beginWxPerlOnly
Not supported by wxPerl.
@endWxPerlOnly
*/
wxMultiChoiceDialog(wxWindow* parent, const wxString& message,
const wxString& caption,
int n, const wxString* choices,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
/**
Constructor taking an array of wxString choices.
@param parent
Parent window.
@param message
Message to show on the dialog.
@param caption
The dialog caption.
@param choices
An array of strings, or a string list, containing the choices.
@param style
A dialog style (bitlist) containing flags chosen from standard
dialog styles and the ones listed in the class documentation. The
default value is equivalent to wxDEFAULT_DIALOG_STYLE |
wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE.
@param pos
Dialog position.
@remarks Use ShowModal() to show the dialog.
@beginWxPerlOnly
Use an array reference for the @a choices parameter.
@endWxPerlOnly
*/
wxMultiChoiceDialog(wxWindow* parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
///@}
/**
Returns array with indexes of selected items.
*/
wxArrayInt GetSelections() const;
/**
Sets selected items from the array of selected items' indexes.
*/
void SetSelections(const wxArrayInt& selections);
/**
Shows the dialog, returning either wxID_OK or wxID_CANCEL.
*/
int ShowModal();
};
/**
@class wxSingleChoiceDialog
This class represents a dialog that shows a list of strings, and allows the
user to select one. Double-clicking on a list item is equivalent to
single-clicking and then pressing OK.
@beginStyleTable
@style{wxOK}
Show an OK button.
@style{wxCANCEL}
Show a Cancel button.
@style{wxCENTRE}
Centre the message.
@endStyleTable
@library{wxbase}
@category{cmndlg}
@see @ref overview_cmndlg_singlechoice, wxMultiChoiceDialog
*/
class wxSingleChoiceDialog : public wxDialog
{
public:
///@{
/**
Constructor, taking an array of wxString choices and optional client
data.
@param parent
Parent window.
@param message
Message to show on the dialog.
@param caption
The dialog caption.
@param n
The number of choices.
@param choices
An array of strings, or a string list, containing the choices.
@param clientData
An array of client data to be associated with the items. See
GetSelectionData().
@param style
A dialog style (bitlist) containing flags chosen from standard
dialog styles and the ones listed in the class documentation. The
default value is equivalent to wxDEFAULT_DIALOG_STYLE |
wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE.
@param pos
Dialog position.
@remarks Use ShowModal() to show the dialog.
@beginWxPerlOnly
Not supported by wxPerl.
@endWxPerlOnly
*/
wxSingleChoiceDialog(wxWindow* parent, const wxString& message,
const wxString& caption,
int n, const wxString* choices,
void** clientData = nullptr,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
/**
Constructor, taking an array of wxString choices and optional client
data.
@param parent
Parent window.
@param message
Message to show on the dialog.
@param caption
The dialog caption.
@param choices
An array of strings, or a string list, containing the choices.
@param clientData
An array of client data to be associated with the items. See
GetSelectionData().
@param style
A dialog style (bitlist) containing flags chosen from standard
dialog styles and the ones listed in the class documentation. The
default value is equivalent to wxDEFAULT_DIALOG_STYLE |
wxRESIZE_BORDER | wxOK | wxCANCEL | wxCENTRE.
@param pos
Dialog position.
@remarks Use ShowModal() to show the dialog.
@beginWxPerlOnly
Use an array reference for the @a choices parameter.
@endWxPerlOnly
*/
wxSingleChoiceDialog(wxWindow* parent,
const wxString& message,
const wxString& caption,
const wxArrayString& choices,
void** clientData = nullptr,
long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition);
///@}
/**
Returns the index of selected item.
*/
int GetSelection() const;
/**
Returns the client data associated with the selection.
@since 2.9.4
*/
void* GetSelectionData() const;
/**
Returns the selected string.
*/
wxString GetStringSelection() const;
/**
Sets the index of the initially selected item.
*/
void SetSelection(int selection);
/**
Shows the dialog, returning either wxID_OK or wxID_CANCEL.
*/
int ShowModal();
};
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_dialog */
///@{
/**
Same as wxGetSingleChoice() but returns the index representing the
selected string. If the user pressed cancel, -1 is returned.
@header{wx/choicdlg.h}
@beginWxPerlOnly
Use an array reference for the @a aChoices parameter.
@endWxPerlOnly
*/
int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
const wxArrayString& aChoices,
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
int n,
const wxString& choices[],
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
int initialSelection,
wxWindow *parent = nullptr);
int wxGetSingleChoiceIndex(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
int initialSelection,
wxWindow *parent = nullptr);
///@}
/** @addtogroup group_funcmacro_dialog */
///@{
/**
Pops up a dialog box containing a message, OK/Cancel buttons and a
single-selection listbox. The user may choose an item and press OK to
return a string or Cancel to return the empty string. Use
wxGetSingleChoiceIndex() if empty string is a valid choice and if you want
to be able to detect pressing Cancel reliably.
You may pass the list of strings to choose from either using @c choices
which is an array of @a n strings for the listbox or by using a single
@c aChoices parameter of type wxArrayString.
If @c centre is @true, the message text (which may include new line
characters) is centred; if @false, the message is left-justified.
Note that the @a x, @a y, @a centre, @a width and @a height parameters are
all ignored. To change the dialog's position or size, create a @c
wxSingleChoiceDialog object instead of calling @c wxGetSingleChoice() and
change its size before showing it.
@header{wx/choicdlg.h}
@beginWxPerlOnly
Use an array reference for the @a choices parameter.
@endWxPerlOnly
*/
wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
const wxArrayString& aChoices,
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
int n,
const wxString& choices[],
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
int initialSelection,
wxWindow *parent = nullptr);
wxString wxGetSingleChoice(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
int initialSelection,
wxWindow *parent = nullptr);
///@}
/** @addtogroup group_funcmacro_dialog */
///@{
/**
Same as wxGetSingleChoice but takes an array of client data pointers
corresponding to the strings, and returns one of these pointers or @NULL
if Cancel was pressed. The @c client_data array must have the same number
of elements as @c choices or @c aChoices!
Note that the @a x, @a y, @a centre, @a width and @a height parameters are
all ignored. To change the dialog's position or size, create a @c
wxSingleChoiceDialog object instead of calling @c wxGetSingleChoice() and
change its size before showing it.
@header{wx/choicdlg.h}
@beginWxPerlOnly
Use an array reference for the @a aChoices and @a client_data parameters.
@endWxPerlOnly
*/
wxString wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
const wxArrayString& aChoices,
const wxString& client_data[],
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
wxString wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
int n,
const wxString& choices[],
const wxString& client_data[],
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT,
int initialSelection = 0);
void* wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
const wxArrayString& choices,
void **client_data,
int initialSelection,
wxWindow *parent = nullptr);
void* wxGetSingleChoiceData(const wxString& message,
const wxString& caption,
int n, const wxString *choices,
void **client_data,
int initialSelection,
wxWindow *parent = nullptr);
///@}
/** @addtogroup group_funcmacro_dialog */
///@{
/**
Pops up a dialog box containing a message, OK/Cancel buttons and a
multiple-selection listbox. The user may choose an arbitrary (including 0)
number of items in the listbox whose indices will be returned in
@c selections array. The initial contents of this array will be used to
select the items when the dialog is shown. If the user cancels the dialog,
the function returns -1 and @c selections array is left unchanged.
You may pass the list of strings to choose from either using @c choices
which is an array of @a n strings for the listbox or by using a single
@c aChoices parameter of type wxArrayString.
Note that the @a x, @a y, @a centre, @a width and @a height parameters are
all ignored. To change the dialog's position or size, create a @c
wxSingleChoiceDialog object instead of calling @c wxGetSingleChoice() and
change its size before showing it.
@header{wx/choicdlg.h}
@beginWxPerlOnly
Use an array reference for the @a choices parameter.
In wxPerl there is no @a selections parameter; the function
returns an array containing the user selections.
@endWxPerlOnly
*/
int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
const wxArrayString& aChoices,
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT);
int wxGetSelectedChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
int n,
const wxString& choices[],
wxWindow* parent = nullptr,
int x = wxDefaultCoord,
int y = wxDefaultCoord,
bool centre = true,
int width = wxCHOICE_WIDTH,
int height = wxCHOICE_HEIGHT);
///@}

View File

@@ -0,0 +1,184 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choice.h
// Purpose: interface of wxChoice
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxChoice
A choice item is used to select one of a list of strings. Unlike a
wxListBox, only the selection is visible until the user pulls down the
menu of choices.
@beginStyleTable
@style{wxCB_SORT}
Sorts the entries alphabetically.
@endStyleTable
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_CHOICE(id, func)}
Process a @c wxEVT_CHOICE event, when an item on the
list is selected.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{choice}
@see wxListBox, wxComboBox, wxCommandEvent
*/
class wxChoice : public wxControl,
public wxItemContainer
{
public:
/**
Default constructor.
@see Create(), wxValidator
*/
wxChoice();
/**
Constructor, creating and showing a choice.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param pos
Window position.
If ::wxDefaultPosition is specified then a default position is chosen.
@param size
Window size.
If ::wxDefaultSize is specified then the choice is sized appropriately.
@param n
Number of strings with which to initialise the choice control.
@param choices
An array of strings with which to initialise the choice control.
@param style
Window style. See wxChoice.
@param validator
Window validator.
@param name
Window name.
@see Create(), wxValidator
@beginWxPerlOnly
Not supported by wxPerl.
@endWxPerlOnly
*/
wxChoice( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr );
/**
Constructor, creating and showing a choice.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param pos
Window position.
@param size
Window size. If wxDefaultSize is specified then the choice is sized
appropriately.
@param choices
An array of strings with which to initialise the choice control.
@param style
Window style. See wxChoice.
@param validator
Window validator.
@param name
Window name.
@see Create(), wxValidator
@beginWxPerlOnly
Use an array reference for the @a choices parameter.
@endWxPerlOnly
*/
wxChoice( wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr );
/**
Destructor, destroying the choice item.
*/
virtual ~wxChoice();
///@{
/**
Creates the choice for two-step construction. See wxChoice().
*/
bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr );
bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr );
///@}
/**
Gets the number of columns in this choice item.
@remarks This is implemented for GTK only and always
returns 1 for the other platforms.
*/
virtual int GetColumns() const;
/**
Unlike wxControlWithItems::GetSelection() which only returns the
accepted selection value (the selection in the control once the
user closes the dropdown list), this function returns the current
selection. That is, while the dropdown list is shown, it returns the
currently selected item in it. When it is not shown, its result is the
same as for the other function.
@since 2.6.2.
In older versions, wxControlWithItems::GetSelection() itself
behaved like this.
*/
virtual int GetCurrentSelection() const;
/**
Sets the number of columns in this choice item.
@param n
Number of columns.
@remarks This is implemented for GTK only and doesn't do
anything under other platforms.
*/
virtual void SetColumns(int n = 1);
virtual bool IsSorted() const;
virtual unsigned int GetCount() const ;
virtual int GetSelection() const ;
virtual void SetSelection(int n);
virtual int FindString(const wxString& s, bool bCase = false) const;
virtual wxString GetString(unsigned int n) const ;
virtual void SetString(unsigned int pos, const wxString& s);
};

View File

@@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choicebk.h
// Purpose: interface of wxChoicebook
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// 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
wxEventType wxEVT_CHOICEBOOK_PAGE_CHANGED;
wxEventType wxEVT_CHOICEBOOK_PAGE_CHANGING;
/**
@class wxChoicebook
wxChoicebook is a class similar to wxNotebook, but uses a wxChoice control
to show the labels instead of the tabs.
For usage documentation of this class, please refer to the base abstract class
wxBookCtrl. You can also use the @ref page_samples_notebook to see wxChoicebook in
action.
wxChoicebook allows the use of wxBookCtrlBase::GetControlSizer(), allowing
a program to add other controls next to the choice control. This is
particularly useful when screen space is restricted, as it often is when
wxChoicebook is being employed.
@beginStyleTable
@style{wxCHB_DEFAULT}
Choose the default location for the labels depending on the current
platform (but currently it's the same everywhere, namely wxCHB_TOP).
@style{wxCHB_TOP}
Place labels above the page area.
@style{wxCHB_LEFT}
Place labels on the left side.
@style{wxCHB_RIGHT}
Place labels on the right side.
@style{wxCHB_BOTTOM}
Place labels below the page area.
@endStyleTable
@beginEventEmissionTable{wxBookCtrlEvent}
@event{EVT_CHOICEBOOK_PAGE_CHANGED(id, func)}
The page selection was changed.
Processes a @c wxEVT_CHOICEBOOK_PAGE_CHANGED event.
@event{EVT_CHOICEBOOK_PAGE_CHANGING(id, func)}
The page selection is about to be changed.
Processes a @c wxEVT_CHOICEBOOK_PAGE_CHANGING event.
This event can be vetoed (using wxNotifyEvent::Veto()).
@endEventTable
@library{wxcore}
@category{bookctrl}
@appearance{choicebook}
@see @ref overview_bookctrl, wxNotebook, @ref page_samples_notebook
*/
class wxChoicebook : public wxBookCtrlBase
{
public:
///@{
/**
Constructs a choicebook control.
*/
wxChoicebook();
wxChoicebook(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
///@}
/**
Create the choicebook control that has already been constructed with
the default constructor.
*/
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxEmptyString);
/**
Returns the wxChoice associated with the control.
*/
wxChoice * GetChoiceCtrl() const;
};

View File

@@ -0,0 +1,195 @@
/////////////////////////////////////////////////////////////////////////////
// Name: clipbrd.h
// Purpose: interface of wxClipboard
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
The backwards compatible access macro that returns the global clipboard
object pointer.
*/
#define wxTheClipboard
/**
@class wxClipboard
A class for manipulating the clipboard.
To use the clipboard, you call member functions of the global
::wxTheClipboard object.
See the @ref overview_dataobject for further information.
Call wxClipboard::Open() to get ownership of the clipboard. If this
operation returns @true, you now own the clipboard. Call
wxClipboard::SetData() to put data on the clipboard, or
wxClipboard::GetData() to retrieve data from the clipboard. Call
wxClipboard::Close() to close the clipboard and relinquish ownership. You
should keep the clipboard open only momentarily.
For example:
@code
// Write some text to the clipboard
if (wxTheClipboard->Open())
{
// This data objects are held by the clipboard,
// so do not delete them in the app.
wxTheClipboard->SetData( new wxTextDataObject("Some text") );
wxTheClipboard->Close();
}
// Read some text
if (wxTheClipboard->Open())
{
if (wxTheClipboard->IsSupported( wxDF_TEXT ))
{
wxTextDataObject data;
wxTheClipboard->GetData( data );
wxMessageBox( data.GetText() );
}
wxTheClipboard->Close();
}
@endcode
@note On GTK, the clipboard behavior can vary depending on the configuration of
the end-user's machine. In order for the clipboard data to persist after
the window closes, a clipboard manager must be installed. Some clipboard
managers will automatically flush the clipboard after each new piece of
data is added, while others will not. The Flush() function will force
the clipboard manager to flush the data.
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, @ref overview_dataobject, wxDataObject
*/
class wxClipboard : public wxObject
{
public:
/**
Default constructor.
*/
wxClipboard();
/**
Destructor.
*/
virtual ~wxClipboard();
/**
Call this function to add the data object to the clipboard.
This is an obsolete synonym for SetData().
*/
virtual bool AddData(wxDataObject* data);
/**
Clears the global clipboard object and the system's clipboard if
possible.
*/
virtual void Clear();
/**
Call this function to close the clipboard, having opened it with
Open().
*/
virtual void Close();
/**
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.
Currently this method is implemented in MSW and GTK and always returns @false
otherwise.
@note On GTK, only the non-primary selection can be flushed. Calling this function
when the clipboard is using the primary selection will return @false and not
make any data available after the program exits.
@return @false if the operation is unsuccessful for any reason.
*/
virtual bool Flush();
/**
Call this function to fill @a data with data on the clipboard, if
available in the required format. Returns @true on success.
*/
virtual bool GetData(wxDataObject& data);
/**
Returns @true if the clipboard has been opened.
*/
virtual bool IsOpened() const;
/**
Returns @true if there is data which matches the data format of the
given data object currently @b available on the clipboard.
@todo The name of this function is misleading. This should be renamed
to something that more accurately indicates what it does.
*/
virtual bool IsSupported(const wxDataFormat& format);
/**
Returns @true if we are using the primary selection, @false if
clipboard one.
@see UsePrimarySelection()
*/
bool IsUsingPrimarySelection() const;
/**
Call this function to open the clipboard before calling SetData() and
GetData().
Call Close() when you have finished with the clipboard. You should keep
the clipboard open for only a very short time.
@return @true on success. This should be tested (as in the sample
shown above).
*/
virtual bool Open();
/**
Call this function to set the data object to the clipboard.
The new data object replaces any previously set one, so if the
application wants to provide clipboard data in several different
formats, it must use a composite data object supporting all of the
formats instead of calling this function several times with different
data objects as this would only leave data from the last one in the
clipboard.
After this function has been called, the clipboard owns the data, so do
not delete the data explicitly.
*/
virtual bool SetData(wxDataObject* data);
/**
On platforms supporting it (all X11-based ports), wxClipboard uses the
CLIPBOARD X11 selection by default. When this function is called with
@true, all subsequent clipboard operations will use PRIMARY selection
until this function is called again with @false.
On the other platforms, there is no PRIMARY selection and so all
clipboard operations will fail. This allows implementing the standard
X11 handling of the clipboard which consists in copying data to the
CLIPBOARD selection only when the user explicitly requests it (i.e. by
selecting the "Copy" menu command) but putting the currently selected
text into the PRIMARY selection automatically, without overwriting the
normal clipboard contents with the currently selected text on the other
platforms.
*/
virtual void UsePrimarySelection(bool primary = false);
/**
Returns the global instance (wxTheClipboard) of the clipboard object.
*/
static wxClipboard *Get();
};

View File

@@ -0,0 +1,187 @@
/////////////////////////////////////////////////////////////////////////////
// Name: clntdata.h
// Purpose: interface of wxClientData[Container] and wxStringClientData
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxClientDataContainer
This class is a mixin that provides storage and management of "client data".
This data can either be of type void - in which case the data
@e container does not take care of freeing the data again or it is of
type wxClientData or its derivatives. In that case the container will free
the memory itself later. Note that you @e must not assign both void data
and data derived from the wxClientData class to a container.
@note This functionality is currently duplicated in wxEvtHandler in order
to avoid having more than one vtable in that class hierarchy.
@library{wxbase}
@category{containers}
@see wxSharedClientDataContainer, wxEvtHandler, wxClientData
*/
class wxClientDataContainer
{
public:
/**
Default constructor.
*/
wxClientDataContainer();
/**
Destructor.
*/
virtual ~wxClientDataContainer();
/**
Get the untyped client data.
*/
void* GetClientData() const;
/**
Get a pointer to the client data object.
*/
wxClientData* GetClientObject() const;
/**
Set the untyped client data.
*/
void SetClientData(void* data);
/**
Set the client data object. Any previous object will be deleted.
*/
void SetClientObject(wxClientData* data);
};
/**
@class wxSharedClientDataContainer
This class is a replacement for @ref 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. As the client data
is a shared object, changing the client data used by any object changes
it for all other objects, too.
@note If your class has a Clone function and needs to store client data,
use wxSharedClientDataContainer and not wxClientDataContainer!
@library{wxbase}
@category{containers}
@see wxClientDataContainer, wxClientData
@since 3.1.7
*/
class 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.
/**
Get the untyped client data.
*/
void* GetClientData() const;
/**
Get a pointer to the client data object.
*/
wxClientData* GetClientObject() const;
/**
Set the untyped client data.
*/
void SetClientData(void* data);
/**
Set the client data object. Any previous object will be deleted.
*/
void SetClientObject(wxClientData* data);
};
/**
@class wxClientData
All classes deriving from wxEvtHandler (such as all controls and wxApp) can
hold arbitrary data which is here referred to as "client data". This is
useful e.g. for scripting languages which need to handle shadow objects for
most of wxWidgets' classes and which store a handle to such a shadow class
as client data in that class. This data can either be of type void - in
which case the data @e container does not take care of freeing the data
again or it is of type wxClientData or its derivatives. In that case the
container (e.g. a control) will free the memory itself later. Note that you
@e must not assign both void data and data derived from the wxClientData
class to a container.
Some controls can hold various items and these controls can additionally
hold client data for each item. This is the case for wxChoice, wxComboBox
and wxListBox. wxTreeCtrl has a specialized class wxTreeItemData for each
item in the tree.
If you want to add client data to your own classes, you may use the mix-in
class wxClientDataContainer.
@library{wxbase}
@category{containers}
@see wxEvtHandler, wxTreeItemData, wxStringClientData,
wxClientDataContainer
*/
class wxClientData
{
public:
/**
Constructor.
*/
wxClientData();
/**
Virtual destructor.
*/
virtual ~wxClientData();
};
/**
@class wxStringClientData
Predefined client data class for holding a string.
@library{wxbase}
@category{containers}
*/
class wxStringClientData : public wxClientData
{
public:
/**
Default constructor.
*/
wxStringClientData();
/**
Create client data with string.
*/
wxStringClientData(const wxString& data);
/**
Get string client data.
*/
const wxString& GetData() const;
/**
Set string client data.
*/
void SetData(const wxString& data);
};

View File

@@ -0,0 +1,179 @@
/////////////////////////////////////////////////////////////////////////////
// Name: clrpicker.h
// Purpose: interface of wxColourPickerCtrl
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#define wxCLRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
#define wxCLRP_DEFAULT_STYLE 0
#define wxCLRP_SHOW_LABEL 0x0008
#define wxCLRP_SHOW_ALPHA 0x0010
wxEventType wxEVT_COLOURPICKER_CHANGED;
wxEventType wxEVT_COLOURPICKER_CURRENT_CHANGED;
wxEventType wxEVT_COLOURPICKER_DIALOG_CANCELLED;
/**
@class wxColourPickerCtrl
This control allows the user to select a colour. The generic implementation
is a button which brings up a wxColourDialog when clicked. Native
implementation may differ but this is usually a (small) widget which give
access to the colour-chooser dialog. It is only available if
@c wxUSE_COLOURPICKERCTRL is set to 1 (the default).
@beginStyleTable
@style{wxCLRP_DEFAULT_STYLE}
The default style: 0.
@style{wxCLRP_USE_TEXTCTRL}
Creates a text control to the left of the picker button which is
completely managed by the wxColourPickerCtrl and which can be used
by the user to specify a colour (see SetColour). The text control
is automatically synchronized with button's value. Use functions
defined in wxPickerBase to modify the text control.
@style{wxCLRP_SHOW_LABEL}
Shows the colour in HTML form (AABBCC) as colour button label
(instead of no label at all).
@style{wxCLRP_SHOW_ALPHA}
Allows selecting opacity in the colour-chooser (effective under
wxGTK and wxOSX).
@endStyleTable
@beginEventEmissionTable{wxColourPickerEvent}
@event{EVT_COLOURPICKER_CHANGED(id, func)}
The user changed the colour selected in the control either using the
button or using text control (see @c wxCLRP_USE_TEXTCTRL; note that
in this case the event is fired only if the user's input is valid,
i.e. recognizable). When using a popup dialog for changing the
colour, this event is sent only when the changes in the dialog are
accepted by the user, unlike @c EVT_COLOURPICKER_CURRENT_CHANGED.
@event{EVT_COLOURPICKER_CURRENT_CHANGED(id, func)}
The user changed the currently selected colour in the dialog
associated with the control. This event is sent immediately when the
selection changes and you must also handle @c EVT_COLOUR_CANCELLED
to revert to the previously selected colour if the selection ends up
not being accepted. This event is new since wxWidgets 3.1.3 and
currently is only implemented in wxMSW.
@event{EVT_COLOURPICKER_DIALOG_CANCELLED(id, func)}
The user cancelled the colour dialog associated with the control,
i.e. closed it without accepting the selection. This event is new
since wxWidgets 3.1.3 and currently is only implemented in wxMSW.
@endEventTable
@library{wxcore}
@category{pickers}
@appearance{colourpickerctrl}
@see wxColourDialog, wxColourPickerEvent
*/
class wxColourPickerCtrl : public wxPickerBase
{
public:
wxColourPickerCtrl();
/**
Initializes the object and calls Create() with all the parameters.
*/
wxColourPickerCtrl(wxWindow* parent, wxWindowID id,
const wxColour& colour = *wxBLACK,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCLRP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxColourPickerCtrlNameStr);
/**
Creates a colour picker with the given arguments.
@param parent
Parent window, must not be non-null.
@param id
The identifier for the control.
@param colour
The initial colour shown in the control.
@param pos
Initial position.
@param size
Initial size.
@param style
The window style, see wxCRLP_* flags.
@param validator
Validator which can be used for additional data checks.
@param name
Control name.
@return @true if the control was successfully created or @false if
creation failed.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxColour& colour = *wxBLACK,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCLRP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxColourPickerCtrlNameStr);
/**
Returns the currently selected colour.
*/
wxColour GetColour() const;
///@{
/**
Sets the currently selected colour. See wxColour::Set().
*/
void SetColour(const wxColour& col);
void SetColour(const wxString& colname);
///@}
};
/**
@class wxColourPickerEvent
This event class is used for the events generated by wxColourPickerCtrl.
@beginEventTable{wxColourPickerEvent}
@event{EVT_COLOURPICKER_CHANGED(id, func)}
Generated whenever the selected colour changes.
@event{EVT_COLOURPICKER_CURRENT_CHANGED(id, func)}
Generated whenever the currently selected colour in the dialog shown
by the picker changes. This event is new since wxWidgets 3.1.3 and
currently is only implemented in wxMSW.
@event{EVT_COLOURPICKER_DIALOG_CANCELLED(id, func)}
Generated when the user cancels the colour dialog associated with
the control, i.e. closes it without accepting the selection. This
event is new since wxWidgets 3.1.3 and currently is only implemented
in wxMSW.
@endEventTable
@library{wxcore}
@category{events}
@see wxColourPickerCtrl
*/
class wxColourPickerEvent : public wxCommandEvent
{
public:
wxColourPickerEvent();
/**
The constructor is not normally used by the user code.
*/
wxColourPickerEvent(wxObject* generator, int id,
const wxColour& colour);
/**
Retrieve the colour the user has just selected.
*/
wxColour GetColour() const;
/**
Set the colour associated with the event.
*/
void SetColour(const wxColour& pos);
};

View File

@@ -0,0 +1,813 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cmdline.h
// Purpose: interface of wxCmdLineParser
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
wxCmdLineEntryDesc::flags field is a combination of these bit masks.
Notice that by default (i.e. if flags are just 0), options are optional
(sic) and each call to wxCmdLineParser::AddParam() allows one more
parameter - this may be changed by giving non-default flags to it, i.e. use
@c wxCMD_LINE_OPTION_MANDATORY to require that the option is given and
@c wxCMD_LINE_PARAM_OPTIONAL to make a parameter optional.
Also, @c wxCMD_LINE_PARAM_MULTIPLE may be specified if the programs accepts a
variable number of parameters - but it only can be given for the last
parameter in the command line description. If you use this flag, you will
probably need to use wxCmdLineEntryDesc::GetParamCount() to retrieve the
number of parameters effectively specified after calling
wxCmdLineEntryDesc::Parse().
@c wxCMD_LINE_NEEDS_SEPARATOR can be specified to require a separator (either
a colon, an equal sign or white space) between the option name and its
value. By default, no separator is required.
@c wxCMD_LINE_SWITCH_NEGATABLE can be specified if you want to allow the
user to specify the switch in both normal form and in negated one (e.g.
/R-). You will need to use wxCmdLineParser::FoundSwitch() to distinguish
between the normal and negated forms of the switch. This flag is new since
wxWidgets 2.9.2.
@c wxCMD_LINE_HIDDEN can be specified for arguments that should exist but
are not to be included in the output of Usage(). These could be, for
example, diagnostics switches that are not useful to the end user.
This flags is new since wxWidgets 3.1.1.
*/
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 a separator 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()
};
/**
The possible values of wxCmdLineEntryDesc::type which specify the type of
the value accepted by an option.
*/
enum wxCmdLineParamType
{
wxCMD_LINE_VAL_STRING,
wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_VAL_DATE,
wxCMD_LINE_VAL_DOUBLE,
wxCMD_LINE_VAL_NONE
};
/**
The type of a command line entity used for wxCmdLineEntryDesc::kind.
*/
enum wxCmdLineEntryType
{
/// A boolean argument of the program; e.g. @c -v to enable verbose mode.
wxCMD_LINE_SWITCH,
/// An argument with an associated value; e.g. @c "-o filename" to specify
/// an optional output filename.
wxCMD_LINE_OPTION,
/// A parameter: a required program argument.
wxCMD_LINE_PARAM,
/// Additional usage text. See wxCmdLineParser::AddUsageText.
wxCMD_LINE_USAGE_TEXT,
wxCMD_LINE_NONE ///< Use this to terminate the list.
};
/**
The state of a switch as returned by wxCmdLineParser::FoundSwitch().
@since 2.9.2
*/
enum wxCmdLineSwitchState
{
/// The switch was found in negated form, i.e. followed by a '-'.
wxCMD_SWITCH_OFF,
/// The switch was not found at all on the command line.
wxCMD_SWITCH_NOT_FOUND
/// The switch was found (and was not negated)
wxCMD_SWITCH_ON
};
/**
Value indicating that wxCmdLineParser::Parse() should determine the wrap
column automatically.
This is the default value for the @c wrapColumn parameter of
wxCmdLineParser::Parse() and means that the text will be wrapped at the
window boundary if it is possible to find it (which may not be the case if
the output is redirected and doesn't appear on a terminal at all, for
example).
@since 3.3.0
*/
constexpr int wxCMD_LINE_WRAP_AUTO = -1;
/**
Value indicating that wxCmdLineParser::Parse() should not wrap the output.
Passing this value as @c wrapColumn parameter of wxCmdLineParser::Parse()
means that the text should not be wrapped at all.
@since 3.3.0
*/
constexpr int wxCMD_LINE_WRAP_NONE = 0;
/**
Flags determining wxCmdLineParser::ConvertStringToArgs() behaviour.
*/
enum wxCmdLineSplitType
{
wxCMD_LINE_SPLIT_DOS,
wxCMD_LINE_SPLIT_UNIX
};
/**
The structure wxCmdLineEntryDesc is used to describe a command line
switch, option or parameter. An array of such structures should be passed
to wxCmdLineParser::SetDesc().
Note that the meanings of parameters of the wxCmdLineParser::AddXXX() functions
are the same as of the corresponding fields in this structure.
*/
struct wxCmdLineEntryDesc
{
/**
The kind of this program argument.
See ::wxCmdLineEntryType for more info.
*/
wxCmdLineEntryType kind;
/**
The usual, short, name of the switch or the option.
It may contain only letters, digits and the underscores.
This field is unused if <tt>kind == wxCMD_LINE_PARAM</tt>.
*/
const char *shortName;
/**
The long name for this program argument (may be empty if the option
has no long name).
It may contain only letters, digits and the underscores.
This field is unused if <tt>kind == wxCMD_LINE_PARAM</tt>.
*/
const char *longName;
/**
This description is used by the wxCmdLineParser::Usage() method to
construct a help message explaining the syntax of the program.
*/
const char *description;
/**
The type associated with this option (ignored if <tt>kind != wxCMD_LINE_OPTION</tt>).
See ::wxCmdLineParamType for more info.
*/
wxCmdLineParamType type;
/**
A combination of one or more ::wxCmdLineEntryFlags enum values.
*/
int flags;
};
/**
The interface wxCmdLineArg provides information for an instance of argument
passed on command line.
Example of use:
@code
wxCmdLineParser parser;
for (wxCmdLineArgs::const_iterator itarg=parser.GetArguments().begin();
itarg!=parser.GetArguments().end();
++itarg)
{
wxString optionName;
switch (itarg->GetKind())
{
case wxCMD_LINE_SWITCH:
if (itarg->IsNegated()) {
}
else {
}
break;
case wxCMD_LINE_OPTION:
// assuming that all the options have a short name
optionName = itarg->GetShortName();
switch (itarg->GetType()) {
case wxCMD_LINE_VAL_NUMBER:
// do something with itarg->GetLongVal();
break;
case wxCMD_LINE_VAL_DOUBLE:
// do something with itarg->GetDoubleVal();
break;
case wxCMD_LINE_VAL_DATE:
// do something with itarg->GetDateVal();
break;
case wxCMD_LINE_VAL_STRING:
// do something with itarg->GetStrVal();
break;
}
break;
case wxCMD_LINE_PARAM:
// do something with itarg->GetStrVal();
break;
}
}
@endcode
The for loop could be written:
@code
for (const auto &arg : parser.GetArguments()) {
// working on arg as with *itarg above
}
@endcode
@since 3.1.0
*/
class wxCmdLineArg
{
public:
virtual ~wxCmdLineArg();
/**
Returns the command line argument value as a wxDateTime.
@note This call works only for @c wxCMD_LINE_VAL_DATE options
*/
virtual const wxDateTime& GetDateVal() const = 0;
/**
Returns the command line argument value as a double.
@note This call works only for @c wxCMD_LINE_VAL_DOUBLE options
*/
virtual double GetDoubleVal() const = 0;
/**
Returns the command line argument entry kind.
@note Parameters can only be retrieved as strings, with GetStrVal()
@see wxCmdLineEntryType, GetType()
*/
virtual wxCmdLineEntryType GetKind() const = 0;
/**
Returns the command line argument value as a long.
@note This call works only for @c wxCMD_LINE_VAL_NUMBER options
*/
virtual long GetLongVal() const = 0;
/**
Returns the command line argument long name if any.
@note This call makes sense only for options and switches
*/
virtual wxString GetLongName() const = 0;
/**
Returns the command line argument short name if any.
@note This call makes sense only for options and switches
*/
virtual wxString GetShortName() const = 0;
/**
Returns the command line argument value as a string.
@note This call works only for @c wxCMD_LINE_VAL_STRING options
and parameters
*/
virtual const wxString& GetStrVal() const = 0;
/**
Returns the command line argument parameter type
@note This call makes sense only for options
(i.e. GetKind() == @c wxCMD_LINE_OPTION).
@see wxCmdLineParamType, GetKind()
*/
virtual wxCmdLineParamType GetType() const = 0;
/**
Returns true if the switch was negated
@note This call works only for switches.
*/
virtual bool IsNegated() const = 0;
};
/**
An ordered collection of wxCmdLineArg providing an iterator to enumerate
the arguments passed on command line.
@see wxCmdLineParser::GetArguments()
@since 3.1.0
*/
class wxCmdLineArgs
{
public:
/**
A bidirectional constant iterator exposing the command line arguments as
wxCmdLineArg references.
*/
class const_iterator;
const_iterator begin() const;
const_iterator end() const;
/**
Returns the number of command line arguments in this collection.
*/
size_t size() const;
};
/**
@class wxCmdLineParser
wxCmdLineParser is a class for parsing the command line.
It has the following features:
- distinguishes options, switches and parameters
- allows option grouping
- allows both short and long options
- automatically generates the usage message from the command line description
- checks types of the options values (number, date, ...).
To use it you should follow these steps:
-# @ref cmdlineparser_construction "Construct" an object of this class
giving it the command line to parse and optionally its description or
use the @c AddXXX() functions later.
-# Call Parse().
-# Use Found() to retrieve the results.
You can also use wxApp's default command line processing just overriding
wxAppConsole::OnInitCmdLine() and wxAppConsole::OnCmdLineParsed().
In the documentation below the following terminology is used:
- @b switch: a boolean option which can be given or not, but which doesn't have
any value. We use the word @e switch to distinguish
such boolean options from more generic options like those
described below. For example, @c "-v" might be a switch
meaning "enable verbose mode".
- @b option: a switch with a value associated to it.
For example, @c "-o filename" might be an
option for specifying the name of the output file.
- @b parameter: a required program argument.
@section cmdlineparser_construction Construction
Before Parse() can be called, the command line parser object must have the
command line to parse and also the rules saying which switches, options and
parameters are valid - this is called command line description in what
follows.
You have complete freedom of choice as to when specify the required
information, the only restriction is that it must be done before calling
Parse().
To specify the command line to parse you may use either one of constructors
accepting it (wxCmdLineParser(int, char**) or
wxCmdLineParser(const wxString&) usually) or, if you use the default
constructor, you can do it later by calling SetCmdLine().
The same holds for command line description: it can be specified either in
the constructor (with or without the command line itself) or constructed
later using either SetDesc() or combination of AddSwitch(), AddOption(),
AddParam() and AddUsageText() methods.
Using constructors or SetDesc() uses a (usually const static) table
containing the command line description. If you want to decide which
options to accept during the run-time, using one of the AddXXX() functions
above might be preferable.
@section cmdlineparser_customization Customization
wxCmdLineParser has several global options which may be changed by the
application. All of the functions described in this section should be
called before Parse().
First global option is the support for long (also known as GNU-style)
options. The long options are the ones which start with two dashes and look
like "\--verbose", i.e. they generally are complete words and not some
abbreviations of them. As long options are used by more and more
applications, they are enabled by default, but may be disabled with
DisableLongOptions().
Another global option is the set of characters which may be used to start
an option (otherwise, the word on the command line is assumed to be a
parameter). Under Unix, @c "-" is always used, but Windows has at least two
common choices for this: @c "-" and @c "/". Some programs also use "+". The
default is to use what suits most the current platform, but may be changed
with SetSwitchChars() method.
Finally, SetLogo() can be used to show some application-specific text
before the explanation given by Usage() function and SetUsageSynopsis() can
be used to replace the default, automatically generated, brief program
usage explanation string shown by it.
@section cmdlineparser_parsing Parsing the Command Line
After the command line description was constructed and the desired options
were set, you can finally call Parse() method. It returns 0 if the command
line was correct and was parsed, -1 if the help option was specified (this
is a separate case as, normally, the program will terminate after this) or
a positive number if there was an error during the command line parsing.
In the latter case, the appropriate error message and usage information are
logged by wxCmdLineParser itself using the standard wxWidgets logging
functions.
@section cmdlineparser_results Getting Results
After calling Parse() (and if it returned 0), you may access the results of
parsing using one of overloaded Found() methods.
For a simple switch, you will simply call Found to determine if the switch
was given or not, for an option or a parameter, you will call a version of
Found() which also returns the associated value in the provided variable.
All Found() functions return true if the switch or option were found in the
command line or false if they were not specified.
@library{wxbase}
@category{appmanagement}
@see wxApp::argc, wxApp::argv, @ref page_samples_console
*/
class wxCmdLineParser
{
public:
/**
Default constructor, you must use SetCmdLine() later.
*/
wxCmdLineParser();
/**
Constructor which specifies the command line to parse.
This is the traditional (Unix) command line format and the parameters
@a argc and @a argv have the same meaning as the typical @c main()
function.
*/
wxCmdLineParser(int argc, char** argv);
/**
Constructor which specifies the command line to parse.
The parameters @a argc and @a argv have the same meaning as the typical
@c main() function, but the latter uses wide character strings.
*/
wxCmdLineParser(int argc, wchar_t** argv);
/**
Constructor which specify the command line to parse in Windows format.
The parameter cmdline has the same meaning as the corresponding
parameter of @c WinMain().
*/
wxCmdLineParser(const wxString& cmdline);
/**
Specifies the @ref SetDesc() "command line description" but not the
command line. You must use SetCmdLine() later.
*/
wxCmdLineParser(const wxCmdLineEntryDesc* desc);
/**
Specifies both the command line (in Unix format) and the
@ref SetDesc() "command line description".
*/
wxCmdLineParser(const wxCmdLineEntryDesc* desc, int argc, char** argv);
/**
Specifies both the command line (in Windows format) and the
@ref SetDesc() "command line description".
*/
wxCmdLineParser(const wxCmdLineEntryDesc* desc,
const wxString& cmdline);
/**
Frees resources allocated by the object.
@note This destructor is not virtual, don't use this class
polymorphically.
*/
~wxCmdLineParser();
/**
Adds an option with only long form.
This is just a convenient wrapper for AddOption() passing an empty
string as short option name.
@since 2.9.3
*/
void AddLongOption(const wxString& lng,
const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0);
/**
Adds a switch with only long form.
This is just a convenient wrapper for AddSwitch() passing an empty
string as short switch name.
@since 2.9.3
*/
void AddLongSwitch(const wxString& lng,
const wxString& desc = wxEmptyString,
int flags = 0);
/**
Add an option @a name with an optional long name @a lng (no long name
if it is empty, which is default) taking a value of the given type
(string by default) to the command line description.
*/
void AddOption(const wxString& name,
const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0);
/**
Add a parameter of the given @a type to the command line description.
*/
void AddParam(const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0);
/**
Add a switch @a name with an optional long name @a lng (no long name if
it is empty, which is default), description @a desc and flags @a flags
to the command line description.
*/
void AddSwitch(const wxString& name,
const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString,
int flags = 0);
/**
Add a string @a text to the command line description shown by Usage().
@since 2.9.0
*/
void AddUsageText(const wxString& text);
/**
Returns @true if long options are enabled, otherwise @false.
@see EnableLongOptions()
*/
bool AreLongOptionsEnabled() const;
/**
Breaks down the string containing the full command line in words.
Words are separated by whitespace and double quotes can be used to
preserve the spaces inside the words.
By default, this function uses Windows-like word splitting algorithm,
i.e. single quotes have no special meaning and backslash can't be used
to escape spaces either. With @c wxCMD_LINE_SPLIT_UNIX flag Unix
semantics is used, i.e. both single and double quotes can be used and
backslash can be used to escape all the other special characters.
*/
static wxArrayString
ConvertStringToArgs(const wxString& cmdline,
wxCmdLineSplitType flags = wxCMD_LINE_SPLIT_DOS);
/**
Identical to EnableLongOptions(@false).
*/
void DisableLongOptions();
/**
Enable or disable support for the long options.
As long options are not (yet) POSIX-compliant, this option allows
disabling them.
@see @ref cmdlineparser_customization and AreLongOptionsEnabled()
*/
void EnableLongOptions(bool enable = true);
/**
Returns @true if the given switch was found, @false otherwise.
*/
bool Found(const wxString& name) const;
/**
Returns whether the switch was found on the command line and whether it
was negated.
This method can be used for any kind of switch but is especially useful
for switches that can be negated, i.e. were added with
wxCMD_LINE_SWITCH_NEGATABLE flag, as otherwise Found() is simpler to
use.
However Found() doesn't allow to distinguish between switch specified
normally, i.e. without dash following it, and negated switch, i.e. with
the following dash. This method will return @c wxCMD_SWITCH_ON or @c
wxCMD_SWITCH_OFF depending on whether the switch was negated or not.
And if the switch was not found at all, @c wxCMD_SWITCH_NOT_FOUND is
returned.
@since 2.9.2
*/
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 (which should not be @NULL).
*/
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 (which should not be @NULL).
*/
bool Found(const wxString& name, long* value) const;
/**
Returns @true if an option taking a float value was found and stores
the value in the provided pointer (which should not be @NULL).
*/
bool Found(const wxString& name, double* value) const;
/**
Returns @true if an option taking a date value was found and stores the
value in the provided pointer (which should not be @NULL).
*/
bool Found(const wxString& name, wxDateTime* value) const;
/**
Returns the value of Nth parameter (as string only).
*/
wxString GetParam(size_t n = 0) const;
/**
Returns the number of parameters found. This function makes sense
mostly if you had used @c wxCMD_LINE_PARAM_MULTIPLE flag.
*/
size_t GetParamCount() const;
/**
Returns the collection of arguments
@note The returned object just refers to the command line parser. The
command line parser must live longer than it.
@see wxCmdLineArgs
@since 3.1.0
*/
wxCmdLineArgs GetArguments() const;
/**
Parse the command line, return 0 if ok, -1 if @c "-h" or @c "\--help"
option was encountered and the help message was given or a positive
value if a syntax error occurred.
@param giveUsage
If @true (default), the usage message is given if a syntax error
was encountered while parsing the command line or if help was
requested. If @false, only error messages about possible syntax
errors are given, use Usage to show the usage message from the
caller if needed.
@param wrapColumn
When @a giveUsage is @true, this parameter specifies the column at
which the help text should be wrapped if given. When left as its
default value of wxCMD_LINE_WRAP_AUTO, the text will be wrapped at
the window boundary, if it was possible to detect it, or not at all
otherwise. If the value of this parameter is wxCMD_LINE_WRAP_NONE,
the text is never wrapped. Any other value specifies the column at
which to wrap, e.g. 80. This parameter is new since wxWidgets 3.3.0.
*/
int Parse(bool giveUsage = true, int wrapColumn = wxCMD_LINE_WRAP_AUTO);
///@{
/**
Set the command line to parse after using one of the constructors which
don't do it.
*/
void SetCmdLine(int argc, char** argv);
void SetCmdLine(int argc, wchar_t** argv);
void SetCmdLine(const wxString& cmdline);
///@}
/**
Constructs the command line description.
Take the command line description from the wxCMD_LINE_NONE terminated
table.
Example of usage:
@code
static const wxCmdLineEntryDesc cmdLineDesc[] =
{
{ wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },
{ wxCMD_LINE_SWITCH, "q", "quiet", "be quiet" },
{ wxCMD_LINE_OPTION, "o", "output", "output file" },
{ wxCMD_LINE_OPTION, "i", "input", "input dir" },
{ wxCMD_LINE_OPTION, "s", "size", "output block size", wxCMD_LINE_VAL_NUMBER },
{ wxCMD_LINE_OPTION, "d", "date", "output file date", wxCMD_LINE_VAL_DATE },
{ wxCMD_LINE_PARAM, nullptr, nullptr, "input file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE },
{ wxCMD_LINE_NONE }
};
wxCmdLineParser parser;
parser.SetDesc(cmdLineDesc);
@endcode
*/
void SetDesc(const wxCmdLineEntryDesc* desc);
/**
The @a logo is some extra text which will be shown by Usage() method.
@see SetUsageSynopsis()
*/
void SetLogo(const wxString& logo);
/**
Set the usage synopsis string.
This string will be shown before the options list in the usage message
generated by Usage() instead of the automatically generated synopsis
showing the application executable followed by all the options.
It can be useful to call this function with a simplified synopsis if
the application has too many command line options for the
auto-generated one to be really useful.
@since 3.3.0
*/
void SetUsageSynopsis(const wxString& synopsis);
/**
@a switchChars contains all characters with which an option or switch
may start. Default is @c "-" for Unix, @c "-/" for Windows.
*/
void SetSwitchChars(const wxString& switchChars);
/**
Give the standard usage message describing all program options. It will
use the options and parameters descriptions specified earlier, so the
resulting message will not be helpful to the user unless the
descriptions were indeed specified.
@param wrapColumn
See Parse() for the description of this parameter. This parameter
is new since wxWidgets 3.3.0.
@see SetLogo(), SetUsageSynopsis()
*/
void Usage(int wrapColumn = wxCMD_LINE_WRAP_AUTO) const;
/**
Return the string containing the program usage description.
Call Usage() to directly show this string to the user.
@param wrapColumn
See Parse() for the description of this parameter. This parameter
is new since wxWidgets 3.3.0.
*/
wxString GetUsageString(int wrapColumn = wxCMD_LINE_WRAP_AUTO) const;
};

View File

@@ -0,0 +1,259 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cmdproc.h
// Purpose: interface of wxCommandProcessor and wxCommand
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxCommand
wxCommand is a base class for modelling an application command, which is an
action usually performed by selecting a menu item, pressing a toolbar
button or any other means provided by the application to change the data or
view.
@library{wxcore}
@category{docview}
@see @ref overview_docview_wxcommand
*/
class wxCommand : public wxObject
{
public:
/**
Constructor. wxCommand is an abstract class, so you will need to derive
a new class and call this constructor from your own constructor.
@param canUndo
Tells the command processor whether this command is undo-able. You
can achieve the same functionality by overriding the CanUndo()
member function (if for example the criteria for undoability is
context-dependent).
@param name
Must be supplied for the command processor to display the command
name in the application's edit menu.
*/
wxCommand(bool canUndo = false, const wxString& name = wxEmptyString);
/**
Destructor.
*/
virtual ~wxCommand();
/**
Returns @true if the command can be undone, @false otherwise.
*/
virtual bool CanUndo() const;
/**
Override this member function to execute the appropriate action when
called.
@return @true to indicate that the action has taken place, @false
otherwise. Returning @false will indicate to the command
processor that the action is not undoable and should not be
added to the command history.
*/
virtual bool Do() = 0;
/**
Returns the command name.
*/
virtual wxString GetName() const;
/**
Override this member function to un-execute a previous Do.
How you implement this command is totally application dependent, but
typical strategies include:
- Perform an inverse operation on the last modified piece of data in
the document. When redone, a copy of data stored in command is pasted
back or some operation reapplied. This relies on the fact that you
know the ordering of Undos; the user can never Undo at an arbitrary
position in the command history.
- Restore the entire document state (perhaps using document
transacting). Potentially very inefficient, but possibly easier to
code if the user interface and data are complex, and an "inverse
execute" operation is hard to write. The docview sample uses the
first method, to remove or restore segments in the drawing.
@return @true to indicate that the action has taken place, @false
otherwise. Returning @false will indicate to the command
processor that the action is not redoable and no change should
be made to the command history.
*/
virtual bool Undo() = 0;
};
/**
@class wxCommandProcessor
wxCommandProcessor is a class that maintains a history of wxCommands, with
undo/redo functionality built-in. Derive a new class from this if you want
different behaviour.
@library{wxcore}
@category{docview}
@see @ref overview_docview_wxcommandproc, wxCommand
*/
class wxCommandProcessor : public wxObject
{
public:
/**
Constructor.
@param maxCommands
May be set to a positive integer to limit the number of commands
stored to it, otherwise (and by default) the list of commands can
grow arbitrarily.
*/
wxCommandProcessor(int maxCommands = -1);
/**
Destructor.
*/
virtual ~wxCommandProcessor();
/**
Returns @true if the currently-active command can be undone, @false
otherwise.
*/
virtual bool CanUndo() const;
/**
Returns @true if the currently-active command can be redone, @false
otherwise.
*/
virtual bool CanRedo() const;
/**
Deletes all commands in the list and sets the current command pointer
to @NULL.
*/
virtual void ClearCommands();
/**
Returns the list of commands.
*/
wxList& GetCommands();
/**
Returns the current command.
*/
wxCommand *GetCurrentCommand() const;
/**
Returns the edit menu associated with the command processor.
*/
wxMenu* GetEditMenu() const;
/**
Returns the maximum number of commands that the command processor
stores.
*/
int GetMaxCommands() const;
/**
Returns the string that will be appended to the Redo menu item.
*/
const wxString& GetRedoAccelerator() const;
/**
Returns the string that will be shown for the redo menu item.
*/
wxString GetRedoMenuLabel() const;
/**
Returns the string that will be appended to the Undo menu item.
*/
const wxString& GetUndoAccelerator() const;
/**
Returns the string that will be shown for the undo menu item.
*/
wxString GetUndoMenuLabel() const;
/**
Initializes the command processor, setting the current command to the
last in the list (if any), and updating the edit menu (if one has been
specified).
*/
virtual void Initialize();
/**
Returns a boolean value that indicates if changes have been made since
the last save operation. This only works if MarkAsSaved() is called
whenever the project is saved.
*/
virtual bool IsDirty() const;
/**
You must call this method whenever the project is saved if you plan to
use IsDirty().
*/
void MarkAsSaved();
/**
Executes (redoes) the current command (the command that has just been
undone if any).
*/
virtual bool Redo();
/**
Tells the command processor to update the Undo and Redo items on this
menu as appropriate. Set this to @NULL if the menu is about to be
destroyed and command operations may still be performed, or the command
processor may try to access an invalid pointer.
*/
void SetEditMenu(wxMenu* menu);
/**
Sets the menu labels according to the currently set menu and the
current command state.
*/
virtual void SetMenuStrings();
/**
Sets the string that will be appended to the Redo menu item.
*/
void SetRedoAccelerator(const wxString& accel);
/**
Sets the string that will be appended to the Undo menu item.
*/
void SetUndoAccelerator(const wxString& accel);
/**
Submits a new command to the command processor.
The command processor calls wxCommand::Do() to execute the command;
if it succeeds, the command is stored in the history list, and the
associated edit menu (if any) updated appropriately.
If it fails, the command is deleted immediately. Once Submit() has been
called, the passed command should not be deleted directly by the application.
@param command
The command to submit
@param storeIt
Indicates whether the successful command should be stored in the
history list.
*/
virtual bool Submit(wxCommand* command, bool storeIt = true);
/**
Just store the command without executing it. The command is stored in the
history list, and the associated edit menu (if any) updated appropriately.
*/
virtual void Store(wxCommand *command);
/**
Undoes the last command executed.
*/
virtual bool Undo();
};

View File

@@ -0,0 +1,799 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cmndata.h
// Purpose: interface of print wx*Data classes
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxPrintPageRange
This class represents a range of pages to be printed.
@library{wxcore}
@category{printing,data}
@see wxPrintDialogData
@since 3.3.0
*/
class wxPrintPageRange
{
public:
/// Default constructor creates an uninitialized range.
wxPrintPageRange() = default;
/**
Constructor creating a range from @a from to @a to (inclusive).
Parameters must be valid, i.e. @a from must be strictly positive and @a
to must be greater or equal to @a from.
*/
wxPrintPageRange(int from, int to);
/// Return @true if both components are initialized correctly.
bool IsValid() const;
/// Return the number of pages in this range if it is valid.
int GetNumberOfPages() const;
int fromPage = 0;
int toPage = 0;
};
/**
Synonym for a vector of page ranges.
@since 3.3.0
*/
using wxPrintPageRanges = std::vector<wxPrintPageRange>;
/**
@class wxPageSetupDialogData
This class holds a variety of information related to wxPageSetupDialog.
It contains a wxPrintData member which is used to hold basic printer
configuration data (as opposed to the user-interface configuration settings
stored by wxPageSetupDialogData).
@library{wxcore}
@category{printing,data}
@see @ref overview_printing, wxPageSetupDialog
*/
class wxPageSetupDialogData : public wxObject
{
public:
/**
Default constructor.
*/
wxPageSetupDialogData();
/**
Copy constructor.
*/
wxPageSetupDialogData(const wxPageSetupDialogData& data);
/**
Construct an object from a print data object.
*/
wxPageSetupDialogData(const wxPrintData& printData);
/**
Destructor.
*/
virtual ~wxPageSetupDialogData();
/**
Enables or disables the "Help" button (Windows only).
*/
void EnableHelp(bool flag);
/**
Enables or disables the margin controls (Windows only).
*/
void EnableMargins(bool flag);
/**
Enables or disables the orientation control (Windows only).
*/
void EnableOrientation(bool flag);
/**
Enables or disables the paper size control (Windows only).
*/
void EnablePaper(bool flag);
/**
Enables or disables the "Printer" button, which invokes a printer setup
dialog.
*/
void EnablePrinter(bool flag);
/**
Returns @true if the dialog will simply return default printer
information (such as orientation) instead of showing a dialog (Windows
only).
*/
bool GetDefaultInfo() const;
/**
Returns @true if the page setup dialog will take its minimum margin
values from the currently selected printer properties (Windows only).
*/
bool GetDefaultMinMargins() const;
/**
Returns @true if the printer setup button is enabled.
*/
bool GetEnableHelp() const;
/**
Returns @true if the margin controls are enabled (Windows only).
*/
bool GetEnableMargins() const;
/**
Returns @true if the orientation control is enabled (Windows only).
*/
bool GetEnableOrientation() const;
/**
Returns @true if the paper size control is enabled (Windows only).
*/
bool GetEnablePaper() const;
/**
Returns @true if the printer setup button is enabled.
*/
bool GetEnablePrinter() const;
/**
Returns the right (x) and bottom (y) margins in millimetres.
*/
wxPoint GetMarginBottomRight() const;
/**
Returns the left (x) and top (y) margins in millimetres.
*/
wxPoint GetMarginTopLeft() const;
/**
Returns the right (x) and bottom (y) minimum margins the user can enter
(Windows only). Units are in millimetres.
*/
wxPoint GetMinMarginBottomRight() const;
/**
Returns the left (x) and top (y) minimum margins the user can enter
(Windows only). Units are in millimetres.
*/
wxPoint GetMinMarginTopLeft() const;
/**
Returns the paper id (stored in the internal wxPrintData object).
@see wxPrintData::SetPaperId()
*/
wxPaperSize GetPaperId() const;
/**
Returns the paper size in millimetres.
*/
wxSize GetPaperSize() const;
/**
Returns a reference to the print data associated with this object.
*/
wxPrintData& GetPrintData();
const wxPrintData& GetPrintData() const;
/**
Returns @true if the print data associated with the dialog data is
valid. This can return @false on Windows if the current printer is not
set, for example. On all other platforms, it returns @true.
*/
bool IsOk() const;
/**
Pass @true if the dialog will simply return default printer information
(such as orientation) instead of showing a dialog (Windows only).
*/
void SetDefaultInfo(bool flag);
/**
Pass @true if the page setup dialog will take its minimum margin values
from the currently selected printer properties (Windows only). Units
are in millimetres.
*/
void SetDefaultMinMargins(bool flag);
/**
Sets the right (x) and bottom (y) margins in millimetres.
*/
void SetMarginBottomRight(const wxPoint& pt);
/**
Sets the left (x) and top (y) margins in millimetres.
*/
void SetMarginTopLeft(const wxPoint& pt);
/**
Sets the right (x) and bottom (y) minimum margins the user can enter
(Windows only). Units are in millimetres.
*/
void SetMinMarginBottomRight(const wxPoint& pt);
/**
Sets the left (x) and top (y) minimum margins the user can enter
(Windows only). Units are in millimetres.
*/
void SetMinMarginTopLeft(const wxPoint& pt);
/**
Sets the paper size id. Calling this function overrides the explicit
paper dimensions passed in SetPaperSize().
@see wxPrintData::SetPaperId()
*/
void SetPaperId(wxPaperSize id);
/**
Sets the paper size in millimetres. If a corresponding paper id is
found, it will be set in the internal wxPrintData object, otherwise the
paper size overrides the paper id.
*/
void SetPaperSize(const wxSize& size);
/**
Sets the print data associated with this object.
*/
void SetPrintData(const wxPrintData& printData);
/**
Assigns print data to this object.
*/
wxPageSetupDialogData& operator =(const wxPrintData& data);
/**
Assigns page setup data to this object.
*/
wxPageSetupDialogData& operator =(const wxPageSetupDialogData& data);
};
/**
Enumeration of various printer bin sources.
@see wxPrintData::SetBin()
*/
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,
};
/**
@class wxPrintData
This class holds a variety of information related to printers and printer
device contexts. This class is used to create a wxPrinterDC and a
wxPostScriptDC. It is also used as a data member of wxPrintDialogData and
wxPageSetupDialogData, as part of the mechanism for transferring data
between the print dialogs and the application.
@library{wxcore}
@category{printing,data}
@see @ref overview_printing, wxPrintDialog, wxPageSetupDialog,
wxPrintDialogData, wxPageSetupDialogData, @ref overview_cmndlg_print,
wxPrinterDC, wxPostScriptDC
*/
class wxPrintData : public wxObject
{
public:
/**
Default constructor.
*/
wxPrintData();
/**
Copy constructor.
*/
wxPrintData(const wxPrintData& data);
/**
Destructor.
*/
virtual ~wxPrintData();
/**
Returns the current bin (papersource). By default, the system is left
to select the bin (@c wxPRINTBIN_DEFAULT is returned).
See SetBin() for the full list of bin values.
*/
wxPrintBin GetBin() const;
/**
Returns @true if collation is on.
*/
bool GetCollate() const;
/**
Returns @true if colour printing is on.
*/
bool GetColour() const;
/**
Returns the duplex mode. One of wxDUPLEX_SIMPLEX, wxDUPLEX_HORIZONTAL,
wxDUPLEX_VERTICAL.
*/
wxDuplexMode GetDuplex() const;
/**
Returns the number of copies requested by the user.
*/
int GetNoCopies() const;
/**
Gets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
*/
wxPrintOrientation GetOrientation() const;
/**
Returns the paper size id.
@see SetPaperId()
*/
wxPaperSize GetPaperId() const;
/**
Returns the printer name. If the printer name is the empty string, it
indicates that the default printer should be used.
*/
const wxString& GetPrinterName() const;
/**
Returns the current print quality. This can be a positive integer,
denoting the number of dots per inch, or one of the following
identifiers:
- wxPRINT_QUALITY_HIGH
- wxPRINT_QUALITY_MEDIUM
- wxPRINT_QUALITY_LOW
- wxPRINT_QUALITY_DRAFT
On input you should pass one of these identifiers, but on return you
may get back a positive integer indicating the current resolution
setting.
*/
wxPrintQuality GetQuality() const;
/**
Returns @true if the print data is valid for using in print dialogs.
This can return @false on Windows if the current printer is not set,
for example. On all other platforms, it returns @true.
*/
bool IsOk() const;
/**
Sets the current bin.
*/
void SetBin(wxPrintBin flag);
/**
Sets collation to on or off.
*/
void SetCollate(bool flag);
/**
Sets colour printing on or off.
*/
void SetColour(bool flag);
/**
Returns the duplex mode. One of wxDUPLEX_SIMPLEX, wxDUPLEX_HORIZONTAL,
wxDUPLEX_VERTICAL.
*/
void SetDuplex(wxDuplexMode mode);
/**
Sets the default number of copies to be printed out.
*/
void SetNoCopies(int n);
/**
Sets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
*/
void SetOrientation(wxPrintOrientation orientation);
/**
Sets the paper id. This indicates the type of paper to be used. For a
mapping between paper id, paper size and string name, see
wxPrintPaperDatabase in @c "paper.h" (not yet documented).
@see SetPaperSize()
*/
void SetPaperId(wxPaperSize paperId);
/**
Sets custom paper size.
This method can be used to set up custom paper size. When using a
standard size, prefer to use SetPaperId() instead.
*/
void SetPaperSize(const wxSize& size);
/**
Sets the printer name. This can be the empty string to indicate that
the default printer should be used.
*/
void SetPrinterName(const wxString& printerName);
/**
Sets the desired print quality. This can be a positive integer,
denoting the number of dots per inch, or one of the following
identifiers:
- wxPRINT_QUALITY_HIGH
- wxPRINT_QUALITY_MEDIUM
- wxPRINT_QUALITY_LOW
- wxPRINT_QUALITY_DRAFT
On input you should pass one of these identifiers, but on return you
may get back a positive integer indicating the current resolution
setting.
*/
void SetQuality(wxPrintQuality quality);
/**
Assigns print data to this object.
*/
wxPrintData& operator =(const wxPrintData& data);
wxString GetFilename() const;
void SetFilename( const wxString &filename );
wxPrintMode GetPrintMode() const ;
void SetPrintMode(wxPrintMode printMode) ;
};
/**
@class wxPrintDialogData
This class holds information related to the visual characteristics of
wxPrintDialog. It contains a wxPrintData object with underlying printing
settings.
@library{wxcore}
@category{printing,cmndlg,data}
@see @ref overview_printing, wxPrintDialog, @ref overview_cmndlg_print
*/
class wxPrintDialogData : public wxObject
{
public:
/**
Default constructor.
*/
wxPrintDialogData();
/**
Copy constructor.
*/
wxPrintDialogData(const wxPrintDialogData& dialogData);
/**
Construct an object from a print dialog data object.
*/
wxPrintDialogData(const wxPrintData& printData);
/**
Destructor.
*/
virtual ~wxPrintDialogData();
/**
Enables or disables the "Help" button.
*/
void EnableHelp(bool flag);
/**
Enables or disables the "Page numbers" controls.
*/
void EnablePageNumbers(bool flag);
/**
Enables or disables the "Print to file" checkbox.
*/
void EnablePrintToFile(bool flag);
/**
Enables or disables the "Selection" radio button.
*/
void EnableSelection(bool flag);
/**
Allows or disallows selecting printing the "Current Page" in the
dialog.
This currently only has an effect under MSW, where the native dialog
enables the "Current Page" radio button if this function is called to
allow the user to print the current page only.
@since 3.3.0
*/
void EnableCurrentPage(bool flag);
/**
Returns @true if the user requested that all pages be printed.
*/
bool GetAllPages() const;
/**
Returns @true if the user requested that the document(s) be collated.
*/
bool GetCollate() const;
/**
Returns the @e from page number, as entered by the user.
This function can't be used if multiple page ranges were specified, use
GetPageRanges() instead.
*/
int GetFromPage() const;
/**
Returns the @e maximum page number.
*/
int GetMaxPage() const;
/**
Returns the @e minimum page number.
*/
int GetMinPage() const;
/**
Returns the number of copies requested by the user.
*/
int GetNoCopies() const;
/**
Returns a reference to the internal wxPrintData object.
*/
wxPrintData& GetPrintData();
/**
Returns @true if the user has selected printing to a file.
*/
bool GetPrintToFile() const;
/**
Returns @true if the user requested that the selection be printed
(where "selection" is a concept specific to the application).
*/
bool GetSelection() const;
/**
Returns @true if the user requested that the current page be printed.
Note that the "current page" is defined by the application.
It only makes sense to call this function if EnableCurrentPage() had been
called before, otherwise it always returns @false.
@since 3.3.0
*/
bool GetCurrentPage() const;
/**
Returns @true if the user requested printing only the specified pages.
The pages to print can be retrieved using GetPageRanges().
@since 3.3.0
*/
bool GetSpecifiedPages() const;
/**
Returns the @e "print to" page number, as entered by the user.
This function can't be used if multiple page ranges were specified, use
GetPageRanges() instead.
*/
int GetToPage() const;
/**
Returns @true if the print data is valid for using in print dialogs.
This can return @false on Windows if the current printer is not set,
for example. On all other platforms, it returns @true.
*/
bool IsOk() const;
/**
Selects the "All pages" radio button.
When called with @true value, enables printing all pages. This is the
default behaviour.
If @a flag is @false, this function doesn't do anything unless it had
been called with @true value before and in this case it switches to
printing the selected pages only (see GetSpecifiedPages()).
*/
void SetAllPages(bool flag = true);
/**
Sets the "Collate" checkbox to @true or @false.
*/
void SetCollate(bool flag);
/**
Sets the @e from page number.
Together with SetToPage(), this function can be used to define a single
range of pages to print. If you need to specify multiple ranges, use
SetPageRanges() instead.
@note If SetPageRanges() was used to specify multiple ranges, this
function cannot be used as there is no single "from" page to set.
*/
void SetFromPage(int page);
/**
Sets the @e maximum page number.
*/
void SetMaxPage(int page);
/**
Sets the @e minimum page number.
*/
void SetMinPage(int page);
/**
Sets the default number of copies the user has requested to be printed
out.
*/
void SetNoCopies(int n);
/**
Sets the internal wxPrintData.
*/
void SetPrintData(const wxPrintData& printData);
/**
Sets the "Print to file" checkbox to @true or @false.
*/
void SetPrintToFile(bool flag);
/**
Selects the "Selection" radio button.
The effect of printing the selection depends on how the application
implements this command, if at all.
This function should only be called when EnableSelection() is used as
well.
If @a flag is @false, this function doesn't do anything unless it had
been called with @true value before and in this case it switches to
printing the selected pages only (see GetSpecifiedPages()).
*/
void SetSelection(bool flag = true);
/**
Selects the "Current Page" radio button when the dialog is initially
shown.
This function can only be called when EnableCurrentPage() is used as
well.
If @a flag is @false, this function doesn't do anything unless it had
been called with @true value before and in this case it switches to
printing the selected pages only (see GetSpecifiedPages()).
@see GetCurrentPage()
@since 3.3.0
*/
void SetCurrentPage(bool flag = true);
/**
@deprecated This function has been deprecated since version 2.5.4.
Determines whether the dialog to be shown will be the Print dialog
(pass @false) or Print Setup dialog (pass @true).
*/
void SetSetupDialog(bool flag);
/**
Sets the @e "print to" page number.
Together with SetFromPage(), this function can be used to define a
single range of pages to print. If you need to specify multiple ranges,
use SetPageRanges() instead.
@note If SetPageRanges() was used to specify multiple ranges, this
function cannot be used as there is no single "to" page to set.
*/
void SetToPage(int page);
/**
Assigns print data to this object.
*/
void operator =(const wxPrintData& data);
/**
Assigns another print dialog data object to this object.
*/
void operator =(const wxPrintDialogData& data);
/**
Sets the maximum number of page ranges that the user can specify.
This value is used as a limit for the number of page ranges that can be
used in the print dialog. The default value is 64.
Currently this is only used in wxMSW.
@since 3.3.0
*/
void SetMaxPageRanges(int maxRanges);
/**
Returns the maximum number of page ranges that the user can specify.
@see SetMaxRanges()
@since 3.3.0
*/
int GetMaxPageRanges() const;
/**
Returns the page ranges to print.
This vector contains the page ranges to be printed. If it is empty, all
pages are printed, otherwise only the pages in the specified ranges are.
@see SetPageRanges()
@since 3.3.0
*/
const std::vector<wxPrintPageRange>& GetPageRanges() const;
/**
Sets the ranges of pages to print.
Each element of the vector represents a range of pages to print. All
ranges should be disjoint and be specified in increasing order.
Currently only wxMSW supports the full functionality of this function,
all other ports only allow specifying a single range.
Passing an empty vector is equivalent to printing all pages.
@since 3.3.0
*/
void SetPageRanges(const std::vector<wxPrintPageRange>& pageRanges);
};

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
// Name: interface/collheaderctrl.h
// Purpose: wxCollapsibleHeaderCtrl documentation
// Author: Tobias Taschner
// Created: 2015-09-19
// Copyright: (c) 2015 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxCollapsibleHeaderCtrl
Header control above a collapsible pane.
The collapsible header usually consists of a small indicator of the
collapsed state and the label text beside it.
This class is used by the generic implementation of wxCollapsiblePane but
maybe used in more complex layouts for other uses.
@beginEventTable{wxCommandEvent}
@event{EVT_COLLAPSIBLEHEADER_CHANGED(id, func)}
User changed the collapsed state.
@endEventTable
@since 3.1.0
@library{wxcore}
@category{ctrl}
@see wxCollapsiblePane
*/
class wxCollapsibleHeaderCtrl : public wxControl
{
public:
wxCollapsibleHeaderCtrl();
/**
Constructor fully creating the control.
The arguments have the usual meanings and only @a parent is typically
required.
*/
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 = wxCollapsibleHeaderCtrlNameStr);
/**
Create the control initialized using the default constructor.
This method can be used to finish the control creation if it hadn't
been done already by using the non-default constructor.
*/
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 = wxCollapsibleHeaderCtrlNameStr);
/**
Set collapsed state of the header.
*/
virtual void SetCollapsed(bool collapsed = true);
/**
Returns @c true if the control is collapsed.
@see SetCollapsed()
*/
virtual bool IsCollapsed() const;
};

View File

@@ -0,0 +1,185 @@
/////////////////////////////////////////////////////////////////////////////
// Name: collpane.h
// Purpose: interface of wxCollapsiblePane
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
#define wxCP_NO_TLW_RESIZE (0x0002)
/**
@class wxCollapsiblePaneEvent
This event class is used for the events generated by wxCollapsiblePane.
@beginEventTable{wxCollapsiblePaneEvent}
@event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
The user expanded or collapsed the collapsible pane.
@endEventTable
@library{wxcore}
@category{events}
@see wxCollapsiblePane
*/
class wxCollapsiblePaneEvent : public wxCommandEvent
{
public:
/**
The constructor is not normally used by the user code.
*/
wxCollapsiblePaneEvent(wxObject* generator, int id, bool collapsed);
/**
Returns @true if the pane has been collapsed.
*/
bool GetCollapsed() const;
/**
Sets this as a collapsed pane event (if @a collapsed is @true) or as an
expanded pane event (if @a collapsed is @false).
*/
void SetCollapsed(bool collapsed);
};
wxEventType wxEVT_COLLAPSIBLEPANE_CHANGED;
/**
@class wxCollapsiblePane
A collapsible pane is a container with an embedded button-like control
which can be used by the user to collapse or expand the pane's contents.
Once constructed, you should use the GetPane() function to access the pane
and add your controls inside it (i.e., use the returned pointer from
GetPane() as the parent for the controls which must go in the pane, @b not the
wxCollapsiblePane itself!).
Note that when using this control inside a sizer, you will usually want to
call wxWindow::Layout() whenever its size changes due to the pane being
opened or closed, in order to adjust the positions of the neighbouring
controls, for example:
@code
wxCollapsiblePane *collpane = new wxCollapsiblePane(this, wxID_ANY, "Details:");
// add the pane with a zero proportion value to the 'sz' sizer which contains it
sz->Add(collpane,
wxSizerFlags().Expand().Border();
// but also ensure that we relayout the entire window when its state
// changes to give it enough space when it expands or reduce the space
// taken by it when it collapses
collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED,
[this](wxCollapsiblePaneEvent &) { Layout(); });
// now add a test label in the collapsible pane using a sizer to layout it:
wxWindow *win = collpane->GetPane();
wxSizer *paneSz = new wxBoxSizer(wxVERTICAL);
paneSz->Add(new wxStaticText(win, wxID_ANY, "test!"), wxSizerFlags().Proportion(1).Expand().DoubleBorder());
win->SetSizer(paneSz);
paneSz->SetSizeHints(win);
@endcode
It is only available if @c wxUSE_COLLPANE is set to 1 (the default).
@beginStyleTable
@style{wxCP_DEFAULT_STYLE}
The default style. It includes wxTAB_TRAVERSAL and wxBORDER_NONE.
@style{wxCP_NO_TLW_RESIZE}
By default wxCollapsiblePane resizes the top level window containing it
when its own size changes. This allows easily implementing dialogs
containing an optionally shown part, for example, and so is the default
behaviour but can be inconvenient in some specific cases -- use this
flag to disable this automatic parent resizing then.
@endStyleTable
@beginEventEmissionTable{wxCollapsiblePaneEvent,wxNavigationKeyEvent}
@event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
The user expanded or collapsed the collapsible pane.
@event{EVT_NAVIGATION_KEY(func)}
Process a navigation key event.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{collapsiblepane}
@see wxPanel, wxCollapsiblePaneEvent
*/
class wxCollapsiblePane : public wxControl
{
public:
/**
Default constructor.
*/
wxCollapsiblePane();
/**
Initializes the object and calls Create() with all the parameters.
*/
wxCollapsiblePane(wxWindow* parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCollapsiblePaneNameStr);
/**
@param parent
Parent window, must be non-null.
@param id
The identifier for the control.
@param label
The initial label shown in the button which allows the user to
expand or collapse the pane window.
@param pos
Initial position.
@param size
Initial size.
@param style
The window style, see wxCP_* flags.
@param validator
Validator which can be used for additional data checks.
@param name
Control name.
@return @true if the control was successfully created or @false if
creation failed.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCollapsiblePaneNameStr);
/**
Collapses or expands the pane window.
*/
virtual void Collapse(bool collapse = true);
/**
Same as calling Collapse(@false).
*/
void Expand();
/**
Returns a pointer to the pane window. Add controls to the returned
wxWindow to make them collapsible.
*/
virtual wxWindow* GetPane() const;
/**
Returns @true if the pane window is currently hidden.
*/
virtual bool IsCollapsed() const;
/**
Returns @true if the pane window is currently shown.
*/
bool IsExpanded() const;
};

View File

@@ -0,0 +1,167 @@
/////////////////////////////////////////////////////////////////////////////
// Name: colordlg.h
// Purpose: interface of wxColourDialog
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxColourDialog
This class represents the colour chooser dialog.
Starting from wxWidgets 3.1.3 and currently in the MSW port only, this
dialog generates wxEVT_COLOUR_CHANGED events while it is being shown, i.e.
from inside its ShowModal() method, that notify the program about the
change of the currently selected colour and allow it to e.g. preview the
effect of selecting this colour. Note that if you react to this event, you
should also correctly revert to the previously selected colour if the
dialog is cancelled by the user.
Example of using this class with dynamic feedback for the selected colour:
@code
// Some function for redrawing using the given colour. Ideally, it
// shouldn't do anything if the colour is the same as the one used
// before.
void Redraw(const wxColour& colour);
wxColourData data;
data.SetColour(initialColourToUse);
wxColourDialog dlg(this, &data);
dlg.Bind(wxEVT_COLOUR_CHANGED, [](wxColourDialogEvent& event) {
Redraw(event.GetColour());
});
if ( dlg.ShowModal() == wxID_OK ) {
// Colour did change.
} else {
// Colour didn't change.
}
// This call is unnecessary under platforms generating
// wxEVT_COLOUR_CHANGED if the dialog was accepted and unnecessary
// under the platforms not generating this event if it was cancelled,
// so we could check for the different cases explicitly to avoid it,
// but it's simpler to just always call it.
Redraw(data.GetColour());
@endcode
@library{wxcore}
@category{cmndlg}
@see @ref overview_cmndlg_colour, wxColour, wxColourData,
wxColourDialogEvent, wxGetColourFromUser()
*/
class wxColourDialog : public wxDialog
{
public:
/**
Constructor. Pass a parent window, and optionally a pointer to a block
of colour data, which will be copied to the colour dialog's colour
data.
Custom colours from colour data object will be used in the dialog's
colour palette. Invalid entries in custom colours list will be ignored
on some platforms(GTK) or replaced with white colour on platforms where
custom colours palette has fixed size (MSW).
@see wxColourData
*/
wxColourDialog(wxWindow* parent, const wxColourData* data = nullptr);
/**
Destructor.
*/
virtual ~wxColourDialog();
/**
Same as wxColourDialog().
*/
bool Create(wxWindow* parent, const wxColourData* data = nullptr);
/**
Returns the colour data associated with the colour dialog.
*/
wxColourData& GetColourData();
/**
Shows the dialog, returning wxID_OK if the user pressed OK, and
wxID_CANCEL otherwise.
*/
virtual int ShowModal();
};
/**
This event class is used for the events generated by wxColourDialog.
@beginEventTable{wxColourPickerEvent}
@event{EVT_COLOUR_CHANGED(id, func)}
Generated whenever the currently selected colour in the dialog
changes. This event is currently only implemented in wxMSW.
@endEventTable
@library{wxcore}
@category{events}
@see wxColourDialog
@since 3.1.3
*/
class wxColourDialogEvent : public wxCommandEvent
{
public:
wxColourDialogEvent();
/**
The constructor is not normally used by the user code.
*/
wxColourDialogEvent(wxEventType evtType,
wxColourDialog* dialog,
const wxColour& colour);
/**
Retrieve the colour the user has just selected.
*/
wxColour GetColour() const;
/**
Set the colour to be sent with the event.
*/
void SetColour(const wxColour& colour);
};
wxEventType wxEVT_COLOUR_CHANGED;
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_dialog */
///@{
/**
Shows the colour selection dialog and returns the colour selected by user
or invalid colour (use wxColour::IsOk() to test whether a colour is valid)
if the dialog was cancelled.
@param parent
The parent window for the colour selection dialog.
@param colInit
If given, this will be the colour initially selected in the dialog.
@param caption
If given, this will be used for the dialog caption.
@param data
Optional object storing additional colour dialog settings, such as
custom colours. If none is provided the same settings as the last time
are used.
@header{wx/colordlg.h}
*/
wxColour wxGetColourFromUser(wxWindow* parent = nullptr,
const wxColour& colInit = wxNullColour,
const wxString& caption = wxEmptyString,
wxColourData* data = nullptr);
///@}

View File

@@ -0,0 +1,424 @@
/////////////////////////////////////////////////////////////////////////////
// Name: colour.h
// Purpose: interface of wxColour
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
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;
/**
@class wxColour
A colour is an object representing a combination of Red, Green, and Blue
(RGB) intensity values and an Alpha value, and is used to determine
drawing colours. See the entry for wxColourDatabase for how a pointer to a predefined,
named colour may be returned instead of creating a new colour.
Valid RGB values are in the range 0 to 255.
You can retrieve the current system colour settings with wxSystemSettings.
@section colour_accessors Channel Accessor Functions
Note that this class provides pairs of functions for each of the colour
channels, i.e. red, green, blue and alpha values. The one word functions
Red(), Green(), Blue() and Alpha() return the values of type @c unsigned @c
char, while GetRed(), GetGreen(), GetBlue() and GetAlpha() returns the same
value as @c unsigned @c int. According to the C++ integer promotion rules,
the result of any arithmetic expression involving the former will be
(signed) @c int, while that of the latter will be @c unsigned, which is
what would be commonly expected, so the latter family of functions should
be typically preferred (but they are only available since wxWidgets 3.1.6).
@library{wxcore}
@category{gdi}
@stdobjects
- ::wxNullColour - An empty, invalid colour.
- ::wxTransparentColour - Valid but fully transparent colour (new in 2.9.1).
- ::wxBLACK
- ::wxBLUE
- ::wxCYAN
- ::wxGREEN
- ::wxYELLOW
- ::wxLIGHT_GREY
- ::wxRED
- ::wxWHITE
@see wxColourDatabase, wxPen, wxBrush, wxColourDialog, wxSystemSettings
*/
class wxColour : public wxObject
{
public:
/**
Default constructor.
*/
wxColour();
/**
@param red
The red value.
@param green
The green value.
@param blue
The blue value.
@param alpha
The alpha value. Alpha values range from 0 (wxALPHA_TRANSPARENT) to
255 (wxALPHA_OPAQUE).
*/
wxColour(unsigned char red, unsigned char green, unsigned char blue,
unsigned char alpha = wxALPHA_OPAQUE);
/**
@param colourName
The colour name.
*/
wxColour(const wxString& colourName);
/**
@param colRGB
A packed RGB value.
*/
wxColour(unsigned long colRGB);
/**
Copy constructor.
*/
wxColour(const wxColour& colour);
/**
Returns the alpha value, on platforms where alpha is not yet supported, this
always returns wxALPHA_OPAQUE.
@see GetAlpha()
*/
virtual unsigned char Alpha() const;
/**
Returns the blue intensity.
@see GetBlue()
*/
virtual unsigned char Blue() const;
/**
Returns the alpha value, on platforms where alpha is not yet supported, this
always returns wxALPHA_OPAQUE.
@since 3.1.6
*/
unsigned int GetAlpha() const;
/**
Returns the blue intensity as unsigned int.
@since 3.1.6
*/
unsigned int GetBlue() const;
/**
Returns the green intensity as unsigned int.
@since 3.1.6
*/
unsigned int GetGreen() const;
/**
Returns the red intensity as unsigned int.
@since 3.1.6
*/
unsigned int GetRed() const;
/**
Converts this colour to a wxString using the given flags.
The supported flags are @c wxC2S_NAME, to obtain the colour name
(e.g. wxColour(255,0,0) == "red"), @c wxC2S_CSS_SYNTAX, to obtain
the colour in the "rgb(r,g,b)" or "rgba(r,g,b,a)" syntax
(e.g. wxColour(255,0,0,85) == "rgba(255,0,0,0.333)"), and
@c wxC2S_HTML_SYNTAX, to obtain the colour as "#" followed by 6
hexadecimal digits (e.g. wxColour(255,0,0) == "#FF0000").
This function returns empty string if the colour is not initialized
(see IsOk()). Otherwise, the returned string is always non-empty, but
the function asserts if the colour has alpha channel (i.e. is non
opaque) but @c wxC2S_CSS_SYNTAX (which is the only one supporting
alpha) is not specified in @a flags.
@note For non-solid (i.e. non-RGB) colour this function returns
"rgb(??, ?? ??)" or "#??????".
@since 2.7.0
*/
virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const;
///@{
/**
Sets the RGB or RGBA colour values from a single 32 bit value.
The arguments @a colRGB and @a colRGBA should be of the form 0x00BBGGRR
and 0xAABBGGRR respectively where @c 0xRR, @c 0xGG, @c 0xBB and @c 0xAA
are the values of the red, green, blue and alpha components.
Notice the right-to-left order of components!
@see GetRGB(), GetRGBA()
@since 2.9.1
*/
void SetRGB(wxUint32 colRGB);
void SetRGBA(wxUint32 colRGBA);
///@}
///@{
/**
Gets the RGB or RGBA colour values as a single 32 bit value.
The returned value is of the same form as expected by SetRGB() and
SetRGBA().
Notice that GetRGB() returns the value with 0 as its highest byte
independently of the value actually returned by Alpha(). So for a fully
opaque colour, the return value of GetRGBA() is @c 0xFFBBGGRR while
that of GetRGB() is @c 0x00BBGGRR.
@since 2.9.1
*/
wxUint32 GetRGB() const;
wxUint32 GetRGBA() const;
///@}
/**
Return the perceived brightness of the colour.
This value is computed using the simple @code 0.299*R + 0.587*G + 0.114*B @endcode
formula with the coefficients taken from the RGB to
YIQ conversion formula and @c R, @c G and @c B being the values of the
corresponding colour channels normalized to 0..1 range, so that the
return value is 0 for black and 1 for white.
@since 3.1.3
*/
double GetLuminance() const;
/**
Returns a pixel value which is platform-dependent.
On Windows, a COLORREF is returned.
On X, an allocated pixel value is returned.
If the pixel is invalid (on X, unallocated), @c -1 is returned.
*/
wxIntPtr GetPixel() const;
/**
Returns the green intensity.
@see GetGreen()
*/
virtual unsigned char Green() const;
/**
Returns @true if the colour object is valid (the colour has been initialised
with RGB values).
*/
virtual bool IsOk() const;
/**
Returns the red intensity.
@see GetRed()
*/
virtual unsigned char Red() const;
/**
Returns @true if the color can be described using RGB values, i.e. is solid,
@false if it is a pattern (currently only possible on macOS)
@since 3.1.2
*/
virtual bool IsSolid() const;
/**
Returns @true if the color is completely transparent (i.e., no opacity).
@since 3.3.1
*/
bool IsTransparent() const;
/**
Returns @true if the color is completely opaque (i.e., full opacity).
@since 3.3.1
*/
bool IsOpaque() const;
/**
Returns @true if the color has some translucency
(not fully opaque, but not transparent either).
@since 3.3.1
*/
bool IsTranslucent() const;
///@{
/**
Sets the RGB intensity values using the given values (first overload),
extracting them from the packed long (second overload), using the given
string (third overload).
When using third form, Set() accepts: colour names (those listed in
wxColourDatabase), the CSS-like @c "rgb(r,g,b)" or @c "rgba(r,g,b,a)" syntax
(case insensitive) and the HTML-like syntax: @c "#" followed by 6 hexadecimal
digits for red, green, blue components.
Returns @true if the conversion was successful, @false otherwise.
@since 2.7.0
*/
void Set(unsigned char red, unsigned char green,
unsigned char blue,
unsigned char alpha = wxALPHA_OPAQUE);
void Set(unsigned long RGB);
bool Set(const wxString& str);
///@}
/**
Tests the inequality of two colours by comparing individual red, green, blue
intensities and alpha values.
*/
bool operator !=(const wxColour& colour) const;
/**
Assignment operator.
@see wxColourDatabase
*/
wxColour& operator=(const wxColour& colour);
/**
Tests the equality of two colours by comparing individual red, green, blue
intensities and alpha values.
*/
bool operator ==(const wxColour& colour) const;
/**
Assigns the same value to @a r, @a g, @a b: 0 if @a on is @c false, 255 otherwise.
@since 2.9.0
*/
static void MakeMono(unsigned char* r, unsigned char* g, unsigned char* b, bool on);
/**
Create a disabled (dimmed) colour from (in/out) rgb parameters.
@since 2.9.0
*/
static void MakeDisabled(unsigned char* r, unsigned char* g, unsigned char* b, unsigned char brightness = 255);
/**
Make a disabled version of this colour.
This method modifies the object in place and returns the object itself.
@since 2.9.5
*/
wxColour& MakeDisabled(unsigned char brightness = 255);
/**
Create a grey colour from (in/out) rgb parameters using integer arithmetic.
@since 2.9.0
*/
static void MakeGrey(unsigned char* r, unsigned char* g, unsigned char* b);
/**
Create a grey colour from (in/out) rgb parameters using floating point arithmetic.
Defaults to using the standard ITU-T BT.601 when converting to YUV, where every pixel equals
(R * @a weight_r) + (G * @a weight_g) + (B * @a weight_b).
@since 2.9.0
*/
static void MakeGrey(unsigned char* r, unsigned char* g, unsigned char* b,
double weight_r, double weight_g, double weight_b);
/**
Blend colour, taking alpha into account.
@since 2.9.0
*/
static unsigned char AlphaBlend(unsigned char fg, unsigned char bg, double alpha);
/**
Utility function that simply darkens or lightens a color, based on the specified
percentage @a ialpha. @a ialpha of 0 would be make the color completely black,
200 completely white and 100 would not change the color.
@since 2.9.0
*/
static void ChangeLightness(unsigned char* r, unsigned char* g, unsigned char* b, int ialpha);
/**
wxColour wrapper for ChangeLightness(r,g,b,ialpha).
@since 2.9.0
*/
wxColour ChangeLightness(int ialpha) const;
};
/** @name Predefined colors. */
///@{
wxColour wxNullColour;
wxColour wxTransparentColour;
wxColour* wxBLACK;
wxColour* wxBLUE;
wxColour* wxCYAN;
wxColour* wxGREEN;
wxColour* wxYELLOW;
wxColour* wxLIGHT_GREY;
wxColour* wxRED;
wxColour* wxWHITE;
///@}
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_misc */
///@{
/**
Converts string to a wxColour best represented by the given string. Returns
@true on success.
@see wxToString(const wxColour&)
@header{wx/colour.h}
*/
bool wxFromString(const wxString& string, wxColour* colour);
/**
Converts the given wxColour into a string.
@see wxFromString(const wxString&, wxColour*)
@header{wx/colour.h}
*/
wxString wxToString(const wxColour& colour);
///@}

View File

@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////
// Name: colourdata.h
// Purpose: interface of wxColourData
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxColourData
This class holds a variety of information related to colour dialogs.
@library{wxcore}
@category{cmndlg,data}
@see wxColour, wxColourDialog, @ref overview_cmndlg_colour
*/
class wxColourData : public wxObject
{
public:
/// number of custom colours we store
enum
{
NUM_CUSTOM = 16
};
/**
Constructor. Initializes the custom colours to @c wxNullColour, the
@e data colour setting to black, and the @e choose full setting to
@true.
*/
wxColourData();
/**
Destructor.
*/
virtual ~wxColourData();
/**
Under Windows, determines whether the Windows colour dialog will
display the full dialog with custom colour selection controls.
Has no meaning under other platforms.
The default value is @true.
*/
bool GetChooseFull() const;
/**
Indicates whether the colour dialog will display alpha values
and an opacity selector. It is meaningful under wxGTK, wxOSX
and with regards to generic colour dialog.
The default value is @false, except wxOSX where it is @true (for
the sake of backward compatibility).
*/
bool GetChooseAlpha() const;
/**
Gets the current colour associated with the colour dialog.
The default colour is black.
*/
wxColour& GetColour();
/**
Returns custom colours associated with the colour dialog.
@param i
An integer between 0 and 15, being any of the 15 custom colours
that the user has saved. The default custom colours are invalid
colours.
*/
wxColour GetCustomColour(int i) const;
/**
Under Windows, tells the Windows colour dialog to display the full
dialog with custom colour selection controls. Under other platforms,
has no effect.
The default value is @true.
*/
void SetChooseFull(bool flag);
/**
Tells the colour dialog to show alpha values and an opacity selector
(slider). Currently it has effect under wxGTK, wxOSX and for generic
colour dialog.
The default value is @false, except wxOSX where it is @true for
backward compatibility.
*/
void SetChooseAlpha(bool flag);
/**
Sets the default colour for the colour dialog.
The default colour is black.
*/
void SetColour(const wxColour& colour);
/**
Sets custom colours for the colour dialog.
@param i
An integer between 0 and 15 for whatever custom colour you want to
set. The default custom colours are invalid colours.
@param colour
The colour to set
*/
void SetCustomColour(int i, const wxColour& colour);
/**
Converts the colours saved in this class in a string form, separating
the various colours with a comma.
*/
wxString ToString() const;
/**
Decodes the given string, which should be in the same format returned
by ToString(), and sets the internal colours.
*/
bool FromString(const wxString& str);
/**
Assignment operator for the colour data.
*/
wxColourData& operator =(const wxColourData& data);
};

View File

@@ -0,0 +1,986 @@
/////////////////////////////////////////////////////////////////////////////
// Name: combo.h
// Purpose: interface of wxComboCtrl and wxComboPopup
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//
// 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
};
/**
@class wxComboPopup
In order to use a custom popup with wxComboCtrl, an interface class must be
derived from wxComboPopup.
For more information on how to use it, see @ref comboctrl_custompopup.
@library{wxcore}
@category{ctrl}
@see wxComboCtrl
*/
class wxComboPopup
{
public:
/**
Default constructor. It is recommended that internal variables are
prepared in Init() instead (because m_combo is not valid in
constructor).
*/
wxComboPopup();
/**
The derived class must implement this to create the popup control.
@return @true if the call succeeded, @false otherwise.
*/
virtual bool Create(wxWindow* parent) = 0;
/**
You only need to implement this member function if you create
your popup class in non-standard way. The default implementation can
handle both multiple-inherited popup control (as seen in wxComboCtrl
samples) and one allocated separately in heap.
If you do completely re-implement this function, make sure it calls
Destroy() for the popup control and also deletes @a this object
(usually as the last thing).
*/
virtual void DestroyPopup();
/**
Utility function that hides the popup.
*/
void Dismiss();
/**
Implement to customize matching of value string to an item container
entry.
@param item
String entered, usually by user or from SetValue() call.
@param trueItem
When item matches an entry, but the entry's string representation
is not exactly the same (case mismatch, for example), then the
true item string should be written back to here, if it is not
@NULL.
@remarks
Default implementation always return true and does not alter
trueItem.
*/
virtual bool FindItem(const wxString& item, wxString* trueItem = nullptr);
/**
The derived class may implement this to return adjusted size for the
popup control, according to the variables given.
@param minWidth
Preferred minimum width.
@param prefHeight
Preferred height. May be -1 to indicate no preference.
@param maxHeight
Max height for window, as limited by screen size.
@remarks This function is called each time popup is about to be shown.
*/
virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
/**
Returns pointer to the associated parent wxComboCtrl.
*/
wxComboCtrl* GetComboCtrl() const;
/**
The derived class must implement this to return pointer to the
associated control created in Create().
*/
virtual wxWindow* GetControl() = 0;
/**
The derived class must implement this to return string representation
of the value.
*/
virtual wxString GetStringValue() const = 0;
/**
The derived class must implement this to initialize its internal
variables. This method is called immediately after construction
finishes. m_combo member variable has been initialized before the call.
*/
virtual void Init();
/**
Utility method that returns @true if Create has been called.
Useful in conjunction with LazyCreate().
*/
bool IsCreated() const;
/**
The derived class may implement this to return @true if it wants to
delay call to Create() until the popup is shown for the first time. It
is more efficient, but on the other hand it is often more convenient to
have the control created immediately.
@remarks Base implementation returns @false.
*/
virtual bool LazyCreate();
/**
The derived class may implement this to do something when the parent
wxComboCtrl gets double-clicked.
*/
virtual void OnComboDoubleClick();
/**
The derived class may implement this to receive key events from the
parent wxComboCtrl.
Events not handled should be skipped, as usual.
*/
virtual void OnComboKeyEvent(wxKeyEvent& event);
/**
The derived class may implement this to do special processing when
popup is hidden.
*/
virtual void OnDismiss();
/**
The derived class may implement this to do special processing when
popup is shown.
*/
virtual void OnPopup();
/**
The derived class may implement this to paint the parent wxComboCtrl.
Default implementation draws value as string.
*/
virtual void PaintComboControl(wxDC& dc, const wxRect& rect);
/**
The derived class must implement this to receive string value changes
from wxComboCtrl.
*/
virtual void SetStringValue(const wxString& value);
protected:
/**
Parent wxComboCtrl. This member variable is prepared automatically
before Init() is called.
*/
wxComboCtrl* m_combo;
};
/**
Features enabled for wxComboCtrl.
@see wxComboCtrl::GetFeatures()
*/
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, ///< wxComboCtrl::SetMargins() can be used.
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.
All = MovableButton | BitmapButton | ButtonSpacing |
TextIndent | PaintControl | PaintWritable |
Borderless ///< All features.
};
};
/**
@class wxComboCtrl
A combo control is a generic combobox that allows totally custom popup. In
addition it has other customization features. For instance, position and
size of the dropdown button can be changed.
@section comboctrl_custompopup Setting Custom Popup for wxComboCtrl
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
SetStringValue("initial text value") and wxControl doesn't have such
method. So we also need a wxComboPopup which is an 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 a wxWidgets control and from it,
so instead it is just a mix-in.
Here's a minimal sample of wxListView popup:
@code
#include <wx/combo.h>
#include <wx/listctrl.h>
class wxListViewComboPopup : public wxListView, public wxComboPopup
{
public:
// Initialize member variables
virtual void Init()
{
m_value = -1;
}
// Create popup control
virtual bool Create(wxWindow* parent)
{
return wxListView::Create(parent,1,wxPoint(0,0),wxDefaultSize);
}
// Return pointer to the created control
virtual wxWindow *GetControl() { return this; }
// Translate string into a list selection
virtual void SetStringValue(const wxString& s)
{
int n = wxListView::FindItem(-1,s);
if ( n >= 0 && n < wxListView::GetItemCount() )
wxListView::Select(n);
}
// Get list selection as a string
virtual wxString GetStringValue() const
{
if ( m_value >= 0 )
return wxListView::GetItemText(m_value);
return wxEmptyString;
}
// Do mouse hot-tracking (which is typical in list popups)
void OnMouseMove(wxMouseEvent& event)
{
// TODO: Move selection to cursor
}
// On mouse left up, set the value and close the popup
void OnMouseClick(wxMouseEvent& WXUNUSED(event))
{
m_value = wxListView::GetFirstSelected();
// TODO: Send event as well
Dismiss();
}
protected:
int m_value; // current item index
private:
wxDECLARE_EVENT_TABLE();
};
wxBEGIN_EVENT_TABLE(wxListViewComboPopup, wxListView)
EVT_MOTION(wxListViewComboPopup::OnMouseMove)
EVT_LEFT_UP(wxListViewComboPopup::OnMouseClick)
wxEND_EVENT_TABLE()
@endcode
Here's how you would create and populate it in a dialog constructor:
@code
wxComboCtrl* comboCtrl = new wxComboCtrl(this, wxID_ANY, wxEmptyString);
wxListViewComboPopup* popupCtrl = new wxListViewComboPopup();
// It is important to call SetPopupControl() as soon as possible
comboCtrl->SetPopupControl(popupCtrl);
// Populate using wxListView methods
popupCtrl->InsertItem(popupCtrl->GetItemCount(), "First Item");
popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Second Item");
popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Third Item");
@endcode
@beginStyleTable
@style{wxCB_READONLY}
Text will not be editable.
@style{wxCB_SORT}
Sorts the entries in the list alphabetically.
@style{wxTE_PROCESS_ENTER}
The control will generate the event @c wxEVT_TEXT_ENTER
(otherwise pressing Enter key is either processed internally by the
control or used for navigation between dialog controls). Windows
only.
@style{wxCC_SPECIAL_DCLICK}
Double-clicking triggers a call to popup's OnComboDoubleClick.
Actual behaviour is defined by a derived class. For instance,
wxOwnerDrawnComboBox will cycle an item. This style only applies if
wxCB_READONLY is used as well.
@style{wxCC_STD_BUTTON}
Drop button will behave more like a standard push button.
@endStyleTable
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_TEXT(id, func)}
Process a @c wxEVT_TEXT event, when the text changes.
@event{EVT_TEXT_ENTER(id, func)}
Process a @c wxEVT_TEXT_ENTER event, when RETURN is pressed in
the combo control.
@event{EVT_COMBOBOX_DROPDOWN(id, func)}
Process a @c wxEVT_COMBOBOX_DROPDOWN event, which is generated
when the popup window is shown (drops down).
@event{EVT_COMBOBOX_CLOSEUP(id, func)}
Process a @c wxEVT_COMBOBOX_CLOSEUP event, which is generated
when the popup window of the combo control disappears (closes up).
You should avoid adding or deleting items in this event.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{comboctrl}
@see wxComboBox, wxChoice, wxOwnerDrawnComboBox, wxComboPopup,
wxCommandEvent
*/
class wxComboCtrl : public wxControl,
public wxTextEntry
{
public:
/**
Default constructor.
*/
wxComboCtrl();
/**
Constructor, creating and showing a combo control.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param value
Initial selection string. An empty string indicates no selection.
@param pos
Window position.
If ::wxDefaultPosition is specified then a default position is chosen.
@param size
Window size.
If ::wxDefaultSize is specified then the window is sized appropriately.
@param style
Window style. See wxComboCtrl.
@param validator
Window validator.
@param name
Window name.
@see Create(), wxValidator
*/
wxComboCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
/**
Destructor, destroying the combo control.
*/
virtual ~wxComboCtrl();
/**
Copies the selected text to the clipboard.
*/
virtual void Copy();
/**
Creates the combo control for two-step construction. Derived classes
should call or replace this function. See wxComboCtrl() for further
details.
*/
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
/**
Copies the selected text to the clipboard and removes the selection.
*/
virtual void Cut();
/**
Dismisses the popup window.
Notice that calling this function will generate a
@c wxEVT_COMBOBOX_CLOSEUP event.
@since 2.9.2
*/
virtual void Dismiss();
/**
Enables or disables popup animation, if any, depending on the value of
the argument.
*/
void EnablePopupAnimation(bool enable = true);
/**
Returns true if given key combination should toggle the popup.
*/
virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const;
/**
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;
/**
Returns disabled button bitmap that has been set with
SetButtonBitmaps().
@return The disabled state bitmap.
*/
wxBitmap GetBitmapDisabled() const;
/**
Returns button mouse hover bitmap that has been set with
SetButtonBitmaps().
@return The mouse hover state bitmap.
*/
wxBitmap GetBitmapHover() const;
/**
Returns default button bitmap that has been set with
SetButtonBitmaps().
@return The normal state bitmap.
*/
wxBitmap GetBitmapNormal() const;
/**
Returns depressed button bitmap that has been set with
SetButtonBitmaps().
@return The depressed state bitmap.
*/
wxBitmap GetBitmapPressed() const;
/**
Returns current size of the dropdown button.
*/
wxSize GetButtonSize();
/**
Returns custom painted area in control.
@see SetCustomPaintWidth().
*/
int GetCustomPaintWidth() const;
/**
Returns features supported by wxComboCtrl. If needed feature is
missing, you need to instead use wxGenericComboCtrl, which however may
lack a native look and feel (but otherwise sports identical API).
@return Value returned is a combination of the flags defined in
wxComboCtrlFeatures.
*/
static int GetFeatures();
/**
Returns the current hint string.
See SetHint() for more information about hints.
@since 2.9.1
*/
virtual wxString GetHint() const;
/**
Returns the insertion point for the combo control's text field.
@note Under Windows, this function always returns 0 if the combo
control doesn't have the focus.
*/
virtual long GetInsertionPoint() const;
/**
Returns the last position in the combo control text field.
*/
virtual long GetLastPosition() const;
/**
Returns the margins used by the control. The @c x field of the returned
point is the horizontal margin and the @c y field is the vertical one.
@remarks If given margin cannot be accurately determined, its value
will be set to -1.
@see SetMargins()
@since 2.9.1
*/
wxPoint GetMargins() const;
/**
Returns current popup interface that has been set with
SetPopupControl().
*/
wxComboPopup* GetPopupControl();
/**
Returns popup window containing the popup control.
*/
wxWindow* GetPopupWindow() const;
/**
Get the text control which is part of the combo control.
*/
wxTextCtrl* GetTextCtrl() const;
/**
Returns actual indentation in pixels.
@deprecated Use GetMargins() instead.
*/
wxCoord GetTextIndent() const;
/**
Returns area covered by the text field (includes everything except
borders and the dropdown button).
*/
const wxRect& GetTextRect() const;
/**
Returns text representation of the current value. For writable combo
control it always returns the value in the text field.
*/
virtual wxString GetValue() const;
/**
Dismisses the popup window.
@param generateEvent
Set this to @true in order to generate
@c wxEVT_COMBOBOX_CLOSEUP event.
@deprecated Use Dismiss() instead.
*/
virtual void HidePopup(bool generateEvent=false);
/**
Returns @true if the popup is currently shown
*/
bool IsPopupShown() const;
/**
Returns @true if the popup window is in the given state. Possible
values are:
@beginTable
@row2col{wxComboCtrl::Hidden, Popup window is hidden.}
@row2col{wxComboCtrl::Animating, Popup window is being shown, but the
popup animation has not yet finished.}
@row2col{wxComboCtrl::Visible, Popup window is fully visible.}
@endTable
*/
bool IsPopupWindowState(int state) const;
/**
Implement in a derived class to define what happens on dropdown button
click. Default action is to show the popup.
@note If you implement this to do something else than show the popup,
you must then also implement DoSetPopupControl() to always return
@NULL.
*/
virtual void OnButtonClick();
/**
Pastes text from the clipboard to the text field.
*/
virtual void Paste();
/**
Shows the popup portion of the combo control.
Notice that calling this function will generate a
@c wxEVT_COMBOBOX_DROPDOWN event.
@since 2.9.2
*/
virtual void Popup();
/**
Removes the text between the two positions in the combo control text
field.
@param from
The first position.
@param to
The last position.
*/
virtual void Remove(long from, long to);
/**
Replaces the text between two positions with the given text, in the
combo control text field.
@param from
The first position.
@param to
The second position.
@param text
The text to insert.
*/
virtual void Replace(long from, long to, const wxString& text);
/**
Sets custom dropdown button graphics.
@param bmpNormal
Default button image.
@param pushButtonBg
If @true, blank push button background is painted below the image.
@param bmpPressed
Depressed button image.
@param bmpHover
Button image when mouse hovers above it. This should be ignored on
platforms and themes that do not generally draw different kind of
button on mouse hover.
@param bmpDisabled
Disabled button image.
*/
void SetButtonBitmaps(const wxBitmapBundle& bmpNormal,
bool pushButtonBg = false,
const wxBitmapBundle& bmpPressed = wxBitmapBundle(),
const wxBitmapBundle& bmpHover = wxBitmapBundle(),
const wxBitmapBundle& bmpDisabled = wxBitmapBundle());
/**
Sets size and position of dropdown button.
@param width
Button width. Value = 0 specifies default.
@param height
Button height. Value = 0 specifies default.
@param side
Indicates which side the button will be placed. Value can be wxLEFT
or wxRIGHT.
@param spacingX
Horizontal spacing around the button. Default is 0.
*/
void SetButtonPosition(int width = -1, int height = -1,
int side = wxRIGHT, int spacingX = 0);
/**
Set width, in pixels, of custom painted area in control without
@c wxCB_READONLY style. In read-only wxOwnerDrawnComboBox, this is used
to indicate area that is not covered by the focus rectangle.
*/
void SetCustomPaintWidth(int width);
/**
Sets a hint shown in an empty unfocused combo control.
Notice that hints are known as <em>cue banners</em> under MSW or
<em>placeholder strings</em> under macOS.
@see wxTextEntry::SetHint()
@since 2.9.1
*/
virtual bool SetHint(const wxString& hint);
/**
Sets the insertion point in the text field.
@param pos
The new insertion point.
*/
virtual void SetInsertionPoint(long pos);
/**
Sets the insertion point at the end of the combo control text field.
*/
virtual void SetInsertionPointEnd();
/**
Uses the given window instead of the default text control as the main
window of the combo control.
By default, combo controls without @c wxCB_READONLY style create a
wxTextCtrl which shows the current value and allows to edit it. This
method allows to use some other window instead of this wxTextCtrl.
This method can be called after creating the combo fully, however in
this case a wxTextCtrl is unnecessarily created just to be immediately
destroyed when it's replaced by a custom window. If you wish to avoid
this, you can use the following approach, also shown in the combo
sample:
@code
// Create the combo control using its default ctor.
wxComboCtrl* combo = new wxComboCtrl();
// Create the custom main control using its default ctor too.
SomeWindow* main = new SomeWindow();
// Set the custom main control before creating the combo.
combo->SetMainControl(main);
// And only create it now: wxTextCtrl won't be unnecessarily
// created because the combo already has a main window.
combo->Create(panel, wxID_ANY, wxEmptyString);
// Finally create the main window itself, now that its parent was
// created.
main->Create(combo, ...);
@endcode
Note that when a custom main window is used, none of the methods of
this class inherited from wxTextEntry, such as SetValue(), Replace(),
SetInsertionPoint() etc do anything and simply return.
@since 3.1.6
*/
void SetMainControl(wxWindow* win);
///@{
/**
Attempts to set the control margins. When margins are given as wxPoint,
x indicates the left and y the top margin. Use -1 to indicate that
an existing value should be used.
@return
@true if setting of all requested margins was successful.
@since 2.9.1
*/
bool SetMargins(const wxPoint& pt);
bool SetMargins(wxCoord left, wxCoord top = -1);
///@}
/**
Set side of the control to which the popup will align itself. Valid
values are @c wxLEFT, @c wxRIGHT and 0. The default value 0 means that
the most appropriate side is used (which, currently, is always
@c wxLEFT).
*/
void SetPopupAnchor(int anchorSide);
/**
Set popup interface class derived from wxComboPopup. This method should
be called as soon as possible after the control has been created,
unless OnButtonClick() has been overridden.
*/
void SetPopupControl(wxComboPopup* popup);
/**
Extends popup size horizontally, relative to the edges of the combo
control.
@param extLeft
How many pixel to extend beyond the left edge of the control.
Default is 0.
@param extRight
How many pixel to extend beyond the right edge of the control.
Default is 0.
@remarks Popup minimum width may override arguments. It is up to the
popup to fully take this into account.
*/
void SetPopupExtents(int extLeft, int extRight);
/**
Sets preferred maximum height of the popup.
@remarks Value -1 indicates the default.
*/
void SetPopupMaxHeight(int height);
/**
Sets minimum width of the popup. If wider than combo control, it will
extend to the left.
@remarks Value -1 indicates the default. Also, popup implementation may
choose to ignore this.
*/
void SetPopupMinWidth(int width);
/**
Selects the text between the two positions, in the combo control text
field.
@param from
The first position.
@param to
The second position.
*/
virtual void SetSelection(long from, long to);
/**
Sets the text for the text field without affecting the popup. Thus,
unlike SetValue(), it works equally well with combo control using
@c wxCB_READONLY style.
*/
void SetText(const wxString& value);
/**
Set a custom window style for the embedded wxTextCtrl. Usually you
will need to use this during two-step creation, just before Create().
For example:
@code
wxComboCtrl* comboCtrl = new wxComboCtrl();
// Let's make the text right-aligned
comboCtrl->SetTextCtrlStyle(wxTE_RIGHT);
comboCtrl->Create(parent, wxID_ANY, wxEmptyString);
@endcode
*/
void SetTextCtrlStyle( int style );
/**
This will set the space in pixels between left edge of the control and
the text, regardless whether control is read-only or not. Value -1 can
be given to indicate platform default.
@deprecated Use SetMargins() instead.
*/
void SetTextIndent(int indent);
/**
Sets the text for the combo control text field.
@note For a combo control with @c wxCB_READONLY style the string must
be accepted by the popup (for instance, exist in the dropdown
list), otherwise the call to SetValue() is ignored.
*/
virtual void SetValue(const wxString& value);
/**
Changes value of the control as if user had done it by selecting an
item from a combo box drop-down list.
*/
void SetValueByUser(const wxString& value);
/**
Show the popup.
@deprecated Use Popup() instead.
*/
virtual void ShowPopup();
/**
Undoes the last edit in the text field. Windows only.
*/
virtual void Undo();
/**
Enable or disable usage of an alternative popup window, which
guarantees ability to focus the popup control, and allows common native
controls to function normally. This alternative popup window is usually
a wxDialog, and as such, when it is shown, its parent top-level window
will appear as if the focus has been lost from it.
*/
void UseAltPopupWindow(bool enable = true);
protected:
/**
This member function is not normally called in application code.
Instead, it can be implemented in a derived class to create a custom
popup animation.
The parameters are the same as those for DoShowPopup().
@return @true if animation finishes before the function returns,
@false otherwise. In the latter case you need to manually call
DoShowPopup() after the animation ends.
*/
virtual bool AnimateShow(const wxRect& rect, int flags);
/**
This member function is not normally called in application code.
Instead, it can be implemented in a derived class to return default
wxComboPopup, in case @a popup is @NULL.
@note If you have implemented OnButtonClick() to do something else than
show the popup, then DoSetPopupControl() must always set @a popup
to @NULL.
*/
virtual void DoSetPopupControl(wxComboPopup* popup);
/**
Flags for DoShowPopup() and AnimateShow().
*/
enum
{
ShowBelow = 0x0000, //!< Show popup below the control.
ShowAbove = 0x0001, //!< Show popup above the control.
CanDeferShow = 0x0002 //!< Can only return true from AnimateShow() if this is set.
};
/**
This member function is not normally called in application code.
Instead, it must be called in a derived class to make sure popup is
properly shown after a popup animation has finished (but only if
AnimateShow() did not finish the animation within its function scope).
@param rect
Position to show the popup window at, in screen coordinates.
@param flags
Combination of any of the following: wxComboCtrl::ShowAbove,
and wxComboCtrl::CanDeferShow.
*/
virtual void DoShowPopup(const wxRect& rect, int flags);
};

View File

@@ -0,0 +1,318 @@
/////////////////////////////////////////////////////////////////////////////
// Name: combobox.h
// Purpose: interface of wxComboBox
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxComboBox
A combobox is like a combination of an edit control and a listbox.
It can be displayed as static list with editable or read-only text field;
or a drop-down list with text field; or a drop-down list without a text
field depending on the platform and presence of wxCB_READONLY style.
A combobox permits a single selection only. Combobox items are numbered
from zero.
If you need a customized combobox, have a look at wxComboCtrl,
wxOwnerDrawnComboBox, wxComboPopup and the ready-to-use wxBitmapComboBox.
Please refer to wxTextEntry documentation for the description of methods
operating with the text entry part of the combobox and to wxItemContainer
for the methods operating with the list of strings. Notice that at least
under MSW wxComboBox doesn't behave correctly if it contains strings
differing in case only so portable programs should avoid adding such
strings to this control.
@beginStyleTable
@style{wxCB_SIMPLE}
Creates a combobox with a permanently displayed list. Windows only.
@style{wxCB_DROPDOWN}
Creates a combobox with a drop-down list. MSW only.
@style{wxCB_READONLY}
A combobox with this style behaves like a wxChoice (and may look in
the same way as well, although this is platform-dependent), i.e. it
allows the user to choose from the list of options but doesn't allow
to enter a value not present in the list.
@style{wxCB_SORT}
Sorts the entries in the list alphabetically.
@style{wxTE_PROCESS_ENTER}
The control will generate the event @c wxEVT_TEXT_ENTER that can be
handled by the program. Otherwise, i.e. either if this style not
specified at all, or it is used, but there is no event handler for
this event or the event handler called wxEvent::Skip() to avoid
overriding the default handling, pressing Enter key is either
processed internally by the control or used to activate the default
button of the dialog, if any.
@endStyleTable
@beginEventEmissionTable{wxCommandEvent}
@event{EVT_COMBOBOX(id, func)}
Process a @c wxEVT_COMBOBOX event, when an item on
the list is selected. Note that calling GetValue() returns the new
value of selection.
@event{EVT_TEXT(id, func)}
Process a @c wxEVT_TEXT event, when the combobox text
changes.
@event{EVT_TEXT_ENTER(id, func)}
Process a @c wxEVT_TEXT_ENTER event, when RETURN is pressed in
the combobox (notice that the combobox must have been created with
wxTE_PROCESS_ENTER style to receive this event).
@event{EVT_COMBOBOX_DROPDOWN(id, func)}
Process a @c wxEVT_COMBOBOX_DROPDOWN event, which is generated
when the list box part of the combo box is shown (drops down).
Notice that this event is only supported by wxMSW, wxGTK with GTK+
2.10 or later, and wxOSX/Cocoa.
@event{EVT_COMBOBOX_CLOSEUP(id, func)}
Process a @c wxEVT_COMBOBOX_CLOSEUP event, which is generated
when the list box of the combo box disappears (closes up). This
event is only generated for the same platforms as
@c wxEVT_COMBOBOX_DROPDOWN above.
@endEventTable
@library{wxcore}
@category{ctrl}
@appearance{combobox}
@see wxListBox, wxTextCtrl, wxChoice, wxCommandEvent
*/
class wxComboBox : public wxControl,
public wxItemContainer,
public wxTextEntry
{
public:
/**
Default constructor.
*/
wxComboBox();
/**
Constructor, creating and showing a combobox.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param value
Initial selection string. An empty string indicates no selection.
Notice that for the controls with @c wxCB_READONLY style this
string must be one of the valid choices if it is not empty.
@param pos
Window position.
If ::wxDefaultPosition is specified then a default position is chosen.
@param size
Window size.
If ::wxDefaultSize is specified then the window is sized appropriately.
@param n
Number of strings with which to initialise the control.
@param choices
An array of strings with which to initialise the control.
@param style
Window style. See wxComboBox.
@param validator
Window validator.
@param name
Window name.
@beginWxPerlOnly
Not supported by wxPerl.
@endWxPerlOnly
@see Create(), wxValidator
*/
wxComboBox(wxWindow* parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0,
const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
/**
Constructor, creating and showing a combobox.
@param parent
Parent window. Must not be @NULL.
@param id
Window identifier. The value wxID_ANY indicates a default value.
@param value
Initial selection string. An empty string indicates no selection.
@param pos
Window position.
@param size
Window size. If wxDefaultSize is specified then the window is sized
appropriately.
@param choices
An array of strings with which to initialise the control.
@param style
Window style. See wxComboBox.
@param validator
Window validator.
@param name
Window name.
@beginWxPerlOnly
Use an array reference for the @a choices parameter.
@endWxPerlOnly
@see Create(), wxValidator
*/
wxComboBox(wxWindow* parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
/**
Destructor, destroying the combobox.
*/
virtual ~wxComboBox();
///@{
/**
Creates the combobox for two-step construction. Derived classes should
call or replace this function. See wxComboBox() for further details.
*/
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
///@}
/**
Returns the item being selected right now.
This function does the same things as wxChoice::GetCurrentSelection()
and returns the item currently selected in the dropdown list if it's
open or the same thing as wxControlWithItems::GetSelection() otherwise.
*/
virtual int GetCurrentSelection() const;
/**
Same as wxTextEntry::GetInsertionPoint().
@note Under wxMSW, this function always returns 0 if the combobox
doesn't have the focus.
*/
virtual long GetInsertionPoint() const;
/**
IsEmpty() is not available in this class.
This method is documented here only to notice that it can't be used
with this class because of the ambiguity between the methods with the
same name inherited from wxItemContainer and wxTextEntry base classes.
Because of this, any attempt to call it results in a compilation error
and you should use either IsListEmpty() or IsTextEmpty() depending on
what exactly do you want to test.
*/
bool IsEmpty() const;
/**
Returns true if the list of combobox choices is empty.
Use this method instead of (not available in this class) IsEmpty() to
test if the list of items is empty.
@since 2.9.3
*/
bool IsListEmpty() const;
/**
Returns true if the text of the combobox is empty.
Use this method instead of (not available in this class) IsEmpty() to
test if the text currently entered into the combobox is empty.
@since 2.9.3
*/
bool IsTextEmpty() const;
/**
Same as wxTextEntry::SetSelection().
*/
virtual void SetSelection(long from, long to);
/**
Sets the text for the combobox text field.
For normal, editable comboboxes with a text entry field calling this
method will generate a @c wxEVT_TEXT event, consistently with
wxTextEntry::SetValue() behaviour, use wxTextEntry::ChangeValue() if
this is undesirable.
For controls with @c wxCB_READONLY style the method behaves somewhat
differently: the string must be in the combobox choices list (the check
for this is case-insensitive) and @c wxEVT_TEXT is @e not generated in
this case.
@param text
The text to set.
*/
virtual void SetValue(const wxString& text);
/**
Shows the list box portion of the combo box.
Currently this method is implemented in wxMSW, wxGTK and wxOSX/Cocoa.
Notice that calling this function will generate a
@c wxEVT_COMBOBOX_DROPDOWN event except under wxOSX where
generation of this event is not supported at all.
@since 2.9.1
*/
virtual void Popup();
/**
Hides the list box portion of the combo box.
Currently this method is implemented in wxMSW, wxGTK and wxOSX/Cocoa.
Notice that calling this function will generate a
@c wxEVT_COMBOBOX_CLOSEUP event except under wxOSX where
generation of this event is not supported at all.
@since 2.9.1
*/
virtual void Dismiss();
virtual int GetSelection() const;
virtual void GetSelection(long *from, long *to) const;
virtual void SetSelection(int n);
virtual int FindString(const wxString& s, bool bCase = false) const;
virtual wxString GetString(unsigned int n) const;
virtual wxString GetStringSelection() const;
/**
Changes the text of the specified combobox item.
Notice that if the item is the currently selected one, i.e. if its text
is displayed in the text part of the combobox, then the text is also
replaced with the new @a text.
*/
virtual void SetString(unsigned int n, const wxString& text);
virtual unsigned int GetCount() const;
};

View File

@@ -0,0 +1,171 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/commandlinkbutton.h
// Purpose: interface of wxCommandLinkButton
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxCommandLinkButton
Objects of this class are similar in appearance to the normal wxButtons but
are similar to the links in a web page in functionality.
Pressing such button usually results in switching to another window of the
program and so they can be used as a replacement for the "Next" button in a
multi-page dialog (such as wxWizard), for example.
Their advantage compared to the ordinary wxButtons is that they emphasize
the action of switching the window and also that they allow to give more
detailed explanation to the user because, in addition to the short button
label, they also show a longer description string.
The short, title-like, part of the label is called the <em>main label</em>
and the longer description is the <em>note</em>. Both of them can be set
and queried independently using wxCommandLinkButton-specific methods such
as SetMainLabel() or GetNote() or also via SetLabel() and GetLabel()
methods inherited from wxButton. When using the latter, the main label and
the note are concatenated into a single string using a new line character
between them (notice that the note part can have more new lines in it).
wxCommandLinkButton generates the same event as wxButton but doesn't
support any of wxButton-specific styles nor adds any new styles of its own.
Currently this class uses native implementation under Windows and a generic
implementation for the other platforms.
@since 2.9.2
@library{wxcore}
@category{ctrl}
@appearance{commandlinkbutton}
@see wxButton, wxBitmapButton
*/
class wxCommandLinkButton : public wxButton
{
public:
/**
Default constructor.
Use Create() to really create the control.
*/
wxCommandLinkButton();
/**
Constructor really creating a command Link button.
The button will be decorated with stock icons under GTK+ 2.
@param parent
Parent window. Must not be @NULL.
@param id
Button identifier. A value of wxID_ANY indicates a default value.
@param mainLabel
First line of text on the button, typically the label of an action
that will be made when the button is pressed.
@param note
Second line of text describing the action performed when the button
is pressed.
@param pos
Button position.
@param size
Button size. If the default size is specified then the button is sized
appropriately for the text.
@param style
Window style. See wxButton class description.
@param validator
Window validator.
@param name
Window name.
@see Create(), wxValidator
*/
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 = wxButtonNameStr);
/**
Button creation function for two-step creation.
For more details, see wxCommandLinkButton().
*/
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 = wxButtonNameStr);
/**
Sets a new main label and note for the button.
Neither of the arguments can be empty, if you need to change just the
label or just the note, use SetMainLabel() or SetNote() instead of this
function.
@param mainLabel
New main label to use.
@param note
New note to use.
*/
void SetMainLabelAndNote(const wxString& mainLabel, const wxString& note);
/**
Sets the string label and note for the button.
@param label
The label and note to set, with the two separated
by the first newline or none to set a blank note.
*/
virtual void SetLabel(const wxString& label);
/**
Returns the string label for the button.
@see SetLabel()
@return
A string with the main label and note concatenated
together with a newline separating them.
*/
wxString GetLabel() const;
/**
Changes the main label.
@param mainLabel
New main label to use.
*/
void SetMainLabel(const wxString& mainLabel);
/**
Changes the note.
@param note
New note to use.
*/
void SetNote(const wxString& note);
/**
Returns the current main label.
@return
Main label currently displayed.
*/
wxString GetMainLabel() const;
/**
Returns the currently used note.
@return
Note currently displayed.
*/
wxString GetNote() const;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/containr.h
// Purpose: documentation of wxNavigationEnabled<>
// Author: Vadim Zeitlin
// Created: 2011-07-23
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
A helper class implementing TAB navigation among the window children.
This class contains the functionality needed to correctly implement TAB
navigation among the children of the window. Its exact contents is not
important and is intentionally not documented as the only way to use this
class is to inherit from it instead of inheriting from the usual base class
directly. For example, if some class needs to inherit from wxControl but
contains multiple sub-windows and needs to support keyboard navigation, it
is enough to declare it in the following way:
@code
class MyControlWithSubChildren :
public wxNavigationEnabled<wxControl>
{
public:
// Default constructor is implemented in the same way as always.
MyControlWithSubChildren() = default;
// Non-default constructor can't use wxControl ctor any more as
// wxControl is not its direct base class, but it can use Create().
MyControlWithSubChildren(wxWindow *parent, wxWindowID winid)
{
wxControl::Create(parent, winid);
// More creation code...
}
// Everything else as usual ...
};
@endcode
@library{wxcore}
@since 2.9.3
*/
template <class W>
class wxNavigationEnabled : public W
{
public:
/// The name of the real base window class that this class derives from.
typedef W BaseWindowClass;
/**
Default constructor.
This class provides only the default constructor as it's not possible,
in general, to provide all the constructors of the real base class
BaseWindowClass.
This is however not usually a problem for wxWindow-derived classes as,
by convention, they always define a Create() method such that calling
it on an object initialized using the default constructor is equivalent
to using a non-default constructor directly. So the classes inheriting
from wxNavigationEnabled<W> should simply call W::Create() in their
constructors.
*/
wxNavigationEnabled();
};

View File

@@ -0,0 +1,429 @@
/////////////////////////////////////////////////////////////////////////////
// Name: control.h
// Purpose: interface of wxControl
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxControl
This is the base class for a control or "widget".
A control is generally a small window which processes user input and/or
displays one or more item of data.
wxControl is mainly intended to function as a base class for the implementation
of native widget classes. It provides some common support for control labels and
dealing with mnemonics in labels as well as some platform support.
Developers of classes for generic or custom controls (which often have no need for
label support and/or platform specifics) might be better of deriving directly from
wxWindow. There are however no known technical restrictions for using wxControl as
a base class for generic widget classes.
@beginEventEmissionTable{wxClipboardTextEvent}
@event{EVT_TEXT_COPY(id, func)}
Some or all of the controls content was copied to the clipboard.
@event{EVT_TEXT_CUT(id, func)}
Some or all of the controls content was cut (i.e. copied and
deleted).
@event{EVT_TEXT_PASTE(id, func)}
Clipboard content was pasted into the control.
@endEventTable
@library{wxcore}
@category{ctrl}
@see wxValidator
*/
class wxControl : public wxWindow
{
public:
/**
Constructs a control.
@param parent
Pointer to a parent window.
@param id
Control identifier. If wxID_ANY, will automatically create an identifier.
@param pos
Control position. wxDefaultPosition indicates that wxWidgets
should generate a default position for the control.
@param size
Control size. wxDefaultSize indicates that wxWidgets should generate
a default size for the window. If no suitable size can be found, the
window will be sized to 20x20 pixels so that the window is visible but
obviously not correctly sized.
@param style
Control style. For generic window styles, please see wxWindow.
@param validator
Control validator.
@param name
Control name.
*/
wxControl(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
/**
Default constructor to allow 2-phase creation.
*/
wxControl();
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
/**
Simulates the effect of the user issuing a command to the item.
@see wxCommandEvent
*/
virtual void Command(wxCommandEvent& event);
/**
Returns the control's label, as it was passed to SetLabel().
Note that the returned string may contains mnemonics ("&" characters) if they were
passed to the SetLabel() function; use GetLabelText() if they are undesired.
Also note that the returned string is always the string which was passed to
SetLabel() but may be different from the string passed to SetLabelText()
(since this last one escapes mnemonic characters).
*/
wxString GetLabel() const;
/**
Returns the control's label without mnemonics.
Note that because of the stripping of the mnemonics the returned string may differ
from the string which was passed to SetLabel() but should always be the same which
was passed to SetLabelText().
*/
wxString GetLabelText() const;
/**
Determine the size needed by the control to leave the given area for
its text.
This function is mostly useful with control displaying short amounts of
text that can be edited by the user, e.g. wxTextCtrl, wxComboBox,
wxSearchCtrl etc. Typically it is used to size these controls for the
maximal amount of input they are supposed to contain, for example:
@code
// Create a control for post code entry.
wxTextCtrl* postcode = new wxTextCtrl(this, ...);
// And set its initial and minimal size to be big enough for
// entering 5 digits.
postcode->SetInitialSize(
postcode->GetSizeFromTextSize(
postcode->GetTextExtent("99999")));
@endcode
Currently this method is only implemented for wxTextCtrl, wxComboBox
and wxChoice in wxMSW and wxGTK.
@param xlen The horizontal extent of the area to leave for text, in
pixels.
@param ylen The vertical extent of the area to leave for text, in
pixels. By default -1 meaning that the vertical component of the
returned size should be the default height of this control.
@return The size that the control should have to leave the area of the
specified size for its text. May return wxDefaultSize if this
method is not implemented for this particular control under the
current platform.
@since 2.9.5
*/
wxSize GetSizeFromTextSize(int xlen, int ylen = -1) const;
/**
@overload
*/
wxSize GetSizeFromTextSize(const wxSize& tsize) const;
/**
Determine the minimum size needed by the control to display the given text.
The helper function that uses combination of GetSizeFromTextSize() and
GetTextExtent() which used together pretty often:
@code
wxSize GetSizeFromText(const wxString& text) const
{
return GetSizeFromTextSize(GetTextExtent(text).GetWidth());
}
@endcode
@param text The given text.
@return The size that the control should have to leave the area of the
specified text. May return wxDefaultSize if this method is not
implemented for this particular control under the current platform.
@since 3.1.3
*/
wxSize GetSizeFromText(const wxString& text) const;
/**
Sets the control's label.
All "&" characters in the @a label are special and indicate that the
following character is a @e mnemonic for this control and can be used to
activate it from the keyboard (typically by using @e Alt key in
combination with it). To insert a literal ampersand character, you need
to double it, i.e. use "&&". If this behaviour is undesirable, use
SetLabelText() instead.
*/
void SetLabel(const wxString& label);
/**
Sets the control's label to exactly the given string.
Unlike SetLabel(), this function shows exactly the @a text passed to it
in the control, without interpreting ampersands in it in any way.
Notice that it means that the control can't have any mnemonic defined
for it using this function.
@see EscapeMnemonics()
*/
void SetLabelText(const wxString& text);
// NB: when writing docs for the following function remember that Doxygen
// will always expand HTML entities (e.g. &quot;) and thus we need to
// write e.g. "&amp;lt;" to have in the output the "&lt;" string.
/**
Sets the controls label to a string using markup.
Simple markup supported by this function can be used to apply different
fonts or colours to different parts of the control label when supported.
If markup is not supported by the control or platform, it is simply
stripped and SetLabel() is used with the resulting string.
For example,
@code
wxStaticText *text;
...
text->SetLabelMarkup("<b>&amp;Bed</b> &amp;mp; "
"<span foreground='red'>breakfast</span> "
"available <big>HERE</big>");
@endcode
would show the string using bold, red and big for the corresponding
words under wxGTK but will simply show the string "Bed &amp; breakfast
available HERE" on the other platforms. In any case, the "B" of "Bed"
will be underlined to indicate that it can be used as a mnemonic for
this control.
The supported tags are:
<TABLE>
<TR>
<TD><b>Tag</b></TD>
<TD><b>Description</b></TD>
</TR>
<TR>
<TD>&lt;b&gt;</TD>
<TD>bold text</TD>
</TR>
<TR>
<TD>&lt;big&gt;</TD>
<TD>bigger text</TD>
</TR>
<TR>
<TD>&lt;i&gt;</TD>
<TD>italic text</TD>
</TR>
<TR>
<TD>&lt;s&gt;</TD>
<TD>strike-through text</TD>
</TR>
<TR>
<TD>&lt;small&gt;</TD>
<TD>smaller text</TD>
</TR>
<TR>
<TD>&lt;tt&gt;</TD>
<TD>monospaced text</TD>
</TR>
<TR>
<TD>&lt;u&gt;</TD>
<TD>underlined text</TD>
</TR>
<TR>
<TD>&lt;span&gt;</TD>
<TD>generic formatter tag, see the table below for supported
attributes.
</TD>
</TR>
</TABLE>
Supported @c &lt;span&gt; attributes:
<TABLE>
<TR>
<TD><b>Name</b></TD>
<TD><b>Description</b></TD>
</TR>
<TR>
<TD>foreground, fgcolor, color</TD>
<TD>Foreground text colour, can be a name or RGB value.</TD>
</TR>
<TR>
<TD>background, bgcolor</TD>
<TD>Background text colour, can be a name or RGB value.</TD>
</TR>
<TR>
<TD>font_family, face</TD>
<TD>Font face name.</TD>
</TR>
<TR>
<TD>font_weight, weight</TD>
<TD>Numeric value in 0..900 range or one of "ultralight",
"light", "normal" (all meaning non-bold), "bold", "ultrabold"
and "heavy" (all meaning bold).</TD>
</TR>
<TR>
<TD>font_style, style</TD>
<TD>Either "oblique" or "italic" (both with the same meaning)
or "normal".</TD>
</TR>
<TR>
<TD>size</TD>
<TD>The font size can be specified either as "smaller" or
"larger" relatively to the current font, as a CSS font size
name ("xx-small", "x-small", "small", "medium", "large",
"x-large" or "xx-large") or as a number giving font size in
1024th parts of a point, i.e. 10240 for a 10pt font.</TD>
</TR>
</TABLE>
This markup language is a strict subset of Pango markup (described at
http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html)
and any tags and span attributes not documented above can't be used
under non-GTK platforms.
Also note that you need to escape the following special characters:
<TABLE>
<TR>
<TD><b>Special character</b></TD>
<TD><b>Escape as</b></TD>
</TR>
<TR>
<TD>@c &amp;</TD>
<TD>@c &amp;amp; or as @c &amp;&amp;</TD>
</TR>
<TR>
<TD>@c &apos;</TD>
<TD>@c &amp;apos;</TD>
</TR>
<TR>
<TD>@c &quot;</TD>
<TD>@c &amp;quot;</TD>
</TR>
<TR>
<TD>@c &lt;</TD>
<TD>@c &amp;lt;</TD>
</TR>
<TR>
<TD>@c &gt;</TD>
<TD>@c &amp;gt;</TD>
</TR>
</TABLE>
The non-escaped ampersand @c &amp; characters are interpreted as
mnemonics as with wxControl::SetLabel.
@param markup
String containing markup for the label. It may contain markup tags
described above and newline characters but currently only wxGTK and
wxOSX support multiline labels with markup, the generic
implementation (also used in wxMSW) only handles single line markup
labels. Notice that the string must be well-formed (e.g. all tags
must be correctly closed) and won't be shown at all otherwise.
@return
@true if the new label was set (even if markup in it was ignored)
or @false if we failed to parse the markup. In this case the label
remains unchanged.
Currently wxButton and wxStaticText support markup in all major ports
(wxMSW, wxGTK and wxOSX/Cocoa). Extending support to more controls is
planned in the future.
@since 2.9.2
*/
bool SetLabelMarkup(const wxString& markup);
public: // static functions
/**
Returns the given @a label string without mnemonics ("&" characters).
*/
static wxString GetLabelText(const wxString& label);
/**
Returns the given @a str string without mnemonics ("&" characters).
@note This function is identical to GetLabelText() and is provided
mostly for symmetry with EscapeMnemonics().
*/
static wxString RemoveMnemonics(const wxString& str);
/**
Escapes the special mnemonics characters ("&") in the given string.
This function can be helpful if you need to set the controls label to a
user-provided string. If the string contains ampersands, they wouldn't
appear on the display but be used instead to indicate that the
character following the first of them can be used as a control mnemonic.
While this can sometimes be desirable (e.g. to allow the user to
configure mnemonics of the controls), more often you will want to use
this function before passing a user-defined string to SetLabel().
Alternatively, if the label is entirely user-defined, you can just call
SetLabelText() directly -- but this function must be used if the label
is a combination of a part defined by program containing the control
mnemonics and a user-defined part.
@param text
The string such as it should appear on the display.
@return
The same string with the ampersands in it doubled.
*/
static wxString EscapeMnemonics(const wxString& text);
/**
Replaces parts of the @a label string with ellipsis, if needed, so
that it fits into @a maxWidth pixels if possible.
Note that this function does @em not guarantee that the returned string
will always be shorter than @a maxWidth; if @a maxWidth is extremely
small, ellipsized text may be larger.
@param label
The string to ellipsize
@param dc
The DC used to retrieve the character widths through the
wxDC::GetPartialTextExtents() function.
@param mode
The ellipsization mode. This is the setting which determines
which part of the string should be replaced by the ellipsis
(unless it is ::wxELLIPSIZE_NONE in which case nothing is done).
See ::wxEllipsizeMode enumeration values for more info.
@param maxWidth
The maximum width of the returned string in pixels.
This argument determines how much characters of the string need to
be removed (and replaced by ellipsis).
@param flags
One or more of the ::wxEllipsizeFlags enumeration values combined.
*/
static wxString Ellipsize(const wxString& label, const wxReadOnlyDC& dc,
wxEllipsizeMode mode, int maxWidth,
int flags = wxELLIPSIZE_FLAGS_DEFAULT);
};

View File

@@ -0,0 +1,223 @@
/////////////////////////////////////////////////////////////////////////////
// Name: convauto.h
// Purpose: interface of wxConvAuto
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Constants representing various BOM types.
BOM is an abbreviation for "Byte Order Mark", a special Unicode character
which may be inserted into the beginning of a text stream to indicate its
encoding.
@since 2.9.3
*/
enum wxBOM
{
/**
Unknown BOM.
This is returned if BOM presence couldn't be determined and normally
happens because not enough bytes of input have been analysed.
*/
wxBOM_Unknown = -1,
/**
No BOM.
The stream doesn't contain BOM character at all.
*/
wxBOM_None,
/**
UTF-32 big endian BOM.
The stream is encoded in big endian variant of UTF-32.
*/
wxBOM_UTF32BE,
/**
UTF-32 little endian BOM.
The stream is encoded in little endian variant of UTF-32.
*/
wxBOM_UTF32LE,
/**
UTF-16 big endian BOM.
The stream is encoded in big endian variant of UTF-16.
*/
wxBOM_UTF16BE,
/**
UTF-16 little endian BOM.
The stream is encoded in little endian variant of UTF-16.
*/
wxBOM_UTF16LE,
/**
UTF-8 BOM.
The stream is encoded in UTF-8.
Notice that contrary to a popular belief, it's perfectly possible and,
n fact, common under Microsoft Windows systems, to have a BOM in an
UTF-8 stream: while it's not used to indicate the endianness of UTF-8
stream (as it's byte-oriented), the BOM can still be useful just as an
unambiguous indicator of UTF-8 being used.
*/
wxBOM_UTF8
};
/**
@class wxConvAuto
This class implements a Unicode to/from multibyte converter capable of
automatically recognizing the encoding of the multibyte text on input. The
logic used is very simple: the class uses the BOM (byte order mark) if it's
present and tries to interpret the input as UTF-8 otherwise. If this fails,
the input is interpreted as being in the default multibyte encoding which
can be specified in the constructor of a wxConvAuto instance and, in turn,
defaults to the value of GetFallbackEncoding() if not explicitly given.
For the conversion from Unicode to multibyte, the same encoding as was
previously used for multibyte to Unicode conversion is reused. If there had
been no previous multibyte to Unicode conversion, UTF-8 is used by default.
Notice that once the multibyte encoding is automatically detected, it
doesn't change any more, i.e. it is entirely determined by the first use of
wxConvAuto object in the multibyte-to-Unicode direction. However creating a
copy of wxConvAuto object, either via the usual copy constructor or
assignment operator, or using wxMBConv::Clone(), resets the automatically
detected encoding so that the new copy will try to detect the encoding of
the input on first use.
This class is used by default in wxWidgets classes and functions reading
text from files such as wxFile, wxFFile, wxTextFile, wxFileConfig and
various stream classes so the encoding set with its SetFallbackEncoding()
method will affect how these classes treat input files. In particular, use
this method to change the fall-back multibyte encoding used to interpret
the contents of the files whose contents isn't valid UTF-8 or to disallow
it completely.
@library{wxbase}
@category{data}
@see @ref overview_mbconv
*/
class wxConvAuto : public wxMBConv
{
public:
/**
Constructs a new wxConvAuto instance. The object will try to detect the
input of the multibyte text given to its wxMBConv::ToWChar() method
automatically but if the automatic detection of Unicode encodings
fails, the fall-back encoding @a enc will be used to interpret it as
multibyte text.
The default value of @a enc, @c wxFONTENCODING_DEFAULT, means that the
global default value (which can be set using SetFallbackEncoding())
should be used. As with that method, passing @c wxFONTENCODING_MAX
inhibits using this encoding completely so the input multibyte text
will always be interpreted as UTF-8 in the absence of BOM and the
conversion will fail if the input doesn't form valid UTF-8 sequence.
Another special value is @c wxFONTENCODING_SYSTEM which means to use
the encoding currently used on the user system, i.e. the encoding
returned by wxLocale::GetSystemEncoding(). Any other encoding will be
used as is, e.g. passing @c wxFONTENCODING_ISO8859_1 ensures that
non-UTF-8 input will be treated as latin1.
*/
wxConvAuto(wxFontEncoding enc = wxFONTENCODING_DEFAULT);
/**
Return the detected BOM type.
The BOM type is detected after sufficiently many initial bytes have
passed through this conversion object so it will always return
wxBOM_Unknown immediately after the object creation but may return a
different value later.
@since 2.9.3
*/
wxBOM GetBOM() const;
/**
Return the detected encoding
Returns @c wxFONTENCODING_MAX if called before the first use.
@since 3.1.5
*/
wxBOM GetEncoding() const;
/**
Check if the fall-back encoding is used.
@since 3.1.5
*/
bool IsUsingFallbackEncoding() const;
/**
Return a pointer to the characters that makes up this BOM.
The returned character count is 2, 3 or 4, or undefined if the return
value is @NULL.
@param bom
A valid BOM type, i.e. not wxBOM_Unknown or wxBOM_None.
@param count
A non-null pointer receiving the number of characters in this BOM.
@return
Pointer to characters composing the BOM or @NULL if BOM is unknown
or invalid. Notice that the returned string is not NUL-terminated
and may contain embedded NULs so @a count must be used to handle it
correctly.
@since 2.9.3
*/
const char* GetBOMChars(wxBOM bom, size_t* count);
/**
Disable the use of the fall back encoding: if the input doesn't have a
BOM and is not valid UTF-8, the conversion will fail.
*/
static void DisableFallbackEncoding();
/**
Returns the encoding used by default by wxConvAuto if no other encoding
is explicitly specified in constructor. By default, returns
@c wxFONTENCODING_ISO8859_1 but can be changed using
SetFallbackEncoding().
*/
static wxFontEncoding GetFallbackEncoding();
/**
Changes the encoding used by default by wxConvAuto if no other encoding
is explicitly specified in constructor. The default value, which can be
retrieved using GetFallbackEncoding(), is @c wxFONTENCODING_ISO8859_1.
Special values of @c wxFONTENCODING_SYSTEM or @c wxFONTENCODING_MAX can
be used for the @a enc parameter to use the encoding of the current
user locale as fall back or not use any encoding for fall back at all,
respectively (just as with the similar constructor parameter). However,
@c wxFONTENCODING_DEFAULT can't be used here.
*/
static void SetFallbackEncoding(wxFontEncoding enc);
/**
Return the BOM type of this buffer.
This is a helper function which is normally only used internally by
wxConvAuto but provided for convenience of the code that wants to
detect the encoding of a stream by checking it for BOM presence on its
own.
@since 2.9.3
*/
static wxBOM DetectBOM(const char *src, size_t srcLen);
};

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cpp.h
// Purpose: interface of global functions
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/** @addtogroup group_funcmacro_misc */
///@{
/**
This macro returns the concatenation of the arguments passed. Unlike when
using the preprocessor operator, the arguments undergo macro expansion
before being concatenated.
@header{wx/cpp.h}
*/
#define wxCONCAT(x1, x2)
#define wxCONCAT3(x1, x2, x3)
#define wxCONCAT4(x1, x2, x3, x4)
#define wxCONCAT5(x1, x2, x3, x4, x5)
///@}
/** @addtogroup group_funcmacro_misc */
///@{
/**
Returns the string representation of the given symbol which can be either a
literal or a macro (hence the advantage of using this macro instead of the
standard preprocessor @c # operator which doesn't work with macros).
Notice that this macro always produces a @c char string, use
wxSTRINGIZE_T() to build a wide string Unicode build.
@see wxCONCAT()
@header{wx/cpp.h}
*/
#define wxSTRINGIZE(x)
/**
Returns the string representation of the given symbol as either an ASCII or
Unicode string, depending on the current build. This is the
Unicode-friendly equivalent of wxSTRINGIZE().
@header{wx/cpp.h}
*/
#define wxSTRINGIZE_T(x)
/**
This obsolete macro is the same as the standard @c \__func__ constant.
Please use the standard macro instead.
@see __WXFUNCTION_SIG__
@header{wx/cpp.h}
*/
#define __WXFUNCTION__ __func__
/**
Expands to the current function's full signature, if available.
Falls back to the function name (i.e., @c \__func__) if not available.
As an example, if you have a class named `Calculator` with a
`double Add(double, double) const` member function,
`__WXFUNCTION_SIG__` may expand to the following:
`double Calculator::Add(double, double) const`
While `__func__` will simply expand to:
`Add`
@header{wx/cpp.h}
@since 3.3.0
*/
#define __WXFUNCTION_SIG__
///@}

View File

@@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////
// Name: creddlg.h
// Created: 2018-10-23
// Copyright: (c) 2018 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxCredentialEntryDialog
This class represents a dialog that requests a user name and a password
from the user.
Currently it is implemented as a generic wxWidgets dialog on all platforms.
Simple example of using this dialog assuming @c MyFrame object has a member
@c m_request of wxWebRequest type:
@code
void MyFrame::OnWebRequestState(wxWebRequestEvent& evt)
{
if ( evt.GetState() == wxWebRequest::State_Unauthorized )
{
wxCredentialEntryDialog dialog
(
this,
wxString::Format
(
"Please enter credentials for accessing "
"the web page at %s",
evt.GetResponse().GetURL()
),
"My Application Title"
);
if ( dialog.ShowModal() == wxID_OK )
{
m_request.GetAuthChallenge().
SetCredentials(dialog.GetCredentials());
}
//else: the dialog was cancelled
}
}
@endcode
@note For secure saving and loading users and passwords, have a look at
wxSecretStore.
@since 3.1.5
@library{wxcore}
@category{cmndlg}
@see @ref overview_cmndlg_cred
*/
class wxCredentialEntryDialog: public wxDialog
{
public:
/**
Default constructor.
Call Create() to really create the dialog later.
*/
wxCredentialEntryDialog();
/**
Constructor.
Use ShowModal() to show the dialog.
See Create() method for parameter description.
*/
wxCredentialEntryDialog(wxWindow* parent, const wxString& message,
const wxString& title,
const wxWebCredentials& cred = wxWebCredentials());
/**
Create the dialog constructed using the default constructor.
@param parent
Parent window.
@param message
Message to show on the dialog.
@param title
Title of the dialog.
@param cred
The default username and password to use (optional).
*/
bool Create(wxWindow* parent, const wxString& message,
const wxString& title,
const wxWebCredentials& cred = wxWebCredentials());
/**
Returns the credentials entered by the user.
This should be called if ShowModal() returned ::wxID_OK.
*/
wxWebCredentials GetCredentials() const;
/**
Sets the current user name.
This function may be called before showing the dialog to provide the
default value for the user name, if it's different from the one given
at the creation time.
*/
void SetUser(const wxString& user);
/**
Sets the current password.
This function may be called before showing the dialog for the reasons
similar to SetUser().
*/
void SetPassword(const wxString& password);
};

View File

@@ -0,0 +1,298 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cshelp.h
// Purpose: interface of wxHelpProvider
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHelpProvider
wxHelpProvider is an abstract class used by a program implementing
context-sensitive help to show the help text for the given window.
The current help provider must be explicitly set by the application using
Set().
@library{wxcore}
@category{help}
@see wxContextHelp, wxContextHelpButton, wxSimpleHelpProvider,
wxHelpControllerHelpProvider, wxWindow::SetHelpText(),
wxWindow::GetHelpTextAtPoint()
*/
class wxHelpProvider
{
public:
/**
Virtual destructor for any base class.
*/
virtual ~wxHelpProvider();
/**
Associates the text with the given window.
@remarks
Although all help providers have these functions to allow making
wxWindow::SetHelpText() work, not all of them implement the functions.
*/
virtual void AddHelp(wxWindow* window, const wxString& text);
/**
Associates the text with the given ID.
This help text will be shown for all windows with ID @a id, unless they
have more specific help text associated using the other AddHelp()
prototype. May be used to set the same help string for all Cancel
buttons in the application, for example.
@remarks
Although all help providers have these functions to allow making
wxWindow::SetHelpText() work, not all of them implement the functions.
*/
virtual void AddHelp(wxWindowID id, const wxString& text);
/**
Returns pointer to help provider instance.
Unlike some other classes, the help provider is not created on demand.
This must be explicitly done by the application using Set().
*/
static wxHelpProvider* Get();
/**
Get the help string for the given window.
The interpretation of the returned string is help provider dependent,
but empty string always means that no help is associated with this
window.
*/
virtual wxString GetHelp(const wxWindow* window) = 0;
/**
Removes the association between the window pointer and the help text.
This is called by the wxWindow destructor. Without this, the table of
help strings will fill up and when window pointers are reused, the
wrong help string will be found.
*/
virtual void RemoveHelp(wxWindow* window);
/**
Set the current, application-wide help provider.
@return Pointer to previous help provider or @NULL if there wasn't any.
*/
static wxHelpProvider* Set(wxHelpProvider* helpProvider);
/**
Shows help for the given window.
Override this function if the help doesn't depend on the exact position
inside the window, otherwise you need to override ShowHelpAtPoint().
Returns @true if help was shown, or @false if no help was available for
this window.
*/
virtual bool ShowHelp(wxWindow* window);
/**
This function may be overridden to show help for the window when it
should depend on the position inside the window, By default this method
forwards to ShowHelp(), so it is enough to only implement the latter if
the help doesn't depend on the position.
@param window
Window to show help text for.
@param point
Coordinates of the mouse at the moment of help event emission.
@param origin
Help event origin, see wxHelpEvent::GetOrigin.
@return @true if help was shown, or @false if no help was available
for this window.
@since 2.7.0
*/
virtual bool ShowHelpAtPoint(wxWindow* window, const wxPoint& point,
wxHelpEvent::Origin origin);
};
/**
@class wxHelpControllerHelpProvider
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. If
you use this with a wxCHMHelpController instance on windows, it will use
the native style of tip window instead of wxTipWindow.
You can use the convenience function wxContextId() to convert an integer
context id to a string for passing to wxWindow::SetHelpText().
@library{wxcore}
@category{help}
@see wxHelpProvider, wxSimpleHelpProvider, wxContextHelp,
wxWindow::SetHelpText(), wxWindow::GetHelpTextAtPoint()
*/
class wxHelpControllerHelpProvider : public wxSimpleHelpProvider
{
public:
/**
Note that the instance doesn't own the help controller. The help
controller should be deleted separately.
*/
wxHelpControllerHelpProvider(wxHelpControllerBase* hc = nullptr);
/**
Returns the help controller associated with this help provider.
*/
wxHelpControllerBase* GetHelpController() const;
/**
Sets the help controller associated with this help provider.
*/
void SetHelpController(wxHelpControllerBase* hc);
};
/**
@class wxContextHelp
This class changes the cursor to a query and puts the application into a
'context-sensitive help mode'. When the user left-clicks on a window
within the specified window, a @c wxEVT_HELP event is sent to that control,
and the application may respond to it by popping up some help.
For example:
@code
wxContextHelp contextHelp(myWindow);
@endcode
There are a couple of ways to invoke this behaviour implicitly:
- Use the wxDIALOG_EX_CONTEXTHELP style for a dialog (Windows only). This
will put a question mark in the titlebar, and Windows will put the
application into context-sensitive help mode automatically, with further
programming.
- Create a wxContextHelpButton, whose predefined behaviour is
to create a context help object. Normally you will write your application
so that this button is only added to a dialog for non-Windows platforms
(use wxDIALOG_EX_CONTEXTHELP on Windows).
Note that on macOS, the cursor does not change when in context-sensitive
help mode.
@library{wxcore}
@category{help}
@see wxHelpEvent, wxHelpController, wxContextHelpButton
*/
class wxContextHelp : public wxObject
{
public:
/**
Constructs a context help object, calling BeginContextHelp() if
@a doNow is @true (the default).
If @a window is @NULL, the top window is used.
*/
wxContextHelp(wxWindow* window = nullptr, bool doNow = true);
/**
Destroys the context help object.
*/
virtual ~wxContextHelp();
/**
Puts the application into context-sensitive help mode. @a window is the
window which will be used to catch events; if @NULL, the top window
will be used.
Returns @true if the application was successfully put into
context-sensitive help mode.
This function only returns when the event loop has finished.
*/
bool BeginContextHelp(wxWindow* window);
/**
Ends context-sensitive help mode. Not normally called by the
application.
*/
bool EndContextHelp();
};
/**
@class wxContextHelpButton
Instances of this class may be used to add a question mark button that when
pressed, puts the application into context-help mode. It does this by
creating a wxContextHelp object which itself generates a @c wxEVT_HELP event
when the user clicks on a window.
On Windows, you may add a question-mark icon to a dialog by use of the
wxDIALOG_EX_CONTEXTHELP extra style, but on other platforms you will have
to add a button explicitly, usually next to OK, Cancel or similar buttons.
@library{wxcore}
@category{help}
@see wxBitmapButton, wxContextHelp
*/
class wxContextHelpButton : public wxBitmapButton
{
public:
/**
Constructor, creating and showing a context help button.
@param parent
Parent window. Must not be @NULL.
@param id
Button identifier. Defaults to wxID_CONTEXT_HELP.
@param pos
Button position.
If ::wxDefaultPosition is specified then a default position is chosen.
@param size
Button size.
If ::wxDefaultSize is specified then the button is sized appropriately
for the question mark bitmap.
@param style
Window style.
@remarks
Normally you only need pass the parent window to the constructor, and
use the defaults for the remaining parameters.
*/
wxContextHelpButton(wxWindow* parent,
wxWindowID id = wxID_CONTEXT_HELP,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
};
/**
@class wxSimpleHelpProvider
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.
@library{wxcore}
@category{help}
@see wxHelpProvider, wxHelpControllerHelpProvider, wxContextHelp,
wxWindow::SetHelpText()(, wxWindow::GetHelpTextAtPoint()
*/
class wxSimpleHelpProvider : public wxHelpProvider
{
public:
};

View File

@@ -0,0 +1,769 @@
/////////////////////////////////////////////////////////////////////////////
// Name: ctrlsub.h
// Purpose: interface of wxControlWithItems
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxItemContainerImmutable
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.
Note that this is not a control, it's a mixin interface that classes
have to derive from in addition to wxControl or wxWindow.
Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox (which
implements an extended interface deriving from this one)
@library{wxcore}
@category{ctrl}
@see wxControlWithItems, wxItemContainer
*/
class wxItemContainerImmutable
{
public:
/// Constructor
wxItemContainerImmutable();
///@{
/**
Returns the number of items in the control.
@see IsEmpty()
*/
virtual unsigned int GetCount() const = 0;
/**
Returns @true if the control is empty or @false if it has some items.
@see GetCount()
*/
bool IsEmpty() const;
/**
Returns the label of the item with the given index.
The index must be valid, i.e. less than the value returned by
GetCount(), otherwise an assert is triggered. Notably, this function
can't be called if the control is empty.
@param n
The zero-based index.
@return The label of the item.
*/
virtual wxString GetString(unsigned int n) const = 0;
/**
Returns the array of the labels of all items in the control.
*/
wxArrayString GetStrings() const;
/**
Sets the label for the given item.
@param n
The zero-based item index.
@param string
The label to set.
*/
virtual void SetString(unsigned int n, const wxString& string) = 0;
/**
Finds an item whose label matches the given string.
@param string
String to find.
@param caseSensitive
Whether search is case sensitive (default is not).
@return The zero-based position of the item, or wxNOT_FOUND if the
string was not found.
*/
virtual int FindString(const wxString& string, bool caseSensitive = false) const;
///@}
/// @name Selection
///@{
/**
Sets the selection to the given item @a n or removes the selection
entirely if @a n == @c wxNOT_FOUND.
Note that this does not cause any command events to be emitted nor does
it deselect any other items in the controls which support multiple
selections.
@param n
The string position to select, starting from zero.
@see SetString(), SetStringSelection()
*/
virtual void SetSelection(int n) = 0;
/**
Returns the index of the selected item or @c wxNOT_FOUND if no item is
selected.
@return The position of the current selection.
@see SetSelection(), GetStringSelection()
*/
virtual int GetSelection() const = 0;
/**
Selects the item with the specified string in the control.
This method doesn't cause any command events to be emitted.
Notice that this method is case-insensitive, i.e. the string is
compared with all the elements of the control case-insensitively and
the first matching entry is selected, even if it doesn't have exactly
the same case as this string and there is an exact match afterwards.
@param string
The string to select.
@return @true if the specified string has been selected, @false if it
wasn't found in the control.
*/
bool SetStringSelection(const wxString& string);
/**
Returns the label of the selected item or an empty string if no item is
selected.
@see GetSelection()
*/
virtual wxString GetStringSelection() const;
/**
This is the same as SetSelection() and exists only because it is
slightly more natural for controls which support multiple selection.
*/
void Select(int n);
///@}
};
/**
@class wxItemContainer
This class is an abstract base class for some wxWidgets controls which
contain several items such as wxListBox, wxCheckListBox, wxComboBox or
wxChoice. It defines an interface which is implemented by all controls
which have string subitems each of which may be selected.
wxItemContainer extends wxItemContainerImmutable interface with methods
for adding/removing items.
It defines the methods for accessing the controls items and although each
of the derived classes implements them differently, they still all conform
to the same interface.
The items in a wxItemContainer have (non-empty) string labels and,
optionally, client data associated with them. Client data may be of two
different kinds: either simple untyped (@c void *) pointers which are
simply stored by the control but not used in any way by it, or typed
pointers (wxClientData*) which are owned by the control meaning that the
typed client data (and only it) will be deleted when an item is deleted
using Delete() or the entire control is cleared using Clear(), which also
happens when it is destroyed.
Finally note that in the same control all items must have client data of
the same type (typed or untyped), if any. This type is determined by the
first call to Append() (the version with client data pointer) or
SetClientData().
Note that this is not a control, it's a mixin interface that classes
have to derive from in addition to wxControl or wxWindow. Convenience
class wxControlWithItems is provided for this purpose.
@library{wxcore}
@category{ctrl}
@see wxControlWithItems, wxItemContainerImmutable
*/
class wxItemContainer : public wxItemContainerImmutable
{
public:
///@{
/**
Appends item into the control.
@param item
String to add.
@return The return value is the index of the newly inserted item.
Note that this may be different from the last one if the
control is sorted (e.g. has @c wxLB_SORT or @c wxCB_SORT
style).
*/
int Append(const wxString& item);
/**
Appends item into the control.
@param item
String to add.
@param clientData
Pointer to client data to associate with the new item.
@return The return value is the index of the newly inserted item.
Note that this may be different from the last one if the
control is sorted (e.g. has @c wxLB_SORT or @c wxCB_SORT
style).
*/
int Append(const wxString& item, void* clientData);
/**
Appends item into the control.
@param item
String to add.
@param clientData
Pointer to client data to associate with the new item.
@return The return value is the index of the newly inserted item.
Note that this may be different from the last one if the
control is sorted (e.g. has @c wxLB_SORT or @c wxCB_SORT
style).
*/
int Append(const wxString& item, wxClientData* clientData);
/**
Appends several items at once into the control.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param items
Array of strings to insert.
*/
int Append(const wxArrayString& items);
/**
Appends several items at once into the control.
This is the same as the overload taking wxArrayString, except that it
works with the standard vector container.
@since 3.1.0
*/
int Append(const std::vector<wxString>& items);
/**
Appends several items at once into the control.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param items
Array of strings to insert.
@param clientData
Array of client data pointers of the same size as @a items to
associate with the new items.
*/
int Append(const wxArrayString& items, void **clientData);
/**
Appends several items at once into the control.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param items
Array of strings to insert.
@param clientData
Array of client data pointers of the same size as @a items to
associate with the new items.
*/
int Append(const wxArrayString& items, wxClientData **clientData);
/**
Appends several items at once into the control.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
*/
int Append(unsigned int n, const wxString* items);
/**
Appends several items at once into the control.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
@param clientData
Array of client data pointers of size @a n to associate with the
new items.
*/
int Append(unsigned int n, const wxString* items,
void** clientData);
/**
Appends several items at once into the control.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
@param clientData
Array of client data pointers of size @a n to associate with the
new items.
*/
int Append(unsigned int n, const wxString* items,
wxClientData** clientData);
///@}
/**
Removes all items from the control.
Clear() also deletes the client data of the existing items if it is
owned by the control.
*/
void Clear();
/**
Deletes an item from the control.
The client data associated with the item will be also deleted if it is
owned by the control. Note that it is an error (signalled by an assert
failure in debug builds) to remove an item with the index negative or
greater or equal than the number of items in the control.
If there is a currently selected item below the item being deleted,
i.e. if GetSelection() returns a valid index greater than or equal to
@a n, the selection is invalidated when this function is called.
However if the selected item appears before the item being deleted, the
selection is preserved unchanged.
@param n
The zero-based item index.
@see Clear()
*/
void Delete(unsigned int n);
/**
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.
Returns true if the control maintains its items in a sorted order.
*/
bool IsSorted() const;
/**
Returns the client object associated with the given item and transfers
its ownership to the caller.
This method, unlike GetClientObject(), expects the caller to delete the
returned pointer. It also replaces the internally stored pointer with
@NULL, i.e. completely detaches the client object pointer from the
control.
It's an error to call this method unless HasClientObjectData() returns
@true.
@param n
The zero-based item index.
@return The associated client object pointer to be deleted by caller or
@NULL.
@since 2.9.2
*/
wxClientData *DetachClientObject(unsigned int n);
/**
Returns true, if either untyped data (@c void*) or object data (wxClientData*)
is associated with the items of the control.
*/
bool HasClientData() const;
/**
Returns true, if object data is associated with the items of the
control.
Object data pointers have the type @c wxClientData* instead of @c void*
and, importantly, are owned by the control, i.e. will be deleted by it,
unlike their untyped counterparts.
*/
bool HasClientObjectData() const;
/**
Returns true, if untyped data (@c void*)
is associated with the items of the control.
*/
bool HasClientUntypedData() const;
///@{
/**
Returns a pointer to the client data associated with the given item (if
any). It is an error to call this function for a control which doesn't
have untyped client data at all although it is OK to call it even if
the given item doesn't have any client data associated with it (but
other items do).
@param n
The zero-based position of the item.
@return A pointer to the client data, or @NULL if not present.
*/
void* GetClientData(unsigned int n) const;
/**
Returns a pointer to the client data associated with the given item (if
any). It is an error to call this function for a control which doesn't
have typed client data at all although it is OK to call it even if the
given item doesn't have any client data associated with it (but other
items do).
Notice that the returned pointer is still owned by the control and will
be deleted by it, use DetachClientObject() if you want to remove the
pointer from the control.
@param n
The zero-based position of the item.
@return A pointer to the client data, or @NULL if not present.
*/
wxClientData* GetClientObject(unsigned int n) const;
/**
Associates the given untyped client data pointer with the given item.
Note that it is an error to call this function if any typed client data
pointers had been associated with the control items before.
@param n
The zero-based item index.
@param data
The client data to associate with the item.
*/
void SetClientData(unsigned int n, void* data);
/**
Associates the given typed client data pointer with the given item: the
@a data object will be deleted when the item is deleted (either
explicitly by using Delete() or implicitly when the control itself is
destroyed). Note that it is an error to call this function if any
untyped client data pointers had been associated with the control items
before.
@param n
The zero-based item index.
@param data
The client data to associate with the item.
*/
void SetClientObject(unsigned int n, wxClientData* data);
///@}
///@{
/**
Inserts item into the control.
@param item
String to add.
@param pos
Position to insert item before, zero based.
@return The return value is the index of the newly inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(const wxString& item, unsigned int pos);
/**
Inserts item into the control.
@param item
String to add.
@param pos
Position to insert item before, zero based.
@param clientData
Pointer to client data to associate with the new item.
@return The return value is the index of the newly inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(const wxString& item, unsigned int pos, void* clientData);
/**
Inserts item into the control.
@param item
String to add.
@param pos
Position to insert item before, zero based.
@param clientData
Pointer to client data to associate with the new item.
@return The return value is the index of the newly inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(const wxString& item, unsigned int pos,
wxClientData* clientData);
/**
Inserts several items at once into the control.
Notice that calling this method is usually much faster than inserting
them one by one if you need to insert a lot of items.
@param items
Array of strings to insert.
@param pos
Position to insert the items before, zero based.
@return The return value is the index of the last inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(const wxArrayString& items, unsigned int pos);
/**
Inserts several items at once into the control.
This is the same as the overload taking wxArrayString, except that it
works with the standard vector container.
@since 3.1.0
*/
int Insert(const std::vector<wxString>& items);
/**
Inserts several items at once into the control.
Notice that calling this method is usually much faster than inserting
them one by one if you need to insert a lot of items.
@param items
Array of strings to insert.
@param pos
Position to insert the items before, zero based.
@param clientData
Array of client data pointers of the same size as @a items to
associate with the new items.
@return The return value is the index of the last inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(const wxArrayString& items, unsigned int pos,
void **clientData);
/**
Inserts several items at once into the control.
Notice that calling this method is usually much faster than inserting
them one by one if you need to insert a lot of items.
@param items
Array of strings to insert.
@param pos
Position to insert the items before, zero based.
@param clientData
Array of client data pointers of the same size as @a items to
associate with the new items.
@return The return value is the index of the last inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(const wxArrayString& items, unsigned int pos,
wxClientData **clientData);
/**
Inserts several items at once into the control.
Notice that calling this method is usually much faster than inserting
them one by one if you need to insert a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
@param pos
Position to insert the items before, zero based.
@return The return value is the index of the last inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(unsigned int n, const wxString* items,
unsigned int pos);
/**
Inserts several items at once into the control.
Notice that calling this method is usually much faster than inserting
them one by one if you need to insert a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
@param pos
Position to insert the new items before, zero based.
@param clientData
Array of client data pointers of size @a n to associate with the
new items.
@return The return value is the index of the last inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(unsigned int n, const wxString* items,
unsigned int pos,
void** clientData);
/**
Inserts several items at once into the control.
Notice that calling this method is usually much faster than inserting
them one by one if you need to insert a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
@param pos
Position to insert the new items before, zero based.
@param clientData
Array of client data pointers of size @a n to associate with the
new items.
@return The return value is the index of the last inserted item.
If the insertion failed for some reason, -1 is returned.
*/
int Insert(unsigned int n, const wxString* items,
unsigned int pos,
wxClientData** clientData);
///@}
///@{
/**
Replaces the current control contents with the given items.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param items
Array of strings to insert.
*/
void Set(const wxArrayString& items);
/**
Replaces the current control contents with the given items.
This is the same as the overload taking wxArrayString, except that it
works with the standard vector container.
@since 3.1.0
*/
void Set(const std::vector<wxString>& items);
/**
Replaces the current control contents with the given items.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param items
Array of strings to insert.
@param clientData
Array of client data pointers of the same size as @a items to
associate with the new items.
*/
void Set(const wxArrayString& items, void **clientData);
/**
Replaces the current control contents with the given items.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param items
Array of strings to insert.
@param clientData
Array of client data pointers of the same size as @a items to
associate with the new items.
*/
void Set(const wxArrayString& items, wxClientData **clientData);
/**
Replaces the current control contents with the given items.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
*/
void Set(unsigned int n, const wxString* items);
/**
Replaces the current control contents with the given items.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
@param clientData
Array of client data pointers of size @a n to associate with the
new items.
*/
void Set(unsigned int n, const wxString* items, void** clientData);
/**
Replaces the current control contents with the given items.
Notice that calling this method is usually much faster than appending
them one by one if you need to add a lot of items.
@param n
Number of items in the @a items array.
@param items
Array of strings of size @a n.
@param clientData
Array of client data pointers of size @a n to associate with the
new items.
*/
void Set(unsigned int n, const wxString* items, wxClientData** clientData);
///@}
};
/**
@class wxControlWithItems
This is convenience class that derives from both wxControl and
wxItemContainer. It is used as basis for some wxWidgets controls
(wxChoice and wxListBox).
@library{wxcore}
@category{ctrl}
@see wxItemContainer, wxItemContainerImmutable
*/
class wxControlWithItems : public wxControl, public wxItemContainer
{
};

View File

@@ -0,0 +1,386 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cursor.h
// Purpose: interface of wxCursor
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxCursor
A cursor is a small bitmap used for denoting where the mouse pointer is,
with a picture that indicates the point of a mouse click.
A cursor may be associated either with the given window (and all its
children, unless any of them defines its own cursor) using
wxWindow::SetCursor(), or set globally using wxSetCursor(). It is also
common to temporarily change the cursor to a "busy cursor" indicating that
some lengthy operation is in progress and wxBusyCursor can be used for
this.
Because a custom cursor of a fixed size would look either inappropriately
big in standard resolution or too small in high resolution, wxCursorBundle
class allows to define a set of cursors of different sizes, letting
wxWidgets to automatically select the most appropriate one for the current
resolution and user's preferred cursor size. Using this class with
wxWindow::SetCursorBundle() is the recommended way to use custom cursors.
@section cursor_custom Creating a Custom Cursor
The following is an example of creating a cursor from 32x32 bitmap data
(down_bits) and a mask (down_mask) where 1 is black and 0 is white for the
bits, and 1 is opaque and 0 is transparent for the mask.
It works on Windows and GTK+.
@code
static char down_bits[] = { 255, 255, 255, 255, 31,
255, 255, 255, 31, 255, 255, 255, 31, 255, 255, 255,
31, 255, 255, 255, 31, 255, 255, 255, 31, 255, 255,
255, 31, 255, 255, 255, 31, 255, 255, 255, 25, 243,
255, 255, 19, 249, 255, 255, 7, 252, 255, 255, 15, 254,
255, 255, 31, 255, 255, 255, 191, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255 };
static char down_mask[] = { 240, 1, 0, 0, 240, 1,
0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1,
0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 255, 31, 0, 0, 255,
31, 0, 0, 254, 15, 0, 0, 252, 7, 0, 0, 248, 3, 0, 0,
240, 1, 0, 0, 224, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0 };
#ifdef __WXMSW__
wxBitmap down_bitmap(down_bits, 32, 32);
wxBitmap down_mask_bitmap(down_mask, 32, 32);
down_bitmap.SetMask(new wxMask(down_mask_bitmap));
wxImage down_image = down_bitmap.ConvertToImage();
down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 6);
down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 14);
wxCursor down_cursor = wxCursor(down_image);
#elif defined(__WXGTK__)
wxCursor down_cursor = wxCursor(down_bits, 32, 32, 6, 14,
down_mask, wxWHITE, wxBLACK);
#endif
@endcode
@library{wxcore}
@category{gdi}
@stdobjects
- ::wxNullCursor
- ::wxSTANDARD_CURSOR
- ::wxHOURGLASS_CURSOR
- ::wxCROSS_CURSOR
@see wxBitmap, wxIcon, wxWindow::SetCursor(), wxSetCursor(), ::wxStockCursor
*/
class wxCursor : public wxGDIObject
{
public:
/**
Default constructor.
*/
wxCursor();
/**
Constructs a cursor from the provided bitmap and hotspot position.
@param bitmap
The bitmap to use for the cursor, should be valid.
@param hotSpotX
Hotspot x coordinate (relative to the top left of the image).
@param hotSpotY
Hotspot y coordinate (relative to the top left of the image).
@since 3.3.0
*/
wxCursor(const wxBitmap& bitmap, int hotSpotX = 0, int hotSpotY = 0);
/**
@overload
@since 3.3.0
*/
wxCursor(const wxBitmap& bitmap, const wxPoint& hotSpot);
/**
Constructs a cursor by passing a string resource name or filename.
The arguments @a hotSpotX and @a hotSpotY are only used when there's no
hotspot info in the resource/image-file to load (e.g. when using
@c wxBITMAP_TYPE_ICO under wxMSW or @c wxBITMAP_TYPE_XPM under wxGTK).
@param cursorName
The name of the resource or the image file to load.
@param type
Icon type to load. It defaults to @c wxCURSOR_DEFAULT_TYPE,
which is a @#define associated to different values on different
platforms:
- under Windows, it defaults to @c wxBITMAP_TYPE_CUR_RESOURCE.
Other permitted types under Windows are @c wxBITMAP_TYPE_CUR
(to load a cursor from a .cur cursor file), @c wxBITMAP_TYPE_ICO
(to load a cursor from a .ico icon file) and @c wxBITMAP_TYPE_ANI
(to load a cursor from a .ani icon file).
- under MacOS, it defaults to @c wxBITMAP_TYPE_MACCURSOR_RESOURCE;
when specifying a string resource name, first a PNG and then a CUR
image is searched in resources.
- under GTK, it defaults to @c wxBITMAP_TYPE_XPM.
See the wxCursor(const wxImage& image) ctor for more info.
- under X11, it defaults to @c wxBITMAP_TYPE_XPM.
@param hotSpotX
Hotspot x coordinate (relative to the top left of the image).
@param hotSpotY
Hotspot y coordinate (relative to the top left of the image).
*/
wxCursor(const wxString& cursorName,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
/**
@overload
@since 3.3.0
*/
wxCursor(const wxString& name, wxBitmapType type, const wxPoint& hotSpot);
/**
Constructs a cursor using a cursor identifier.
@param cursorId
A stock cursor identifier. See ::wxStockCursor.
*/
wxCursor(wxStockCursor cursorId);
/**
Constructs a cursor from a wxImage. If cursor are monochrome on the
current platform, colors with the RGB elements all greater than 127
will be foreground, colors less than this background. The mask (if any)
will be used to specify the transparent area.
In wxMSW the foreground will be white and the background black.
If the cursor is larger than 32x32 it is resized.
In wxGTK, colour cursors and alpha channel are supported (starting from
GTK+ 2.2). Otherwise the two most frequent colors will be used for
foreground and background. In any case, the cursor will be displayed
at the size of the image.
Under wxMac (Cocoa), large cursors are supported.
Notice that the @a image can define the cursor hot spot. To set it you
need to use wxImage::SetOption() with @c wxIMAGE_OPTION_CUR_HOTSPOT_X
or @c wxIMAGE_OPTION_CUR_HOTSPOT_Y, e.g.
@code
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX);
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotSpotY);
@endcode
*/
wxCursor(const wxImage& image);
/**
Constructs a cursor from XPM data.
In versions of wxWidgets until 3.1.6 constructing wxCursor from XPM
data implicitly used wxImage constructor from XPM data and wxCursor
constructor from wxImage. Since 3.1.6 this constructor overload is
available to allow constructing wxCursor from XPM to still work, even
though wxImage constructor from XPM is now @c explicit.
*/
wxCursor(const char* const* xpmData);
/**
wxGTK-specific constructor from data in XBM format.
The parameters @a fg and @a bg have an effect only on GTK+, and force
the cursor to use particular background and foreground colours.
@param bits
An array of XBM data bits.
@param width
Cursor width.
@param height
Cursor height.
@param hotSpotX
Hotspot x coordinate (relative to the top left of the image).
@param hotSpotY
Hotspot y coordinate (relative to the top left of the image).
@param maskBits
Bits for a mask bitmap.
@param fg
Foreground colour.
@param bg
Background colour.
@onlyfor{wxgtk}
@beginWxPerlOnly
In wxPerl use Wx::Cursor->newData(bits, width, height, hotSpotX = -1, hotSpotY = -1, maskBits = 0).
@endWxPerlOnly
*/
wxCursor(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = nullptr,
const wxColour* fg = nullptr, const wxColour* bg = nullptr);
/**
Copy constructor, uses @ref overview_refcount "reference counting".
@param cursor
Pointer or reference to a cursor to copy.
*/
wxCursor(const wxCursor& cursor);
/**
Returns @true if cursor data is present.
*/
virtual bool IsOk() const;
/**
Returns the coordinates of the cursor hot spot.
The hot spot is the point at which the mouse is actually considered to
be when this cursor is used.
This method is currently implemented in wxMSW, wxGTK and wxOSX (since
wxWidgets 3.3.0) and returns ::wxDefaultPosition in the other ports.
@since 3.1.0
*/
wxPoint GetHotSpot() const;
/**
Assignment operator, using @ref overview_refcount "reference counting".
*/
wxCursor& operator =(const wxCursor& cursor);
};
/**
@name Predefined cursors.
@see wxStockCursor
*/
///@{
wxCursor wxNullCursor;
wxCursor* wxSTANDARD_CURSOR;
wxCursor* wxHOURGLASS_CURSOR;
wxCursor* wxCROSS_CURSOR;
///@}
/**
@class wxCursorBundle
A cursor bundle is a set of different versions of the same cursor at
different sizes.
This class relationship with wxCursor is similar to that of wxBitmapBundle
with wxBitmap, but it has a simpler interface because cursors are never
scaled and always use the closest available size. It is typically used like
the following:
@code
MyFrame::MyFrame()
{
SetCursorBundle(wxCursorBundle(wxBitmapBundle::FromResources("mycursor"),
wxPoint(1, 1)));
}
@endcode
Please see wxBitmapBundle documentation for more information about
different ways of creating it.
@library{wxcore}
@category{gdi}
@since 3.3.0
*/
class wxCursorBundle
{
public:
/**
Default ctor constructs an empty bundle.
Such bundle represents the absence of any custom cursor but not an
empty cursor (::wxCURSOR_BLANK can be used if this is really needed).
You can use the assignment operator to set the bundle contents later.
*/
wxCursorBundle();
/**
Create a cursor bundle from the given bitmap bundle.
@param bitmaps
The bitmap bundle to use for the cursor, typically containing
bitmap in at least two sizes.
@param hotSpot
Hotspot coordinates (relative to the top left of the image).
The coordinates are relative to the default size of the bitmap
bundle and are scaled by wxWidgets for other sizes.
*/
explicit wxCursorBundle(const wxBitmapBundle& bitmaps,
const wxPoint& hotSpot);
/// @overload
explicit wxCursorBundle(const wxBitmapBundle& bitmaps,
int hotSpotX = 0, int hotSpotY = 0);
/**
Copy constructor performs a shallow copy of the bundle.
This operation is cheap as it doesn't copy any bitmaps.
*/
wxCursorBundle(const wxCursorBundle& other);
/**
Assignment operator performs a shallow copy of the bundle.
This operation is cheap as it doesn't copy any bitmaps.
*/
wxCursorBundle& operator=(const wxCursorBundle& other);
/**
Check if cursor bundle is non-empty.
*/
bool IsOk() const;
/**
Clear the bundle contents.
IsOk() will return false after doing this.
Use the assignment operator to set the bundle contents later.
*/
void Clear();
/**
Get the cursor of the size suitable for the given window.
*/
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.
*/
wxCursor GetCursorForMainWindow() const;
/**
Check if two objects refer to the same bundle.
Note that this compares the object identity, i.e. this function returns
@true only for copies of the same bundle, but @false for two bundles
created from the same bitmap bundle and same hotspot coordinates.
*/
bool IsSameAs(const wxCursorBundle& other) const;
};

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/custombgwin.h
// Purpose: Documentation of wxCustomBackgroundWindow.
// Author: Vadim Zeitlin
// Created: 2011-10-10
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
A helper class making it possible to use custom background for any window.
wxWindow itself only provides SetBackgroundColour() method taking a (solid)
wxColour. This class extends it by allowing to use custom bitmap
backgrounds with any window, provided that you inherit from it. Notice that
the usual rule of not interfering with event handling or painting of native
controls still applies, so you shouldn't try to use custom backgrounds with
classes such as wxButton (even if this might work on some platforms, it's
not guaranteed to work in general). But you can use this class in
conjunction with wxWindow, wxPanel, wxFrame and other similar classes, e.g.
the erase sample shows how to use it with wxScrolledWindow:
@code
#include "wx/custombgwin.h"
class MyCanvas : public wxCustomBackgroundWindow<wxScrolledWindow>
{
public:
MyCanvas(wxWindow* parent)
{
// Notice that we must explicitly call base class Create()
// instead of using its ctor as wxCustomBackgroundWindow
// doesn't define any non-default ctors.
Create(parent, wxID_ANY);
...
SetBackgroundBitmap(bitmap);
}
};
@endcode
@category{miscwnd}
@since 2.9.3
*/
template <class W>
class wxCustomBackgroundWindow : public W
{
public:
/// Trivial default constructor.
wxCustomBackgroundWindow();
/**
Set the background bitmap for this window.
If @a bmp is a valid bitmap, this bitmap will be tiled over the panel
background and show through any of its transparent children. Passing an
invalid bitmap reverts to the default background appearance.
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);
};

View File

@@ -0,0 +1,849 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dataobj.h
// Purpose: interface of wx*DataObject
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDataFormat
A wxDataFormat is an encapsulation of a platform-specific format handle
which is used by the system for the clipboard and drag and drop operations.
The applications are usually only interested in, for example, pasting data
from the clipboard only if the data is in a format the program understands
and a data format is something which uniquely identifies this format.
On the system level, a data format is usually just a number (@c CLIPFORMAT
under Windows or @c Atom under X11, for example) and the standard formats
are, indeed, just numbers which can be implicitly converted to wxDataFormat.
The standard formats are:
@beginDefList
@itemdef{wxDF_INVALID,
An invalid format - used as default argument for functions taking
a wxDataFormat argument sometimes.}
@itemdef{wxDF_TEXT,
Text format (wxString).}
@itemdef{wxDF_BITMAP,
A bitmap (wxBitmap).}
@itemdef{wxDF_METAFILE,
A metafile (wxMetafile, Windows only).}
@itemdef{wxDF_UNICODETEXT,
Unicode text format (wxString).}
@itemdef{wxDF_FILENAME,
A list of filenames.}
@itemdef{wxDF_HTML,
An HTML string. This is currently only valid on Mac and MSW.}
@itemdef{wxDF_PNG,
A PNG file. This is valid only on MSW. This constant is available
since wxWidgets 3.1.5.}
@endDefList
As mentioned above, these standard formats may be passed to any function
taking wxDataFormat argument because wxDataFormat has an implicit
conversion from them (or, to be precise from the type
@c wxDataFormat::NativeFormat which is the type used by the underlying
platform for data formats).
Aside the standard formats, the application may also use custom formats
which are identified by their names (strings) and not numeric identifiers.
Although internally custom format must be created (or @e registered) first,
you shouldn't care about it because it is done automatically the first time
the wxDataFormat object corresponding to a given format name is created.
The only implication of this is that you should avoid having global
wxDataFormat objects with non-default constructor because their
constructors are executed before the program has time to perform all
necessary initialisations and so an attempt to do clipboard format
registration at this time will usually lead to a crash!
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, @ref page_samples_dnd, wxDataObject
*/
class wxDataFormat
{
public:
/**
Constructs a data format object for one of the standard data formats or
an empty data object (use SetType() or SetId() later in this case).
@beginWxPerlOnly
In wxPerl use Wx::Bitmap->newNative(format).
@endWxPerlOnly
*/
wxDataFormat(wxDataFormatId format = wxDF_INVALID);
/**
Constructs a data format object for a custom format identified by its
name @a format.
@beginWxPerlOnly
In wxPerl use Wx::Bitmap->newUser(format).
@endWxPerlOnly
*/
wxDataFormat(const wxString& format);
/**
Returns the name of a custom format (this function will fail for a
standard format).
*/
wxString GetId() const;
/**
Returns the platform-specific number identifying the format.
*/
wxDataFormatId GetType() const;
/**
Sets the format to be the custom format identified by the given name.
*/
void SetId(const wxString& format);
/**
Sets the format to the given value, which should be one of wxDF_XXX
constants.
*/
void SetType(wxDataFormatId type);
/**
Returns @true if the formats are different.
*/
bool operator !=(const wxDataFormat& format) const;
/**
Returns @true if the formats are different.
*/
bool operator !=(wxDataFormatId format) const;
/**
Returns @true if the formats are equal.
*/
bool operator ==(const wxDataFormat& format) const;
/**
Returns @true if the formats are equal.
*/
bool operator ==(wxDataFormatId format) const;
};
const wxDataFormat wxFormatInvalid;
/**
@class wxDataObject
A wxDataObject represents data that can be copied to or from the clipboard,
or dragged and dropped. The important thing about wxDataObject is that this
is a 'smart' piece of data unlike 'dumb' data containers such as memory
buffers or files. Being 'smart' here means that the data object itself
should know what data formats it supports and how to render itself in each
of its supported formats.
A supported format, incidentally, is exactly the format in which the data
can be requested from a data object or from which the data object may be
set. In the general case, an object may support different formats on
'input' and 'output', i.e. it may be able to render itself in a given
format but not be created from data on this format or vice versa.
wxDataObject defines the wxDataObject::Direction enumeration type which
distinguishes between them.
See wxDataFormat documentation for more about formats.
Not surprisingly, being 'smart' comes at a price of added complexity. This
is reasonable for the situations when you really need to support multiple
formats, but may be annoying if you only want to do something simple like
cut and paste text.
To provide a solution for both cases, wxWidgets has two predefined classes
which derive from wxDataObject: wxDataObjectSimple and
wxDataObjectComposite. wxDataObjectSimple is the simplest wxDataObject
possible and only holds data in a single format (such as HTML or text) and
wxDataObjectComposite is the simplest way to implement a wxDataObject that
does support multiple formats because it achieves this by simply holding
several wxDataObjectSimple objects.
So, you have several solutions when you need a wxDataObject class (and you
need one as soon as you want to transfer data via the clipboard or drag and
drop):
-# Use one of the built-in classes.
- You may use wxTextDataObject, wxBitmapDataObject wxFileDataObject,
wxURLDataObject in the simplest cases when you only need to support
one format and your data is either text, bitmap or list of files.
-# Use wxDataObjectSimple
- Deriving from wxDataObjectSimple is the simplest solution for custom
data - you will only support one format and so probably won't be able
to communicate with other programs, but data transfer will work in
your program (or between different instances of it).
-# Use wxDataObjectComposite
- This is a simple but powerful solution which allows you to support
any number of formats (either standard or custom if you combine it
with the previous solution).
-# Use wxDataObject directly
- This is the solution for maximum flexibility and efficiency, but it
is also the most difficult to implement.
Please note that the easiest way to use drag and drop and the clipboard
with multiple formats is by using wxDataObjectComposite, but it is not the
most efficient one as each wxDataObjectSimple would contain the whole data
in its respective formats. Now imagine that you want to paste 200 pages of
text in your proprietary format, as well as Word, RTF, HTML, Unicode and
plain text to the clipboard and even today's computers are in trouble. For
this case, you will have to derive from wxDataObject directly and make it
enumerate its formats and provide the data in the requested format on
demand.
Note that neither the GTK+ data transfer mechanisms for clipboard and drag
and drop, nor OLE data transfer, @e copies any data until another application
actually requests the data. This is in contrast to the 'feel' offered to
the user of a program who would normally think that the data resides in the
clipboard after having pressed 'Copy' - in reality it is only declared to
be @e available.
You may also derive your own data object classes from wxCustomDataObject
for user-defined types. The format of user-defined data is given as a
mime-type string literal, such as "application/word" or "image/png". These
strings are used as they are under Unix (so far only GTK+) to identify a
format and are translated into their Windows equivalent under Win32 (using
the OLE IDataObject for data exchange to and from the clipboard and for
drag and drop). Note that the format string translation under Windows is
not yet finished.
Each class derived directly from wxDataObject must override and implement
all of its functions which are pure virtual in the base class. The data
objects which only render their data or only set it (i.e. work in only one
direction), should return 0 from GetFormatCount().
@beginWxPerlOnly
This class is not currently usable from wxPerl; you may use
Wx::PlDataObjectSimple instead.
@endWxPerlOnly
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, @ref page_samples_dnd, wxFileDataObject,
wxTextDataObject, wxBitmapDataObject, wxCustomDataObject,
wxDropTarget, wxDropSource, wxTextDropTarget, wxFileDropTarget
*/
class wxDataObject
{
public:
enum Direction
{
/** Format is supported by GetDataHere() */
Get = 0x01,
/** Format is supported by SetData() */
Set = 0x02,
/**
Format is supported by both GetDataHere() and SetData()
(unused currently)
*/
Both = 0x03
};
/**
Constructor.
*/
wxDataObject();
/**
Destructor.
*/
virtual ~wxDataObject();
/**
Copies all formats supported in the given direction @a dir to the array
pointed to by @a formats.
There must be enough space for GetFormatCount(dir) formats in it.
@beginWxPerlOnly
In wxPerl this method only takes the @a dir parameter. In scalar
context it returns the first format in the list, in list
context it returns a list containing all the supported
formats.
@endWxPerlOnly
*/
virtual void GetAllFormats(wxDataFormat* formats,
Direction dir = Get) const = 0;
/**
The method will write the data of the format @a format to the buffer
@a buf. In other words, copy the data from this object in the given
format to the supplied buffer. Returns @true on success, @false on
failure.
*/
virtual bool GetDataHere(const wxDataFormat& format, void* buf) const = 0;
/**
Returns the data size of the given format @a format.
*/
virtual size_t GetDataSize(const wxDataFormat& format) const = 0;
/**
Returns the number of available formats for rendering or setting the
data.
*/
virtual size_t GetFormatCount(Direction dir = Get) const = 0;
/**
Returns the preferred format for either rendering the data (if @a dir
is @c Get, its default value) or for setting it. Usually this will be
the native format of the wxDataObject.
*/
virtual wxDataFormat GetPreferredFormat(Direction dir = Get) const = 0;
/**
Set the data in the format @a format of the length @a len provided in
the buffer @a buf. In other words, copy length bytes of data from the
buffer to this data object.
@param format
The format for which to set the data.
@param len
The size of data in bytes.
@param buf
Non-@NULL pointer to the data.
@return
@true on success, @false on failure.
*/
virtual bool SetData(const wxDataFormat& format, size_t len, const void* buf);
/**
Returns true if this format is supported.
*/
bool IsSupported(const wxDataFormat& format, Direction dir = Get) const;
};
/**
@class wxCustomDataObject
wxCustomDataObject is a specialization of wxDataObjectSimple for some
application-specific data in arbitrary (either custom or one of the
standard ones). The only restriction is that it is supposed that this data
can be copied bitwise (i.e. with @c memcpy()), so it would be a bad idea to
make it contain a C++ object (though C struct is fine).
By default, wxCustomDataObject stores the data inside in a buffer. To put
the data into the buffer you may use either SetData() or TakeData()
depending on whether you want the object to make a copy of data or not.
This class may be used as is, but if you don't want store the data inside
the object but provide it on demand instead, you should override GetSize(),
GetData() and SetData() (or may be only the first two or only the last one
if you only allow reading/writing the data).
@library{wxcore}
@category{dnd}
@see wxDataObject
*/
class wxCustomDataObject : public wxDataObjectSimple
{
public:
/**
The constructor accepts a @a format argument which specifies the
(single) format supported by this object. If it isn't set here,
wxDataObjectSimple::SetFormat() should be used.
*/
wxCustomDataObject(const wxDataFormat& format = wxFormatInvalid);
/**
The destructor will free the data held by the object. Notice that
although it calls the virtual Free() function, the base class version
will always be called (C++ doesn't allow calling virtual functions from
constructors or destructors), so if you override Free(), you should
override the destructor in your class as well (which would probably
just call the derived class' version of Free()).
*/
virtual ~wxCustomDataObject();
/**
This function is called to allocate @a size bytes of memory from
SetData(). The default version just uses the 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 the data.
*/
virtual void Free();
/**
Returns a pointer to the data.
*/
virtual void* GetData() const;
/**
Returns the data size in bytes.
*/
virtual size_t GetSize() const;
/**
Set the data. The data object will make an internal copy.
*/
virtual bool SetData(size_t size, const void* data);
/**
Like SetData(), but doesn't copy the data - instead the object takes
ownership of the pointer.
*/
void TakeData(size_t size, void* data);
};
/**
@class wxDataObjectComposite
wxDataObjectComposite is the simplest wxDataObject derivation which may be
used to support multiple formats. It contains several wxDataObjectSimple
objects and supports any format supported by at least one of them. Only one
of these data objects is @e preferred (the first one if not explicitly
changed by using the second parameter of Add()) and its format determines
the preferred format of the composite data object as well.
See wxDataObject documentation for the reasons why you might prefer to use
wxDataObject directly instead of wxDataObjectComposite for efficiency
reasons.
This example shows how a composite data object capable of storing either
bitmaps or file names (presumably of bitmap files) can be initialized and
used:
@code
MyDropTarget::MyDropTarget()
{
wxDataObjectComposite* dataobj = new wxDataObjectComposite();
dataobj->Add(new wxBitmapDataObject(), true);
dataobj->Add(new wxFileDataObject());
SetDataObject(dataobj);
}
wxDragResult MyDropTarget::OnData(wxCoord x, wxCoord y,
wxDragResult defaultDragResult)
{
if ( !GetData() )
return wxDragNone;
wxDataObjectComposite *
dataobjComp = static_cast<wxDataObjectComposite *>(GetDataObject());
wxDataFormat format = dataobjComp->GetReceivedFormat();
wxDataObject *dataobj = dataobjComp->GetObject(format);
switch ( format.GetType() )
{
case wxDF_BITMAP:
{
wxBitmapDataObject *
dataobjBitmap = static_cast<wxBitmapDataObject *>(dataobj);
... use dataobj->GetBitmap() ...
}
break;
case wxDF_FILENAME:
{
wxFileDataObject *
dataobjFile = static_cast<wxFileDataObject *>(dataobj);
... use dataobj->GetFilenames() ...
}
break;
default:
wxFAIL_MSG( "unexpected data object format" );
}
return defaultDragResult;
}
@endcode
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, wxDataObject, wxDataObjectSimple, wxFileDataObject,
wxTextDataObject, wxBitmapDataObject
*/
class wxDataObjectComposite : public wxDataObject
{
public:
/**
The default constructor.
*/
wxDataObjectComposite();
/**
Adds the @a dataObject to the list of supported objects and it becomes
the preferred object if @a preferred is @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 the passed format for
the specified direction.
@NULL is returned if the specified @a format is not supported for this
direction @a dir. The returned pointer is owned by wxDataObjectComposite
itself and shouldn't be deleted by caller.
@since 2.9.1
*/
wxDataObjectSimple *GetObject(const wxDataFormat& format,
wxDataObject::Direction dir = wxDataObject::Get) const;
};
/**
@class wxDataObjectSimple
This is the simplest possible implementation of the wxDataObject class.
The data object of (a class derived from) this class only supports
<strong>one format</strong>, so the number of virtual functions to
be implemented is reduced.
Notice that this is still an abstract base class and cannot be used
directly, it must be derived. The objects supporting rendering the data
must override GetDataSize() and GetDataHere() while the objects which may
be set must override SetData(). Of course, the objects supporting both
operations must override all three methods.
@beginWxPerlOnly
In wxPerl, you need to derive your data object class from
Wx::PlDataObjectSimple.
@endWxPerlOnly
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, @ref page_samples_dnd, wxFileDataObject,
wxTextDataObject, wxBitmapDataObject
*/
class wxDataObjectSimple : public wxDataObject
{
public:
/**
Constructor accepts the supported format (none by default) which may
also be set later with SetFormat().
*/
wxDataObjectSimple(const wxDataFormat& format = wxFormatInvalid);
/**
Copy the data to the buffer, return @true on success.
Must be implemented in the derived class if the object supports rendering
its data.
*/
virtual bool GetDataHere(void* buf) const;
/**
Gets the size of our data. Must be implemented in the derived class if
the object supports rendering its data.
*/
virtual size_t GetDataSize() const;
/**
Returns the (one and only one) format supported by this object.
It is assumed that the format is supported in both directions.
*/
const wxDataFormat& GetFormat() const;
/**
Copy the data from the buffer, return @true on success.
Must be implemented in the derived class if the object supports setting
its data.
*/
virtual bool SetData(size_t len, const void* buf);
/**
Sets the supported format.
*/
void SetFormat(const wxDataFormat& format);
};
/**
@class wxBitmapDataObject
wxBitmapDataObject is a specialization of wxDataObject for bitmap data. It
can be used without change to paste data into the wxClipboard or a
wxDropSource. A user may wish to derive a new class from this class for
providing a bitmap on-demand in order to minimize memory consumption when
offering data in several formats, such as a bitmap and GIF.
This class may be used as is, but GetBitmap() may be overridden to increase
efficiency.
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, wxDataObject, wxDataObjectSimple, wxFileDataObject,
wxTextDataObject, wxDataObject
*/
class wxBitmapDataObject : public wxDataObjectSimple
{
public:
/**
Constructor, optionally passing a bitmap (otherwise use SetBitmap()
later).
*/
wxBitmapDataObject(const wxBitmap& bitmap = wxNullBitmap);
/**
Returns the bitmap associated with the data object. You may wish to
override this method when offering data on-demand, but this is not
required by wxWidgets' internals. Use this method to get data in bitmap
form from the wxClipboard.
*/
virtual wxBitmap GetBitmap() const;
/**
Sets the bitmap associated with the data object. This method is called
when the data object receives data. Usually there will be no reason to
override this function.
*/
virtual void SetBitmap(const wxBitmap& bitmap);
};
/**
@class wxImageDataObject
wxImageDataObject is a specialization of wxDataObject for image data.
It can be used e.g. when you need to put on and retrieve from the clipboard
a wxImage with its metadata (like image resolution).
@since 3.1.5
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, wxDataObject, wxCustomDataObject, wxBitmapDataObject
*/
class wxImageDataObject : public wxCustomDataObject
{
public:
/**
Constructor, optionally passing an image (otherwise use SetImage()
later).
*/
explicit wxImageDataObject(const wxImage& image = wxNullImage);
/**
Returns the image associated with the data object.
*/
wxImage GetImage() const;
/**
Sets the image stored by the data object.
*/
void SetImage(const wxImage& image);
};
/**
@class wxURLDataObject
wxURLDataObject is a wxDataObject containing an URL and can be used e.g.
when you need to put an URL on or retrieve it from the clipboard:
@code
wxTheClipboard->SetData(new wxURLDataObject(url));
@endcode
@note The actual base class of this class is not always wxDataObject
itself, but rather either wxDataObjectComposite in wxMSW and wxGTK or
wxTextDataObject in the other ports. Please don't rely on the exact
base class, it is not guaranteed that it won't change in the future.
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, wxDataObject
*/
class wxURLDataObject: public wxDataObject
{
public:
/**
Constructor, may be used to initialize the URL. If @a url is empty,
SetURL() can be used later.
*/
wxURLDataObject(const wxString& url = wxEmptyString);
/**
Returns the URL stored by this object, as a string.
*/
wxString GetURL() const;
/**
Sets the URL stored by this object.
*/
void SetURL(const wxString& url);
};
/**
@class wxTextDataObject
wxTextDataObject is a specialization of wxDataObjectSimple for text data.
It can be used without change to paste data into the wxClipboard or a
wxDropSource. A user may wish to derive a new class from this class for
providing text on-demand in order to minimize memory consumption when
offering data in several formats, such as plain text and RTF because by
default the text is stored in a string in this class, but it might as well
be generated when requested, in which case GetText() should be overridden.
Note that if you already have the text inside a string, you will not
achieve any efficiency gain by overriding these functions because copying
wxStrings is already a very efficient operation (data is not actually
copied because wxStrings are reference counted).
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, wxDataObject, wxDataObjectSimple, wxFileDataObject,
wxBitmapDataObject
*/
class wxTextDataObject : public wxDataObjectSimple
{
public:
/**
Constructor, may be used to initialise the text (otherwise SetText()
should be used later).
*/
wxTextDataObject(const wxString& text = wxEmptyString);
/**
Returns the text associated with the data object. You may wish to
override this method when offering data on-demand, but this is not
required by wxWidgets' internals. Use this method to get data in text
form from the wxClipboard.
*/
virtual wxString GetText() const;
/**
@deprecated
Don't use or call this function, it simply returns the length of the
text plus one for compatibility purposes.
*/
size_t GetTextLength() const;
/**
Returns 2 under wxMac and wxGTK, where text data coming from the
clipboard may be provided as ANSI (@c wxDF_TEXT) or as Unicode text
(@c wxDF_UNICODETEXT).
Returns 1 under other platforms (e.g. wxMSW).
*/
virtual size_t GetFormatCount(wxDataObject::Direction dir = wxDataObject::Get) const;
/**
Returns the preferred format supported by this object.
This is @c wxDF_TEXT or @c wxDF_UNICODETEXT depending on the platform.
*/
const wxDataFormat& GetFormat() const;
/**
Returns all the formats supported by wxTextDataObject.
Under wxMac and wxGTK they are @c wxDF_TEXT and @c wxDF_UNICODETEXT,
under other ports returns only one of the two, depending on the build mode.
*/
virtual void GetAllFormats(wxDataFormat* formats,
wxDataObject::Direction dir = wxDataObject::Get) const;
/**
Sets the text associated with the data object. This method is called
when the data object receives the data and, by default, copies the text
into the member variable. If you want to process the text on the fly
you may wish to override this function.
*/
virtual void SetText(const wxString& strText);
};
/**
@class wxFileDataObject
wxFileDataObject is a specialization of wxDataObject for file names. The
program works with it just as if it were a list of absolute file names, but
internally it uses the same format as Explorer and other compatible
programs under Windows or GNOME/KDE file manager under Unix which makes it
possible to receive files from them using this class.
@library{wxcore}
@category{dnd}
@see wxDataObject, wxDataObjectSimple, wxTextDataObject,
wxBitmapDataObject, wxDataObject
*/
class wxFileDataObject : public wxDataObjectSimple
{
public:
/**
Constructor.
*/
wxFileDataObject();
/**
Adds a file to the file list represented by this data object (Windows only).
*/
void AddFile(const wxString& file);
/**
Returns the array of file names.
*/
const wxArrayString& GetFilenames() const;
};
/**
@class wxHTMLDataObject
wxHTMLDataObject is used for working with HTML-formatted text.
@library{wxcore}
@category{dnd}
@see wxDataObject, wxDataObjectSimple
*/
class wxHTMLDataObject : public wxDataObjectSimple
{
public:
/**
Constructor.
*/
wxHTMLDataObject(const wxString& html = wxEmptyString);
/**
Returns the HTML string.
*/
virtual wxString GetHTML() const;
/**
Sets the HTML string.
*/
virtual void SetHTML(const wxString& html);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,219 @@
/////////////////////////////////////////////////////////////////////////////
// Name: datectrl.h
// Purpose: interface of wxDatePickerCtrl
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/// 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
};
/**
@class wxDatePickerCtrl
This control allows the user to select a date. Unlike wxCalendarCtrl, which
is a relatively big control, wxDatePickerCtrl is implemented as a small
window showing the currently selected date. The control can be edited using
the keyboard, and can also display a popup window for more user-friendly
date selection, depending on the styles used and the platform.
It is only available if @c wxUSE_DATEPICKCTRL is set to 1.
@beginStyleTable
@style{wxDP_SPIN}
Creates a control without a month calendar drop down but with
spin-control-like arrows to change individual date components. This
style is not supported by the generic version.
@style{wxDP_DROPDOWN}
Creates a control with a month calendar drop-down part from which
the user can select a date. In OSX/Cocoa native version this
style is supported on macOS 10.15.4 and later.
@style{wxDP_DEFAULT}
Creates a control with the style that is best supported for the
current platform (currently wxDP_SPIN under Windows and OSX/Cocoa
and wxDP_DROPDOWN elsewhere).
@style{wxDP_ALLOWNONE}
With this style, the control allows the user to not enter any valid
date at all. Without it - the default - the control always has some
valid date. This style is not supported in OSX/Cocoa native version.
@style{wxDP_SHOWCENTURY}
Forces display of the century in the default date format. Without
this style the century could be displayed, or not, depending on the
default date representation in the system. This style is not
supported in OSX/Cocoa native version currently.
@endStyleTable
As can be seen from the remarks above, most of the control style are only
supported in the native MSW implementation. In portable code it's
recommended to use @c wxDP_DEFAULT style only, possibly combined with @c
wxDP_SHOWCENTURY (this is also the style used by default if none is
specified).
@note In wxMSW this control uses default user date format even if
wxUILocale::UseDefault() hasn't been called, while under the other
platforms it only does it if the default UI locale has been set.
For applications targeting international users, it is strongly
recommended to call wxUILocale::UseDefault() to ensure that the
behaviour is consistent across all platforms.
@beginEventEmissionTable{wxDateEvent}
@event{EVT_DATE_CHANGED(id, func)}
Process a wxEVT_DATE_CHANGED event, which fires when the user
changes the current selection in the control.
@endEventTable
@library{wxcore}
@category{pickers}
@appearance{datepickerctrl}
@see wxTimePickerCtrl, wxCalendarCtrl, wxDateEvent
*/
class wxDatePickerCtrl : public wxControl
{
public:
/**
Default constructor.
*/
wxDatePickerCtrl();
/**
Initializes the object and calls Create() with all the parameters.
*/
wxDatePickerCtrl(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 = "datectrl");
/**
Create the control window.
This method should only be used for objects created using default
constructor.
@param parent
Parent window, must not be non-null.
@param id
The identifier for the control.
@param dt
The initial value of the control, if an invalid date (such as the
default value) is used, the control is set to today.
@param pos
Initial position.
@param size
Initial size. If left at default value, the control chooses its own
best size by using the height approximately equal to a text control
and width large enough to show the date string fully.
@param style
The window style, see the description of the styles in the class
documentation.
@param validator
Validator which can be used for additional data checks.
@param name
Control name.
@return @true if the control was successfully created or @false if
creation failed.
*/
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 = "datectrl");
/**
If the control had been previously limited to a range of dates using
SetRange(), returns the lower and upper bounds of this range. If no
range is set (or only one of the bounds is set), @a dt1 and/or @a dt2
are set to be invalid.
Notice that when using a native MSW implementation of this control the
lower range is always set, even if SetRange() hadn't been called
explicitly, as the native control only supports dates later than year
1601.
@param dt1
Pointer to the object which receives the lower range limit or
becomes invalid if it is not set. May be @NULL if the caller is not
interested in lower limit.
@param dt2
Same as above but for the upper limit.
@return @false if no range limits are currently set, @true if at least
one bound is set.
*/
virtual bool GetRange(wxDateTime* dt1, wxDateTime* dt2) const;
/**
Returns the currently entered date.
For a control with @c wxDP_ALLOWNONE style the returned value may be
invalid if no date is entered, otherwise it is always valid.
*/
virtual wxDateTime GetValue() const;
/**
Set the text to show when there is no valid value.
For the controls with @c 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.
Notably, @a text can be empty to completely hide the date if no valid
date is specified.
@since 3.1.5
*/
void SetNullText(const wxString& text);
/**
Sets the valid range for the date selection. If @a dt1 is valid, it
becomes the earliest date (inclusive) accepted by the control. If
@a dt2 is valid, it becomes the latest possible date.
Notice that if the current value is not inside the new range, it will
be adjusted to lie inside it, i.e. calling this method can change the
control value, however no events are generated by it.
@remarks If the current value of the control is outside of the newly
set range bounds, the behaviour is undefined.
*/
virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2);
/**
Changes the current value of the control.
The date should be valid unless the control was created with @c
wxDP_ALLOWNONE style and included in the currently selected range, if
any.
Calling this method does not result in a date change event.
*/
virtual void SetValue(const wxDateTime& dt);
};

View File

@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dateevt.h
// Purpose: interface of wxDateEvent
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDateEvent
This event class holds information about a date change and is used together
with wxDatePickerCtrl. It also serves as a base class
for wxCalendarEvent.
@library{wxcore}
@category{events}
*/
class wxDateEvent : public wxCommandEvent
{
public:
wxDateEvent();
wxDateEvent(wxWindow *win, const wxDateTime& dt, wxEventType type);
/**
Returns the date.
*/
const wxDateTime& GetDate() const;
/**
Sets the date carried by the event, normally only used by the library
internally.
*/
void SetDate(const wxDateTime& date);
};
wxEventType wxEVT_DATE_CHANGED;
wxEventType wxEVT_TIME_CHANGED;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,410 @@
/////////////////////////////////////////////////////////////////////////////
// Name: datstrm.h
// Purpose: interface of wxDataInputStream and wxDataOutputStream
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDataOutputStream
This class provides functions that write binary data types in a portable
way.
Data can be written in either big-endian or little-endian format,
little-endian being the default on all architectures but BigEndianOrdered()
can be used to change this. The default format for the floating point types
is 80 bit "extended precision" unless @c wxUSE_APPLE_IEEE was turned off
during the library compilation, in which case extended precision is not
available at all. You can call UseBasicPrecisions() to change this and
use the standard IEEE 754 32 bit single precision format for floats and
standard 64 bit double precision format for doubles. This is recommended
for the new code for better interoperability with other software that
typically uses standard IEEE 754 formats for its data, the use of extended
precision by default is solely due to backwards compatibility.
If you want to write data to text files (or streams) use wxTextOutputStream
instead.
The "<<" operator is overloaded and you can use this class like a standard
C++ iostream. See wxDataInputStream for its usage and caveats.
@library{wxbase}
@category{streams}
@see wxDataInputStream
*/
class wxDataOutputStream
{
public:
/**
Constructs a datastream object from an output stream.
Only write methods will be available.
@param stream
The output stream.
@param conv
Charset conversion object used to encoding strings
before writing them to the stream (see
WriteString() for a detailed description). Note that you must not
destroy @a conv before you destroy this wxDataOutputStream
instance! It is recommended to use the default value (UTF-8).
*/
wxDataOutputStream(wxOutputStream& stream,
const wxMBConv& conv = wxConvUTF8);
/**
Destroys the wxDataOutputStream object.
*/
~wxDataOutputStream();
/**
If @a be_order is @true, all data will be written in big-endian order,
e.g. for reading on a Sparc or from Java-Streams (which always use
big-endian order), otherwise data will be written in little-endian
order.
*/
void BigEndianOrdered(bool be_order);
/**
Returns the current text conversion class used for
writing strings.
*/
wxMBConv *GetConv() const;
/**
Sets the text conversion class used for writing strings.
*/
void SetConv( const wxMBConv &conv );
/**
Disables the use of extended precision format for floating point
numbers.
This method disables the use of 80 bit extended precision format for
the @c float and @c double values written to the stream, which is used
by default (unless @c wxUSE_APPLE_IEEE was set to @c 0 when building
the library, in which case the extended format support is not available
at all and this function does nothing).
After calling it, @c float values will be written out in one of IEEE
754 "basic formats", i.e. 32 bit single precision format for floats and
64 bit double precision format for doubles.
@since 2.9.5
*/
void UseBasicPrecisions();
/**
Explicitly request the use of extended precision for floating point
numbers.
This function allows the application code to explicitly request the use
of 80 bit extended precision format for the floating point numbers.
This is the case by default but using this function explicitly ensures
that the compilation of code relying on producing the output stream
using extended precision would fail when using a version of wxWidgets
compiled with @c wxUSE_APPLE_IEEE==0 and so not supporting this format
at all.
@since 2.9.5
*/
void UseExtendedPrecision();
/**
Writes the single byte @a i8 to the stream.
*/
void Write8(wxUint8 i8);
/**
Writes an array of bytes to the stream. The number of bytes to write is
specified with the @a size variable.
*/
void Write8(const wxUint8* buffer, size_t size);
/**
Writes the 16 bit unsigned integer @a i16 to the stream.
*/
void Write16(wxUint16 i16);
/**
Writes an array of 16 bit unsigned integer to the stream. The number of
16 bit unsigned integer to write is specified with the @a size variable.
*/
void Write16(const wxUint16* buffer, size_t size);
/**
Writes the 32 bit unsigned integer @a i32 to the stream.
*/
void Write32(wxUint32 i32);
/**
Writes an array of 32 bit unsigned integer to the stream. The number of
32 bit unsigned integer to write is specified with the @a size variable.
*/
void Write32(const wxUint32* buffer, size_t size);
/**
Writes the 64 bit unsigned integer @a i64 to the stream.
*/
void Write64(wxUint64 i64);
/**
Writes an array of 64 bit unsigned integer to the stream. The number of
64 bit unsigned integer to write is specified with the @a size variable.
*/
void Write64(const wxUint64* buffer, size_t size);
/**
Writes the float @a f to the stream.
If UseBasicPrecisions() had been called, the value is written out using
the standard IEEE 754 32 bit single precision format. Otherwise, this
method uses the same format as WriteDouble(), i.e. 80 bit extended
precision representation.
@since 2.9.5
*/
void WriteFloat(float f);
/**
Writes an array of float to the stream. The number of floats to write is
specified by the @a size variable.
@since 2.9.5
*/
void WriteFloat(const float* buffer, size_t size);
/**
Writes the double @a d to the stream.
The output format is either 80 bit extended precision or, if
UseBasicPrecisions() had been called, standard IEEE 754 64 bit double
precision.
*/
void WriteDouble(double d);
/**
Writes an array of double to the stream. The number of doubles to write is
specified by the @a size variable.
*/
void WriteDouble(const double* buffer, size_t size);
/**
Writes @a string to the stream. Actually, this method writes the size
of the string before writing @a string itself.
The string is converted to multibyte representation with @e conv object
passed to stream's constructor and this representation is written to
the stream. UTF-8 is used by default.
*/
void WriteString(const wxString& string);
};
/**
@class wxDataInputStream
This class provides functions that read binary data types in a portable
way.
Please see wxDataOutputStream for the discussion of the format expected by
this stream on input, notably for the floating point values.
If you want to read data from text files (or streams) use wxTextInputStream
instead.
The ">>" operator is overloaded and you can use this class like a standard
C++ iostream. Note, however, that the arguments are the fixed size types
wxUint32, wxInt32 etc and on a typical 32-bit computer, none of these match
to the "long" type (wxInt32 is defined as signed int on 32-bit
architectures) so that you cannot use long. To avoid problems (here and
elsewhere), make use of the wxInt32, wxUint32, etc types.
For example:
@code
wxFileInputStream input( "mytext.dat" );
wxDataInputStream store( input );
wxUint8 i1;
float f2;
wxString line;
store >> i1; // read a 8 bit integer.
store >> i1 >> f2; // read a 8 bit integer followed by float.
store >> line; // read a text line
@endcode
@library{wxbase}
@category{streams}
@see wxDataOutputStream
*/
class wxDataInputStream
{
public:
/**
Constructs a datastream object from an input stream.
Only read methods will be available.
@param stream
The input stream.
@param conv
Charset conversion object used to decode strings
(see ReadString() for a detailed description). Note that you
must not destroy @a conv before you destroy this wxDataInputStream
instance!
*/
wxDataInputStream(wxInputStream& stream,
const wxMBConv& conv = wxConvUTF8 );
/**
Destroys the wxDataInputStream object.
*/
~wxDataInputStream();
/**
If @a be_order is @true, all data will be read in big-endian order,
such as written by programs on a big endian architecture (e.g. Sparc)
or written by Java-Streams (which always use big-endian order).
*/
void BigEndianOrdered(bool be_order);
/**
Returns the current text conversion class used for
reading strings.
*/
wxMBConv *GetConv() const;
/**
Reads a single byte from the stream.
*/
wxUint8 Read8();
/**
Reads bytes from the stream in a specified buffer. The number of bytes
to read is specified by the @a size variable.
*/
void Read8(wxUint8* buffer, size_t size);
/**
Reads a 16 bit unsigned integer from the stream.
*/
wxUint16 Read16();
/**
Reads 16 bit unsigned integers from the stream in a specified buffer.
The number of 16 bit unsigned integers to read is specified by the
@a size variable.
*/
void Read16(wxUint16* buffer, size_t size);
/**
Reads a 32 bit unsigned integer from the stream.
*/
wxUint32 Read32();
/**
Reads 32 bit unsigned integers from the stream in a specified buffer.
The number of 32 bit unsigned integers to read is specified by the
@a size variable.
*/
void Read32(wxUint32* buffer, size_t size);
/**
Reads a 64 bit unsigned integer from the stream.
*/
wxUint64 Read64();
/**
Reads 64 bit unsigned integers from the stream in a specified buffer.
The number of 64 bit unsigned integers to read is specified by the
@a size variable.
*/
void Read64(wxUint64* buffer, size_t size);
/**
Reads a float from the stream.
Notice that if UseBasicPrecisions() hadn't been called, this function
simply reads a double and truncates it to float as by default the same
(80 bit extended precision) representation is used for both float and
double values.
@since 2.9.5
*/
float ReadFloat();
/**
Reads float data from the stream in a specified buffer.
The number of floats to read is specified by the @a size variable.
@since 2.9.5
*/
void ReadFloat(float* buffer, size_t size);
/**
Reads a double from the stream.
The expected format is either 80 bit extended precision or, if
UseBasicPrecisions() had been called, standard IEEE 754 64 bit double
precision.
*/
double ReadDouble();
/**
Reads double data from the stream in a specified buffer.
The number of doubles to read is specified by the @a size variable.
*/
void ReadDouble(double* buffer, size_t size);
/**
Reads a string from a stream. Actually, this function first reads a
long integer specifying the length of the string (without the last null
character) and then reads the string.
The function reads all bytes until the next `NUL` one from the stream
and uses the @e conv object passed to constructor to convert them to
text, which is then returned as wxString. You are responsible for using
the same converter as when writing the stream, as the information about
the encoding is not stored in the stream itself.
@see wxDataOutputStream::WriteString()
*/
wxString ReadString();
/**
Sets the text conversion class used for reading strings.
*/
void SetConv( const wxMBConv &conv );
/**
Disables the use of extended precision format for floating point
numbers.
This method disables the use of 80 bit extended precision format for
the @c float and @c double values read from the stream, which is used
by default (unless @c wxUSE_APPLE_IEEE was set to @c 0 when building
the library, in which case the extended format support is not available
at all and this function does nothing).
After calling it, @c float values will be expected to appear in one of
IEEE 754 "basic formats", i.e. 32 bit single precision format for
floats and 64 bit double precision format for doubles in the input.
@since 2.9.5
*/
void UseBasicPrecisions();
/**
Explicitly request the use of extended precision for floating point
numbers.
This function allows the application code to explicitly request the use
of 80 bit extended precision format for the floating point numbers.
This is the case by default but using this function explicitly ensures
that the compilation of code relying on reading the input containing
numbers in extended precision format would fail when using a version of
wxWidgets compiled with @c wxUSE_APPLE_IEEE==0 and so not supporting
this format at all.
@since 2.9.5
*/
void UseExtendedPrecision();
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,229 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcbuffer.h
// Purpose: interface of wxBufferedDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Assumes the buffer bitmap covers the entire scrolled window,
// and prepares the window DC accordingly
#define wxBUFFER_VIRTUAL_AREA 0x01
// Assumes the buffer bitmap only covers the client area;
// does not prepare the window DC
#define wxBUFFER_CLIENT_AREA 0x02
// Set when not using specific buffer bitmap. Note that this
// is private style and not returned by GetStyle.
#define wxBUFFER_USES_SHARED_BUFFER 0x04
/**
@class wxBufferedDC
This class provides a simple way to avoid flicker: when drawing on it,
everything is in fact first drawn on an in-memory buffer (a wxBitmap) and
then copied to the screen, using the associated wxDC, only once, when this
object is destroyed. wxBufferedDC itself is typically associated with
wxClientDC, if you want to use it in your @c EVT_PAINT handler, you should
look at wxBufferedPaintDC instead.
When used like this, a valid @e DC must be specified in the constructor
while the @e buffer bitmap doesn't have to be explicitly provided, by
default this class will allocate the bitmap of required size itself.
However using a dedicated bitmap can speed up the redrawing process by
eliminating the repeated creation and destruction of a possibly big bitmap.
Otherwise, wxBufferedDC can be used in the same way as any other device
context.
Another possible use for wxBufferedDC is to use it to maintain a
backing store for the window contents. In this case, the associated @e DC
may be @NULL but a valid backing store bitmap should be specified.
Finally, please note that GTK+ 2.0 as well as macOS provide double buffering
themselves natively. You can either use wxWindow::IsDoubleBuffered() to
determine whether you need to use buffering or not, or use
wxAutoBufferedPaintDC to avoid needless double buffering on the systems
which already do it automatically.
@library{wxcore}
@category{dc}
@see wxDC, wxMemoryDC, wxBufferedPaintDC, wxAutoBufferedPaintDC
*/
class wxBufferedDC : public wxMemoryDC
{
public:
/**
Default constructor. You must call one of the Init() methods later in
order to use the device context.
*/
wxBufferedDC();
/**
Creates a buffer for the provided @a dc. Init() must not be called when
using this constructor.
@param dc
The underlying DC: everything drawn to this object will be flushed
to this DC when this object is destroyed. You may pass @NULL in
order to just initialize the buffer, and not flush it.
@param area
The size of the bitmap to be used for buffering (this bitmap is
created internally when it is not given explicitly).
@param style
wxBUFFER_CLIENT_AREA to indicate that just the client area of the
window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the
buffer bitmap covers the virtual area.
*/
wxBufferedDC(wxDC* dc, const wxSize& area,
int style = wxBUFFER_CLIENT_AREA);
/**
Creates a buffer for the provided dc. Init() must not be called when
using this constructor.
@param dc
The underlying DC: everything drawn to this object will be flushed
to this DC when this object is destroyed. You may pass @NULL in
order to just initialize the buffer, and not flush it.
@param buffer
Explicitly provided bitmap to be used for buffering: this is the
most efficient solution as the bitmap doesn't have to be recreated
each time but it also requires more memory as the bitmap is never
freed. The bitmap should have appropriate size, anything drawn
outside of its bounds is clipped.
@param style
wxBUFFER_CLIENT_AREA to indicate that just the client area of the
window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the
buffer bitmap covers the virtual area.
*/
wxBufferedDC(wxDC* dc, wxBitmap& buffer = wxNullBitmap,
int style = wxBUFFER_CLIENT_AREA);
/**
Copies everything drawn on the DC so far to the underlying DC
associated with this object, if any.
*/
virtual ~wxBufferedDC();
///@{
/**
Initializes the object created using the default constructor. Please
see the constructors for parameter details.
*/
void Init(wxDC* dc, const wxSize& area,
int style = wxBUFFER_CLIENT_AREA);
void Init(wxDC* dc, wxBitmap& buffer = wxNullBitmap,
int style = wxBUFFER_CLIENT_AREA);
///@}
/**
Blits the buffer to the dc, and detaches the dc from the buffer (so it
can be effectively used once only).
Usually only called in the destructor or by the destructor of derived
classes if the BufferedDC must blit before the derived class (which may
own the dc it's blitting to) is destroyed.
*/
void UnMask();
/**
Set the style.
*/
void SetStyle(int style);
/**
Get the style.
*/
int GetStyle() const;
};
/**
@class wxAutoBufferedPaintDC
This wxDC derivative can be used inside of an @c EVT_PAINT() event handler
to achieve double-buffered drawing. Just use this class instead of
wxPaintDC and make sure wxWindow::SetBackgroundStyle() is called with
wxBG_STYLE_PAINT somewhere in the class initialization code, and that's
all you have to do to (mostly) avoid flicker.
The difference between wxBufferedPaintDC and this class is that this class
won't double-buffer on platforms which have native double-buffering
already, avoiding any unnecessary buffering to avoid flicker.
wxAutoBufferedPaintDC is simply a typedef of wxPaintDC on platforms that
have native double-buffering, otherwise, it is a typedef of
wxBufferedPaintDC.
@library{wxcore}
@category{dc}
@see wxDC, wxBufferedPaintDC, wxPaintDC
*/
class wxAutoBufferedPaintDC : public wxBufferedPaintDC
{
public:
/**
Constructor. Pass a pointer to the window on which you wish to paint.
*/
wxAutoBufferedPaintDC(wxWindow* window);
};
/**
* Check if the window is natively double buffered and will return a wxPaintDC
* if it is, a wxBufferedPaintDC otherwise. It is the caller's responsibility
* to delete the wxDC pointer when finished with it.
*/
wxDC* wxAutoBufferedPaintDCFactory(wxWindow* window);
/**
@class wxBufferedPaintDC
This is a subclass of wxBufferedDC which can be used inside of an
@c EVT_PAINT() event handler to achieve double-buffered drawing. Just use
this class instead of wxPaintDC and make sure
wxWindow::SetBackgroundStyle() is called with wxBG_STYLE_PAINT somewhere
in the class initialization code, and that's all you have to do to (mostly)
avoid flicker. The only thing to watch out for is that if you are using
this class together with wxScrolled, you probably do @b not want to call
wxScrolled::PrepareDC() on it as it already does this internally for the
real underlying wxPaintDC.
@library{wxcore}
@category{dc}
@see wxDC, wxBufferedDC, wxAutoBufferedPaintDC, wxPaintDC
*/
class wxBufferedPaintDC : public wxBufferedDC
{
public:
///@{
/**
As with wxBufferedDC, you may either provide the bitmap to be used for
buffering or let this object create one internally (in the latter case,
the size of the client part of the window is used).
Pass wxBUFFER_CLIENT_AREA for the @a style parameter to indicate that
just the client area of the window is buffered, or
wxBUFFER_VIRTUAL_AREA to indicate that the buffer bitmap covers the
virtual area.
*/
wxBufferedPaintDC(wxWindow* window, wxBitmap& buffer,
int style = wxBUFFER_CLIENT_AREA);
wxBufferedPaintDC(wxWindow* window,
int style = wxBUFFER_CLIENT_AREA);
///@}
/**
Copies everything drawn on the DC so far to the window associated with
this object, using a wxPaintDC.
*/
virtual ~wxBufferedPaintDC();
};

View File

@@ -0,0 +1,133 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcclient.h
// Purpose: interface of wxClientDC and wxPaintDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxPaintDC
A wxPaintDC must be constructed if an application wishes to paint on the
client area of a window from within an EVT_PAINT() event handler. This
should normally be constructed as a temporary stack object; don't store a
wxPaintDC object. If you have an EVT_PAINT() handler, you @e must create a
wxPaintDC object within it even if you don't actually use it.
Using wxPaintDC within your EVT_PAINT() handler is important because it
automatically sets the clipping area to the damaged area of the window.
Attempts to draw outside this area do not appear.
A wxPaintDC object is initialized to use the same font and colours as the
window it is associated with.
@library{wxcore}
@category{dc}
@see wxDC, wxMemoryDC
*/
class wxPaintDC : public wxClientDC
{
public:
/**
Constructor. Pass a pointer to the window on which you wish to paint.
*/
wxPaintDC(wxWindow* window);
};
/**
@class wxClientDC
Deprecated class for drawing on the client area of a window.
wxClientDC should not be used any longer, please use wxInfoDC instead for
obtaining information about the device context associated with a window.
@note While wxClientDC may also be used for drawing on the client area of a
window from outside an EVT_PAINT() handler in some ports, this does @em not
work on most of the platforms: neither wxOSX nor wxGTK with GTK 3 Wayland
backend support this at all, so drawing using wxClientDC simply doesn't
have any effect there. CanBeUsedForDrawing() can be used to determine
whether wxClientDC can be used for drawing in the current environment, but
it is recommended to only draw on the window using wxPaintDC, as this is
guaranteed to work everywhere. To redraw a small part of the window, use
wxWindow::RefreshRect() to invalidate just this part and check
wxWindow::GetUpdateRegion() in the paint event handler to redraw this part
only.
wxClientDC objects should normally be constructed as temporary stack
objects, i.e. don't store a wxClientDC object.
A wxClientDC object is initialized to use the same font and colours as the
window it is associated with.
@library{wxcore}
@category{dc}
@see wxDC, wxMemoryDC, wxPaintDC, wxWindowDC
*/
class wxClientDC : public wxWindowDC
{
public:
/**
Constructor. Pass a pointer to the window on which you wish to paint.
*/
wxClientDC(wxWindow* window);
/**
Return true if drawing on wxClientDC actually works.
In many environments (currently this includes wxGTK when using Wayland
backend, wxMSW when using double buffering and wxOSX in all cases),
wxClientDC can be only used for obtaining information about the device
context, but not for actually drawing on it. Portable code should avoid
using wxClientDC completely, as explained in the class documentation,
but it is also possible to optionally use it only when it does work,
i.e. when this function returns @true.
@param window The window that would be used with wxClientDC.
@since 3.3.0
*/
static bool CanBeUsedForDrawing(const wxWindow* window);
};
/**
@class wxWindowDC
Deprecated class for drawing on the entire window.
Please don't use this class in the new code, as it doesn't work on modern
systems any longer and using it is not guaranteed to have any effect at all.
A wxWindowDC must be constructed if an application wishes to paint on the
whole area of a window (client and decorations). This should normally be
constructed as a temporary stack object; don't store a wxWindowDC object.
To draw on a window from inside an EVT_PAINT() handler, construct a
wxPaintDC object instead.
To draw on the client area of a window from outside an EVT_PAINT() handler,
construct a wxClientDC object.
A wxWindowDC object is initialized to use the same font and colours as the
window it is associated with.
@library{wxcore}
@category{dc}
@see wxDC, wxMemoryDC, wxPaintDC, wxClientDC
*/
class wxWindowDC : public wxDC
{
public:
/**
Constructor. Pass a pointer to the window on which you wish to paint.
*/
wxWindowDC(wxWindow* window);
};

View File

@@ -0,0 +1,112 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcgraph.h
// Purpose: interface of wxGCDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxGCDC
wxGCDC is a device context that draws on a wxGraphicsContext.
wxGCDC does its best to implement wxDC API, but the following features are
not (fully) implemented because wxGraphicsContext doesn't support them:
- GetPixel() method is not implemented and always returns @false because
modern graphics layers don't support retrieving the contents of the drawn
pixels.
- FloodFill() method is not, and can't be, implemented, as its
functionality relies on reading the pixels from wxGraphicsContext too.
- SetLogicalFunction() method only works with @c wxCOPY, @c wxOR,
@c wxNO_OP, @c wxCLEAR and @c wxXOR functions, attempts to use any other
function (including @c wxINVERT) don't do anything.
- Similarly, ::wxRasterOperationMode parameter of Blit() and StretchBlit()
can only be one of the supported logical functions listed above, using
any other function will result in an assertion failure and not drawing
anything.
- For Direct2D-based wxGraphicsContext, only true-type fonts can be used
in the font-related functions.
@library{wxcore}
@category{dc}
@see wxDC, wxGraphicsContext
*/
class wxGCDC: public wxDC
{
public:
/**
Constructs a wxGCDC from a wxWindowDC.
*/
wxGCDC( const wxWindowDC& windowDC );
/**
Constructs a wxGCDC from a wxMemoryDC.
*/
wxGCDC( const wxMemoryDC& memoryDC );
/**
Constructs a wxGCDC from a wxPrinterDC.
*/
wxGCDC( const wxPrinterDC& printerDC );
/**
Construct a wxGCDC from an existing graphics context.
Note that this object takes ownership of @a context and will delete it
when it is destroyed or when SetGraphicsContext() is called with a
different context object.
Also notice that @a context will continue using the same font, pen and
brush as before until SetFont(), SetPen() or SetBrush() is explicitly
called to change them. This means that the code can use this
wxDC-derived object to work using pens and brushes with alpha component,
for example (which normally isn't supported by wxDC API), but it also
means that the return values of GetFont(), GetPen() and GetBrush() won't
really correspond to the actually used objects because they simply can't
represent them anyhow. If you wish to avoid such discrepancy, you need
to call the setter methods to bring wxDC and wxGraphicsContext font, pen
and brush in sync with each other.
*/
wxGCDC(wxGraphicsContext* context);
/**
Constructs a wxGCDC from a wxEnhMetaFileDC.
This constructor is only available in wxMSW port and when @c
wxUSE_ENH_METAFILE build option is enabled, i.e. when wxEnhMetaFileDC
class itself is available.
@since 2.9.3
*/
wxGCDC( const wxEnhMetaFileDC& emfDC );
wxGCDC();
virtual ~wxGCDC();
/**
Retrieves associated wxGraphicsContext
*/
wxGraphicsContext* GetGraphicsContext() const;
/**
Set the graphics context to be used for this wxGCDC.
Note that this object takes ownership of @a context and will delete it when
it is destroyed or when SetGraphicsContext() is called again.
Also, unlike the constructor taking wxGraphicsContext, this method will
reapply the current font, pen and brush, so that this object continues
to use them, if they had been changed before (which is never the case
when constructing wxGCDC directly from wxGraphicsContext).
*/
void SetGraphicsContext(wxGraphicsContext* context);
};

View File

@@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcmemory.h
// Purpose: interface of wxMemoryDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxMemoryDC
A memory device context provides a means to draw graphics onto a bitmap.
When drawing in to a mono-bitmap, using @c wxWHITE, @c wxWHITE_PEN and
@c wxWHITE_BRUSH will draw the background colour (i.e. 0) whereas all other
colours will draw the foreground colour (i.e. 1).
A bitmap must be selected into the new memory DC before it may be used for
anything. Typical usage is as follows:
@code
// Create a memory DC
wxMemoryDC temp_dc;
temp_dc.SelectObject(test_bitmap);
// We can now draw into the memory DC...
// Copy from this DC to another DC.
old_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT, temp_dc, 0, 0);
@endcode
Note that the memory DC must be deleted (or the bitmap selected out of it)
before a bitmap can be reselected into another memory DC.
And, before performing any other operations on the bitmap data, the bitmap
must be selected out of the memory DC:
@code
temp_dc.SelectObject(wxNullBitmap);
@endcode
This happens automatically when wxMemoryDC object goes out of scope.
Note that the scaling factor of the bitmap determines the scaling factor
used by this device context, so when using a memory device context as a
back buffer for a window, you should typically create the bitmap using the
same scale factor as used by the window, e.g.
@code
void MyWindow::OnPaint(wxPaintEvent&)
{
wxBitmap bmp;
bmp.CreateWithDIPSize(GetClientSize(), GetDPIScaleFactor());
{
wxMemoryDC memdc(bmp);
... use memdc to draw on the bitmap ...
}
wxPaintDC dc(this);
dc.DrawBitmap(bmp, wxPoint(0, 0));
}
@endcode
@library{wxcore}
@category{dc}
@see wxBitmap, wxDC
*/
class wxMemoryDC : public wxDC
{
public:
/**
Constructs a new memory device context.
Use the wxDC::IsOk() member to test whether the constructor was
successful in creating a usable device context. Don't forget to select
a bitmap into the DC before drawing on it.
*/
wxMemoryDC();
/**
Constructs a new memory device context having the same characteristics
as the given existing device context.
This constructor creates a memory device context @e compatible with @a
dc in wxMSW, the argument is ignored in the other ports. If @a dc is
@NULL, a device context compatible with the screen is created, just as
with the default constructor.
Note that the DPI scaling factor is @e not inherited from @a dc, but
is determined by the scaling factor of the bitmap selected into this
device context later.
*/
wxMemoryDC(wxDC *dc);
/**
Constructs a new memory device context and calls SelectObject() with
the given bitmap.
Use the wxDC::IsOk() member to test whether the constructor was
successful in creating a usable device context.
*/
wxMemoryDC(wxBitmap& bitmap);
/**
Allow using this device context object to modify the given bitmap
contents.
Note that if you need to only use the existing bitmap contents instead
of modifying it, you should use SelectObjectAsSource() instead.
Before using the updated bitmap data, make sure to select it out of
context first either by selecting ::wxNullBitmap into the device
context or destroying the device context entirely.
If the bitmap is already selected in this device context, nothing is
done. If it is selected in another context, the function asserts and
drawing on the bitmap won't work correctly.
Note that this function changes the scale factor of this device context
(as returned by wxDC::GetContentScaleFactor()) to be the same as the
bitmap scale factor (as returned by wxBitmap::GetScaleFactor()).
*/
void SelectObject(wxBitmap& bitmap);
/**
Selects the given bitmap into the device context, to use as the memory
bitmap.
Selecting the bitmap as source into a memory DC allows you to copy its
contents to another device context using wxDC::Blit(). Note that using
wxDC::DrawBitmap() or wxDC::DrawIcon() is a simpler way to do the same
thing.
@note Modifying a bitmap selected only as a source may not work
correctly and can notably modify the other bitmaps sharing the same
data due to the use of reference counting (see @ref overview_refcount).
If the argument is ::wxNullBitmap (or some other uninitialised wxBitmap)
the current bitmap is selected out of the device context, allowing the
current bitmap to be destroyed safely.
*/
void SelectObjectAsSource(const wxBitmap& bitmap);
/**
Get the selected bitmap.
*/
const wxBitmap& GetSelectedBitmap() const;
wxBitmap& GetSelectedBitmap();
};

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcmirror.h
// Purpose: interface of wxMirrorDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxMirrorDC
wxMirrorDC is a simple wrapper class which is always associated with a real
wxDC object and either forwards all of its operations to it without changes
(no mirroring takes place) or exchanges @e x and @e y coordinates which
makes it possible to reuse the same code to draw a figure and its mirror --
i.e. reflection related to the diagonal line x == y.
@since 2.5.0
@library{wxcore}
@category{dc}
*/
class wxMirrorDC : public wxDC
{
public:
/**
Creates a (maybe) mirrored DC associated with the real @a dc.
Everything drawn on wxMirrorDC will appear (and maybe mirrored) on
@a dc.
@a mirror specifies if we do mirror (if it is @true) or not (if it is
@false).
*/
wxMirrorDC(wxDC& dc, bool mirror);
};

View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcprint.h
// Purpose: interface of wxPrinterDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxPrinterDC
A printer device context is specific to MSW and Mac, and allows access to
any printer with a Windows or Macintosh driver. See wxDC for further
information on device contexts, and wxDC::GetSize() for advice on achieving
the correct scaling for the page.
@library{wxcore}
@category{printing}
@see @ref overview_printing, wxDC
*/
class wxPrinterDC : public wxDC
{
public:
/**
Constructor. Pass a wxPrintData object with information necessary for
setting up a suitable printer device context. This is the recommended
way to construct a wxPrinterDC. Make sure you specify a reference to a
wxPrintData object, not a pointer - you may not even get a warning if
you pass a pointer instead.
*/
wxPrinterDC(const wxPrintData& printData);
/**
Return the rectangle in device coordinates that corresponds to the full
paper area, including the nonprinting regions of the paper. The point
(0,0) in device coordinates is the top left corner of the page
rectangle, which is the printable area on MSW and Mac. The coordinates
of the top left corner of the paper rectangle will therefore have small
negative values, while the bottom right coordinates will be somewhat
larger than the values returned by wxDC::GetSize().
*/
wxRect GetPaperRect() const;
};

View File

@@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcps.h
// Purpose: interface of wxPostScriptDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxPostScriptDC
This defines the wxWidgets Encapsulated PostScript device context, which
can write PostScript files on any platform. See wxDC for descriptions of
the member functions.
@section start_doc Starting a document
Document should be started with call to StartDoc() prior to calling any
function to execute a drawing operation.
However, some functions, like SetFont(), may be legitimately called even
before StartDoc().
@library{wxbase}
@category{dc}
*/
class wxPostScriptDC : public wxDC
{
public:
wxPostScriptDC();
/**
Constructs a PostScript printer device context from a wxPrintData object.
*/
wxPostScriptDC(const wxPrintData& printData);
};

View File

@@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcscreen.h
// Purpose: interface of wxScreenDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxScreenDC
Deprecated class for drawing on the screen.
Please don't use this class in the new code, as it doesn't work on modern
systems any longer and using it is not guaranteed to have any effect at all.
Use wxDisplay for getting information about the screen and wxOverlay for
temporarily drawing over a window.
A wxScreenDC can be used to paint on the screen. This should normally be
constructed as a temporary stack object; don't store a wxScreenDC object.
When using multiple monitors, wxScreenDC corresponds to the entire virtual
screen composed of all of them. Notice that coordinates on wxScreenDC can
be negative in this case, see wxDisplay::GetGeometry() for more.
@library{wxcore}
@category{dc}
@see wxDC, wxMemoryDC, wxPaintDC, wxClientDC, wxWindowDC
*/
class wxScreenDC : public wxDC
{
public:
/**
Constructor.
*/
wxScreenDC();
/**
Use this in conjunction with StartDrawingOnTop().
This function destroys the temporary window created to implement on-top
drawing (X only).
*/
static bool EndDrawingOnTop();
/**
Use this in conjunction with EndDrawingOnTop() to ensure that drawing
to the screen occurs on top of existing windows. Without this, some
window systems (such as X) only allow drawing to take place underneath
other windows.
This version of StartDrawingOnTop() is used to specify that the area
that will be drawn on coincides with the given window. It is
recommended that an area of the screen is specified with
StartDrawingOnTop(wxRect*) because with large regions, flickering
effects are noticeable when destroying the temporary transparent window
used to implement this feature.
You might use this function when implementing a drag feature, for
example as in the wxSplitterWindow implementation.
@remarks This function is probably obsolete since the X implementations
allow drawing directly on the screen now. However, the fact
that this function allows the screen to be refreshed
afterwards, may be useful to some applications.
*/
static bool StartDrawingOnTop(wxWindow* window);
/**
Use this in conjunction with EndDrawingOnTop() to ensure that drawing
to the screen occurs on top of existing windows. Without this, some
window systems (such as X) only allow drawing to take place underneath
other windows.
This version of StartDrawingOnTop() is used to specify an area of the
screen which is to be drawn on. If @NULL is passed, the whole screen is
available. It is recommended that an area of the screen is specified
with this function rather than with StartDrawingOnTop(wxWindow*),
because with large regions, flickering effects are noticeable when
destroying the temporary transparent window used to implement this
feature.
You might use this function when implementing a drag feature, for
example as in the wxSplitterWindow implementation.
@remarks This function is probably obsolete since the X implementations
allow drawing directly on the screen now. However, the fact
that this function allows the screen to be refreshed
afterwards, may be useful to some applications.
*/
static bool StartDrawingOnTop(wxRect* rect = nullptr);
};

View File

@@ -0,0 +1,226 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcsvg.h
// Purpose: interface of wxSVGFileDC
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
SVG shape rendering mode.
These options represent the values defined in the SVG specification:
https://svgwg.org/svg2-draft/painting.html#ShapeRenderingProperty
*/
enum wxSVGShapeRenderingMode
{
wxSVG_SHAPE_RENDERING_AUTO = 0,
wxSVG_SHAPE_RENDERING_OPTIMIZE_SPEED,
wxSVG_SHAPE_RENDERING_CRISP_EDGES,
wxSVG_SHAPE_RENDERING_GEOMETRIC_PRECISION,
wxSVG_SHAPE_RENDERING_OPTIMISE_SPEED = wxSVG_SHAPE_RENDERING_OPTIMIZE_SPEED
};
/**
@class wxSVGFileDC
A wxSVGFileDC is a device context onto which graphics and text can be
drawn, and the output produced as a vector file, in SVG format.
This format can be read by a range of programs, including a Netscape plugin
(Adobe) and the open source Inkscape program (http://inkscape.org/). Full
details are given in the W3C SVG recommendation (http://www.w3.org/TR/SVG/).
The intention behind wxSVGFileDC is that it can be used to produce a file
corresponding to the screen display context, wxSVGFileDC, by passing the
wxSVGFileDC as a parameter instead of a wxDC. Thus the wxSVGFileDC
is a write-only class.
As the wxSVGFileDC is a vector format, raster operations like GetPixel()
are unlikely to be supported. However, the SVG specification allows for
raster files to be embedded in the SVG, and so bitmaps, icons and blit
operations in wxSVGFileDC are supported. By default only PNG format bitmaps
are supported and these are saved as separate files in the same folder
as the SVG file, however it is possible to change this behaviour by
replacing the built in bitmap handler using wxSVGFileDC::SetBitmapHandler().
More substantial SVG libraries (for reading and writing) are available at
<a href="http://wxart2d.sourceforge.net/" target="_blank">wxArt2D</a> and
<a href="http://wxsvg.sourceforge.net/" target="_blank">wxSVG</a>.
@library{wxcore}
@category{dc}
*/
class wxSVGFileDC : public wxDC
{
public:
/**
Initializes a wxSVGFileDC with the given @a filename, @a width and
@a height at @a dpi resolution, and an optional @a title.
The title provides a readable name for the SVG document.
*/
wxSVGFileDC(const wxString& filename, int width = 320, int height = 240,
double dpi = 72, const wxString& title = wxString());
/**
Draws a rectangle the size of the SVG using the wxDC::SetBackground() brush.
*/
void Clear();
/**
Replaces the default bitmap handler with @a handler.
By default, an object of wxSVGBitmapFileHandler class is used as bitmap
handler. You may want to replace it with an object of predefined
wxSVGBitmapEmbedHandler class to embed the bitmaps in the generated SVG
instead of storing them in separate files like this:
@code
mySVGFileDC->SetBitmapHandler(new wxSVGBitmapEmbedHandler());
@endcode
or derive your own bitmap handler class and use it if you need to
customize the bitmap handling further.
@param handler The new bitmap handler. If non-null, this object takes
ownership of this handler and will delete it when it is not needed
any more.
@since 3.1.0
*/
void SetBitmapHandler(wxSVGBitmapHandler* handler);
/**
Set the shape rendering mode of the generated SVG.
All subsequent drawing calls will have this rendering mode set in the
SVG file.
The default mode is wxSVG_SHAPE_RENDERING_AUTO.
@since 3.1.3
*/
void SetShapeRenderingMode(wxSVGShapeRenderingMode renderingMode);
/**
Destroys the current clipping region so that none of the DC is clipped.
Since intersections arising from sequential calls to SetClippingRegion are represented
with nested SVG group elements (\<g\>), all such groups are closed when
DestroyClippingRegion is called.
*/
void DestroyClippingRegion();
///@{
/**
Function not implemented in this DC class.
*/
void CrossHair(wxCoord x, wxCoord y);
bool FloodFill(wxCoord x, wxCoord y, const wxColour& colour,
wxFloodFillStyle style = wxFLOOD_SURFACE);
bool GetPixel(wxCoord x, wxCoord y, wxColour* colour) const;
void SetPalette(const wxPalette& palette);
int GetDepth() const;
void SetLogicalFunction(wxRasterOperationMode function);
wxRasterOperationMode GetLogicalFunction() const;
bool StartDoc(const wxString& message);
void EndDoc();
void StartPage();
void EndPage();
///@}
};
/**
Abstract base class for handling bitmaps inside a wxSVGFileDC.
To use it you need to derive a new class from it and override
ProcessBitmap() to generate a properly a formed SVG image element (see
http://www.w3.org/TR/SVG/struct.html#ImageElement).
Two example bitmap handlers are provided in wx/dcsvg.h. The first (default)
handler will create PNG files in the same folder as the SVG file and uses
links to them in the SVG. The second handler (wxSVGBitmapEmbedHandler) will
embed the PNG image in the SVG file using base 64 encoding.
The handler can be changed by calling wxSVGFileDC::SetBitmapHandler().
@library{wxcore}
@category{dc}
@since 3.1.0
*/
class wxSVGBitmapHandler
{
public:
/**
Writes the bitmap representation as SVG to the given stream.
The XML generated by this function will be inserted into the SVG file
inline with the XML generated by the main wxSVGFileDC class so it is
important that the XML is properly formed.
@param bitmap A valid bitmap to add to SVG.
@param x Horizontal position of the bitmap.
@param y Vertical position of the bitmap.
@param stream The stream to write SVG contents to.
*/
virtual bool ProcessBitmap(const wxBitmap& bitmap,
wxCoord x, wxCoord y,
wxOutputStream& stream) const = 0;
};
/**
Handler embedding bitmaps as base64-encoded PNGs into the SVG.
@see wxSVGFileDC::SetBitmapHandler().
@library{wxcore}
@category{dc}
@since 3.1.0
*/
class wxSVGBitmapEmbedHandler : public wxSVGBitmapHandler
{
public:
virtual bool ProcessBitmap(const wxBitmap& bitmap,
wxCoord x, wxCoord y,
wxOutputStream& stream) const;
};
/**
Handler saving bitmaps to external PNG files and linking to it from the
SVG.
This handler is used by default by wxSVGFileDC. PNG files are created in
the same folder as the SVG file and are named using the SVG filename
appended with ``_image#.png``.
When using wxSVGFileDC::SetBitmapHandler() to set this handler with the
default constructor, the PNG files are created in the runtime location of
the application. The save location can be customized by using the
wxSVGBitmapFileHandler(const wxFileName&) constructor.
@see wxSVGFileDC::SetBitmapHandler().
@library{wxcore}
@category{dc}
@since 3.1.0
*/
class wxSVGBitmapFileHandler : public wxSVGBitmapHandler
{
public:
/**
Create a wxSVGBitmapFileHandler and specify the location where the file
will be saved.
@param path The path of the save location. If @a path contains a
filename, the autogenerated filename will be appended to this name.
@since 3.1.3
*/
wxSVGBitmapFileHandler(const wxFileName& path);
virtual bool ProcessBitmap(const wxBitmap& bitmap,
wxCoord x, wxCoord y,
wxOutputStream& stream) const;
};

View File

@@ -0,0 +1,351 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dde.h
// Purpose: interface of wxDDEConnection
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDDEConnection
A wxDDEConnection object represents the connection between a client and a
server. It can be created by making a connection using a wxDDEClient
object, or by the acceptance of a connection by a wxDDEServer object.
The bulk of a DDE (Dynamic Data Exchange) conversation is controlled by calling
members in a wxDDEConnection object or by overriding its members.
An application should normally derive a new connection class from
wxDDEConnection, in order to override the communication event handlers to
do something interesting.
This DDE-based implementation is available on Windows only, but a
platform-independent, socket-based version of this API is available using
wxTCPConnection.
@library{wxbase}
@category{ipc}
@onlyfor{wxmsw}
@see wxConnectionBase, wxDDEClient, wxDDEServer, @ref overview_ipc
*/
class wxDDEConnection : public wxConnectionBase
{
public:
/**
Constructs a connection object. If no user-defined connection object is
to be derived from wxDDEConnection, then the constructor should not be
called directly, since the default connection object will be provided
on requesting (or accepting) a connection. However, if the user defines
his or her own derived connection object, the
wxDDEServer::OnAcceptConnection() and/or
wxDDEClient::OnMakeConnection() members should be replaced by functions
which construct the new connection object.
A default buffer will be associated with this connection.
*/
wxDDEConnection();
/**
Constructs a connection object. If no user-defined connection object is
to be derived from wxDDEConnection, then the constructor should not be
called directly, since the default connection object will be provided
on requesting (or accepting) a connection. However, if the user defines
his or her own derived connection object, the
wxDDEServer::OnAcceptConnection() and/or
wxDDEClient::OnMakeConnection() members should be replaced by functions
which construct the new connection object.
@param buffer
Buffer for this connection object to use in transactions.
@param size
Size of the buffer given.
*/
wxDDEConnection(void* buffer, size_t size);
///@{
/**
Called by the server application to advise the client of a change in
the data associated with the given item. Causes the client connection's
OnAdvise() member to be called.
@return @true if successful.
*/
bool Advise(const wxString& item, const void* data, size_t size,
wxIPCFormat format = wxIPC_PRIVATE);
bool Advise(const wxString& item, const char* data);
bool Advise(const wxString& item, const wchar_t* data);
bool Advise(const wxString& item, const wxString data);
///@}
/**
Called by the client or server application to disconnect from the other
program; it causes the OnDisconnect() message to be sent to the
corresponding connection object in the other program. The default
behaviour of OnDisconnect() is to delete the connection, but the
calling application must explicitly delete its side of the connection
having called Disconnect().
@return @true if successful.
*/
bool Disconnect();
///@{
/**
Called by the client application to execute a command on the server.
Can also be used to transfer arbitrary data to the server (similar to
Poke() in that respect). Causes the server connection's OnExecute()
member to be called.
@return @true if successful.
*/
bool Execute(const void* data, size_t size,
wxIPCFormat format = wxIPC_PRIVATE);
bool Execute(const char* data);
bool Execute(const wchar_t* data);
bool Execute(const wxString data);
///@}
/**
Message sent to the client application when the server notifies it of a
change in the data associated with the given item.
*/
virtual bool OnAdvise(const wxString& topic, const wxString& item,
const void* data, size_t size, wxIPCFormat format);
/**
Message sent to the client or server application when the other
application notifies it to delete the connection. Default behaviour is
to delete the connection object.
*/
virtual bool OnDisconnect();
/**
Message sent to the server application when the client notifies it to
execute the given data. Note that there is no item associated with
this message.
*/
virtual bool OnExecute(const wxString& topic, const void* data,
size_t size, wxIPCFormat format);
/**
Message sent to the server application when the client notifies it to
accept the given data.
*/
virtual bool OnPoke(const wxString& topic, const wxString& item,
const void* data, size_t size, wxIPCFormat format);
/**
Message sent to the server application when the client calls Request().
The server should respond by returning a character string from
OnRequest(), or @NULL to indicate no data.
*/
virtual const void* OnRequest(const wxString& topic,
const wxString& item, size_t* size,
wxIPCFormat format);
/**
Message sent to the server application by the client, when the client
wishes to start an "advise loop" for the given topic and item. The
server can refuse to participate by returning @false.
*/
virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
/**
Message sent to the server application by the client, when the client
wishes to stop an "advise loop" for the given topic and item. The
server can refuse to stop the advise loop by returning @false, although
this doesn't have much meaning in practice.
*/
virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
///@{
/**
Called by the client application to poke data into the server. Can be
used to transfer arbitrary data to the server. Causes the server
connection's OnPoke() member to be called.
@return @true if successful.
*/
bool Poke(const wxString& item, const void* data, size_t size,
wxIPCFormat format = wxIPC_PRIVATE);
bool Poke(const wxString& item, const char* data);
bool Poke(const wxString& item, const wchar_t* data);
bool Poke(const wxString& item, const wxString data);
///@}
/**
Called by the client application to request data from the server.
Causes the server connection's OnRequest() member to be called.
@return A character string (actually a pointer to the connection's
buffer) if successful, @NULL otherwise.
*/
const void* Request(const wxString& item, size_t* size,
wxIPCFormat format = wxIPC_TEXT);
/**
Called by the client application to ask if an advise loop can be
started with the server. Causes the server connection's OnStartAdvise()
member to be called.
@return @true if the server okays it, @false otherwise.
*/
bool StartAdvise(const wxString& item);
/**
Called by the client application to ask if an advise loop can be
stopped. Causes the server connection's OnStopAdvise() member to be
called.
@return @true if the server okays it, @false otherwise.
*/
bool StopAdvise(const wxString& item);
};
/**
@class wxDDEClient
A wxDDEClient object represents the client part of a client-server DDE
(Dynamic Data Exchange) conversation.
To create a client which can communicate with a suitable server, you need
to derive a class from wxDDEConnection and another from wxDDEClient. The
custom wxDDEConnection class will intercept communications in a
"conversation" with a server, and the custom wxDDEServer is required so
that a user-overridden OnMakeConnection() member can return a
wxDDEConnection of the required class, when a connection is made.
This DDE-based implementation is available on Windows only, but a
platform-independent, socket-based version of this API is available using
wxTCPClient.
@library{wxbase}
@category{ipc}
@onlyfor{wxmsw}
@see wxDDEServer, wxDDEConnection, @ref overview_ipc
*/
class wxDDEClient : public wxObject
{
public:
/**
Constructs a client object.
*/
wxDDEClient();
/**
Tries to make a connection with a server specified by the host (machine
name under UNIX, ignored under Windows), service name (must contain an
integer port number under UNIX), and topic string. If the server allows
a connection, a wxDDEConnection object will be returned.
The type of wxDDEConnection returned can be altered by overriding the
OnMakeConnection() member to return your own derived connection object.
*/
wxConnectionBase* MakeConnection(const wxString& host,
const wxString& service,
const wxString& topic);
/**
The type of wxDDEConnection returned from a MakeConnection() call can
be altered by deriving the OnMakeConnection() member to return your own
derived connection object. By default, a wxDDEConnection object is
returned.
The advantage of deriving your own connection class is that it will
enable you to intercept messages initiated by the server, such as
wxDDEConnection::OnAdvise(). You may also want to store
application-specific data in instances of the new class.
*/
wxConnectionBase* OnMakeConnection();
/**
Returns @true if this is a valid host name, @false otherwise. This
always returns @true under MS Windows.
*/
bool ValidHost(const wxString& host);
};
/**
@class wxDDEServer
A wxDDEServer object represents the server part of a client-server DDE
(Dynamic Data Exchange) conversation.
This DDE-based implementation is available on Windows only, but a
platform-independent, socket-based version of this API is available using
wxTCPServer.
@library{wxbase}
@category{ipc}
@onlyfor{wxmsw}
@see wxDDEClient, wxDDEConnection, @ref overview_ipc
*/
class wxDDEServer
{
public:
/**
Constructs a server object.
*/
wxDDEServer();
/**
Registers the server using the given service name. Under UNIX, the
string must contain an integer id which is used as an Internet port
number. @false is returned if the call failed (for example, if the port
number is already in use).
*/
bool Create(const wxString& service);
/**
When a client calls wxDDEClient::MakeConnection(), the server receives
the message and this member is called. The application should derive a
member to intercept this message and return a connection object of
either the standard wxDDEConnection type, or of a user-derived type.
If the @a topic is "STDIO", the application may wish to refuse the
connection. Under UNIX, when a server is created the
OnAcceptConnection() message is always sent for standard input and
output, but in the context of DDE messages it doesn't make a lot of
sense.
*/
virtual wxConnectionBase* OnAcceptConnection(const wxString& topic);
};
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_misc */
///@{
/**
Called when wxWidgets exits, to clean up the DDE system. This no longer
needs to be called by the application.
@see wxDDEInitialize()
@header{wx/dde.h}
*/
void wxDDECleanUp();
/**
Initializes the DDE system. May be called multiple times without harm.
This no longer needs to be called by the application: it will be called by
wxWidgets if necessary.
@see wxDDEServer, wxDDEClient, wxDDEConnection, wxDDECleanUp()
@header{wx/dde.h}
*/
void wxDDEInitialize();
///@}

View File

@@ -0,0 +1,414 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/debug.h
// Purpose: interface of global functions
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/** @addtogroup group_funcmacro_debug */
///@{
/**
Exits the program immediately.
This is a simple wrapper for the standard abort() function.
@since 2.9.4
*/
void wxAbort();
/**
Preprocessor symbol defining the level of debug support available.
This symbol is defined to 1 by default meaning that asserts are compiled in
(although they may be disabled by a call to wxDisableAsserts()). You may
predefine it as 0 prior to including any wxWidgets headers to omit the
calls to wxASSERT() and related macros entirely in your own code and you
may also predefine it as 0 when building wxWidgets to also avoid including
any asserts in wxWidgets itself.
Alternatively, you may predefine it as 2 to include wxASSERT_LEVEL_2() and
similar macros which are used for asserts which have non-trivial run-time
costs and so are disabled by default.
@since 2.9.1
@header{wx/debug.h}
*/
#define wxDEBUG_LEVEL
/**
Compatibility macro indicating presence of debug support.
This symbol is defined if wxDEBUG_LEVEL is greater than 0 and undefined
otherwise.
@header{wx/debug.h}
*/
#define __WXDEBUG__
/**
Type for the function called in case of assert failure.
@see wxSetAssertHandler()
*/
typedef void (*wxAssertHandler_t)(const wxString& file,
int line,
const wxString& func,
const wxString& cond,
const wxString& msg);
/**
Assert macro. An error message will be generated if the condition is @false in
debug mode, but nothing will be done in the release build.
Please note that the condition in wxASSERT() should have no side effects
because it will not be executed in release mode at all.
This macro should be used to catch (in debug builds) logical errors done
by the programmer.
@see wxASSERT_MSG(), wxCOMPILE_TIME_ASSERT()
@header{wx/debug.h}
*/
#define wxASSERT( condition )
/**
Assert macro for expensive run-time checks.
This macro does nothing unless wxDEBUG_LEVEL is 2 or more and is meant to
be used for the assertions with noticeable performance impact and which,
hence, should be disabled during run-time.
If wxDEBUG_LEVEL is 2 or more, it becomes the same as wxASSERT().
@header{wx/debug.h}
*/
#define wxASSERT_LEVEL_2( condition )
/**
Assert macro with a custom message for expensive run-time checks.
If wxDEBUG_LEVEL is 2 or more, this is the same as wxASSERT_MSG(),
otherwise it doesn't do anything at all.
@see wxASSERT_LEVEL_2()
@header{wx/debug.h}
*/
#define wxASSERT_LEVEL_2_MSG( condition, msg)
/**
This macro results in a @ref wxCOMPILE_TIME_ASSERT "compile time assertion failure"
if the size of the given @c type is less than @c size bits.
This macro should be used to catch (in debug builds) logical errors done
by the programmer.
You may use it like this, for example:
@code
// we rely on the int being able to hold values up to 2^32
wxASSERT_MIN_BITSIZE(int, 32);
// can't work with the platforms using UTF-8 for wchar_t
wxASSERT_MIN_BITSIZE(wchar_t, 16);
@endcode
@header{wx/debug.h}
*/
#define wxASSERT_MIN_BITSIZE( type, size )
/**
Assert macro with message.
An error message will be generated if the condition is @false.
This macro should be used to catch (in debug builds) logical errors done
by the programmer.
@see wxASSERT(), wxCOMPILE_TIME_ASSERT()
@header{wx/debug.h}
*/
#define wxASSERT_MSG( condition, message )
/**
Assert macro pretending to assert at the specified location.
This macro is the same as wxASSERT_MSG(), but the assert message will use
the specified source file, line number and function name instead of the
values corresponding to the current location as done by wxASSERT_MSG() by
default.
It is mostly useful for asserting inside functions called from macros, as
by passing the usual @c \__FILE__, @c \__LINE__ and @c \__func__ values to
a function, it's possible to pretend that the assert happens at the
location of the macro in the source code (which can be useful) instead of
inside the function itself (which is never useful as these values are
always the same for the given assertion).
@since 3.1.0
@header{wx/debug.h}
*/
#define wxASSERT_MSG_AT( condition, message, file, line, func )
/**
Checks that the condition is @true, returns with the given return value if
not (stops execution in debug mode). This check is done even in release mode.
This macro should be used to catch (both in debug and release builds) logical
errors done by the programmer.
@header{wx/debug.h}
*/
#define wxCHECK( condition, retValue )
/**
Checks that the condition is @true, returns with the given return value if
not (stops execution in debug mode). This check is done even in release mode.
This macro may be only used in non-void functions, see also wxCHECK_RET().
This macro should be used to catch (both in debug and release builds) logical
errors done by the programmer.
@header{wx/debug.h}
*/
#define wxCHECK_MSG( condition, retValue, message )
/**
Checks that the condition is @true, and returns if not (stops execution
with the given error message in debug mode). This check is done even in
release mode.
This macro should be used in void functions instead of wxCHECK_MSG().
This macro should be used to catch (both in debug and release builds) logical
errors done by the programmer.
@header{wx/debug.h}
*/
#define wxCHECK_RET( condition, message )
/**
Checks that the condition is @true, and if not, it will wxFAIL() and
execute the given @c operation if it is not. This is a generalisation of
wxCHECK() and may be used when something else than just returning from the
function must be done when the @c condition is @false. This check is done
even in release mode.
This macro should be used to catch (both in debug and release builds) logical
errors done by the programmer.
@header{wx/debug.h}
*/
#define wxCHECK2(condition, operation)
/**
This is the same as wxCHECK2(), but wxFAIL_MSG() with the specified
@c message is called instead of wxFAIL() if the @c condition is @false.
This macro should be used to catch (both in debug and release builds) logical
errors done by the programmer.
@header{wx/debug.h}
*/
#define wxCHECK2_MSG( condition, operation, message )
/**
Using wxCOMPILE_TIME_ASSERT() results in a compilation error if the
specified @c condition is @false. The compiler error message should include
the @c message identifier - please note that it must be a valid C++
identifier and not a string unlike in the other cases.
This macro is mostly useful for testing the expressions involving the
@c sizeof operator as they can't be tested by the preprocessor but it is
sometimes desirable to test them at the compile time.
Note that this macro internally declares a struct whose name it tries to
make unique by using the @c \__LINE__ in it but it may still not work if you
use it on the same line in two different source files. In this case you may
either change the line in which either of them appears on or use the
wxCOMPILE_TIME_ASSERT2() macro.
Also note that Microsoft Visual C++ has a bug which results in compiler
errors if you use this macro with 'Program Database For Edit And Continue'
(@c /ZI) option, so you shouldn't use it ('Program Database' (@c /Zi) is ok
though) for the code making use of this macro.
This macro should be used to catch misconfigurations at compile-time.
@see wxASSERT_MSG(), wxASSERT_MIN_BITSIZE()
@header{wx/debug.h}
*/
#define wxCOMPILE_TIME_ASSERT( condition, message )
/**
This macro is identical to wxCOMPILE_TIME_ASSERT() except that it allows
you to specify a unique @c name for the struct internally defined by this
macro to avoid getting the compilation errors described for
wxCOMPILE_TIME_ASSERT().
This macro should be used to catch misconfigurations at compile-time.
@header{wx/debug.h}
*/
#define wxCOMPILE_TIME_ASSERT2(condition, message, name)
/**
Disable the condition checks in the assertions.
This is the same as calling wxSetAssertHandler() with @NULL handler.
@since 2.9.0
@header{wx/debug.h}
*/
void wxDisableAsserts();
/**
Use this macro to disable asserts in release build when not using
wxIMPLEMENT_APP().
By default, assert message boxes are suppressed in release build by
wxIMPLEMENT_APP() which uses this macro. If you don't use wxIMPLEMENT_APP()
because your application initializes wxWidgets directly (e.g. calls
wxEntry() or wxEntryStart() itself) but still want to suppress assert
notifications in release build you need to use this macro directly.
@see wxDISABLE_DEBUG_SUPPORT()
@since 2.9.1
@header{wx/debug.h}
*/
#define wxDISABLE_ASSERTS_IN_RELEASE_BUILD() wxDisableAsserts()
/**
Will always generate an assert error if this code is reached (in debug mode).
Note that you don't have to (and cannot) use brackets when invoking this
macro:
@code
if (...some condition...) {
wxFAIL;
}
@endcode
This macro should be used to catch (in debug builds) logical errors done
by the programmer.
@see wxFAIL_MSG()
@header{wx/debug.h}
*/
#define wxFAIL
/**
Will always generate an assert error with specified message if this code is
reached (in debug mode).
This macro is useful for marking "unreachable" code areas, for example it
may be used in the "default:" branch of a switch statement if all possible
cases are processed above.
This macro should be used to catch (in debug builds) logical errors done
by the programmer.
@see wxFAIL()
@header{wx/debug.h}
*/
#define wxFAIL_MSG( message )
/**
Assert failure macro pretending to assert at the specified location.
This is a cross between wxASSERT_MSG_AT() and wxFAIL_MSG(), see their
documentation for more details.
@since 3.1.0
@header{wx/debug.h}
*/
#define wxFAIL_MSG_AT( message, file, line, func )
/**
Returns @true if the program is running under debugger, @false otherwise.
Please note that this function is currently only implemented for Win32 and
always returns @false elsewhere.
@header{wx/debug.h}
*/
bool wxIsDebuggerRunning();
/**
Sets the function to be called in case of assertion failure.
The default assert handler forwards to wxApp::OnAssertFailure() whose
default behaviour is, in turn, to show the standard assertion failure
dialog if a wxApp object exists or shows the same dialog itself directly
otherwise.
While usually it is enough -- and more convenient -- to just override
OnAssertFailure(), to handle all assertion failures, including those
occurring even before wxApp object creation of after its destruction you
need to provide your assertion handler function.
This function also provides a simple way to disable all asserts: simply
pass @NULL pointer to it. Doing this will result in not even evaluating
assert conditions at all, avoiding almost all run-time cost of asserts.
Notice that this function is not MT-safe, so you should call it before
starting any other threads.
The return value of this function is the previous assertion handler. It can
be called after any pre-processing by your handler and can also be restored
later if you uninstall your handler.
@param handler
The function to call in case of assertion failure or @NULL.
@return
The previous assert handler which is not @NULL by default but could be
@NULL if it had been previously set to this value using this function.
@since 2.9.0
@header{wx/debug.h}
*/
wxAssertHandler_t wxSetAssertHandler(wxAssertHandler_t handler);
/**
Reset the assert handler to default function which shows a message box when
an assert happens.
This can be useful for the applications compiled in release build (with @c
NDEBUG defined) for which the asserts are by default disabled: if you wish
to enable them even in this case you need to call this function.
@since 2.9.1
@header{wx/debug.h}
*/
void wxSetDefaultAssertHandler();
/**
Generate a debugger exception meaning that the control is passed to the
debugger if one is attached to the process.
Otherwise the program just terminates abnormally.
If @c wxDEBUG_LEVEL is 0 (which is not the default) this function does
nothing.
@header{wx/debug.h}
*/
void wxTrap();
///@}

View File

@@ -0,0 +1,388 @@
/////////////////////////////////////////////////////////////////////////////
// Name: debugrpt.h
// Purpose: interface of wxDebugReport*
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDebugReportPreview
This class presents the debug report to the user and allows him to veto
report entirely or remove some parts of it. Although not mandatory, using
this class is strongly recommended as data included in the debug report
might contain sensitive private information and the user should be notified
about it as well as having a possibility to examine the data which had been
gathered to check whether this is effectively the case and discard the
debug report if it is.
wxDebugReportPreview is an abstract base class, currently the only concrete
class deriving from it is wxDebugReportPreviewStd.
@library{wxqa}
@category{debugging}
*/
class wxDebugReportPreview
{
public:
/**
Default constructor.
*/
wxDebugReportPreview();
/**
Destructor is trivial as well but should be virtual for a base class.
*/
virtual ~wxDebugReportPreview();
/**
Present the report to the user and allow him to modify it by removing
some or all of the files and, potentially, adding some notes.
@return @true if the report should be processed or @false if the user
chose to cancel report generation or removed all files from
it.
*/
virtual bool Show(wxDebugReport& dbgrpt) const = 0;
};
/**
@class wxDebugReportCompress
wxDebugReportCompress is a wxDebugReport which compresses all the files in
this debug report into a single ZIP file in its wxDebugReport::Process()
function.
@library{wxqa}
@category{debugging}
*/
class wxDebugReportCompress : public wxDebugReport
{
public:
/**
Default constructor does nothing special.
*/
wxDebugReportCompress();
/**
Set the directory where the debug report should be generated.
By default, the debug report is generated under user temporary files
directory. This is usually fine if it is meant to be processed in some
way (e.g. automatically uploaded to a remote server) but if the user is
asked to manually upload or send the report, it may be more convenient
to generate it in e.g. the users home directory and this function
allows doing this.
Notice that it should be called before wxDebugReport::Process() or it
has no effect.
@param dir
The full path to an existing directory where the debug report file
should be generated.
@since 2.9.1
*/
void SetCompressedFileDirectory(const wxString& dir);
/**
Set the base name of the generated debug report file.
This function is similar to SetCompressedFileDirectory() but allows
changing the base name of the file. Notice that the file extension will
always be @c .zip.
By default, a unique name constructed from wxApp::GetAppName(), the
current process id and the current date and time is used.
@param name
The base name (i.e. without extension) of the file.
@since 2.9.1
*/
void SetCompressedFileBaseName(const wxString& name);
/**
Returns the full path of the compressed file (empty if creation
failed).
*/
const wxString& GetCompressedFileName() const;
};
/**
@class wxDebugReport
wxDebugReport is used to generate a debug report, containing information
about the program current state. It is usually used from
wxApp::OnFatalException() as shown in the @ref page_samples_debugrpt.
A wxDebugReport object contains one or more files. A few of them can be
created by the class itself but more can be created from the outside and
then added to the report. Also note that several virtual functions may be
overridden to further customize the class behaviour.
Once a report is fully assembled, it can simply be left in the temporary
directory so that the user can email it to the developers (in which case
you should still use wxDebugReportCompress to compress it in a single file)
or uploaded to a Web server using wxDebugReportUpload (setting up the Web
server to accept uploads is your responsibility, of course). Other
handlers, for example for automatically emailing the report, can be defined
as well but are not currently included in wxWidgets.
A typical usage example:
@code
wxDebugReport report;
wxDebugReportPreviewStd preview;
report.AddCurrentContext(); // could also use AddAll()
report.AddCurrentDump(); // to do both at once
if ( preview.Show(report) )
report.Process();
@endcode
@library{wxqa}
@category{debugging}
*/
class wxDebugReport
{
public:
/**
This enum is used for functions that report either the current state or
the state during the last (fatal) exception.
*/
enum Context {
Context_Current,
Context_Exception
};
/**
The constructor creates a temporary directory where the files that will
be included in the report are created. Use IsOk() to check for errors.
*/
wxDebugReport();
/**
The destructor normally destroys the temporary directory created in the
constructor with all the files it contains. Call Reset() to prevent
this from happening.
*/
virtual ~wxDebugReport();
/**
Adds all available information to the report. Currently this includes a
text (XML) file describing the process context and, under Win32, a
minidump file.
*/
void AddAll(Context context = Context_Exception);
/**
Add an XML file containing the current or exception context and the
stack trace.
*/
virtual bool AddContext(Context ctx);
/**
The same as calling AddContext(Context_Current).
*/
bool AddCurrentContext();
/**
The same as calling AddDump(Context_Current).
*/
bool AddCurrentDump();
/**
Adds the minidump file to the debug report.
Minidumps are only available under recent Win32 versions
(@c dbghlp32.dll can be installed under older systems to make minidumps
available).
*/
virtual bool AddDump(Context ctx);
/**
The same as calling AddContext(Context_Exception).
*/
bool AddExceptionContext();
/**
The same as calling AddDump(Context_Exception).
*/
bool AddExceptionDump();
/**
Add another file to the report. If @a filename is an absolute path, it
is copied to a file in the debug report directory with the same name.
Otherwise the file will be searched in the temporary directory returned
by GetDirectory().
The argument @a description only exists to be displayed to the user in
the report summary shown by wxDebugReportPreview.
@see GetDirectory(), AddText()
*/
virtual void AddFile(const wxString& filename, const wxString& description);
/**
This is a convenient wrapper around AddFile(). It creates the file with
the given @a name and writes @a text to it, then adds the file to the
report. The @a filename shouldn't contain the path.
@return @true if file could be added successfully, @false if an IO
error occurred.
*/
bool AddText(const wxString& filename, const wxString& text,
const wxString& description);
/**
This method should be used to construct the full name of the files
which you wish to add to the report using AddFile().
@return The name of the temporary directory used for the files in this
report.
*/
const wxString& GetDirectory() const;
/**
Retrieves the name (relative to GetDirectory()) and the description of
the file with the given index. If @a n is greater than or equal to the
number of files, then @false is returned.
*/
bool GetFile(size_t n, wxString* name, wxString* desc) const;
/**
Gets the current number files in this report.
*/
size_t GetFilesCount() const;
/**
Gets the name used as a base name for various files, by default
wxApp::GetAppName() is used.
*/
virtual wxString GetReportName() const;
/**
Returns @true if the object was successfully initialized. If this
method returns @false the report can't be used.
*/
bool IsOk() const;
/**
Processes this report: the base class simply notifies the user that the
report has been generated. This is usually not enough -- instead you
should override this method to do something more useful to you.
*/
bool Process();
/**
Removes the file from report: this is used by wxDebugReportPreview to
allow the user to remove files potentially containing private
information from the report.
*/
void RemoveFile(const wxString& name);
/**
Resets the directory name we use. The object can't be used any more
after this as it becomes uninitialized and invalid.
*/
void Reset();
protected:
/**
This function may be overridden to add arbitrary custom context to the
XML context file created by AddContext(). By default, it does nothing.
*/
virtual void DoAddCustomContext(wxXmlNode* nodeRoot);
/**
This function may be overridden to modify the contents of the exception
tag in the XML context file.
*/
virtual bool DoAddExceptionInfo(wxXmlNode* nodeContext);
/**
This function may be overridden to modify the contents of the modules
tag in the XML context file.
*/
virtual bool DoAddLoadedModules(wxXmlNode* nodeModules);
/**
This function may be overridden to modify the contents of the system
tag in the XML context file.
*/
virtual bool DoAddSystemInfo(wxXmlNode* nodeSystemInfo);
};
/**
@class wxDebugReportPreviewStd
wxDebugReportPreviewStd is a standard debug report preview window. It
displays a dialog allowing the user to examine the contents of a debug
report, remove files from and add notes to it.
@library{wxqa}
@category{debugging}
*/
class wxDebugReportPreviewStd : public wxDebugReportPreview
{
public:
/**
Trivial default constructor.
*/
wxDebugReportPreviewStd();
/**
Shows the dialog.
@see wxDebugReportPreview::Show()
*/
bool Show(wxDebugReport& dbgrpt) const;
};
/**
@class wxDebugReportUpload
This class is used to upload a compressed file using HTTP POST request. As
this class derives from wxDebugReportCompress, before upload the report is
compressed in a single ZIP file.
@library{wxqa}
@category{debugging}
*/
class wxDebugReportUpload : public wxDebugReportCompress
{
public:
/**
This class will upload the compressed file created by its base class to
an HTML multipart/form-data form at the specified address. The @a url
is the upload page address, @a input is the name of the @c "type=file"
control on the form used for the file name and @a action is the value
of the form action field. The report is uploaded using the @e curl
program which should be available, the @e curl parameter may be used to
specify the full path to it.
*/
wxDebugReportUpload(const wxString& url, const wxString& input,
const wxString& action,
const wxString& curl = "curl");
protected:
/**
This function may be overridden in a derived class to show the output
from curl: this may be an HTML page or anything else that the server
returned. Value returned by this function becomes the return value of
wxDebugReport::Process().
*/
virtual bool OnServerReply(const wxArrayString& reply);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,738 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dialog.h
// Purpose: interface of wxDialog
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Modes used for wxDialog::SetLayoutAdaptationMode().
*/
enum wxDialogLayoutAdaptationMode
{
wxDIALOG_ADAPTATION_MODE_DEFAULT = 0, ///< Use global adaptation enabled status.
wxDIALOG_ADAPTATION_MODE_ENABLED = 1, ///< Enable this dialog overriding global status.
wxDIALOG_ADAPTATION_MODE_DISABLED = 2 ///< Disable this dialog overriding global status.
};
#define wxDIALOG_NO_PARENT 0x00000020 ///< Don't make owned by apps top window
#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
#define wxDIALOG_ADAPTATION_NONE 0 ///< Don't do any layout adaptation
#define wxDIALOG_ADAPTATION_STANDARD_SIZER 1 ///< Only look for wxStdDialogButtonSizer for non-scrolling part
#define wxDIALOG_ADAPTATION_ANY_SIZER 2 ///< Also look for any suitable sizer for non-scrolling part
#define wxDIALOG_ADAPTATION_LOOSE_BUTTONS 3 ///< Also look for 'loose' standard buttons for non-scrolling part
/**
@class wxDialog
A dialog box is a window with a title bar and sometimes a system menu,
which can be moved around the screen. It can contain controls and other
windows and is often used to allow the user to make some choice or to
answer a question.
Dialogs can be made scrollable, automatically, for computers with low
resolution screens: please see @ref overview_dialog_autoscrolling for
further details.
Dialogs usually contain either a single button allowing to close the
dialog or two buttons, one accepting the changes and the other one
discarding them (such button, if present, is automatically activated if the
user presses the "Esc" key). By default, buttons with the standard wxID_OK
and wxID_CANCEL identifiers behave as expected. Starting with wxWidgets 2.7
it is also possible to use a button with a different identifier instead,
see SetAffirmativeId() and SetEscapeId().
Also notice that the CreateButtonSizer() should be used to create the
buttons appropriate for the current platform and positioned correctly
(including their order which is platform-dependent).
@section dialog_modal Modal and Modeless
There are two kinds of dialog, modal and modeless. A modal dialog blocks
program flow and user input on other windows until it is dismissed, whereas
a modeless dialog behaves more like a frame in that program flow continues,
and input in other windows is still possible. To show a modal dialog you
should use the ShowModal() method while to show a dialog modelessly you
simply use Show(), just as with frames.
Note that the modal dialog is one of the very few examples of
wxWindow-derived objects which may be created on the stack and not on the
heap. In other words, while most windows would be created like this:
@code
void AskUser()
{
MyAskDialog *dlg = new MyAskDialog(...);
if ( dlg->ShowModal() == wxID_OK )
// ...
//else: dialog was cancelled or some another button pressed
dlg->Destroy();
}
@endcode
You can achieve the same result with dialogs by using simpler code:
@code
void AskUser()
{
MyAskDialog dlg(...);
if ( dlg.ShowModal() == wxID_OK )
// ...
// no need to call Destroy() here
}
@endcode
An application can define a wxCloseEvent handler for the dialog to respond
to system close events.
@beginStyleTable
@style{wxCAPTION}
Shows the title bar, containing the window title, for this window.
Note that this style is implicitly enabled by wxMINIMIZE_BOX,
wxMAXIMIZE_BOX and wxCLOSE_BOX on most systems as the corresponding
buttons couldn't be shown if the window had no title bar at all.
@style{wxDEFAULT_DIALOG_STYLE}
Equivalent to a combination of wxCAPTION, wxCLOSE_BOX and
wxSYSTEM_MENU (the last one is not used under Unix).
@style{wxRESIZE_BORDER}
Display a resizable frame around the window.
@style{wxSYSTEM_MENU}
Display a system menu.
@style{wxCLOSE_BOX}
Displays a close box on the frame. This style implicitly enables
wxCAPTION too.
@style{wxMAXIMIZE_BOX}
Displays a maximize box on the dialog. This style implicitly enables
wxCAPTION too.
@style{wxMINIMIZE_BOX}
Displays a minimize box on the dialog. This style implicitly enables
wxCAPTION too.
@style{wxTHICK_FRAME}
Display a thick frame around the window.
@style{wxSTAY_ON_TOP}
The dialog stays on top of all other windows.
@style{wxNO_3D}
This style is obsolete and doesn't do anything any more, don't use
it in any new code.
@style{wxDIALOG_NO_PARENT}
By default, a dialog created with a @NULL parent window will be
given the @ref wxApp::GetTopWindow() "application's top level window"
as parent. Use this style to prevent this from happening and create
an orphan dialog. This is not recommended for modal dialogs.
@style{wxDIALOG_EX_CONTEXTHELP}
Under Windows, puts a query button on the caption. When pressed,
Windows will go into a context-sensitive help mode and wxWidgets
will send a @c wxEVT_HELP event if the user clicked on an application
window. Note that this is an extended style and must be set by
calling SetExtraStyle() before Create is called (two-step
construction).
@style{wxDIALOG_EX_METAL}
On macOS, frames with this style will be shown with a metallic
look. This is an extra style.
@endStyleTable
Under Unix a window manager recognizing the WM hints should be running for
any of these styles to have an effect.
@beginEventEmissionTable{wxCloseEvent}
@event{EVT_CLOSE(func)}
The dialog is being closed by the user or programmatically (see wxWindow::Close).
The user may generate this event clicking the close button
(typically the 'X' on the top-right of the title bar) if it's present
(see the @c wxCLOSE_BOX style).
@event{EVT_INIT_DIALOG(func)}
Process a @c wxEVT_INIT_DIALOG event. See wxInitDialogEvent.
@endEventTable
@library{wxcore}
@category{cmndlg}
@see @ref overview_dialog, wxFrame, @ref overview_validator
*/
class wxDialog : public wxTopLevelWindow
{
public:
/**
Default constructor.
*/
wxDialog();
/**
Constructor.
@param parent
Can be @NULL, a frame or another dialog box.
@param id
An identifier for the dialog. A value of -1 is taken to mean a
default.
@param title
The title of the dialog.
@param pos
The dialog position. The value wxDefaultPosition indicates a
default position, chosen by either the windowing system or
wxWidgets, depending on platform.
@param size
The dialog size. The value wxDefaultSize indicates a default size,
chosen by either the windowing system or wxWidgets, depending on
platform.
@param style
The window style.
@param name
Used to associate a name with the window. This is @a not the same
as the title of the window.
@see Create()
*/
wxDialog(wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr);
/**
Destructor.
Deletes any child windows before deleting the physical window.
See @ref overview_windowdeletion for more info.
*/
virtual ~wxDialog();
/**
Adds an identifier to be regarded as a main button for the
non-scrolling area of a dialog.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
void AddMainButtonId(wxWindowID id);
/**
Returns @true if this dialog can and should perform layout adaptation
using DoLayoutAdaptation(), usually if the dialog is too large to fit
on the display.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
virtual bool CanDoLayoutAdaptation();
/**
Centres the dialog box on the display.
@param direction
May be wxHORIZONTAL, wxVERTICAL or wxBOTH.
*/
void Centre(int direction = wxBOTH);
/**
Used for two-step dialog box construction.
@see wxDialog()
*/
bool Create(wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr);
/**
Creates a sizer with standard buttons. @a flags is a bit list of the
following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, wxCLOSE, wxHELP,
wxNO_DEFAULT.
The sizer lays out the buttons in a manner appropriate to the platform.
This function uses CreateStdDialogButtonSizer() internally for most
platforms but doesn't create the sizer at all for the platforms with
hardware buttons (such as smartphones) for which it sets up the
hardware buttons appropriately and returns @NULL, so don't forget to
test that the return value is valid before using it.
*/
wxSizer* CreateButtonSizer(long flags);
/**
Creates a sizer with standard buttons using CreateButtonSizer()
separated from the rest of the dialog contents by a horizontal
wxStaticLine.
@note Just like CreateButtonSizer(), this function may return @NULL if
no buttons were created.
This is a combination of CreateButtonSizer() and
CreateSeparatedSizer().
*/
wxSizer* CreateSeparatedButtonSizer(long flags);
/**
Returns the sizer containing the given one with a separating
wxStaticLine if necessarily.
This function is useful for creating the sizer containing footer-like
contents in dialog boxes. It will add a separating static line only if
it conforms to the current platform convention (currently it is not
added under Mac where the use of static lines for grouping is
discouraged and is added elsewhere).
@since 2.9.2
@param sizer The sizer to wrap, must be non-null.
@return The sizer wrapping the input one or possibly the input sizer
itself if no wrapping is necessary.
*/
wxSizer *CreateSeparatedSizer(wxSizer *sizer);
/**
Creates a wxStdDialogButtonSizer with standard buttons. @a flags is a
bit list of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY,
wxCLOSE, wxHELP, wxNO_DEFAULT.
The sizer lays out the buttons in a manner appropriate to the platform.
@note Unlike when using wxStdDialogButtonSizer directly, creating the sizer
with this method usually results in one of its buttons being default
(and having initial focus): @a wxNO_DEFAULT will make the No button
the default, otherwise the OK or Yes button will be set as the default
when present.
*/
wxStdDialogButtonSizer* CreateStdDialogButtonSizer(long flags);
/**
Splits text up at newlines and places the lines into wxStaticText
objects with the specified maximum width in a vertical wxBoxSizer.
If @a widthMax has its default value of -1, only explicit new line
characters in @a message are taken into account. Otherwise, lines are
broken either after a new line or wrapped, at word boundary, if their
width would become bigger than the specified maximal width.
@param message The text to be displayed.
@param widthMax Specifies the text's maximum width (this argument is
available since version 3.1.1, previous versions always behaved as if
the maximal width of -1 was specified).
@see wxStaticText::Wrap(int width)
*/
wxSizer *CreateTextSizer(const wxString& message, int widthMax = -1);
/**
Performs layout adaptation, usually if the dialog is too large to fit
on the display.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
virtual bool DoLayoutAdaptation();
/**
A static function enabling or disabling layout adaptation for all
dialogs.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
static void EnableLayoutAdaptation(bool enable);
/**
Ends a modal dialog, passing a value to be returned from the
ShowModal() invocation.
@param retCode
The value that should be returned by ShowModal.
@see ShowModal(), GetReturnCode(), SetReturnCode()
*/
virtual void EndModal(int retCode);
/**
Gets the identifier of the button which works like standard OK button
in this dialog.
@see SetAffirmativeId()
*/
int GetAffirmativeId() const;
/**
Override this to return a window containing the main content of the
dialog. This is particularly useful when the dialog implements pages,
such as wxPropertySheetDialog, and allows the
@ref overview_dialog "layout adaptation code" to know that only the
pages need to be made scrollable.
*/
virtual wxWindow* GetContentWindow() const;
/**
Gets the identifier of the button to map presses of @c ESC button to.
@see SetEscapeId()
*/
int GetEscapeId() const;
/**
Returns @true if the dialog has been adapted, usually by making it
scrollable to work with a small display.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
bool GetLayoutAdaptationDone() const;
/**
Gets a value representing the aggressiveness of search for buttons and
sizers to be in the non-scrolling part of a layout-adapted dialog. Zero
switches off adaptation, and 3 allows search for standard buttons
anywhere in the dialog.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
int GetLayoutAdaptationLevel() const;
/**
Gets the adaptation mode, overriding the global adaptation flag.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
wxDialogLayoutAdaptationMode GetLayoutAdaptationMode() const;
/**
A static function getting the current layout adapter object.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
static wxDialogLayoutAdapter* GetLayoutAdapter();
/**
Returns an array of identifiers to be regarded as the main buttons for
the non-scrolling area of a dialog.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
wxArrayInt& GetMainButtonIds();
/**
Gets the return code for this window.
@remarks A return code is normally associated with a modal dialog,
where ShowModal() returns a code to the application.
@see SetReturnCode(), ShowModal(), EndModal()
*/
int GetReturnCode() const;
/**
On PocketPC, a dialog is automatically provided with an empty toolbar.
This function allows you to access the toolbar and add tools to it.
Removing tools and adding arbitrary controls are not currently
supported.
This function is not available on any other platform.
@onlyfor{wxmsw}
*/
wxToolBar* GetToolBar() const;
/**
Iconizes or restores the dialog. Windows only.
@param iconize
If @true, iconizes the dialog box; if @false, shows and restores it.
@remarks Note that in Windows, iconization has no effect since dialog
boxes cannot be iconized. However calling Iconize(@false) will
bring the window to the front, as does Show(@true).
*/
virtual void Iconize(bool iconize = true);
/**
Returns @true if the dialog box is iconized. Windows only.
@remarks Always returns @false under Windows since dialogs cannot be
iconized.
*/
virtual bool IsIconized() const;
/**
A static function returning @true if layout adaptation is enabled for
all dialogs.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
static bool IsLayoutAdaptationEnabled();
/**
Returns @true if @a id is in the array of identifiers to be regarded as
the main buttons for the non-scrolling area of a dialog.
@onlyfor{wxmsw}
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
bool IsMainButtonId(wxWindowID id) const;
/**
Returns @true if the dialog box is modal, @false otherwise.
*/
virtual bool IsModal() const;
/**
Sets the identifier to be used as OK button. When the button with this
identifier is pressed, the dialog calls wxWindow::Validate() and
wxWindow::TransferDataFromWindow() and, if they both return @true,
closes the dialog with the affirmative id return code.
Also, when the user presses a hardware OK button on the devices having
one or the special OK button in the PocketPC title bar, an event with
this id is generated.
By default, the affirmative id is wxID_OK.
@see GetAffirmativeId(), SetEscapeId()
*/
void SetAffirmativeId(int id);
/**
Sets the identifier of the button which should work like the standard
"Cancel" button in this dialog. When the button with this id is
clicked, the dialog is closed. Also, when the user presses @c ESC key
in the dialog or closes the dialog using the close button in the title
bar, this is mapped to the click of the button with the specified id.
By default, the escape id is the special value wxID_ANY meaning that
wxID_CANCEL button is used if it's present in the dialog and otherwise
the button with GetAffirmativeId() is used. Another special value for
@a id is wxID_NONE meaning that @c ESC presses should be ignored. If
any other value is given, it is interpreted as the id of the button to
map the escape key to.
@note This method should be used for custom modal dialog implemented in
wxWidgets itself, native dialogs such as wxMessageDialog or
wxFileDialog, handle @c ESC presses in their own way which cannot be
customized.
*/
void SetEscapeId(int id);
/**
Sets the icon for this dialog.
@param icon
The icon to associate with this dialog.
@see wxIcon
*/
void SetIcon(const wxIcon& icon);
/**
Sets the icons for this dialog.
@param icons
The icons to associate with this dialog.
@see wxIconBundle
*/
void SetIcons(const wxIconBundle& icons);
/**
Marks the dialog as having been adapted, usually by making it
scrollable to work with a small display.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
void SetLayoutAdaptationDone(bool done);
/**
Sets the aggressiveness of search for buttons and sizers to be in the
non-scrolling part of a layout-adapted dialog. Zero switches off
adaptation, and 3 allows search for standard buttons anywhere in the
dialog.
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
*/
void SetLayoutAdaptationLevel(int level);
/**
Sets the adaptation mode, overriding the global adaptation flag.
@see wxDialogLayoutAdaptationMode, @ref overview_dialog_autoscrolling
(for more on layout adaptation)
*/
void SetLayoutAdaptationMode(wxDialogLayoutAdaptationMode mode);
/**
A static function for setting the current layout adapter object,
returning the old adapter. If you call this, you should delete the old
adapter object.
@see wxDialogLayoutAdapter, @ref overview_dialog_autoscrolling
*/
static wxDialogLayoutAdapter* SetLayoutAdapter(wxDialogLayoutAdapter* adapter);
/**
Sets the return code for this window.
A return code is normally associated with a modal dialog, where
ShowModal() returns a code to the application. The function EndModal()
calls SetReturnCode().
@param retCode
The integer return code, usually a control identifier.
@see GetReturnCode(), ShowModal(), EndModal()
*/
void SetReturnCode(int retCode);
/**
Hides or shows the dialog. The preferred way of dismissing a modal
dialog is to use EndModal().
@param show
If @true, the dialog box is shown and brought to the front,
otherwise the box is hidden. If @false and the dialog is modal,
control is returned to the calling program.
*/
virtual bool Show(bool show = true);
/**
Shows an application-modal dialog.
Program flow does not return until the dialog has been dismissed with
EndModal().
Notice that it is possible to call ShowModal() for a dialog which had
been previously shown with Show(), this allows making an existing
modeless dialog modal. However ShowModal() can't be called twice
without intervening EndModal() calls.
Note that this function creates a temporary event loop which takes
precedence over the application's main event loop (see wxEventLoopBase)
and which is destroyed when the dialog is dismissed.
This also results in a call to wxApp::ProcessPendingEvents().
@return The value set with SetReturnCode().
@see ShowWindowModal(), ShowWindowModalThenDo(),
EndModal(), GetReturnCode(), SetReturnCode()
*/
virtual int ShowModal();
/**
Shows a dialog modal to the parent top level window only.
Unlike ShowModal(), dialogs shown with this function only prevent the
user from interacting with their parent frame only but not with the
rest of the application. They also don't block the program execution
but instead return immediately, as Show(), and generate a
wxEVT_WINDOW_MODAL_DIALOG_CLOSED event (wxWindowModalDialogEvent)
later when the dialog is closed.
Currently this function is only fully implemented in wxOSX ports, under
the other platforms it behaves like ShowModal() (but also sends the
above mentioned event).
@see wxWindowModalDialogEvent, ShowWindowModalThenDo()
@since 2.9.0
*/
void ShowWindowModal();
/**
Shows a dialog modal to the parent top level window only and call a
functor after the dialog is closed.
Same as the other ShowWindowModal() overload, but calls the functor
passed as the argument upon completion, instead of generating the
wxEVT_WINDOW_MODAL_DIALOG_CLOSED event.
This form is particularly useful in combination with lambdas,
when it allows writing window-modal very similarly to how ShowModal()
is used (with the notable exception of not being able to create
the dialog on stack):
@code
wxWindowPtr<wxDialog> dlg(new wxMessageDialog(this, "Hello!"));
dlg->ShowWindowModalThenDo([this,dlg](int retcode){
if ( retcode == wxID_OK )
DoSomething();
// dlg is implicitly destroyed here, because the pointer was
// explicitly captured by the lambda
});
@endcode
@param onEndModal Function object to call when the dialog is
closed. The functor is called with a single
integer argument, dialog's return code.
@note The dialog instance must not be destroyed until @a onEndModal
is called. The best way to ensure that is to use wxWindowPtr
to hold a pointer and include it in the lambda's capture,
by value (not reference!), as shown in the example above.
@since 3.0
@see wxWindowPtr<T>
*/
template<typename Functor>
void ShowWindowModalThenDo(const Functor& onEndModal);
};
/**
@class wxDialogLayoutAdapter
This abstract class is the base for classes that help wxWidgets perform
run-time layout adaptation of dialogs. Principally, this is to cater for
small displays by making part of the dialog scroll, but the application
developer may find other uses for layout adaption.
By default, there is one instance of wxStandardDialogLayoutAdapter which
can perform adaptation for most custom dialogs and dialogs with book
controls such as wxPropertySheetDialog.
@library{wxcore}
@category{winlayout}
@see @ref overview_dialog_autoscrolling
*/
class wxDialogLayoutAdapter
{
public:
/**
Default constructor.
*/
wxDialogLayoutAdapter();
/**
Override this to returns @true if adaptation can and should be done.
*/
virtual bool CanDoLayoutAdaptation(wxDialog* dialog) = 0;
/**
Override this to perform layout adaptation, such as making parts of the
dialog scroll and resizing the dialog to fit the display. Normally this
function will be called just before the dialog is shown.
*/
virtual bool DoLayoutAdaptation(wxDialog* dialog) = 0;
};
/**
Event sent by wxDialog::ShowWindowModal() when the dialog closes.
@since 2.9.0
*/
class wxWindowModalDialogEvent : public wxCommandEvent
{
public:
/// Constructor
wxWindowModalDialogEvent (wxEventType commandType = wxEVT_NULL, int id = 0);
/// Return the corresponding dialog.
wxDialog *GetDialog() const;
/// Return the dialog's return code.
int GetReturnCode() const;
/// Clone the event.
virtual wxEvent *Clone() const;
};

View File

@@ -0,0 +1,215 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dialup.h
// Purpose: interface of wxDialUpManager
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDialUpManager
This class encapsulates functions dealing with verifying the connection
status of the workstation (connected to the Internet via a direct
connection, connected through a modem or not connected at all) and to
establish this connection if possible/required (i.e. in the case of the
modem).
The program may also wish to be notified about the change in the connection
status (for example, to perform some action when the user connects to the
network the next time or, on the contrary, to stop receiving data from the
net when the user hangs up the modem). For this, you need to use one of the
event macros described below.
This class is different from other wxWidgets classes in that there is at
most one instance of this class in the program accessed via Create() and
you can't create the objects of this class directly.
@beginEventEmissionTable{wxDialUpEvent}
@event{EVT_DIALUP_CONNECTED(func)}
A connection with the network was established.
@event{EVT_DIALUP_DISCONNECTED(func)}
The connection with the network was lost.
@endEventTable
@library{wxcore}
@category{net}
@see @ref page_samples_dialup, wxDialUpEvent
*/
class wxDialUpManager
{
public:
/**
Destructor.
*/
virtual ~wxDialUpManager();
/**
Cancel dialing the number initiated with Dial() with async parameter
equal to @true.
@note This won't result in a DISCONNECTED event being sent.
@see IsDialing()
*/
virtual bool CancelDialing() = 0;
/**
This function should create and return the object of the
platform-specific class derived from wxDialUpManager. You should delete
the pointer when you are done with it.
*/
static wxDialUpManager* Create();
/**
Dial the given ISP, use @a username and @a password to authenticate.
The parameters are only used under Windows currently, for Unix you
should use SetConnectCommand() to customize this functions behaviour.
If no @a nameOfISP is given, the function will select the default one
(proposing the user to choose among all connections defined on this
machine) and if no username and/or password are given, the function
will try to do without them, but will ask the user if really needed.
If @a async parameter is @false, the function waits until the end of
dialing and returns @true upon successful completion.
If @a async is @true, the function only initiates the connection and
returns immediately - the result is reported via events (an event is
sent anyhow, but if dialing failed it will be a DISCONNECTED one).
*/
virtual bool Dial(const wxString& nameOfISP = wxEmptyString,
const wxString& username = wxEmptyString,
const wxString& password = wxEmptyString,
bool async = true) = 0;
/**
Disable automatic check for connection status change - notice that the
@c wxEVT_DIALUP_XXX events won't be sent any more either.
*/
virtual void DisableAutoCheckOnlineStatus() = 0;
/**
Enable automatic checks for the connection status and sending of
@c wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events. The interval
parameter is only for Unix where we do the check manually and specifies
how often should we repeat the check (each minute by default). Under
Windows, the notification about the change of connection status is sent
by the system and so we don't do any polling and this parameter is
ignored.
@return @false if couldn't set up automatic check for online status.
*/
virtual bool EnableAutoCheckOnlineStatus(size_t nSeconds = 60) = 0;
/**
This function is only implemented under Windows.
Fills the array with the names of all possible values for the first
parameter to Dial() on this machine and returns their number (may be
0).
*/
virtual size_t GetISPNames(wxArrayString& names) const = 0;
/**
Hang up the currently active dial up connection.
*/
virtual bool HangUp() = 0;
/**
Returns @true if the computer has a permanent network connection (i.e.\
is on a LAN) and so there is no need to use Dial() function to go
online.
@note This function tries to guess the result and it is not always
guaranteed to be correct, so it is better to ask user for
confirmation or give him a possibility to override it.
*/
virtual bool IsAlwaysOnline() const = 0;
/**
Returns @true if (async) dialing is in progress.
@see Dial()
*/
virtual bool IsDialing() const = 0;
/**
Returns @true if the dialup manager was initialized correctly. If this
function returns @false, no other functions will work either, so it is
a good idea to call this function and check its result before calling
any other wxDialUpManager methods.
*/
virtual bool IsOk() const = 0;
/**
Returns @true if the computer is connected to the network: under
Windows, this just means that a RAS connection exists, under Unix we
check that the "well-known host" (as specified by SetWellKnownHost())
is reachable.
*/
virtual bool IsOnline() const = 0;
/**
This method is for Unix only.
Sets the commands to start up the network and to hang up again.
*/
virtual void SetConnectCommand(const wxString& commandDial = "/usr/bin/pon",
const wxString& commandHangup = "/usr/bin/poff") = 0;
/**
Sometimes the built-in logic for determining the online status may
fail, so, in general, the user should be allowed to override it. This
function allows forcefully setting the online status - whatever our
internal algorithm may think about it.
@see IsOnline()
*/
virtual void SetOnlineStatus(bool isOnline = true) = 0;
/**
This method is for Unix only.
Under Unix, the value of well-known host is used to check whether we're
connected to the internet. It is unused under Windows, but this
function is always safe to call. The default value is
@c "www.yahoo.com:80".
*/
virtual void SetWellKnownHost(const wxString& hostname,
int portno = 80) = 0;
};
/**
@class wxDialUpEvent
This is the event class for the dialup events sent by wxDialUpManager.
@library{wxcore}
@category{events}
*/
class wxDialUpEvent : public wxEvent
{
public:
/**
Constructor is only used by wxDialUpManager.
*/
wxDialUpEvent(bool isConnected, bool isOwnEvent);
/**
Is this a @c CONNECTED or @c DISCONNECTED event? In other words, does
it notify about transition from offline to online state or vice versa?
*/
bool IsConnectedEvent() const;
/**
Does this event come from wxDialUpManager::Dial() or from some external
process (i.e. does it result from our own attempt to establish the
connection)?
*/
bool IsOwnEvent() const;
};

View File

@@ -0,0 +1,379 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dir.h
// Purpose: interface of wxDir and wxDirTraverser
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Possible return values of wxDirTraverser callback functions.
*/
enum wxDirTraverseResult
{
wxDIR_IGNORE = -1, ///< Ignore this directory but continue with others.
wxDIR_STOP, ///< Stop traversing.
wxDIR_CONTINUE ///< Continue into this directory.
};
/**
The return value of wxDir::GetTotalSize() in case of error.
*/
wxULongLong wxInvalidSize;
/**
@class wxDirTraverser
wxDirTraverser is an abstract interface which must be implemented by
objects passed to wxDir::Traverse() function.
Example of use (this works almost like wxDir::GetAllFiles()):
@code
class wxDirTraverserSimple : public wxDirTraverser
{
public:
wxDirTraverserSimple(wxArrayString& files) : m_files(files) { }
virtual wxDirTraverseResult OnFile(const wxString& filename)
{
m_files.Add(filename);
return wxDIR_CONTINUE;
}
virtual wxDirTraverseResult OnDir(const wxString& WXUNUSED(dirname))
{
return wxDIR_CONTINUE;
}
private:
wxArrayString& m_files;
};
// get the names of all files in the array
wxArrayString files;
wxDirTraverserSimple traverser(files);
wxDir dir(dirname);
dir.Traverse(traverser);
@endcode
@library{wxbase}
@category{file}
*/
class wxDirTraverser
{
public:
/**
This function is called for each directory. It may return ::wxDIR_STOP
to abort traversing completely, ::wxDIR_IGNORE to skip this directory
but continue with others or ::wxDIR_CONTINUE to enumerate all files and
subdirectories in this directory.
This is a pure virtual function and must be implemented in the derived
class.
*/
virtual wxDirTraverseResult OnDir(const wxString& dirname) = 0;
/**
This function is called for each file. It may return ::wxDIR_STOP to
abort traversing (for example, if the file being searched is found) or
::wxDIR_CONTINUE to proceed.
This is a pure virtual function and must be implemented in the derived
class.
*/
virtual wxDirTraverseResult OnFile(const wxString& filename) = 0;
/**
This function is called for each directory which we failed to open for
enumerating. It may return ::wxDIR_STOP to abort traversing completely,
::wxDIR_IGNORE to skip this directory but continue with others or
::wxDIR_CONTINUE to retry opening this directory once again.
The base class version always returns ::wxDIR_IGNORE.
*/
virtual wxDirTraverseResult OnOpenError(const wxString& openerrorname);
};
/**
These flags affect the behaviour of GetFirst/GetNext() and Traverse(),
determining what types are included in the list of items they produce.
*/
enum wxDirFlags
{
wxDIR_FILES = 0x0001, ///< Includes files.
wxDIR_DIRS = 0x0002, ///< Includes directories.
wxDIR_HIDDEN = 0x0004, ///< Includes hidden files.
wxDIR_DOTDOT = 0x0008, ///< Includes "." and "..".
/**
Don't follow symbolic links during the directory traversal.
This flag is ignored under systems not supporting symbolic links (i.e.
non-Unix ones).
Notice that this flag is @e not included in wxDIR_DEFAULT and so the
default behaviour of wxDir::Traverse() is to follow symbolic links,
even if they lead outside of the directory being traversed.
@since 2.9.5
*/
wxDIR_NO_FOLLOW = 0x0010,
/**
Default directory traversal flags include both files and directories,
even hidden.
Notice that by default wxDIR_NO_FOLLOW is @e not included, meaning that
symbolic links are followed by default. If this is not desired, you
must pass that flag explicitly.
*/
wxDIR_DEFAULT = wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN
};
/**
@class wxDir
wxDir is a portable equivalent of Unix open/read/closedir functions which
allow enumerating of the files in a directory. wxDir allows enumerating
files as well as directories.
wxDir also provides a flexible way to enumerate files recursively using
Traverse() or a simpler GetAllFiles() function.
Example of use:
@code
wxDir dir(wxGetCwd());
if ( !dir.IsOpened() )
{
// deal with the error here - wxDir would already log an error message
// explaining the exact reason of the failure
return;
}
puts("Enumerating object files in current directory:");
wxString filename;
bool cont = dir.GetFirst(&filename, filespec, flags);
while ( cont )
{
printf("%s\n", filename.c_str());
cont = dir.GetNext(&filename);
}
@endcode
@library{wxbase}
@category{file}
*/
class wxDir
{
public:
/**
Default constructor, use Open() afterwards.
*/
wxDir();
/**
Opens the directory for enumeration, use IsOpened() to test for errors.
*/
wxDir(const wxString& dir);
/**
Destructor cleans up the associated resources by calling Close().
It is not virtual and so this class is not meant to be used
polymorphically.
*/
~wxDir();
/**
Close the directory.
The object can't be used after closing it, but Open() may be called
again to reopen it later.
@since 2.9.5
*/
void Close();
/**
Test for existence of a directory with the given name.
*/
static bool Exists(const wxString& dir);
/**
The function returns the path of the first file matching the given
@a filespec or an empty string if there are no files matching it.
The @a flags parameter may or may not include ::wxDIR_FILES, the
function always behaves as if it were specified. By default, @a flags
includes ::wxDIR_DIRS and so the function recurses into the
subdirectories but if this flag is not specified, the function
restricts the search only to the directory @a dirname itself.
See ::wxDirFlags for the list of the possible flags.
@see Traverse()
*/
static wxString FindFirst(const wxString& dirname,
const wxString& filespec,
int flags = wxDIR_DEFAULT);
/**
The function appends the names of all the files under directory
@a dirname to the array @a files (note that its old content is
preserved).
Only files matching the @a filespec are taken, with empty spec matching
all non-hidden files (use ::wxDIR_HIDDEN to include them too).
The @a flags parameter should always include ::wxDIR_FILES or the array
would be unchanged and should include ::wxDIR_DIRS flag to recurse into
subdirectories (both flags are included in the value by default).
See ::wxDirFlags for the list of the possible flags.
@return Returns the total number of files found while traversing
the directory @a dirname (i.e. the number of entries appended
to the @a files array).
@see Traverse()
*/
static size_t GetAllFiles(const wxString& dirname, wxArrayString* files,
const wxString& filespec = wxEmptyString,
int flags = wxDIR_DEFAULT);
/**
Start enumerating all files matching @a filespec (or all files if it is
empty) and @e flags, return @true on success.
See ::wxDirFlags for the list of the possible flags.
*/
bool GetFirst(wxString* filename,
const wxString& filespec = wxEmptyString,
int flags = wxDIR_DEFAULT) const;
/**
Returns the name of the directory itself.
The returned string does not have the trailing path separator (slash or
backslash).
Notice that in spite of this the last character of the returned string
can still be the path separator if this directory is the root one.
Because of this, don't append @c wxFILE_SEP_PATH to the returned value
if you do need a slash-terminated directory name but use
GetNameWithSep() instead to avoid having duplicate consecutive slashes.
*/
wxString GetName() const;
/**
Returns the name of the directory with the path separator appended.
The last character of the returned string is always @c wxFILE_SEP_PATH
unless the string is empty, indicating that this directory is invalid.
@see GetName()
@since 2.9.4
*/
wxString GetNameWithSep() const;
/**
Continue enumerating files which satisfy the criteria specified by the
last call to GetFirst().
*/
bool GetNext(wxString* filename) const;
/**
Returns the size (in bytes) of all files recursively found in @c dir or
@c wxInvalidSize in case of error.
In case it happens that while traversing folders a file's size cannot
be read, that file is added to the @a filesSkipped array, if not @NULL,
and then skipped. This usually happens with some special folders which
are locked by the operating system or by another process. Remember that
when the size of @a filesSkipped is not zero, then the returned value
is not 100% accurate and, if the skipped files were big, it could be
far from real size of the directory.
@see wxFileName::GetHumanReadableSize(), wxGetDiskSpace()
*/
static wxULongLong GetTotalSize(const wxString& dir,
wxArrayString* filesSkipped = nullptr);
/**
Returns @true if the directory contains any files matching the given
@a filespec. If @a filespec is empty, look for any files at all. In any
case, even hidden files are taken into account.
*/
bool HasFiles(const wxString& filespec = wxEmptyString) const;
/**
Returns @true if the directory contains any subdirectories (if a non
empty @a dirspec is given, only check for directories matching it).
The hidden subdirectories are taken into account as well.
*/
bool HasSubDirs(const wxString& dirspec = wxEmptyString) const;
/**
Returns @true if the directory was successfully opened by a previous
call to Open().
*/
bool IsOpened() const;
/**
Creates a directory.
This is just an alias for wxFileName::Mkdir(); refer to that function
for more info.
*/
static bool Make(const wxString &dir, int perm = wxS_DIR_DEFAULT,
int flags = 0);
/**
Open the directory for enumerating, returns @true on success or @false
if an error occurred.
*/
bool Open(const wxString& dir);
/**
Removes a directory.
This is just an alias for wxFileName::Rmdir(); refer to that function
for more info.
*/
static bool Remove(const wxString &dir, int flags = 0);
/**
Enumerate all files and directories under the given directory.
If @a flags contains ::wxDIR_DIRS this enumeration is recursive, i.e.
all the subdirectories of the given one and the files inside them will
be traversed. Otherwise only the files in this directory itself are.
If @a flags doesn't contain ::wxDIR_FILES then only subdirectories are
examined but not normal files. It doesn't make sense to not specify
either ::wxDIR_DIRS or ::wxDIR_FILES and usually both of them should be
specified, as is the case by default.
For each directory found, @ref wxDirTraverser::OnDir() "sink.OnDir()"
is called and @ref wxDirTraverser::OnFile() "sink.OnFile()" is called
for every file. Depending on the return value, the enumeration may
continue or stop. If entering a subdirectory fails, @ref
wxDirTraverser::OnOpenError() "sink.OnOpenError()" is called.
The function returns the total number of files found or @c "(size_t)-1"
on error.
See ::wxDirFlags for the full list of the possible flags.
@see GetAllFiles()
*/
size_t Traverse(wxDirTraverser& sink,
const wxString& filespec = wxEmptyString,
int flags = wxDIR_DEFAULT) const;
};

View File

@@ -0,0 +1,289 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dirctrl.h
// Purpose: interface of wxGenericDirCtrl
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
enum
{
// Only allow directory viewing/selection, no files
wxDIRCTRL_DIR_ONLY = 0x0010,
// When setting the default path, select the first file in the directory
wxDIRCTRL_SELECT_FIRST = 0x0020,
// Show the filter list
wxDIRCTRL_SHOW_FILTERS = 0x0040,
// Use 3D borders on internal controls
wxDIRCTRL_3D_INTERNAL = 0x0080,
// Editable labels
wxDIRCTRL_EDIT_LABELS = 0x0100,
// Allow multiple selection
wxDIRCTRL_MULTIPLE = 0x0200,
wxDIRCTRL_DEFAULT_STYLE = wxDIRCTRL_3D_INTERNAL
};
/**
@class wxGenericDirCtrl
This control can be used to place a directory listing (with optional
files) on an arbitrary window.
The control contains a wxTreeCtrl window representing the directory
hierarchy, and optionally, a wxChoice window containing a list of filters.
@beginStyleTable
@style{wxDIRCTRL_DIR_ONLY}
Only show directories, and not files.
@style{wxDIRCTRL_3D_INTERNAL}
Use 3D borders for internal controls. This is the default.
@style{wxDIRCTRL_SELECT_FIRST}
When setting the default path, select the first file in the
directory.
@style{wxDIRCTRL_SHOW_FILTERS}
Show the drop-down filter list.
@style{wxDIRCTRL_EDIT_LABELS}
Allow the folder and file labels to be editable.
@style{wxDIRCTRL_MULTIPLE}
Allows multiple files and folders to be selected.
@endStyleTable
@library{wxcore}
@category{ctrl}
@appearance{genericdirctrl}
@beginEventEmissionTable
@event{EVT_DIRCTRL_SELECTIONCHANGED(id, func)}
Selected directory has changed.
Processes a @c wxEVT_DIRCTRL_SELECTIONCHANGED event type.
Notice that this event is generated even for the changes done by the
program itself and not only those done by the user.
Available since wxWidgets 2.9.5.
@event{EVT_DIRCTRL_FILEACTIVATED(id, func)}
The user activated a file by double-clicking or pressing Enter.
Available since wxWidgets 2.9.5.
@endEventTable
*/
class wxGenericDirCtrl : public wxControl
{
public:
/**
Default constructor.
*/
wxGenericDirCtrl();
/**
Main constructor.
@param parent
Parent window.
@param id
Window identifier.
@param dir
Initial folder.
@param pos
Position.
@param size
Size.
@param style
Window style. Please see wxGenericDirCtrl for a list of possible
styles.
@param filter
A filter string, using the same syntax as that for wxFileDialog.
This may be empty if filters are not being used. Example:
@c "All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg"
@param defaultFilter
The zero-indexed default filter setting.
@param name
The window name.
*/
wxGenericDirCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxString& dir = wxDirDialogDefaultFolderStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDIRCTRL_DEFAULT_STYLE,
const wxString& filter = wxEmptyString,
int defaultFilter = 0,
const wxString& name = wxTreeCtrlNameStr);
/**
Destructor.
*/
virtual ~wxGenericDirCtrl();
/**
Collapse the given @a path.
*/
virtual bool CollapsePath(const wxString& path);
/**
Collapses the entire tree.
*/
virtual void CollapseTree();
/**
Create function for two-step construction. See wxGenericDirCtrl() for
details.
*/
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxString& dir = wxDirDialogDefaultFolderStr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDIRCTRL_DEFAULT_STYLE,
const wxString& filter = wxEmptyString, int defaultFilter = 0,
const wxString& name = wxTreeCtrlNameStr);
/**
Tries to expand as much of the given @a path as possible, so that the
filename or directory is visible in the tree control.
*/
virtual bool ExpandPath(const wxString& path);
/**
Gets the default path.
*/
virtual wxString GetDefaultPath() const;
/**
Gets selected filename path only (else empty string).
This function doesn't count a directory as a selection.
*/
virtual wxString GetFilePath() const;
/**
Fills the array @a paths with the currently selected filepaths.
This function doesn't count a directory as a selection.
*/
virtual void GetFilePaths(wxArrayString& paths) const;
/**
Returns the filter string.
*/
virtual wxString GetFilter() const;
/**
Returns the current filter index (zero-based).
*/
virtual int GetFilterIndex() const;
/**
Returns a pointer to the filter list control (if present).
*/
virtual wxDirFilterListCtrl* GetFilterListCtrl() const;
/**
Gets the currently-selected directory or filename.
*/
virtual wxString GetPath() const;
/**
Gets the path corresponding to the given tree control item.
@since 2.9.5
*/
wxString GetPath(wxTreeItemId itemId) const;
/**
Fills the array @a paths with the selected directories and filenames.
*/
virtual void GetPaths(wxArrayString& paths) const;
/**
Returns the root id for the tree control.
*/
virtual wxTreeItemId GetRootId();
/**
Returns a pointer to the tree control.
*/
virtual wxTreeCtrl* GetTreeCtrl() const;
/**
Initializes variables.
*/
virtual void Init();
/**
Collapse and expand the tree, thus re-creating it from scratch. May be
used to update the displayed directory content.
*/
virtual void ReCreateTree();
/**
Sets the default path.
*/
virtual void SetDefaultPath(const wxString& path);
/**
Sets the filter string.
*/
virtual void SetFilter(const wxString& filter);
/**
Sets the current filter index (zero-based).
*/
virtual void SetFilterIndex(int n);
/**
Sets the current path.
*/
virtual void SetPath(const wxString& path);
/**
@param show
If @true, hidden folders and files will be displayed by the
control. If @false, they will not be displayed.
*/
virtual void ShowHidden(bool show);
/**
Selects the given item.
In multiple selection controls, can be also used to deselect a
currently selected item if the value of @a select is false.
Existing selections are not changed. Only visible items can be
(de)selected, otherwise use ExpandPath().
*/
virtual void SelectPath(const wxString& path, bool select = true);
/**
Selects only the specified paths, clearing any previous selection.
Only supported when wxDIRCTRL_MULTIPLE is set.
*/
virtual void SelectPaths(const wxArrayString& paths);
/**
Removes the selection from all currently selected items.
*/
virtual void UnselectAll();
};
class wxDirFilterListCtrl: public wxChoice
{
public:
wxDirFilterListCtrl();
wxDirFilterListCtrl(wxGenericDirCtrl* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
bool Create(wxGenericDirCtrl* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0);
virtual ~wxDirFilterListCtrl();
void Init();
//// Operations
void FillFilterList(const wxString& filter, int defaultFilter);
};
wxEventType wxEVT_DIRCTRL_SELECTIONCHANGED;
wxEventType wxEVT_DIRCTRL_FILEACTIVATED;

View File

@@ -0,0 +1,177 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dirdlg.h
// Purpose: interface of wxDirDialog
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#define wxDD_CHANGE_DIR 0x0100
#define wxDD_DIR_MUST_EXIST 0x0200
#define wxDD_MULTIPLE 0x0400
#define wxDD_SHOW_HIDDEN 0x0001
#define wxDD_NEW_DIR_BUTTON 0 // deprecated, on by default now,
#define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
/**
Initial folder for generic directory dialog.
*/
const char wxDirDialogDefaultFolderStr[] = "/";
/**
Default message for directory selector dialog.
*/
const char wxDirSelectorPromptStr[] = "Select a directory";
/**
Default name for directory selector dialog.
*/
const char wxDirDialogNameStr[] = "wxDirCtrl";
/**
@class wxDirDialog
This class represents the directory chooser dialog.
@beginStyleTable
@style{wxDD_DEFAULT_STYLE}
Equivalent to a combination of @c wxDEFAULT_DIALOG_STYLE and
@c wxRESIZE_BORDER.
@style{wxDD_DIR_MUST_EXIST}
The dialog will allow the user to choose only an existing folder.
When this style is not given, a "Create new directory" button is
added to the dialog or some other way is provided to
the user to type the name of a new folder.
@style{wxDD_CHANGE_DIR}
Change the current working directory to the directory chosen by the
user.
This flag cannot be used with the @c wxDD_MULTIPLE style.
@style{wxDD_MULTIPLE}
Allow the user to select multiple directories.
This flag is only available since wxWidgets 3.1.4.
@style{wxDD_SHOW_HIDDEN}
Show hidden and system folders.
This flag is only available since wxWidgets 3.1.4.
@endStyleTable
@remarks macOS 10.11+ does not display a title bar on the dialog. Use SetMessage()
to change the string displayed to the user at the top of the dialog after creation.
The SetTitle() method is provided for compatibility with pre-10.11 macOS versions
that do still support displaying the title bar.
@library{wxcore}
@category{cmndlg}
@see @ref overview_cmndlg_dir, ::wxDirSelector(), wxDirPickerCtrl, wxFileDialog
*/
class wxDirDialog : public wxDialog
{
public:
/**
Constructor. Use ShowModal() to show the dialog.
@param parent
Parent window.
@param message
Message to show on the dialog.
@param defaultPath
The default path, or the empty string.
@param style
The dialog style, see @c wxDD_* styles for more info.
@param pos
Dialog position. Ignored under Windows.
@param size
Dialog size. Ignored under Windows.
@param name
The dialog name, not used.
*/
wxDirDialog(wxWindow* parent,
const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxEmptyString,
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString& name = wxDirDialogNameStr);
/**
Destructor.
*/
virtual ~wxDirDialog();
/**
Returns the message that will be displayed on the dialog.
*/
virtual wxString GetMessage() const;
/**
Returns the default or user-selected path.
@note This function can't be used with dialogs which have the @c wxDD_MULTIPLE style,
use GetPaths() instead.
*/
virtual wxString GetPath() const;
/**
Fills the array @a paths with the full paths of the chosen directories.
@note This function should only be used with the dialogs which have @c wxDD_MULTIPLE style,
use GetPath() for the others.
@since 3.1.4
*/
virtual void GetPaths(wxArrayString& paths) const;
/**
Sets the message that will be displayed on the dialog.
*/
virtual void SetMessage(const wxString& message);
/**
Sets the default path.
*/
virtual void SetPath(const wxString& path);
/**
Shows the dialog, returning @c wxID_OK if the user pressed OK, and
@c wxID_CANCEL otherwise.
*/
int ShowModal();
};
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_dialog */
///@{
/**
Pops up a directory selector dialog. The arguments have the same meaning
as those of wxDirDialog::wxDirDialog(). The message is displayed at the
top, and the @a defaultPath, if specified, is set as the initial selection.
The application must check for an empty return value (if the user pressed
Cancel). For example:
@code
const wxString dir = wxDirSelector("Choose a folder");
if ( !dir.empty() )
{
...
}
@endcode
@header{wx/dirdlg.h}
*/
wxString wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxEmptyString,
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
wxWindow* parent = nullptr);
///@}

View File

@@ -0,0 +1,236 @@
/////////////////////////////////////////////////////////////////////////////
// Name: display.h
// Purpose: interface of wxDisplay
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDisplay
Determines the sizes and locations of displays connected to the system.
@library{wxcore}
@category{cfg}
*/
class wxDisplay
{
public:
/**
Default constructor creating wxDisplay object representing the primary
display.
*/
wxDisplay();
/**
Constructor, setting up a wxDisplay instance with the specified
display.
@param index
The index of the display to use. This must be non-negative and
lower than the value returned by GetCount().
*/
explicit wxDisplay(unsigned int index);
/**
Constructor creating the display object associated with the given
window.
This is the most convenient way of finding the display on which the
given window is shown while falling back to the default display if it
is not shown at all or positioned outside of any display.
@param window
A valid, i.e. non-null, window.
@see GetFromWindow()
@since 3.1.2
*/
explicit wxDisplay(const wxWindow* window);
/**
Destructor.
*/
~wxDisplay();
/**
Changes the video mode of this display to the mode specified in the
mode parameter.
If wxDefaultVideoMode is passed in as the mode parameter, the defined
behaviour is that wxDisplay will reset the video mode to the default
mode used by the display. On Windows, the behaviour is normal. However,
there are differences on other platforms. On Unix variations using X11
extensions it should behave as defined, but some irregularities may
occur.
*/
bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode);
/**
Returns the client area of the display. The client area is the part of
the display available for the normal (non full screen) windows, usually
it is the same as GetGeometry() but it could be less if there is a
taskbar (or equivalent) on this display.
*/
wxRect GetClientArea() const;
/**
Returns the number of connected displays.
*/
static unsigned int GetCount();
/**
Returns the current video mode that this display is in.
*/
wxVideoMode GetCurrentMode() const;
/**
Returns the index of the display on which the given point lies, or
@c wxNOT_FOUND if the point is not on any connected display.
@param pt
The point to locate.
*/
static int GetFromPoint(const wxPoint& pt);
/**
Returns the index of the display with biggest intersection with the
given rectangle or @c wxNOT_FOUND if the rectangle doesn't intersect
any display.
Note that usually the returned display will be the same display which
contains the center of the rectangle, but this is not always the case,
as rectangle might be partly visible even if its center is off screen,
and in this case GetFromPoint() would returns @c wxNOT_FOUND, but this
function would return a valid display.
@param rect
The rectangle to check.
@since 3.3.0
*/
static int GetFromRect(const wxRect& rect);
/**
Returns the index of the display on which the given window lies.
If the window is on more than one display it gets the display that
overlaps the window the most.
Returns @c wxNOT_FOUND if the window is not on any connected display.
@param win
The window to locate.
*/
static int GetFromWindow(const wxWindow* win);
/**
Returns the bounding rectangle of the display whose index was passed to
the constructor.
@see GetClientArea(), wxDisplaySize()
*/
wxRect GetGeometry() const;
/**
Fills and returns an array with all the video modes that are supported
by this display, or video modes that are supported by this display and
match the mode parameter (if mode is not wxDefaultVideoMode).
*/
wxArrayVideoModes GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const;
/**
Returns the display's name.
The returned value is currently an empty string under all platforms
except MSW.
*/
wxString GetName() const;
/**
Returns display depth, i.e. number of bits per pixel (0 if unknown)
@since 3.1.2
*/
int GetDepth() const;
/**
Returns display resolution in pixels per inch.
Horizontal and vertical resolution are returned in @c x and @c y
components of the wxSize object respectively.
If the resolution information is not available, returns `wxSize(0, 0)`.
@since 3.1.2
*/
wxSize GetPPI() const;
/**
Returns scaling factor used by this display.
The scaling factor is the ratio between GetPPI() and GetStdPPI()
(it is implicitly assumed that this ratio is the same for both
horizontal and vertical components).
@see wxWindow::GetContentScaleFactor(), wxWindow::GetDPIScaleFactor()
@since 3.1.5
*/
double GetScaleFactor() const;
/**
Returns default display resolution for the current platform in pixels
per inch.
This function mostly used internally, use GetPPI() to get the actual
display resolution.
Currently the standard PPI is the same in both horizontal and vertical
directions on all platforms and its value is 96 everywhere except under
Apple devices (those running macOS, iOS, watchOS etc), where it is 72.
@see GetStdPPI()
@since 3.1.5
*/
static int GetStdPPIValue();
/**
Returns default display resolution for the current platform as wxSize.
This function is equivalent to constructing wxSize object with both
components set to GetStdPPIValue().
@since 3.1.5
*/
static wxSize GetStdPPI();
/**
Returns @true if the display has not been unplugged yet.
This function can return @false if the display configuration has
changed since this wxDisplay object has been created and either this
display is known not to be connected to the system any more (support
for detecting this is currently only implemented in wxMSW) or the
display status is now unknown (which happens in all the other ports
detecting the display configuration changes, e.g. wxOSX).
A disconnected object is still usable, but all accessor functions
return invalid fallback values (e.g. 0 for the width and height) and so
such objects are not really useful any more. It is recommended to
recreate them when the display configuration changes, which can be done
in wxEVT_DISPLAY_CHANGED handler of any top-level window.
@since 3.3.0
*/
bool IsConnected() const;
/**
Returns @true if the display is the primary display. The primary
display is the one whose index is 0.
*/
bool IsPrimary() const;
};

View File

@@ -0,0 +1,455 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dnd.h
// Purpose: interface of wxDropSource and wx*DropTarget
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
Possible flags for drag and drop operations.
*/
enum
{
wxDrag_CopyOnly = 0, ///< Allow only copying.
wxDrag_AllowMove = 1, ///< Allow moving too (copying is always allowed).
wxDrag_DefaultMove = 3 ///< Allow moving and make it default operation.
};
/**
Result returned from a wxDropSource::DoDragDrop() call.
*/
enum wxDragResult
{
wxDragError, ///< Error prevented the D&D operation from completing.
wxDragNone, ///< Drag target didn't accept the data.
wxDragCopy, ///< The data was successfully copied.
wxDragMove, ///< The data was successfully moved (MSW only).
wxDragLink, ///< Operation is a drag-link.
wxDragCancel ///< The operation was cancelled by user (not an error).
};
/**
@class wxDropTarget
This class represents a target for a drag and drop operation. A
wxDataObject can be associated with it and by default, this object will be
filled with the data from the drag source, if the data formats supported by
the data object match the drag source data format.
There are various virtual handler functions defined in this class which may
be overridden to give visual feedback or react in a more fine-tuned way,
e.g. by not accepting data on the whole window area, but only a small
portion of it. The normal sequence of calls is OnEnter(), OnDragOver()
possibly many times, OnDrop() and finally OnData().
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, @ref overview_dataobject, wxDropSource,
wxTextDropTarget, wxFileDropTarget, wxDataFormat, wxDataObject
*/
class wxDropTarget
{
public:
/**
Constructor. @a data is the data to be associated with the drop target.
*/
wxDropTarget(wxDataObject* data = nullptr);
/**
Destructor. Deletes the associated data object, if any.
*/
virtual ~wxDropTarget();
/**
This method may only be called from within OnData(). By default, this
method copies the data from the drop source to the wxDataObject
associated with this drop target, calling its wxDataObject::SetData()
method.
*/
virtual bool GetData();
/**
Called after OnDrop() returns @true. By default this will usually
GetData() and will return the suggested default value @a defResult.
*/
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult defResult) = 0;
/**
Called when the mouse is being dragged over the drop target. By
default, this calls functions return the suggested return value @a defResult.
@param x
The x coordinate of the mouse.
@param y
The y coordinate of the mouse.
@param defResult
Suggested value for return value. Determined by SHIFT or CONTROL
key states.
@return The desired operation or wxDragNone. This is used for optical
feedback from the side of the drop source, typically in form
of changing the icon.
*/
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult defResult);
/**
Called when the user drops a data object on the target. Return @false
to veto the operation.
@param x
The x coordinate of the mouse.
@param y
The y coordinate of the mouse.
@return @true to accept the data, or @false to veto the operation.
*/
virtual bool OnDrop(wxCoord x, wxCoord y);
/**
Called when the mouse enters the drop target. By default, this calls
OnDragOver().
@param x
The x coordinate of the mouse.
@param y
The y coordinate of the mouse.
@param defResult
Suggested default for return value. Determined by SHIFT or CONTROL
key states.
@return The desired operation or wxDragNone. This is used for optical
feedback from the side of the drop source, typically in form
of changing the icon.
*/
virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult defResult);
/**
Called when the mouse leaves the drop target.
*/
virtual void OnLeave();
/**
Returns the data wxDataObject associated with the drop target
*/
wxDataObject *GetDataObject() const;
/**
Sets the data wxDataObject associated with the drop target and deletes
any previously associated data object.
*/
void SetDataObject(wxDataObject* data);
/**
Sets the default action for drag and drop. Use wxDragMove or
wxDragCopy to set default action to move or copy and use wxDragNone
(default) to set default action specified by initialization of dragging
(see wxDropSource::DoDragDrop())
*/
void SetDefaultAction(wxDragResult action);
/**
Returns default action for drag and drop or wxDragNone if this not
specified.
*/
wxDragResult GetDefaultAction();
};
/**
@class wxDropSource
This class represents a source for a drag and drop operation.
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, @ref overview_dataobject, wxDropTarget,
wxTextDropTarget, wxFileDropTarget
*/
class wxDropSource
{
public:
/**
This constructor requires that you must call SetData() later.
Note that the type of @a iconCopy and subsequent parameters
differs between different ports: these are cursors under Windows and OS
X but icons for GTK. You should use the macro wxDROP_ICON() in portable
programs instead of directly using either of these types.
@onlyfor{wxmsw,wxosx}
@param win
The window which initiates the drag and drop operation.
@param iconCopy
The icon or cursor used for feedback for copy operation.
@param iconMove
The icon or cursor used for feedback for move operation.
@param iconNone
The icon or cursor used for feedback when operation can't be done.
*/
wxDropSource(wxWindow* win = nullptr,
const wxCursorBundle& iconCopy = {},
const wxCursorBundle& iconMove = {},
const wxCursorBundle& iconNone = {});
/**
The constructor taking a wxDataObject.
Note that the type of @a iconCopy and subsequent parameters
differs between different ports: these are cursors under Windows and OS
X but icons for GTK. You should use the macro wxDROP_ICON() in portable
programs instead of directly using either of these types.
@onlyfor{wxmsw,wxosx}
@param data
The data associated with the drop source.
@param win
The window which initiates the drag and drop operation.
@param iconCopy
The icon or cursor used for feedback for copy operation.
@param iconMove
The icon or cursor used for feedback for move operation.
@param iconNone
The icon or cursor used for feedback when operation can't be done.
*/
wxDropSource(wxDataObject& data, wxWindow* win = nullptr,
const wxCursorBundle& iconCopy = {},
const wxCursorBundle& iconMove = {},
const wxCursorBundle& iconNone = {});
/**
This constructor requires that you must call SetData() later.
This is the wxGTK-specific version of the constructor taking wxIcon
instead of wxCursor as the other ports.
@onlyfor{wxgtk}
@param win
The window which initiates the drag and drop operation.
@param iconCopy
The icon or cursor used for feedback for copy operation.
@param iconMove
The icon or cursor used for feedback for move operation.
@param iconNone
The icon or cursor used for feedback when operation can't be done.
*/
wxDropSource(wxWindow* win = nullptr,
const wxIcon& iconCopy = wxNullIcon,
const wxIcon& iconMove = wxNullIcon,
const wxIcon& iconNone = wxNullIcon);
/**
The constructor taking a wxDataObject.
This is the wxGTK-specific version of the constructor taking wxIcon
instead of wxCursor as the other ports.
@onlyfor{wxgtk}
@param data
The data associated with the drop source.
@param win
The window which initiates the drag and drop operation.
@param iconCopy
The icon or cursor used for feedback for copy operation.
@param iconMove
The icon or cursor used for feedback for move operation.
@param iconNone
The icon or cursor used for feedback when operation can't be done.
*/
wxDropSource(wxDataObject& data, wxWindow* win = nullptr,
const wxIcon& iconCopy = wxNullIcon,
const wxIcon& iconMove = wxNullIcon,
const wxIcon& iconNone = wxNullIcon);
/**
Starts the drag-and-drop operation which will terminate when the user
releases the mouse. Call this in response to a mouse button press, for
example.
@param flags
If ::wxDrag_AllowMove is included in the flags, data may be moved
and not only copied as is the case for the default
::wxDrag_CopyOnly. If ::wxDrag_DefaultMove is specified
(which includes the previous flag), moving is not only possible but
becomes the default operation.
@return The operation requested by the user, may be ::wxDragCopy,
::wxDragMove, ::wxDragLink, ::wxDragCancel or ::wxDragNone if
an error occurred.
*/
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
/**
Returns the wxDataObject object that has been assigned previously.
*/
wxDataObject* GetDataObject();
/**
You may give some custom UI feedback during the drag and drop operation
by overriding this function. It is called on each mouse move, so your
implementation must not be too slow.
@param effect
The effect to implement. One of ::wxDragCopy, ::wxDragMove,
::wxDragLink and ::wxDragNone.
@return @false if you want default feedback, or @true if you implement
your own feedback. The return value is ignored under GTK.
*/
virtual bool GiveFeedback(wxDragResult effect);
/**
Set the icon to use for a certain drag result.
@param res
The drag result to set the icon for.
@param cursor
The icon to show when this drag result occurs.
@onlyfor{wxmsw,wxosx}
*/
void SetCursor(wxDragResult res, const wxCursorBundle& cursor);
/**
Set the icon to use for a certain drag result.
@param res
The drag result to set the icon for.
@param icon
The icon to show when this drag result occurs.
@onlyfor{wxgtk}
*/
void SetIcon(wxDragResult res, const wxIcon& icon);
/**
Sets the data wxDataObject associated with the drop source. This will
not delete any previously associated data.
*/
void SetData(wxDataObject& data);
};
/**
@class wxTextDropTarget
A predefined drop target for dealing with text data.
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, wxDropSource, wxDropTarget, wxFileDropTarget
*/
class wxTextDropTarget : public wxDropTarget
{
public:
/**
Constructor.
*/
wxTextDropTarget();
/**
See wxDropTarget::OnDrop(). This function is implemented appropriately
for text, and calls OnDropText().
*/
virtual bool OnDrop(wxCoord x, wxCoord y);
/**
Override this function to receive dropped text.
@param x
The x coordinate of the mouse.
@param y
The y coordinate of the mouse.
@param data
The data being dropped: a wxString.
Return @true to accept the data, or @false to veto the operation.
*/
virtual bool OnDropText(wxCoord x, wxCoord y, const wxString& data) = 0;
};
/**
@class wxFileDropTarget
This is a drop target which accepts files (dragged from File Manager or
Explorer).
@library{wxcore}
@category{dnd}
@see @ref overview_dnd, wxDropSource, wxDropTarget, wxTextDropTarget
*/
class wxFileDropTarget : public wxDropTarget
{
public:
/**
Constructor.
*/
wxFileDropTarget();
/**
See wxDropTarget::OnDrop(). This function is implemented appropriately
for files, and calls OnDropFiles().
*/
virtual bool OnDrop(wxCoord x, wxCoord y);
/**
Override this function to receive dropped files.
@param x
The x coordinate of the mouse.
@param y
The y coordinate of the mouse.
@param filenames
An array of filenames.
Return @true to accept the data, or @false to veto the operation.
*/
virtual bool OnDropFiles(wxCoord x, wxCoord y,
const wxArrayString& filenames) = 0;
};
// ============================================================================
// Global functions/macros
// ============================================================================
/** @addtogroup group_funcmacro_gdi */
///@{
/**
This macro creates either a cursor (MSW) or an icon (elsewhere) with the
given @a name (of type <tt>const char*</tt>). Under MSW, the cursor is
loaded from the resource file and the icon is loaded from XPM file under
other platforms.
This macro should be used with wxDropSource::wxDropSource().
@return wxCursor on MSW, otherwise returns a wxIcon
@header{wx/dnd.h}
*/
#define wxDROP_ICON(name)
/**
Returns true if res indicates that something was done during a DnD operation,
i.e. is neither error nor none nor cancel.
*/
bool wxIsDragResultOk(wxDragResult res);
///@}

View File

@@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////
// Name: docmdi.h
// Purpose: interface of wxDocMDIParentFrame and wxDocMDIChildFrame
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxDocMDIParentFrame
The wxDocMDIParentFrame class provides a default top-level frame for
applications using the document/view framework. This class can only be used
for MDI parent frames.
It cooperates with the wxView, wxDocument, wxDocManager and wxDocTemplate
classes.
@library{wxcore}
@category{docview}
@see @ref overview_docview, @ref page_samples_docview, wxMDIParentFrame
*/
class wxDocMDIParentFrame : public wxMDIParentFrame
{
public:
///@{
/**
Constructor.
*/
wxDocMDIParentFrame();
wxDocMDIParentFrame(wxDocManager* manager, wxFrame* parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
///@}
/**
Destructor.
*/
virtual ~wxDocMDIParentFrame();
/**
Creates the window.
*/
bool Create(wxDocManager* manager, wxFrame* parent,
wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
};
/**
@class wxDocMDIChildFrame
The wxDocMDIChildFrame class provides a default frame for displaying
documents on separate windows. This class can only be used for MDI child
frames.
The class is part of the document/view framework supported by wxWidgets,
and cooperates with the wxView, wxDocument, wxDocManager and wxDocTemplate
classes.
@library{wxcore}
@category{docview}
@see @ref overview_docview, @ref page_samples_docview, wxMDIChildFrame
*/
class wxDocMDIChildFrame : public wxMDIChildFrame
{
public:
/**
Constructor.
*/
wxDocMDIChildFrame(wxDocument* doc, wxView* view,
wxMDIParentFrame* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
/**
Destructor.
*/
virtual ~wxDocMDIChildFrame();
/**
Returns the document associated with this frame.
*/
wxDocument* GetDocument() const;
/**
Returns the view associated with this frame.
*/
wxView* GetView() const;
/**
Sets the document for this frame.
*/
void SetDocument(wxDocument* doc);
/**
Sets the view for this frame.
*/
void SetView(wxView* view);
};

File diff suppressed because it is too large Load Diff

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