BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Friends | List of all members
BALL::VIEW::PyWidget Class Reference

#include <BALL/VIEW/WIDGETS/pyWidget.h>

Inheritance diagram for BALL::VIEW::PyWidget:
BALL::VIEW::DockWidget QDockWidget BALL::VIEW::ModularWidget BALL::Embeddable BALL::VIEW::ConnectionObject

Classes

class  MyLineEdit
 
class  MyTextEdit
 

Public Member Functions

Constructors and Destructors
 PyWidget (QWidget *parent=0, const char *name=0)
 
 PyWidget (const PyWidget &p)
 only needed for Pyhon Interface More...
 
 ~PyWidget ()
 
bool isValid () const
 Is full Python support available? More...
 
- Public Member Functions inherited from BALL::VIEW::DockWidget
 DockWidget (QWidget *parent, const char *title=0)
 Use this constructor! More...
 
virtual ~DockWidget ()
 
void setGuest (QWidget &guest)
 
virtual void setWidgetVisible (bool state)
 For usage with Python: More...
 
virtual void registerForHelpSystem (const QObject *widget, const String &url)
 
QGridLayout * getGuestLayout ()
 
- Public Member Functions inherited from BALL::VIEW::ModularWidget
void setWorkingDirFromFilename_ (String filename)
 
virtual void showHelp (const String &url)
 
 ModularWidget (const char *name="<ModularWidget>")
 
 ModularWidget (const ModularWidget &widget)
 
virtual ~ModularWidget ()
 
virtual void destroy ()
 
virtual void clear ()
 
QAction * insertMenuEntry (Position parent_id, const String &name, const QObject *receiver=0, const char *slot=0, const String &description="", QKeySequence accel=QKeySequence())
 
void setMenuHint (const String &hint)
 
void setMenuHelp (const String &url)
 
virtual void addToolBarEntries (QToolBar *main_tb)
 
void setIcon (const String &filename, bool add_to_main_toolbar=true)
 
bool lockComposites ()
 
bool unlockComposites ()
 Unlock the Composites. More...
 
MainControlgetMainControl () const
 
virtual void setStatusbarText (const String &text, bool important=false)
 
virtual void setStatusbarText (const QString &text, bool important=false)
  More...
 
String getWorkingDir ()
 Implemented for convenience. More...
 
void setWorkingDir (const String &dir)
 Implemented for convenience. More...
 
FragmentDBgetFragmentDB () const
 
- Public Member Functions inherited from BALL::Embeddable
 Embeddable (const String &identifier="<Embeddable>")
 
 Embeddable (const Embeddable &embeddable)
 
virtual ~Embeddable ()
 
void setIdentifier (const String &identifier)
 
const StringgetIdentifier () const
 
void unregisterThis ()
 
virtual void registerThis ()
 
- Public Member Functions inherited from BALL::VIEW::ConnectionObject
 ConnectionObject ()
 
virtual ~ConnectionObject ()
 
void registerConnectionObject (ConnectionObject &object)
 
void unregisterConnectionObject (ConnectionObject &object)
 
bool isConnectionObjectRegistered (const ConnectionObject &object)
 
ConnectionObjectgetParent () const
 
ConnectionObjectgetRoot ()
 
virtual void onNotify (Message *message)
 

Friends

class MyLineEdit
 

ModularWidget related methods

TextEditorWidgettext_edit_
 
TextEditorWidgetscript_output_
 
MyTextEditscript_edit_
 
QTabWidget * tab_widget_
 
PythonHighlighter highlighter_1_
 
PythonHighlighter highlighter_2_
 
PythonValidator validator_
 
MyLineEditline_edit_
 
QComboBox * combo_box_
 
QComboBox * editor_combo_box_
 
std::list< Hotkeyhotkeys_
 
String working_dir_
 
bool valid_
 
bool started_startup_script_
 
Preferencespreferences_
 
Position current_line_
 
bool multi_line_mode_
 
