some os/2 icon-bitmap fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-12-06 05:01:46 +00:00
parent 58b1642453
commit 43543d985b
13 changed files with 202 additions and 158 deletions

View File

@@ -596,20 +596,20 @@ enum
#define wxByte wxUint8 #define wxByte wxUint8
#define wxWord wxUint16 #define wxWord wxUint16
// base floating point types // base floating point types
// wxFloat32 : 32 bit IEEE float ( 1 sign , 8 exponent bits , 23 fraction bits // 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 // wxFloat64 : 64 bit IEEE float ( 1 sign , 11 exponent bits , 52 fraction bits
// wxDouble : native fastest representation that has at least wxFloat64 // wxDouble : native fastest representation that has at least wxFloat64
// precision, so use the IEEE types for storage , and this for calculations // precision, so use the IEEE types for storage , and this for calculations
typedef float wxFloat32 ; typedef float wxFloat32 ;
#if defined( __WXMAC__ ) && defined (__MWERKS__) #if defined( __WXMAC__ ) && defined (__MWERKS__)
typedef short double wxFloat64; typedef short double wxFloat64;
#else #else
typedef double wxFloat64; typedef double wxFloat64;
#endif #endif
#if defined( __WXMAC__ ) && !defined( __POWERPC__ ) #if defined( __WXMAC__ ) && !defined( __POWERPC__ )
typedef long double wxDouble; typedef long double wxDouble;
#else #else
typedef double wxDouble ; typedef double wxDouble ;
@@ -636,13 +636,13 @@ typedef float wxFloat32 ;
#if defined (__MWERKS__) && ( (__MWERKS__ < 0x0900) || macintosh ) #if defined (__MWERKS__) && ( (__MWERKS__ < 0x0900) || macintosh )
// assembler versions for these // assembler versions for these
#ifdef __POWERPC__ #ifdef __POWERPC__
inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i ) inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i )
{return (__lhbrx( &i , 0 ) ) ;} {return (__lhbrx( &i , 0 ) ) ;}
inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i ) inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i )
{return (__lhbrx( &i , 0 ) ) ;} {return (__lhbrx( &i , 0 ) ) ;}
inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i ) inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i )
{return (__lwbrx( &i , 0 ) ) ;} {return (__lwbrx( &i , 0 ) ) ;}
inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i ) inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i )
{return (__lwbrx( &i , 0 ) ) ;} {return (__lwbrx( &i , 0 ) ) ;}
#else #else
#pragma parameter __D0 wxUINT16_SWAP_ALWAYS(__D0) #pragma parameter __D0 wxUINT16_SWAP_ALWAYS(__D0)
@@ -1686,7 +1686,6 @@ typedef unsigned long WXMSGID;
typedef void* WXRESULT; typedef void* WXRESULT;
typedef int (*WXFARPROC)(); typedef int (*WXFARPROC)();
// some windows handles not defined by PM // some windows handles not defined by PM
typedef unsigned long COLORREF;
typedef unsigned long HANDLE; typedef unsigned long HANDLE;
typedef unsigned long HICON; typedef unsigned long HICON;
typedef unsigned long HFONT; typedef unsigned long HFONT;
@@ -1700,7 +1699,33 @@ typedef unsigned long HIMAGELIST;
typedef unsigned long HGLOBAL; typedef unsigned long HGLOBAL;
typedef unsigned long DWORD; typedef unsigned long DWORD;
typedef unsigned short WORD; 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__) #if defined(__GNUWIN32__) || defined(__WXWINE__)
typedef int (*WXFARPROC)(); typedef int (*WXFARPROC)();

View File

@@ -59,7 +59,7 @@ enum
wxLIST_NEXT_ALL, // Searches for subsequent item by index wxLIST_NEXT_ALL, // Searches for subsequent item by index
wxLIST_NEXT_BELOW, // Searches for an item below the specified item 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_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) // Alignment flags for Arrange (MSW only except wxLIST_ALIGN_LEFT)

View File

@@ -22,7 +22,7 @@ class WXDLLEXPORT wxKeyEvent;
class WXDLLEXPORT wxLog; class WXDLLEXPORT wxLog;
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp; WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
HAB vHabmain; WXDLLEXPORT_DATA(extern HAB) vHabmain;
// Force an exit from main loop // Force an exit from main loop
void WXDLLEXPORT wxExit(void); void WXDLLEXPORT wxExit(void);

