File: QT_Spec.h

package info (click to toggle)
rlplot 1.5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 3,232 kB
  • ctags: 6,169
  • sloc: cpp: 83,932; yacc: 3,401; makefile: 172
file content (331 lines) | stat: -rwxr-xr-x 9,122 bytes parent folder | download | duplicates (3)
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
//QT_Spec.h, Copyright (c) 2001-2008 R.Lackner
//
//    This file is part of RLPlot.
//
//    RLPlot 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.
//
//    RLPlot is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with RLPlot; if not, write to the Free Software
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
#include "rlplot.h"
#include "menu.h"
#include "TheDialog.h"
#include <qwidget.h>
#include <qapplication.h>
#include <qnamespace.h>

#if QT_VERSION < 0x040000
	#include <qpen.h>
	#include <qprinter.h>
	#include <qdragobject.h>
	#include <qmenubar.h>
	#include <qscrollbar.h>
	#include <qmessagebox.h>
	#include <qpixmap.h>
	#include <qfiledialog.h>
	#include <qimage.h>
	#include <qcursor.h>
	#include <qclipboard.h>
	#include <qbuffer.h>
	#include <qbitmap.h>
	#include <qtextstream.h>
#else 
	#include <QtGui>
#endif

#define RLP_PORT	4321		//enable clipboard server
#ifdef RLP_PORT
	#include <sys/socket.h>
	#include <netdb.h>
	#include <pthread.h>
	#include <fcntl.h>
	#include <unistd.h>
	#include <sys/ioctl.h>
#endif

bool ProcMenuEvent(int id, QWidget *parent, anyOutput *OutputClass, GraphObj *BaseObj);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class TxtCurBlink:public QObject {
	Q_OBJECT
public:
	TxtCurBlink();
	void Show();
//	void showCopyMark();

protected:
	void timerEvent(QTimerEvent *);

private:
	bool isVis;
	int count;
};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// use sockets for to exchange clipboard data
// undefine RLP_PORT to limit clipboard to a single instance

class RLPserver {
public:
	GraphObj *SourceGO;
	bool bValid;

	RLPserver(QObject* parent=0, GraphObj *g=0);
	~RLPserver();
	void CreateThread();
	void SetGO(GraphObj *g);
	char *GetXML();
	char *GetRLP();
	char *GetTXT() {return text_plain; };
	bool ok() {return true;};
#ifdef RLP_PORT
	int Socket() {return sock;};
#endif

private:
	char *text_xml, *text_rlp, *text_plain;
#ifdef RLP_PORT
	pthread_t thread;
	pthread_attr_t thread_attr;
	int sock;
#endif
};

#if QT_VERSION < 0x040000 

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class RLPmenu:public QMenuBar {
	Q_OBJECT
public:
	RLPmenu(QWidget *par, anyOutput *o, GraphObj *g);

public slots:
	void doMenuItem(int id);

private:
	anyOutput *OutputClass;
	QWidget *parent;
	GraphObj *BaseObj;

};

#else 			//Qt version >= 4.0

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class RLPaction:public QAction {
	Q_OBJECT
public:
	RLPaction(QWidget *par, anyOutput *o, GraphObj *g, char *name, int id);
	~RLPaction(){;};

public slots:
	void doMenuItem();

private:
	int Id;
	anyOutput *OutputClass;
	QWidget *parent;
	GraphObj *BaseObj;
};

#endif

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// The Qt widget class implementet for RLPlot
class RLPwidget:public QMainWindow {
	Q_OBJECT

public:
	QScrollBar *HScroll, *VScroll;
	QPixmap *mempic;
	QMenuBar *menu_bar;

	RLPwidget(QWidget *par=0, const char *name=0, anyOutput *o = 0,
		GraphObj *g = 0);
	~RLPwidget();
	void openHistoryFile(int idx);

public slots:
	void hScrollEvent(int pos);
	void vScrollEvent(int pos);
	void cmNOP(){;};
	void cmCopy(){ProcMenuEvent(CM_COPY, this, OutputClass, BaseObj);};
	void cmCut(){ProcMenuEvent(CM_CUT, this, OutputClass, BaseObj);};
	void cmZoomIn(){ProcMenuEvent(CM_ZOOMIN, this, OutputClass, BaseObj);};
	void cmZoomOut(){ProcMenuEvent(CM_ZOOMOUT, this, OutputClass, BaseObj);};
	void cmZoomFit(){ProcMenuEvent(CM_ZOOMFIT, this, OutputClass, BaseObj);};
	void cmPaste();
	void cmUndo(){if(BaseObj) BaseObj->Command(CMD_UNDO, 0L, OutputClass);};
	void cmSave(){ProcMenuEvent(CM_SAVE, this, OutputClass, BaseObj);};
	void cmOpen(){ProcMenuEvent(CM_OPEN, this, OutputClass, BaseObj);};
	void cmPrint(){ProcMenuEvent(CM_PRINT, this, OutputClass, BaseObj);};
	void cmNewInst(){ProcMenuEvent(CM_NEWINST, this, OutputClass, BaseObj);};

protected:
	void paintEvent(QPaintEvent *);
	void resizeEvent(QResizeEvent *);
	void closeEvent(QCloseEvent *);
	void mouseDoubleClickEvent(QMouseEvent *e);
	void mousePressEvent(QMouseEvent *e);
	void mouseReleaseEvent(QMouseEvent *e);
	void mouseMoveEvent(QMouseEvent *e);
	void keyPressEvent(QKeyEvent *e);
	void focusInEvent(QFocusEvent *e);

private:
	QWidget *parent;
	anyOutput *OutputClass;
	GraphObj *BaseObj;
};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if QT_VERSION < 0x040000
class DlgWidget:public QWidget {
#else
class DlgWidget:public QWidget {
#endif
	Q_OBJECT
public:
	QPixmap *mempic;
	anyOutput *OutputClass;