Size multi_lines_
 
String multi_line_text_
 
vector< Stringhistory_
 
vector< boolresults_
 
Position history_position_
 
String startup_script_
 
PythonSettingspython_settings_
 
RunPythonThreadthread_
 
bool stop_script_
 
Size complete_prefix_
 
String class_
 
String member_
 
Position intend_
 
bool running_
 
bool silent_
 
bool full_silent_
 
bool script_mode_
 
String current_script_
 
virtual void initializeWidget (MainControl &main_control)
 
virtual void finalizeWidget (MainControl &main_control)
 
void initializePreferencesTab (Preferences &preferences)
 
void finalizePreferencesTab (Preferences &preferences)
 
virtual void applyPreferences ()
 
virtual void scriptDialog (bool run=false)
 Open a dialog to select a script. More...
 
bool toAbortScript ()
 
void map (String modifier, String key, String command, String comment="")
 
void unmap (String modifier, String key)
 see above More...
 
void insertHotkey (const Hotkey &hotkey)
 
void removeHotkey (const Hotkey &hotkey)
 
void reactTo (const QKeyEvent &e)
 
virtual bool canHandle (const String &fileformat) const
 
virtual bool openFile (const String &filename)
 
bool openFile (const String &filename, bool run, bool is_current=false)
 
bool runString (String command)
 
String getCurrentLine () const
 
void dump (std::ostream &s, Size depth) const
 
void showClassDocu (String classname, String member)
 
virtual void fetchPreferences (INIFile &inifile)
 
virtual void writePreferences (INIFile &inifile)
 
void checkMenu (MainControl &main_control)
 
QString getCurrentScript ()
 
bool isInDirectMode () const
 
void showEditContextMenu (const QPoint &point)
 
void showContextMenu (const QPoint &point)
 
void showCompletion ()
 
void clear ()
 
void exportHistory ()
 
void abortScript ()
 
void showDocumentation ()
 
bool runCurrentScript ()
 
void loadScript ()
 
void execScript ()
 
void saveScript ()
 
void clearScript ()
 
virtual void hotkeyItem ()
 
virtual void modifyHotkeys ()
 
void appendText (const String &text, bool output=false, bool state_message=false)
 
bool getMembers (const String &classname, QStringList &sl, const String &prefix)
 
virtual bool returnPressed ()
 
virtual bool completionSelected_ ()
 
virtual void showHelp_ ()
 
virtual void printCursorPosition_ ()
 
virtual void createScript_ ()
 
virtual void clearHistory_ ()
 
bool getClassAndMember_ (String toc)
 
void setError_ (bool state)
 
virtual void startInterpreter ()
 
virtual void paste ()
 
bool parseLine_ (String line)
 Parse a and execute a given string. If silent_ is set to true, no prompts are being printed. More...
 
void appendToHistory_ (const String &line)
 
void newPrompt_ ()
 
bool testMultilineStart_ (const String &line)
 
const char * getPrompt_ () const
 
bool storeScript_ ()
 
String runCommand_ (const String &command, bool &state)
 
void appendText_ (TextEditorWidget *te, String text)
 
void retrieveHistoryLine_ (Position index)
 
virtual void contentsDragEnterEvent (QDragEnterEvent *e)
 
virtual void contentsDropEvent (QDropEvent *e)
 
bool keyPressed (QKeyEvent *e)
 
void createMenuHelpEntry_ (QMenu *menu, TextEditorWidget *text_edit, const QPoint &point)
 
void findError_ (String result)
 
String getCurrentWord_ (QTextCursor &text_cursor)
 
QComboBox * getCompletionBox_ ()
 
std::list< Hotkey >::iterator findKey_ (Hotkey &hotkey)
 

Additional Inherited Members

- Public Types inherited from BALL::Embeddable
typedef std::vector< Embeddable * > EmbeddableVector
 
- Public Slots inherited from BALL::VIEW::DockWidget
virtual void dropEvent (QDropEvent *e)
 
