Version: 3.0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Miscellaneous

Detailed Description

Group of miscellaneous functions and macros.

Related class group: Miscellaneous

Macros

#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)
 Generate deprecation warning with the given message when a function is used.
 
#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.
 
wxWindowwxFindWindowAtPoint (const wxPoint &pt)
 Find the deepest window at the given mouse position in screen coordinates, returning the window if found, or NULL if not.
 
wxWindowwxFindWindowByLabel (const wxString &label, wxWindow *parent=NULL)
 
wxWindowwxFindWindowByName (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.
 
int wxNewId ()
 
void wxRegisterId (int 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.
 
bool wxLoadUserResource (const void **outData, size_t *outLen, const wxString &resourceName, const wxChar *resourceType="TEXT", WXHINSTANCE module=0)
 Loads an object from Windows resource file.
 
char * wxLoadUserResource (const wxString &resourceName, const wxChar *resourceType="TEXT", int *pLen=NULL, WXHINSTANCE module=0)
 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.
 
wxWindowwxFindWindowAtPointer (wxPoint &pt)
 Find the deepest window at the mouse pointer position, returning the window and current pointer position in screen coordinates.
 
wxWindowwxGetActiveWindow ()
 Gets the currently active window (implemented for MSW and GTK only currently, always returns NULL in the other ports).
 
wxWindowwxGetTopLevelParent (wxWindow *window)
 Returns the first top level parent of the given window, or in other words, the frame or dialog containing it, or NULL.
 

Macro Definition Documentation

#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.

See Also
wxDECLARE_NO_COPY_CLASS()
#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
};

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.

See Also
wxDECLARE_NO_ASSIGN_CLASS(), wxDECLARE_NO_COPY_TEMPLATE_CLASS()
#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.

Parameters
classnameThe name of the template class.
argThe name of the template parameter.
See Also
wxDECLARE_NO_COPY_TEMPLATE_CLASS_2
#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.

Parameters
classnameThe name of the template class.
arg1The name of the first template parameter.
arg2The name of the second template parameter.
See Also
wxDECLARE_NO_COPY_TEMPLATE_CLASS
#define wxDEPRECATED (   function)

Generate deprecation warning with the given message when a function is used.

This macro can be used to generate a warning indicating that a function is deprecated (i.e. scheduled for removal in the future) and explaining why is it so and/or what should it be replaced with. It applies to the declaration following it, for example:

wxDEPRECATED_MSG("use safer overload returning wxString instead")
void wxGetSomething(char* buf, size_t len);
wxString wxGetSomething();

For compilers other than clang, g++ 4.5 or later and MSVC 8 (MSVS 2005) or later, the message is ignored and a generic deprecation warning is given if possible, i.e. if the compiler is g++ (any supported version) or MSVC 7 (MSVS 2003) or later.

Since
3.0

Include file:

#include <wx/defs.h> 

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.

Notice that this macro itself is deprecated in favour of wxDEPRECATED_MSG()!

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.

Parameters
typeThe type of the function.
nameThe name of the function to load, not a string (without quotes, it is quoted automatically by the macro).
dynlibThe 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
See Also
wxLL()

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.

See Also
wxON_BLOCK_EXIT_OBJ0()

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.

See Also
wxON_BLOCK_EXIT_OBJ0(), wxON_BLOCK_EXIT_NULL()

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.

See Also
wxCONCAT()

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 Documentation

typedef int(* wxSortCallback)(const void *pItem1, const void *pItem2, const void *user_data)

Compare function type for use with wxQsort()

Include file:

#include <wx/utils.h> 

Enumeration Type Documentation

anonymous enum

flags for wxStripMenuCodes

Enumerator:
wxStrip_Mnemonics 
wxStrip_Accel 
wxStrip_All 

Elements of this enum specify the possible behaviours of wxBase64Decode when an invalid character is encountered.

Enumerator:
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.

Function Documentation

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.

Parameters
dstPointer to output buffer, may be NULL to just compute the necessary buffer size.
dstLenThe size of the output buffer, ignored if dst is NULL.
srcThe input string, must not be NULL. For the version using wxString, the input string should contain only ASCII characters.
srcLenThe 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.
modeThis 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.
posErrIf 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> 
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.

Since
2.9.1

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 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> 
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.

Parameters
dstThe output buffer, may be NULL to retrieve the needed buffer size.
dstLenThe output buffer size, ignored if dst is NULL.
srcThe input buffer, must not be NULL.
srcLenThe length of the input data.
Returns
wxCONV_FAILED if the output buffer is too small.

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.

Parameters
srcThe input buffer, must not be NULL.
srcLenThe length of the input data.

Include file:

#include <wx/base64.h> 
wxString wxBase64Encode ( const wxMemoryBuffer buf)

This function encodes the given data using base64 and returns the output as a wxString.

There is no error return.

Include file:

#include <wx/base64.h> 
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.

See Also
wxDDEInitialize()

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.

See Also
wxDDEServer, wxDDEClient, wxDDEConnection, wxDDECleanUp()

Include file:

#include <wx/dde.h> 
template<typename T >
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.

MyClass *ptr = new MyClass;
...
wxDELETE(ptr);
wxASSERT(!ptr);

Include file:

#include <wx/defs.h> 
template<typename T >
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.

MyClass *array = new MyClass[17];
...
wxDELETEA(array);
wxASSERT(!array);
See Also
wxDELETE()

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> 
int wxFindMenuItemId ( wxFrame frame,
const wxString menuString,
const wxString itemString 
)

Find a menu item identifier associated with the given frame's menu bar.

Include file:

#include <wx/utils.h> 
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.

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> 
wxWindow* wxFindWindowAtPointer ( wxPoint pt)

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> 
wxWindow* wxFindWindowByLabel ( const wxString label,
wxWindow parent = NULL 
)
Deprecated:
Replaced by wxWindow::FindWindowByLabel().

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> 
wxWindow* wxFindWindowByName ( const wxString name,
wxWindow parent = NULL 
)
Deprecated:
Replaced by wxWindow::FindWindowByName().

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> 
bool wxFromString ( const wxString string,
wxColour colour 
)

Converts string to a wxColour best represented by the given string.

Returns true on success.

See Also
wxToString(const wxColour&)

Include file:

#include <wx/colour.h> 
bool wxFromString ( const wxString string,
wxFont font 
)

Converts string to a wxFont best represented by the given string.

Returns true on success.

See Also
wxToString(const wxFont&)

Include file:

#include <wx/font.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 ( )

Under X only, returns the current display name.

See Also
wxSetDisplayName()

Include file:

#include <wx/utils.h> 
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 ( )

Returns the mouse position in screen coordinates.

Include file:

#include <wx/utils.h> 
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.

Parameters
idGiven id of the wxMenuItem, wxButton, wxToolBar tool, etc.
flagsCombination of the elements of wxStockLabelQueryFlag.

Include file:

#include <wx/stockitem.h> 
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.

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.

See Also
wxLaunchDefaultBrowser(), wxExecute()

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:

  • if it has a valid scheme (e.g. "file:", "http:" or "mailto:") it is passed to the appropriate browser configured in the user system.
  • if it has no valid scheme (e.g. it's a local file path without the "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:".
  • if it has no valid scheme and it's not a local file/directory, then "http:" is prepended and the browser is called.

Returns true if the application was successfully launched.

Note
For some configurations of the running user, the application which is launched to open the given URL may be URL-dependent (e.g. a browser may be used for local URLs while another one may be used for remote URLs).
See Also
wxLaunchDefaultApplication(), wxExecute()

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
See Also
wxULL(), wxLongLong

Include file:

#include <wx/longlong.h> 
bool wxLoadUserResource ( const void **  outData,
size_t *  outLen,
const wxString resourceName,
const wxChar resourceType = "TEXT",
WXHINSTANCE  module = 0 
)

Loads an object from Windows resource file.

This function loads the resource with the given name and type from the resources embedded into a Windows application.

The typical use for it is to load some data from the data files embedded into the program itself. For example, you could have the following fragment in your .rc file

mydata MYDATA "myfile.dat"

and then use it in the following way:

const void* data = NULL;
size_t size = 0;
if ( !wxLoadUserResource(&data, &size, "mydata", "MYDATA") ) {
... handle error ...
}
else {
// Use the data in any way, for example:
wxMemoryInputStream is(data, size);
... read the data from stream ...
}
Parameters
outDataFilled with the pointer to the data on successful return. Notice that this pointer does not need to be freed by the caller.
outLenFilled with the length of the data in bytes.
resourceNameThe name of the resource to load.
resourceTypeThe type of the resource in usual Windows format, i.e. either a real string like "MYDATA" or an integer created by the standard Windows MAKEINTRESOURCE() macro, including any constants for the standard resources types like RT_RCDATA.
moduleThe HINSTANCE of the module to load the resources from. The current module is used by default.
Returns
true if the data was loaded from resource or false if it couldn't be found (in which case no error is logged) or was found but couldn't be loaded (which is unexpected and does result in an error message).

This function is available under Windows only.

Library:  wxBase

Include file:

#include <wx/utils.h> 
Since
2.9.1
char* wxLoadUserResource ( const wxString resourceName,
const wxChar resourceType = "TEXT",
int *  pLen = NULL,
WXHINSTANCE  module = 0 
)

Loads a user-defined Windows resource as a string.

This is a wrapper for the general purpose overload wxLoadUserResource(const void**, size_t*, const wxString&, const wxChar*, WXHINSTANCE) and can be more convenient for the string data, but does an extra copy compared to the general version.

Parameters
resourceNameThe name of the resource to load.
resourceTypeThe type of the resource in usual Windows format, i.e. either a real string like "MYDATA" or an integer created by the standard Windows MAKEINTRESOURCE() macro, including any constants for the standard resources types like RT_RCDATA.
pLenFilled with the length of the returned buffer if it is non-NULL. This parameter should be used if NUL characters can occur in the resource data. It is new since wxWidgets 2.9.1
moduleThe HINSTANCE of the module to load the resources from. The current module is used by default. This parameter is new since wxWidgets 2.9.1.
Returns
A pointer to the data to be delete[]d by caller on success or NULL on error.

This function is available under Windows only.

Library:  wxBase

Include file:

#include <wx/utils.h> 
template<typename F , typename P1 , ... , typename PN >
wxScopeGuard wxMakeGuard ( 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.

int wxNewId ( )
Deprecated:
Ids generated by it can conflict with the Ids defined by the user code, use 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)
Deprecated:
Replaced by wxWindow::Close(). 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 ( int  id)

Ensures that Ids subsequently generated by wxNewId() do not clash with the given id.

Include file:

#include <wx/utils.h> 
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.

See Also
wxGetDisplayName()

Include file:

#include <wx/utils.h> 
wxString wxStripMenuCodes ( const wxString str,
int  flags = wxStrip_All 
)

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> 
template<typename T >
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:

int x = 3,
y = 4;
wxSwap(x, y);
wxASSERT( x == 4 && y == 3 );
wxString wxToString ( const wxColour colour)

Converts the given wxColour into a string.

See Also
wxFromString(const wxString&, wxColour*)

Include file:

#include <wx/colour.h> 
wxString wxToString ( const wxFont font)

Converts the given wxFont into a string.

See Also
wxFromString(const wxString&, wxFont*)

Include file:

#include <wx/font.h> 
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
See Also
wxLL(), wxLongLong

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>