]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/logg.h
Move constant strings to .rodata/.data.rel.ro ELF segment from .data by making them...
[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 wxUSE_GUI
16
17 // ----------------------------------------------------------------------------
18 // the following log targets are only compiled in if the we're compiling the
19 // GUI part (andnot just the base one) of the library, they're implemented in
20 // src/generic/logg.cpp *and not src/common/log.cpp unlike all the rest)
21 // ----------------------------------------------------------------------------
22
23 #if wxUSE_TEXTCTRL
24
25 // log everything to a text window (GUI only of course)
26 class WXDLLEXPORT wxLogTextCtrl : public wxLog
27 {
28 public:
29 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
30
31 private:
32 // implement sink function
33 virtual void DoLogString(const wxChar *szString, time_t t);
34
35 // the control we use
36 wxTextCtrl *m_pTextCtrl;
37
38 DECLARE_NO_COPY_CLASS(wxLogTextCtrl)
39 };
40
41 #endif // wxUSE_TEXTCTRL
42
43 // ----------------------------------------------------------------------------
44 // GUI log target, the default one for wxWidgets programs
45 // ----------------------------------------------------------------------------
46
47 #if wxUSE_LOGGUI
48
49 class WXDLLEXPORT wxLogGui : public wxLog
50 {
51 public:
52 // ctor
53 wxLogGui();
54
55 // show all messages that were logged since the last Flush()
56 virtual void Flush();
57
58 protected:
59 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
60
61 // empty everything
62 void Clear();
63
64 wxArrayString m_aMessages; // the log message texts
65 wxArrayInt m_aSeverity; // one of wxLOG_XXX values
66 wxArrayLong m_aTimes; // the time of each message
67 bool m_bErrors, // do we have any errors?
68 m_bWarnings, // any warnings?
69 m_bHasMessages; // any messages at all?
70
71 };
72
73 #endif // wxUSE_LOGGUI
74
75 // ----------------------------------------------------------------------------
76 // (background) log window: this class forwards all log messages to the log
77 // target which was active when it was instantiated, but also collects them
78 // to the log window. This window has it's own menu which allows the user to
79 // close it, clear the log contents or save it to the file.
80 // ----------------------------------------------------------------------------
81
82 #if wxUSE_LOGWINDOW
83
84 class WXDLLEXPORT wxLogWindow : public wxLogPassThrough
85 {
86 public:
87 wxLogWindow(wxWindow *pParent, // the parent frame (can be NULL)
88 const wxChar *szTitle, // the title of the frame
89 bool bShow = true, // show window immediately?
90 bool bPassToOld = true); // pass messages to the old target?
91
92 ~wxLogWindow();
93
94 // window operations
95 // show/hide the log window
96 void Show(bool bShow = true);
97 // retrieve the pointer to the frame
98 wxFrame *GetFrame() const;
99
100 // overridables
101 // called immediately after the log frame creation allowing for
102 // any extra initializations
103 virtual void OnFrameCreate(wxFrame *frame);
104 // called if the user closes the window interactively, will not be
105 // called if it is destroyed for another reason (such as when program
106 // exits) - return true from here to allow the frame to close, false
107 // to prevent this from happening
108 virtual bool OnFrameClose(wxFrame *frame);
109 // called right before the log frame is going to be deleted: will
110 // always be called unlike OnFrameClose()
111 virtual void OnFrameDelete(wxFrame *frame);
112
113 protected:
114 virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
115 virtual void DoLogString(const wxChar *szString, time_t t);
116
117 private:
118 wxLogFrame *m_pLogFrame; // the log frame
119
120 DECLARE_NO_COPY_CLASS(wxLogWindow)
121 };
122
123 #endif // wxUSE_LOGWINDOW
124
125 #endif // wxUSE_GUI
126
127 #endif // _WX_LOGG_H_
128