Group of miscellaneous functions and macros.
Related class group: Miscellaneous
Defines | |
#define | wxCONCAT(x1, x2) |
This macro returns the concatenation of the arguments passed. | |
#define | wxCONCAT3(x1, x2, x3) |
#define | wxCONCAT4(x1, x2, x3, x4) |
#define | wxCONCAT5(x1, x2, x3, x4, x5) |
#define | wxSTRINGIZE(x) |
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 # operator which doesn't work with macros). | |
#define | wxSTRINGIZE_T(x) |
Returns the string representation of the given symbol as either an ASCII or Unicode string, depending on the current build. | |
#define | __WXFUNCTION__ |
This macro expands to the name of the current function if the compiler supports any of __FUNCTION__ , __func__ or equivalent variables or macros or to NULL if none of them is available. | |
#define | wxDECLARE_NO_ASSIGN_CLASS(classname) |
This macro can be used in a class declaration to disable the generation of default assignment operator. | |
#define | wxDECLARE_NO_COPY_CLASS(classname) |
This macro can be used in a class declaration to disable the generation of default copy ctor and assignment operator. | |
#define | wxDECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg) |
Analog of wxDECLARE_NO_COPY_CLASS() for template classes. | |
#define | wxDECLARE_NO_COPY_TEMPLATE_CLASS_2(classname, arg1, arg2) |
Analog of wxDECLARE_NO_COPY_TEMPLATE_CLASS() for templates with 2 parameters. | |
#define | wxDEPRECATED(function) |
This macro can be used around a function declaration to generate warnings indicating that this function is deprecated (i.e. | |
#define | wxDEPRECATED_BUT_USED_INTERNALLY(function) |
This is a special version of wxDEPRECATED() macro which only does something when the deprecated function is used from the code outside wxWidgets itself but doesn't generate warnings when it is used from wxWidgets. | |
#define | wxDEPRECATED_INLINE(func, body) |
This macro is similar to wxDEPRECATED() but can be used to not only declare the function function as deprecated but to also provide its (inline) implementation body. | |
#define | wxDEPRECATED_ACCESSOR(func, what) |
A helper macro allowing to easily define a simple deprecated accessor. | |
#define | wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(func, body) |
Combination of wxDEPRECATED_BUT_USED_INTERNALLY() and wxDEPRECATED_INLINE(). | |
#define | wxEXPLICIT |
wxEXPLICIT is a macro which expands to the C++ explicit keyword if the compiler supports it or nothing otherwise. | |
#define | wxSUPPRESS_GCC_PRIVATE_DTOR_WARNING(name) |
GNU C++ compiler gives a warning for any class whose destructor is private unless it has a friend. | |
#define | wxDYNLIB_FUNCTION(type, name, dynlib) |
When loading a function from a DLL you always have to cast the returned void * pointer to the correct type and, even more annoyingly, you have to repeat this type twice if you want to declare and define a function pointer all in one line. | |
#define | wxLongLongFmtSpec |
This macro is defined to contain the printf() format specifier using which 64 bit integer numbers (i.e. | |
#define | wxON_BLOCK_EXIT(function,...) |
Ensure that the global function with a few (up to some implementation-defined limit) is executed on scope exit, whether due to a normal function return or because an exception has been thrown. | |
#define | wxON_BLOCK_EXIT0(function) |
#define | wxON_BLOCK_EXIT1(function, p1) |
#define | wxON_BLOCK_EXIT2(function, p1, p2) |
#define | wxON_BLOCK_EXIT3(function, p1, p2, p3) |
#define | wxON_BLOCK_EXIT_OBJ(object, method,...) |
This family of macros is similar to wxON_BLOCK_EXIT(), but calls a method of the given object instead of a free function. | |
#define | wxON_BLOCK_EXIT_OBJ0(object, method) |
#define | wxON_BLOCK_EXIT_OBJ1(object, method, p1) |
#define | wxON_BLOCK_EXIT_OBJ2(object, method, p1, p2) |
#define | wxON_BLOCK_EXIT_OBJ3(object, method, p1, p2, p3) |
#define | wxON_BLOCK_EXIT_THIS(method,...) |
This family of macros is similar to wxON_BLOCK_OBJ(), but calls a method of this object instead of a method of the specified object. | |
#define | wxON_BLOCK_EXIT_THIS0(method) |
#define | wxON_BLOCK_EXIT_THIS1(method, p1) |
#define | wxON_BLOCK_EXIT_THIS2(method, p1, p2) |
#define | wxON_BLOCK_EXIT_THIS3(method, p1, p2, p3) |
#define | wxON_BLOCK_EXIT_SET(var, value) |
This macro sets a variable to the specified value on scope exit. | |
#define | wxON_BLOCK_EXIT_NULL(ptr) |
This macro sets the pointer passed to it as argument to NULL on scope exit. | |
Typedefs | |
typedef int(* | wxSortCallback )(const void *pItem1, const void *pItem2, const void *user_data) |
Compare function type for use with wxQsort() | |
Enumerations | |
enum | wxBase64DecodeMode { wxBase64DecodeMode_Strict, wxBase64DecodeMode_SkipWS, wxBase64DecodeMode_Relaxed } |
Elements of this enum specify the possible behaviours of wxBase64Decode when an invalid character is encountered. More... | |
enum | { wxStrip_Mnemonics = 1, wxStrip_Accel = 2, wxStrip_All = wxStrip_Mnemonics | wxStrip_Accel } |
flags for wxStripMenuCodes More... | |
Functions | |
size_t | wxBase64Encode (char *dst, size_t dstLen, const void *src, size_t srcLen) |
This function encodes the given data using base64. | |
wxString | wxBase64Encode (const void *src, size_t srcLen) |
This function encodes the given data using base64 and returns the output as a wxString. | |
wxString | wxBase64Encode (const wxMemoryBuffer &buf) |
This function encodes the given data using base64 and returns the output as a wxString. | |
size_t | wxBase64DecodedSize (size_t srcLen) |
Returns the size of the buffer necessary to contain the data encoded in a base64 string of length srcLen. | |
size_t | wxBase64EncodedSize (size_t len) |
Returns the length of the string with base64 representation of a buffer of specified size len. | |
size_t | wxBase64Decode (void *dst, size_t dstLen, const char *src, size_t srcLen=wxNO_LEN, wxBase64DecodeMode mode=wxBase64DecodeMode_Strict, size_t *posErr=NULL) |
This function decodes a Base64-encoded string. | |
size_t | wxBase64Decode (void *dst, size_t dstLen, const wxString &str, wxBase64DecodeMode mode=wxBase64DecodeMode_Strict, size_t *posErr=NULL) |
Decode a Base64-encoded wxString. | |
wxMemoryBuffer | wxBase64Decode (const char *src, size_t srcLen=wxNO_LEN, wxBase64DecodeMode mode=wxBase64DecodeMode_Strict, size_t *posErr=NULL) |
Decode a Base64-encoded string and return decoded contents in a buffer. | |
wxMemoryBuffer | wxBase64Decode (const wxString &src, wxBase64DecodeMode mode=wxBase64DecodeMode_Strict, size_t *posErr=NULL) |
Decode a Base64-encoded wxString and return decoded contents in a buffer. | |
bool | wxFromString (const wxString &string, wxColour *colour) |
Converts string to a wxColour best represented by the given string. | |
wxString | wxToString (const wxColour &colour) |
Converts the given wxColour into a string. | |
void | wxDDECleanUp () |
Called when wxWidgets exits, to clean up the DDE system. | |
void | wxDDEInitialize () |
Initializes the DDE system. | |
template<typename T > | |
wxDELETE (T *&ptr) | |
A function which deletes and nulls the pointer. | |
template<typename T > | |
wxDELETEA (T *&array) | |
A function which deletes and nulls the pointer. | |
template<typename T > | |
wxSwap (T &first, T &second) | |
Swaps the contents of two variables. | |
void | wxVaCopy (va_list argptrDst, va_list argptrSrc) |
This macro is the same as the standard C99 va_copy for the compilers which support it or its replacement for those that don't. | |
bool | wxFromString (const wxString &string, wxFont *font) |
Converts string to a wxFont best represented by the given string. | |
wxString | wxToString (const wxFont &font) |
Converts the given wxFont into a string. | |
wxLongLong_t | wxLL (number) |
This macro is defined for the platforms with a native 64 bit integer type and allow the use of 64 bit compile time constants: | |
wxLongLong_t | wxULL (number) |
This macro is defined for the platforms with a native 64 bit integer type and allow the use of 64 bit compile time constants: | |
template<typename F , typename P1 , ... , typename PN > | |
wxScopeGuard | wxMakeGuard (F func, P1 p1,..., PN pN) |
Returns a scope guard object which will call the specified function with the given parameters on scope exit. | |
wxString | wxGetStockLabel (wxWindowID id, long flags=wxSTOCK_WITH_MNEMONIC) |
Returns label that should be used for given id element. | |
wxBatteryState | wxGetBatteryState () |
Returns battery state as one of wxBATTERY_NORMAL_STATE , wxBATTERY_LOW_STATE , wxBATTERY_CRITICAL_STATE , wxBATTERY_SHUTDOWN_STATE or wxBATTERY_UNKNOWN_STATE . | |
wxPowerType | wxGetPowerType () |
Returns the type of power source as one of wxPOWER_SOCKET , wxPOWER_BATTERY or wxPOWER_UNKNOWN . | |
wxString | wxGetDisplayName () |
Under X only, returns the current display name. | |
bool | wxGetKeyState (wxKeyCode key) |
For normal keys, returns true if the specified key is currently down. | |
wxPoint | wxGetMousePosition () |
Returns the mouse position in screen coordinates. | |
wxMouseState | wxGetMouseState () |
Returns the current state of the mouse. | |
void | wxEnableTopLevelWindows (bool enable=true) |
This function enables or disables all top level windows. | |
wxWindow * | wxFindWindowAtPoint (const wxPoint &pt) |
Find the deepest window at the given mouse position in screen coordinates, returning the window if found, or NULL if not. | |
wxWindow * | wxFindWindowByLabel (const wxString &label, wxWindow *parent=NULL) |
wxWindow * | wxFindWindowByName (const wxString &name, wxWindow *parent=NULL) |
int | wxFindMenuItemId (wxFrame *frame, const wxString &menuString, const wxString &itemString) |
Find a menu item identifier associated with the given frame's menu bar. | |
long | wxNewId () |
void | wxRegisterId (long id) |
Ensures that Ids subsequently generated by wxNewId() do not clash with the given id. | |
bool | wxLaunchDefaultApplication (const wxString &document, int flags=0) |
Opens the document in the application associated with the files of this type. | |
bool | wxLaunchDefaultBrowser (const wxString &url, int flags=0) |
Opens the url in user's default browser. | |
wxString | wxLoadUserResource (const wxString &resourceName, const wxString &resourceType="TEXT") |
Loads a user-defined Windows resource as a string. | |
void | wxPostDelete (wxObject *object) |
void | wxQsort (void *pbase, size_t total_elems, size_t size, wxSortCallback cmp, const void *user_data) |
Function implementing quick sort algorithm. | |
void | wxSetDisplayName (const wxString &displayName) |
Under X only, sets the current display name. | |
wxString | wxStripMenuCodes (const wxString &str, int flags=wxStrip_All) |
Strips any menu codes from str and returns the result. | |
wxWindow * | wxFindWindowAtPointer (wxPoint &pt) |
Find the deepest window at the mouse pointer position, returning the window and current pointer position in screen coordinates. | |
wxWindow * | wxGetActiveWindow () |
Gets the currently active window (implemented for MSW and GTK only currently, always returns NULL in the other ports). | |
wxWindow * | wxGetTopLevelParent (wxWindow *window) |
Returns the first top level parent of the given window, or in other words, the frame or dialog containing it, or NULL. |
#define __WXFUNCTION__ |
This macro expands to the name of the current function if the compiler supports any of __FUNCTION__
, __func__
or equivalent variables or macros or to NULL if none of them is available.
Include file:
#include <wx/cpp.h>
#define wxCONCAT | ( | x1, | |
x2 | |||
) |
This macro returns the concatenation of the arguments passed.
Unlike when using the preprocessor operator, the arguments undergo macro expansion before being concatenated.
Include file:
#include <wx/cpp.h>
#define wxCONCAT3 | ( | x1, | |
x2, | |||
x3 | |||
) |
#define wxCONCAT4 | ( | x1, | |
x2, | |||
x3, | |||
x4 | |||
) |
#define wxCONCAT5 | ( | x1, | |
x2, | |||
x3, | |||
x4, | |||
x5 | |||
) |
#define wxDECLARE_NO_ASSIGN_CLASS | ( | classname | ) |
This macro can be used in a class declaration to disable the generation of default assignment operator.
Some classes have a well-defined copy constructor but cannot have an assignment operator, typically because they can't be modified once created. In such case, this macro can be used to disable the automatic assignment operator generation.
#define wxDECLARE_NO_COPY_CLASS | ( | classname | ) |
This macro can be used in a class declaration to disable the generation of default copy ctor and assignment operator.
Some classes don't have a well-defined copying semantics. In this case the standard C++ convention is to not allow copying them. One way of achieving it is to use this macro which simply defines a private copy constructor and assignment operator.
Beware that simply not defining copy constructor and assignment operator is not enough as the compiler would provide its own automatically-generated versions of them -- hence the usefulness of this macro.
Example of use:
class FooWidget { public: FooWidget(); ... private: // widgets can't be copied wxDECLARE_NO_COPY_CLASS(FooWidget); };
Notice that a semicolon must be used after this macro and that it changes the access specifier to private internally so it is better to use it at the end of the class declaration.
#define wxDECLARE_NO_COPY_TEMPLATE_CLASS | ( | classname, | |
arg | |||
) |
Analog of wxDECLARE_NO_COPY_CLASS() for template classes.
This macro can be used for template classes (with a single template parameter) for the same purpose as wxDECLARE_NO_COPY_CLASS() is used with the non-template classes.
classname | The name of the template class. |
arg | The name of the template parameter. |
#define wxDECLARE_NO_COPY_TEMPLATE_CLASS_2 | ( | classname, | |
arg1, | |||
arg2 | |||
) |
Analog of wxDECLARE_NO_COPY_TEMPLATE_CLASS() for templates with 2 parameters.
This macro can be used for template classes with two template parameters for the same purpose as wxDECLARE_NO_COPY_CLASS() is used with the non-template classes.
classname | The name of the template class. |
arg1 | The name of the first template parameter. |
arg2 | The name of the second template parameter. |
#define wxDEPRECATED | ( | function | ) |
This macro can be used around a function declaration to generate warnings indicating that this function is deprecated (i.e.
obsolete and planned to be removed in the future) when it is used. Only Visual C++ 7 and higher and g++ compilers currently support this functionality.
Example of use:
// old function, use wxString version instead wxDEPRECATED( void wxGetSomething(char *buf, size_t len) ); // ... wxString wxGetSomething();
Include file:
#include <wx/defs.h>
#define wxDEPRECATED_ACCESSOR | ( | func, | |
what | |||
) |
A helper macro allowing to easily define a simple deprecated accessor.
Compared to wxDEPRECATED_INLINE() it saves a return
statement and, especially, a strangely looking semicolon inside a macro.
Example of use
class wxFoo { public: int GetValue() const { return m_value; } // this one is deprecated because it was erroneously non-const wxDEPRECATED_ACCESSOR( int GetValue(), m_value ) private: int m_value; };
#define wxDEPRECATED_BUT_USED_INTERNALLY | ( | function | ) |
This is a special version of wxDEPRECATED() macro which only does something when the deprecated function is used from the code outside wxWidgets itself but doesn't generate warnings when it is used from wxWidgets.
It is used with the virtual functions which are called by the library itself -- even if such function is deprecated the library still has to call it to ensure that the existing code overriding it continues to work, but the use of this macro ensures that a deprecation warning will be generated if this function is used from the user code or, in case of Visual C++, even when it is simply overridden.
Include file:
#include <wx/defs.h>
#define wxDEPRECATED_BUT_USED_INTERNALLY_INLINE | ( | func, | |
body | |||
) |
Combination of wxDEPRECATED_BUT_USED_INTERNALLY() and wxDEPRECATED_INLINE().
This macro should be used for deprecated functions called by the library itself (usually for backwards compatibility reasons) and which are defined inline.
Include file:
#include <wx/defs.h>
#define wxDEPRECATED_INLINE | ( | func, | |
body | |||
) |
This macro is similar to wxDEPRECATED() but can be used to not only declare the function function as deprecated but to also provide its (inline) implementation body.
It can be used as following:
class wxFoo { public: // OldMethod() is deprecated, use NewMethod() instead void NewMethod(); wxDEPRECATED_INLINE( void OldMethod(), NewMethod(); ) };
Include file:
#include <wx/defs.h>
#define wxDYNLIB_FUNCTION | ( | type, | |
name, | |||
dynlib | |||
) |
When loading a function from a DLL you always have to cast the returned void *
pointer to the correct type and, even more annoyingly, you have to repeat this type twice if you want to declare and define a function pointer all in one line.
This macro makes this slightly less painful by allowing you to specify the type only once, as the first parameter, and creating a variable of this type named after the function but with pfn
prefix and initialized with the function name from the wxDynamicLibrary dynlib.
type | The type of the function. |
name | The name of the function to load, not a string (without quotes, it is quoted automatically by the macro). |
dynlib | The library to load the function from. |
Include file:
#include <wx/dynlib.h>
#define wxEXPLICIT |
wxEXPLICIT
is a macro which expands to the C++ explicit
keyword if the compiler supports it or nothing otherwise.
Thus, it can be used even in the code which might have to be compiled with an old compiler without support for this language feature but still take advantage of it when it is available.
Include file:
#include <wx/defs.h>
#define wxLongLongFmtSpec |
This macro is defined to contain the printf()
format specifier using which 64 bit integer numbers (i.e.
those of type wxLongLong_t
) can be printed. Example of using it:
#ifdef wxLongLong_t wxLongLong_t ll = wxLL(0x1234567890abcdef); printf("Long long = %" wxLongLongFmtSpec "x\n", ll); #endif
Include file:
#include <wx/longlong.h>
#define wxON_BLOCK_EXIT | ( | function, | |
... | |||
) |
Ensure that the global function with a few (up to some implementation-defined limit) is executed on scope exit, whether due to a normal function return or because an exception has been thrown.
A typical example of its usage:
void *buf = malloc(size); wxON_BLOCK_EXIT1(free, buf);
Please see the original article by Andrei Alexandrescu and Petru Marginean published in December 2000 issue of C/C++ Users Journal for more details.
Include file:
#include <wx/scopeguard.h>
#define wxON_BLOCK_EXIT0 | ( | function | ) |
#define wxON_BLOCK_EXIT1 | ( | function, | |
p1 | |||
) |
#define wxON_BLOCK_EXIT2 | ( | function, | |
p1, | |||
p2 | |||
) |
#define wxON_BLOCK_EXIT3 | ( | function, | |
p1, | |||
p2, | |||
p3 | |||
) |
#define wxON_BLOCK_EXIT_NULL | ( | ptr | ) |
This macro sets the pointer passed to it as argument to NULL on scope exit.
It must be used instead of wxON_BLOCK_EXIT_SET() when the value being set is NULL
.
Include file:
#include <wx/scopeguard.h>
#define wxON_BLOCK_EXIT_OBJ | ( | object, | |
method, | |||
... | |||
) |
This family of macros is similar to wxON_BLOCK_EXIT(), but calls a method of the given object instead of a free function.
Include file:
#include <wx/scopeguard.h>
#define wxON_BLOCK_EXIT_OBJ0 | ( | object, | |
method | |||
) |
#define wxON_BLOCK_EXIT_OBJ1 | ( | object, | |
method, | |||
p1 | |||
) |
#define wxON_BLOCK_EXIT_OBJ2 | ( | object, | |
method, | |||
p1, | |||
p2 | |||
) |
#define wxON_BLOCK_EXIT_OBJ3 | ( | object, | |
method, | |||
p1, | |||
p2, | |||
p3 | |||
) |
#define wxON_BLOCK_EXIT_SET | ( | var, | |
value | |||
) |
This macro sets a variable to the specified value on scope exit.
Example of usage:
void foo() { bool isDoingSomething = true; { wxON_BLOCK_EXIT_SET(isDoingSomething, false); ... do something ... } ... isDoingSomething is false now ... }
Notice that value is copied, i.e. stored by value, so it can be a temporary object returned by a function call, for example.
Include file:
#include <wx/scopeguard.h>
#define wxON_BLOCK_EXIT_THIS | ( | method, | |
... | |||
) |
This family of macros is similar to wxON_BLOCK_OBJ(), but calls a method of this
object instead of a method of the specified object.
Include file:
#include <wx/scopeguard.h>
#define wxON_BLOCK_EXIT_THIS0 | ( | method | ) |
#define wxON_BLOCK_EXIT_THIS1 | ( | method, | |
p1 | |||
) |
#define wxON_BLOCK_EXIT_THIS2 | ( | method, | |
p1, | |||
p2 | |||
) |
#define wxON_BLOCK_EXIT_THIS3 | ( | method, | |
p1, | |||
p2, | |||
p3 | |||
) |
#define wxSTRINGIZE | ( | x | ) |
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 #
operator which doesn't work with macros).
Notice that this macro always produces a char
string, use wxSTRINGIZE_T() to build a wide string Unicode build.
Include file:
#include <wx/cpp.h>
#define wxSTRINGIZE_T | ( | 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().
Include file:
#include <wx/cpp.h>
#define wxSUPPRESS_GCC_PRIVATE_DTOR_WARNING | ( | name | ) |
GNU C++ compiler gives a warning for any class whose destructor is private unless it has a friend.
This warning may sometimes be useful but it doesn't make sense for reference counted class which always delete themselves (hence destructor should be private) but don't necessarily have any friends, so this macro is provided to disable the warning in such case. The name parameter should be the name of the class but is only used to construct a unique friend class name internally.
Example of using the macro:
class RefCounted { public: RefCounted() { m_nRef = 1; } void IncRef() { m_nRef++ ; } void DecRef() { if ( !--m_nRef ) delete this; } private: ~RefCounted() { } wxSUPPRESS_GCC_PRIVATE_DTOR(RefCounted) };
Notice that there should be no semicolon after this macro.
Include file:
#include <wx/defs.h>
typedef int(* wxSortCallback)(const void *pItem1, const void *pItem2, const void *user_data) |
enum wxBase64DecodeMode |
Elements of this enum specify the possible behaviours of wxBase64Decode when an invalid character is encountered.
size_t wxBase64Decode | ( | void * | dst, |
size_t | dstLen, | ||
const char * | src, | ||
size_t | srcLen = wxNO_LEN , |
||
wxBase64DecodeMode | mode = wxBase64DecodeMode_Strict , |
||
size_t * | posErr = NULL |
||
) |
This function decodes a Base64-encoded string.
This overload is a raw decoding function and decodes the data into the provided buffer dst of the given size 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 not be NULL-terminated.
This overload returns the number of bytes written to the buffer or the necessary buffer size if dst was NULL or wxCONV_FAILED
on error, e.g. if the output buffer is too small or invalid characters were encountered in the input string.
dst | Pointer to output buffer, may be NULL to just compute the necessary buffer size. |
dstLen | The size of the output buffer, ignored if dst is NULL. |
src | The input string, must not be NULL. For the version using wxString, the input string should contain only ASCII characters. |
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. |
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. |
posErr | If this pointer is non-NULL and an error occurs during decoding, it is filled with the index of the invalid character. |
Include file:
#include <wx/base64.h>
wxMemoryBuffer wxBase64Decode | ( | const char * | src, |
size_t | srcLen = wxNO_LEN , |
||
wxBase64DecodeMode | mode = wxBase64DecodeMode_Strict , |
||
size_t * | posErr = NULL |
||
) |
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.
Include file:
#include <wx/base64.h>
wxMemoryBuffer wxBase64Decode | ( | const wxString & | src, |
wxBase64DecodeMode | mode = wxBase64DecodeMode_Strict , |
||
size_t * | posErr = NULL |
||
) |
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.
Include file:
#include <wx/base64.h>
size_t wxBase64Decode | ( | void * | dst, |
size_t | dstLen, | ||
const wxString & | str, | ||
wxBase64DecodeMode | mode = wxBase64DecodeMode_Strict , |
||
size_t * | posErr = NULL |
||
) |
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 char*
pointer and its length.
Include file:
#include <wx/base64.h>
size_t wxBase64DecodedSize | ( | size_t | srcLen | ) |
Returns the size of the buffer necessary to contain the data encoded in a base64 string of length srcLen.
This can be useful for allocating a buffer to be passed to wxBase64Decode().
Include file:
#include <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.
To allocate the buffer of the correct size, use wxBase64EncodedSize() or call this function with dst set to NULL -- it will then return the necessary buffer size.
src | The input buffer, must not be NULL. |
srcLen | The length of the input data. |
Include file:
#include <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.
To allocate the buffer of the correct size, use wxBase64EncodedSize() or call this function with 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.
dst | The output buffer, may be NULL to retrieve the needed buffer size. |
dstLen | The output buffer size, ignored if dst is NULL. |
src | The input buffer, must not be NULL. |
srcLen | The length of the input data. |
wxCONV_FAILED
if the output buffer is too small.Include file:
#include <wx/base64.h>
wxString wxBase64Encode | ( | const wxMemoryBuffer & | buf | ) |
size_t wxBase64EncodedSize | ( | size_t | len | ) |
Returns the length of the string with base64 representation of a buffer of specified size len.
This can be useful for allocating the buffer passed to wxBase64Encode().
Include file:
#include <wx/base64.h>
void wxDDECleanUp | ( | ) |
Called when wxWidgets exits, to clean up the DDE system.
This no longer needs to be called by the application.
Include file:
#include <wx/dde.h>
void wxDDEInitialize | ( | ) |
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.
Include file:
#include <wx/dde.h>
wxDELETE | ( | T *& | ptr | ) |
A function which deletes and nulls the pointer.
This function uses operator delete to free the pointer and also sets it to NULL. Notice that this does not work for arrays, use wxDELETEA() for them.
Include file:
#include <wx/defs.h>
wxDELETEA | ( | T *& | array | ) |
A function which deletes and nulls the pointer.
This function uses vector operator delete (delete
[]) to free the array pointer and also sets it to NULL. Notice that this does not work for non-array pointers, use wxDELETE() for them.
Include file:
#include <wx/defs.h>
void wxEnableTopLevelWindows | ( | bool | enable = true | ) |
This function enables or disables all top level windows.
It is used by wxSafeYield().
Include file:
#include <wx/utils.h>
Find a menu item identifier associated with the given frame's menu bar.
Include file:
#include <wx/utils.h>
Find the deepest window at the given mouse position in screen coordinates, returning the window if found, or NULL if not.
This function takes child windows at the given position into account even if they are disabled. The hidden children are however skipped by it.
Include file:
#include <wx/utils.h>
Find the deepest window at the mouse pointer position, returning the window and current pointer position in screen coordinates.
Include file:
#include <wx/window.h>
Find a window by its label. Depending on the type of window, the label may be a window title or panel item label. If parent is NULL, the search will start from all top-level frames and dialog boxes; if non-NULL, the search will be limited to the given window hierarchy. The search is recursive in both cases.
Include file:
#include <wx/utils.h>
Find a window by its name (as given in a window constructor or Create function call). If parent is NULL, the search will start from all top-level frames and dialog boxes; if non-NULL, the search will be limited to the given window hierarchy. The search is recursive in both cases.
If no such named window is found, wxFindWindowByLabel() is called.
Include file:
#include <wx/utils.h>
wxWindow* wxGetActiveWindow | ( | ) |
Gets the currently active window (implemented for MSW and GTK only currently, always returns NULL in the other ports).
Include file:
#include <wx/window.h>
wxBatteryState wxGetBatteryState | ( | ) |
Returns battery state as one of wxBATTERY_NORMAL_STATE
, wxBATTERY_LOW_STATE
, wxBATTERY_CRITICAL_STATE
, wxBATTERY_SHUTDOWN_STATE
or wxBATTERY_UNKNOWN_STATE
.
wxBATTERY_UNKNOWN_STATE
is also the default on platforms where this feature is not implemented (currently everywhere but MS Windows).
Include file:
#include <wx/utils.h>
wxString wxGetDisplayName | ( | ) |
bool wxGetKeyState | ( | wxKeyCode | key | ) |
For normal keys, returns true if the specified key is currently down.
For togglable keys (Caps Lock, Num Lock and Scroll Lock), returns true if the key is toggled such that its LED indicator is lit. There is currently no way to test whether togglable keys are up or down.
Even though there are virtual key codes defined for mouse buttons, they cannot be used with this function currently.
Include file:
#include <wx/utils.h>
wxPoint wxGetMousePosition | ( | ) |
wxMouseState wxGetMouseState | ( | ) |
Returns the current state of the mouse.
Returns a wxMouseState instance that contains the current position of the mouse pointer in screen coordinates, as well as boolean values indicating the up/down status of the mouse buttons and the modifier keys.
Include file:
#include <wx/utils.h>
wxPowerType wxGetPowerType | ( | ) |
Returns the type of power source as one of wxPOWER_SOCKET
, wxPOWER_BATTERY
or wxPOWER_UNKNOWN
.
wxPOWER_UNKNOWN
is also the default on platforms where this feature is not implemented (currently everywhere but MS Windows).
Include file:
#include <wx/utils.h>
wxString wxGetStockLabel | ( | wxWindowID | id, |
long | flags = wxSTOCK_WITH_MNEMONIC |
||
) |
Returns label that should be used for given id element.
id | Given id of the wxMenuItem, wxButton, wxToolBar tool, etc. |
flags | Combination of the elements of wxStockLabelQueryFlag. |
Include file:
#include <wx/stockitem.h>
Returns the first top level parent of the given window, or in other words, the frame or dialog containing it, or NULL.
Include file:
#include <wx/window.h>
bool wxLaunchDefaultApplication | ( | const wxString & | document, |
int | flags = 0 |
||
) |
Opens the document in the application associated with the files of this type.
The flags parameter is currently not used
Returns true if the application was successfully launched.
Include file:
#include <wx/utils.h>
bool wxLaunchDefaultBrowser | ( | const wxString & | url, |
int | flags = 0 |
||
) |
Opens the url in user's default browser.
If the flags parameter contains wxBROWSER_NEW_WINDOW
flag, a new window is opened for the URL (currently this is only supported under Windows).
And unless the flags parameter contains wxBROWSER_NOBUSYCURSOR
flag, a busy cursor is shown while the browser is being launched (using wxBusyCursor).
The parameter url is interpreted as follows:
"file:"
, "http:"
or "mailto:"
) it is passed to the appropriate browser configured in the user system."file:"
prefix), then wxFileExists and wxDirExists are used to test if it's a local file/directory; if it is, then the browser is called with the url parameter eventually prefixed by "file:"
."http:"
is prepended and the browser is called.Returns true if the application was successfully launched.
Include file:
#include <wx/utils.h>
wxLongLong_t wxLL | ( | number | ) |
This macro is defined for the platforms with a native 64 bit integer type and allow the use of 64 bit compile time constants:
#ifdef wxLongLong_t wxLongLong_t ll = wxLL(0x1234567890abcdef); #endif
Include file:
#include <wx/longlong.h>
wxString wxLoadUserResource | ( | const wxString & | resourceName, |
const wxString & | resourceType = "TEXT" |
||
) |
Loads a user-defined Windows resource as a string.
If the resource is found, the function creates a new character array and copies the data into it. A pointer to this data is returned. If unsuccessful, NULL is returned.
The resource must be defined in the .rc file using the following syntax:
myResource TEXT file.ext
Where file.ext
is a file that the resource compiler can find.
This function is available under Windows only.
Include file:
#include <wx/utils.h>
wxScopeGuard wxMakeGuard | ( | F | func, |
P1 | p1, | ||
..., | |||
PN | pN | ||
) |
Returns a scope guard object which will call the specified function with the given parameters on scope exit.
This function is overloaded to take several parameters up to some implementation-defined (but relatively low) limit.
The func should be a functor taking parameters of the types P1, ..., PN, i.e. the expression func
(p1, ..., pN) should be valid.
long wxNewId | ( | ) |
wxID_ANY
to assign ids which are guaranteed to not conflict with the user-defined ids for the controls and menu items you create instead of using this function.Generates an integer identifier unique to this run of the program.
Include file:
#include <wx/utils.h>
void wxPostDelete | ( | wxObject * | object | ) |
See the window deletion overview.
Tells the system to delete the specified object when all other events have been processed. In some environments, it is necessary to use this instead of deleting a frame directly with the delete operator, because some GUIs will still send events to a deleted window.
Include file:
#include <wx/utils.h>
void wxQsort | ( | void * | pbase, |
size_t | total_elems, | ||
size_t | size, | ||
wxSortCallback | cmp, | ||
const void * | user_data | ||
) |
Function implementing quick sort algorithm.
This function sorts total_elems objects of size size located at pbase. It uses cmp function for comparing them and passes user_data pointer to the comparison function each time it's called.
Include file:
#include <wx/utils.h>
void wxRegisterId | ( | long | id | ) |
void wxSetDisplayName | ( | const wxString & | displayName | ) |
Under X only, sets the current display name.
This is the X host and display name such as "colonsay:0.0", and the function indicates which display should be used for creating windows from this point on. Setting the display within an application allows multiple displays to be used.
Include file:
#include <wx/utils.h>
Strips any menu codes from str and returns the result.
By default, the functions strips both the mnemonics character ('&'
) which is used to indicate a keyboard shortkey, and the accelerators, which are used only in the menu items and are separated from the main text by the \t
(TAB) character. By using flags of wxStrip_Mnemonics
or wxStrip_Accel
to strip only the former or the latter part, respectively.
Notice that in most cases wxMenuItem::GetLabelFromText() or wxControl::GetLabelText() can be used instead.
Include file:
#include <wx/utils.h>
wxSwap | ( | T & | first, |
T & | second | ||
) |
Swaps the contents of two variables.
This is similar to std::swap() but can be used even on the platforms where the standard C++ library is not available (if you don't target such platforms, please use std::swap() instead).
The function relies on type T being copy constructible and assignable.
Example of use:
wxLongLong_t wxULL | ( | number | ) |
This macro is defined for the platforms with a native 64 bit integer type and allow the use of 64 bit compile time constants:
#ifdef wxLongLong_t unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef); #endif
Include file:
#include <wx/longlong.h>
void wxVaCopy | ( | va_list | argptrDst, |
va_list | argptrSrc | ||
) |
This macro is the same as the standard C99 va_copy
for the compilers which support it or its replacement for those that don't.
It must be used to preserve the value of a va_list
object if you need to use it after passing it to another function because it can be modified by the latter.
As with va_start
, each call to wxVaCopy
must have a matching va_end
.
Include file:
#include <wx/defs.h>