Contents Up Previous Next

Macros

These macros are defined in wxWindows.

wxINTXX_SWAP_ALWAYS
wxINTXX_SWAP_ON_BE
wxINTXX_SWAP_ON_LE
CLASSINFO
DECLARE_ABSTRACT_CLASS
DECLARE_APP
DECLARE_CLASS
DECLARE_DYNAMIC_CLASS
IMPLEMENT_ABSTRACT_CLASS
IMPLEMENT_ABSTRACT_CLASS2
IMPLEMENT_APP
IMPLEMENT_CLASS
IMPLEMENT_CLASS2
IMPLEMENT_DYNAMIC_CLASS
IMPLEMENT_DYNAMIC_CLASS2
wxBITMAP
wxConstCast
WXDEBUG_NEW
wxDynamicCast
wxICON
wxStaticCast
WXTRACE
WXTRACELEVEL


wxINTXX_SWAP_ALWAYS

wxInt32 wxINT32_SWAP_ALWAYS(wxInt32 value)

wxUint32 wxUINT32_SWAP_ALWAYS(wxUint32 value)

wxInt16 wxINT16_SWAP_ALWAYS(wxInt16 value)

wxUint16 wxUINT16_SWAP_ALWAYS(wxUint16 value)

This macro will swap the bytes of the value variable from little endian to big endian or vice versa.


wxINTXX_SWAP_ON_BE

wxInt32 wxINT32_SWAP_ON_BE(wxInt32 value)

wxUint32 wxUINT32_SWAP_ON_BE(wxUint32 value)

wxInt16 wxINT16_SWAP_ON_BE(wxInt16 value)

wxUint16 wxUINT16_SWAP_ON_BE(wxUint16 value)

This macro will swap the bytes of the value variable from little endian to big endian or vice versa if the program is compiled on a big-endian architecture (such as Sun work stations). If the program has been compiled on a little-endian architecture, the value will be unchanged.

Use these macros to read data from and write data to a file that stores data in little endian (Intel i386) format.


wxINTXX_SWAP_ON_LE

wxInt32 wxINT32_SWAP_ON_LE(wxInt32 value)

wxUint32 wxUINT32_SWAP_ON_LE(wxUint32 value)

wxInt16 wxINT16_SWAP_ON_LE(wxInt16 value)

wxUint16 wxUINT16_SWAP_ON_LE(wxUint16 value)

This macro will swap the bytes of the value variable from little endian to big endian or vice versa if the program is compiled on a little-endian architecture (such as Intel PCs). If the program has been compiled on a big-endian architecture, the value will be unchanged.

Use these macros to read data from and write data to a file that stores data in big endian format.


CLASSINFO

wxClassInfo * CLASSINFO(className)

Returns a pointer to the wxClassInfo object associated with this class.

Include files

<wx/object.h>


DECLARE_ABSTRACT_CLASS

DECLARE_ABSTRACT_CLASS(className)

Used inside a class declaration to declare that the class should be made known to the class hierarchy, but objects of this class cannot be created dynamically. The same as DECLARE_CLASS.

Example:

class wxCommand: public wxObject
{
  DECLARE_ABSTRACT_CLASS(wxCommand)

 private:
  ...
 public:
  ...
};
Include files

<wx/object.h>


DECLARE_APP

DECLARE_APP(className)

This is used in headers to create a forward declaration of the wxGetApp function implemented by IMPLEMENT_APP. It creates the declaration className& wxGetApp(void).

Example:

  DECLARE_APP(MyApp)
Include files

<wx/app.h>


DECLARE_CLASS

DECLARE_CLASS(className)

Used inside a class declaration to declare that the class should be made known to the class hierarchy, but objects of this class cannot be created dynamically. The same as DECLARE_ABSTRACT_CLASS.

Include files

<wx/object.h>


DECLARE_DYNAMIC_CLASS

DECLARE_DYNAMIC_CLASS(className)

Used inside a class declaration to declare that the objects of this class should be dynamically creatable from run-time type information.

Example:

class wxFrame: public wxWindow
{
  DECLARE_DYNAMIC_CLASS(wxFrame)

 private:
  const wxString\& frameTitle;
 public:
  ...
};
Include files

<wx/object.h>


IMPLEMENT_ABSTRACT_CLASS

IMPLEMENT_ABSTRACT_CLASS(className, baseClassName)

Used in a C++ implementation file to complete the declaration of a class that has run-time type information. The same as IMPLEMENT_CLASS.

Example:

IMPLEMENT_ABSTRACT_CLASS(wxCommand, wxObject)

wxCommand::wxCommand(void)
{
...
}
Include files

