From 43543d985b04d065178df50dbbc998786ff97282 Mon Sep 17 00:00:00 2001 From: David Webster Date: Mon, 6 Dec 1999 05:01:46 +0000 Subject: [PATCH 1/1] some os/2 icon-bitmap fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 45 +++++++++++---- include/wx/listctrl.h | 2 +- include/wx/os2/app.h | 2 +- include/wx/os2/bitmap.h | 3 + include/wx/os2/pnghand.h | 28 +++++---- src/generic/imaglist.cpp | 40 +++++++------ src/os2/app.cpp | 15 ++--- src/os2/bitmap.cpp | 122 ++++++++++++++++++++------------------- src/os2/cursor.cpp | 5 +- src/os2/icon.cpp | 6 +- src/os2/pnghand.cpp | 3 +- src/os2/statbmp.cpp | 25 ++++---- src/os2/thread.cpp | 64 ++++++++++---------- 13 files changed, 202 insertions(+), 158 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index a27d2371c3..2df82c842a 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -596,20 +596,20 @@ enum #define wxByte wxUint8 #define wxWord wxUint16 -// base floating point types +// base floating point types // wxFloat32 : 32 bit IEEE float ( 1 sign , 8 exponent bits , 23 fraction bits // wxFloat64 : 64 bit IEEE float ( 1 sign , 11 exponent bits , 52 fraction bits // wxDouble : native fastest representation that has at least wxFloat64 // precision, so use the IEEE types for storage , and this for calculations -typedef float wxFloat32 ; -#if defined( __WXMAC__ ) && defined (__MWERKS__) +typedef float wxFloat32 ; +#if defined( __WXMAC__ ) && defined (__MWERKS__) typedef short double wxFloat64; #else typedef double wxFloat64; #endif -#if defined( __WXMAC__ ) && !defined( __POWERPC__ ) +#if defined( __WXMAC__ ) && !defined( __POWERPC__ ) typedef long double wxDouble; #else typedef double wxDouble ; @@ -636,13 +636,13 @@ typedef float wxFloat32 ; #if defined (__MWERKS__) && ( (__MWERKS__ < 0x0900) || macintosh ) // assembler versions for these #ifdef __POWERPC__ - inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i ) + inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i ) {return (__lhbrx( &i , 0 ) ) ;} - inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i ) + inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i ) {return (__lhbrx( &i , 0 ) ) ;} - inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i ) + inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i ) {return (__lwbrx( &i , 0 ) ) ;} - inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i ) + inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i ) {return (__lwbrx( &i , 0 ) ) ;} #else #pragma parameter __D0 wxUINT16_SWAP_ALWAYS(__D0) @@ -1686,7 +1686,6 @@ typedef unsigned long WXMSGID; typedef void* WXRESULT; typedef int (*WXFARPROC)(); // some windows handles not defined by PM -typedef unsigned long COLORREF; typedef unsigned long HANDLE; typedef unsigned long HICON; typedef unsigned long HFONT; @@ -1700,7 +1699,33 @@ typedef unsigned long HIMAGELIST; typedef unsigned long HGLOBAL; typedef unsigned long DWORD; typedef unsigned short WORD; -#endif + +// WIN32 graphics types for OS/2 GPI + +// RGB under OS2 is more like a PALETTEENTRY struct under Windows so we need a real RGB def +#define OS2RGB(r,g,b) ((DWORD ((BYTE) (r) | ((WORD) (g) << 8)) | (((DWORD)(BYTE)(b)) << 16))) + +typedef unsigned long COLORREF; +#define GetBValue(rgb) ((BYTE)((rgb) >> 16)) +#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8)) +#define GetRValue(rgb) ((BYTE)(rgb)) +#define PALETTEINDEX(i) ((COLORREF)(0x01000000 | (DWORD)(WORD)(i))) +#define PALETTERGB(r,g,b) (0x02000000 | OS2RGB(r,g,b)) +// OS2's RGB/RGB2 is backwards from this +typedef struct tagPALETTEENTRY +{ + char bRed; + char bGreen; + char bBlue; + char bFlags; +} PALETTEENTRY; +typedef struct tagLOGPALETTE +{ + WORD palVersion; + WORD palNumentries; + WORD PALETTEENTRY[1]; +} LOGPALETTE; +#endif //__WXPM__ #if defined(__GNUWIN32__) || defined(__WXWINE__) typedef int (*WXFARPROC)(); diff --git a/include/wx/listctrl.h b/include/wx/listctrl.h index 31b86aac5a..667d975b4d 100644 --- a/include/wx/listctrl.h +++ b/include/wx/listctrl.h @@ -59,7 +59,7 @@ enum wxLIST_NEXT_ALL, // Searches for subsequent item by index wxLIST_NEXT_BELOW, // Searches for an item below the specified item wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item - wxLIST_NEXT_RIGHT, // Searches for an item to the right of the specified item + wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item }; // Alignment flags for Arrange (MSW only except wxLIST_ALIGN_LEFT) diff --git a/include/wx/os2/app.h b/include/wx/os2/app.h index effb025e8b..d003b78ae9 100644 --- a/include/wx/os2/app.h +++ b/include/wx/os2/app.h @@ -22,7 +22,7 @@ class WXDLLEXPORT wxKeyEvent; class WXDLLEXPORT wxLog; WXDLLEXPORT_DATA(extern wxApp*) wxTheApp; -HAB vHabmain; +WXDLLEXPORT_DATA(extern HAB) vHabmain; // Force an exit from main loop void WXDLLEXPORT wxExit(void); diff --git a/include/wx/os2/bitmap.h b/include/wx/os2/bitmap.h index a9946995d9..e3fbd51069 100644 --- a/include/wx/os2/bitmap.h +++ b/include/wx/os2/bitmap.h @@ -272,6 +272,9 @@ public: protected: WXHBITMAP m_hMaskBitmap; DECLARE_DYNAMIC_CLASS(wxMask) +private: + HDC m_hDc; + HPS m_hPs; }; // ---------------------------------------------------------------------------- diff --git a/include/wx/os2/pnghand.h b/include/wx/os2/pnghand.h index 373ab863d0..d95875f12b 100644 --- a/include/wx/os2/pnghand.h +++ b/include/wx/os2/pnghand.h @@ -18,18 +18,26 @@ class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler { - DECLARE_DYNAMIC_CLASS(wxPNGFileHandler) + DECLARE_DYNAMIC_CLASS(wxPNGFileHandler) public: - inline wxPNGFileHandler(void) - { - m_name = "PNG bitmap file"; - m_extension = "bmp"; - m_type = wxBITMAP_TYPE_PNG; - }; + inline wxPNGFileHandler(void) + { + m_sName = "PNG bitmap file"; + m_sExtension = "bmp"; + m_lType = wxBITMAP_TYPE_PNG; + }; - virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight); - virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); + virtual bool LoadFile( wxBitmap* pBitmap + ,const wxString& rName + ,long lFlags + ,int nDesiredWidth + ,int nDesiredHeight + ); + virtual bool SaveFile( wxBitmap* pBitmap + ,const wxString& rName + ,int nType + ,const wxPalette* pPalette = NULL + ); }; #endif diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index 8011b2b648..87eb78dcd3 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -10,7 +10,7 @@ #ifdef __GNUG__ #pragma implementation "imaglist.h" #endif - + // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -58,24 +58,30 @@ int wxImageList::Add( const wxBitmap &bitmap ) return m_images.Number()-1; } -const wxBitmap *wxImageList::GetBitmap( int index ) const +const wxBitmap *wxImageList::GetBitmap( int index ) const { wxNode *node = m_images.Nth( index ); - + wxCHECK_MSG( node, (wxBitmap *) NULL, wxT("wrong index in image list") ); - + return (wxBitmap*)node->Data(); } - + bool wxImageList::Replace( int index, const wxBitmap &bitmap ) { wxNode *node = m_images.Nth( index ); - + wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); wxBitmap* newBitmap = NULL; if (bitmap.IsKindOf(CLASSINFO(wxIcon))) +#if defined(__VISAGECPP__) +//just can't do this in VisualAge now, with all this new Bitmap-Icon stuff +//so construct it from a bitmap object until I can figure this nonsense out. (DW) + newBitmap = new wxBitmap(bitmap) ; +#else newBitmap = new wxIcon( (const wxIcon&) bitmap ); +#endif else newBitmap = new wxBitmap(bitmap) ; @@ -90,25 +96,25 @@ bool wxImageList::Replace( int index, const wxBitmap &bitmap ) m_images.DeleteNode( node ); m_images.Insert( next, newBitmap ); } - + return TRUE; } bool wxImageList::Remove( int index ) { wxNode *node = m_images.Nth( index ); - + wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); - + m_images.DeleteNode( node ); - + return TRUE; } bool wxImageList::RemoveAll() { m_images.Clear(); - + return TRUE; } @@ -116,15 +122,15 @@ bool wxImageList::GetSize( int index, int &width, int &height ) const { width = 0; height = 0; - + wxNode *node = m_images.Nth( index ); - + wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); - + wxBitmap *bm = (wxBitmap*)node->Data(); width = bm->GetWidth(); height = bm->GetHeight(); - + return TRUE; } @@ -132,9 +138,9 @@ bool wxImageList::Draw( int index, wxDC &dc, int x, int y, int flags, bool WXUNUSED(solidBackground) ) { wxNode *node = m_images.Nth( index ); - + wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); - + wxBitmap *bm = (wxBitmap*)node->Data(); if (bm->IsKindOf(CLASSINFO(wxIcon))) diff --git a/src/os2/app.cpp b/src/os2/app.cpp index 9abb82c4ba..72c419454c 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -68,6 +68,7 @@ extern wxCursor* g_globalCursor; HINSTANCE wxhInstance = 0; QMSG svCurrentMsg; wxApp* wxTheApp = NULL; +HAB vHabmain = NULL; // FIXME why not const? and not static? @@ -481,8 +482,8 @@ int wxEntry( bool wxApp::OnInitGui() { - m_vHab = WinInitialize(0); - m_hMq = WinCreateMsgQueue(m_vHab, 0); + vHabmain = WinInitialize(0); + m_hMq = WinCreateMsgQueue(vHabmain, 0); return TRUE; } @@ -530,7 +531,7 @@ bool wxApp::Initialized() // bool wxApp::DoMessage() { - BOOL bRc = ::WinGetMsg(m_vHab, &m_vMsg, HWND(NULL), 0, 0); + BOOL bRc = ::WinGetMsg(vHabmain, &m_vMsg, HWND(NULL), 0, 0); if (bRc == 0) { @@ -592,7 +593,7 @@ bool wxApp::DoMessage() if ( !ProcessMessage((WXMSG *)&vMsg) ) { - ::WinDispatchMsg(m_vHab, &vMsg); + ::WinDispatchMsg(vHabmain, &vMsg); } } svSavedMessages.Empty(); @@ -603,7 +604,7 @@ bool wxApp::DoMessage() // Process the message if (!ProcessMessage((WXMSG *)&svCurrentMsg) ) { - ::WinDispatchMsg(m_vHab, (PQMSG)&svCurrentMsg); + ::WinDispatchMsg(vHabmain, (PQMSG)&svCurrentMsg); } } return TRUE; @@ -633,7 +634,7 @@ int wxApp::MainLoop() #if wxUSE_THREADS wxMutexGuiLeaveOrEnter(); #endif // wxUSE_THREADS - while (!::WinPeekMsg(m_vHab, &svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && + while (!::WinPeekMsg(vHabmain, &svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && ProcessIdle() ) { } @@ -678,7 +679,7 @@ void wxApp::ExitMainLoop() bool wxApp::Pending() { - return (::WinPeekMsg(m_vHab, (PQMSG)&svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) != 0); + return (::WinPeekMsg(vHabmain, (PQMSG)&svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) != 0); } void wxApp::Dispatch() diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index 8b7c34da37..47a6cdd53c 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -95,18 +95,17 @@ bool wxBitmap::CopyFromIconOrCursor( m_refData = pRefData; - refData->m_width = rIcon.GetWidth(); - refData->m_height = rIcon.GetHeight(); - refData->m_depth = wxDisplayDepth(); + pRefData->m_nWidth = rIcon.GetWidth(); + pRefData->m_nHeight = rIcon.GetHeight(); + pRefData->m_nDepth = wxDisplayDepth(); - refData->m_hBitmap = (WXHBITMAP)rIcon.GetHandle(); + pRefData->m_hBitmap = (WXHBITMAP)rIcon.GetHandle(); // no mask??? - refData->m_bitmapMask = new wxMask(); + pRefData->m_pBitmapMask = new wxMask(); #if WXWIN_COMPATIBILITY_2 - refData->m_ok = TRUE; + pRefData->m_bOk = TRUE; #endif // WXWIN_COMPATIBILITY_2 - return(TRUE); } @@ -118,7 +117,7 @@ bool wxBitmap::CopyFromCursor( if (!rCursor.Ok()) return(FALSE); - return CopyFromIconOrCursor(wxGDIImage)rCursor); + return(CopyFromIconOrCursor(rCursor)); } bool wxBitmap::CopyFromIcon( @@ -134,7 +133,7 @@ bool wxBitmap::CopyFromIcon( refData->m_ok = TRUE; #endif // WXWIN_COMPATIBILITY_2 - return CopyFromIconOrCursor(icon); + return CopyFromIconOrCursor(rIcon); } wxBitmap::~wxBitmap() @@ -157,10 +156,10 @@ wxBitmap::wxBitmap( BITMAPINFO2 vInfo; HDC hDc; HPS hPs; - DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; SIZEL vSize = {0, 0}; - wxAssert(vHabmain != NULL); + wxASSERT(vHabmain != NULL); hDc = ::DevOpenDC(vHabmain, OD_MEMORY, (PSZ)"*", 1L, (PDEVOPENDATA)&vDop, 0L); @@ -182,7 +181,7 @@ wxBitmap::wxBitmap( vHeader.ulColorEncoding = 0; vHeader.ulIdentifier = 0; - hPs = ::GpiCreatePS(vHabMain, hdc, &vSize, GPIA_ASSOC | PU_PELS); + hPs = ::GpiCreatePS(vHabmain, hDc, &vSize, GPIA_ASSOC | PU_PELS); if (hPs == 0) { wxLogLastError("GpiCreatePS Failure"); @@ -193,18 +192,18 @@ wxBitmap::wxBitmap( m_refData = pRefData; - refData->m_width = nTheWidth; - refData->m_height = nTheHeight; - refData->m_depth = nNoBits; - refData->m_numColors = 0; - refData->m_selectedInto = NULL; + pRefData->m_nWidth = nTheWidth; + pRefData->m_nHeight = nTheHeight; + pRefData->m_nDepth = nNoBits; + pRefData->m_nNumColors = 0; + pRefData->m_pSelectedInto = NULL; HBITMAP hBmp = ::GpiCreateBitmap(hPs, &vHeader, 0L, NULL, &vInfo); - if ( !hbmp ) + if (!hBmp) { wxLogLastError("CreateBitmap"); } - SetHBITMAP((WXHBITMAP)hbmp); + SetHBITMAP((WXHBITMAP)hBmp); } // Create from XPM data @@ -214,7 +213,7 @@ wxBitmap::wxBitmap( { Init(); -F (void)Create( (void *)ppData + (void)Create( (void *)ppData ,wxBITMAP_TYPE_XPM_DATA ,0 ,0 @@ -277,15 +276,15 @@ bool wxBitmap::Create( BITMAPINFO2 vInfo; HPS hpsScreen; HDC hdcScreen; - DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; SIZEL vSize = {0, 0}; LONG lBitCount; - wxAssert(vHabmain != NULL); + wxASSERT(vHabmain != NULL); hpsScreen = ::WinGetScreenPS(HWND_DESKTOP); hdcScreen = ::GpiQueryDevice(hpsScreen); - ::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, &lBitCount); + ::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitCount); vHeader.cbFix = sizeof(vHeader); vHeader.cx = (USHORT)nW; @@ -305,13 +304,12 @@ bool wxBitmap::Create( vHeader.ulColorEncoding = 0; vHeader.ulIdentifier = 0; - UnRef(); m_refData = new wxBitmapRefData; - GetBitmapData()->m_width = nW; - GetBitmapData()->m_height = nH; - GetBitmapData()->m_depth = nD; + GetBitmapData()->m_nWidth = nW; + GetBitmapData()->m_nHeight = nH; + GetBitmapData()->m_nDepth = nD; if (nD > 0) { @@ -325,13 +323,13 @@ bool wxBitmap::Create( { LONG lPlanes; - ::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, &lPlanes); + ::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes); hBmp = ::GpiCreateBitmap(hpsScreen, &vHeader, 0L, NULL, &vInfo); if (!hBmp) { wxLogLastError("CreateBitmap"); } - GetBitmapData()->m_depth = wxDisplayDepth(); + GetBitmapData()->m_nDepth = wxDisplayDepth(); } SetHBITMAP((WXHBITMAP)hBmp); @@ -362,13 +360,13 @@ bool wxBitmap::LoadFile( ,lType , -1 , -1 - ); + )); } else { wxImage vImage; - if (!vImage.LoadFile(rFilename, lType) || !image.Ok() ) + if (!vImage.LoadFile(rFilename, lType) || !vImage.Ok() ) return(FALSE); *this = vImage.ConvertToBitmap(); @@ -394,20 +392,20 @@ bool wxBitmap::Create( if (!pHandler) { wxLogDebug(wxT("Failed to create bitmap: no bitmap handler for " - "type %d defined."), type); + "type %d defined."), lType); return(FALSE); } m_refData = new wxBitmapRefData; - return(handler->Create( this - ,pData - ,lType - ,nWidth - ,nHeight - ,nDepth - )); + return(pHandler->Create( this + ,pData + ,lType + ,nWidth + ,nHeight + ,nDepth + )); } bool wxBitmap::SaveFile( @@ -495,18 +493,19 @@ wxBitmap wxBitmap::GetBitmapForDC( ,this->GetHeight() ,rDc.GetDepth() ); + WXHBITMAP vOldBitmap; HPS hMemoryPS; HPS hPs; POINTL vPoint[4]; - SIZEL vSize = {0,0} + SIZEL vSize = {0,0}; - hMemoryPS = ::GpiCreatePS(habMain, (HDC)vMemDC.m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPI_ASSOC); - hPs = ::GpiCreatePS(habMain, (HDC)rDc.m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPI_ASSOC); + hMemoryPS = ::GpiCreatePS(vHabmain, (HDC)vMemDC.GetHDC(), &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); + hPs = ::GpiCreatePS(vHabmain, (HDC)rDc.GetHDC(), &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); // TODO: Set the points - rDc.m_oldBitmap = (WXHBITMAP)::GpiSetBitMap(hPs, (HBITMAP)vTmpBitmap.GetHBITMAP()); - :GpiBitBlt(hPs, hMemoryPS, 4L, vPoint, ROP_SRCCOPY | BBO_IGNORE); + vOldBitmap = (WXHBITMAP)::GpiSetBitmap(hPs, (HBITMAP)vTmpBitmap.GetHBITMAP()); + ::GpiBitBlt(hPs, hMemoryPS, 4L, vPoint, ROP_SRCCOPY, BBO_IGNORE); return(vTmpBitmap); } @@ -567,7 +566,7 @@ bool wxMask::Create( ) { BITMAPINFOHEADER2 vHeader; - DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; SIZEL vSize = {0, 0}; POINTL vPoint[4]; @@ -598,7 +597,7 @@ bool wxMask::Create( HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); ::GpiSetBitmap(srcPS, (HBITMAP)m_hMaskBitmap); // TODO: Set the point array - :GpiBitBlt(destPs, srcPS, 4L, vPoint, ROP_SRCCOPY | BBO_IGNORE); + ::GpiBitBlt(destPS, srcPS, 4L, vPoint, ROP_SRCCOPY , BBO_IGNORE); ::GpiDestroyPS(srcPS); ::GpiDestroyPS(destPS); @@ -619,16 +618,19 @@ bool wxMask::Create( } if (rBitmap.Ok() && rBitmap.GetPalette()->Ok()) { - unsigned char red, green, blue; + unsigned char cRed; + unsigned char cGreen; + unsigned char cBlue; + if (rBitmap.GetPalette()->GetRGB( nPaletteIndex - ,&rRed - ,&rGreen - ,&rBlue + ,&cRed + ,&cGreen + ,&cBlue )) { - wxColour vTransparentColour( rRed - ,rGreen - ,rBlue + wxColour vTransparentColour( cRed + ,cGreen + ,cBlue ); return (Create( rBitmap @@ -647,7 +649,7 @@ bool wxMask::Create( ) { BITMAPINFOHEADER2 vHeader; - DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; SIZEL vSize = {0, 0}; POINTL vPoint[4]; @@ -678,7 +680,7 @@ bool wxMask::Create( ,NULL ,NULL ); - ); + HPS srcPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); ::GpiSetBitmap(srcPS, (HBITMAP)rBitmap.GetHBITMAP()); HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); @@ -695,7 +697,7 @@ bool wxMask::Create( vPoint.x = w; vPoint.y = h; - COLORREF col = ::GpiQueryPel(srcPS, w, h); + COLORREF col = ::GpiQueryPel(srcPS, &vPoint); if (col == vMaskColour) { @@ -747,9 +749,9 @@ bool wxBitmapHandler::Load( , int nHeight ) { - wxBitmap* bitmap = wxDynamicCast( pImage - ,wxBitmap - ); + wxBitmap* pBitmap = wxDynamicCast( pImage + ,wxBitmap + ); return(pBitmap ? LoadFile( pBitmap ,rName @@ -795,7 +797,7 @@ bool wxBitmapHandler::LoadFile( , int WXUNUSED(nDesiredHeight) ) { - return(FALSE(; + return(FALSE); } bool wxBitmapHandler::SaveFile( diff --git a/src/os2/cursor.cpp b/src/os2/cursor.cpp index b55237c68b..e3efb12c76 100644 --- a/src/os2/cursor.cpp +++ b/src/os2/cursor.cpp @@ -32,7 +32,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) wxCursorRefData::wxCursorRefData(void) { - m_width = 32; m_height = 32; + m_nWidth = 32; + m_nHeight = 32; m_hCursor = 0 ; m_destroyCursor = FALSE; } @@ -59,9 +60,9 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho M_CURSORDATA->m_destroyCursor = FALSE; M_CURSORDATA->m_hCursor = 0; - M_CURSORDATA->m_ok = FALSE; // TODO: /* + M_CURSORDATA->m_bOK = FALSE; if (flags & wxBITMAP_TYPE_CUR_RESOURCE) { M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0); diff --git a/src/os2/icon.cpp b/src/os2/icon.cpp index ffece6b1f3..b03ecf734e 100644 --- a/src/os2/icon.cpp +++ b/src/os2/icon.cpp @@ -43,8 +43,8 @@ void wxIconRefData::Free() { - if ( m_hIcon ) - ::DestroyIcon((HICON) m_hIcon); + if (m_hIcon) + ::WinFreeFileIcon((HPOINTER)m_hIcon); } // ---------------------------------------------------------------------------- @@ -88,7 +88,7 @@ bool wxIcon::LoadFile( , int nDesiredHeight ) { - wxGDIImageHandler* pHandler = FindHandler(type); + wxGDIImageHandler* pHandler = FindHandler(lType); UnRef(); m_refData = new wxIconRefData; diff --git a/src/os2/pnghand.cpp b/src/os2/pnghand.cpp index 2022d171f5..10f0c013aa 100644 --- a/src/os2/pnghand.cpp +++ b/src/os2/pnghand.cpp @@ -56,8 +56,7 @@ extern "C" void png_write_init PNGARG((png_structp png_ptr)); #endif -void -ima_png_error(png_struct *png_ptr, char *message) +void ima_png_error(png_struct *png_ptr, char *message) { // wxMessageBox(message, "PNG error"); diff --git a/src/os2/statbmp.cpp b/src/os2/statbmp.cpp index a04f0547cd..36d6463c72 100644 --- a/src/os2/statbmp.cpp +++ b/src/os2/statbmp.cpp @@ -47,22 +47,23 @@ bool wxStaticBitmap::Create( Init(); SetName(rName); - if (pParent) parent->AddChild(this); + if (pParent) + pParent->AddChild(this); - m_backgroundColour = parent->GetBackgroundColour() ; - m_foregroundColour = parent->GetForegroundColour() ; + m_backgroundColour = pParent->GetBackgroundColour() ; + m_foregroundColour = pParent->GetForegroundColour() ; - if ( id == -1 ) + if (nId == -1) m_windowId = (int)NewControlId(); else m_windowId = nId; m_windowStyle = lStyle; - int nX= pos.x; - int nY = pos.y; - int nWidth = size.x; - int nHeight = size.y; + int nX= rPos.x; + int nY = rPos.y; + int nWidth = rSize.x; + int nHeight = rSize.y; m_windowStyle = lStyle; @@ -70,9 +71,9 @@ bool wxStaticBitmap::Create( // TODO: create static bitmap control const wxChar* zClassname = wxT("WX_STATIC"); - int nWinstyle ? SS_ICON : SS_BITMAP; + int nWinstyle = m_bIsIcon ? SS_ICON : SS_BITMAP; - m_hWnd = (WXWHND)::WinCreateWindow( pParent->GetHWND() + m_hWnd = (WXHWND)::WinCreateWindow( pParent->GetHWND() ,zClassname ,wxT("") ,nWinstyle | WS_VISIBLE @@ -97,7 +98,7 @@ bool wxStaticBitmap::Create( bool wxStaticBitmap::ImageIsOk() const { - return(m_pImage ** m_pImage->Ok()); + return(m_pImage && m_pImage->Ok()); } void wxStaticBitmap::Free() @@ -131,7 +132,7 @@ void wxStaticBitmap::SetImage( int nH; GetPosition(&nX, &nY); - GetSize(&nW, &nHh); + GetSize(&nW, &nH); ::WinSendMsg( GetHwnd() ,SM_SETHANDLE diff --git a/src/os2/thread.cpp b/src/os2/thread.cpp index 7b4a4643c8..ac5b0d56ca 100644 --- a/src/os2/thread.cpp +++ b/src/os2/thread.cpp @@ -53,21 +53,21 @@ wxMutex* p_wxMainMutex; wxThread* m_pThread; // pointer to the wxWindows thread object // if it's FALSE, some secondary thread is holding the GUI lock -static bool s_bGuiOwnedByMainThread = TRUE; +static bool gs_bGuiOwnedByMainThread = TRUE; // critical section which controls access to all GUI functions: any secondary // thread (i.e. except the main one) must enter this crit section before doing // any GUI calls -static wxCriticalSection *s_pCritsectGui = NULL; +static wxCriticalSection *gs_pCritsectGui = NULL; // critical section which protects s_nWaitingForGui variable -static wxCriticalSection *s_pCritsectWaitingForGui = NULL; +static wxCriticalSection *gs_pCritsectWaitingForGui = NULL; // number of threads waiting for GUI in wxMutexGuiEnter() -static size_t s_nWaitingForGui = 0; +static size_t gs_nWaitingForGui = 0; // are we waiting for a thread termination? -static bool s_bWaitingForThread = FALSE; +static bool gs_bWaitingForThread = FALSE; // ============================================================================ // OS/2 implementation of thread classes @@ -232,7 +232,7 @@ wxCondition::~wxCondition() void wxCondition::Wait() { - (void)m_internal->Wait(SEM_INFINITE_WAIT); + (void)m_internal->Wait(SEM_INDEFINITE_WAIT); } bool wxCondition::Wait( @@ -356,10 +356,10 @@ ULONG wxThreadInternal::OS2ThreadStart( // enter m_critsect before changing the thread state pThread->m_critsect.Enter(); - bool bWasCancelled = thread->m_internal->GetState() == STATE_CANCELED; + bool bWasCancelled = pThread->m_internal->GetState() == STATE_CANCELED; pThread->m_internal->SetState(STATE_EXITED); - thread->m_critsect.Leave(); + pThread->m_critsect.Leave(); pThread->OnExit(); @@ -368,7 +368,7 @@ ULONG wxThreadInternal::OS2ThreadStart( if (pThread->IsDetached() && !bWasCancelled) { // auto delete - delete thread; + delete pThread; } //else: the joinable threads handle will be closed when Wait() is done return dwRet; @@ -380,6 +380,7 @@ void wxThreadInternal::SetPriority( { // translate wxWindows priority to the PM one ULONG ulOS2_Priority; + ULONG ulrc; m_nPriority = nPriority; @@ -582,7 +583,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc) if (IsMain()) { // set flag for wxIsWaitingForThread() - gs_waitingForThread = TRUE; + gs_bWaitingForThread = TRUE; #if wxUSE_GUI wxBeginBusyCursor(); @@ -611,7 +612,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc) if ( IsMain() ) { - gs_waitingForThread = FALSE; + gs_bWaitingForThread = FALSE; #if wxUSE_GUI wxEndBusyCursor(); @@ -626,9 +627,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc) delete this; } - wxASSERT_MSG( (DWORD)rc != STILL_ACTIVE, - wxT("thread must be already terminated.") ); - if ( pRc ) *pRc = rc; @@ -729,10 +727,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) bool wxThreadModule::OnInit() { - s_pCritsectWaitingForGui = new wxCriticalSection(); + gs_pCritsectWaitingForGui = new wxCriticalSection(); - s_pCritsectGui = new wxCriticalSection(); - s_pCritsectGui->Enter(); + gs_pCritsectGui = new wxCriticalSection(); + gs_pCritsectGui->Enter(); PTIB ptib; PPIB ppib; @@ -745,14 +743,14 @@ bool wxThreadModule::OnInit() void wxThreadModule::OnExit() { - if (s_pCritsectGui) + if (gs_pCritsectGui) { - s_pCritsectGui->Leave(); - delete s_pCritsectGui; - s_pCritsectGui = NULL; + gs_pCritsectGui->Leave(); + delete gs_pCritsectGui; + gs_pCritsectGui = NULL; } - wxDELETE(s_pCritsectWaitingForGui); + wxDELETE(gs_pCritsectWaitingForGui); } // ---------------------------------------------------------------------------- @@ -766,24 +764,24 @@ void WXDLLEXPORT wxWakeUpMainThread() void WXDLLEXPORT wxMutexGuiLeave() { - wxCriticalSectionLocker enter(*s_pCritsectWaitingForGui); + wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui); if ( wxThread::IsMain() ) { - s_bGuiOwnedByMainThread = FALSE; + gs_bGuiOwnedByMainThread = FALSE; } else { // decrement the number of waiters now - wxASSERT_MSG( s_nWaitingForGui > 0, + wxASSERT_MSG(gs_nWaitingForGui > 0, wxT("calling wxMutexGuiLeave() without entering it first?") ); - s_nWaitingForGui--; + gs_nWaitingForGui--; wxWakeUpMainThread(); } - s_pCritsectGui->Leave(); + gs_pCritsectGui->Leave(); } void WXDLLEXPORT wxMutexGuiLeaveOrEnter() @@ -791,17 +789,17 @@ void WXDLLEXPORT wxMutexGuiLeaveOrEnter() wxASSERT_MSG( wxThread::IsMain(), wxT("only main thread may call wxMutexGuiLeaveOrEnter()!") ); - wxCriticalSectionLocker enter(*s_pCritsectWaitingForGui); + wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui); - if ( s_nWaitingForGui == 0 ) + if (gs_nWaitingForGui == 0) { // no threads are waiting for GUI - so we may acquire the lock without // any danger (but only if we don't already have it) if (!wxGuiOwnedByMainThread()) { - s_pCritsectGui->Enter(); + gs_pCritsectGui->Enter(); - s_bGuiOwnedByMainThread = TRUE; + gs_bGuiOwnedByMainThread = TRUE; } //else: already have it, nothing to do } @@ -818,12 +816,12 @@ void WXDLLEXPORT wxMutexGuiLeaveOrEnter() bool WXDLLEXPORT wxGuiOwnedByMainThread() { - return s_bGuiOwnedByMainThread; + return gs_bGuiOwnedByMainThread; } bool WXDLLEXPORT wxIsWaitingForThread() { - return s_bWaitingForThread; + return gs_bWaitingForThread; } #endif -- 2.47.2