00001 #ifndef PYTHON_SHELL_TRANSITION_HH
00002 #define PYTHON_SHELL_TRANSITION_HH
00003
00004 #include <utility>
00005 #include <QObject>
00006 #include <QEvent>
00007 #include <ost/gui/python_shell/python_interpreter.hh>
00008 #include "transition_guard.hh"
00009
00010
00011 class QKeyEvent;
00012 class QMouseEvent;
00013
00014 namespace ost { namespace gui {
00015
00016
00017 class State;
00018 class PythonShellWidget;
00019 class ShellHistory;
00020
00021 class TransitionBase: public QObject{
00022 Q_OBJECT
00023 public:
00024 TransitionBase(State* target, TransitionGuard* guard=new TransitionGuard());
00025 signals:
00026 void triggered();
00027 protected:
00028 void trigger_();
00029 bool is_active_();
00030 State* target_;
00031 TransitionGuard* guard_;
00032 };
00033
00034 class AutomaticTransition: public TransitionBase{
00035 Q_OBJECT
00036 public:
00037 AutomaticTransition(State* target, TransitionGuard* guard=new TransitionGuard());
00038 bool checkTransition();
00039 };
00040
00041 class SignalTransition: public TransitionBase{
00042 Q_OBJECT
00043 public:
00044 SignalTransition(QObject * sender,const char * signal, State* target, TransitionGuard* guard=new TransitionGuard());
00045 protected slots:
00046 void onSignal();
00047 };
00048
00049 class KeyEventTransition: public TransitionBase{
00050 Q_OBJECT
00051 public:
00052 KeyEventTransition(QEvent::Type type,int key,Qt::KeyboardModifiers modifiers, State* target, bool swallow_event=true, TransitionGuard* guard=new TransitionGuard());
00053 virtual std::pair<bool,bool> checkEvent(QKeyEvent* event);
00054 protected:
00055 QEvent::Type type_;
00056 int key_;
00057 Qt::KeyboardModifiers modifiers_;
00058 bool swallow_;
00059 };
00060
00061 class MouseEventTransition: public TransitionBase{
00062 Q_OBJECT
00063 public:
00064 MouseEventTransition(QEvent::Type type,Qt::MouseButton button,Qt::KeyboardModifiers modifiers, State* target, bool swallow_event=true, TransitionGuard* guard=new TransitionGuard());
00065 virtual std::pair<bool,bool> checkEvent(QMouseEvent* event);
00066 protected:
00067 QEvent::Type type_;
00068 Qt::MouseButton button_;
00069 Qt::KeyboardModifiers modifiers_;
00070 bool swallow_;
00071 };
00072
00073
00074
00075
00076 }}
00077 #endif // PYTHON_SHELL_TRANSITION_HH