1 -- Created on: 1991-11-18
2 -- Created by: NW,JPB,CAL,GG
3 -- Copyright (c) 1991-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 : GG 28/01/00 G004
22 -- Add gamma correction computation just before dumping an image.
23 -- GG 07/03/00 G004 Add MMSize() method
24 -- TCL 26/10/00 G002 SetBackground(aName: CString) method
25 -- SAV 24/11/01 SetBackground(Quantity_Color)
26 -- GG - RIC120302 Add NEW XParentWindow methods.
32 ---Purpose: This class defines a X11 window
33 -- Warning: The position and size for the creation of the window
34 -- are defined in Device Screen Unit (DSU)
35 -- floating [0,1] space.
45 AsciiString from TCollection,
46 Background from Aspect,
47 GradientBackground from Aspect,
48 TypeOfResize from Aspect,
50 FillMethod from Aspect,
51 GradientFillMethod from Aspect,
53 NameOfColor from Quantity,
54 Parameter from Quantity,
62 GraphicDevice from Xw,
63 WindowQuality from Xw,
68 WindowDefinitionError from Aspect,
69 WindowError from Aspect
73 Create ( Device : GraphicDevice from Xw )
74 returns mutable Window from Xw
75 raises WindowDefinitionError from Aspect;
78 Create ( Device : GraphicDevice from Xw ;
79 aPart1, aPart2 : Integer from Standard ;
80 aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY ;
81 BackColor : NameOfColor from Quantity =
82 Quantity_NOC_MATRAGRAY )
83 returns mutable Window from Xw
85 ---Purpose: Creates a Window from an X Window defined by his ID
86 -- This Xid equals (aPart1 << 16) + aPart2.
87 -- A child of this Window is created when the WindowQuality
88 -- isn't the same than the parent Window
89 -- Trigger: Raises WindowDefinitionError if the connection failed
90 -- or if the Position out of the Screen Space
91 raises WindowDefinitionError from Aspect ;
93 Create ( Device : GraphicDevice from Xw ;
94 aWindow : Handle from Aspect;
95 aQuality : WindowQuality from Xw = Xw_WQ_SAMEQUALITY ;
96 BackColor : NameOfColor from Quantity =
97 Quantity_NOC_MATRAGRAY )
98 returns mutable Window from Xw
100 ---Purpose: Creates a Window from an X Window defined by his Xid
101 -- A child of this Window is created when the WindowQuality
102 -- isn't the same than the parent Window
103 -- Trigger: Raises WindowDefinitionError if the connection failed
104 -- or if the Position out of the Screen Space
105 raises WindowDefinitionError from Aspect ;
107 Create ( Device : GraphicDevice from Xw ;
108 Title : CString from Standard ;
109 Xc : Parameter from Quantity = 0.5 ;
110 Yc : Parameter from Quantity = 0.5 ;
111 Width : Parameter from Quantity = 0.5 ;
112 Height : Parameter from Quantity = 0.5 ;
113 Quality : WindowQuality from Xw = Xw_WQ_DRAWINGQUALITY ;
114 BackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY ;
115 Parent : Handle from Aspect = 0 )
116 returns mutable Window from Xw
118 ---Purpose: Creates a Window defined by his Center and his Size
119 -- in DSU from the Parent Window.
120 -- NOTE than if Parent is 0 the window is created from the
122 -- Connects it to the X server at the first call
123 -- depending of the GraphicDevice Visual and
124 -- Display parameters.
125 -- Quality defined a 2D or 3D Graphics oriented Window and
127 -- Xw_WQ_DRAWINGQUALITY for 2D Wireframe.
128 -- Xw_WQ_PICTUREQUALITY for Picture.
129 -- Xw_WQ_3DQUALITY for 3D Shading, HiddenLines, Wireframe.
131 -- Creation of an Xw_Window automatically determines the
132 -- smaller dimension of the screen (usually the height)
133 -- and parametrises it as 1.0.
134 -- The smaller dimension of the window is limited to 1.0
135 -- We can give a value greater than 1.0 to the larger
137 -- No matter how large the values passed in argument, the
138 -- window is automatically limited to the maximum size of
140 -- The ratio of width to height of a conventional screen is
141 -- of the order of 1.3.
143 -- Trigger: Raises WindowDefinitionError if the connection failed
144 -- or if the Position out of the Screen Space
145 raises WindowDefinitionError from Aspect ;
147 Create ( theDevice : GraphicDevice from Xw ;
148 theTitle : CString from Standard ;
149 thePxLeft : Integer from Standard ;
150 thePxTop : Integer from Standard ;
151 thePxWidth : Integer from Standard ;
152 thePxHeight : Integer from Standard ;
153 theQuality : WindowQuality from Xw = Xw_WQ_DRAWINGQUALITY ;
154 theBackColor : NameOfColor from Quantity = Quantity_NOC_MATRAGRAY ;
155 theParent : Handle from Aspect = 0 )
156 returns mutable Window from Xw
158 ---Purpose: Creates a Window defined by his position and size
159 -- in pixels from the Parent Window.
160 -- Trigger: Raises WindowDefinitionError if the connection failed
161 -- or if the Position out of the Screen Space
162 raises WindowDefinitionError from Aspect ;
164 ---------------------------------------------------
165 -- Category: Methods to modify the class definition
166 ---------------------------------------------------
168 SetBackground ( me : mutable ;
169 Background : Background from Aspect ) is virtual;
171 ---Purpose: Modifies the window background.
172 -- Warning: the background color is ignored when the quality
173 -- of this window is TRANSPARENT.
174 ---Category: Methods to modify the class definition
176 SetBackground ( me : mutable ;
177 BackColor : NameOfColor from Quantity ) is virtual;
179 ---Purpose: Modifies the window background from a Named Color.
180 -- Warning: the background color is ignored when the quality
181 -- of this window is TRANSPARENT.
182 ---Category: Methods to modify the class definition
184 SetBackground ( me : mutable; color : Color from Quantity ) is virtual;
186 ---Purpose: Modifies the window background from a Named Color.
187 -- Warning: the background color is ignored when the quality
188 -- of this window is TRANSPARENT.
189 ---Category: Methods to modify the class definition
191 SetBackground( me: mutable;
192 aPixmap: Handle from Aspect);
194 ---Purpose: Defines the window background directly from a bitmap.
195 -- Warning: the bitmap and window must have the same depth.
196 ---Category: Methods to modify the class definition
198 SetBackground( me: mutable;
199 aName: CString from Standard;
200 aMethod : FillMethod from Aspect = Aspect_FM_CENTERED)
201 returns Boolean from Standard;
203 ---Purpose: Loads the window background from an image file <aName>
204 -- defined with a supported format XWD,GIF or BMP
205 -- and returns TRUE if the operation is successfull.
206 ---Category: Methods to modify the class definition
208 SetBackground ( me : mutable ;
209 Background : GradientBackground from Aspect ) is virtual;
211 ---Purpose: Modifies the window gradient background.
212 -- Warning: the gradient background colours are ignored when the quality
213 -- of this window is TRANSPARENT.
214 ---Category: Methods to modify the class definition
216 SetBackground( me : mutable;
217 aCol1 : Color from Quantity;
218 aCol2 : Color from Quantity;
219 aMethod : GradientFillMethod from Aspect = Aspect_GFM_HOR);
221 ---Purpose: Modifies the window gradient background.
222 -- Warning: the gradient background colours are ignored when the quality
223 -- of this window is TRANSPARENT.
224 ---Category: Methods to modify the class definition
226 SetDoubleBuffer ( me : mutable ;
227 DBmode : Boolean from Standard )
229 ---Purpose: Activates/Deactivates the Double Buffering capability
231 -- Warning: Double Buffering is always DISABLE by default
232 -- If there is not enought ressources to activate the
233 -- double-buffering the DB mode flag can be set to FALSE.
234 ---Category: Methods to modify the class definition
239 ---Purpose: Flushs all graphics to the screen and Swap the Double
241 -- Category: Methods to modify the class definition
242 -- Trigger: Raises if Something is WRONG at Drawing Time.
243 raises WindowError from Aspect is virtual;
245 Map ( me ) is virtual;
247 ---Purpose: Opens the window <me>.
248 ---Category: Methods to modify the class definition
250 Unmap ( me ) is virtual;
252 ---Purpose: Closes the window <me>.
253 ---Category: Methods to modify the class definition
256 returns TypeOfResize from Aspect
258 ---Purpose: Applies the resizing to the window <me>.
259 ---Category: Methods to modify the class definition
260 raises WindowError from Aspect is virtual;
262 DoMapping ( me ) returns Boolean from Standard
263 raises WindowError from Aspect is virtual;
265 ---Purpose: Apply the mapping change to the window <me>
266 -- and returns TRUE if the window is mapped at screen.
267 ---Category: Methods to modify the class definition
269 Destroy ( me : mutable )
271 ---Purpose: Destroies the Window
273 -- Category: Methods to modify the class definition
274 -- Trigger: Raises if Window is not defined properly
275 raises WindowError from Aspect is virtual;
277 Clear ( me ) is virtual;
279 ---Purpose: Clears the Window in the Background color
280 ---Category: Methods to modify the class definition
283 Xc, Yc : Integer from Standard ;
284 Width, Height : Integer from Standard )
286 ---Purpose: Clears the Window Area defined by his center and PIXEL size
287 -- in the Background color
288 -- Category: Methods to modify the class definition
289 -- Trigger: Raises if Window is not defined properly
290 raises WindowError from Aspect is virtual;
294 ---Purpose: Restores The Window from the BackingStored Window
295 -- See BackingStore () method.
296 ---Category: Methods to modify the class definition
297 raises WindowError from Aspect is virtual;
300 Xc, Yc : Integer from Standard ;
301 Width, Height : Integer from Standard )
303 ---Purpose: Restores The Window Area defined by his center
304 -- and PIXEL size from the BackingStored Window
305 -- See BackingStore () method.
306 ---Category: Methods to modify the class definition
307 raises WindowError from Aspect is virtual;
309 Dump ( me ; aFilename : CString from Standard;
310 aGammaValue: Real from Standard = 1.0 ) returns Boolean
312 ---Purpose: Dumps the Window to an XWD,GIF or BMP file with
313 -- an optional gamma correction value according to the graphic system.
314 -- and returns TRUE if the dump occurs normaly.
315 -- Category: Methods to modify the class definition
316 -- Trigger: Raises if Window is not defined properly
317 raises WindowError from Aspect is virtual;
319 DumpArea ( me ; aFilename : CString from Standard ;
320 Xc, Yc : Integer from Standard ;
321 Width, Height : Integer from Standard ;
322 aGammaValue: Real from Standard = 1.0 ) returns Boolean
324 ---Purpose: Dumps the Window Area defined by his center and PIXEL size
325 -- to an XWD,GIF or BMP file with
326 -- an optional gamma correction value according to the graphic system.
327 -- and returns TRUE if the dump occurs normaly.
328 -- Category: Methods to modify the class definition
329 -- Trigger: Raises if Window is not defined properly
330 -- or the area is out of the Window.
331 raises WindowError from Aspect is virtual;
333 ToPixMap ( me ; theImage : in out PixMap from Image )
336 ---Purpose : dump the full contents of the window to a pixmap.
339 Load ( me ; aFilename : CString from Standard) returns Boolean
341 ---Purpose: Loads the XWD file to this Window.
342 -- Returns TRUE if the loading occurs normaly.
343 -- Warning: Note that the Window is enlarged automatically
344 -- when the image size is too large for this window.
345 -- Category: Methods to modify the class definition
346 -- Trigger: Raises if Window is not defined properly
347 raises WindowError from Aspect is virtual;
349 LoadArea ( me ; aFilename : CString from Standard ;
350 Xc, Yc : Integer from Standard ;
351 Width, Height : Integer from Standard ) returns Boolean
353 ---Purpose: Loads the XWD file to Window Area defined by his center
355 -- Returns TRUE if the loading occurs normaly.
356 -- Warning: Note that the Image is zoomed automatically
357 -- when the image size is too large for this window area.
358 -- Category: Methods to modify the class definition
359 -- Trigger: Raises if Window is not defined properly
360 -- or the area is out of the Window.
361 raises WindowError from Aspect is virtual;
363 SetCursor ( me ; anId : Integer from Standard ;
364 aColor : NameOfColor from Quantity
365 = Quantity_NOC_YELLOW ) is virtual ;
367 ---Purpose: Changes the current window cursor by anId cursor
368 -- in the specified color.
369 -- NOTE than anId must be one of /usr/include/X11/cursorfont.h
370 -- or 0 for Deactivate the cursor
371 ---Category: Methods to modify the class definition
373 ----------------------------
374 -- Category: Inquire methods
375 ----------------------------
378 returns Boolean from Standard is virtual;
380 ---Purpose: Returns the BackingStore capability for this Window.
381 -- If Answer is True Exposure can be recovered by
382 -- Restore RestoreArea methods.
383 -- If Answer is False, Application must Redraw the
385 ---Category: Inquire methods
388 returns Boolean from Standard is virtual;
390 ---Purpose: Returns the DoubleBuffer state.
391 ---Category: Inquire methods
394 returns Boolean from Standard is virtual;
396 ---Purpose: Returns True if the window <me> is opened
397 -- and False if the window is closed.
398 ---Category: Inquire methods
401 returns Ratio from Quantity is virtual;
403 ---Purpose: Returns The Window RATIO equal to the physical
404 -- WIDTH/HEIGHT dimensions
405 ---Category: Inquire methods
408 X1, Y1, X2, Y2 : out Parameter from Quantity ) is virtual;
410 ---Purpose: Returns The Window POSITION in DSU
411 ---Category: Inquire methods
414 X1, Y1, X2, Y2 : out Integer from Standard ) is virtual;
416 ---Purpose: Returns The Window POSITION in PIXEL
417 ---Category: Inquire methods
420 Width, Height : out Parameter from Quantity ) is virtual;
422 ---Purpose: Returns The Window SIZE in DSU
423 ---Category: Inquire methods
426 Width, Height : out Integer from Standard ) is virtual;
428 ---Purpose: Returns The Window SIZE in PIXEL
429 ---Category: Inquire methods
432 Width, Height : out Real from Standard ) is virtual;
434 ---Purpose: Returns The Window SIZE in MM
435 ---Category: Inquire methods
437 Convert ( me ; PV : Integer from Standard )
438 returns Parameter from Quantity is virtual;
440 ---Purpose: Returns the DSU value depending of the PIXEL value.
441 ---Category: Inquire methods
443 Convert ( me ; DV : Parameter from Quantity )
444 returns Integer from Standard is virtual;
446 ---Purpose: Returns the PIXEL value depending of the DSU value.
447 ---Category: Inquire methods
450 PX, PY : Integer from Standard ;
451 DX, DY : out Parameter from Quantity ) is virtual;
453 ---Purpose: Returns the DSU position depending of the PIXEL position.
454 ---Category: Inquire methods
457 DX, DY : Parameter from Quantity ;
458 PX, PY : out Integer from Standard ) is virtual;
460 ---Purpose: Returns the PIXEL position depending of the DSU position.
461 ---Category: Inquire methods
464 returns Handle from Aspect is static;
466 ---Purpose: Returns the X window ID of the created window <me>.
467 ---Category: Inquire methods
469 XWindow ( me ; aPart1, aPart2 : out Integer from Standard ) is static;
471 ---Purpose: Returns the X window ID of the created window <me>.
472 -- This Xid equals (aPart1 << 16) + aPart2.
475 returns Handle from Aspect is static;
477 ---Purpose: Returns the X window ID parent of the created window <me>.
478 ---Category: Inquire methods
480 XParentWindow ( me ; aPart1, aPart2 : out Integer from Standard ) is static;
482 ---Purpose: Returns the X window ID parent of the created window <me>.
483 -- This Xid equals (aPart1 << 16) + aPart2.
486 returns Handle from Aspect is static;
488 ---Purpose: Returns the X pixmap ID of the created window <me>.
489 -- If BackingStore () is permitted.
490 ---Category: Inquire methods
492 PointerPosition ( me ; X, Y : out Integer from Standard )
493 returns Boolean from Standard is virtual;
495 ---Purpose: Returns the Pointer position relatively to the Window <me>
496 -- and FALSE if the pointer is outside of the window
497 ---Category: Inquire methods
500 returns ColorMap from Xw is static;
502 ---Purpose: Returns the Colormap attached to this Window
505 returns TypeMap from Xw is static;
507 ---Purpose: Returns the Typemap attached to this Window
510 returns WidthMap from Xw is static;
512 ---Purpose: Returns the Widthmap attached to this Window
515 returns FontMap from Xw is static;
517 ---Purpose: Returns the Fontmap attached to this Window
520 returns MarkMap from Xw is static;
522 ---Purpose: Returns the Markmap attached to this Window
525 returns Handle from Aspect
527 ---Purpose: Returns the Colormap XId attached to this Window
528 -- depending of the HardWare and Visual class
529 -- Trigger: Raises if Window is not defined properly
530 raises WindowError from Aspect is static;
533 returns Address from Standard
535 ---Purpose: Returns the Visual address attached to this Window
536 -- depending of the HardWare
537 -- Trigger: Raises if Window is not defined properly
538 raises WindowError from Aspect is static;
541 returns TypeOfVisual from Xw is static;
543 ---Purpose: Returns the X window Visual class of the created window <me>
544 ---Category: Inquire methods
547 returns Integer from Standard is static;
549 ---Purpose: Returns the X window Visual depth of the created window <me>
550 ---Category: Inquire methods
553 returns Integer from Standard is static;
555 ---Purpose: Returns the Visual ID of the Window
556 ---Category: Inquire methods
559 returns WindowQuality from Xw is static;
561 ---Purpose: Returns the Quality of this window
562 ---Category: Inquire methods
564 PixelOfColor ( me ;aColor : NameOfColor from Quantity;
565 aPixel : out Integer from Standard )
566 returns Boolean from Standard is static;
568 ---Purpose: Returns FALSE when the returned pixel value <aPixel>
569 -- of an RGB color <aColor> is exact or TRUE
570 -- when the pixel value is approximated.
572 PixelOfColor ( me ;aColor : Color from Quantity;
573 aPixel : out Integer from Standard )
574 returns Boolean from Standard is static;
576 ---Purpose: Returns FALSE when the returned pixel value <aPixel>
577 -- of an RGB color <aColor> is exact or TRUE
578 -- when the pixel value is approximated.
580 -- make becarefull about the number of different pixel
581 -- of colors reserved in the colormap in PseudoColor mode !!!
583 BackgroundPixel ( me ; aPixel : out Integer from Standard )
584 returns Boolean from Standard is static;
586 ---Purpose: Returns FALSE when the returned background pixel
587 -- value <aPixel> is not defined
589 ExtendedWindow ( me )
590 returns Address from Standard
591 is static protected ;
593 ---Purpose: Returns the ExtendedWindow address of the created window.
594 ---Category: Inquire methods
596 ExtendedColorMap ( me )
597 returns Address from Standard
598 is static protected ;
600 ---Purpose: Returns the ExtendedColorMap address of the created window.
601 ---Category: Inquire methods
603 ExtendedTypeMap ( me )
604 returns Address from Standard
605 is static protected ;
607 ---Purpose: Returns the ExtendedTypeMap address of the created window.
608 ---Category: Inquire methods
610 ExtendedWidthMap ( me )
611 returns Address from Standard
612 is static protected ;
614 ---Purpose: Returns the ExtendedWidthMap address of the created window.
615 ---Category: Inquire methods
617 ExtendedFontMap ( me )
618 returns Address from Standard
619 is static protected ;
621 ---Purpose: Returns the ExtendedFontMap address of the created window.
622 ---Category: Inquire methods
624 ExtendedMarkMap ( me )
625 returns Address from Standard
626 is static protected ;
628 ---Purpose: Returns the ExtendedMarkMap address of the created window.
629 ---Category: Inquire methods
631 SetWindow ( me: mutable ; aWindow : Handle from Aspect ;
632 aQuality: WindowQuality from Xw ;
633 BackColor : NameOfColor from Quantity )
635 ---Trigger: Raises if Window is not defined properly
636 raises WindowError from Aspect
639 SetWindow ( me: mutable ; Title : CString from Standard ;
640 Xc, Yc, Width, Height: Parameter from Quantity ;
641 Quality : WindowQuality from Xw ;
642 BackColor : NameOfColor from Quantity ;
643 Parent : Handle from Aspect )
645 ---Trigger: Raises if Window is not defined properly
646 raises WindowError from Aspect
649 PrintError(myclass) is protected;
650 ---Purpose: Print last error or raise depending of the error gravity.
652 Init( me: mutable ) is private;
653 ---Purpose: Initialise the fileds of class
657 MyQuality : WindowQuality from Xw is protected ;
658 MyColorMap : ColorMap from Xw is protected ;
659 MyTypeMap : TypeMap from Xw is protected ;
660 MyWidthMap : WidthMap from Xw is protected ;
661 MyFontMap : FontMap from Xw is protected ;
662 MyMarkMap : MarkMap from Xw is protected ;
663 MyXWindow : Handle from Aspect is protected ;
664 MyXParentWindow : Handle from Aspect is protected ;
665 MyXPixmap : Handle from Aspect is protected ;
666 MyVisualClass : TypeOfVisual from Xw is protected ;
667 MyDepth : Integer from Standard is protected ;
668 MyBackgroundIndex : Integer from Standard is protected ;
669 MyExtendedDisplay : Address from Standard is protected ;
670 MyExtendedWindow : Address from Standard is protected ;
671 MyExtendedColorMap : Address from Standard is protected ;
672 MyExtendedTypeMap : Address from Standard is protected ;
673 MyExtendedWidthMap : Address from Standard is protected ;
674 MyExtendedFontMap : Address from Standard is protected ;
675 MyExtendedMarkMap : Address from Standard is protected ;
679 class Driver from Xw,
680 class IconBox from Xw,