wxWidgets: wxMessageOutput Class Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
wxMessageOutput Class Referenceabstract
Class List by Category » Logging

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-4.x86_64/src/wxWidgets-3.1.5/interface/wx/msgout.h>`

Inheritance diagram for wxMessageOutput:
[legend]

## Detailed Description

Simple class allowing to write strings to various output channels.

wxMessageOutput is a low-level class and doesn't provide any of the conveniences of wxLog. It simply allows writing a message to some output channel: usually file or standard error but possibly also a message box. While use of wxLog and related functions is preferable in many cases sometimes this simple interface may be more convenient.

This class itself is an abstract base class for various concrete derived classes:

- wxMessageOutputStderr
- wxMessageOutputBest
- wxMessageOutputMessageBox
- wxMessageOutputLog

It also provides access to the global message output object which is created by wxAppTraits::CreateMessageOutput() which creates an object of class wxMessageOutputStderr in console applications and wxMessageOutputBest in the GUI ones but may be overridden in user-defined traits class.

Example of using this class:

wxMessageOutputDebug().Printf("name=%s, preparing to greet...", name);
wxMessageOutput::Get()->Printf("Hello, %s!", name);
wxMessageOutputDebug
Output messages to the system debug output channel.
Definition msgout.h:165
wxMessageOutput::Printf
void Printf(const wxString &format,...)
Output a message.
wxMessageOutput::Get
static wxMessageOutput * Get()
Return the global message output object.

##

Library: wxBase

<>< =''>:</>&;&;< =''>\ </></>

## Public Member Functions
void | Printf (const wxString &format,...)
| Output a message.
virtual void | Output (const wxString &str)=0
| Method called by Printf() to really output the text.

## Static Public Member Functions
static wxMessageOutput * | Get ()
| Return the global message output object.
static wxMessageOutput * | Set (wxMessageOutput *msgout)
| Sets the global message output object.

## Member Function Documentation

## ◆ Get()

wxMessageOutput * wxMessageOutput::Get | ( |  | ) |
| static

Return the global message output object.

This object is never NULL while the program is running but may be NULL during initialization (before wxApp object is instantiated) or shutdown.(after wxApp destruction).

See also
  wxAppTraits::CreateMessageOutput()

## ◆ Output()

virtual void wxMessageOutput::Output | ( | const wxString & | str | ) |
| pure virtual

Method called by Printf() to really output the text.

This method is overridden in various derived classes and is also the one you should override if you implement a custom message output object.

It may also be called directly instead of Printf(). This is especially useful when outputting a user-defined string because it can be simply called with this string instead of using

msgout.Printf("%s", str);

(notice that passing user-defined string to Printf() directly is, of course, a security risk).

## ◆ Printf()

void wxMessageOutput::Printf | ( | const wxString & | format,
|  |  | ... )

Output a message.

This function uses the same conventions as standard `printf()`.

## ◆ Set()

wxMessageOutput * wxMessageOutput::Set | ( | wxMessageOutput * | msgout | ) |
| static

Sets the global message output object.

Using this function may be a simpler alternative to changing the message output object used for your program than overriding wxAppTraits::CreateMessageOutput().

Remember to delete the returned pointer or restore it later with another call to Set().