virtual void dragEnterEvent (QDragEnterEvent *e)
 
virtual void showGuestContextMenu (const QPoint &)
 
- Static Public Member Functions inherited from BALL::VIEW::ModularWidget
static void registerWidget (ModularWidget *mwidget) throw (Exception::NullPointer)
 
- Protected Member Functions inherited from BALL::VIEW::DockWidget
 DockWidget ()
 
 DockWidget (const DockWidget &)
 
- Static Protected Member Functions inherited from BALL::Embeddable
static void registerInstance_ (const std::type_info &type, const Embeddable *instance)
 
static void unregisterInstance_ (const Embeddable *instance)
 
static Size countInstances_ (const std::type_info &type)
 
static EmbeddablegetInstance_ (const std::type_info &type, Position index)
 
static EmbeddablegetInstance_ (const std::type_info &type, const String &identifier)
 
- Protected Attributes inherited from BALL::VIEW::DockWidget
QWidgetcontainer_
 
QWidgetguest_
 
QGridLayout * layout_
 

Detailed Description

Python Widget This class is a Window for a Python interpreter interface. So it is possible to access all data in the running application in realtime with the script language. PyWidget also has the capablities to run a Python script from a file at startup, or on demand from the user.

Definition at line 142 of file pyWidget.h.

Constructor & Destructor Documentation

BALL::VIEW::PyWidget::PyWidget ( QWidget parent = 0,
const char *  name = 0 
)

Standard constructor. If the widget is part of a BALL MainControl widget, it inserts a menu entry Tools|Restart Python into the menu bar.

Parameters
parentthe parent widget
namethe widget name
BALL::VIEW::PyWidget::PyWidget ( const PyWidget p)

only needed for Pyhon Interface

BALL::VIEW::PyWidget::~PyWidget ( )

Member Function Documentation

void BALL::VIEW::PyWidget::abortScript ( )
slot
void BALL::VIEW::PyWidget::appendText ( const String text,
bool  output = false,
bool  state_message = false 
)
slot
void BALL::VIEW::PyWidget::appendText_ ( TextEditorWidget te,
String  text 
)
protected
void BALL::VIEW::PyWidget::appendToHistory_ ( const String line)
protected
virtual void BALL::VIEW::PyWidget::applyPreferences ( )
virtual

Apply the preferences of the specific tab. In this method the widget can extract any changed values from its preferences tab (if required). This method is called automatically by the applyPreferencesTab from the MainControl object if the apply button in the Preferences dialog is pressed.

Parameters
preferencesthe Preferences dialog of the MainControl
See Also
initializePreferencesTab
finalizePreferencesTab
applyPreferencesTab

Reimplemented from BALL::VIEW::ModularWidget.

virtual bool BALL::VIEW::PyWidget::canHandle ( const String fileformat) const
virtual

Test if this ModularWidget can handle a given file format. (Overloaded from ModularWidget)

Parameters
fileformshort string with the file extension (e.g. PDB)
See Also
openFile

Reimplemented from BALL::VIEW::ModularWidget.

void BALL::VIEW::PyWidget::checkMenu ( MainControl main_control)
virtual

Menu checking method. This method is called MainControl::checkMenus before a popup menu is shown. It should be used to update the state of menu entries (e.g. disable or enable entries).

Parameters
main_controlthe MainControl object whose menus should be checked

Reimplemented from BALL::VIEW::ModularWidget.

void BALL::VIEW::PyWidget::clear ( )
slot
virtual void BALL::VIEW::PyWidget::clearHistory_ ( )
protectedvirtualslot
void BALL::VIEW::PyWidget::clearScript ( )
slot
virtual bool BALL::VIEW::PyWidget::completionSelected_ ( )
protectedvirtualslot
virtual void BALL::VIEW::PyWidget::contentsDragEnterEvent ( QDragEnterEvent *  e)
protectedvirtual
virtual void BALL::VIEW::PyWidget::contentsDropEvent ( QDropEvent *  e)
protectedvirtual
void BALL::VIEW::PyWidget::createMenuHelpEntry_ ( QMenu *  menu,
TextEditorWidget text_edit,
const QPoint &  point 
)
protected
virtual void BALL::VIEW::PyWidget::createScript_ ( )
protectedvirtualslot
void BALL::VIEW::PyWidget::dump ( std::ostream &  s,
Size  depth 
) const
virtual

