-- Modifications: DCB at March 1998 Porting MFT for Windows NT (95)
-- PLOTNIKOV Eugeny at July 1998 (BUC60286)
--- VKH at October 1999 (class PixMap added)
package WNT
---Purpose: Creates the Window drawable.
---Category: Classes
- class PixMap;
- ---Purpose: Creates a windows bitmap
- ---Category: Classes
-
class WClass;
---Purpose: Creates a Windows NT window class.
---Category: Classes
+++ /dev/null
--- Created on: 1999-10-27
--- Created by: VKH
--- Copyright (c) 1999 Matra Datavision
--- Copyright (c) 1999-2012 OPEN CASCADE SAS
---
--- The content of this file is subject to the Open CASCADE Technology Public
--- License Version 6.5 (the "License"). You may not use the content of this file
--- except in compliance with the License. Please obtain a copy of the License
--- at http://www.opencascade.org and read it completely before using this file.
---
--- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
--- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
---
--- The Original Code and all software distributed under the License is
--- distributed on an "AS IS" basis, without warranty of any kind, and the
--- Initial Developer hereby disclaims all such warranties, including without
--- limitation, any warranties of merchantability, fitness for a particular
--- purpose or non-infringement. Please see the License for the specific terms
--- and conditions governing the rights and limitations under the License.
-
--- Updated: SZV IMP100701 Add the "depth" field and method
--- to the pixmap object.
-
-class PixMap from WNT
-
- ---Version:
-
- ---Purpose: This class defines a windows bitmap
-
- ---Keywords: Bitmap, Pixmap
-
-inherits
- Transient from Standard
-
-uses
- Handle from Aspect,
- Color from Quantity,
- Window from Aspect
-
-raises
- PixmapDefinitionError from Aspect,
- PixmapError from Aspect
-
-is
-
- Create ( aWindow : Window from Aspect;
- aWidth, anHeight : Integer from Standard;
- aCDepth : Integer from Standard = 0 )
- returns mutable PixMap from WNT
- raises PixmapDefinitionError from Aspect;
- ---Level: Public
- ---Purpose: Warning! When <aDepth> is NULL , the pixmap is created
- -- with the SAME depth than the window <aWindow>
-
- ---------------------------------------------------
- -- Category: Methods to modify the class definition
- ---------------------------------------------------
-
- Destroy ( me : mutable )
- ---Level: Advanced
- ---Purpose: Destroies the Bitmap
- ---C++: alias ~
- -- Trigger: Raises if Bitmap is not defined properly
- raises PixmapError from Aspect is virtual;
-
- Dump ( me; aFilename : CString from Standard ;
- aGammaValue: Real from Standard = 1.0 )
- returns Boolean
- ---Level: Advanced
- ---Purpose:
- -- Dumps the Bitmap to an image file with
- -- an optional gamma correction value
- -- and returns TRUE if the dump occurs normaly.
- ---Category: Methods to modify the class definition
- raises PixmapError from Aspect is virtual;
-
- PixelColor ( me : in;
- theX, theY : in Integer from Standard )
- returns Color from Quantity
- is virtual;
- ---Purpose:
- -- Returns the pixel color.
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
- PixmapID ( me ) returns Handle from Aspect is virtual;
- ---Level: Advanced
- ---Purpose: Returns the ID of the just created bitmap
- ---Category: Inquire methods
-
- ----------------------------
- -- Category: Private methods
- ----------------------------
-
- PreferedDepth( me ; aWindow: Window from Aspect;
- aDepth: Integer from Standard)
- returns Integer from Standard is private;
-
-fields
- myDC : Handle from Aspect is protected;
- myBitmap : Handle from Aspect is protected;
- myWND : Window from Aspect;
- myWidth : Integer from Standard is protected;
- myHeight : Integer from Standard is protected;
- myDepth : Integer from Standard is protected;
-end PixMap;
+++ /dev/null
-// Created on: 1999-12-20
-// Created by: VKH
-// Copyright (c) 1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-// SZV/GG IMP100701 Add the "depth" field and method
-// to the pixmap object.
-
-
-//-Version
-
-// include windows.h first to have all definitions available
-#include <windows.h>
-
-#include <WNT_PixMap.ixx>
-
-#include <WNT_Window.hxx>
-
-extern int DumpBitmapToFile (HBITMAP, const char* );
-
-#include <WNT_GraphicDevice.hxx>
-
-Standard_Integer WNT_PixMap::PreferedDepth(
- const Handle(Aspect_Window)& aWindow,
- const Standard_Integer aCDepth) const
-{
- Standard_Integer theDepth = 32;
- if (aCDepth <= 1) theDepth = 1;
- else if (aCDepth <= 4) theDepth = 4;
- else if (aCDepth <= 8) theDepth = 8;
- else if (aCDepth <= 16) theDepth = 16;
- else if (aCDepth <= 24) theDepth = 24;
-
- return theDepth;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////
-WNT_PixMap::WNT_PixMap (const Handle(Aspect_Window)& theWindow,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight,
- const Standard_Integer theDepth)
-: myWND (theWindow),
- myWidth (theWidth),
- myHeight (theHeight),
- myDepth (PreferedDepth (theWindow, theDepth))
-{
- const Handle(WNT_Window)& hWindow = Handle(WNT_Window)::DownCast(theWindow);
- HDC hdc = GetDC ( (HWND)(hWindow->HWindow()) );
- HDC hdcMem = CreateCompatibleDC ( hdc );
- ReleaseDC ( (HWND)(hWindow->HWindow()), hdc );
- myDC = hdcMem;
-
- Standard_Integer theNbColors = 0, theFormat = PFD_TYPE_RGBA;
-
-#ifdef BUG // Our OpenGl driver supports only RGB mode.
- //WIL001: Color table can not be initialized - do not use
- if (myDepth <= 8)
- {
- theNbColors = (1 << myDepth);
- theFormat = PFD_TYPE_COLORINDEX;
- }
-#endif
-
- Standard_Integer sizeBmi = Standard_Integer(sizeof(BITMAPINFO)+sizeof(RGBQUAD)*theNbColors);
- PBITMAPINFO pBmi = (PBITMAPINFO)(new char[sizeBmi]);
- ZeroMemory ( pBmi, sizeBmi );
-
- pBmi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); //sizeBmi
- pBmi->bmiHeader.biWidth = myWidth;
- pBmi->bmiHeader.biHeight = myHeight;
- pBmi->bmiHeader.biPlanes = 1;
- pBmi->bmiHeader.biBitCount = myDepth; //WIL001: was 24
- pBmi->bmiHeader.biCompression = BI_RGB;
-
- LPVOID ppvBits;
- HBITMAP hBmp = CreateDIBSection ( hdcMem, pBmi, DIB_RGB_COLORS, &ppvBits, NULL, 0 );
- if ( !hBmp )
- Aspect_PixmapDefinitionError::Raise ( "CreateDIBSection" );
- SelectBitmap ( hdcMem, hBmp );
- myBitmap = hBmp;
-
- delete[] pBmi;
-
- if (myDepth > 1) {
-
- PIXELFORMATDESCRIPTOR pfd;
- ZeroMemory ( &pfd, sizeof (PIXELFORMATDESCRIPTOR) );
- pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP;
- pfd.iPixelType = theFormat; //WIL001: was PFD_TYPE_RGBA
- pfd.cColorBits = myDepth; //WIL001: was 24
- pfd.cDepthBits = 24;//
- pfd.iLayerType = PFD_MAIN_PLANE;
-
- Standard_Integer iPf = ChoosePixelFormat(hdcMem, &pfd);
- if ( !iPf )
- Aspect_PixmapDefinitionError::Raise ( "ChoosePixelFormat" );
-
- if ( !DescribePixelFormat ( hdcMem, iPf, sizeof(PIXELFORMATDESCRIPTOR), &pfd ) )
- Aspect_PixmapDefinitionError::Raise ( "DescribePixelFormat" );
-
- if ( !SetPixelFormat(hdcMem, iPf, &pfd) )
- Aspect_PixmapDefinitionError::Raise ( "SetPixelFormat" );
- }
-}
-
-///////////////////////////////
-void WNT_PixMap::Destroy ()
-{
- if ( myDC ) DeleteDC ( (HDC)myDC );
- if ( myBitmap ) DeleteObject ( (HBITMAP)myBitmap );
-}
-
-////////////////////////////////////////////////////////////
-Standard_Boolean WNT_PixMap::Dump (const Standard_CString theFilename,
- const Standard_Real theGammaValue) const
-{
- // *** gamma correction must be implemented also on WNT system ...
- const Handle(WNT_Window) hWindow = Handle(WNT_Window)::DownCast(myWND);
-
- Handle(WNT_GraphicDevice) dev =
- Handle ( WNT_GraphicDevice )::DownCast ( hWindow->MyGraphicDevice );
- if ( dev.IsNull() ) return Standard_False;
- //Aspect_PixmapError::Raise ( "WNT_GraphicDevice is NULL" );
-
- return DumpBitmapToFile ((HBITMAP)myBitmap, theFilename);
-}
-
-////////////////////////////////////////////////////////////
-Standard_Address WNT_PixMap::PixmapID() const
-{
- return myDC;
-}
-
-Quantity_Color WNT_PixMap::PixelColor (const Standard_Integer ,
- const Standard_Integer ) const
-{
- Aspect_PixmapError::Raise ("PixelColor() method not implemented!");
- return Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB);
-}
friends
class WDriver from WNT,
- class IconBox from WNT,
- class PixMap from WNT
+ class IconBox from WNT
end Window;
-Test.com
-Test_deb.com
Xw_Extension.h
Xw_Cextern.hxx
Xw_alloc_color.cxx
+++ /dev/null
-#csh
-../drv/MEM/$STATION/Test$1
-
+++ /dev/null
-#csh
-$DEBUG ../drv/MEM/$STATION/Test$1
-
---Purpose: Creates the X Window drawable.
---Category: Classes
- class PixMap;
- ---Purpose: Creates a X pixmap
- ---Category: Classes
-
class ColorMap;
---Purpose: Creates the X Colormap
---Category: Classes
+++ /dev/null
--- Created on: 1999-10-14
--- Created by: VKH
--- Copyright (c) 1999 Matra Datavision
--- Copyright (c) 1999-2012 OPEN CASCADE SAS
---
--- The content of this file is subject to the Open CASCADE Technology Public
--- License Version 6.5 (the "License"). You may not use the content of this file
--- except in compliance with the License. Please obtain a copy of the License
--- at http://www.opencascade.org and read it completely before using this file.
---
--- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
--- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
---
--- The Original Code and all software distributed under the License is
--- distributed on an "AS IS" basis, without warranty of any kind, and the
--- Initial Developer hereby disclaims all such warranties, including without
--- limitation, any warranties of merchantability, fitness for a particular
--- purpose or non-infringement. Please see the License for the specific terms
--- and conditions governing the rights and limitations under the License.
-
--- Updated: GG IMP100701 Add the "depth" field and method
--- to the pixmap object.
-
-class PixMap from Xw
-
- ---Version:
-
- ---Purpose: This class defines a X11 pixmap
-
- ---Keywords: Bitmap, Pixmap, X11
-
-inherits
- Transient from Standard
-uses
- Handle from Aspect,
- Color from Quantity,
- Window from Aspect,
- Window from Xw
-raises
- PixmapDefinitionError from Aspect,
- PixmapError from Aspect
-is
- Create ( aWindow : Window from Aspect;
- aWidth, anHeight : Integer from Standard;
- aDepth : Integer from Standard = 0 )
- returns mutable PixMap from Xw
- raises PixmapDefinitionError from Aspect;
- ---Level: Public
- ---Purpose: Warning! When <aDepth> is NULL , the pixmap is created
- -- with the SAME depth than the window <aWindow>
-
- ---------------------------------------------------
- -- Category: Methods to modify the class definition
- ---------------------------------------------------
-
- Destroy ( me : mutable )
- ---Level: Advanced
- ---Purpose: Destroies the Pixmap
- -- Trigger: Raises if Pixmap is not defined properly
- raises PixmapError from Aspect is virtual;
-
- Dump ( me ; aFilename : CString from Standard;
- aGammaValue: Real from Standard = 1.0 )
- returns Boolean
- is virtual;
- ---Level: Advanced
- ---Purpose:
- -- Dumps the Bitmap to an image file with
- -- an optional gamma correction value
- -- and returns TRUE if the dump occurs normaly.
- ---Category: Methods to modify the class definition
-
- PixelColor ( me : in;
- theX, theY : in Integer from Standard )
- returns Color from Quantity
- is virtual;
- ---Purpose:
- -- Returns the pixel color.
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
- PixmapID ( me ) returns Handle from Aspect is virtual;
- ---Level: Advanced
- ---Purpose: Returns the ID of the just created pixmap
- ---Category: Inquire methods
-
- ----------------------------
- -- Category: Private methods
- ----------------------------
-
- PreferedDepth( me ; aWindow : Window from Aspect;
- aDepth : Integer from Standard)
- returns Integer from Standard is private;
-
-fields
- myPixmap : Handle from Aspect is protected;
- myWindow : Window from Xw;
- myWidth : Integer from Standard is protected;
- myHeight : Integer from Standard is protected;
- myDepth : Integer from Standard is protected;
-end PixMap;
+++ /dev/null
-// Created on: 1999-10-14
-// Created by: VKH
-// Copyright (c) 1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-// Updated GG 06/03/00 Xw_PixMap MUST creates a Pixmap and no more an Image !!!
-// GG IMP100701 Add the "depth" field and method
-// to the pixmap object.
-
-
-
-//-Version
-
-#define xTRACE 1
-
-#include <TCollection_AsciiString.hxx>
-#include <Image_AlienPixMap.hxx>
-
-#include <errno.h>
-#include <stdio.h>
-
-#include <Xw_PixMap.ixx>
-
-#include <Xw_Window.hxx>
-#include <Xw_Extension.h>
-
-XW_STATUS Xw_save_xwd_image ( void*, void*, char* );
-XW_STATUS Xw_save_bmp_image ( void*, void*, char* );
-XW_STATUS Xw_save_gif_image ( void*, void*, char* );
-
-Standard_Integer Xw_PixMap::PreferedDepth(
- const Handle(Aspect_Window)& aWindow,
- const Standard_Integer aDepth) const {
- Handle(Xw_Window) hwindow = Handle(Xw_Window)::DownCast(aWindow);
- XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) hwindow->ExtendedWindow();
- if( aDepth <= 0 ) return _DEPTH;
-// Gets the nearest depth from possible screen depths
- Standard_Integer i,j;
- Screen *scr = DefaultScreenOfDisplay(_DISPLAY);
- for( i=j=0 ; i<scr->ndepths ; i++ ) {
- if( Abs(aDepth - scr->depths[i].depth) <
- Abs(aDepth - scr->depths[j].depth) ) {
- j = i;
- }
- }
- return scr->depths[j].depth;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-Xw_PixMap::Xw_PixMap (const Handle(Aspect_Window)& theWindow,
- const Standard_Integer theWidth,
- const Standard_Integer theHeight,
- const Standard_Integer theDepth)
-: myWindow (Handle(Xw_Window)::DownCast(theWindow)),
- myWidth (theWidth),
- myHeight (theHeight),
- myDepth (PreferedDepth (theWindow, theDepth))
-{
- XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
-
- Xw_print_error();
- if( !Xw_get_trace() ) Xw_set_synchronize(_DISPLAY,True);
- myPixmap = XCreatePixmap( _DISPLAY, _WINDOW, myWidth, myHeight, myDepth);
- if( !Xw_get_trace() ) Xw_set_synchronize(_DISPLAY,False);
-
- if ( !myPixmap || Xw_print_error() ) {
- char errstring[256];
- sprintf(errstring," *** Xw_PixMap : Cann't allocates pixmap of size %d x %d, request failed with errno : '%s'",myWidth, myHeight,strerror(errno));
- Aspect_PixmapDefinitionError::Raise ( errstring );
- }
-}
-
-///////////////////////////////
-void
-Xw_PixMap::Destroy ()
-{
- if( myPixmap ) {
-#ifdef TRACE
- printf(" $$$ Xw_PixMap::Destroy() %x\n",myPixmap);
-#endif
- XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
- XFreePixmap(_DISPLAY,myPixmap);
- }
-}
-
-////////////////////////////////////////////////////////////
-Standard_Boolean Xw_PixMap::Dump (const Standard_CString theFileName,
- const Standard_Real theGammaValue) const
-{
- // the attributes
- XWindowAttributes winAttr;
- XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
- XGetWindowAttributes (_DISPLAY, _WINDOW, &winAttr);
- if (winAttr.visual->c_class != TrueColor)
- {
- std::cerr << "Visual Type not supported!";
- return Standard_False;
- }
-
- Image_AlienPixMap anImage;
- bool isBigEndian = Image_PixMap::IsBigEndianHost();
- const Standard_Size aSizeRowBytes = Standard_Size(winAttr.width) * 4;
- if (!anImage.InitTrash (isBigEndian ? Image_PixMap::ImgRGB32 : Image_PixMap::ImgBGR32,
- Standard_Size(winAttr.width), Standard_Size(winAttr.height), aSizeRowBytes))
- {
- return Standard_False;
- }
- anImage.SetTopDown (true);
-
- XImage* anXImage = XCreateImage (_DISPLAY, winAttr.visual,
- 32, ZPixmap, 0, (char* )anImage.ChangeData(), winAttr.width, winAttr.height, 32, int(aSizeRowBytes));
- anXImage->bitmap_bit_order = anXImage->byte_order = (isBigEndian ? MSBFirst : LSBFirst);
- if (XGetSubImage (_DISPLAY, myPixmap,
- 0, 0, winAttr.width, winAttr.height,
- AllPlanes, ZPixmap, anXImage, 0, 0) == NULL)
- {
- anXImage->data = NULL;
- XDestroyImage (anXImage);
- return Standard_False;
- }
-
- // destroy the image
- anXImage->data = NULL;
- XDestroyImage (anXImage);
-
- // save the image
- if (Abs (theGammaValue - 1.0) > 0.001)
- {
- anImage.AdjustGamma (theGammaValue);
- }
-
- // save the image
- return anImage.Save (theFileName);
-}
-
-////////////////////////////////////////////////////////////
-Aspect_Handle Xw_PixMap::PixmapID() const
-{
- return myPixmap;
-}
-
-Quantity_Color Xw_PixMap::PixelColor (const Standard_Integer theX,
- const Standard_Integer theY) const
-{
- // the attributes
- XWindowAttributes winAttr;
- XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*) myWindow->ExtendedWindow();
- XGetWindowAttributes (_DISPLAY, _WINDOW, &winAttr);
-
- // find the image
- XImage* pximage = XGetImage (_DISPLAY, myPixmap,
- 0, 0, myWidth, myHeight,
- AllPlanes, ZPixmap);
- if (pximage == NULL)
- {
- return Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB);
- }
-
- XColor aColor;
- aColor.pixel = XGetPixel (pximage, theX, theY);
- XDestroyImage (pximage);
-
- XQueryColor (_DISPLAY, myWindow->XColorMap(), &aColor);
- return Quantity_Color (Quantity_Parameter (aColor.red) / 65535.0,
- Quantity_Parameter (aColor.green) / 65535.0,
- Quantity_Parameter (aColor.blue) / 65535.0,
- Quantity_TOC_RGB);
-}
friends
class Driver from Xw,
- class IconBox from Xw,
- class PixMap from Xw
+ class IconBox from Xw
end Window ;