<wx/object.h>


IMPLEMENT_ABSTRACT_CLASS2

IMPLEMENT_ABSTRACT_CLASS2(className, baseClassName1, baseClassName2)

Used in a C++ implementation file to complete the declaration of a class that has run-time type information and two base classes. The same as IMPLEMENT_CLASS2.

Include files

<wx/object.h>


IMPLEMENT_APP

IMPLEMENT_APP(className)

This is used in the application class implementation file to make the application class known to wxWindows for dynamic construction. You use this instead of

Old form:

  MyApp myApp;
New form:

  IMPLEMENT_APP(MyApp)
See also DECLARE_APP.

Include files

<wx/app.h>


IMPLEMENT_CLASS

IMPLEMENT_CLASS(className, baseClassName)

Used in a C++ implementation file to complete the declaration of a class that has run-time type information. The same as IMPLEMENT_ABSTRACT_CLASS.

Include files

<wx/object.h>


IMPLEMENT_CLASS2

IMPLEMENT_CLASS2(className, baseClassName1, baseClassName2)

Used in a C++ implementation file to complete the declaration of a class that has run-time type information and two base classes. The same as IMPLEMENT_ABSTRACT_CLASS2.

Include files

<wx/object.h>


IMPLEMENT_DYNAMIC_CLASS

IMPLEMENT_DYNAMIC_CLASS(className, baseClassName)

Used in a C++ implementation file to complete the declaration of a class that has run-time type information, and whose instances can be created dynamically.

Example:

IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)

wxFrame::wxFrame(void)
{
...
}
Include files

<wx/object.h>


IMPLEMENT_DYNAMIC_CLASS2

IMPLEMENT_DYNAMIC_CLASS2(className, baseClassName1, baseClassName2)

Used in a C++ implementation file to complete the declaration of a class that has run-time type information, and whose instances can be created dynamically. Use this for classes derived from two base classes.

Include files

<wx/object.h>


wxBITMAP

wxBITMAP(bitmapName)

This macro loads a bitmap from either application resources (on the platforms for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to avoid using #ifdefs when creating bitmaps.

See also

Bitmaps and icons overview, wxICON

Include files

<wx/gdicmn.h>


wxConstCast

wxConstCast(ptr, classname)

This macro expands into const_cast<classname *>(ptr) if the compiler supports const_cast or into an old, C-style cast, otherwise.

See also

wxDynamicCast
wxStaticCast


WXDEBUG_NEW

WXDEBUG_NEW(arg)

This is defined in debug mode to be call the redefined new operator with filename and line number arguments. The definition is:

#define WXDEBUG_NEW new(__FILE__,__LINE__)
In non-debug mode, this is defined as the normal new operator.

Include files

<wx/object.h>


wxDynamicCast

wxDynamicCast(ptr, classname)

This macro returns the pointer ptr cast to the type classname * if the pointer is of this type (the check is done during the run-time) or NULL otherwise. Usage of this macro is preferred over obsoleted wxObject::IsKindOf() function.

The ptr argument may be NULL, in which case NULL will be returned.

Example:

    wxWindow *win = wxWindow::FindFocus();
    wxTextCtrl *text = wxDynamicCast(win, wxTextCtrl);
    if ( text )
    {
        // a text control has the focus...
    }
    else
    {
        // no window has the focus or it is not a text control
    }
See also

RTTI overview
wxConstCast
wxStatiicCast


wxICON

wxICON(iconName)

This macro loads an icon from either application resources (on the platforms for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to avoid using #ifdefs when creating icons.

See also

Bitmaps and icons overview, wxBITMAP

Include files

<wx/gdicmn.h>


wxStaticCast

wxStaticCast(ptr, classname)

This macro checks that the cast is valid in debug mode (an assert failure will result if wxDynamicCast(ptr, classname) == NULL) and then returns the result of executing an equivalent of static_cast<classname *>(ptr).

wxDynamicCast
wxConstCast


WXTRACE

Include files

<wx/object.h>

WXTRACE(formatString, ...)

Calls wxTrace with printf-style variable argument syntax. Output is directed to the current output stream (see wxDebugContext).

This macro is now obsolete, replaced by Log functions.

Include files

<wx/memory.h>


WXTRACELEVEL

WXTRACELEVEL(level, formatString, ...)

Calls wxTraceLevel with printf-style variable argument syntax. Output is directed to the current output stream (see wxDebugContext). The first argument should be the level at which this information is appropriate. It will only be output if the level returned by wxDebugContext::GetLevel is equal to or greater than this value.

This function is now obsolete, replaced by Log functions.

Include files

<wx/memory.h>