Miscellaneous
[Functions and Macros by Category]

size_t wxBase64Encode (char *dst, size_t dstLen, const void *src, size_t srcLen)
wxString wxBase64Encode (const void *src, size_t srcLen)
wxString wxBase64Encode (const wxMemoryBuffer &buf)
size_t wxBase64DecodedSize (size_t srcLen)
size_t wxBase64EncodedSize (size_t 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)
wxMemoryBuffer wxBase64Decode (const char *src, size_t srcLen=wxNO_LEN, wxBase64DecodeMode mode=wxBase64DecodeMode_Strict, size_t posErr=NULL)
wxMemoryBuffer wxBase64Decode (const wxString &src, wxBase64DecodeMode mode=wxBase64DecodeMode_Strict, size_t posErr=NULL)
bool wxFromString (const wxString &string, wxColour *colour)
wxString wxToString (const wxColour &colour)
void wxDDECleanUp ()
void wxDDEInitialize ()
void wxPostEvent (wxEvtHandler *dest, const wxEvent &event)
void wxQueueEvent (wxEvtHandler *dest, wxEvent *event)
bool wxFromString (const wxString &string, wxFont *font)
wxString wxToString (const wxFont &font)
wxString wxGetStockLabel (wxWindowID id, bool withCodes=true, const wxString &accelerator=wxEmptyString)
wxBatteryState wxGetBatteryState ()
wxWindowwxFindWindowAtPointer (wxPoint &pt)
wxWindowwxGetActiveWindow ()
wxWindowwxGetTopLevelParent (wxWindow *window)
void wxVaCopy (va_list argptrDst, va_list argptrSrc)
#define DECLARE_NO_ASSIGN_CLASS(classname)
#define DECLARE_NO_COPY_CLASS(classname)
#define DECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg)
#define wxDEPRECATED(function)
#define wxDEPRECATED_BUT_USED_INTERNALLY(function)
#define wxDEPRECATED_INLINE(func, body)
#define wxEXPLICIT
#define wxSUPPRESS_GCC_PRIVATE_DTOR_WARNING(name)
wxLongLong_t wxLL (number)
wxLongLong_t wxULL (number)
#define wxLongLongFmtSpec
#define wxCONCAT(x1, x2)
#define wxCONCAT3(x1, x2, x3)
#define wxCONCAT4(x1, x2, x3, x4)
#define wxCONCAT5(x1, x2, x3, x4, x5)
#define wxSTRINGIZE(x)
#define wxSTRINGIZE_T(x)
#define __WXFUNCTION__
#define wxDYNLIB_FUNCTION(type, name, dynlib)
#define wxON_BLOCK_EXIT0(function)
#define wxON_BLOCK_EXIT1(function, p1)
#define wxON_BLOCK_EXIT2(function, p1, p2)
#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_THIS0(method)
#define wxON_BLOCK_EXIT_THIS1(method, p1)
#define wxON_BLOCK_EXIT_THIS2(method, p1, p2)
#define wxON_BLOCK_EXIT_SET(var, value)
#define wxON_BLOCK_EXIT_NULL(ptr)

Define 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/debug.h> 

#define DECLARE_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:
DECLARE_NO_COPY_CLASS()

#define DECLARE_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
        DECLARE_NO_COPY_CLASS(FooWidget)
    };

Notice that a semicolon should not 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 DECLARE_NO_COPY_TEMPLATE_CLASS ( classname,
arg   ) 

Equivalent of DECLARE_NO_COPY_CLASS() for template classes.

This macro can be used for template classes (with a single template parameter) for the same purpose as DECLARE_NO_COPY_CLASS() is used with the non-template classes.

Parameters:
classname The name of the template class.
arg The name of the template parameter.

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

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 wxCONCAT4 ( x1,
x2,
x3,
x4   ) 

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 wxCONCAT5 ( x1,
x2,
x3,
x4,
x5   ) 

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 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_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_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:
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

See also:
wxLL()
Include file:
#include <wx/longlong.h> 

#define wxON_BLOCK_EXIT0 ( function   ) 