View File

@@ -272,6 +272,9 @@ public:
protected: protected:
WXHBITMAP m_hMaskBitmap; WXHBITMAP m_hMaskBitmap;
DECLARE_DYNAMIC_CLASS(wxMask) DECLARE_DYNAMIC_CLASS(wxMask)
private:
HDC m_hDc;
HPS m_hPs;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -18,18 +18,26 @@
class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler
{ {
DECLARE_DYNAMIC_CLASS(wxPNGFileHandler) DECLARE_DYNAMIC_CLASS(wxPNGFileHandler)
public: public:
inline wxPNGFileHandler(void) inline wxPNGFileHandler(void)
{ {
m_name = "PNG bitmap file"; m_sName = "PNG bitmap file";
m_extension = "bmp"; m_sExtension = "bmp";
m_type = wxBITMAP_TYPE_PNG; m_lType = wxBITMAP_TYPE_PNG;
}; };
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, virtual bool LoadFile( wxBitmap* pBitmap
int desiredWidth, int desiredHeight); ,const wxString& rName
virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); ,long lFlags
,int nDesiredWidth
,int nDesiredHeight
);
virtual bool SaveFile( wxBitmap* pBitmap
,const wxString& rName
,int nType
,const wxPalette* pPalette = NULL
);
}; };
#endif #endif

View File

@@ -10,7 +10,7 @@
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "imaglist.h" #pragma implementation "imaglist.h"
#endif #endif
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
@@ -58,24 +58,30 @@ int wxImageList::Add( const wxBitmap &bitmap )
return m_images.Number()-1; 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 ); wxNode *node = m_images.Nth( index );
wxCHECK_MSG( node, (wxBitmap *) NULL, wxT("wrong index in image list") ); wxCHECK_MSG( node, (wxBitmap *) NULL, wxT("wrong index in image list") );
return (wxBitmap*)node->Data(); return (wxBitmap*)node->Data();
} }
bool wxImageList::Replace( int index, const wxBitmap &bitmap ) bool wxImageList::Replace( int index, const wxBitmap &bitmap )
{ {
wxNode *node = m_images.Nth( index ); wxNode *node = m_images.Nth( index );
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
wxBitmap* newBitmap = NULL; wxBitmap* newBitmap = NULL;
if (bitmap.IsKindOf(CLASSINFO(wxIcon))) 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 ); newBitmap = new wxIcon( (const wxIcon&) bitmap );
#endif
else else
newBitmap = new wxBitmap(bitmap) ; newBitmap = new wxBitmap(bitmap) ;
@@ -90,25 +96,25 @@ bool wxImageList::Replace( int index, const wxBitmap &bitmap )
m_images.DeleteNode( node ); m_images.DeleteNode( node );
m_images.Insert( next, newBitmap ); m_images.Insert( next, newBitmap );
} }
return TRUE; return TRUE;
} }
bool wxImageList::Remove( int index ) bool wxImageList::Remove( int index )
{ {
wxNode *node = m_images.Nth( index ); wxNode *node = m_images.Nth( index );
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
m_images.DeleteNode( node ); m_images.DeleteNode( node );
return TRUE; return TRUE;
} }
bool wxImageList::RemoveAll() bool wxImageList::RemoveAll()
{ {
m_images.Clear(); m_images.Clear();
return TRUE; return TRUE;
} }
@@ -116,15 +122,15 @@ bool wxImageList::GetSize( int index, int &width, int &height ) const
{ {
width = 0; width = 0;
height = 0; height = 0;
wxNode *node = m_images.Nth( index ); wxNode *node = m_images.Nth( index );
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
wxBitmap *bm = (wxBitmap*)node->Data(); wxBitmap *bm = (wxBitmap*)node->Data();
width = bm->GetWidth(); width = bm->GetWidth();
height = bm->GetHeight(); height = bm->GetHeight();
return TRUE; return TRUE;
} }
@@ -132,9 +138,9 @@ bool wxImageList::Draw( int index, wxDC &dc, int x, int y,
int flags, bool WXUNUSED(solidBackground) ) int flags, bool WXUNUSED(solidBackground) )
{ {
wxNode *node = m_images.Nth( index ); wxNode *node = m_images.Nth( index );
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
wxBitmap *bm = (wxBitmap*)node->Data(); wxBitmap *bm = (wxBitmap*)node->Data();
if (bm->IsKindOf(CLASSINFO(wxIcon))) if (bm->IsKindOf(CLASSINFO(wxIcon)))

View File

@@ -68,6 +68,7 @@ extern wxCursor* g_globalCursor;
HINSTANCE wxhInstance = 0; HINSTANCE wxhInstance = 0;
QMSG svCurrentMsg; QMSG svCurrentMsg;
wxApp* wxTheApp = NULL; wxApp* wxTheApp = NULL;
HAB vHabmain = NULL;
// FIXME why not const? and not static? // FIXME why not const? and not static?
@@ -481,8 +482,8 @@ int wxEntry(
bool wxApp::OnInitGui() bool wxApp::OnInitGui()
{ {
m_vHab = WinInitialize(0); vHabmain = WinInitialize(0);
m_hMq = WinCreateMsgQueue(m_vHab, 0); m_hMq = WinCreateMsgQueue(vHabmain, 0);
return TRUE; return TRUE;
} }
@@ -530,7 +531,7 @@ bool wxApp::Initialized()
// //
bool wxApp::DoMessage() 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) if (bRc == 0)
{ {
@@ -592,7 +593,7 @@ bool wxApp::DoMessage()
if ( !ProcessMessage((WXMSG *)&vMsg) ) if ( !ProcessMessage((WXMSG *)&vMsg) )
{ {
::WinDispatchMsg(m_vHab, &vMsg); ::WinDispatchMsg(vHabmain, &vMsg);
} }
} }
svSavedMessages.Empty(); svSavedMessages.Empty();
@@ -603,7 +604,7 @@ bool wxApp::DoMessage()
// Process the message // Process the message
if (!ProcessMessage((WXMSG *)&svCurrentMsg) ) if (!ProcessMessage((WXMSG *)&svCurrentMsg) )
{ {
::WinDispatchMsg(m_vHab, (PQMSG)&svCurrentMsg); ::WinDispatchMsg(vHabmain, (PQMSG)&svCurrentMsg);
} }
} }
return TRUE; return TRUE;
@@ -633,7 +634,7 @@ int wxApp::MainLoop()
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexGuiLeaveOrEnter(); wxMutexGuiLeaveOrEnter();
#endif // wxUSE_THREADS #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() ) ProcessIdle() )
{ {
} }
@@ -678,7 +679,7 @@ void wxApp::ExitMainLoop()
bool wxApp::Pending() 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() void wxApp::Dispatch()

