1 #ifndef EMBEDDER_H
2 #define EMBEDDER_H
3 
4 #include <qglobal.h>
5 #include "macros.h"
6 
7 #if (defined(QMC2_OS_UNIX) && QT_VERSION < 0x050000) || defined(QMC2_OS_WIN)
8 
9 #if defined(QMC2_OS_UNIX)
10 #include <QX11EmbedContainer>
11 #include "embedderopt.h"
12 #elif defined(QMC2_OS_WIN)
13 #include <QtGui>
14 #include <QTimer>
15 #include "embedderopt.h"
16 #endif
17 
18 class Embedder : public QWidget
19 {
20 	Q_OBJECT
21 
22 	friend class EmbedContainer;
23 
24 	public:
25 		bool embedded;
26 		bool optionsShown;
27 		WId embeddedWinId;
28 		EmbedderOptions *embedderOptions;
29 		QGridLayout *gridLayout;
30 		QString machineName;
31 		QString machineId;
32 		QSize nativeResolution;
33 		int cmLeft, cmTop, cmRight, cmBottom;
34 #if defined(QMC2_OS_UNIX)
35 		bool pauseKeyPressed;
36 		bool isPaused;
37 		bool resuming;
38 		bool pausing;
39 		QX11EmbedContainer *embedContainer;
40 #elif defined(QMC2_OS_WIN)
41 		bool isPaused;
42 		QWidget *embedContainer;
43 #endif
44 		QIcon iconRunning;
45 		QIcon iconPaused;
46 		QIcon iconStopped;
47 		QIcon iconUnknown;
48 
49 		Embedder(QString name, QString id, WId wid, bool currentlyPaused = false, QWidget *parent = 0, QIcon icon = QIcon());
50 
51 	public slots:
52 		void embed();
embed(WId wid)53 		void embed(WId wid) { embeddedWinId = wid; embed(); }
54 		void release();
55 		void clientClosed();
56 		void toggleOptions();
57 		void adjustIconSizes();
58 		void forceFocus();
59 #if defined(QMC2_OS_UNIX)
60 		void simulatePauseKey();
61 		void pause();
62 		void resume();
63 		void showEventDelayed();
64 		void hideEventDelayed();
65 		void clientEmbedded();
66 		void clientError(QX11EmbedContainer::Error);
67 #endif
68 
69 	protected:
70 		void closeEvent(QCloseEvent *);
71 		void showEvent(QShowEvent *);
72 		void hideEvent(QHideEvent *);
73 		void resizeEvent(QResizeEvent *);
74 
75 	signals:
76 		void closing();
77 
78 #if defined(QMC2_OS_WIN)
79 	private slots:
80 		void checkWindow();
81 		void updateWindow();
82 
83 	private:
84 		QRect originalRect;
85 		QTimer checkTimer;
86 		HWND windowHandle;
87 		QString windowTitle;
88 		bool embeddingWindow;
89 		bool releasingWindow;
90 		bool checkingWindow;
91 		bool updatingWindow;
92 		bool fullScreen;
93 #endif
94 };
95 
96 #endif
97 
98 #endif
99