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 DoLogString(const wxString
& szString
, time_t t
);
39 wxSUPPRESS_DOLOGSTRING_HIDE_WARNING()
43 wxTextCtrl
*m_pTextCtrl
;
45 wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl
);
48 #endif // wxUSE_TEXTCTRL
50 // ----------------------------------------------------------------------------
51 // GUI log target, the default one for wxWidgets programs
52 // ----------------------------------------------------------------------------
56 class WXDLLIMPEXP_CORE wxLogGui
: public wxLog
62 // show all messages that were logged since the last Flush()
66 virtual void DoLog(wxLogLevel level
, const wxString
& szString
, time_t t
);
68 wxSUPPRESS_DOLOG_HIDE_WARNING()
70 // return the title to be used for the log dialog, depending on m_bErrors
71 // and m_bWarnings values
72 wxString
GetTitle() const;
74 // return the icon (one of wxICON_XXX constants) to be used for the dialog
75 // depending on m_bErrors/m_bWarnings
76 int GetSeverityIcon() const;
82 wxArrayString m_aMessages
; // the log message texts
83 wxArrayInt m_aSeverity
; // one of wxLOG_XXX values
84 wxArrayLong m_aTimes
; // the time of each message
85 bool m_bErrors
, // do we have any errors?
86 m_bWarnings
, // any warnings?
87 m_bHasMessages
; // any messages at all?
90 // this method is called to show a single log message, it uses
91 // wxMessageBox() by default
92 virtual void DoShowSingleLogMessage(const wxString
& message
,
93 const wxString
& title
,
96 // this method is called to show multiple log messages, it uses wxLogDialog
97 virtual void DoShowMultipleLogMessages(const wxArrayString
& messages
,
98 const wxArrayInt
& severities
,
99 const wxArrayLong
& times
,
100 const wxString
& title
,
104 #endif // wxUSE_LOGGUI
106 // ----------------------------------------------------------------------------
107 // (background) log window: this class forwards all log messages to the log
108 // target which was active when it was instantiated, but also collects them
109 // to the log window. This window has it's own menu which allows the user to
110 // close it, clear the log contents or save it to the file.
111 // ----------------------------------------------------------------------------
115 class WXDLLIMPEXP_CORE wxLogWindow
: public wxLogPassThrough
118 wxLogWindow(wxWindow
*pParent
, // the parent frame (can be NULL)
119 const wxString
& szTitle
, // the title of the frame
120 bool bShow
= true, // show window immediately?
121 bool bPassToOld
= true); // pass messages to the old target?
123 virtual ~wxLogWindow();
126 // show/hide the log window
127 void Show(bool bShow
= true);
128 // retrieve the pointer to the frame
129 wxFrame
*GetFrame() const;
132 // called immediately after the log frame creation allowing for
133 // any extra initializations
134 virtual void OnFrameCreate(wxFrame
*frame
);
135 // called if the user closes the window interactively, will not be
136 // called if it is destroyed for another reason (such as when program
137 // exits) - return true from here to allow the frame to close, false
138 // to prevent this from happening
139 virtual bool OnFrameClose(wxFrame
*frame
);
140 // called right before the log frame is going to be deleted: will
141 // always be called unlike OnFrameClose()
142 virtual void OnFrameDelete(wxFrame
*frame
);
145 virtual void DoLog(wxLogLevel level
, const wxString
& szString
, time_t t
);
146 virtual void DoLogString(const wxString
& szString
, time_t t
);
148 wxSUPPRESS_DOLOG_HIDE_WARNING()
149 wxSUPPRESS_DOLOGSTRING_HIDE_WARNING()
152 wxLogFrame
*m_pLogFrame
; // the log frame
154 wxDECLARE_NO_COPY_CLASS(wxLogWindow
);
157 #endif // wxUSE_LOGWINDOW
161 #endif // _WX_LOGG_H_