0023151: Add command line option to DRAWEXE to execute specified command
[occt.git] / src / Draw / Draw_Window.hxx
CommitLineData
b311480e 1// Created on: 1994-07-27
2// Created by: Remi LEQUETTE
3// Copyright (c) 1994-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#ifndef Draw_Window_HeaderFile
23#define Draw_Window_HeaderFile
24
25#include <Standard_Boolean.hxx>
26#include <Standard_Integer.hxx>
27
28#ifndef WNT
29
30const Standard_Integer MAXCOLOR = 15;
31
32typedef unsigned long Window;
33typedef unsigned long Pixmap;
34typedef unsigned long Drawable;
35
36// Definition de la class Base_Window (Definie dans Draw_Window.cxx)
37//===================================
38class Base_Window;
39
40// Definition de la classe Segment
41//================================
42struct Segment
43{
44 short xx1;
45 short yy1;
46 short xx2;
47 short yy2;
48
49 void Init(short x1, short y1, short x2, short y2) {
50 xx1 = x1; yy1 = y1; xx2 = x2; yy2 = y2;
51 }
52
53};
54
55// Definition de la structure Event
56//=================================
57typedef struct Event
58{
59 Standard_Integer type;
60 Window window;
61 Standard_Integer button;
62 Standard_Integer x;
63 Standard_Integer y;
64} Event;
65
66// Definition de la classe Draw_Window
67//====================================
68class Draw_Window
69{
70
71 public :
72
73 Draw_Window (); // the window is not initialized
74 Draw_Window (const char* title,
75 Standard_Integer X, Standard_Integer Y = 0,
76 Standard_Integer DX = 50, Standard_Integer DY = 50);
77
78 Draw_Window (Window mother);
79 Draw_Window (Window mother,char* title,
80 Standard_Integer X = 0, Standard_Integer Y = 0,
81 Standard_Integer DX = 50, Standard_Integer DY = 50);
82 Draw_Window(const char *window);
83
84 void Init (Standard_Integer X = 0, Standard_Integer Y = 0,
85 Standard_Integer DX = 50, Standard_Integer DY = 50);
86
87 void Init (Window mother,
88 Standard_Integer X = 0, Standard_Integer Y = 0,
89 Standard_Integer DX = 50, Standard_Integer DY = 50);
90
91
92 void StopWinManager();
93
94 void SetPosition (Standard_Integer NewXpos,
95 Standard_Integer NewYpos);
96
97 void SetDimension(Standard_Integer NewDx,
98 Standard_Integer NewDy);
99
100 void GetPosition(Standard_Integer &PosX,
101 Standard_Integer &PosY);
102
103 Standard_Integer HeightWin() const;
104 Standard_Integer WidthWin() const;
105
106 void SetTitle(const char* title);
107 char* GetTitle();
108
109 void DisplayWindow();
110 void Hide();
111 void Destroy();
112 void Clear();
113 void Wait(Standard_Boolean wait = Standard_True);
114
115 Drawable GetDrawable() const;
116 // Initializes off-screen image buffer according to current window size
117 void InitBuffer();
118
119 static Standard_Boolean DefineColor(const Standard_Integer, const char*);
120 void SetColor(int);
121 void SetMode(int);
122 void DrawString(int, int, char*);
123 void DrawSegments(Segment* ,int);
124 void Redraw();
125 static void Flush();
126
127 // save snapshot
128 Standard_Boolean Save(const char* theFileName) const;
129
130 virtual ~Draw_Window ();
131
132 // X Event management
133 virtual void WExpose();
134 virtual void WButtonPress(const Standard_Integer X,
135 const Standard_Integer Y,
136 const Standard_Integer& button);
137 virtual void WButtonRelease(const Standard_Integer X,
138 const Standard_Integer Y,
139 const Standard_Integer& button);
140 //virtual void WKeyPress(char, KeySym& );
141 virtual void WMotionNotify(const Standard_Integer X,
142 const Standard_Integer Y);
143
144 virtual void WConfigureNotify(const Standard_Integer X,
145 const Standard_Integer Y,
146 const Standard_Integer dx,
147 const Standard_Integer dy);
148
149 virtual void WUnmapNotify();
150
151 Base_Window& base;
152 Window win;
153 Window myMother; // default : myMother is the root window
154 Pixmap myBuffer;
155
156 static Draw_Window* firstWindow;
157 Draw_Window* next;
158 Draw_Window* previous;
159
160 Standard_Boolean myUseBuffer;
161 Standard_Boolean withWindowManager;
162
163};
164
165//======================================================
166// funtion : Run_Appli
167// purpose : run the application
168// interp will be called to interpret a command
169// and return True if the command is complete
170//======================================================
171
bf03eb83 172void Run_Appli(Standard_Boolean (*inteprete) (const char*));
7fd59977 173
174//======================================================
175// funtion : Init_Appli
176// purpose :
177//======================================================
178Standard_Boolean Init_Appli();
179
180//======================================================
181// funtion : Destroy_Appli()
182// purpose :
183//======================================================
184void Destroy_Appli();
185
186//======================================================
187// funtion : GetNextEvent()
188// purpose :
189//======================================================
190void GetNextEvent(Event&);
191
192#else
193// Specifique WNT
194
195#include <windows.h>
196
197#define DRAWCLASS "DRAWWINDOW"
198#define DRAWTITLE "Draw View"
199#define MAXCOLOR 15
200
201#if !defined(__Draw_API) && !defined(HAVE_NO_DLL)
202# ifdef __Draw_DLL
203# define __Draw_API __declspec( dllexport )
204# else
205# define __Draw_API __declspec( dllimport )
206# endif
207#endif
208
209// definition de la classe Segment
210
211class DrawWindow;
212class Segment
213{
214 friend class DrawWindow;
215 public :
216 //constructeur
217 Segment () {}
218 //destructeur
219 ~Segment () {}
220
221 //methods
222 void Init(Standard_Integer,
223 Standard_Integer,
224 Standard_Integer,
225 Standard_Integer);
226 private:
227 //atributs :
228 Standard_Integer x1;
229 Standard_Integer y1;
230 Standard_Integer x2;
231 Standard_Integer y2;
232};
233
234//definition de la classe DRAWWINDOW
235
236class DrawWindow
237{
238 //constructeur
239public:
240 __Draw_API DrawWindow();
241 __Draw_API DrawWindow(char*, Standard_Integer, Standard_Integer,
242 Standard_Integer, Standard_Integer);
243 __Draw_API DrawWindow(char*, Standard_Integer, Standard_Integer,
244 Standard_Integer, Standard_Integer, HWND);
245 //destructeur
246 __Draw_API ~DrawWindow();
247
248 //methods
249public:
250 __Draw_API void Init(Standard_Integer, Standard_Integer,
251 Standard_Integer, Standard_Integer);
252
253 __Draw_API void SetUseBuffer(Standard_Boolean);
254 // Turns on/off usage of off-screen image buffer (can be used for redrawing optimization)
255
256 __Draw_API Standard_Boolean GetUseBuffer() const { return myUseBuffer; }
257 // Returns Standard_True if off-screen image buffer is being used
258
259 //taille et position
260 __Draw_API void SetPosition (Standard_Integer,Standard_Integer);
261 __Draw_API void SetDimension(Standard_Integer,Standard_Integer);
262 __Draw_API void GetPosition (Standard_Integer&,Standard_Integer&);
263 __Draw_API Standard_Integer HeightWin() const;
264 __Draw_API Standard_Integer WidthWin() const;
265
266 //Title
267 __Draw_API void SetTitle(char*);
268 __Draw_API char* GetTitle();
269
270 //Affichage
271 __Draw_API void DisplayWindow();
272 __Draw_API void Hide();
273 __Draw_API void Destroy();
274 __Draw_API void Clear();
275 __Draw_API static void Flush() {} ;
276
277 // save snapshot
278 __Draw_API Standard_Boolean Save(const char* theFileName) const;
279
280 //Dessin
281 __Draw_API void DrawString(int,int,char*);
282 __Draw_API void DrawSegments(Segment*,int);
283
284 __Draw_API void InitBuffer();
285 // Initializes off-screen image buffer according to current window size
286
287 __Draw_API void Redraw();
288 // Copies an image from memory buffer to screen
289
290 //Couleur
291 __Draw_API void SetColor(Standard_Integer);
292 __Draw_API void SetMode(int);
293 __Draw_API static Standard_Boolean DefineColor ( const Standard_Integer,const char*);
294
295 //Gestion des Messages
296 __Draw_API virtual void WExpose ();
297 __Draw_API virtual void WButtonPress(const Standard_Integer,const Standard_Integer,
298 const Standard_Integer&);
299 __Draw_API virtual void WButtonRelease(const Standard_Integer,const Standard_Integer,
300 const Standard_Integer&);
301 __Draw_API virtual void WMotionNotify(const Standard_Integer,const Standard_Integer);
302 __Draw_API virtual void WConfigureNotify(const Standard_Integer,const Standard_Integer,
303 const Standard_Integer,const Standard_Integer);
304 __Draw_API virtual void WUnmapNotify();
305
306 //Gestion souris
307 __Draw_API static void SelectWait (HANDLE&,int&,int&,int&);
308 __Draw_API static void SelectNoWait (HANDLE&,int&,int&,int&);
309
310 // Procedure de fenetre
311 __Draw_API static LONG APIENTRY DrawProc (HWND,UINT,WPARAM,LONG);
312
313private:
314
315 __Draw_API static HWND CreateDrawWindow(HWND,int);
316 __Draw_API HDC GetMemDC(HDC);
317 __Draw_API void ReleaseMemDC(HDC);
318
319 //atributs
320public:
321 HWND win;
322 static HWND hWndClientMDI;
323
324private:
325 static DrawWindow* firstWindow;
326 DrawWindow* next;
327 DrawWindow* previous;
328 HBITMAP myMemHbm;
329 HBITMAP myOldHbm;
330 Standard_Boolean myUseBuffer;
331 Standard_Integer myCurrPen;
332 Standard_Integer myCurrMode;
333};
334
335typedef DrawWindow Draw_Window;
336typedef enum {
337 STOP_CONSOLE,
338 WAIT_CONSOLE_COMMAND,
339 HAS_CONSOLE_COMMAND} console_semaphore_value;
340
341// PROCEDURE DE DRAW WINDOW
342
343__Draw_API Standard_Boolean Init_Appli(HINSTANCE,HINSTANCE,int,HWND&);
344__Draw_API void Run_Appli(HWND);
345__Draw_API void Destroy_Appli(HINSTANCE);
346
347#endif
348
349#endif