Version: 3.1.0

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. More...
 
#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). More...
 
#define wxSTRINGIZE_T(x)
 Returns the string representation of the given symbol as either an ASCII or Unicode string, depending on the current build. More...
 
#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. More...
 
#define wxDECLARE_NO_ASSIGN_CLASS(classname)
 This macro can be used in a class declaration to disable the generation of default assignment operator. More...
 
#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. More...
 
#define wxDECLARE_NO_COPY_TEMPLATE_CLASS(classname, arg)
 Analog of wxDECLARE_NO_COPY_CLASS() for template classes. More...
 
#define wxDECLARE_NO_COPY_TEMPLATE_CLASS_2(classname, arg1, arg2)
 Analog of wxDECLARE_NO_COPY_TEMPLATE_CLASS() for templates with 2 parameters. More...
 
#define wxDEPRECATED(function)
 Generate deprecation warning with the given message when a function is used. More...
 
#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. More...
 
#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. More...
 
#define wxDEPRECATED_ACCESSOR(func, what)
 A helper macro allowing to easily define a simple deprecated accessor. More...
 
#define wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(func, body)
 Combination of wxDEPRECATED_BUT_USED_INTERNALLY() and wxDEPRECATED_INLINE(). More...
 
#define wxEXPLICIT
 wxEXPLICIT is a macro which expands to the C++ explicit keyword if the compiler supports it or nothing otherwise. More...
 
#define wxOVERRIDE
 wxOVERRIDE expands to the C++11 override keyword if it's supported by the compiler or nothing otherwise. More...
 
#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. More...
 
#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. More...
 
