summaryrefslogtreecommitdiffstats
path: root/src/documentiface.h
blob: 5f32cfe41de5a551e684232f32d16cdbfde01adf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/***************************************************************************
 *   Copyright (C) 2005 by David Saxton                                    *
 *   [email protected]                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef DOCUMENTIFACE_H
#define DOCUMENTIFACE_H

#include "config.h"

#include <dcopobject.h>
#include <dcopref.h>

class CircuitDocument;
class Document;
class FlowCodeDocument;
class ICNDocument;
class ItemDocument;
class MechanicsDocument;
class TextDocument;
class View;

/**
@author David Saxton
*/
class DocumentIface : public DCOPObject
{
	K_DCOP

	public:
		DocumentIface( Document * document );
		virtual ~DocumentIface();
		
	k_dcop:
		QString caption() const;
		DCOPRef activeView();
		uint numberOfViews();
// 		View *createView( ViewContainer *viewContainer, uint viewAreaId, const char *name = 0l );
		QString url();
		bool openURL( const QString & url );
		bool isModified();
		bool isUndoAvailable();
		bool isRedoAvailable();
		void save();
		void saveAs();
		bool close();
		void print();
		void cut();
		void copy();
		void paste();
		void undo();
		void redo();
		void selectAll();
		
	protected:
		DCOPRef viewToRef( View * view );
		
		Document * m_pDocument;
};

class TextDocumentIface : public DocumentIface
{
	K_DCOP

	public:
		TextDocumentIface( TextDocument * document );
		
	k_dcop:
		void formatAssembly();
		void convertToMicrobe();
		void convertToHex();
		void convertToPIC();
		void convertToAssembly();
		void clearBookmarks();
		bool isDebugging();
		void debugRun();
		void debugInterrupt();
		void debugStop();
		void debugStep();
		void debugStepOver();
		void debugStepOut();
		
	protected:
		TextDocument * m_pTextDocument;
};

class ItemDocumentIface : public DocumentIface
{
	K_DCOP

	public:
		ItemDocumentIface( ItemDocument * document );
		
	k_dcop:
		QCStringList validItemIDs();
		/**
		 * Create an item with the given id (e.g. "ec/resistor") at the given
		 * position.
		 * @return name of item (assigned to it by KTechlab)
		 */
		QString addItem( const QString & id, int x, int y );
		void selectItem( const QString & id );
		void unselectItem( const QString & id );
		void clearHistory();
		void unselectAll();
		void alignHorizontally();
		void alignVertically();
		void distributeHorizontally();
		void distributeVertically();
		void deleteSelection();
		
	protected:
		ItemDocument * m_pItemDocument;
};

class MechanicsDocumentIface : public ItemDocumentIface
{
	K_DCOP
			
	public:
		MechanicsDocumentIface( MechanicsDocument * document );
		
	protected:
		MechanicsDocument * m_pMechanicsDocument;
};

class ICNDocumentIface : public ItemDocumentIface
{
	K_DCOP

	public:
		ICNDocumentIface( ICNDocument * document );
		
	k_dcop:
		void exportToImage();
		QCStringList nodeIDs( const QString & id );
		/**
		 * Makes a connection from node1 on item1 to node2 on item2
		 */
		QString makeConnection( const QString & item1, const QString & node1, const QString & item2, const QString & node2 );
		void selectConnector( const QString & id );
		void unselectConnector( const QString & id );
		
	protected:
		ICNDocument * m_pICNDocument;
};

class CircuitDocumentIface : public ICNDocumentIface
{
	K_DCOP

	public:
		CircuitDocumentIface( CircuitDocument * document );
		
	k_dcop:
		void setOrientation0();
		void setOrientation90();
		void setOrientation180();
		void setOrientation270();
		void rotateCounterClockwise();
		void rotateClockwise();
		void flip();
		void displayEquations();
		void createSubcircuit();
		
	protected:
		CircuitDocument * m_pCircuitDocument;
};

class FlowCodeDocumentIface : public ICNDocumentIface
{
	K_DCOP

	public:
		FlowCodeDocumentIface( FlowCodeDocument * document );
		void convertToMicrobe();
		void convertToHex();
		void convertToPIC();
		void convertToAssembly();
		
	k_dcop:
		void setPicType( const QString & id );
		
	protected:
		FlowCodeDocument * m_pFlowCodeDocument;
};

#endif