View File

@@ -95,18 +95,17 @@ bool wxBitmap::CopyFromIconOrCursor(
m_refData = pRefData; m_refData = pRefData;
refData->m_width = rIcon.GetWidth(); pRefData->m_nWidth = rIcon.GetWidth();
refData->m_height = rIcon.GetHeight(); pRefData->m_nHeight = rIcon.GetHeight();
refData->m_depth = wxDisplayDepth(); pRefData->m_nDepth = wxDisplayDepth();
refData->m_hBitmap = (WXHBITMAP)rIcon.GetHandle(); pRefData->m_hBitmap = (WXHBITMAP)rIcon.GetHandle();
// no mask??? // no mask???
refData->m_bitmapMask = new wxMask(); pRefData->m_pBitmapMask = new wxMask();
#if WXWIN_COMPATIBILITY_2 #if WXWIN_COMPATIBILITY_2
refData->m_ok = TRUE; pRefData->m_bOk = TRUE;
#endif // WXWIN_COMPATIBILITY_2 #endif // WXWIN_COMPATIBILITY_2
return(TRUE); return(TRUE);
} }
@@ -118,7 +117,7 @@ bool wxBitmap::CopyFromCursor(
if (!rCursor.Ok()) if (!rCursor.Ok())
return(FALSE); return(FALSE);
return CopyFromIconOrCursor(wxGDIImage)rCursor); return(CopyFromIconOrCursor(rCursor));
} }
bool wxBitmap::CopyFromIcon( bool wxBitmap::CopyFromIcon(
@@ -134,7 +133,7 @@ bool wxBitmap::CopyFromIcon(
refData->m_ok = TRUE; refData->m_ok = TRUE;
#endif // WXWIN_COMPATIBILITY_2 #endif // WXWIN_COMPATIBILITY_2
return CopyFromIconOrCursor(icon); return CopyFromIconOrCursor(rIcon);
} }
wxBitmap::~wxBitmap() wxBitmap::~wxBitmap()
@@ -157,10 +156,10 @@ wxBitmap::wxBitmap(
BITMAPINFO2 vInfo; BITMAPINFO2 vInfo;
HDC hDc; HDC hDc;
HPS hPs; 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}; SIZEL vSize = {0, 0};
wxAssert(vHabmain != NULL); wxASSERT(vHabmain != NULL);
hDc = ::DevOpenDC(vHabmain, OD_MEMORY, (PSZ)"*", 1L, (PDEVOPENDATA)&vDop, 0L); hDc = ::DevOpenDC(vHabmain, OD_MEMORY, (PSZ)"*", 1L, (PDEVOPENDATA)&vDop, 0L);
@@ -182,7 +181,7 @@ wxBitmap::wxBitmap(
vHeader.ulColorEncoding = 0; vHeader.ulColorEncoding = 0;
vHeader.ulIdentifier = 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) if (hPs == 0)
{ {
wxLogLastError("GpiCreatePS Failure"); wxLogLastError("GpiCreatePS Failure");
@@ -193,18 +192,18 @@ wxBitmap::wxBitmap(
m_refData = pRefData; m_refData = pRefData;
refData->m_width = nTheWidth; pRefData->m_nWidth = nTheWidth;
refData->m_height = nTheHeight; pRefData->m_nHeight = nTheHeight;
refData->m_depth = nNoBits; pRefData->m_nDepth = nNoBits;
refData->m_numColors = 0; pRefData->m_nNumColors = 0;
refData->m_selectedInto = NULL; pRefData->m_pSelectedInto = NULL;
HBITMAP hBmp = ::GpiCreateBitmap(hPs, &vHeader, 0L, NULL, &vInfo); HBITMAP hBmp = ::GpiCreateBitmap(hPs, &vHeader, 0L, NULL, &vInfo);
if ( !hbmp ) if (!hBmp)
{ {
wxLogLastError("CreateBitmap"); wxLogLastError("CreateBitmap");
} }
SetHBITMAP((WXHBITMAP)hbmp); SetHBITMAP((WXHBITMAP)hBmp);
} }
// Create from XPM data // Create from XPM data
@@ -214,7 +213,7 @@ wxBitmap::wxBitmap(
{ {
Init(); Init();
F (void)Create( (void *)ppData (void)Create( (void *)ppData
,wxBITMAP_TYPE_XPM_DATA ,wxBITMAP_TYPE_XPM_DATA
,0 ,0
,0 ,0
@@ -277,15 +276,15 @@ bool wxBitmap::Create(
BITMAPINFO2 vInfo; BITMAPINFO2 vInfo;
HPS hpsScreen; HPS hpsScreen;
HDC hdcScreen; 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}; SIZEL vSize = {0, 0};
LONG lBitCount; LONG lBitCount;
wxAssert(vHabmain != NULL); wxASSERT(vHabmain != NULL);
hpsScreen = ::WinGetScreenPS(HWND_DESKTOP); hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
hdcScreen = ::GpiQueryDevice(hpsScreen); hdcScreen = ::GpiQueryDevice(hpsScreen);
::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, &lBitCount); ::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitCount);
vHeader.cbFix = sizeof(vHeader); vHeader.cbFix = sizeof(vHeader);
vHeader.cx = (USHORT)nW; vHeader.cx = (USHORT)nW;
@@ -305,13 +304,12 @@ bool wxBitmap::Create(
vHeader.ulColorEncoding = 0; vHeader.ulColorEncoding = 0;
vHeader.ulIdentifier = 0; vHeader.ulIdentifier = 0;
UnRef(); UnRef();
m_refData = new wxBitmapRefData; m_refData = new wxBitmapRefData;
GetBitmapData()->m_width = nW; GetBitmapData()->m_nWidth = nW;
GetBitmapData()->m_height = nH; GetBitmapData()->m_nHeight = nH;
GetBitmapData()->m_depth = nD; GetBitmapData()->m_nDepth = nD;
if (nD > 0) if (nD > 0)
{ {
@@ -325,13 +323,13 @@ bool wxBitmap::Create(
{ {
LONG lPlanes; LONG lPlanes;
::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, &lPlanes); ::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes);
hBmp = ::GpiCreateBitmap(hpsScreen, &vHeader, 0L, NULL, &vInfo); hBmp = ::GpiCreateBitmap(hpsScreen, &vHeader, 0L, NULL, &vInfo);
if (!hBmp) if (!hBmp)
{ {
wxLogLastError("CreateBitmap"); wxLogLastError("CreateBitmap");
} }
GetBitmapData()->m_depth = wxDisplayDepth(); GetBitmapData()->m_nDepth = wxDisplayDepth();
} }
SetHBITMAP((WXHBITMAP)hBmp); SetHBITMAP((WXHBITMAP)hBmp);
@@ -362,13 +360,13 @@ bool wxBitmap::LoadFile(
,lType ,lType
, -1 , -1
, -1 , -1
); ));
} }
else else
{ {
wxImage vImage; wxImage vImage;
if (!vImage.LoadFile(rFilename, lType) || !image.Ok() ) if (!vImage.LoadFile(rFilename, lType) || !vImage.Ok() )
return(FALSE); return(FALSE);
*this = vImage.ConvertToBitmap(); *this = vImage.ConvertToBitmap();
@@ -394,20 +392,20 @@ bool wxBitmap::Create(
if (!pHandler) if (!pHandler)
{ {
wxLogDebug(wxT("Failed to create bitmap: no bitmap handler for " wxLogDebug(wxT("Failed to create bitmap: no bitmap handler for "
"type %d defined."), type); "type %d defined."), lType);
return(FALSE); return(FALSE);
} }
m_refData = new wxBitmapRefData; m_refData = new wxBitmapRefData;
return(handler->Create( this return(pHandler->Create( this
,pData ,pData
,lType ,lType
,nWidth ,nWidth
,nHeight ,nHeight
,nDepth ,nDepth
)); ));
} }
bool wxBitmap::SaveFile( bool wxBitmap::SaveFile(
@@ -495,18 +493,19 @@ wxBitmap wxBitmap::GetBitmapForDC(
,this->GetHeight() ,this->GetHeight()
,rDc.GetDepth() ,rDc.GetDepth()
); );
WXHBITMAP vOldBitmap;
HPS hMemoryPS; HPS hMemoryPS;
HPS hPs; HPS hPs;
POINTL vPoint[4]; 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); hMemoryPS = ::GpiCreatePS(vHabmain, (HDC)vMemDC.GetHDC(), &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
hPs = ::GpiCreatePS(habMain, (HDC)rDc.m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPI_ASSOC); hPs = ::GpiCreatePS(vHabmain, (HDC)rDc.GetHDC(), &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
// TODO: Set the points // TODO: Set the points
rDc.m_oldBitmap = (WXHBITMAP)::GpiSetBitMap(hPs, (HBITMAP)vTmpBitmap.GetHBITMAP()); vOldBitmap = (WXHBITMAP)::GpiSetBitmap(hPs, (HBITMAP)vTmpBitmap.GetHBITMAP());
:GpiBitBlt(hPs, hMemoryPS, 4L, vPoint, ROP_SRCCOPY | BBO_IGNORE); ::GpiBitBlt(hPs, hMemoryPS, 4L, vPoint, ROP_SRCCOPY, BBO_IGNORE);
return(vTmpBitmap); return(vTmpBitmap);
} }
@@ -567,7 +566,7 @@ bool wxMask::Create(
) )
{ {
BITMAPINFOHEADER2 vHeader; 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}; SIZEL vSize = {0, 0};
POINTL vPoint[4]; POINTL vPoint[4];
@@ -598,7 +597,7 @@ bool wxMask::Create(
HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
::GpiSetBitmap(srcPS, (HBITMAP)m_hMaskBitmap); ::GpiSetBitmap(srcPS, (HBITMAP)m_hMaskBitmap);
// TODO: Set the point array // 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(srcPS);
::GpiDestroyPS(destPS); ::GpiDestroyPS(destPS);
@@ -619,16 +618,19 @@ bool wxMask::Create(
} }
if (rBitmap.Ok() && rBitmap.GetPalette()->Ok()) 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 if (rBitmap.GetPalette()->GetRGB( nPaletteIndex
,&rRed ,&cRed
,&rGreen ,&cGreen
,&rBlue ,&cBlue
)) ))
{ {
wxColour vTransparentColour( rRed wxColour vTransparentColour( cRed
,rGreen ,cGreen
,rBlue ,cBlue
); );
return (Create( rBitmap return (Create( rBitmap
@@ -647,7 +649,7 @@ bool wxMask::Create(
) )
{ {
BITMAPINFOHEADER2 vHeader; 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}; SIZEL vSize = {0, 0};
POINTL vPoint[4]; POINTL vPoint[4];
@@ -678,7 +680,7 @@ bool wxMask::Create(
,NULL ,NULL
,NULL ,NULL
); );
);
HPS srcPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); HPS srcPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
::GpiSetBitmap(srcPS, (HBITMAP)rBitmap.GetHBITMAP()); ::GpiSetBitmap(srcPS, (HBITMAP)rBitmap.GetHBITMAP());
HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC); HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
@@ -695,7 +697,7 @@ bool wxMask::Create(
vPoint.x = w; vPoint.x = w;
vPoint.y = h; vPoint.y = h;
COLORREF col = ::GpiQueryPel(srcPS, w, h); COLORREF col = ::GpiQueryPel(srcPS, &vPoint);
if (col == vMaskColour) if (col == vMaskColour)
{ {
@@ -747,9 +749,9 @@ bool wxBitmapHandler::Load(
, int nHeight , int nHeight
) )
{ {
wxBitmap* bitmap = wxDynamicCast( pImage wxBitmap* pBitmap = wxDynamicCast( pImage
,wxBitmap ,wxBitmap
); );
return(pBitmap ? LoadFile( pBitmap return(pBitmap ? LoadFile( pBitmap
,rName ,rName
@@ -795,7 +797,7 @@ bool wxBitmapHandler::LoadFile(
, int WXUNUSED(nDesiredHeight) , int WXUNUSED(nDesiredHeight)
) )
{ {
return(FALSE(; return(FALSE);
} }
bool wxBitmapHandler::SaveFile( bool wxBitmapHandler::SaveFile(

View File

@@ -32,7 +32,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
wxCursorRefData::wxCursorRefData(void) wxCursorRefData::wxCursorRefData(void)
{ {
m_width = 32; m_height = 32; m_nWidth = 32;
m_nHeight = 32;
m_hCursor = 0 ; m_hCursor = 0 ;
m_destroyCursor = FALSE; 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_destroyCursor = FALSE;
M_CURSORDATA->m_hCursor = 0; M_CURSORDATA->m_hCursor = 0;
M_CURSORDATA->m_ok = FALSE;
// TODO: // TODO:
/* /*
M_CURSORDATA->m_bOK = FALSE;
if (flags & wxBITMAP_TYPE_CUR_RESOURCE) if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
{ {
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0); M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);

View File

@@ -43,8 +43,8 @@
void wxIconRefData::Free() void wxIconRefData::Free()
{ {
if ( m_hIcon ) if (m_hIcon)
::DestroyIcon((HICON) m_hIcon); ::WinFreeFileIcon((HPOINTER)m_hIcon);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -88,7 +88,7 @@ bool wxIcon::LoadFile(
, int nDesiredHeight , int nDesiredHeight
) )
{ {
wxGDIImageHandler* pHandler = FindHandler(type); wxGDIImageHandler* pHandler = FindHandler(lType);
UnRef(); UnRef();
m_refData = new wxIconRefData; m_refData = new wxIconRefData;

View File

@@ -56,8 +56,7 @@ extern "C" void png_write_init PNGARG((png_structp png_ptr));
#endif #endif
void void ima_png_error(png_struct *png_ptr, char *message)
ima_png_error(png_struct *png_ptr, char *message)
{ {
// wxMessageBox(message, "PNG error"); // wxMessageBox(message, "PNG error");

View File

@@ -47,22 +47,23 @@ bool wxStaticBitmap::Create(
Init(); Init();
SetName(rName); SetName(rName);
if (pParent) parent->AddChild(this); if (pParent)
pParent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour() ; m_backgroundColour = pParent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ; m_foregroundColour = pParent->GetForegroundColour() ;
if ( id == -1 ) if (nId == -1)
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = nId; m_windowId = nId;
m_windowStyle = lStyle; m_windowStyle = lStyle;
int nX= pos.x; int nX= rPos.x;
int nY = pos.y; int nY = rPos.y;
int nWidth = size.x; int nWidth = rSize.x;
int nHeight = size.y; int nHeight = rSize.y;
m_windowStyle = lStyle; m_windowStyle = lStyle;
@@ -70,9 +71,9 @@ bool wxStaticBitmap::Create(
// TODO: create static bitmap control // TODO: create static bitmap control
const wxChar* zClassname = wxT("WX_STATIC"); 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 ,zClassname
,wxT("") ,wxT("")
,nWinstyle | WS_VISIBLE ,nWinstyle | WS_VISIBLE
@@ -97,7 +98,7 @@ bool wxStaticBitmap::Create(
bool wxStaticBitmap::ImageIsOk() const bool wxStaticBitmap::ImageIsOk() const
{ {
return(m_pImage ** m_pImage->Ok()); return(m_pImage && m_pImage->Ok());
} }
void wxStaticBitmap::Free() void wxStaticBitmap::Free()
@@ -131,7 +132,7 @@ void wxStaticBitmap::SetImage(
int nH; int nH;
GetPosition(&nX, &nY); GetPosition(&nX, &nY);
GetSize(&nW, &nHh); GetSize(&nW, &nH);
::WinSendMsg( GetHwnd() ::WinSendMsg( GetHwnd()
,SM_SETHANDLE ,SM_SETHANDLE

View File

@@ -53,21 +53,21 @@ wxMutex* p_wxMainMutex;
wxThread* m_pThread; // pointer to the wxWindows thread object wxThread* m_pThread; // pointer to the wxWindows thread object
// if it's FALSE, some secondary thread is holding the GUI lock // 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 // 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 // thread (i.e. except the main one) must enter this crit section before doing
// any GUI calls // any GUI calls
static wxCriticalSection *s_pCritsectGui = NULL; static wxCriticalSection *gs_pCritsectGui = NULL;
// critical section which protects s_nWaitingForGui variable // 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() // 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? // are we waiting for a thread termination?
static bool s_bWaitingForThread = FALSE; static bool gs_bWaitingForThread = FALSE;
// ============================================================================ // ============================================================================
// OS/2 implementation of thread classes // OS/2 implementation of thread classes
@@ -232,7 +232,7 @@ wxCondition::~wxCondition()
void wxCondition::Wait() void wxCondition::Wait()
{ {
(void)m_internal->Wait(SEM_INFINITE_WAIT); (void)m_internal->Wait(SEM_INDEFINITE_WAIT);
} }
bool wxCondition::Wait( bool wxCondition::Wait(
@@ -356,10 +356,10 @@ ULONG wxThreadInternal::OS2ThreadStart(
// enter m_critsect before changing the thread state // enter m_critsect before changing the thread state
pThread->m_critsect.Enter(); 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); pThread->m_internal->SetState(STATE_EXITED);
thread->m_critsect.Leave(); pThread->m_critsect.Leave();
pThread->OnExit(); pThread->OnExit();
@@ -368,7 +368,7 @@ ULONG wxThreadInternal::OS2ThreadStart(
if (pThread->IsDetached() && !bWasCancelled) if (pThread->IsDetached() && !bWasCancelled)
{ {
// auto delete // auto delete
delete thread; delete pThread;
} }
//else: the joinable threads handle will be closed when Wait() is done //else: the joinable threads handle will be closed when Wait() is done
return dwRet; return dwRet;
@@ -380,6 +380,7 @@ void wxThreadInternal::SetPriority(
{ {
// translate wxWindows priority to the PM one // translate wxWindows priority to the PM one
ULONG ulOS2_Priority; ULONG ulOS2_Priority;
ULONG ulrc;
m_nPriority = nPriority; m_nPriority = nPriority;
@@ -582,7 +583,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
if (IsMain()) if (IsMain())
{ {
// set flag for wxIsWaitingForThread() // set flag for wxIsWaitingForThread()
gs_waitingForThread = TRUE; gs_bWaitingForThread = TRUE;
#if wxUSE_GUI #if wxUSE_GUI
wxBeginBusyCursor(); wxBeginBusyCursor();
@@ -611,7 +612,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
if ( IsMain() ) if ( IsMain() )
{ {
gs_waitingForThread = FALSE; gs_bWaitingForThread = FALSE;
#if wxUSE_GUI #if wxUSE_GUI
wxEndBusyCursor(); wxEndBusyCursor();
@@ -626,9 +627,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
delete this; delete this;
} }
wxASSERT_MSG( (DWORD)rc != STILL_ACTIVE,
wxT("thread must be already terminated.") );
if ( pRc ) if ( pRc )
*pRc = rc; *pRc = rc;
@@ -729,10 +727,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
bool wxThreadModule::OnInit() bool wxThreadModule::OnInit()
{ {
s_pCritsectWaitingForGui = new wxCriticalSection(); gs_pCritsectWaitingForGui = new wxCriticalSection();
s_pCritsectGui = new wxCriticalSection(); gs_pCritsectGui = new wxCriticalSection();
s_pCritsectGui->Enter(); gs_pCritsectGui->Enter();
PTIB ptib; PTIB ptib;
PPIB ppib; PPIB ppib;
@@ -745,14 +743,14 @@ bool wxThreadModule::OnInit()
void wxThreadModule::OnExit() void wxThreadModule::OnExit()
{ {
if (s_pCritsectGui) if (gs_pCritsectGui)
{ {
s_pCritsectGui->Leave(); gs_pCritsectGui->Leave();
delete s_pCritsectGui; delete gs_pCritsectGui;
s_pCritsectGui = NULL; gs_pCritsectGui = NULL;
} }
wxDELETE(s_pCritsectWaitingForGui); wxDELETE(gs_pCritsectWaitingForGui);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -766,24 +764,24 @@ void WXDLLEXPORT wxWakeUpMainThread()
void WXDLLEXPORT wxMutexGuiLeave() void WXDLLEXPORT wxMutexGuiLeave()
{ {
wxCriticalSectionLocker enter(*s_pCritsectWaitingForGui); wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui);
if ( wxThread::IsMain() ) if ( wxThread::IsMain() )
{ {
s_bGuiOwnedByMainThread = FALSE; gs_bGuiOwnedByMainThread = FALSE;
} }
else else
{ {
// decrement the number of waiters now // decrement the number of waiters now
wxASSERT_MSG( s_nWaitingForGui > 0, wxASSERT_MSG(gs_nWaitingForGui > 0,
wxT("calling wxMutexGuiLeave() without entering it first?") ); wxT("calling wxMutexGuiLeave() without entering it first?") );
s_nWaitingForGui--; gs_nWaitingForGui--;
wxWakeUpMainThread(); wxWakeUpMainThread();
} }
s_pCritsectGui->Leave(); gs_pCritsectGui->Leave();
} }
void WXDLLEXPORT wxMutexGuiLeaveOrEnter() void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
@@ -791,17 +789,17 @@ void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
wxASSERT_MSG( wxThread::IsMain(), wxASSERT_MSG( wxThread::IsMain(),
wxT("only main thread may call wxMutexGuiLeaveOrEnter()!") ); 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 // no threads are waiting for GUI - so we may acquire the lock without
// any danger (but only if we don't already have it) // any danger (but only if we don't already have it)
if (!wxGuiOwnedByMainThread()) if (!wxGuiOwnedByMainThread())
{ {
s_pCritsectGui->Enter(); gs_pCritsectGui->Enter();
s_bGuiOwnedByMainThread = TRUE; gs_bGuiOwnedByMainThread = TRUE;
} }
//else: already have it, nothing to do //else: already have it, nothing to do
} }
@@ -818,12 +816,12 @@ void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
bool WXDLLEXPORT wxGuiOwnedByMainThread() bool WXDLLEXPORT wxGuiOwnedByMainThread()
{ {
return s_bGuiOwnedByMainThread; return gs_bGuiOwnedByMainThread;
} }
bool WXDLLEXPORT wxIsWaitingForThread() bool WXDLLEXPORT wxIsWaitingForThread()
{ {
return s_bWaitingForThread; return gs_bWaitingForThread;
} }
#endif #endif