Internal state dump. Dump the current internal state of this mainControl to the output ostream s with dumping depth depth. Calls ConnectionObject::dump.

Parameters
soutput stream where to output the internal state
depththe dumping depth

Reimplemented from BALL::VIEW::ModularWidget.

void BALL::VIEW::PyWidget::execScript ( )
slot
void BALL::VIEW::PyWidget::exportHistory ( )
slot
virtual void BALL::VIEW::PyWidget::fetchPreferences ( INIFile inifile)
virtual

Load settings from an INIFile

See Also
ModularWidget::fetchPreferences

Reimplemented from BALL::VIEW::DockWidget.

void BALL::VIEW::PyWidget::finalizePreferencesTab ( Preferences preferences)
virtual

Remove the preferences tab. This method can remove a preferences widget (if created in initializePreferencesTab) from the Preferences dialog of the MainControl. This method is called automatically by MainControl::aboutToExit() at the end of the application.

Parameters
preferencesthe Preferences dialog of the MainControl

Reimplemented from BALL::VIEW::ModularWidget.

virtual void BALL::VIEW::PyWidget::finalizeWidget ( MainControl main_control)
virtual

Remove menu entries.

Reimplemented from BALL::VIEW::ModularWidget.

void BALL::VIEW::PyWidget::findError_ ( String  result)
protected
std::list<Hotkey>::iterator BALL::VIEW::PyWidget::findKey_ ( Hotkey hotkey)
protected
bool BALL::VIEW::PyWidget::getClassAndMember_ ( String  toc)
protected
QComboBox* BALL::VIEW::PyWidget::getCompletionBox_ ( )
protected
String BALL::VIEW::PyWidget::getCurrentLine ( ) const
QString BALL::VIEW::PyWidget::getCurrentScript ( )
String BALL::VIEW::PyWidget::getCurrentWord_ ( QTextCursor &  text_cursor)
protected
bool BALL::VIEW::PyWidget::getMembers ( const String classname,
QStringList &  sl,
const String prefix 
)
slot
const char* BALL::VIEW::PyWidget::getPrompt_ ( ) const
protected
virtual void BALL::VIEW::PyWidget::hotkeyItem ( )
virtualslot
void BALL::VIEW::PyWidget::initializePreferencesTab ( Preferences preferences)
virtual

Initialize a preferences tab for the widget (if needed). This method can be used to create preferences widgets that can be inserted into the Preferences dialog with the method insertTab. This method is called automatically by MainControl::show at the start of the application.

Parameters
preferencesthe Preferences dialog of the MainControl

Reimplemented from BALL::VIEW::ModularWidget.

virtual void BALL::VIEW::PyWidget::initializeWidget ( MainControl main_control)
virtual

Setup the menu entries.

Reimplemented from BALL::VIEW::DockWidget.

void BALL::VIEW::PyWidget::insertHotkey ( const Hotkey hotkey)
bool BALL::VIEW::PyWidget::isInDirectMode ( ) const
bool BALL::VIEW::PyWidget::isValid ( ) const
inlinevirtual

Is full Python support available?

Reimplemented from BALL::VIEW::ConnectionObject.

Definition at line 204 of file pyWidget.h.

bool BALL::VIEW::PyWidget::keyPressed ( QKeyEvent *  e)
protected
void BALL::VIEW::PyWidget::loadScript ( )
slot
void BALL::VIEW::PyWidget::map ( String  modifier,
String  key,
String  command,
String  comment = "" 
)