This macro ensures that the global function with 0, 1, 2 or more parameters (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_EXIT1 ( function,
p1   ) 

This macro ensures that the global function with 0, 1, 2 or more parameters (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_EXIT2 ( function,
p1,
p2   ) 

This macro ensures that the global function with 0, 1, 2 or more parameters (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_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_OBJ0 ( object,
method   ) 

This family of macros is similar to wxON_BLOCK_EXIT0(), but calls a method of the given object instead of a free function.

Include file:

#include <wx/scopeguard.h> 

#define wxON_BLOCK_EXIT_OBJ1 ( object,
method,
p1   ) 

This family of macros is similar to wxON_BLOCK_EXIT0(), but calls a method of the given object instead of a free function.

Include file:

#include <wx/scopeguard.h> 

#define wxON_BLOCK_EXIT_OBJ2 ( object,
method,
p1,
p2   ) 

This family of macros is similar to wxON_BLOCK_EXIT0(), but calls a method of the given object instead of a free function.

Include file:

#include <wx/scopeguard.h> 

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

See also:
wxON_BLOCK_EXIT_OBJ0(), wxON_BLOCK_EXIT_NULL()
Include file:
#include <wx/scopeguard.h> 

#define wxON_BLOCK_EXIT_THIS0 ( method   ) 

This family of macros is similar to wxON_BLOCK_OBJ0(), 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_THIS1 ( method,
p1   ) 

This family of macros is similar to wxON_BLOCK_OBJ0(), 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_THIS2 ( method,
p1,
p2   ) 

This family of macros is similar to wxON_BLOCK_OBJ0(), but calls a method of this object instead of a method of the specified object.

Include file:

#include <wx/scopeguard.h> 

#define wxSTRINGIZE (  ) 

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 (  ) 

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> 


Function Documentation

wxMemoryBuffer wxBase64Decode ( const wxString src,
wxBase64DecodeMode  mode = wxBase64DecodeMode_Strict,
size_t  posErr = NULL 
)

See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t) overload for more info 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> 

wxMemoryBuffer wxBase64Decode ( const char *  src,
size_t  srcLen = wxNO_LEN,
wxBase64DecodeMode  mode = wxBase64DecodeMode_Strict,
size_t  posErr = NULL 
)

See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t) overload for more info about the parameters of this function.

This overload allocates memory internally and returns it as wxMemoryBuffer and is recommended for normal use.

This overload returns a buffer with the base64 decoded binary equivalent of the input string. In neither case is the buffer NULL-terminated.

Include file:

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

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

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

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

Parameters:
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.
Returns:
wxCONV_FAILED if the output buffer is too small.
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> 

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> 

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> 

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> 

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 wxGetStockLabel ( wxWindowID  id,
bool  withCodes = true,
const wxString accelerator = wxEmptyString 
)

Returns label that should be used for given id element.

Parameters:
id Given id of the wxMenuItem, wxButton, wxToolBar tool, etc.
withCodes If false then strip accelerator code from the label; useful for getting labels without accelerator char code like for toolbar tooltip or on platforms without traditional keyboard like smartphones.
accelerator Optional accelerator string automatically added to label; useful for building labels for wxMenuItem.
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> 

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> 

void wxPostEvent ( wxEvtHandler dest,
const wxEvent event 
)

In a GUI application, this function posts event to the specified dest object using wxEvtHandler::AddPendingEvent().

Otherwise, it dispatches event immediately using wxEvtHandler::ProcessEvent(). See the respective documentation for details (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent() this function is not thread-safe for event objects having wxString fields, use wxQueueEvent() instead.

Include file:

#include <wx/event.h> 

void wxQueueEvent ( wxEvtHandler dest,
wxEvent event 
)

Queue an event for processing on the given object.

This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation for more details.

Include file:

#include <wx/event.h> 

Parameters:
dest The object to queue the event on, can't be NULL.
event The heap-allocated and non-NULL event to queue, the function takes ownership of it.

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> 



wxWidgets logo

[ top ]