]>
Commit | Line | Data |
---|---|---|
7e8c564c VS |
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 | |
7e8c564c | 7 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> |
65571936 | 8 | // Licence: wxWindows licence |
7e8c564c VS |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_LOGG_H_ | |
12 | #define _WX_LOGG_H_ | |
13 | ||
7e8c564c VS |
14 | #if wxUSE_GUI |
15 | ||
b895ab50 VZ |
16 | class WXDLLIMPEXP_FWD_CORE wxTextCtrl; |
17 | class WXDLLIMPEXP_FWD_CORE wxLogFrame; | |
18 | class WXDLLIMPEXP_FWD_CORE wxWindow; | |
19 | ||
7e8c564c VS |
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 | // ---------------------------------------------------------------------------- | |
25 | ||
26 | #if wxUSE_TEXTCTRL | |
27 | ||
28 | // log everything to a text window (GUI only of course) | |
53a2db12 | 29 | class WXDLLIMPEXP_CORE wxLogTextCtrl : public wxLog |
7e8c564c VS |
30 | { |
31 | public: | |
32 | wxLogTextCtrl(wxTextCtrl *pTextCtrl); | |
33 | ||
6f02a879 | 34 | protected: |
7e8c564c | 35 | // implement sink function |
bc73d5ae | 36 | virtual void DoLogText(const wxString& msg); |
b99891b0 | 37 | |
6f02a879 | 38 | private: |
7e8c564c VS |
39 | // the control we use |
40 | wxTextCtrl *m_pTextCtrl; | |
41 | ||
c0c133e1 | 42 | wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl); |
7e8c564c VS |
43 | }; |
44 | ||
45 | #endif // wxUSE_TEXTCTRL | |
46 | ||
47 | // ---------------------------------------------------------------------------- | |
77ffb593 | 48 | // GUI log target, the default one for wxWidgets programs |
7e8c564c VS |
49 | // ---------------------------------------------------------------------------- |
50 | ||
51 | #if wxUSE_LOGGUI | |
52 | ||
53a2db12 | 53 | class WXDLLIMPEXP_CORE wxLogGui : public wxLog |
7e8c564c VS |
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: | |
bc73d5ae VZ |
63 | virtual void DoLogRecord(wxLogLevel level, |
64 | const wxString& msg, | |
65 | const wxLogRecordInfo& info); | |
b99891b0 | 66 | |
9ad2fe62 VZ |
67 | // return the title to be used for the log dialog, depending on m_bErrors |
68 | // and m_bWarnings values | |
69 | wxString GetTitle() const; | |
70 | ||
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; | |
74 | ||
7e8c564c VS |
75 | // empty everything |
76 | void Clear(); | |
77 | ||
9ad2fe62 | 78 | |
7e8c564c VS |
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? | |
85 | ||
9ad2fe62 VZ |
86 | private: |
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, | |
91 | int style); | |
92 | ||
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, | |
98 | int style); | |
7e8c564c VS |
99 | }; |
100 | ||
101 | #endif // wxUSE_LOGGUI | |
102 | ||
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 | |
e3778b4d | 106 | // to the log window. This window has its own menu which allows the user to |
7e8c564c VS |
107 | // close it, clear the log contents or save it to the file. |
108 | // ---------------------------------------------------------------------------- | |
109 | ||
110 | #if wxUSE_LOGWINDOW | |
111 | ||
53a2db12 | 112 | class WXDLLIMPEXP_CORE wxLogWindow : public wxLogPassThrough |
7e8c564c VS |
113 | { |
114 | public: | |
46ff9bd5 VS |
115 | wxLogWindow(wxWindow *pParent, // the parent frame (can be NULL) |
116 | const wxString& szTitle, // the title of the frame | |
dabbc6a5 DS |
117 | bool bShow = true, // show window immediately? |
118 | bool bPassToOld = true); // pass messages to the old target? | |
7e8c564c | 119 | |
d3c7fc99 | 120 | virtual ~wxLogWindow(); |
7e8c564c VS |
121 | |
122 | // window operations | |
123 | // show/hide the log window | |
dabbc6a5 | 124 | void Show(bool bShow = true); |
7e8c564c VS |
125 | // retrieve the pointer to the frame |
126 | wxFrame *GetFrame() const; | |
127 | ||
128 | // overridables | |
7e8c564c VS |
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 | |
dabbc6a5 | 131 | // exits) - return true from here to allow the frame to close, false |
7e8c564c VS |
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); | |
137 | ||
138 | protected: | |
bc73d5ae | 139 | virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg); |
b99891b0 | 140 | |
7e8c564c VS |
141 | private: |
142 | wxLogFrame *m_pLogFrame; // the log frame | |
143 | ||
c0c133e1 | 144 | wxDECLARE_NO_COPY_CLASS(wxLogWindow); |
7e8c564c VS |
145 | }; |
146 | ||
147 | #endif // wxUSE_LOGWINDOW | |
148 | ||
149 | #endif // wxUSE_GUI | |
150 | ||
151 | #endif // _WX_LOGG_H_ | |
152 |