Map a key to a command Modifier can be: "", Ctrl, Shift Key should be F2 - F12

virtual void BALL::VIEW::PyWidget::modifyHotkeys ( )
virtualslot
void BALL::VIEW::PyWidget::newPrompt_ ( )
protected

Print prompt. Determine the correct type of prompt and append it to the current text. The cursor is placed after the prompt and textChanged is emitted.

virtual bool BALL::VIEW::PyWidget::openFile ( const String filename)
virtual

Tell this ModularWidget to open a given file. (Overloaded from ModularWidget)

See Also
canHandle

Reimplemented from BALL::VIEW::ModularWidget.

bool BALL::VIEW::PyWidget::openFile ( const String filename,
bool  run,
bool  is_current = false 
)

Run a Python script from a given file

Parameters
is_currentstates wheter this file is currently loaded in the editor
bool BALL::VIEW::PyWidget::parseLine_ ( String  line)
protected

Parse a and execute a given string. If silent_ is set to true, no prompts are being printed.

virtual void BALL::VIEW::PyWidget::paste ( )
protectedvirtual
virtual void BALL::VIEW::PyWidget::printCursorPosition_ ( )
protectedvirtualslot
void BALL::VIEW::PyWidget::reactTo ( const QKeyEvent &  e)
void BALL::VIEW::PyWidget::removeHotkey ( const Hotkey hotkey)
void BALL::VIEW::PyWidget::retrieveHistoryLine_ ( Position  index)
protected

Replace the line the cursor is in with a line from the history. Used to display text from the history (cursor down/up). The previous content of the line is stored in current_line_ if this is the first time the history function is used for this specific line.

virtual bool BALL::VIEW::PyWidget::returnPressed ( )
protectedvirtualslot
String BALL::VIEW::PyWidget::runCommand_ ( const String command,
bool state 
)
protected
bool BALL::VIEW::PyWidget::runCurrentScript ( )
slot
bool BALL::VIEW::PyWidget::runString ( String  command)
void BALL::VIEW::PyWidget::saveScript ( )
slot
virtual void BALL::VIEW::PyWidget::scriptDialog ( bool  run = false)
virtual

Open a dialog to select a script.

void BALL::VIEW::PyWidget::setError_ ( bool  state)
protected
void BALL::VIEW::PyWidget::showClassDocu ( String  classname,
String  member 
)
void BALL::VIEW::PyWidget::showCompletion ( )
slot
void BALL::VIEW::PyWidget::showContextMenu ( const QPoint &  point)
slot
void BALL::VIEW::PyWidget::showDocumentation ( )
slot
void BALL::VIEW::PyWidget::showEditContextMenu ( const QPoint &  point)
slot
virtual void BALL::VIEW::PyWidget::showHelp_ ( )
protectedvirtualslot
virtual void BALL::VIEW::PyWidget::startInterpreter ( )
protectedvirtual

Start the interpreter. This method initializes the interpreter if it is not yet running. An already running interpreter is reinitialized. This method calls PyInitialize() to create an interpreter.

bool BALL::VIEW::PyWidget::storeScript_ ( )
protected
bool BALL::VIEW::PyWidget::testMultilineStart_ ( const String line)
protected
bool BALL::VIEW::PyWidget::toAbortScript ( )
void BALL::VIEW::PyWidget::unmap ( String  modifier,
String  key 
)

see above

virtual void BALL::VIEW::PyWidget::writePreferences ( INIFile inifile)
virtual

Write settings to an INIFile

See Also
ModularWidget::writePreferences

Reimplemented from BALL::VIEW::DockWidget.

Friends And Related Function Documentation

friend class MyLineEdit
friend

Definition at line 177 of file pyWidget.h.

Member Data Documentation

String BALL::VIEW::PyWidget::class_
protected

Definition at line 447 of file pyWidget.h.

QComboBox* BALL::VIEW::PyWidget::combo_box_
protected

Definition at line 427 of file pyWidget.h.

