1 -- Created on: 1996-01-26
2 -- Created by: PLOTNIKOV Eugeny
3 -- Copyright (c) 1996-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.
21 -- Modified: FMN - 23/01/98 -> Add DoMapping
22 -- Modified : GG 28/01/00 G004
23 -- Add gamma correction computation just before dumping an image.
24 -- GG 07/03/00 G004 Add MMSize() method
25 -- TCL 26/10/00 G002 SetBackground(aName: CString) method
26 -- GG - RIC120302 Add NEW HParentWindow methods.
27 -- SAV 24/11/01 SetBackground(Quantity_Color)
29 class Window from WNT inherits Window from Aspect
31 ---Purpose: This class defines Windows NT window
32 -- Warning: The position and size for the creation of the window
33 -- are defined in Device Screen Unit (DSU)
34 -- floating [0,1] space.
36 -- As 3D view window is the main purpose of this class,
37 -- and 3D view does not need its background to be drawn
38 -- by the system, by default the window background is not drawn.
39 -- This can be overridden by calling ClearFlags( WDF_NOERASEBKGRND ).
40 -- See also WNT_WndProc.cxx and InterfaceGraphic_WNT.hxx.
45 Background from Aspect,
46 GradientBackground from Aspect,
47 TypeOfResize from Aspect,
48 FillMethod from Aspect,
49 GradientFillMethod from Aspect,
51 NameOfColor from Quantity,
53 Parameter from Quantity,
55 GraphicDevice from WNT,
62 ImageManager from WNT,
67 WindowDefinitionError from Aspect,
68 WindowError from Aspect
73 aDevice : GraphicDevice from WNT;
74 aTitle : CString from Standard;
75 aClass : WClass from WNT;
76 aStyle : Dword from WNT = 0;
77 Xc : Parameter from Quantity = 0.5;
78 Yc : Parameter from Quantity = 0.5;
79 aWidth : Parameter from Quantity = 0.5;
80 aHeight : Parameter from Quantity = 0.5;
81 aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY;
82 aParent : Handle from Aspect = 0;
83 aMenu : Handle from Aspect = 0;
84 aClientStruct : Address from Standard = 0
86 returns mutable Window from WNT
88 ---Purpose: Creates a Window defined by his Center and his Size
89 -- in DSU from the Parent Window. If <aParent> is 0 then
90 -- creates a window without parent.
91 -- Creation of an WNT_Window automatically determines the
92 -- smaller dimension of the screen (usually the height)
93 -- and parametrises it as 1.0.
94 -- The smaller dimension of the window is limited to 1.0
95 -- We can give a value greater than 1.0 to the larger
97 -- No matter how large the values passed in argument, the
98 -- window is automatically limited to the maximum size of
100 -- The ratio of width to height of a conventional screen is
101 -- of the order of 1.3.
102 -- Trigger: Raises WindowDefinitionError if the Position out of the
103 -- Screen Space or the window creation failed.
104 raises WindowDefinitionError from Aspect;
106 Create (theDevice : GraphicDevice from WNT;
107 theTitle : CString from Standard;
108 theClass : WClass from WNT;
109 theStyle : Dword from WNT;
110 thePxLeft : Integer from Standard;
111 thePxTop : Integer from Standard;
112 thePxWidth : Integer from Standard;
113 thePxHeight : Integer from Standard;
114 theBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY;
115 theParent : Handle from Aspect = 0;
116 theMenu : Handle from Aspect = 0;
117 theClientStruct : Address from Standard = 0)
118 returns mutable Window from WNT
120 ---Purpose: Creates a Window defined by his position and size
121 -- in pixles from the Parent Window.
122 -- Trigger: Raises WindowDefinitionError if the Position out of the
123 -- Screen Space or the window creation failed.
124 raises WindowDefinitionError from Aspect;
127 aDevice : GraphicDevice from WNT;
128 aHandle : Handle from Aspect;
129 aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY
131 returns mutable Window from WNT;
133 ---Purpose: Creates a Window based on the existing window handle.
134 -- This handle equals ( aPart1 << 16 ) + aPart2.
137 aDevice : GraphicDevice from WNT;
138 aPart1 : Integer from Standard;
139 aPart2 : Integer from Standard;
140 aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY
142 returns mutable Window from WNT;
144 ---Purpose: Creates a Window based on the existing window <aHandle>.
146 Destroy ( me : mutable )
149 ---Purpose: Destroies the Window and all resourses attached to it.
153 ---------------------------------------------------
154 -- Category: Methods to modify the class definition
155 ---------------------------------------------------
160 Background : Background from Aspect
164 ---Purpose: Modifies the window background.
168 BackColor : NameOfColor from Quantity
172 ---Purpose: Modifies the window background.
176 color : Color from Quantity
180 ---Purpose: Modifies the window background.
185 aBackPixmap : Handle from Aspect
188 ---Purpose: Modifies the window background.
192 aName : CString from Standard ;
193 aMethod: FillMethod from Aspect = Aspect_FM_CENTERED
194 ) returns Boolean from Standard;
196 ---Purpose: Loads the window background from an image file <aName>
197 -- defined with a supported format XWD,GIF or BMP
198 -- and returns TRUE if the operation is successfull.
199 -- Category: Methods to modify the class definition
201 SetBackground ( me : mutable ;
202 Background : GradientBackground from Aspect ) is virtual;
204 ---Purpose: Modifies the window gradient background.
205 -- Warning: the gradient background colours is ignored when the quality
206 -- of this window is TRANSPARENT.
207 ---Category: Methods to modify the class definition
209 SetBackground( me : mutable;
210 aCol1 : Color from Quantity;
211 aCol2 : Color from Quantity;
212 aMethod : GradientFillMethod from Aspect = Aspect_GFM_HOR);
214 ---Purpose: Modifies the window gradient background.
215 -- Warning: the gradient background colours are ignored when the quality
216 -- of this window is TRANSPARENT.
217 ---Category: Methods to modify the class definition
219 SetCursor ( me; aCursor : Handle from Aspect )
222 ---Purpose: Sets cursor <aCursor> for ENTIRE WINDOW CLASS to which
223 -- the Window belongs.
227 anIcon : Handle from Aspect;
228 aName : CString from Standard = 0
232 ---Purpose: Sets icon <anIcon> for window
234 SetIconName ( me : mutable; aName : CString from Standard )
237 ---Purpose: Sets name for window's icon
241 DBmode : Boolean from Standard
244 ---Purpose: Activates/Deactivates the Double Buffering capability
246 -- Warning: Double Buffering is always DISABLE by default.
247 -- Trigger: Raises if BackingStore () isn't allowed for this Window
248 raises WindowError from Aspect is virtual;
252 ---Purpose: Flushes all graphics to the screen and Swap the Double
254 -- Trigger: Raises if Something is WRONG at Drawing Time.
255 raises WindowError from Aspect is virtual;
260 ---Purpose: Opens the window <me>.
262 Map ( me; aMapMode : Integer from Standard )
265 ---Purpose: Opens a window <me> according to <aMapMode>.
266 -- This method is specific to Windows NT.
267 -- <aMapMode> can be one of SW_xxx constants defined
268 -- in <windows.h>. See documentation.
273 ---Purpose: Closes the window <me>.
276 returns TypeOfResize from Aspect
278 ---Purpose: Applies the resizing to the window <me>.
279 raises WindowError from Aspect is virtual;
281 DoMapping ( me ) returns Boolean from Standard
282 raises WindowError from Aspect is virtual;
284 ---Purpose: Apply the mapping change to the window <me>
285 -- and returns TRUE if the window is mapped at screen.
286 ---Category: Methods to modify the class definition
292 ---Purpose: Clears the Window in the Background color.
296 Xc : Integer from Standard;
297 Yc : Integer from Standard;
298 Width : Integer from Standard;
299 Height : Integer from Standard
302 ---Purpose: Clears the Window Area defined by his center and PIXEL
303 -- size in the Background color
304 -- Trigger: Raises if Window is not defined properly
305 raises WindowError from Aspect is virtual;
309 ---Purpose: Restores The Window from the BackingStored Window
310 -- See BackingStore () method.
311 raises WindowError from Aspect is virtual;
315 Xc : Integer from Standard;
316 Yc : Integer from Standard;
317 Width : Integer from Standard;
318 Height : Integer from Standard
321 ---Purpose: Restores The Window Area defined by his center
322 -- and PIXEL size from the BackingStored Window
323 -- See BackingStore () method.
324 raises WindowError from Aspect is virtual;
328 aFilename : CString from Standard;
329 aGammaValue: Real from Standard = 1.0
333 ---Purpose: Dumps the Window to an XWD,GIF or BMP filei with
334 -- an optional gamma correction value according to the graphic system.
335 -- and returns TRUE if the dump occurs normaly.
336 -- Trigger: Raises if Window is not defined properly
337 raises WindowError from Aspect is virtual;
341 aFilename : CString from Standard;
342 Xc : Integer from Standard;
343 Yc : Integer from Standard;
344 Width : Integer from Standard;
345 Height : Integer from Standard;
346 aGammaValue: Real from Standard = 1.0
348 returns Boolean from Standard
350 ---Purpose: Dumps the Window Area defined by his center and PIXEL size
351 -- to an image file with an optional gamma correction value
352 -- and returns TRUE if the dump occurs normaly.
353 -- Trigger: Raises if Window is not defined properly
354 -- or the area is out of the Window.
355 raises WindowError from Aspect is virtual;
357 ToPixMap ( me ; theImage : in out PixMap from Image )
360 ---Purpose : dump the full contents of the window to a pixmap.
363 Load ( me; aFilename : CString from Standard )
364 returns Boolean from Standard
366 ---Purpose: Loads the XWD file to this Window.
367 -- Returns TRUE if the loading occurs normaly.
368 -- Warning: Note that the Window is enlarged automatically
369 -- when the image size is too large for this window.
370 -- Trigger: Raises if Window is not defined properly
371 raises WindowError from Aspect is virtual;
375 aFilename : CString from Standard;
376 Xc : Integer from Standard;
377 Yc : Integer from Standard;
378 Width : Integer from Standard;
379 Height : Integer from Standard
381 returns Boolean from Standard
382 ---Purpose: Loads the XWD file to Window Area defined by his center
384 -- Returns TRUE if the loading occurs normaly.
385 -- Warning: Note that the Image is zoomed automatically
386 -- when the image size is too large for this window area.
387 -- Trigger: Raises if Window is not defined properly
388 -- or the area is out of the Window.
389 raises WindowError from Aspect is virtual;
391 SetOutputFormat ( me : mutable; aFormat : TypeOfImage from WNT )
394 ---Purpose: Sets format of the image file created by Dump or
397 SetPos ( me : mutable; X, Y, X1, Y1 : Integer from Standard )
400 ---Purpose: Changes variables due to window position.
402 SetFlags ( me : mutable; aFlags : Integer from Standard )
405 ---Purpose: Sets user defined flags in the extra window data area.
406 -- Supported flags WDF_* are listed in InterfaceGraphic_WNT.hxx
407 -- In particular, the window backround can be turned off using this method.
409 ResetFlags ( me : mutable; aFlags : Integer from Standard )
412 ---Purpose: Reset specified flags in the extra window data area.
413 -- Supported flags WDF_* are listed in InterfaceGraphic_WNT.hxx
414 -- In particular, the window backround can be turned on using this method.
417 ----------------------------
418 -- Category: Inquire methods
419 ----------------------------
423 returns Boolean from Standard is virtual;
425 ---Purpose: Returns the BackingStore capability for this Window.
426 -- If Answer is True Exposure can be recovered by
427 -- Restore RestoreArea methods.
428 -- If Answer is False, Application must Redraw the
432 returns Boolean from Standard is virtual;
434 ---Purpose: Returns the DoubleBuffer state.
438 returns Boolean from Standard is virtual;
440 ---Purpose: Returns True if the window <me> is opened
441 -- and False if the window is closed.
444 returns Ratio from Quantity is virtual;
446 ---Purpose: Returns The Window RATIO equal to the physical
447 -- WIDTH/HEIGHT dimensions.
451 X1 : out Parameter from Quantity;
452 Y1 : out Parameter from Quantity;
453 X2 : out Parameter from Quantity;
454 Y2 : out Parameter from Quantity
458 ---Purpose: Returns The Window POSITION in DSU
462 X1 : out Integer from Standard;
463 Y1 : out Integer from Standard;
464 X2 : out Integer from Standard;
465 Y2 : out Integer from Standard
469 ---Purpose: Returns The Window POSITION in PIXEL
473 Width : out Parameter from Quantity;
474 Height : out Parameter from Quantity
478 ---Purpose: Returns The Window SIZE in DSU
482 Width : out Integer from Standard;
483 Height : out Integer from Standard
487 ---Purpose: Returns The Window SIZE in PIXEL
491 Width : out Real from Standard;
492 Height : out Real from Standard
496 ---Purpose: Returns The Window SIZE in MM
500 PV : Integer from Standard
502 returns Parameter from Quantity is virtual;
504 ---Purpose: Returns the DSU value depending of the PIXEL value.
508 DV : Parameter from Quantity
510 returns Integer from Standard is virtual;
512 ---Purpose: Returns the PIXEL value depending of the DSU value.
516 PX, PY : Integer from Standard;
517 DX, DY : out Parameter from Quantity
521 ---Purpose: Returns the DSU position depending of the PIXEL position.
525 DX, DY : Parameter from Quantity;
526 PX, PY : out Integer from Standard
530 ---Purpose: Returns the PIXEL position depending of the DSU position.
533 returns Handle from Aspect is static;
535 ---Purpose: Returns the Windows NT handle of the created window <me>.
539 returns Handle from Aspect is static;
541 ---Purpose: Returns the Windows NT handle parent of the created window <me>.
545 returns Handle from Aspect is static;
547 ---Purpose: Returns the Windows NT double buffer pixmap handle
548 -- of the created window <me>.
549 -- If BackingStore () is permitted.
553 returns Address from Standard;
555 ---Purpose: Returns address of the window procedure.
559 returns ImageManager from WNT is static;
561 ---Purpose: Returns ImageManager of the Window.
566 aDevice : GraphicDevice from WNT;
567 aHandle : Handle from Aspect;
568 aBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY
571 ---Purpose: private method
575 aXLeft : Integer from Standard is protected; -- Window coordinates
576 aYTop : Integer from Standard is protected;
577 aXRight : Integer from Standard is protected;
578 aYBottom : Integer from Standard is protected;
579 myWClass : WClass from WNT is protected; -- Window class
580 myHWindow : Handle from Aspect is protected; -- Window handle
581 myHParentWindow : Handle from Aspect is protected; -- Parent window handle
582 myHPixmap : Handle from Aspect is protected; -- Bitmap handle
583 myDoubleBuffer : Boolean from Standard is protected; -- DoubleBuffer flag
584 myExtraData : WindowData from WNT is protected; -- additional data
585 myFormat : TypeOfImage from WNT is protected; -- type of output image
586 myImages : ImageManager from WNT is protected;
587 myIcon : Icon from WNT is protected;
588 myWndProc : Address from Standard is protected; -- address of window procedure
589 myUsrData : Address from Standard is protected;
593 class WDriver from WNT,
594 class IconBox from WNT