1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/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"
30 #include "wx/cursor.h"
33 #include "wx/apptrait.h"
36 #include "wx/os2/private.h" // includes <windows.h>
38 // ============================================================================
40 // ============================================================================
42 // ----------------------------------------------------------------------------
43 // functions to work with .INI files
44 // ----------------------------------------------------------------------------
46 // Sleep for nSecs seconds. Attempt a Windows implementation using timers.
47 static bool inTimer
= FALSE
;
49 class wxSleepTimer
: public wxTimer
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
;
336 while(::WinPeekMsg(hab
, &vMsg
, hwndFilter
, 0, 0, PM_REMOVE
))
338 ::WinDispatchMsg(hab
, &vMsg
);
340 return TRUE
;//*** temporary?
344 wxFAIL_MSG(_T("pWnd==NULL !!!"));
345 return FALSE
;//*** temporary?
349 // ----------------------------------------------------------------------------
351 // ----------------------------------------------------------------------------
353 // See also the wxGetMousePosition in window.cpp
354 // Deprecated: use wxPoint wxGetMousePosition() instead
355 void wxGetMousePosition(
362 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
367 // Return TRUE if we have a colour display
368 bool wxColourDisplay()
375 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
376 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
377 ::DevQueryCaps(hdcScreen
, CAPS_COLORS
, 1L, &lColors
);
378 return(lColors
> 1L);
380 // I don't see how the PM display could not be color. Besides, this
381 // was leaking DCs and PSs!!! MN
386 // Returns depth of screen
393 static LONG nDepth
= 0;
395 // The screen colordepth ain't gonna change. No reason to query
398 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
399 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
400 ::DevQueryCaps(hdcScreen
, CAPS_COLOR_PLANES
, 1L, &lPlanes
);
401 ::DevQueryCaps(hdcScreen
, CAPS_COLOR_BITCOUNT
, 1L, &lBitsPerPixel
);
403 nDepth
= (int)(lPlanes
* lBitsPerPixel
);
404 ::DevCloseDC(hdcScreen
);
405 ::WinReleasePS(hpsScreen
);
410 // Get size of display
418 static LONG lWidth
= 0;
419 static LONG lHeight
= 0;
421 // The screen size ain't gonna change either so just cache the values
423 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
424 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
425 ::DevQueryCaps(hdcScreen
, CAPS_WIDTH
, 1L, &lWidth
);
426 ::DevQueryCaps(hdcScreen
, CAPS_HEIGHT
, 1L, &lHeight
);
427 ::DevCloseDC(hdcScreen
);
428 ::WinReleasePS(hpsScreen
);
431 *pWidth
= (int)lWidth
;
433 *pHeight
= (int)lHeight
;
436 void wxDisplaySizeMM(
444 hpsScreen
= ::WinGetScreenPS(HWND_DESKTOP
);
445 hdcScreen
= ::GpiQueryDevice(hpsScreen
);
448 ::DevQueryCaps( hdcScreen
449 ,CAPS_HORIZONTAL_RESOLUTION
454 ::DevQueryCaps( hdcScreen
455 ,CAPS_VERTICAL_RESOLUTION
459 ::DevCloseDC(hdcScreen
);
460 ::WinReleasePS(hpsScreen
);
463 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
465 // This is supposed to return desktop dimensions minus any window
466 // manager panels, menus, taskbars, etc. If there is a way to do that
467 // for this platform please fix this function, otherwise it defaults
468 // to the entire desktop.
471 wxDisplaySize(width
, height
);
474 void wxGUIAppTraits::InitializeGui(unsigned long &ulHab
)
476 ulHab
= ::WinInitialize(0);
479 void wxGUIAppTraits::TerminateGui(unsigned long ulHab
)
481 ::WinTerminate(ulHab
);
484 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
486 static wxToolkitInfo vInfo
;
487 ULONG ulSysInfo
[QSV_MAX
] = {0};
490 vInfo
.shortName
= _T("PM");
491 vInfo
.name
= _T("wxOS2");
492 #ifdef __WXUNIVERSAL__
493 vInfo
.shortName
<< _T("univ");
494 vInfo
.name
<< _T("/wxUniversal");
496 ulrc
= ::DosQuerySysInfo( 1L
499 ,sizeof(ULONG
) * QSV_MAX
503 vInfo
.versionMajor
= ulSysInfo
[QSV_VERSION_MAJOR
] / 10;
504 vInfo
.versionMinor
= ulSysInfo
[QSV_VERSION_MINOR
];
510 // ---------------------------------------------------------------------------
511 // window information functions
512 // ---------------------------------------------------------------------------
514 wxString WXDLLEXPORT
wxGetWindowText( WXHWND hWnd
)
520 long lLen
= ::WinQueryWindowTextLength((HWND
)hWnd
) + 1;
521 ::WinQueryWindowText((HWND
)hWnd
, lLen
, (PSZ
)(wxChar
*)wxStringBuffer(vStr
, lLen
));
527 wxString WXDLLEXPORT
wxGetWindowClass( WXHWND hWnd
)
532 int nLen
= 256; // some starting value
536 int nCount
= ::WinQueryClassName((HWND
)hWnd
, nLen
, (PSZ
)(wxChar
*)wxStringBuffer(vStr
, nLen
));
540 // the class name might have been truncated, retry with larger
553 WXWORD WXDLLEXPORT
wxGetWindowId(
557 return ::WinQueryWindowUShort((HWND
)hWnd
, QWS_ID
);
568 vPoint
[0].x
= rRect
.xLeft
;
569 vPoint
[0].y
= rRect
.yBottom
;
570 ::GpiMove(hPS
, &vPoint
[0]);
571 if (dwStyle
& wxSIMPLE_BORDER
||
572 dwStyle
& wxSTATIC_BORDER
)
574 vPoint
[1].x
= rRect
.xRight
- 1;
575 vPoint
[1].y
= rRect
.yTop
- 1;
583 if (dwStyle
& wxSUNKEN_BORDER
)
585 LINEBUNDLE vLineBundle
;
587 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
588 vLineBundle
.usMixMode
= FM_OVERPAINT
;
589 vLineBundle
.fxWidth
= 2;
590 vLineBundle
.lGeomWidth
= 2;
591 vLineBundle
.usType
= LINETYPE_SOLID
;
592 vLineBundle
.usEnd
= 0;
593 vLineBundle
.usJoin
= 0;
596 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
600 vPoint
[1].x
= rRect
.xRight
- 1;
601 vPoint
[1].y
= rRect
.yTop
- 1;
608 vPoint
[0].x
= rRect
.xLeft
+ 1;
609 vPoint
[0].y
= rRect
.yBottom
+ 1;
610 ::GpiMove(hPS
, &vPoint
[0]);
611 vPoint
[1].x
= rRect
.xRight
- 2;
612 vPoint
[1].y
= rRect
.yTop
- 2;
620 vLineBundle
.lColor
= 0x00000000; // BLACK
621 vLineBundle
.usMixMode
= FM_OVERPAINT
;
622 vLineBundle
.fxWidth
= 2;
623 vLineBundle
.lGeomWidth
= 2;
624 vLineBundle
.usType
= LINETYPE_SOLID
;
625 vLineBundle
.usEnd
= 0;
626 vLineBundle
.usJoin
= 0;
629 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
633 vPoint
[0].x
= rRect
.xLeft
+ 2;
634 vPoint
[0].y
= rRect
.yBottom
+ 2;
635 ::GpiMove(hPS
, &vPoint
[0]);
636 vPoint
[1].x
= rRect
.xLeft
+ 2;
637 vPoint
[1].y
= rRect
.yTop
- 3;
638 ::GpiLine(hPS
, &vPoint
[1]);
639 vPoint
[1].x
= rRect
.xRight
- 3;
640 vPoint
[1].y
= rRect
.yTop
- 3;
641 ::GpiLine(hPS
, &vPoint
[1]);
643 vPoint
[0].x
= rRect
.xLeft
+ 3;
644 vPoint
[0].y
= rRect
.yBottom
+ 3;
645 ::GpiMove(hPS
, &vPoint
[0]);
646 vPoint
[1].x
= rRect
.xLeft
+ 3;
647 vPoint
[1].y
= rRect
.yTop
- 4;
648 ::GpiLine(hPS
, &vPoint
[1]);
649 vPoint
[1].x
= rRect
.xRight
- 4;
650 vPoint
[1].y
= rRect
.yTop
- 4;
651 ::GpiLine(hPS
, &vPoint
[1]);
653 if (dwStyle
& wxDOUBLE_BORDER
)
655 LINEBUNDLE vLineBundle
;
657 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
658 vLineBundle
.usMixMode
= FM_OVERPAINT
;
659 vLineBundle
.fxWidth
= 2;
660 vLineBundle
.lGeomWidth
= 2;
661 vLineBundle
.usType
= LINETYPE_SOLID
;
662 vLineBundle
.usEnd
= 0;
663 vLineBundle
.usJoin
= 0;
666 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
670 vPoint
[1].x
= rRect
.xRight
- 1;
671 vPoint
[1].y
= rRect
.yTop
- 1;
678 vLineBundle
.lColor
= 0x00000000; // WHITE
679 vLineBundle
.usMixMode
= FM_OVERPAINT
;
680 vLineBundle
.fxWidth
= 2;
681 vLineBundle
.lGeomWidth
= 2;
682 vLineBundle
.usType
= LINETYPE_SOLID
;
683 vLineBundle
.usEnd
= 0;
684 vLineBundle
.usJoin
= 0;
687 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
691 vPoint
[0].x
= rRect
.xLeft
+ 2;
692 vPoint
[0].y
= rRect
.yBottom
+ 2;
693 ::GpiMove(hPS
, &vPoint
[0]);
694 vPoint
[1].x
= rRect
.xRight
- 2;
695 vPoint
[1].y
= rRect
.yTop
- 2;
702 vLineBundle
.lColor
= 0x00FFFFFF; // BLACK
703 vLineBundle
.usMixMode
= FM_OVERPAINT
;
704 vLineBundle
.fxWidth
= 2;
705 vLineBundle
.lGeomWidth
= 2;
706 vLineBundle
.usType
= LINETYPE_SOLID
;
707 vLineBundle
.usEnd
= 0;
708 vLineBundle
.usJoin
= 0;
711 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
715 vPoint
[0].x
= rRect
.xLeft
+ 3;
716 vPoint
[0].y
= rRect
.yBottom
+ 3;
717 ::GpiMove(hPS
, &vPoint
[0]);
718 vPoint
[1].x
= rRect
.xRight
- 3;
719 vPoint
[1].y
= rRect
.yTop
- 3;
727 if (dwStyle
& wxRAISED_BORDER
)
729 LINEBUNDLE vLineBundle
;
731 vLineBundle
.lColor
= 0x00000000; // BLACK
732 vLineBundle
.usMixMode
= FM_OVERPAINT
;
733 vLineBundle
.fxWidth
= 2;
734 vLineBundle
.lGeomWidth
= 2;
735 vLineBundle
.usType
= LINETYPE_SOLID
;
736 vLineBundle
.usEnd
= 0;
737 vLineBundle
.usJoin
= 0;
740 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
744 vPoint
[1].x
= rRect
.xRight
- 1;
745 vPoint
[1].y
= rRect
.yTop
- 1;
752 vPoint
[0].x
= rRect
.xLeft
+ 1;
753 vPoint
[0].y
= rRect
.yBottom
+ 1;
754 ::GpiMove(hPS
, &vPoint
[0]);
755 vPoint
[1].x
= rRect
.xRight
- 2;
756 vPoint
[1].y
= rRect
.yTop
- 2;
764 vLineBundle
.lColor
= 0x00FFFFFF; // WHITE
765 vLineBundle
.usMixMode
= FM_OVERPAINT
;
766 vLineBundle
.fxWidth
= 2;
767 vLineBundle
.lGeomWidth
= 2;
768 vLineBundle
.usType
= LINETYPE_SOLID
;
769 vLineBundle
.usEnd
= 0;
770 vLineBundle
.usJoin
= 0;
773 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
777 vPoint
[0].x
= rRect
.xLeft
+ 2;
778 vPoint
[0].y
= rRect
.yBottom
+ 2;
779 ::GpiMove(hPS
, &vPoint
[0]);
780 vPoint
[1].x
= rRect
.xLeft
+ 2;
781 vPoint
[1].y
= rRect
.yTop
- 3;
782 ::GpiLine(hPS
, &vPoint
[1]);
783 vPoint
[1].x
= rRect
.xRight
- 3;
784 vPoint
[1].y
= rRect
.yTop
- 3;
785 ::GpiLine(hPS
, &vPoint
[1]);
787 vPoint
[0].x
= rRect
.xLeft
+ 3;
788 vPoint
[0].y
= rRect
.yBottom
+ 3;
789 ::GpiMove(hPS
, &vPoint
[0]);
790 vPoint
[1].x
= rRect
.xLeft
+ 3;
791 vPoint
[1].y
= rRect
.yTop
- 4;
792 ::GpiLine(hPS
, &vPoint
[1]);
793 vPoint
[1].x
= rRect
.xRight
- 4;
794 vPoint
[1].y
= rRect
.yTop
- 4;
795 ::GpiLine(hPS
, &vPoint
[1]);
797 } // end of wxDrawBorder
801 , const wxFont
& rFont
809 if (hWnd
== NULLHANDLE
)
813 // The fonts available for Presentation Params are just a few
814 // outline fonts, the rest are available to the GPI, so we must
815 // map the families to one of these three
817 switch(rFont
.GetFamily())
820 strcpy(zFacename
, "Script");
824 strcpy(zFacename
, "WarpSans");
828 strcpy(zFacename
,"Times New Roman");
832 strcpy(zFacename
, "Courier New");
836 strcpy(zFacename
, "Courier New");
842 strcpy(zFacename
, "Helvetica");
846 switch(rFont
.GetWeight())
855 case wxFONTWEIGHT_MAX
:
856 strcpy(zWeight
, "Bold");
860 switch(rFont
.GetStyle())
864 strcpy(zStyle
, "Italic");
871 sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), zFacename
);
872 if (zWeight
[0] != '\0')
875 strcat(zFont
, zWeight
);
877 if (zStyle
[0] != '\0')
880 strcat(zFont
, zStyle
);
882 ::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
) + 1, (PVOID
)zFont
);
883 } // end of wxOS2SetFont
885 // ---------------------------------------------------------------------------
886 // Helper for taking a regular bitmap and giving it a disabled look
887 // ---------------------------------------------------------------------------
888 wxBitmap
wxDisableBitmap(
893 wxMask
* pMask
= rBmp
.GetMask();
896 return(wxNullBitmap
);
898 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
899 SIZEL vSize
= {0, 0};
900 HDC hDC
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
901 HPS hPS
= ::GpiCreatePS(vHabmain
, hDC
, &vSize
, PU_PELS
| GPIA_ASSOC
);
902 BITMAPINFOHEADER2 vHeader
;
906 HBITMAP hBitmap
= (HBITMAP
)rBmp
.GetHBITMAP();
907 HBITMAP hOldBitmap
= NULLHANDLE
;
908 HBITMAP hOldMask
= NULLHANDLE
;
909 HBITMAP hMask
= (HBITMAP
)rBmp
.GetMask()->GetMaskBitmap();
910 unsigned char* pucBits
; // buffer that will contain the bitmap data
911 unsigned char* pucData
; // pointer to use to traverse bitmap data
912 unsigned char* pucBitsMask
; // buffer that will contain the mask data
913 unsigned char* pucDataMask
; // pointer to use to traverse mask data
916 bool bpp16
= (wxDisplayDepth() == 16);
918 memset(&vHeader
, '\0', 16);
921 memset(&vInfo
, '\0', 16);
923 vInfo
.cx
= (ULONG
)rBmp
.GetWidth();
924 vInfo
.cy
= (ULONG
)rBmp
.GetHeight();
926 vInfo
.cBitCount
= 24; // Set to desired count going in
929 // Create the buffers for data....all wxBitmaps are 24 bit internally
931 int nBytesPerLine
= rBmp
.GetWidth() * 3;
932 int nSizeDWORD
= sizeof(DWORD
);
933 int nLineBoundary
= nBytesPerLine
% nSizeDWORD
;
939 // Bitmap must be in a double-word aligned address so we may
940 // have some padding to worry about
942 if (nLineBoundary
> 0)
944 nPadding
= nSizeDWORD
- nLineBoundary
;
945 nBytesPerLine
+= nPadding
;
947 pucBits
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
948 memset(pucBits
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
949 pucBitsMask
= (unsigned char *)malloc(nBytesPerLine
* rBmp
.GetHeight());
950 memset(pucBitsMask
, '\0', (nBytesPerLine
* rBmp
.GetHeight()));
953 // Extract the bitmap and mask data
955 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hBitmap
)) == HBM_ERROR
)
957 vError
= ::WinGetLastError(vHabmain
);
958 sError
= wxPMErrorToStr(vError
);
960 ::GpiQueryBitmapInfoHeader(hBitmap
, &vHeader
);
961 vInfo
.cBitCount
= 24;
962 if ((lScans
= ::GpiQueryBitmapBits( hPS
964 ,(LONG
)rBmp
.GetHeight()
969 vError
= ::WinGetLastError(vHabmain
);
970 sError
= wxPMErrorToStr(vError
);
972 if ((hOldMask
= ::GpiSetBitmap(hPS
, hMask
)) == HBM_ERROR
)
974 vError
= ::WinGetLastError(vHabmain
);
975 sError
= wxPMErrorToStr(vError
);
977 ::GpiQueryBitmapInfoHeader(hMask
, &vHeader
);
978 vInfo
.cBitCount
= 24;
979 if ((lScans
= ::GpiQueryBitmapBits( hPS
981 ,(LONG
)rBmp
.GetHeight()
986 vError
= ::WinGetLastError(vHabmain
);
987 sError
= wxPMErrorToStr(vError
);
989 if (( hMask
= ::GpiSetBitmap(hPS
, hOldMask
)) == HBM_ERROR
)
991 vError
= ::WinGetLastError(vHabmain
);
992 sError
= wxPMErrorToStr(vError
);
995 pucDataMask
= pucBitsMask
;
998 // Get the mask value
1000 for (i
= 0; i
< rBmp
.GetHeight(); i
++)
1002 for (j
= 0; j
< rBmp
.GetWidth(); j
++)
1005 if (bpp16
&& *pucDataMask
== 0xF8) // 16 bit display gobblygook
1010 else if (*pucDataMask
== 0xFF) // set to grey
1017 *pucData
= ((unsigned char)(lColor
>> 16));
1022 if (bpp16
&& *(pucDataMask
+ 1) == 0xFC) // 16 bit display gobblygook
1027 else if (*(pucDataMask
+ 1) == 0xFF) // set to grey
1034 *pucData
= ((unsigned char)(lColor
>> 8));
1039 if (bpp16
&& *(pucDataMask
+ 2) == 0xF8) // 16 bit display gobblygook
1044 else if (*(pucDataMask
+ 2) == 0xFF) // set to grey
1051 *pucData
= ((unsigned char)lColor
);
1056 for (j
= 0; j
< nPadding
; j
++)
1064 // Create a new bitmap and set the modified bits
1066 wxBitmap
vNewBmp( rBmp
.GetWidth()
1070 HBITMAP hNewBmp
= (HBITMAP
)vNewBmp
.GetHBITMAP();
1072 if ((hOldBitmap
= ::GpiSetBitmap(hPS
, hNewBmp
)) == HBM_ERROR
)
1074 vError
= ::WinGetLastError(vHabmain
);
1075 sError
= wxPMErrorToStr(vError
);
1077 if ((lScansSet
= ::GpiSetBitmapBits( hPS
1079 ,(LONG
)rBmp
.GetHeight()
1085 vError
= ::WinGetLastError(vHabmain
);
1086 sError
= wxPMErrorToStr(vError
);
1090 pNewMask
= new wxMask(pMask
->GetMaskBitmap());
1091 vNewBmp
.SetMask(pNewMask
);
1093 ::GpiSetBitmap(hPS
, NULLHANDLE
);
1094 ::GpiDestroyPS(hPS
);
1098 return(wxNullBitmap
);
1099 } // end of wxDisableBitmap
1101 COLORREF
wxColourToRGB(
1102 const wxColour
& rColor
1105 return(OS2RGB(rColor
.Red(), rColor
.Green(), rColor
.Blue()));
1106 } // end of wxColourToRGB