#define wxLongLongFmtSpec
 This macro is defined to contain the printf() format specifier using which 64 bit integer numbers (i.e. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#define wxON_BLOCK_EXIT_NULL(ptr)
 This macro sets the pointer passed to it as argument to NULL on scope exit. More...
 

Typedefs

typedef int(* wxSortCallback) (const void *pItem1, const void *pItem2, const void *user_data)
 Compare function type for use with wxQsort() More...
 

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. More...
 
wxString wxBase64Encode (const void *src, size_t srcLen)
 This function encodes the given data using base64 and returns the output as a wxString. More...
 
wxString wxBase64Encode (const wxMemoryBuffer &buf)
 This function encodes the given data using base64 and returns the output as a wxString. More...
 
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. More...
 
size_t wxBase64EncodedSize (size_t len)
 Returns the length of the string with base64 representation of a buffer of specified size len. More...
 
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. More...
 
size_t wxBase64Decode (void *dst, size_t dstLen, const wxString &str, wxBase64DecodeMode mode=wxBase64DecodeMode_Strict, size_t *posErr=NULL)
 Decode a Base64-encoded wxString. More...
 
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. More...
 
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. More...
 
bool wxFromString (const wxString &string, wxColour *colour)
 Converts string to a wxColour best represented by the given string. More...
 
wxString wxToString (const wxColour &colour)
 Converts the given wxColour into a string. More...
 
void wxDDECleanUp ()
 Called when wxWidgets exits, to clean up the DDE system. More...
 
void wxDDEInitialize ()
 Initializes the DDE system. More...
 
template<typename T >
 wxDELETE (T *&ptr)
 A function which deletes and nulls the pointer. More...
 
template<typename T >
 wxDELETEA (T *&array)
 A function which deletes and nulls the pointer. More...
 
template<typename T >
 wxSwap (T &first, T &second)
 Swaps the contents of two variables. More...
 
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. More...
 
bool wxFromString (const wxString &string, wxFont *font)
 Converts string to a wxFont best represented by the given string. More...
 
wxString wxToString (const wxFont &font)
 Converts the given wxFont into a string. More...
 
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: More...
 
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: More...
 
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. More...
 
wxString wxGetStockLabel (wxWindowID id, long flags=wxSTOCK_WITH_MNEMONIC)
 Returns label that should be used for given id element. More...
 
wxTextOutputStreamendl (wxTextOutputStream &stream)
 Writes '\n' to stream. More...
 
wxBatteryState wxGetBatteryState ()
 Returns battery state as one of wxBATTERY_NORMAL_STATE, wxBATTERY_LOW_STATE, wxBATTERY_CRITICAL_STATE, wxBATTERY_SHUTDOWN_STATE or wxBATTERY_UNKNOWN_STATE. More...
 
wxPowerType wxGetPowerType ()
 Returns the type of power source as one of wxPOWER_SOCKET, wxPOWER_BATTERY or wxPOWER_UNKNOWN. More...
 
wxString wxGetDisplayName ()
 Under X only, returns the current display name. More...
 
bool wxGetKeyState (wxKeyCode key)
 For normal keys, returns true if the specified key is currently down. More...
 
wxPoint wxGetMousePosition ()
 Returns the mouse position in screen coordinates. More...
 
wxMouseState wxGetMouseState ()
 Returns the current state of the mouse. More...
 
void wxEnableTopLevelWindows (bool enable=true)
 This function enables or disables all top level windows. More...
 
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. More...
 
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. More...
 
int wxNewId ()
 
void wxRegisterId (int id)
 Ensures that Ids subsequently generated by wxNewId() do not clash with the given id. More...
 
bool wxLaunchDefaultApplication (const wxString &document, int flags=0)
 Opens the document in the application associated with the files of this type. More...
 
bool wxLaunchDefaultBrowser (const wxString &url, int flags=0)
 Opens the url in user's default browser. More...
 
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. More...
 
char * wxLoadUserResource (const wxString &resourceName, const wxChar *resourceType="TEXT", int *pLen=NULL, WXHINSTANCE module=0)
 Loads a user-defined Windows resource as a string. More...
 
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. More...
 
void wxSetDisplayName (const wxString &displayName)
 Under X only, sets the current display name. More...
 
wxString wxStripMenuCodes (const wxString &str, int flags=wxStrip_All)
 Strips any menu codes from str and returns the result. More...
 
wxWindowwxFindWindowAtPointer (wxPoint &pt)
 Find the deepest window at the mouse pointer position, returning the window and current pointer position in screen coordinates. More...
 
wxWindowwxGetActiveWindow ()
 Gets the currently active window (implemented for MSW and GTK only currently, always returns NULL in the other ports). More...
 
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. More...
 

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:

1 class FooWidget
2 {
3 public:
4  FooWidget();
5  ...
6 
7 private:
8  // widgets can't be copied
9  wxDECLARE_NO_COPY_CLASS(FooWidget);
10 };

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:

1 wxDEPRECATED_MSG("use safer overload returning wxString instead")
2 void wxGetSomething(char* buf, size_t len);
3 
4 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:

1 // old function, use wxString version instead
2 wxDEPRECATED( void wxGetSomething(char *buf, size_t len) );
3 
4 // ...
5 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

1 class wxFoo
2 {
3 public:
4  int GetValue() const { return m_value; }
5 
6  // this one is deprecated because it was erroneously non-const
7  wxDEPRECATED_ACCESSOR( int GetValue(), m_value )
8 
9 private:
10  int m_value;
11 };
#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:

1 class wxFoo
2 {
3 public:
4  // OldMethod() is deprecated, use NewMethod() instead
5  void NewMethod();
6  wxDEPRECATED_INLINE( void OldMethod(), NewMethod(); )
7 };

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:

1 #ifdef wxLongLong_t
2  wxLongLong_t ll = wxLL(0x1234567890abcdef);
3  printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
4 #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:

1 void *buf = malloc(size);
2 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:

1 void foo()
2 {
3  bool isDoingSomething = true;
4  {
5  wxON_BLOCK_EXIT_SET(isDoingSomething, false);
6  ... do something ...
7  }
8  ... isDoingSomething is false now ...
9 }

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 wxOVERRIDE

wxOVERRIDE expands to the C++11 override keyword if it's supported by the compiler or nothing otherwise.

This macro is useful for writing code which may be compiled by both C++11 and non-C++11 compilers and still allow the use of override for the former.

Example of using this macro:

1 class MyApp : public wxApp {
2 public:
3  virtual bool OnInit() wxOVERRIDE;
4 
5  // This would result in an error from a C++11 compiler as the
6  // method doesn't actually override the base class OnExit() due to
7  // a typo in its name.
8  //virtual int OnEzit() wxOVERRIDE;
9 };

Include file:

#include <wx/defs.h> 
Since
3.1.0
#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:

1 class RefCounted
2 {
3 public:
4  RefCounted() { m_nRef = 1; }
5  void IncRef() { m_nRef++ ; }
6  void DecRef() { if ( !--m_nRef ) delete this; }
7 
8 private:
9  ~RefCounted() { }
10 
11  wxSUPPRESS_GCC_PRIVATE_DTOR(RefCounted)
12 };

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

Writes '\n' to stream.

Include file:

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

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.

1 MyClass *ptr = new MyClass;
2 ...
3 wxDELETE(ptr);
4 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.

1 MyClass *array = new MyClass[17];
2 ...
3 wxDELETEA(array);
4 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.

Notice that if window is itself already a TLW, it is returned directly.

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:

1 #ifdef wxLongLong_t
2  wxLongLong_t ll = wxLL(0x1234567890abcdef);
3 #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

1 mydata MYDATA "myfile.dat"

and then use it in the following way:

1 const void* data = NULL;
2 size_t size = 0;
3 if ( !wxLoadUserResource(&data, &size, "mydata", "MYDATA") ) {
4  ... handle error ...
5 }
6 else {
7  // Use the data in any way, for example:
8  wxMemoryInputStream is(data, size);
9  ... read the data from stream ...
10 }
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:

1 int x = 3,
2  y = 4;
3 wxSwap(x, y);
4 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:

1 #ifdef wxLongLong_t
2  unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
3 #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>