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