~ubuntu-branches/ubuntu/oneiric/kig/oneiric

« back to all changes in this revision

Viewing changes to scripting/script_mode.h

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2011-07-10 11:57:38 UTC
  • Revision ID: james.westby@ubuntu.com-20110710115738-gdjnn1kctr49lmy9
Tags: upstream-4.6.90+repack
ImportĀ upstreamĀ versionĀ 4.6.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C)  2003  Dominique Devriese <devriese@kde.org>
 
2
 
 
3
// This program is free software; you can redistribute it and/or
 
4
// modify it under the terms of the GNU General Public License
 
5
// as published by the Free Software Foundation; either version 2
 
6
// of the License, or (at your option) any later version.
 
7
 
 
8
// This program is distributed in the hope that it will be useful,
 
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
// GNU General Public License for more details.
 
12
 
 
13
// You should have received a copy of the GNU General Public License
 
14
// along with this program; if not, write to the Free Software
 
15
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
16
// 02110-1301, USA.
 
17
 
 
18
#ifndef KIG_SCRIPTING_SCRIPT_MODE_H
 
19
#define KIG_SCRIPTING_SCRIPT_MODE_H
 
20
 
 
21
#include "script-common.h"
 
22
 
 
23
#include "../modes/base_mode.h"
 
24
 
 
25
#include <list>
 
26
 
 
27
class NewScriptWizard;
 
28
 
 
29
/**
 
30
 * Base mode to interact with a script.
 
31
 */
 
32
class ScriptModeBase
 
33
  : public BaseMode
 
34
{
 
35
protected:
 
36
  ScriptModeBase( KigPart& doc );
 
37
 
 
38
// mp: argument list is implemented as a std::list instead of std::set
 
39
// because otherwise the user loses the correct argument ordering (in
 
40
// case of more than one argument
 
41
  std::list<ObjectHolder*> margs;
 
42
  NewScriptWizard* mwizard;
 
43
 
 
44
  KigPart& mpart;
 
45
 
 
46
  enum WAWD { SelectingArgs, EnteringCode };
 
47
  WAWD mwawd;
 
48
 
 
49
private:
 
50
  ScriptType::Type mtype;
 
51
 
 
52
public:
 
53
  virtual ~ScriptModeBase();
 
54
 
 
55
  void dragRect( const QPoint& p, KigWidget& w );
 
56
//  void dragObject( const Objects& os, const QPoint& pointClickedOn, KigWidget& w, bool ctrlOrShiftDown );
 
57
  void leftClickedObject( ObjectHolder* o, const QPoint& p,
 
58
                          KigWidget& w, bool actrlOrShiftDown );
 
59
  void mouseMoved( const std::vector<ObjectHolder*>& os, const QPoint& p,
 
60
                   KigWidget& w, bool shiftpressed );
 
61
  void midClicked( const QPoint&, KigWidget& );
 
62
  void rightClicked( const std::vector<ObjectHolder*>&, const QPoint&, KigWidget& );
 
63
 
 
64
  void argsPageEntered();
 
65
  void codePageEntered();
 
66
 
 
67
  virtual bool queryFinish() = 0;
 
68
  virtual bool queryCancel() = 0;
 
69
 
 
70
  void redrawScreen( KigWidget* w );
 
71
 
 
72
  void killMode();
 
73
 
 
74
  void enableActions();
 
75
 
 
76
  void setScriptType( ScriptType::Type type );
 
77
 
 
78
  void addArgs( const std::vector<ObjectHolder*>& obj, KigWidget& w );
 
79
 
 
80
  void goToCodePage();
 
81
 
 
82
};
 
83
 
 
84
/**
 
85
 * Script mode to create a script.
 
86
 */
 
87
class ScriptCreationMode
 
88
  : public ScriptModeBase
 
89
{
 
90
public:
 
91
  ScriptCreationMode( KigPart& doc );
 
92
  virtual ~ScriptCreationMode();
 
93
 
 
94
  virtual bool queryFinish();
 
95
  virtual bool queryCancel();
 
96
};
 
97
 
 
98
/**
 
99
 * Script mode to edit an already-built script.
 
100
 */
 
101
class ScriptEditMode
 
102
  : public ScriptModeBase
 
103
{
 
104
private:
 
105
  ObjectTypeCalcer* mexecuted;
 
106
  std::vector<ObjectCalcer*> mexecargs;
 
107
  std::vector<ObjectCalcer*> mcompiledargs;
 
108
 
 
109
  QString morigscript;
 
110
 
 
111
public:
 
112
  ScriptEditMode( ObjectTypeCalcer* exec_calc, KigPart& doc );
 
113
  virtual ~ScriptEditMode();
 
114
 
 
115
  virtual bool queryFinish();
 
116
  virtual bool queryCancel();
 
117
};
 
118
 
 
119
#endif