Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PyConsole / PyConsole_Console.h
1
2 #ifndef PYCONSOLE_CONSOLE_H
3 #define PYCONSOLE_CONSOLE_H
4
5 #include "PyConsole.h"
6
7 //#include <SUIT_PopupClient.h>
8 #include <QWidget>
9 #include <QMap>
10
11 class PyConsole_Interp;
12 class PyConsole_Editor;
13 class PyConsole_EnhInterp;
14 class QMenu;
15
16 class PYCONSOLE_EXPORT PyConsole_Console : public QWidget//, public SUIT_PopupClient
17 {
18   Q_OBJECT
19
20 public:
21   //! Context popup menu actions flags
22   enum
23   {
24     CopyId         = 0x01,                                           //!< "Copy" menu action
25     PasteId        = 0x02,                                           //!< "Paste" menu action
26     ClearId        = 0x04,                                           //!< "Clear" menu action
27     SelectAllId    = 0x08,                                           //!< "Select All" menu action
28     DumpCommandsId = 0x16,                                           //!< "DumpCommands" menu action
29     All = CopyId | PasteId | ClearId | SelectAllId | DumpCommandsId  //!< all menu actions
30   };
31
32 public:
33   PyConsole_Console( QWidget* parent, PyConsole_Interp* interp = 0 );
34   virtual ~PyConsole_Console();
35
36   //! \brief Get python interperter
37   PyConsole_Interp*   getInterp() { return myInterp; } 
38   QFont               font() const;
39   virtual void        setFont( const QFont& );
40
41   bool                isSync() const;
42   void                setIsSync( const bool );
43
44   bool                isSuppressOutput() const;
45   void                setIsSuppressOutput( const bool );
46
47   bool                isShowBanner() const;
48   void                setIsShowBanner( const bool );
49
50   void                exec( const QString& );
51   void                execAndWait( const QString& );
52
53   virtual bool        eventFilter( QObject*, QEvent* );
54
55   //! \brief Get popup client symbolic name
56   virtual QString     popupClientType() const { return QString( "PyConsole" ); }
57   virtual void        contextMenuPopup( QMenu* );
58
59   void                setMenuActions( const int );
60   int                 menuActions() const;
61
62 protected:
63   void                createActions();
64   void                updateActions();
65
66   PyConsole_Console( QWidget* parent, PyConsole_Interp*,  PyConsole_Editor*);
67
68
69   PyConsole_Interp*   myInterp;    //!< python interpreter
70   PyConsole_Editor*   myEditor;    //!< python console editor widget
71   QMap<int, QAction*> myActions;   //!< menu actions list
72 };
73
74 /**
75  * Enhance console object providing auto-completion.
76  * Similar to PyConsole_Console except that an enhanced interpreter and enhanced editor
77  * are encapsulated.
78  */
79 //
80 class PYCONSOLE_EXPORT PyConsole_EnhConsole: public PyConsole_Console
81 {
82   Q_OBJECT
83
84 public:
85   PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp = 0);
86   virtual ~PyConsole_EnhConsole() {}
87 };
88
89 #endif // PYCONSOLE_CONSOLE_H