Size BALL::VIEW::PyWidget::complete_prefix_
protected

Definition at line 446 of file pyWidget.h.

Position BALL::VIEW::PyWidget::current_line_
protected

Definition at line 435 of file pyWidget.h.

String BALL::VIEW::PyWidget::current_script_
protected

Definition at line 452 of file pyWidget.h.

QComboBox * BALL::VIEW::PyWidget::editor_combo_box_
protected

Definition at line 427 of file pyWidget.h.

bool BALL::VIEW::PyWidget::full_silent_
protected

Definition at line 450 of file pyWidget.h.

PythonHighlighter BALL::VIEW::PyWidget::highlighter_1_
protected

Definition at line 424 of file pyWidget.h.

PythonHighlighter BALL::VIEW::PyWidget::highlighter_2_
protected

Definition at line 424 of file pyWidget.h.

vector<String> BALL::VIEW::PyWidget::history_
protected

Definition at line 439 of file pyWidget.h.

Position BALL::VIEW::PyWidget::history_position_
protected

Definition at line 441 of file pyWidget.h.

std::list<Hotkey> BALL::VIEW::PyWidget::hotkeys_
protected

Definition at line 428 of file pyWidget.h.

Position BALL::VIEW::PyWidget::intend_
protected

Definition at line 448 of file pyWidget.h.

MyLineEdit* BALL::VIEW::PyWidget::line_edit_
protected

Definition at line 426 of file pyWidget.h.

String BALL::VIEW::PyWidget::member_
protected

Definition at line 447 of file pyWidget.h.

bool BALL::VIEW::PyWidget::multi_line_mode_
protected

Definition at line 436 of file pyWidget.h.

String BALL::VIEW::PyWidget::multi_line_text_
protected

Definition at line 438 of file pyWidget.h.

Size BALL::VIEW::PyWidget::multi_lines_
protected

Definition at line 437 of file pyWidget.h.

Preferences* BALL::VIEW::PyWidget::preferences_
protected

Definition at line 433 of file pyWidget.h.

PythonSettings* BALL::VIEW::PyWidget::python_settings_
protected

Definition at line 443 of file pyWidget.h.

vector<bool> BALL::VIEW::PyWidget::results_
protected

Definition at line 440 of file pyWidget.h.

bool BALL::VIEW::PyWidget::running_
protected

Definition at line 449 of file pyWidget.h.

MyTextEdit* BALL::VIEW::PyWidget::script_edit_
protected

Definition at line 422 of file pyWidget.h.

bool BALL::VIEW::PyWidget::script_mode_
protected

Definition at line 451 of file pyWidget.h.

TextEditorWidget * BALL::VIEW::PyWidget::script_output_
protected

Definition at line 421 of file pyWidget.h.

bool BALL::VIEW::PyWidget::silent_
protected

Definition at line 450 of file pyWidget.h.

bool BALL::VIEW::PyWidget::started_startup_script_
protected

Definition at line 432 of file pyWidget.h.

String BALL::VIEW::PyWidget::startup_script_
protected

Definition at line 442 of file pyWidget.h.

bool BALL::VIEW::PyWidget::stop_script_
protected

Definition at line 445 of file pyWidget.h.

QTabWidget* BALL::VIEW::PyWidget::tab_widget_
protected

Definition at line 423 of file pyWidget.h.

TextEditorWidget* BALL::VIEW::PyWidget::text_edit_
protected

Definition at line 421 of file pyWidget.h.

RunPythonThread* BALL::VIEW::PyWidget::thread_
protected

Definition at line 444 of file pyWidget.h.

bool BALL::VIEW::PyWidget::valid_
protected

Definition at line 431 of file pyWidget.h.

PythonValidator BALL::VIEW::PyWidget::validator_
protected

Definition at line 425 of file pyWidget.h.

String BALL::VIEW::PyWidget::working_dir_
protected

Definition at line 430 of file pyWidget.h.