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