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/os2/private.h" // includes <windows.h>
36 // ============================================================================
38 // ============================================================================
40 // ----------------------------------------------------------------------------
41 // functions to work with .INI files
42 // ----------------------------------------------------------------------------
44 // Sleep for nSecs seconds. Attempt a Windows implementation using timers.
45 static bool inTimer
= FALSE
;
47 class wxSleepTimer
: public wxTimer
57 static wxTimer
* wxTheSleepTimer
= NULL
;
59 // Reading and writing resources (eg WIN.INI, .Xdefaults)
62 const wxString
& rSection
63 , const wxString
& rEntry
64 , const wxString
& rValue
65 , const wxString
& rFile
73 hIni
= ::PrfOpenProfile(hab
, (PSZ
)WXSTRINGCAST rFile
);
76 return (::PrfWriteProfileString( hIni
77 ,(PSZ
)WXSTRINGCAST rSection
78 ,(PSZ
)WXSTRINGCAST rEntry
79 ,(PSZ
)WXSTRINGCAST rValue
84 return (::PrfWriteProfileString( HINI_PROFILE
85 ,(PSZ
)WXSTRINGCAST rSection
86 ,(PSZ
)WXSTRINGCAST rEntry
87 ,(PSZ
)WXSTRINGCAST rValue
93 const wxString
& rSection
94 , const wxString
& rEntry
96 , const wxString
& rFile
101 wxSprintf(zBuf
, "%.4f", fValue
);
102 return wxWriteResource( rSection
109 bool wxWriteResource(
110 const wxString
& rSection
111 , const wxString
& rEntry
113 , const wxString
& rFile
118 wxSprintf(zBuf
, "%ld", lValue
);
119 return wxWriteResource( rSection
126 bool wxWriteResource(
127 const wxString
& rSection
128 , const wxString
& rEntry
130 , const wxString
& rFile
135 wxSprintf(zBuf
, "%d", lValue
);
136 return wxWriteResource( rSection
144 const wxString
& rSection
145 , const wxString
& rEntry
147 , const wxString
& rFile
152 wxChar zDefunkt
[] = _T("$$default");
157 hIni
= ::PrfOpenProfile(hab
, (PSZ
)WXSTRINGCAST rFile
);
160 ULONG n
= ::PrfQueryProfileString( hIni
161 ,(PSZ
)WXSTRINGCAST rSection
162 ,(PSZ
)WXSTRINGCAST rEntry
169 if (n
== 0L || wxStrcmp(zBuf
, zDefunkt
) == 0)
178 ULONG n
= ::PrfQueryProfileString( HINI_PROFILE
179 ,(PSZ
)WXSTRINGCAST rSection
180 ,(PSZ
)WXSTRINGCAST rEntry
187 if (n
== 0L || wxStrcmp(zBuf
, zDefunkt
) == 0)
191 strcpy((char*)*ppValue
, zBuf
);
196 const wxString
& rSection
197 , const wxString
& rEntry
199 , const wxString
& rFile
204 zStr
= new wxChar
[1000];
205 bool bSucc
= wxGetResource( rSection
213 *pValue
= (float)wxStrtod(zStr
, NULL
);
225 const wxString
& rSection
226 , const wxString
& rEntry
228 , const wxString
& rFile
233 zStr
= new wxChar
[1000];
234 bool bSucc
= wxGetResource( rSection
242 *pValue
= wxStrtol(zStr
, NULL
, 10);
254 const wxString
& rSection
255 , const wxString
& rEntry
257 , const wxString
& rFile
262 zStr
= new wxChar
[1000];
263 bool bSucc
= wxGetResource( rSection
271 *pValue
= (int)wxStrtol(zStr
, NULL
, 10);
281 #endif // wxUSE_RESOURCES
283 // ---------------------------------------------------------------------------
284 // helper functions for showing a "busy" cursor
285 // ---------------------------------------------------------------------------
287 HCURSOR gs_wxBusyCursor
= 0; // new, busy cursor
288 HCURSOR gs_wxBusyCursorOld
= 0; // old cursor
289 static int gs_wxBusyCursorCount
= 0;
291 // Set the cursor to the busy cursor for all windows
292 void wxBeginBusyCursor(
296 if ( gs_wxBusyCursorCount
++ == 0 )
298 gs_wxBusyCursor
= (HCURSOR
)pCursor
->GetHCURSOR();
299 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)gs_wxBusyCursor
);
301 //else: nothing to do, already set
304 // Restore cursor to normal
305 void wxEndBusyCursor()
307 wxCHECK_RET( gs_wxBusyCursorCount
> 0
308 ,_T("no matching wxBeginBusyCursor() for wxEndBusyCursor()")
311 if (--gs_wxBusyCursorCount
== 0)
313 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)gs_wxBusyCursorOld
);
314 gs_wxBusyCursorOld
= 0;
318 // TRUE if we're between the above two calls
321 return (gs_wxBusyCursorCount
> 0);
324 // Check whether this window wants to process messages, e.g. Stop button
325 // in long calculations.
326 bool wxCheckForInterrupt(
334 HWND hwndFilter
= NULLHANDLE
;
335 HWND hwndWin
= (HWND
) pWnd
->GetHWND();
337 while(::WinPeekMsg(hab
, &vMsg
, hwndFilter
, 0, 0, PM_REMOVE
))
339 ::WinDispatchMsg(hab
, &vMsg
);
341 return TRUE
;//*** temporary?
345 wxFAIL_MSG(_T("pWnd==NULL !!!"));
346 return FALSE
;//*** temporary?
350 // ----------------------------------------------------------------------------
352 // ----------------------------------------------------------------------------
354 // See also the wxGetMousePosition in window.cpp
355 // Deprecated: use wxPoint wxGetMousePosition() instead
356 void wxGetMousePosition(
363 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
368 // Return TRUE if we have a colour display
369 bool wxColourDisplay()
376 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
377 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
378 ::DevQueryCaps(hdcScreen
, CAPS_COLORS
, 1L, &lColors
);
379 return(lColors
> 1L);
381 // I don't see how the PM display could not be color. Besides, this
382 // was leaking DCs and PSs!!! MN
387 // Returns depth of screen
394 static LONG nDepth
= 0;
396 // The screen colordepth ain't gonna change. No reason to query
399 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
400 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
401 ::DevQueryCaps(hdcScreen
, CAPS_COLOR_PLANES
, 1L, &lPlanes
);
402 ::DevQueryCaps(hdcScreen
, CAPS_COLOR_BITCOUNT
, 1L, &lBitsPerPixel
);
404 nDepth
= (int)(lPlanes
* lBitsPerPixel
);
405 ::DevCloseDC(hdcScreen
);
406 ::WinReleasePS(hpsScreen
);
411 // Get size of display
419 static LONG lWidth
= 0;
420 static LONG lHeight
= 0;
422 // The screen size ain't gonna change either so just cache the values
424 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
425 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
426 ::DevQueryCaps(hdcScreen
, CAPS_WIDTH
, 1L, &lWidth
);
427 ::DevQueryCaps(hdcScreen
, CAPS_HEIGHT
, 1L, &lHeight
);
428 ::DevCloseDC(hdcScreen
);
429 ::WinReleasePS(hpsScreen
);
431 *pWidth
= (int)lWidth
;
432 *pHeight
= (int)lHeight
;
435 void wxDisplaySizeMM(
443 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
444 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
447 ::DevQueryCaps( hdcScreen
448 ,CAPS_HORIZONTAL_RESOLUTION
453 ::DevQueryCaps( hdcScreen
454 ,CAPS_VERTICAL_RESOLUTION
458 ::DevCloseDC(hdcScreen
);
459 ::WinReleasePS(hpsScreen
);
462 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
464 // This is supposed to return desktop dimensions minus any window
465 // manager panels, menus, taskbars, etc. If there is a way to do that
466 // for this platform please fix this function, otherwise it defaults
467 // to the entire desktop.
470 wxDisplaySize(width
, height
);
473 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
475 static wxToolkitInfo vInfo
;
476 ULONG ulSysInfo
[QSV_MAX
] = {0};
479 vInfo
.shortName
= _T("PM");
480 vInfo
.name
= _T("wxOS2");
481 #ifdef __WXUNIVERSAL__
482 vInfo
.shortName
<< _T("univ");
483 vInfo
.name
<< _T("/wxUniversal");
485 ulrc
= ::DosQuerySysInfo( 1L
488 ,sizeof(ULONG
) * QSV_MAX
492 vInfo
.versionMajor
= ulSysInfo
[QSV_VERSION_MAJOR
] / 10;
493 vInfo
.versionMinor
= ulSysInfo
[QSV_VERSION_MINOR
];
499 // ---------------------------------------------------------------------------
500 // window information functions
501 // ---------------------------------------------------------------------------
503 wxString WXDLLEXPORT
wxGetWindowText(
508 long lLen
= ::WinQueryWindowTextLength((HWND
)hWnd
) + 1;
510 ::WinQueryWindowText((HWND
)hWnd
, lLen
, vStr
.GetWriteBuf((int)lLen
));
511 vStr
.UngetWriteBuf();
516 wxString WXDLLEXPORT
wxGetWindowClass(
521 int nLen
= 256; // some starting value
525 int nCount
= ::WinQueryClassName((HWND
)hWnd
, nLen
, vStr
.GetWriteBuf(nLen
));
527 vStr
.UngetWriteBuf();
530 // the class name might have been truncated, retry with larger
542 WXWORD WXDLLEXPORT
wxGetWindowId(
546 return ::WinQueryWindowUShort((HWND
)hWnd
, QWS_ID
);
557 vPoint
[0].x
= rRect
.xLeft
;
558 vPoint
[0].y
= rRect
.yBottom
;
559 ::GpiMove(hPS
, &vPoint
[0]);
560 if (dwStyle
& wxSIMPLE_BORDER
||
561 dwStyle
& wxSTATIC_BORDER
)
563 vPoint
[1].x
= rRect
.xRight
- 1;
564 vPoint
[1].y
= rRect
.yTop
- 1;
572 if (dwStyle
& wxSUNKEN_BORDER
)
574 LINEBUNDLE vLineBundle
;
576 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
577 vLineBundle
.usMixMode
= FM_OVERPAINT
;
578 vLineBundle
.fxWidth
= 2;
579 vLineBundle
.lGeomWidth
= 2;
580 vLineBundle
.usType
= LINETYPE_SOLID
;
581 vLineBundle
.usEnd
= 0;
582 vLineBundle
.usJoin
= 0;
585 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
589 vPoint
[1].x
= rRect
.xRight
- 1;
590 vPoint
[1].y
= rRect
.yTop
- 1;
597 vPoint
[0].x
= rRect
.xLeft
+ 1;
598 vPoint
[0].y
= rRect
.yBottom
+ 1;
599 ::GpiMove(hPS
, &vPoint
[0]);
600 vPoint
[1].x
= rRect
.xRight
- 2;
601 vPoint
[1].y
= rRect
.yTop
- 2;
609 vLineBundle
.lColor
= 0x00000000; // BLACK
610 vLineBundle
.usMixMode
= FM_OVERPAINT
;
611 vLineBundle
.fxWidth
= 2;
612 vLineBundle
.lGeomWidth
= 2;
613 vLineBundle
.usType
= LINETYPE_SOLID
;
614 vLineBundle
.usEnd
= 0;
615 vLineBundle
.usJoin
= 0;
618 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
622 vPoint
[0].x
= rRect
.xLeft
+ 2;
623 vPoint
[0].y
= rRect
.yBottom
+ 2;
624 ::GpiMove(hPS
, &vPoint
[0]);
625 vPoint
[1].x
= rRect
.xLeft
+ 2;
626 vPoint
[1].y
= rRect
.yTop
- 3;
627 ::GpiLine(hPS
, &vPoint
[1]);
628 vPoint
[1].x
= rRect
.xRight
- 3;
629 vPoint
[1].y
= rRect
.yTop
- 3;
630 ::GpiLine(hPS
, &vPoint
[1]);
632 vPoint
[0].x
= rRect
.xLeft
+ 3;
633 vPoint
[0].y
= rRect
.yBottom
+ 3;
634 ::GpiMove(hPS
, &vPoint
[0]);
635 vPoint
[1].x
= rRect
.xLeft
+ 3;
636 vPoint
[1].y
= rRect
.yTop
- 4;
637 ::GpiLine(hPS
, &vPoint
[1]);
638 vPoint
[1].x
= rRect
.xRight
- 4;
639 vPoint
[1].y
= rRect
.yTop
- 4;
640 ::GpiLine(hPS
, &vPoint
[1]);
642 if (dwStyle
& wxDOUBLE_BORDER
)
644 LINEBUNDLE vLineBundle
;
646 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
647 vLineBundle
.usMixMode
= FM_OVERPAINT
;
648 vLineBundle
.fxWidth
= 2;
649 vLineBundle
.lGeomWidth
= 2;
650 vLineBundle
.usType
= LINETYPE_SOLID
;
651 vLineBundle
.usEnd
= 0;
652 vLineBundle
.usJoin
= 0;
655 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
659 vPoint
[1].x
= rRect
.xRight
- 1;
660 vPoint
[1].y
= rRect
.yTop
- 1;
667 vLineBundle
.lColor
= 0x00000000; // WHITE
668 vLineBundle
.usMixMode
= FM_OVERPAINT
;
669 vLineBundle
.fxWidth
= 2;
670 vLineBundle
.lGeomWidth
= 2;
671 vLineBundle
.usType
= LINETYPE_SOLID
;
672 vLineBundle
.usEnd
= 0;
673 vLineBundle
.usJoin
= 0;
676 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
680 vPoint
[0].x
= rRect
.xLeft
+ 2;
681 vPoint
[0].y
= rRect
.yBottom
+ 2;
682 ::GpiMove(hPS
, &vPoint
[0]);
683 vPoint
[1].x
= rRect
.xRight
- 2;
684 vPoint
[1].y
= rRect
.yTop
- 2;
691 vLineBundle
.lColor
= 0x00FFFFFF; // BLACK
692 vLineBundle
.usMixMode
= FM_OVERPAINT
;
693 vLineBundle
.fxWidth
= 2;
694 vLineBundle
.lGeomWidth
= 2;
695 vLineBundle
.usType
= LINETYPE_SOLID
;
696 vLineBundle
.usEnd
= 0;
697 vLineBundle
.usJoin
= 0;
700 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
704 vPoint
[0].x
= rRect
.xLeft
+ 3;
705 vPoint
[0].y
= rRect
.yBottom
+ 3;
706 ::GpiMove(hPS
, &vPoint
[0]);
707 vPoint
[1].x
= rRect
.xRight
- 3;
708 vPoint
[1].y
= rRect
.yTop
- 3;
716 if (dwStyle
& wxRAISED_BORDER
)
718 LINEBUNDLE vLineBundle
;
720 vLineBundle
.lColor
= 0x00000000; // BLACK
721 vLineBundle
.usMixMode
= FM_OVERPAINT
;
722 vLineBundle
.fxWidth
= 2;
723 vLineBundle
.lGeomWidth
= 2;
724 vLineBundle
.usType
= LINETYPE_SOLID
;
725 vLineBundle
.usEnd
= 0;
726 vLineBundle
.usJoin
= 0;
729 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
733 vPoint
[1].x
= rRect
.xRight
- 1;
734 vPoint
[1].y
= rRect
.yTop
- 1;
741 vPoint
[0].x
= rRect
.xLeft
+ 1;
742 vPoint
[0].y
= rRect
.yBottom
+ 1;
743 ::GpiMove(hPS
, &vPoint
[0]);
744 vPoint
[1].x
= rRect
.xRight
- 2;
745 vPoint
[1].y
= rRect
.yTop
- 2;
753 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
754 vLineBundle
.usMixMode
= FM_OVERPAINT
;
755 vLineBundle
.fxWidth
= 2;
756 vLineBundle
.lGeomWidth
= 2;
757 vLineBundle
.usType
= LINETYPE_SOLID
;
758 vLineBundle
.usEnd
= 0;
759 vLineBundle
.usJoin
= 0;
762 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
766 vPoint
[0].x
= rRect
.xLeft
+ 2;
767 vPoint
[0].y
= rRect
.yBottom
+ 2;
768 ::GpiMove(hPS
, &vPoint
[0]);
769 vPoint
[1].x
= rRect
.xLeft
+ 2;
770 vPoint
[1].y
= rRect
.yTop
- 3;
771 ::GpiLine(hPS
, &vPoint
[1]);
772 vPoint
[1].x
= rRect
.xRight
- 3;
773 vPoint
[1].y
= rRect
.yTop
- 3;
774 ::GpiLine(hPS
, &vPoint
[1]);
776 vPoint
[0].x
= rRect
.xLeft
+ 3;
777 vPoint
[0].y
= rRect
.yBottom
+ 3;
778 ::GpiMove(hPS
, &vPoint
[0]);
779 vPoint
[1].x
= rRect
.xLeft
+ 3;
780 vPoint
[1].y
= rRect
.yTop
- 4;
781 ::GpiLine(hPS
, &vPoint
[1]);
782 vPoint
[1].x
= rRect
.xRight
- 4;
783 vPoint
[1].y
= rRect
.yTop
- 4;
784 ::GpiLine(hPS
, &vPoint
[1]);
786 } // end of wxDrawBorder
790 , const wxFont
& rFont
798 if (hWnd
== NULLHANDLE
)
802 // The fonts available for Presentation Params are just a few
803 // outline fonts, the rest are available to the GPI, so we must
804 // map the families to one of these three
806 switch(rFont
.GetFamily())
809 strcpy(zFacename
, "Script");
813 strcpy(zFacename
, "WarpSans");
817 strcpy(zFacename
,"Times New Roman");
821 strcpy(zFacename
, "Courier New");
825 strcpy(zFacename
, "Courier New");
831 strcpy(zFacename
, "Helvetica");
835 switch(rFont
.GetWeight())
844 case wxFONTWEIGHT_MAX
:
845 strcpy(zWeight
, "Bold");
849 switch(rFont
.GetStyle())
853 strcpy(zStyle
, "Italic");
860 sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), zFacename
);
861 if (zWeight
[0] != '\0')
864 strcat(zFont
, zWeight
);
866 if (zStyle
[0] != '\0')
869 strcat(zFont
, zStyle
);
871 ::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
) + 1, (PVOID
)zFont
);
872 } // end of wxOS2SetFont
874 // ---------------------------------------------------------------------------
875 // Helper for taking a regular bitmap and giving it a disabled look
876 // ---------------------------------------------------------------------------
877 wxBitmap
wxDisableBitmap(
882 wxMask
* pMask
= rBmp
.GetMask();
885 return(wxNullBitmap
);
887 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
888 SIZEL vSize
= {0, 0};
889 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
890 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
891 BITMAPINFOHEADER2 vHeader
;
895 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
896 HBITMAP hOldBitmap
= NULLHANDLE
;
897 HBITMAP hOldMask
= NULLHANDLE
;
898 HBITMAP hMask
= (HBITMAP
)rBmp
.GetMask()->GetMaskBitmap();
899 unsigned char* pucBits
; // buffer that will contain the bitmap data
900 unsigned char* pucData
; // pointer to use to traverse bitmap data
901 unsigned char* pucBitsMask
; // buffer that will contain the mask data
902 unsigned char* pucDataMask
; // pointer to use to traverse mask data
905 bool bpp16
= (wxDisplayDepth() == 16);
907 memset(&vHeader
, '\0', 16);
910 memset(&vInfo
, '\0', 16);
912 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
913 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
915 vInfo
.cBitCount
= 24; // Set to desired count going in
918 // Create the buffers for data....all wxBitmaps are 24 bit internally
920 int nBytesPerLine
= rBmp
.GetWidth() * 3;
921 int nSizeDWORD
= sizeof(DWORD
);
922 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
928 // Bitmap must be ina double-word alligned address so we may
929 // have some padding to worry about
931 if (nLineBoundary
> 0)
933 nPadding
= nSizeDWORD
- nLineBoundary
;
934 nBytesPerLine
+= nPadding
;
936 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
937 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
938 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
939 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
942 // Extract the bitmap and mask data
944 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
946 vError
= ::WinGetLastError(vHabmain
);
947 sError
= wxPMErrorToStr(vError
);
949 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
950 vInfo
.cBitCount
= 24;
951 if ((lScans
= ::GpiQueryBitmapBits( hPS
953 ,(LONG
)rBmp
.GetHeight()
958 vError
= ::WinGetLastError(vHabmain
);
959 sError
= wxPMErrorToStr(vError
);
961 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
963 vError
= ::WinGetLastError(vHabmain
);
964 sError
= wxPMErrorToStr(vError
);
966 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
967 vInfo
.cBitCount
= 24;
968 if ((lScans
= ::GpiQueryBitmapBits( hPS
970 ,(LONG
)rBmp
.GetHeight()
975 vError
= ::WinGetLastError(vHabmain
);
976 sError
= wxPMErrorToStr(vError
);
978 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
980 vError
= ::WinGetLastError(vHabmain
);
981 sError
= wxPMErrorToStr(vError
);
984 pucDataMask
= pucBitsMask
;
987 // Get the mask value
989 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
991 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
994 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
999 else if (*pucDataMask
== 0xFF) // set to grey
1006 *pucData
= ((unsigned char)(lColor
>> 16));
1011 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1016 else if (*(pucDataMask
+ 1) == 0xFF) // set to grey
1023 *pucData
= ((unsigned char)(lColor
>> 8));
1028 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1033 else if (*(pucDataMask
+ 2) == 0xFF) // set to grey
1040 *pucData
= ((unsigned char)lColor
);
1045 for (j
= 0; j
< nPadding
; j
++)
1053 // Create a new bitmap and set the modified bits
1055 wxBitmap
vNewBmp( rBmp
.GetWidth()
1059 HBITMAP hNewBmp
= (HBITMAP
)vNewBmp
.GetHBITMAP();
1061 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hNewBmp
)) == HBM_ERROR
)
1063 vError
= ::WinGetLastError(vHabmain
);
1064 sError
= wxPMErrorToStr(vError
);
1066 if ((lScansSet
= ::GpiSetBitmapBits( hPS
1068 ,(LONG
)rBmp
.GetHeight()
1074 vError
= ::WinGetLastError(vHabmain
);
1075 sError
= wxPMErrorToStr(vError
);
1079 pNewMask
= new wxMask(pMask
->GetMaskBitmap());
1080 vNewBmp
.SetMask(pNewMask
);
1082 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1083 ::GpiDestroyPS(hPS
);
1087 return(wxNullBitmap
);
1088 } // end of wxDisableBitmap
1090 COLORREF
wxColourToRGB(
1091 const wxColour
& rColor
1094 return(OS2RGB(rColor
.Red(), rColor
.Green(), rColor
.Blue()));
1095 } // end of wxColourToRGB