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
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.
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.
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.
22 #ifndef Draw_Window_HeaderFile
23 #define Draw_Window_HeaderFile
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Integer.hxx>
30 const Standard_Integer MAXCOLOR = 15;
32 typedef unsigned long Window;
33 typedef unsigned long Pixmap;
34 typedef unsigned long Drawable;
36 // Definition de la class Base_Window (Definie dans Draw_Window.cxx)
37 //===================================
40 // Definition de la classe Segment
41 //================================
49 void Init(short x1, short y1, short x2, short y2) {
50 xx1 = x1; yy1 = y1; xx2 = x2; yy2 = y2;
55 // Definition de la structure Event
56 //=================================
59 Standard_Integer type;
61 Standard_Integer button;
66 // Definition de la classe Draw_Window
67 //====================================
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);
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);
84 void Init (Standard_Integer X = 0, Standard_Integer Y = 0,
85 Standard_Integer DX = 50, Standard_Integer DY = 50);
87 void Init (Window mother,
88 Standard_Integer X = 0, Standard_Integer Y = 0,
89 Standard_Integer DX = 50, Standard_Integer DY = 50);
92 void StopWinManager();
94 void SetPosition (Standard_Integer NewXpos,
95 Standard_Integer NewYpos);
97 void SetDimension(Standard_Integer NewDx,
98 Standard_Integer NewDy);
100 void GetPosition(Standard_Integer &PosX,
101 Standard_Integer &PosY);
103 Standard_Integer HeightWin() const;
104 Standard_Integer WidthWin() const;
106 void SetTitle(const char* title);
109 void DisplayWindow();
113 void Wait(Standard_Boolean wait = Standard_True);
115 Drawable GetDrawable() const;
116 // Initializes off-screen image buffer according to current window size
119 static Standard_Boolean DefineColor(const Standard_Integer, const char*);
122 void DrawString(int, int, char*);
123 void DrawSegments(Segment* ,int);
128 Standard_Boolean Save(const char* theFileName) const;
130 virtual ~Draw_Window ();
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);
144 virtual void WConfigureNotify(const Standard_Integer X,
145 const Standard_Integer Y,
146 const Standard_Integer dx,
147 const Standard_Integer dy);
149 virtual void WUnmapNotify();
153 Window myMother; // default : myMother is the root window
156 static Draw_Window* firstWindow;
158 Draw_Window* previous;
160 Standard_Boolean myUseBuffer;
161 Standard_Boolean withWindowManager;
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 //======================================================
172 void Run_Appli(Standard_Boolean (*inteprete) (const char*));
174 //======================================================
175 // funtion : Init_Appli
177 //======================================================
178 Standard_Boolean Init_Appli();
180 //======================================================
181 // funtion : Destroy_Appli()
183 //======================================================
184 void Destroy_Appli();
186 //======================================================
187 // funtion : GetNextEvent()
189 //======================================================
190 void GetNextEvent(Event&);
197 #define DRAWCLASS "DRAWWINDOW"
198 #define DRAWTITLE "Draw View"
201 #if !defined(__Draw_API) && !defined(HAVE_NO_DLL)
203 # define __Draw_API __declspec( dllexport )
205 # define __Draw_API __declspec( dllimport )
209 // definition de la classe Segment
214 friend class DrawWindow;
222 void Init(Standard_Integer,
234 //definition de la classe DRAWWINDOW
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);
246 __Draw_API ~DrawWindow();
250 __Draw_API void Init(Standard_Integer, Standard_Integer,
251 Standard_Integer, Standard_Integer);
253 __Draw_API void SetUseBuffer(Standard_Boolean);
254 // Turns on/off usage of off-screen image buffer (can be used for redrawing optimization)
256 __Draw_API Standard_Boolean GetUseBuffer() const { return myUseBuffer; }
257 // Returns Standard_True if off-screen image buffer is being used
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;
267 __Draw_API void SetTitle(char*);
268 __Draw_API char* GetTitle();
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() {} ;
278 __Draw_API Standard_Boolean Save(const char* theFileName) const;
281 __Draw_API void DrawString(int,int,char*);
282 __Draw_API void DrawSegments(Segment*,int);
284 __Draw_API void InitBuffer();
285 // Initializes off-screen image buffer according to current window size
287 __Draw_API void Redraw();
288 // Copies an image from memory buffer to screen
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*);
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();
307 __Draw_API static void SelectWait (HANDLE&,int&,int&,int&);
308 __Draw_API static void SelectNoWait (HANDLE&,int&,int&,int&);
310 // Procedure de fenetre
311 __Draw_API static LONG APIENTRY DrawProc (HWND,UINT,WPARAM,LONG);
315 __Draw_API static HWND CreateDrawWindow(HWND,int);
316 __Draw_API HDC GetMemDC(HDC);
317 __Draw_API void ReleaseMemDC(HDC);
322 static HWND hWndClientMDI;
325 static DrawWindow* firstWindow;
327 DrawWindow* previous;
330 Standard_Boolean myUseBuffer;
331 Standard_Integer myCurrPen;
332 Standard_Integer myCurrMode;
335 typedef DrawWindow Draw_Window;
338 WAIT_CONSOLE_COMMAND,
339 HAS_CONSOLE_COMMAND} console_semaphore_value;
341 // PROCEDURE DE DRAW WINDOW
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);