]>
Commit | Line | Data |
---|---|---|
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 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_LOGG_H_ | |
12 | #define _WX_LOGG_H_ | |
13 | ||
14 | #if wxUSE_GUI | |
15 | ||
16 | class WXDLLIMPEXP_FWD_CORE wxTextCtrl; | |
17 | class WXDLLIMPEXP_FWD_CORE wxLogFrame; | |
18 | class WXDLLIMPEXP_FWD_CORE wxWindow; | |
19 | ||
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) | |
29 | class WXDLLIMPEXP_CORE wxLogTextCtrl : public wxLog | |
30 | { | |
31 | public: | |
32 | wxLogTextCtrl(wxTextCtrl *pTextCtrl); | |
33 | ||
34 | protected: | |
35 | // implement sink function | |
36 | virtual void DoLogText(const wxString& msg); | |
37 | ||
38 | private: | |
39 | // the control we use | |
40 | wxTextCtrl *m_pTextCtrl; | |
41 | ||
42 | wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl); | |
43 | }; | |
44 | ||
45 | #endif // wxUSE_TEXTCTRL | |
46 | ||
47 | // ---------------------------------------------------------------------------- | |
48 | // GUI log target, the default one for wxWidgets programs | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
51 | #if wxUSE_LOGGUI | |
52 | ||
53 | class WXDLLIMPEXP_CORE 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 DoLogRecord(wxLogLevel level, | |
64 | const wxString& msg, | |
65 | const wxLogRecordInfo& info); | |
66 | ||
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 | ||
75 | // empty everything | |
76 | void Clear(); | |
77 | ||
78 | ||
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 | ||
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); | |
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 | |
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 | // ---------------------------------------------------------------------------- | |
109 | ||
110 | #if wxUSE_LOGWINDOW | |
111 | ||
112 | class WXDLLIMPEXP_CORE wxLogWindow : public wxLogPassThrough | |
113 | { | |
114 | public: | |
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? | |
119 | ||
120 | virtual ~wxLogWindow(); | |
121 | ||
122 | // window operations | |
123 | // show/hide the log window | |
124 | void Show(bool bShow = true); | |
125 | // retrieve the pointer to the frame | |
126 | wxFrame *GetFrame() const; | |
127 | ||
128 | // overridables | |
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); | |
137 | ||
138 | protected: | |
139 | virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg); | |
140 | ||
141 | private: | |
142 | wxLogFrame *m_pLogFrame; // the log frame | |
143 | ||
144 | wxDECLARE_NO_COPY_CLASS(wxLogWindow); | |
145 | }; | |
146 | ||
147 | #endif // wxUSE_LOGWINDOW | |
148 | ||
149 | #endif // wxUSE_GUI | |
150 | ||
151 | #endif // _WX_LOGG_H_ | |
152 |