1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/logg.h
3 // Purpose: Assorted wxLogXXX functions, and wxLog (sink for logs)
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 class WXDLLIMPEXP_FWD_CORE wxTextCtrl
;
18 class WXDLLIMPEXP_FWD_CORE wxLogFrame
;
19 class WXDLLIMPEXP_FWD_CORE wxWindow
;
21 // ----------------------------------------------------------------------------
22 // the following log targets are only compiled in if the we're compiling the
23 // GUI part (andnot just the base one) of the library, they're implemented in
24 // src/generic/logg.cpp *and not src/common/log.cpp unlike all the rest)
25 // ----------------------------------------------------------------------------
29 // log everything to a text window (GUI only of course)
30 class WXDLLIMPEXP_CORE wxLogTextCtrl
: public wxLog
33 wxLogTextCtrl(wxTextCtrl
*pTextCtrl
);
36 // implement sink function
37 virtual void DoLogText(const wxString
& msg
);
41 wxTextCtrl
*m_pTextCtrl
;
43 wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl
);
46 #endif // wxUSE_TEXTCTRL
48 // ----------------------------------------------------------------------------
49 // GUI log target, the default one for wxWidgets programs
50 // ----------------------------------------------------------------------------
54 class WXDLLIMPEXP_CORE wxLogGui
: public wxLog
60 // show all messages that were logged since the last Flush()
64 virtual void DoLogRecord(wxLogLevel level
,
66 const wxLogRecordInfo
& info
);
68 // return the title to be used for the log dialog, depending on m_bErrors
69 // and m_bWarnings values
70 wxString
GetTitle() const;
72 // return the icon (one of wxICON_XXX constants) to be used for the dialog
73 // depending on m_bErrors/m_bWarnings
74 int GetSeverityIcon() const;
80 wxArrayString m_aMessages
; // the log message texts
81 wxArrayInt m_aSeverity
; // one of wxLOG_XXX values
82 wxArrayLong m_aTimes
; // the time of each message
83 bool m_bErrors
, // do we have any errors?
84 m_bWarnings
, // any warnings?
85 m_bHasMessages
; // any messages at all?
88 // this method is called to show a single log message, it uses
89 // wxMessageBox() by default
90 virtual void DoShowSingleLogMessage(const wxString
& message
,
91 const wxString
& title
,
94 // this method is called to show multiple log messages, it uses wxLogDialog
95 virtual void DoShowMultipleLogMessages(const wxArrayString
& messages
,
96 const wxArrayInt
& severities
,
97 const wxArrayLong
& times
,
98 const wxString
& title
,
102 #endif // wxUSE_LOGGUI
104 // ----------------------------------------------------------------------------
105 // (background) log window: this class forwards all log messages to the log
106 // target which was active when it was instantiated, but also collects them
107 // to the log window. This window has it's own menu which allows the user to
108 // close it, clear the log contents or save it to the file.
109 // ----------------------------------------------------------------------------
113 class WXDLLIMPEXP_CORE wxLogWindow
: public wxLogPassThrough
116 wxLogWindow(wxWindow
*pParent
, // the parent frame (can be NULL)
117 const wxString
& szTitle
, // the title of the frame
118 bool bShow
= true, // show window immediately?
119 bool bPassToOld
= true); // pass messages to the old target?
121 virtual ~wxLogWindow();
124 // show/hide the log window
125 void Show(bool bShow
= true);
126 // retrieve the pointer to the frame
127 wxFrame
*GetFrame() const;
130 // called immediately after the log frame creation allowing for
131 // any extra initializations
132 virtual void OnFrameCreate(wxFrame
*frame
);
133 // called if the user closes the window interactively, will not be
134 // called if it is destroyed for another reason (such as when program
135 // exits) - return true from here to allow the frame to close, false
136 // to prevent this from happening
137 virtual bool OnFrameClose(wxFrame
*frame
);
138 // called right before the log frame is going to be deleted: will
139 // always be called unlike OnFrameClose()
140 virtual void OnFrameDelete(wxFrame
*frame
);
143 virtual void DoLogTextAtLevel(wxLogLevel level
, const wxString
& msg
);
146 wxLogFrame
*m_pLogFrame
; // the log frame
148 wxDECLARE_NO_COPY_CLASS(wxLogWindow
);
151 #endif // wxUSE_LOGWINDOW
155 #endif // _WX_LOGG_H_