split log.h into GUI and base parts
[wxWidgets.git] / include / wx / generic / logg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/logg.h
3 // Purpose: Assorted wxLogXXX functions, and wxLog (sink for logs)
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 29/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_LOGG_H_
13 #define _WX_LOGG_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "logg.h"
17 #endif
18
19 #if wxUSE_GUI
20
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 // ----------------------------------------------------------------------------
26
27 #if wxUSE_TEXTCTRL
28
29 // log everything to a text window (GUI only of course)
30 class WXDLLEXPORT wxLogTextCtrl : public wxLog
31 {
32 public:
33 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
34
35 private:
36 // implement sink function
37 virtual void DoLogString(const wxChar *szString, time_t t);
38
39 // the control we use
40 wxTextCtrl *m_pTextCtrl;
41
42 DECLARE_NO_COPY_CLASS(wxLogTextCtrl)
43 };
44
45 #endif // wxUSE_TEXTCTRL
46
47 // ----------------------------------------------------------------------------
48 // GUI log target, the default one for wxWindows programs
49 // ----------------------------------------------------------------------------
50
51 #if wxUSE_LOGGUI
52
53 class WXDLLEXPORT wxLogGui : public wxLog
54 {
55 public:
56 // ctor
57 wxLogGui();
58
59 // show all messages that were logged since the last Flush()
60 virtual void Flush();
61
62 protected:
63 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
64
65 // empty everything
66 void Clear();
67
68 wxArrayString m_aMessages; // the log message texts
69 wxArrayInt m_aSeverity; // one of wxLOG_XXX values
70 wxArrayLong m_aTimes; // the time of each message
71 bool m_bErrors, // do we have any errors?
72 m_bWarnings, // any warnings?
73 m_bHasMessages; // any messages at all?
74
75 };
76
77 #endif // wxUSE_LOGGUI
78
79 // ----------------------------------------------------------------------------
80 // (background) log window: this class forwards all log messages to the log
81 // target which was active when it was instantiated, but also collects them
82 // to the log window. This window has it's own menu which allows the user to
83 // close it, clear the log contents or save it to the file.
84 // ----------------------------------------------------------------------------
85
86 #if wxUSE_LOGWINDOW
87
88 class WXDLLEXPORT wxLogWindow : public wxLogPassThrough
89 {
90 public:
91 wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
92 const wxChar *szTitle, // the title of the frame
93 bool bShow = TRUE, // show window immediately?
94 bool bPassToOld = TRUE); // pass messages to the old target?
95
96 ~wxLogWindow();
97
98 // window operations
99 // show/hide the log window
100 void Show(bool bShow = TRUE);
101 // retrieve the pointer to the frame
102 wxFrame *GetFrame() const;
103
104 // overridables
105 // called immediately after the log frame creation allowing for
106 // any extra initializations
107 virtual void OnFrameCreate(wxFrame *frame);
108 // called if the user closes the window interactively, will not be
109 // called if it is destroyed for another reason (such as when program
110 // exits) - return TRUE from here to allow the frame to close, FALSE
111 // to prevent this from happening
112 virtual bool OnFrameClose(wxFrame *frame);
113 // called right before the log frame is going to be deleted: will
114 // always be called unlike OnFrameClose()
115 virtual void OnFrameDelete(wxFrame *frame);
116
117 protected:
118 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
119 virtual void DoLogString(const wxChar *szString, time_t t);
120
121 private:
122 wxLogFrame *m_pLogFrame; // the log frame
123
124 DECLARE_NO_COPY_CLASS(wxLogWindow)
125 };
126
127 #endif // wxUSE_LOGWINDOW
128
129 #endif // wxUSE_GUI
130
131 #endif // _WX_LOGG_H_
132