Salome HOME
Initial version
[modules/gui.git] / src / LogWindow / LogWindow.h
1 //  KERNEL SALOME_Event : Define event posting mechanism
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //  File   : LogWindow.h
23 //  Author : 
24 //  Module : KERNEL
25
26 #ifndef LogWindow_HeaderFile
27 #define LogWindow_HeaderFile
28
29 #if defined LOGWINDOW_EXPORTS
30 #if defined WIN32
31 #define LOGWINDOW_EXPORT __declspec( dllexport )
32 #else
33 #define LOGWINDOW_EXPORT
34 #endif
35 #else
36 #if defined WIN32
37 #define LOGWINDOW_EXPORT __declspec( dllimport )
38 #else
39 #define LOGWINDOW_EXPORT
40 #endif
41 #endif
42
43 #include <SUIT_PopupClient.h>
44
45 #include <qframe.h>
46 #include <qstringlist.h>
47
48 #ifdef WIN32
49 #pragma warning( disable:4251 )
50 #endif
51
52 class QAction;
53 class QTextBrowser;
54
55 class LOGWINDOW_EXPORT LogWindow : public QFrame, public SUIT_PopupClient
56 {
57   Q_OBJECT
58
59   enum { CopyId, ClearId, SelectAllId, SaveToFileId };
60
61 public:
62         LogWindow( QWidget* theParent );
63         virtual ~LogWindow();
64
65   virtual             QString popupClientType() const { return QString( "LogWindow" ); }
66   virtual void        contextMenuPopup( QPopupMenu* );
67
68   bool                eventFilter( QObject* o, QEvent* e );
69
70   void                setBanner( const QString& banner );
71   void                setSeparator( const QString& separator );
72
73   virtual void        putMessage( const QString& message, bool addSeparator = true );
74   void                clear( bool clearHistory = false );
75
76   bool                saveLog( const QString& fileName );
77
78 protected slots:
79   void                onSaveToFile();
80   void                onSelectAll();
81   void                onClear();
82   void                onCopy();
83
84 private:
85   void                createActions();
86   void                updateActions();
87
88 private:
89   QTextBrowser*       myView;
90   QString             myBanner;
91   QString             mySeparator;
92   QStringList         myHistory;
93   int                 myBannerSize;
94   QMap<int, QAction*> myActions;
95 };
96
97 #ifdef WIN32
98 #pragma warning( default:4251 )
99 #endif
100
101 #endif