]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/logg.h
Fix another line somehow missing from the wxGraphicsBitmap forward port.
[wxWidgets.git] / include / wx / generic / logg.h
CommitLineData
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
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// Licence: wxWindows licence
7e8c564c
VS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_LOGG_H_
13#define _WX_LOGG_H_
14
7e8c564c
VS
15#if wxUSE_GUI
16
b895ab50
VZ
17class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
18class WXDLLIMPEXP_FWD_CORE wxLogFrame;
19class WXDLLIMPEXP_FWD_CORE wxWindow;
20
7e8c564c
VS
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)
53a2db12 30class WXDLLIMPEXP_CORE wxLogTextCtrl : public wxLog
7e8c564c
VS
31{
32public:
33 wxLogTextCtrl(wxTextCtrl *pTextCtrl);
34
6f02a879 35protected:
7e8c564c 36 // implement sink function
bc73d5ae 37 virtual void DoLogText(const wxString& msg);
b99891b0 38
6f02a879 39private:
7e8c564c
VS
40 // the control we use
41 wxTextCtrl *m_pTextCtrl;
42
c0c133e1 43 wxDECLARE_NO_COPY_CLASS(wxLogTextCtrl);
7e8c564c
VS
44};
45
46#endif // wxUSE_TEXTCTRL
47
48// ----------------------------------------------------------------------------
77ffb593 49// GUI log target, the default one for wxWidgets programs
7e8c564c
VS
50// ----------------------------------------------------------------------------
51
52#if wxUSE_LOGGUI
53
53a2db12 54class WXDLLIMPEXP_CORE wxLogGui : public wxLog
7e8c564c
VS
55{
56public:
57 // ctor
58 wxLogGui();
59
60 // show all messages that were logged since the last Flush()
61 virtual void Flush();
62
63protected:
bc73d5ae
VZ
64 virtual void DoLogRecord(wxLogLevel level,
65 const wxString& msg,
66 const wxLogRecordInfo& info);
b99891b0 67
9ad2fe62
VZ
68 // return the title to be used for the log dialog, depending on m_bErrors
69 // and m_bWarnings values
70 wxString GetTitle() const;
71
72 // return the icon (one of wxICON_XXX constants) to be used for the dialog
73 // depending on m_bErrors/m_bWarnings
74 int GetSeverityIcon() const;
75
7e8c564c
VS
76 // empty everything
77 void Clear();
78
9ad2fe62 79
7e8c564c
VS
80 wxArrayString m_aMessages; // the log message texts
81 wxArrayInt m_aSeverity; // one of wxLOG_XXX values
82 wxArrayLong m_aTimes; // the time of each message
83 bool m_bErrors, // do we have any errors?
84 m_bWarnings, // any warnings?
85 m_bHasMessages; // any messages at all?
86
9ad2fe62
VZ
87private:
88 // this method is called to show a single log message, it uses
89 // wxMessageBox() by default
90 virtual void DoShowSingleLogMessage(const wxString& message,
91 const wxString& title,
92 int style);
93
94 // this method is called to show multiple log messages, it uses wxLogDialog
95 virtual void DoShowMultipleLogMessages(const wxArrayString& messages,
96 const wxArrayInt& severities,
97 const wxArrayLong& times,
98 const wxString& title,
99 int style);
7e8c564c
VS
100};
101
102#endif // wxUSE_LOGGUI
103
104// ----------------------------------------------------------------------------
105// (background) log window: this class forwards all log messages to the log
106// target which was active when it was instantiated, but also collects them
107// to the log window. This window has it's own menu which allows the user to
108// close it, clear the log contents or save it to the file.
109// ----------------------------------------------------------------------------
110
111#if wxUSE_LOGWINDOW
112
53a2db12 113class WXDLLIMPEXP_CORE wxLogWindow : public wxLogPassThrough
7e8c564c
VS
114{
115public:
46ff9bd5
VS
116 wxLogWindow(wxWindow *pParent, // the parent frame (can be NULL)
117 const wxString& szTitle, // the title of the frame
dabbc6a5
DS
118 bool bShow = true, // show window immediately?
119 bool bPassToOld = true); // pass messages to the old target?
7e8c564c 120
d3c7fc99 121 virtual ~wxLogWindow();
7e8c564c
VS
122
123 // window operations
124 // show/hide the log window
dabbc6a5 125 void Show(bool bShow = true);
7e8c564c
VS
126 // retrieve the pointer to the frame
127 wxFrame *GetFrame() const;
128
129 // overridables
130 // called immediately after the log frame creation allowing for
131 // any extra initializations
132 virtual void OnFrameCreate(wxFrame *frame);
133 // called if the user closes the window interactively, will not be
134 // called if it is destroyed for another reason (such as when program
dabbc6a5 135 // exits) - return true from here to allow the frame to close, false
7e8c564c
VS
136 // to prevent this from happening
137 virtual bool OnFrameClose(wxFrame *frame);
138 // called right before the log frame is going to be deleted: will
139 // always be called unlike OnFrameClose()
140 virtual void OnFrameDelete(wxFrame *frame);
141
142protected:
bc73d5ae 143 virtual void DoLogTextAtLevel(wxLogLevel level, const wxString& msg);
b99891b0 144
7e8c564c
VS
145private:
146 wxLogFrame *m_pLogFrame; // the log frame
147
c0c133e1 148 wxDECLARE_NO_COPY_CLASS(wxLogWindow);
7e8c564c
VS
149};
150
151#endif // wxUSE_LOGWINDOW
152
153#endif // wxUSE_GUI
154
155#endif // _WX_LOGG_H_
156