1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: os2/utilsgui.cpp
3 // Purpose: Various utility functions only available in GUI
4 // Author: David Webster
6 // Created: 20.08.2003 (extracted from os2/utils.cpp)
8 // Copyright: (c) David Webster
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
31 #include "wx/cursor.h"
34 #include "wx/apptrait.h"
37 #include "wx/os2/private.h" // includes <windows.h>
39 // ============================================================================
41 // ============================================================================
43 // ----------------------------------------------------------------------------
44 // functions to work with .INI files
45 // ----------------------------------------------------------------------------
47 // Sleep for nSecs seconds. Attempt a Windows implementation using timers.
48 static bool inTimer
= FALSE
;
50 class wxSleepTimer
: public wxTimer
60 static wxTimer
* wxTheSleepTimer
= NULL
;
62 // Reading and writing resources (eg WIN.INI, .Xdefaults)
65 const wxString
& rSection
66 , const wxString
& rEntry
67 , const wxString
& rValue
68 , const wxString
& rFile
76 hIni
= ::PrfOpenProfile(hab
, (PSZ
)WXSTRINGCAST rFile
);
79 return (::PrfWriteProfileString( hIni
80 ,(PSZ
)WXSTRINGCAST rSection
81 ,(PSZ
)WXSTRINGCAST rEntry
82 ,(PSZ
)WXSTRINGCAST rValue
87 return (::PrfWriteProfileString( HINI_PROFILE
88 ,(PSZ
)WXSTRINGCAST rSection
89 ,(PSZ
)WXSTRINGCAST rEntry
90 ,(PSZ
)WXSTRINGCAST rValue
96 const wxString
& rSection
97 , const wxString
& rEntry
99 , const wxString
& rFile
104 wxSprintf(zBuf
, "%.4f", fValue
);
105 return wxWriteResource( rSection
112 bool wxWriteResource(
113 const wxString
& rSection
114 , const wxString
& rEntry
116 , const wxString
& rFile
121 wxSprintf(zBuf
, "%ld", lValue
);
122 return wxWriteResource( rSection
129 bool wxWriteResource(
130 const wxString
& rSection
131 , const wxString
& rEntry
133 , const wxString
& rFile
138 wxSprintf(zBuf
, "%d", lValue
);
139 return wxWriteResource( rSection
147 const wxString
& rSection
148 , const wxString
& rEntry
150 , const wxString
& rFile
155 wxChar zDefunkt
[] = _T("$$default");
160 hIni
= ::PrfOpenProfile(hab
, (PSZ
)WXSTRINGCAST rFile
);
163 ULONG n
= ::PrfQueryProfileString( hIni
164 ,(PSZ
)WXSTRINGCAST rSection
165 ,(PSZ
)WXSTRINGCAST rEntry
172 if (n
== 0L || wxStrcmp(zBuf
, zDefunkt
) == 0)
181 ULONG n
= ::PrfQueryProfileString( HINI_PROFILE
182 ,(PSZ
)WXSTRINGCAST rSection
183 ,(PSZ
)WXSTRINGCAST rEntry
190 if (n
== 0L || wxStrcmp(zBuf
, zDefunkt
) == 0)
194 strcpy((char*)*ppValue
, zBuf
);
199 const wxString
& rSection
200 , const wxString
& rEntry
202 , const wxString
& rFile
207 zStr
= new wxChar
[1000];
208 bool bSucc
= wxGetResource( rSection
216 *pValue
= (float)wxStrtod(zStr
, NULL
);
228 const wxString
& rSection
229 , const wxString
& rEntry
231 , const wxString
& rFile
236 zStr
= new wxChar
[1000];
237 bool bSucc
= wxGetResource( rSection
245 *pValue
= wxStrtol(zStr
, NULL
, 10);
257 const wxString
& rSection
258 , const wxString
& rEntry
260 , const wxString
& rFile
265 zStr
= new wxChar
[1000];
266 bool bSucc
= wxGetResource( rSection
274 *pValue
= (int)wxStrtol(zStr
, NULL
, 10);
284 #endif // wxUSE_RESOURCES
286 // ---------------------------------------------------------------------------
287 // helper functions for showing a "busy" cursor
288 // ---------------------------------------------------------------------------
290 HCURSOR gs_wxBusyCursor
= 0; // new, busy cursor
291 HCURSOR gs_wxBusyCursorOld
= 0; // old cursor
292 static int gs_wxBusyCursorCount
= 0;
294 // Set the cursor to the busy cursor for all windows
295 void wxBeginBusyCursor(
299 if ( gs_wxBusyCursorCount
++ == 0 )
301 gs_wxBusyCursor
= (HCURSOR
)pCursor
->GetHCURSOR();
302 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)gs_wxBusyCursor
);
304 //else: nothing to do, already set
307 // Restore cursor to normal
308 void wxEndBusyCursor()
310 wxCHECK_RET( gs_wxBusyCursorCount
> 0
311 ,_T("no matching wxBeginBusyCursor() for wxEndBusyCursor()")
314 if (--gs_wxBusyCursorCount
== 0)
316 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)gs_wxBusyCursorOld
);
317 gs_wxBusyCursorOld
= 0;
321 // TRUE if we're between the above two calls
324 return (gs_wxBusyCursorCount
> 0);
327 // Check whether this window wants to process messages, e.g. Stop button
328 // in long calculations.
329 bool wxCheckForInterrupt(
337 HWND hwndFilter
= NULLHANDLE
;
338 HWND hwndWin
= (HWND
) pWnd
->GetHWND();
340 while(::WinPeekMsg(hab
, &vMsg
, hwndFilter
, 0, 0, PM_REMOVE
))
342 ::WinDispatchMsg(hab
, &vMsg
);
344 return TRUE
;//*** temporary?
348 wxFAIL_MSG(_T("pWnd==NULL !!!"));
349 return FALSE
;//*** temporary?
353 // ----------------------------------------------------------------------------
355 // ----------------------------------------------------------------------------
357 // See also the wxGetMousePosition in window.cpp
358 // Deprecated: use wxPoint wxGetMousePosition() instead
359 void wxGetMousePosition(
366 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
371 // Return TRUE if we have a colour display
372 bool wxColourDisplay()
379 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
380 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
381 ::DevQueryCaps(hdcScreen
, CAPS_COLORS
, 1L, &lColors
);
382 return(lColors
> 1L);
384 // I don't see how the PM display could not be color. Besides, this
385 // was leaking DCs and PSs!!! MN
390 // Returns depth of screen
397 static LONG nDepth
= 0;
399 // The screen colordepth ain't gonna change. No reason to query
402 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
403 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
404 ::DevQueryCaps(hdcScreen
, CAPS_COLOR_PLANES
, 1L, &lPlanes
);
405 ::DevQueryCaps(hdcScreen
, CAPS_COLOR_BITCOUNT
, 1L, &lBitsPerPixel
);
407 nDepth
= (int)(lPlanes
* lBitsPerPixel
);
408 ::DevCloseDC(hdcScreen
);
409 ::WinReleasePS(hpsScreen
);
414 // Get size of display
422 static LONG lWidth
= 0;
423 static LONG lHeight
= 0;
425 // The screen size ain't gonna change either so just cache the values
427 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
428 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
429 ::DevQueryCaps(hdcScreen
, CAPS_WIDTH
, 1L, &lWidth
);
430 ::DevQueryCaps(hdcScreen
, CAPS_HEIGHT
, 1L, &lHeight
);
431 ::DevCloseDC(hdcScreen
);
432 ::WinReleasePS(hpsScreen
);
434 *pWidth
= (int)lWidth
;
435 *pHeight
= (int)lHeight
;
438 void wxDisplaySizeMM(
446 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
447 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
450 ::DevQueryCaps( hdcScreen
451 ,CAPS_HORIZONTAL_RESOLUTION
456 ::DevQueryCaps( hdcScreen
457 ,CAPS_VERTICAL_RESOLUTION
461 ::DevCloseDC(hdcScreen
);
462 ::WinReleasePS(hpsScreen
);
465 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
467 // This is supposed to return desktop dimensions minus any window
468 // manager panels, menus, taskbars, etc. If there is a way to do that
469 // for this platform please fix this function, otherwise it defaults
470 // to the entire desktop.
473 wxDisplaySize(width
, height
);
476 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
478 static wxToolkitInfo vInfo
;
479 ULONG ulSysInfo
[QSV_MAX
] = {0};
482 vInfo
.shortName
= _T("PM");
483 vInfo
.name
= _T("wxOS2");
484 #ifdef __WXUNIVERSAL__
485 vInfo
.shortName
<< _T("univ");
486 vInfo
.name
<< _T("/wxUniversal");
488 ulrc
= ::DosQuerySysInfo( 1L
491 ,sizeof(ULONG
) * QSV_MAX
495 vInfo
.versionMajor
= ulSysInfo
[QSV_VERSION_MAJOR
] / 10;
496 vInfo
.versionMinor
= ulSysInfo
[QSV_VERSION_MINOR
];
502 // ---------------------------------------------------------------------------
503 // window information functions
504 // ---------------------------------------------------------------------------
506 wxString WXDLLEXPORT
wxGetWindowText(
511 long lLen
= ::WinQueryWindowTextLength((HWND
)hWnd
) + 1;
513 ::WinQueryWindowText((HWND
)hWnd
, lLen
, vStr
.GetWriteBuf((int)lLen
));
514 vStr
.UngetWriteBuf();
519 wxString WXDLLEXPORT
wxGetWindowClass(
524 int nLen
= 256; // some starting value
528 int nCount
= ::WinQueryClassName((HWND
)hWnd
, nLen
, vStr
.GetWriteBuf(nLen
));
530 vStr
.UngetWriteBuf();
533 // the class name might have been truncated, retry with larger
545 WXWORD WXDLLEXPORT
wxGetWindowId(
549 return ::WinQueryWindowUShort((HWND
)hWnd
, QWS_ID
);
560 vPoint
[0].x
= rRect
.xLeft
;
561 vPoint
[0].y
= rRect
.yBottom
;
562 ::GpiMove(hPS
, &vPoint
[0]);
563 if (dwStyle
& wxSIMPLE_BORDER
||
564 dwStyle
& wxSTATIC_BORDER
)
566 vPoint
[1].x
= rRect
.xRight
- 1;
567 vPoint
[1].y
= rRect
.yTop
- 1;
575 if (dwStyle
& wxSUNKEN_BORDER
)
577 LINEBUNDLE vLineBundle
;
579 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
580 vLineBundle
.usMixMode
= FM_OVERPAINT
;
581 vLineBundle
.fxWidth
= 2;
582 vLineBundle
.lGeomWidth
= 2;
583 vLineBundle
.usType
= LINETYPE_SOLID
;
584 vLineBundle
.usEnd
= 0;
585 vLineBundle
.usJoin
= 0;
588 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
592 vPoint
[1].x
= rRect
.xRight
- 1;
593 vPoint
[1].y
= rRect
.yTop
- 1;
600 vPoint
[0].x
= rRect
.xLeft
+ 1;
601 vPoint
[0].y
= rRect
.yBottom
+ 1;
602 ::GpiMove(hPS
, &vPoint
[0]);
603 vPoint
[1].x
= rRect
.xRight
- 2;
604 vPoint
[1].y
= rRect
.yTop
- 2;
612 vLineBundle
.lColor
= 0x00000000; // BLACK
613 vLineBundle
.usMixMode
= FM_OVERPAINT
;
614 vLineBundle
.fxWidth
= 2;
615 vLineBundle
.lGeomWidth
= 2;
616 vLineBundle
.usType
= LINETYPE_SOLID
;
617 vLineBundle
.usEnd
= 0;
618 vLineBundle
.usJoin
= 0;
621 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
625 vPoint
[0].x
= rRect
.xLeft
+ 2;
626 vPoint
[0].y
= rRect
.yBottom
+ 2;
627 ::GpiMove(hPS
, &vPoint
[0]);
628 vPoint
[1].x
= rRect
.xLeft
+ 2;
629 vPoint
[1].y
= rRect
.yTop
- 3;
630 ::GpiLine(hPS
, &vPoint
[1]);
631 vPoint
[1].x
= rRect
.xRight
- 3;
632 vPoint
[1].y
= rRect
.yTop
- 3;
633 ::GpiLine(hPS
, &vPoint
[1]);
635 vPoint
[0].x
= rRect
.xLeft
+ 3;
636 vPoint
[0].y
= rRect
.yBottom
+ 3;
637 ::GpiMove(hPS
, &vPoint
[0]);
638 vPoint
[1].x
= rRect
.xLeft
+ 3;
639 vPoint
[1].y
= rRect
.yTop
- 4;
640 ::GpiLine(hPS
, &vPoint
[1]);
641 vPoint
[1].x
= rRect
.xRight
- 4;
642 vPoint
[1].y
= rRect
.yTop
- 4;
643 ::GpiLine(hPS
, &vPoint
[1]);
645 if (dwStyle
& wxDOUBLE_BORDER
)
647 LINEBUNDLE vLineBundle
;
649 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
650 vLineBundle
.usMixMode
= FM_OVERPAINT
;
651 vLineBundle
.fxWidth
= 2;
652 vLineBundle
.lGeomWidth
= 2;
653 vLineBundle
.usType
= LINETYPE_SOLID
;
654 vLineBundle
.usEnd
= 0;
655 vLineBundle
.usJoin
= 0;
658 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
662 vPoint
[1].x
= rRect
.xRight
- 1;
663 vPoint
[1].y
= rRect
.yTop
- 1;
670 vLineBundle
.lColor
= 0x00000000; // WHITE
671 vLineBundle
.usMixMode
= FM_OVERPAINT
;
672 vLineBundle
.fxWidth
= 2;
673 vLineBundle
.lGeomWidth
= 2;
674 vLineBundle
.usType
= LINETYPE_SOLID
;
675 vLineBundle
.usEnd
= 0;
676 vLineBundle
.usJoin
= 0;
679 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
683 vPoint
[0].x
= rRect
.xLeft
+ 2;
684 vPoint
[0].y
= rRect
.yBottom
+ 2;
685 ::GpiMove(hPS
, &vPoint
[0]);
686 vPoint
[1].x
= rRect
.xRight
- 2;
687 vPoint
[1].y
= rRect
.yTop
- 2;
694 vLineBundle
.lColor
= 0x00FFFFFF; // BLACK
695 vLineBundle
.usMixMode
= FM_OVERPAINT
;
696 vLineBundle
.fxWidth
= 2;
697 vLineBundle
.lGeomWidth
= 2;
698 vLineBundle
.usType
= LINETYPE_SOLID
;
699 vLineBundle
.usEnd
= 0;
700 vLineBundle
.usJoin
= 0;
703 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
707 vPoint
[0].x
= rRect
.xLeft
+ 3;
708 vPoint
[0].y
= rRect
.yBottom
+ 3;
709 ::GpiMove(hPS
, &vPoint
[0]);
710 vPoint
[1].x
= rRect
.xRight
- 3;
711 vPoint
[1].y
= rRect
.yTop
- 3;
719 if (dwStyle
& wxRAISED_BORDER
)
721 LINEBUNDLE vLineBundle
;
723 vLineBundle
.lColor
= 0x00000000; // BLACK
724 vLineBundle
.usMixMode
= FM_OVERPAINT
;
725 vLineBundle
.fxWidth
= 2;
726 vLineBundle
.lGeomWidth
= 2;
727 vLineBundle
.usType
= LINETYPE_SOLID
;
728 vLineBundle
.usEnd
= 0;
729 vLineBundle
.usJoin
= 0;
732 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
736 vPoint
[1].x
= rRect
.xRight
- 1;
737 vPoint
[1].y
= rRect
.yTop
- 1;
744 vPoint
[0].x
= rRect
.xLeft
+ 1;
745 vPoint
[0].y
= rRect
.yBottom
+ 1;
746 ::GpiMove(hPS
, &vPoint
[0]);
747 vPoint
[1].x
= rRect
.xRight
- 2;
748 vPoint
[1].y
= rRect
.yTop
- 2;
756 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
757 vLineBundle
.usMixMode
= FM_OVERPAINT
;
758 vLineBundle
.fxWidth
= 2;
759 vLineBundle
.lGeomWidth
= 2;
760 vLineBundle
.usType
= LINETYPE_SOLID
;
761 vLineBundle
.usEnd
= 0;
762 vLineBundle
.usJoin
= 0;
765 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
769 vPoint
[0].x
= rRect
.xLeft
+ 2;
770 vPoint
[0].y
= rRect
.yBottom
+ 2;
771 ::GpiMove(hPS
, &vPoint
[0]);
772 vPoint
[1].x
= rRect
.xLeft
+ 2;
773 vPoint
[1].y
= rRect
.yTop
- 3;
774 ::GpiLine(hPS
, &vPoint
[1]);
775 vPoint
[1].x
= rRect
.xRight
- 3;
776 vPoint
[1].y
= rRect
.yTop
- 3;
777 ::GpiLine(hPS
, &vPoint
[1]);
779 vPoint
[0].x
= rRect
.xLeft
+ 3;
780 vPoint
[0].y
= rRect
.yBottom
+ 3;
781 ::GpiMove(hPS
, &vPoint
[0]);
782 vPoint
[1].x
= rRect
.xLeft
+ 3;
783 vPoint
[1].y
= rRect
.yTop
- 4;
784 ::GpiLine(hPS
, &vPoint
[1]);
785 vPoint
[1].x
= rRect
.xRight
- 4;
786 vPoint
[1].y
= rRect
.yTop
- 4;
787 ::GpiLine(hPS
, &vPoint
[1]);
789 } // end of wxDrawBorder
793 , const wxFont
& rFont
801 if (hWnd
== NULLHANDLE
)
805 // The fonts available for Presentation Params are just a few
806 // outline fonts, the rest are available to the GPI, so we must
807 // map the families to one of these three
809 switch(rFont
.GetFamily())
812 strcpy(zFacename
, "Script");
816 strcpy(zFacename
, "WarpSans");
820 strcpy(zFacename
,"Times New Roman");
824 strcpy(zFacename
, "Courier New");
828 strcpy(zFacename
, "Courier New");
834 strcpy(zFacename
, "Helvetica");
838 switch(rFont
.GetWeight())
847 case wxFONTWEIGHT_MAX
:
848 strcpy(zWeight
, "Bold");
852 switch(rFont
.GetStyle())
856 strcpy(zStyle
, "Italic");
863 sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), zFacename
);
864 if (zWeight
[0] != '\0')
867 strcat(zFont
, zWeight
);
869 if (zStyle
[0] != '\0')
872 strcat(zFont
, zStyle
);
874 ::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
) + 1, (PVOID
)zFont
);
875 } // end of wxOS2SetFont
877 // ---------------------------------------------------------------------------
878 // Helper for taking a regular bitmap and giving it a disabled look
879 // ---------------------------------------------------------------------------
880 wxBitmap
wxDisableBitmap(
885 wxMask
* pMask
= rBmp
.GetMask();
888 return(wxNullBitmap
);
890 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
891 SIZEL vSize
= {0, 0};
892 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
893 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
894 BITMAPINFOHEADER2 vHeader
;
898 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
899 HBITMAP hOldBitmap
= NULLHANDLE
;
900 HBITMAP hOldMask
= NULLHANDLE
;
901 HBITMAP hMask
= (HBITMAP
)rBmp
.GetMask()->GetMaskBitmap();
902 unsigned char* pucBits
; // buffer that will contain the bitmap data
903 unsigned char* pucData
; // pointer to use to traverse bitmap data
904 unsigned char* pucBitsMask
; // buffer that will contain the mask data
905 unsigned char* pucDataMask
; // pointer to use to traverse mask data
908 bool bpp16
= (wxDisplayDepth() == 16);
910 memset(&vHeader
, '\0', 16);
913 memset(&vInfo
, '\0', 16);
915 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
916 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
918 vInfo
.cBitCount
= 24; // Set to desired count going in
921 // Create the buffers for data....all wxBitmaps are 24 bit internally
923 int nBytesPerLine
= rBmp
.GetWidth() * 3;
924 int nSizeDWORD
= sizeof(DWORD
);
925 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
931 // Bitmap must be ina double-word alligned address so we may
932 // have some padding to worry about
934 if (nLineBoundary
> 0)
936 nPadding
= nSizeDWORD
- nLineBoundary
;
937 nBytesPerLine
+= nPadding
;
939 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
940 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
941 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
942 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
945 // Extract the bitmap and mask data
947 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
949 vError
= ::WinGetLastError(vHabmain
);
950 sError
= wxPMErrorToStr(vError
);
952 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
953 vInfo
.cBitCount
= 24;
954 if ((lScans
= ::GpiQueryBitmapBits( hPS
956 ,(LONG
)rBmp
.GetHeight()
961 vError
= ::WinGetLastError(vHabmain
);
962 sError
= wxPMErrorToStr(vError
);
964 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
966 vError
= ::WinGetLastError(vHabmain
);
967 sError
= wxPMErrorToStr(vError
);
969 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
970 vInfo
.cBitCount
= 24;
971 if ((lScans
= ::GpiQueryBitmapBits( hPS
973 ,(LONG
)rBmp
.GetHeight()
978 vError
= ::WinGetLastError(vHabmain
);
979 sError
= wxPMErrorToStr(vError
);
981 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
983 vError
= ::WinGetLastError(vHabmain
);
984 sError
= wxPMErrorToStr(vError
);
987 pucDataMask
= pucBitsMask
;
990 // Get the mask value
992 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
994 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
997 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1002 else if (*pucDataMask
== 0xFF) // set to grey
1009 *pucData
= ((unsigned char)(lColor
>> 16));
1014 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1019 else if (*(pucDataMask
+ 1) == 0xFF) // set to grey
1026 *pucData
= ((unsigned char)(lColor
>> 8));
1031 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1036 else if (*(pucDataMask
+ 2) == 0xFF) // set to grey
1043 *pucData
= ((unsigned char)lColor
);
1048 for (j
= 0; j
< nPadding
; j
++)
1056 // Create a new bitmap and set the modified bits
1058 wxBitmap
vNewBmp( rBmp
.GetWidth()
1062 HBITMAP hNewBmp
= (HBITMAP
)vNewBmp
.GetHBITMAP();
1064 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hNewBmp
)) == HBM_ERROR
)
1066 vError
= ::WinGetLastError(vHabmain
);
1067 sError
= wxPMErrorToStr(vError
);
1069 if ((lScansSet
= ::GpiSetBitmapBits( hPS
1071 ,(LONG
)rBmp
.GetHeight()
1077 vError
= ::WinGetLastError(vHabmain
);
1078 sError
= wxPMErrorToStr(vError
);
1082 pNewMask
= new wxMask(pMask
->GetMaskBitmap());
1083 vNewBmp
.SetMask(pNewMask
);
1085 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1086 ::GpiDestroyPS(hPS
);
1090 return(wxNullBitmap
);
1091 } // end of wxDisableBitmap
1093 COLORREF
wxColourToRGB(
1094 const wxColour
& rColor
1097 return(OS2RGB(rColor
.Red(), rColor
.Green(), rColor
.Blue()));
1098 } // end of wxColourToRGB