	DlgWidget(QWidget *par=0L, const char *name = 0L, tag_DlgObj *d = 0L, DWORD flags = 0L);
	~DlgWidget();

protected:
	void paintEvent(QPaintEvent *);
	void mouseDoubleClickEvent(QMouseEvent *e);
	void mousePressEvent(QMouseEvent *e);
	void mouseReleaseEvent(QMouseEvent *e);
	void mouseMoveEvent(QMouseEvent *e);
	void keyPressEvent(QKeyEvent *e);
	void focusInEvent(QFocusEvent *e);
	void focusOutEvent(QFocusEvent *e);
	void closeEvent(QCloseEvent *e);
	void timerEvent(QTimerEvent *);

private:
	QWidget *parent;
	tag_DlgObj *dlg;
};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class BitMapQT:public anyOutput {
public:
	QMainWindow *widget;
	QWidget *dlgwidget;
	HatchOut *hgo;
	QPixmap *mempic;
	QImage *image;
	QPen qPen;
	QPainter qPainter;
	QFont qFont;
	void *ShowObj;				//eph_obj
	void *ShowAnimated;			//copy mark

	BitMapQT(GraphObj *g, QMainWindow *wi, int vr = 98, int hr = 98);
	BitMapQT(GraphObj *g, QWidget *wi, int vr = 98, int hr = 98);
	BitMapQT(int w, int h, double hr, double vr);
	~BitMapQT();
	bool SetLine(LineDEF *lDef);
	bool SetFill(FillDEF *fill);
	bool SetTextSpec(TextDEF *set);
	virtual bool Erase(DWORD Color);
	virtual bool StartPage() {return true;};
	bool CopyBitmap(int x, int y, anyOutput* src, int sx, int sy,
		int sw, int sh, bool invert);
	virtual void MouseCapture(bool bgrab){return;};
	bool oGetTextExtent(char *text, int cb, int *width, int *height);
	bool oGetTextExtentW(w_char *text, int cb, int *width, int *height);
	bool oGetPix(int x, int y, DWORD *col);
	bool oDrawIcon(int type, int x, int y);
	bool oCircle(int x1, int y1, int x2, int y2, char* nam = 0L);
	bool oPolyline(POINT * pts, int cp, char *nam = 0L);
	bool oRectangle(int x1, int y1, int x2, int y2, char *nam = 0L);
	bool oSolidLine(POINT *p);
	bool oTextOut(int x, int y, char *txt, int cb);
	bool oTextOutW(int x, int y, w_char *txt, int cb);
	bool oPolygon(POINT *pts, int cp, char *nam = 0L);
};

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class OutputQT:public BitMapQT {
public:
	QScrollBar *HScroll, *VScroll;
#if QT_VERSION < 0x040000
	RLPmenu *menu;
#else
	QAction *itFil1, *itFil2, *itFil3, *itFil4, *itFil5, *itFil6;
	QAction *ittStd, *ittDraw, *ittPl, *ittPg, *ittRec, *ittRrec, *ittElly, *ittArr, *ittTxt;
#endif

	OutputQT(GraphObj *g);
	OutputQT(DlgWidget *wi);
	~OutputQT();
	bool ActualSize(RECT *rc);
	void Focus(){if(widget){widget->show(); widget->activateWindow();widget->raise();}};
	void Caption(char *txt, bool bModified);
	void MouseCursor(int cid, bool force);
	bool SetScroll(bool isVert, int iMin, int iMax, int iPSize, int iPos);
	bool EndPage();
	void MouseCapture(bool bgrab);
	bool UpdateRect(RECT *rc, bool invert);
	void ShowLine(POINT * pts, int cp, DWORD color);
	void ShowEllipse(POINT p1, POINT p2, DWORD color); 
	void ShowInvert(RECT *rec);
	bool SetMenu(int type);
	void CheckMenu(int mid, bool check);
	void FileHistory();
	void CreateNewWindow(GraphObj *g);

private:
	GraphObj *BaseObj;
};

class PrintQT:public anyOutput{
public:
	HatchOut *hgo;
	QPrinter *printer;

	PrintQT(GraphObj *g, char *file);
	~PrintQT();
	bool ActualSize(RECT *rc);
	bool SetLine(LineDEF *lDef);
	bool SetFill(FillDEF *fill);
	bool SetTextSpec(TextDEF *set);
	bool StartPage();
	bool EndPage();
	bool Eject();
	bool oGetTextExtent(char *text, int cb, int *width, int *height);
	bool oGetTextExtentW(w_char *text, int cb, int *width, int *height);
	bool oCircle(int x1, int y1, int x2, int y2, char* nam = 0L);
	bool oPolyline(POINT * pts, int cp, char *nam = 0L);
	bool oRectangle(int x1, int y1, int x2, int y2, char *nam = 0L);
	bool oSolidLine(POINT *p);
	bool oTextOut(int x, int y, char *txt, int cb);
	bool oTextOutW(int x, int y, w_char *txt, int cb);
	bool oPolygon(POINT *pts, int cp, char *nam = 0L);

private:
	QPen qPen;
	QFont qFont;
	QPainter qPainter;
#if QT_VERSION >= 0x040000
	QMatrix dxf;
#else
	QWMatrix dxf;
#endif
	char *fileName;
	GraphObj *go;
	bool bPrinting;
};