1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : PyConsole_Console.cxx
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
27 \class PyConsole_Console
28 \brief Python console widget.
31 #include "PyConsole_Interp.h" /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
32 #include "SalomePyConsole_Console.h"
33 #include "SalomePyConsole_Editor.h"
34 #include "SalomePyConsole_EnhEditor.h"
35 #include "PyConsole_EnhInterp.h"
40 #include <QApplication>
44 #include <QVBoxLayout>
46 PyConsole_EditorBase *SalomePyConsole_Console::SalomePyConsole_Interp_Creator::createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const
47 { return new SalomePyConsole_Editor(interp,console); }
49 PyConsole_Interp *SalomePyConsole_Console::SalomePyConsole_Interp_Creator::createInterp( ) const
50 { return new PyConsole_Interp; }
55 Creates new python console widget.
56 \param parent parent widget
57 \param interp python interpreter
59 SalomePyConsole_Console::SalomePyConsole_Console( QWidget* parent, PyConsole_Interp* interp )
60 : PyConsole_ConsoleBase( parent, interp, 0 )
62 SalomePyConsole_Interp_Creator crea;
63 defaultConstructor(interp,crea);
67 * Protected constructor.
69 SalomePyConsole_Console::SalomePyConsole_Console( QWidget* parent, PyConsole_Interp* i, SalomePyConsole_Editor* e )
70 : PyConsole_ConsoleBase(parent,i,e)
77 Does nothing for the moment.
79 SalomePyConsole_Console::~SalomePyConsole_Console()
84 \brief Create the context popup menu.
86 Fill in the popup menu with the commands.
88 \param menu context popup menu
90 void SalomePyConsole_Console::contextMenuPopup( QMenu *menu )
92 PyConsole_ConsoleBase::contextMenuPopup(menu);
98 Handles context menu request event.
102 \return True if the event is processed and further processing should be stopped
104 bool SalomePyConsole_Console::eventFilter( QObject* o, QEvent* e )
106 if ( o == myEditor->viewport() && e->type() == QEvent::ContextMenu )
108 contextMenuRequest( (QContextMenuEvent*)e );
111 return QWidget::eventFilter( o, e );
114 PyConsole_EditorBase *SalomePyConsole_EnhConsole::SalomePyConsole_Interp_EnhCreator::createEditor( PyConsole_Interp *interp, PyConsole_ConsoleBase *console ) const
115 { return new SalomePyConsole_EnhEditor(interp,console); }
117 PyConsole_Interp *SalomePyConsole_EnhConsole::SalomePyConsole_Interp_EnhCreator::createInterp( ) const
118 { return new PyConsole_EnhInterp; }
121 * Similar to constructor of the base class but using enhanced objects.
122 * TODO: this should really be done in a factory to avoid code duplication.
126 SalomePyConsole_EnhConsole::SalomePyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp )
127 : SalomePyConsole_Console( parent, interp, 0 )
129 SalomePyConsole_Interp_EnhCreator crea;
130 defaultConstructor(interp,crea);