2003-06-25 12:28:47 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/generic/logg.h
|
|
|
|
// Purpose: Assorted wxLogXXX functions, and wxLog (sink for logs)
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29/01/98
|
|
|
|
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-06-25 12:28:47 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_LOGG_H_
|
|
|
|
#define _WX_LOGG_H_
|
|
|
|
|
|
|
|
#if wxUSE_GUI
|
|
|
|
|
2009-03-22 11:40:53 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxLogFrame;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
|
|
|
|
2003-06-25 12:28:47 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the following log targets are only compiled in if the we're compiling the
|
|
|
|
// GUI part (andnot just the base one) of the library, they're implemented in
|
|
|
|
// src/generic/logg.cpp *and not src/common/log.cpp unlike all the rest)
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if wxUSE_TEXTCTRL
|
|
|
|
|
|
|
|
// log everything to a text window (GUI only of course)
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxLogTextCtrl : public wxLog
|
2003-06-25 12:28:47 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxLogTextCtrl(wxTextCtrl *pTextCtrl);
|
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
protected:
|
2003-06-25 12:28:47 -04:00
|
|
|
// implement sink function
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoLogText(const wxString& msg) wxOVERRIDE;
|
2007-06-22 14:09:03 -04:00
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
private:
|
2003-06-25 12:28:47 -04:00
|
|
|
// the control we use
|
|
|
|
wxTextCtrl *m_pTextCtrl;
|
|
|
|
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl);
|
2003-06-25 12:28:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxUSE_TEXTCTRL
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2004-05-23 10:56:36 -04:00
|
|
|
// GUI log target, the default one for wxWidgets programs
|
2003-06-25 12:28:47 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if wxUSE_LOGGUI
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxLogGui : public wxLog
|
2003-06-25 12:28:47 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctor
|
|
|
|
wxLogGui();
|
|
|
|
|
|
|
|
// show all messages that were logged since the last Flush()
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Flush() wxOVERRIDE;
|
2003-06-25 12:28:47 -04:00
|
|
|
|
|
|
|
protected:
|
2009-07-08 09:47:33 -04:00
|
|
|
virtual void DoLogRecord(wxLogLevel level,
|
|
|
|
const wxString& msg,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxLogRecordInfo& info) wxOVERRIDE;
|
2007-06-22 14:09:03 -04:00
|
|
|
|
2008-09-11 09:58:54 -04:00
|
|
|
// return the title to be used for the log dialog, depending on m_bErrors
|
|
|
|
// and m_bWarnings values
|
|
|
|
wxString GetTitle() const;
|
|
|
|
|
|
|
|
// return the icon (one of wxICON_XXX constants) to be used for the dialog
|
|
|
|
// depending on m_bErrors/m_bWarnings
|
|
|
|
int GetSeverityIcon() const;
|
|
|
|
|
2003-06-25 12:28:47 -04:00
|
|
|
// empty everything
|
|
|
|
void Clear();
|
|
|
|
|
2008-09-11 09:58:54 -04:00
|
|
|
|
2003-06-25 12:28:47 -04:00
|
|
|
wxArrayString m_aMessages; // the log message texts
|
|
|
|
wxArrayInt m_aSeverity; // one of wxLOG_XXX values
|
|
|
|
wxArrayLong m_aTimes; // the time of each message
|
|
|
|
bool m_bErrors, // do we have any errors?
|
|
|
|
m_bWarnings, // any warnings?
|
|
|
|
m_bHasMessages; // any messages at all?
|
|
|
|
|
2008-09-11 09:58:54 -04:00
|
|
|
private:
|
|
|
|
// this method is called to show a single log message, it uses
|
|
|
|
// wxMessageBox() by default
|
|
|
|
virtual void DoShowSingleLogMessage(const wxString& message,
|
|
|
|
const wxString& title,
|
|
|
|
int style);
|
|
|
|
|
|
|
|
// this method is called to show multiple log messages, it uses wxLogDialog
|
|
|
|
virtual void DoShowMultipleLogMessages(const wxArrayString& messages,
|
|
|
|
const wxArrayInt& severities,
|
|
|
|
const wxArrayLong& times,
|
|
|
|
const wxString& title,
|
|
|
|
int style);
|
2003-06-25 12:28:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxUSE_LOGGUI
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// (background) log window: this class forwards all log messages to the log
|
|
|
|
// target which was active when it was instantiated, but also collects them
|
2011-04-30 06:57:04 -04:00
|
|
|
// to the log window. This window has its own menu which allows the user to
|
2003-06-25 12:28:47 -04:00
|
|
|
// close it, clear the log contents or save it to the file.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if wxUSE_LOGWINDOW
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxLogWindow : public wxLogPassThrough
|
2003-06-25 12:28:47 -04:00
|
|
|
{
|
|
|
|
public:
|
2007-06-28 12:59:06 -04:00
|
|
|
wxLogWindow(wxWindow *pParent, // the parent frame (can be NULL)
|
|
|
|
const wxString& szTitle, // the title of the frame
|
2004-06-12 19:44:08 -04:00
|
|
|
bool bShow = true, // show window immediately?
|
|
|
|
bool bPassToOld = true); // pass messages to the old target?
|
2003-06-25 12:28:47 -04:00
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxLogWindow();
|
2003-06-25 12:28:47 -04:00
|
|
|
|
|
|
|
// window operations
|
|
|
|
// show/hide the log window
|
2004-06-12 19:44:08 -04:00
|
|
|
void Show(bool bShow = true);
|
2003-06-25 12:28:47 -04:00
|
|
|
// retrieve the pointer to the frame
|
|
|
|
wxFrame *GetFrame() const;
|
|
|
|
|
|
|
|
// overridables
|
|
|
|
// called if the user closes the window interactively, will not be
|
|
|
|
// called if it is destroyed for another reason (such as when program
|
2004-06-12 19:44:08 -04:00
|
|
|
// exits) - return true from here to allow the frame to close, false
|
2003-06-25 12:28:47 -04:00
|
|
|
// to prevent this from happening
|
|
|
|
virtual bool OnFrameClose(wxFrame *frame);
|
|
|
|
// called right before the log frame is going to be deleted: will
|
|
|
|
// always be called unlike OnFrameClose()
|
|
|
|
virtual void OnFrameDelete(wxFrame *frame);
|
|
|
|
|
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg) wxOVERRIDE;
|
2007-06-22 14:09:03 -04:00
|
|
|
|
2003-06-25 12:28:47 -04:00
|
|
|
private:
|
|
|
|
wxLogFrame *m_pLogFrame; // the log frame
|
|
|
|
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxLogWindow);
|
2003-06-25 12:28:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxUSE_LOGWINDOW
|
|
|
|
|
|
|
|
#endif // wxUSE_GUI
|
|
|
|
|
|
|
|
#endif // _WX_LOGG_H_
|
|
|
|
|