Catching up to new common class interfaces.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2002-04-05 22:09:25 +00:00
parent 0f5fa11181
commit 3437f881c4
12 changed files with 585 additions and 351 deletions

View File

@@ -85,9 +85,10 @@ protected:
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase* CreateTool( int vId virtual wxToolBarToolBase* CreateTool( int vId
,const wxBitmap& rBitmap1 ,const wxString& rsLabel
,const wxBitmap& rBitmap2 ,const wxBitmap& rBitmapNormal
,bool bToggle ,const wxBitmap& rBitmapDisabled
,wxItemKind vKind
,wxObject* pClientData ,wxObject* pClientData
,const wxString& rShortHelpString ,const wxString& rShortHelpString
,const wxString& rLongHelpString ,const wxString& rLongHelpString

View File

@@ -67,7 +67,7 @@ public:
virtual void Restore(void); virtual void Restore(void);
virtual void SendSizeEvent(void); virtual void SendSizeEvent(void);
virtual void SetIcon(const wxIcon& rIcon); virtual void SetIcon(const wxIcon& rIcon);
inline virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); } virtual void SetIcons(const wxIconBundle& rIcons);
virtual bool Show(bool bShow = TRUE); virtual bool Show(bool bShow = TRUE);
virtual bool ShowFullScreen( bool bShow virtual bool ShowFullScreen( bool bShow

View File

@@ -496,6 +496,7 @@ protected:
bool m_bBackgroundTransparent:1; bool m_bBackgroundTransparent:1;
bool m_bMouseInWindow:1; bool m_bMouseInWindow:1;
bool m_bDoubleClickAllowed:1; bool m_bDoubleClickAllowed:1;
bool m_bLastKeydownProcessed:1;
bool m_bWinCaptured:1; bool m_bWinCaptured:1;
WXDWORD m_dwExStyle; WXDWORD m_dwExStyle;

View File

@@ -68,7 +68,7 @@ void wxBitmapRefData::Free()
if (m_hBitmap) if (m_hBitmap)
{ {
if ( !::GpiDeleteBitmap((HBITMAP)m_hBitmap) ) if (!::GpiDeleteBitmap((HBITMAP)m_hBitmap))
{ {
wxLogLastError("GpiDeleteBitmap(hbitmap)"); wxLogLastError("GpiDeleteBitmap(hbitmap)");
} }
@@ -85,10 +85,6 @@ void wxBitmapRefData::Free()
// this function should be called from all wxBitmap ctors // this function should be called from all wxBitmap ctors
void wxBitmap::Init() void wxBitmap::Init()
{ {
// m_refData = NULL; done in the base class ctor
if (wxTheBitmapList)
wxTheBitmapList->AddBitmap(this);
} // end of wxBitmap::Init } // end of wxBitmap::Init
bool wxBitmap::CopyFromIconOrCursor( bool wxBitmap::CopyFromIconOrCursor(
@@ -147,15 +143,13 @@ bool wxBitmap::CopyFromIcon(
wxBitmap::~wxBitmap() wxBitmap::~wxBitmap()
{ {
if (wxTheBitmapList)
wxTheBitmapList->DeleteObject(this);
} // end of wxBitmap::~wxBitmap } // end of wxBitmap::~wxBitmap
wxBitmap::wxBitmap( wxBitmap::wxBitmap(
const char zBits[] const char zBits[]
, int nTheWidth , int nWidth
, int nTheHeight , int nHeight
, int nNoBits , int nDepth
) )
{ {
Init(); Init();
@@ -167,48 +161,104 @@ wxBitmap::wxBitmap(
HPS hPs; HPS hPs;
DEVOPENSTRUC 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};
char* pzData;
wxASSERT(vHabmain != NULL); wxASSERT(vHabmain != NULL);
m_refData = pRefData;
pRefData->m_nWidth = nWidth;
pRefData->m_nHeight = nHeight;
pRefData->m_nDepth = nDepth;
pRefData->m_nNumColors = 0;
pRefData->m_pSelectedInto = NULL;
hDc = ::DevOpenDC(vHabmain, OD_MEMORY, (PSZ)"*", 1L, (PDEVOPENDATA)&vDop, 0L); hDc = ::DevOpenDC(vHabmain, OD_MEMORY, (PSZ)"*", 1L, (PDEVOPENDATA)&vDop, 0L);
vHeader.cbFix = sizeof(vHeader);
vHeader.cx = (USHORT)nTheWidth;
vHeader.cy = (USHORT)nTheHeight;
vHeader.cPlanes = 1L;
vHeader.cBitCount = nNoBits;
vHeader.ulCompression = BCA_UNCOMP;
vHeader.cxResolution = 0;
vHeader.cyResolution = 0;
vHeader.cclrUsed = 0;
vHeader.cclrImportant = 0;
vHeader.usUnits = BRU_METRIC;
vHeader.usRecording = BRA_BOTTOMUP;
vHeader.usRendering = BRH_NOTHALFTONED;
vHeader.cSize1 = 0;
vHeader.cSize2 = 0;
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) if (hPs == 0)
{ {
wxLogLastError("GpiCreatePS Failure"); wxLogLastError("GpiCreatePS Failure");
} }
m_refData = pRefData; if (nDepth == 1)
{
//
// We assume that it is in XBM format which is not quite the same as
// the format CreateBitmap() wants because the order of bytes in the
// line is inversed!
//
const size_t nBytesPerLine = (nWidth + 7) / 8;
const size_t nPadding = nBytesPerLine % 2;
const size_t nLen = nHeight * (nPadding + nBytesPerLine);
const char* pzSrc = zBits;
int nRows;
size_t nCols;
pRefData->m_nWidth = nTheWidth; pzData = (char *)malloc(nLen);
pRefData->m_nHeight = nTheHeight;
pRefData->m_nDepth = nNoBits; char* pzDst = pzData;
pRefData->m_nNumColors = 0;
pRefData->m_pSelectedInto = NULL; for (nRows = 0; nRows < nHeight; nRows++)
{
for (nCols = 0; nCols < nBytesPerLine; nCols++)
{
unsigned char ucVal = *pzSrc++;
unsigned char ucReversed = 0;
int nBits;
for (nBits = 0; nBits < 8; nBits++)
{
ucReversed <<= 1;
ucReversed |= (ucVal & 0x01);
ucVal >>= 1;
}
*pzDst++ = ucReversed;
}
if (nPadding)
*pzDst++ = 0;
}
}
else
{
//
// Bits should already be in Windows standard format
//
pzData = (char *)zBits; // const_cast is harmless
}
memset(&vHeader, '\0', sizeof(BITMAPINFOHEADER2));
vHeader.cbFix = sizeof(vHeader);
vHeader.cx = (USHORT)nWidth;
vHeader.cy = (USHORT)nHeight;
vHeader.cPlanes = 1L;
vHeader.cBitCount = nDepth;
vHeader.usReserved = 0;
vHeader.ulCompression = BCA_UNCOMP;
vHeader.usRecording = BRA_BOTTOMUP;
vHeader.usRendering = BRH_NOTHALFTONED;
vHeader.ulColorEncoding = BCE_RGB;
vHeader.ulIdentifier = 0;
memset(&vInfo, '\0', sizeof(BITMAPINFO2));
vInfo.cbFix = sizeof(vInfo);
vInfo.cx = (USHORT)nWidth;
vInfo.cy = (USHORT)nHeight;
vInfo.cPlanes = 1L;
vInfo.cBitCount = nDepth;
vInfo.usReserved = 0;
vInfo.ulCompression = BCA_UNCOMP;
vInfo.usRecording = BRA_BOTTOMUP;
vInfo.usRendering = BRH_NOTHALFTONED;
vInfo.ulColorEncoding = BCE_RGB;
vInfo.ulIdentifier = 0;
HBITMAP hBmp = ::GpiCreateBitmap(hPs, &vHeader, CBM_INIT, (PBYTE)pzData, &vInfo);
HBITMAP hBmp = ::GpiCreateBitmap(hPs, &vHeader, 0L, NULL, &vInfo);
if (!hBmp) if (!hBmp)
{ {
wxLogLastError("CreateBitmap"); wxLogLastError("CreateBitmap");
} }
::WinReleasePS(hPs);
SetHBITMAP((WXHBITMAP)hBmp); SetHBITMAP((WXHBITMAP)hBmp);
} // end of wxBitmap::wxBitmap } // end of wxBitmap::wxBitmap
@@ -460,335 +510,493 @@ bool wxBitmap::SaveFile(
// wxImage-wxBitmap convertion // wxImage-wxBitmap convertion
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) bool wxBitmap::CreateFromImage (
const wxImage& rImage
, int nDepth
)
{ {
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") ) wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
// TODO: int nSizeLimit = 1024 * 768 * 3;
/* int nWidth = GetWidth();
int sizeLimit = 1024*768*3; int nBmpHeight = GetHeight();
int nBytePerLine = nWidth * 3;
int nSizeDWORD = sizeof(DWORD);
int nLineBoundary = nBytePerLine % nSizeDWORD;
int nPadding = 0;
// width and height of the device-dependent bitmap if (nLineBoundary > 0)
int width = GetWidth();
int bmpHeight = GetHeight();
// calc the number of bytes per scanline and padding
int bytePerLine = width*3;
int sizeDWORD = sizeof( DWORD );
int lineBoundary = bytePerLine % sizeDWORD;
int padding = 0;
if( lineBoundary > 0 )
{ {
padding = sizeDWORD - lineBoundary; nPadding = nSizeDWORD - nLineBoundary;
bytePerLine += padding; nBytePerLine += nPadding;
} }
// calc the number of DIBs and heights of DIBs
int numDIB = 1; //
int hRemain = 0; // Calc the number of DIBs and heights of DIBs
int height = sizeLimit/bytePerLine; //
if( height >= bmpHeight ) int nNumDIB = 1;
height = bmpHeight; int nHRemain = 0;
int nHeight = nSizeLimit / nBytePerLine;
if (nHeight >= nBmpHeight)
nHeight = nBmpHeight;
else else
{ {
numDIB = bmpHeight / height; nNumDIB = nBmpHeight / nHeight;
hRemain = bmpHeight % height; nHRemain = nBmpHeight % nHeight;
if( hRemain >0 ) numDIB++; if (nHRemain > 0)
nNumDIB++;
} }
// set bitmap parameters //
wxBitmap bitmap; // Set bitmap parameters
wxCHECK_MSG( Ok(), bitmap, wxT("invalid image") ); //
bitmap.SetWidth( width ); wxCHECK_MSG(rImage.Ok(), FALSE, wxT("invalid image"));
bitmap.SetHeight( bmpHeight ); SetWidth(nWidth);
bitmap.SetDepth( wxDisplayDepth() ); SetHeight(nBmpHeight);
if (nDepth == -1)
nDepth = wxDisplayDepth();
SetDepth(nDepth);
// create a DIB header #if wxUSE_PALETTE
int headersize = sizeof(BITMAPINFOHEADER); //
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize ); // Copy the palette from the source image
wxCHECK_MSG( lpDIBh, bitmap, wxT("could not allocate memory for DIB header") ); //
SetPalette(rImage.GetPalette());
#endif // wxUSE_PALETTE
//
// Create a DIB header
//
BITMAPINFOHEADER2 vHeader;
//
// Fill in the DIB header // Fill in the DIB header
lpDIBh->bmiHeader.biSize = headersize; //
lpDIBh->bmiHeader.biWidth = (DWORD)width; memset(&vHeader, '\0', sizeof(BITMAPINFOHEADER2));
lpDIBh->bmiHeader.biHeight = (DWORD)(-height); vHeader.cbFix = sizeof(vHeader);
lpDIBh->bmiHeader.biSizeImage = bytePerLine*height; vHeader.cx = (USHORT)nWidth;
// the general formula for biSizeImage: vHeader.cy = (USHORT)nHeight;
// ( ( ( ((DWORD)width*24) +31 ) & ~31 ) >> 3 ) * height; vHeader.cPlanes = 1L;
lpDIBh->bmiHeader.biPlanes = 1; vHeader.cBitCount = 24;
lpDIBh->bmiHeader.biBitCount = 24; vHeader.ulCompression = BCA_UNCOMP;
lpDIBh->bmiHeader.biCompression = BI_RGB; vHeader.cbImage = nBytePerLine * nHeight;
lpDIBh->bmiHeader.biClrUsed = 0; vHeader.cclrUsed = 0;
//
// These seem not really needed for our purpose here. // These seem not really needed for our purpose here.
lpDIBh->bmiHeader.biClrImportant = 0; //
lpDIBh->bmiHeader.biXPelsPerMeter = 0; vHeader.cxResolution = 0;
lpDIBh->bmiHeader.biYPelsPerMeter = 0; vHeader.cyResolution = 0;
// memory for DIB data vHeader.cclrImportant = 0;
unsigned char *lpBits; vHeader.usUnits = BRU_METRIC;
lpBits = (unsigned char *)malloc( lpDIBh->bmiHeader.biSizeImage ); vHeader.usReserved = 0;
if( !lpBits ) vHeader.cSize1 = 0;
vHeader.cSize2 = 0;
vHeader.usRecording = BRA_BOTTOMUP;
vHeader.usRendering = BRH_NOTHALFTONED;
vHeader.ulColorEncoding = BCE_RGB;
vHeader.ulIdentifier = 0;
//
// Memory for DIB data
//
unsigned char* pucBits;
pucBits = (unsigned char *)malloc(vHeader.cbImage);
if(!pucBits)
{ {
wxFAIL_MSG( wxT("could not allocate memory for DIB") ); wxFAIL_MSG(wxT("could not allocate memory for DIB"));
free( lpDIBh ); return FALSE;
return bitmap;
} }
// create and set the device-dependent bitmap //
HDC hdc = ::GetDC(NULL); // Create and set the device-dependent bitmap
HDC memdc = ::CreateCompatibleDC( hdc ); //
HBITMAP hbitmap; DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
hbitmap = ::CreateCompatibleBitmap( hdc, width, bmpHeight ); SIZEL vSize = {0, 0};
::SelectObject( memdc, hbitmap); HDC hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
HPS hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
HBITMAP hBmp;
HBITMAP hBmpOld;
// copy image data into DIB data and then into DDB (in a loop) hBmp = ::GpiCreateBitmap( hPS
unsigned char *data = GetData(); ,&vHeader
int i, j, n; ,0L
int origin = 0; ,NULL
unsigned char *ptdata = data; ,NULL
unsigned char *ptbits; );
hBmpOld = ::GpiSetBitmap(hPS, hBmp);
for( n=0; n<numDIB; n++ ) #if wxUSE_PALETTE
HPAL hOldPalette = NULLHANDLE;
if (rImage.GetPalette().Ok())
{ {
if( numDIB > 1 && n == numDIB-1 && hRemain > 0 ) hOldPalette = ::GpiSelectPalette(hPS, (HPAL)rImage.GetPalette().GetHPALETTE());
{ }
// redefine height and size of the (possibly) last smaller DIB #endif // wxUSE_PALETTE
// memory is not reallocated
height = hRemain;
lpDIBh->bmiHeader.biHeight = (DWORD)(-height);
lpDIBh->bmiHeader.biSizeImage = bytePerLine*height;
}
ptbits = lpBits;
for( j=0; j<height; j++ ) //
// Copy image data into DIB data and then into DDB (in a loop)
//
unsigned char* pData = rImage.GetData();
int i;
int j;
int n;
int nOrigin = 0;
unsigned char* ptdata = pData;
unsigned char* ptbits;
for (n = 0; n < nNumDIB; n++)
{
if (nNumDIB > 1 && n == nNumDIB - 1 && nHRemain > 0)
{ {
for( i=0; i<width; i++ ) //
// Redefine height and size of the (possibly) last smaller DIB
// memory is not reallocated
//
nHeight = nHRemain;
vHeader.cy = (DWORD)(nHeight);
vHeader.cbImage = nBytePerLine * nHeight;
}
ptbits = pucBits;
for (j = 0; j < nHeight; j++)
{
for (i = 0; i < nWidth; i++)
{ {
*(ptbits++) = *(ptdata+2); *(ptbits++) = *(ptdata + 2);
*(ptbits++) = *(ptdata+1); *(ptbits++) = *(ptdata + 1);
*(ptbits++) = *(ptdata ); *(ptbits++) = *(ptdata);
ptdata += 3; ptdata += 3;
} }
for( i=0; i< padding; i++ ) *(ptbits++) = 0; for (i = 0; i < nPadding; i++)
*(ptbits++) = 0;
} }
::StretchDIBits( memdc, 0, origin, width, height,\
0, 0, width, height, lpBits, lpDIBh, DIB_RGB_COLORS, SRCCOPY);
origin += height;
// if numDIB = 1, lines below can also be used
// hbitmap = CreateDIBitmap( hdc, &(lpDIBh->bmiHeader), CBM_INIT, lpBits, lpDIBh, DIB_RGB_COLORS );
// The above line is equivalent to the following two lines.
// hbitmap = ::CreateCompatibleBitmap( hdc, width, height );
// ::SetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS);
// or the following lines
// hbitmap = ::CreateCompatibleBitmap( hdc, width, height );
// HDC memdc = ::CreateCompatibleDC( hdc );
// ::SelectObject( memdc, hbitmap);
// ::SetDIBitsToDevice( memdc, 0, 0, width, height,
// 0, 0, 0, height, (void *)lpBits, lpDIBh, DIB_RGB_COLORS);
// ::SelectObject( memdc, 0 );
// ::DeleteDC( memdc );
}
bitmap.SetHBITMAP( (WXHBITMAP) hbitmap );
// similarly, created an mono-bitmap for the possible mask //
if( HasMask() ) // Have to do something similar to WIN32's StretchDIBits, use GpiBitBlt
//
POINTL vPoint[4] = { 0, nOrigin,
nWidth, nHeight,
0, 0, nWidth, nHeight
};
::GpiBitBlt( hPS
,hPS
,4
,vPoint
,ROP_SRCCOPY
,BBO_IGNORE
);
nOrigin += nHeight;
}
SetHBITMAP((WXHBITMAP)hBmp);
#if wxUSE_PALETTE
if (hOldPalette)
::GpiSelectPalette(hPS, hOldPalette);
#endif // wxUSE_PALETTE
//
// Similarly, created an mono-bitmap for the possible mask
//
if (rImage.HasMask())
{ {
hbitmap = ::CreateBitmap( (WORD)width, (WORD)bmpHeight, 1, 1, NULL ); memset(&vHeader, '\0', sizeof(BITMAPINFOHEADER2));
::SelectObject( memdc, hbitmap); vHeader.cbFix = sizeof(BITMAPINFOHEADER2);
if( numDIB == 1 ) height = bmpHeight; vHeader.cx = nWidth;
else height = sizeLimit/bytePerLine; vHeader.cy = nHeight;
lpDIBh->bmiHeader.biHeight = (DWORD)(-height); vHeader.cPlanes = 1;
lpDIBh->bmiHeader.biSizeImage = bytePerLine*height; vHeader.cBitCount = 1;
origin = 0; hBmp = ::GpiCreateBitmap( hPS
unsigned char r = GetMaskRed(); ,&vHeader
unsigned char g = GetMaskGreen(); ,0L
unsigned char b = GetMaskBlue(); ,NULL
unsigned char zero = 0, one = 255; ,NULL
ptdata = data; );
for( n=0; n<numDIB; n++ ) hBmpOld = ::GpiSetBitmap(hPS, hBmp);
if (nNumDIB == 1)
nHeight = nBmpHeight;
else
nHeight = nSizeLimit / nBytePerLine;
vHeader.cy = (DWORD)(nHeight);
vHeader.cbImage = nBytePerLine * nHeight;
nOrigin = 0;
unsigned char cRed = rImage.GetMaskRed();
unsigned char cGreen = rImage.GetMaskGreen();
unsigned char cBlue = rImage.GetMaskBlue();
unsigned char cZero = 0;
unsigned char cOne = 255;
ptdata = pData;
for (n = 0; n < nNumDIB; n++)
{ {
if( numDIB > 1 && n == numDIB - 1 && hRemain > 0 ) if (nNumDIB > 1 && n == nNumDIB - 1 && nHRemain > 0)
{ {
// redefine height and size of the (possibly) last smaller DIB //
// Redefine height and size of the (possibly) last smaller DIB
// memory is not reallocated // memory is not reallocated
height = hRemain; //
lpDIBh->bmiHeader.biHeight = (DWORD)(-height); nHeight = nHRemain;
lpDIBh->bmiHeader.biSizeImage = bytePerLine*height; vHeader.cy = (DWORD)(nHeight);
vHeader.cbImage = nBytePerLine * nHeight;
} }
ptbits = lpBits; ptbits = pucBits;
for( int j=0; j<height; j++ ) for (int j = 0; j < nHeight; j++)
{ {
for(i=0; i<width; i++ ) for (i = 0; i < nWidth; i++)
{ {
if( (*(ptdata++)!=r) | (*(ptdata++)!=g) | (*(ptdata++)!=b) ) if ((*(ptdata++) != cRed) || (*(ptdata++) != cGreen) || (*(ptdata++) != cBlue))
{ {
*(ptbits++) = one; *(ptbits++) = cOne;
*(ptbits++) = one; *(ptbits++) = cOne;
*(ptbits++) = one; *(ptbits++) = cOne;
} }
else else
{ {
*(ptbits++) = zero; *(ptbits++) = cZero;
*(ptbits++) = zero; *(ptbits++) = cZero;
*(ptbits++) = zero; *(ptbits++) = cZero;
} }
} }
for( i=0; i< padding; i++ ) *(ptbits++) = zero; for (i = 0; i < nPadding; i++)
*(ptbits++) = cZero;
} }
::StretchDIBits( memdc, 0, origin, width, height,\ POINTL vPoint[4] = { 0, nOrigin,
0, 0, width, height, lpBits, lpDIBh, DIB_RGB_COLORS, SRCCOPY); nWidth, nHeight,
origin += height; 0, 0, nWidth, nHeight
};
::GpiBitBlt( hPS
,hPS
,4
,vPoint
,ROP_SRCCOPY
,BBO_IGNORE
);
nOrigin += nHeight;
} }
// create a wxMask object
wxMask *mask = new wxMask(); //
mask->SetMaskBitmap( (WXHBITMAP) hbitmap ); // Create a wxMask object
bitmap.SetMask( mask ); //
wxMask* pMask = new wxMask();
pMask->SetMaskBitmap((WXHBITMAP)hBmp);
SetMask(pMask);
hBmpOld = ::GpiSetBitmap(hPS, hBmp);
} }
// free allocated resources //
::SelectObject( memdc, 0 ); // Free allocated resources
::DeleteDC( memdc ); //
::ReleaseDC(NULL, hdc); ::GpiSetBitmap(hPS, NULLHANDLE);
free(lpDIBh); ::GpiDestroyPS(hPS);
free(lpBits); ::DevCloseDC(hDC);
free(pucBits);
// check the wxBitmap object
if( bitmap.GetHBITMAP() )
bitmap.SetOk( TRUE );
else
bitmap.SetOk( FALSE );
*/
return TRUE; return TRUE;
} } // end of wxBitmap::CreateFromImage
wxImage wxBitmap::ConvertToImage() const wxImage wxBitmap::ConvertToImage() const
{ {
wxImage image; wxImage vImage;
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
// create an wxImage object //
int width = GetWidth(); // Create an wxImage object
int height = GetHeight(); //
image.Create( width, height ); int nWidth = GetWidth();
unsigned char *data = image.GetData(); int nHeight = GetHeight();
if( !data ) int nDevWidth;
int nDevHeight;
int nBytePerLine = nWidth * 3;
int nSizeDWORD = sizeof(DWORD);
int nLineBoundary = nBytePerLine % nSizeDWORD;
int nPadding = 0;
unsigned char* pData;
unsigned char* lpBits;
long lScans;
BITMAPINFOHEADER2 vDIBh;
BITMAPINFO2 vDIBInfo;
HDC hDCMem;
PSZ pszData[4] = { "Display", NULL, NULL, NULL };
HPS hPSMem;
HPS hPS;
SIZEL vSizlPage = {0,0};
HBITMAP hBitmap;
vImage.Create( nWidth
,nHeight
);
pData = vImage.GetData();
if(!pData)
{ {
wxFAIL_MSG( wxT("could not allocate data for image") ); wxFAIL_MSG( wxT("could not allocate data for image") );
return wxNullImage; return wxNullImage;
} }
if(nLineBoundary > 0)
{
nPadding = nSizeDWORD - nLineBoundary;
nBytePerLine += nPadding;
}
wxDisplaySize( &nDevWidth
,&nDevHeight
);
//
// Create and fill a DIB header
//
memset(&vDIBh, '\0', sizeof(BITMAPINFOHEADER2));
vDIBh.cbFix = sizeof(BITMAPINFOHEADER2);
vDIBh.cx = nWidth;
vDIBh.cy = nHeight;
vDIBh.cPlanes = 1;
vDIBh.cbImage = nBytePerLine * nHeight;
vDIBh.cBitCount = 24;
// calc the number of bytes per scanline and padding in the DIB memset(&vDIBInfo, '\0', sizeof(BITMAPINFO2));
int bytePerLine = width*3; vDIBInfo.cbFix = sizeof(BITMAPINFO2);
int sizeDWORD = sizeof( DWORD ); vDIBInfo.cPlanes = 1;
int lineBoundary = bytePerLine % sizeDWORD; vDIBInfo.cBitCount = 24;
int padding = 0; vDIBInfo.ulCompression = BCA_UNCOMP;
if( lineBoundary > 0 ) vDIBInfo.usReserved = 0;
vDIBInfo.usRecording = BRA_BOTTOMUP;
vDIBInfo.usRendering = BRH_NOTHALFTONED;
vDIBInfo.ulColorEncoding = BCE_RGB;
vDIBInfo.ulIdentifier = 0;
lpBits = (unsigned char *)malloc(vDIBh.cbImage);
if (!lpBits)
{ {
padding = sizeDWORD - lineBoundary; wxFAIL_MSG(wxT("could not allocate data for DIB"));
bytePerLine += padding; free(pData);
} return wxNullImage;
// TODO:
/*
// create a DIB header
int headersize = sizeof(BITMAPINFOHEADER);
LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
if( !lpDIBh )
{
wxFAIL_MSG( wxT("could not allocate data for DIB header") );
free( data );
return;
}
// Fill in the DIB header
lpDIBh->bmiHeader.biSize = headersize;
lpDIBh->bmiHeader.biWidth = width;
lpDIBh->bmiHeader.biHeight = -height;
lpDIBh->bmiHeader.biSizeImage = bytePerLine * height;
lpDIBh->bmiHeader.biPlanes = 1;
lpDIBh->bmiHeader.biBitCount = 24;
lpDIBh->bmiHeader.biCompression = BI_RGB;
lpDIBh->bmiHeader.biClrUsed = 0;
// These seem not really needed for our purpose here.
lpDIBh->bmiHeader.biClrImportant = 0;
lpDIBh->bmiHeader.biXPelsPerMeter = 0;
lpDIBh->bmiHeader.biYPelsPerMeter = 0;
// memory for DIB data
unsigned char *lpBits;
lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage );
if( !lpBits )
{
wxFAIL_MSG( wxT("could not allocate data for DIB") );
free( data );
free( lpDIBh );
return;
} }
// copy data from the device-dependent bitmap to the DIB //
HDC hdc = ::GetDC(NULL); // Copy data from the device-dependent bitmap to the DIB
HBITMAP hbitmap; //
hbitmap = (HBITMAP) bitmap.GetHBITMAP(); hDCMem = ::DevOpenDC( vHabmain
::GetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS ); ,OD_MEMORY
,"*"
,4
,(PDEVOPENDATA)pszData
,NULLHANDLE
);
hPSMem = ::GpiCreatePS( vHabmain
,hDCMem
,&vSizlPage
,PU_PELS | GPIA_ASSOC | GPIT_MICRO
);
hBitmap = ::GpiCreateBitmap( hPSMem
,&vDIBh
,0L
,NULL
,NULL
);
lScans = ::GpiQueryBitmapBits( hPSMem
,0L
,(LONG)nHeight
,(PBYTE)lpBits
,&vDIBInfo
);
// copy DIB data into the wxImage object //
int i, j; // Copy DIB data into the wxImage object
unsigned char *ptdata = data; //
unsigned char *ptbits = lpBits; int i;
for( i=0; i<height; i++ ) int j;
unsigned char* ptdata = pData;
unsigned char* ptbits = lpBits;
for (i = 0; i < nHeight; i++)
{ {
for( j=0; j<width; j++ ) for (j = 0; j < nWidth; j++)
{ {
*(ptdata++) = *(ptbits+2); *(ptdata++) = *(ptbits+2);
*(ptdata++) = *(ptbits+1); *(ptdata++) = *(ptbits+1);
*(ptdata++) = *(ptbits ); *(ptdata++) = *(ptbits );
ptbits += 3; ptbits += 3;
} }
ptbits += padding; ptbits += nPadding;
} }
// similarly, set data according to the possible mask bitmap //
if( bitmap.GetMask() && bitmap.GetMask()->GetMaskBitmap() ) // Similarly, set data according to the possible mask bitmap
//
if (GetMask() && GetMask()->GetMaskBitmap())
{ {
hbitmap = (HBITMAP) bitmap.GetMask()->GetMaskBitmap(); hBitmap = (HBITMAP)GetMask()->GetMaskBitmap();
// memory DC created, color set, data copied, and memory DC deleted
HDC memdc = ::CreateCompatibleDC( hdc ); //
::SetTextColor( memdc, RGB( 0, 0, 0 ) ); // Memory DC/PS created, color set, data copied, and memory DC/PS deleted
::SetBkColor( memdc, RGB( 255, 255, 255 ) ); //
::GetDIBits( memdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS ); HDC hMemDC = ::DevOpenDC( vHabmain
::DeleteDC( memdc ); ,OD_MEMORY
// background color set to RGB(16,16,16) in consistent with wxGTK ,"*"
unsigned char r=16, g=16, b=16; ,4
ptdata = data; ,(PDEVOPENDATA)pszData
,NULLHANDLE
);
HPS hMemPS = ::GpiCreatePS( vHabmain
,hMemDC
,&vSizlPage
,PU_PELS | GPIA_ASSOC | GPIT_MICRO
);
::GpiSetColor(hMemPS, OS2RGB(0, 0, 0));
::GpiSetBackColor(hMemPS, OS2RGB(255, 255, 255) );
::GpiQueryBitmapBits( hPSMem
,0L
,(LONG)nHeight
,(PBYTE)lpBits
,&vDIBInfo
);
::GpiDestroyPS(hMemPS);
::DevCloseDC(hMemDC);
//
// Background color set to RGB(16,16,16) in consistent with wxGTK
//
unsigned char ucRed = 16;
unsigned char ucGreen = 16;
unsigned char ucBlue = 16;
ptdata = pData;
ptbits = lpBits; ptbits = lpBits;
for( i=0; i<height; i++ ) for (i = 0; i < nHeight; i++)
{ {
for( j=0; j<width; j++ ) for (j = 0; j < nWidth; j++)
{ {
if( *ptbits != 0 ) if (*ptbits != 0)
ptdata += 3; ptdata += 3;
else else
{ {
*(ptdata++) = r; *(ptdata++) = ucRed;
*(ptdata++) = g; *(ptdata++) = ucGreen;
*(ptdata++) = b; *(ptdata++) = ucBlue;
} }
ptbits += 3; ptbits += 3;
} }
ptbits += padding; ptbits += nPadding;
} }
SetMaskColour( r, g, b ); vImage.SetMaskColour( ucRed
SetMask( TRUE ); ,ucGreen
,ucBlue
);
vImage.SetMask(TRUE);
} }
else else
{ {
SetMask( FALSE ); vImage.SetMask(FALSE);
} }
// free allocated resources
::ReleaseDC(NULL, hdc); //
free(lpDIBh); // Free allocated resources
//
::GpiDestroyPS(hPSMem);
::DevCloseDC(hDCMem);
free(lpBits); free(lpBits);
*/ return vImage;
} // end of wxBitmap::ConvertToImage
return image;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// sub bitmap extraction // sub bitmap extraction
@@ -924,34 +1132,11 @@ void wxBitmap::SetMask(
GetBitmapData()->m_pBitmapMask = pMask; GetBitmapData()->m_pBitmapMask = pMask;
} // end of wxBitmap::SetMask } // end of wxBitmap::SetMask
//
// Will try something for OS/2 but not really sure how close
// to the msw intent this is.
//
wxBitmap wxBitmap::GetBitmapForDC( wxBitmap wxBitmap::GetBitmapForDC(
wxDC& rDc wxDC& rDc
) const ) const
{ {
wxMemoryDC vMemDC; return(*this);
wxBitmap vTmpBitmap( this->GetWidth()
,this->GetHeight()
,rDc.GetDepth()
);
WXHBITMAP vOldBitmap;
HPS hMemoryPS;
HPS hPs;
POINTL vPoint[4];
SIZEL vSize = {0,0};
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
vOldBitmap = (WXHBITMAP)::GpiSetBitmap(hPs, (HBITMAP)vTmpBitmap.GetHBITMAP());
::GpiBitBlt(hPs, hMemoryPS, 4L, vPoint, ROP_SRCCOPY, BBO_IGNORE);
return(vTmpBitmap);
} // end of wxBitmap::GetBitmapForDC } // end of wxBitmap::GetBitmapForDC
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1361,3 +1546,4 @@ HBITMAP wxInvertMask(
return hBmpInvMask; return hBmpInvMask;
} // end of WxWinGdi_InvertMask } // end of WxWinGdi_InvertMask

View File

@@ -323,7 +323,7 @@ bool wxBitmapDataObject::SetData(
return FALSE; return FALSE;
} }
m_bitmap = vImage.ConvertToBitmap(); m_bitmap = wxBitmap(vImage);
#endif //wxUSE_STREAMS #endif //wxUSE_STREAMS
return m_bitmap.Ok(); return m_bitmap.Ok();
@@ -335,7 +335,7 @@ void wxBitmapDataObject::DoConvertToPng()
return; return;
#if wxUSE_STREAMS #if wxUSE_STREAMS
wxImage vImage(m_bitmap); wxImage vImage = m_bitmap.ConvertToImage();
wxPNGHandler vHandler; wxPNGHandler vHandler;
wxCountingOutputStream vCount; wxCountingOutputStream vCount;

View File

@@ -923,9 +923,10 @@ bool wxFrame::HandlePaint()
// //
// Icons in PM are the same as "pointers" // Icons in PM are the same as "pointers"
// //
const wxIcon& vIcon = GetIcon();
HPOINTER hIcon; HPOINTER hIcon;
if (m_icon.Ok()) if (vIcon.Ok())
hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L); hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
else else
hIcon = (HPOINTER)m_hDefaultIcon; hIcon = (HPOINTER)m_hDefaultIcon;
@@ -1379,9 +1380,10 @@ MRESULT wxFrame::OS2WindowProc(
case CM_QUERYDRAGIMAGE: case CM_QUERYDRAGIMAGE:
{ {
const wxIcon& vIcon = GetIcon();
HPOINTER hIcon; HPOINTER hIcon;
if (m_icon.Ok()) if (vIcon.Ok())
hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L); hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L);
else else
hIcon = (HPOINTER)m_hDefaultIcon; hIcon = (HPOINTER)m_hDefaultIcon;

View File

@@ -281,7 +281,7 @@ int wxListBox::DoAppend(
wxOwnerDrawn* pNewItem = CreateItem(nIndex); // dummy argument wxOwnerDrawn* pNewItem = CreateItem(nIndex); // dummy argument
pNewItem->SetName(rsItem); pNewItem->SetName(rsItem);
m_aItems.Add(pNewItem); m_aItems.Insert(pNewItem, nIndex);
::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)((SHORT)nIndex), MPFROMP(pNewItem)); ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)((SHORT)nIndex), MPFROMP(pNewItem));
pNewItem->SetFont(GetFont()); pNewItem->SetFont(GetFont());
} }
@@ -331,24 +331,18 @@ void wxListBox::DoSetItems(
// //
// First delete old items // First delete old items
// //
size_t lUi = m_aItems.Count(); WX_CLEAR_ARRAY(m_aItems);
while (lUi-- != 0)
{
delete m_aItems[lUi];
}
m_aItems.Empty();
// //
// Then create new ones // Then create new ones
// //
for (lUi = 0; lUi < (size_t)m_nNumItems; lUi++) for (size_t ui = 0; ui < (size_t)m_nNumItems; ui++)
{ {
wxOwnerDrawn* pNewItem = CreateItem(lUi); wxOwnerDrawn* pNewItem = CreateItem(ui);
pNewItem->SetName(raChoices[lUi]); pNewItem->SetName(raChoices[ui]);
m_aItems.Add(pNewItem); m_aItems.Add(pNewItem);
::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(lUi), MPFROMP(pNewItem)); ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(ui), MPFROMP(pNewItem));
} }
} }
#endif // wxUSE_OWNER_DRAWN #endif // wxUSE_OWNER_DRAWN
@@ -596,8 +590,25 @@ void wxListBox::DoInsertItems(
int nItems = asItems.GetCount(); int nItems = asItems.GetCount();
for (int i = 0; i < nItems; i++) for (int i = 0; i < nItems; i++)
::WinSendMsg(GetHwnd(), LM_INSERTITEM, MPFROMLONG((LONG)(i + nPos)), (MPARAM)asItems[i].c_str()); {
m_nNumItems += nItems; int nIndex = (int)::WinSendMsg( GetHwnd()
,LM_INSERTITEM
,MPFROMLONG((LONG)(i + nPos))
,(MPARAM)asItems[i].c_str()
);
wxOwnerDrawn* pNewItem = CreateItem(nIndex);
pNewItem->SetName(asItems[i]);
pNewItem->SetFont(GetFont());
m_aItems.Insert(pNewItem, nIndex);
::WinSendMsg( GetHwnd()
,LM_SETITEMHANDLE
,(MPARAM)((SHORT)nIndex)
,MPFROMP(pNewItem)
);
m_nNumItems += nItems;
}
} // end of wxListBox::DoInsertItems } // end of wxListBox::DoInsertItems
void wxListBox::SetString( void wxListBox::SetString(

View File

@@ -250,9 +250,11 @@ COMMONOBJS = \
..\common\$D\hashmap.obj \ ..\common\$D\hashmap.obj \
..\common\$D\helpbase.obj \ ..\common\$D\helpbase.obj \
..\common\$D\http.obj \ ..\common\$D\http.obj \
..\common\$D\iconbndl.obj \
..\common\$D\imagall.obj \ ..\common\$D\imagall.obj \
..\common\$D\imagbmp.obj \ ..\common\$D\imagbmp.obj \
..\common\$D\image.obj \ ..\common\$D\image.obj \
..\common\$D\imagfill.obj \
..\common\$D\imaggif.obj \ ..\common\$D\imaggif.obj \
..\common\$D\imagiff.obj \ ..\common\$D\imagiff.obj \
..\common\$D\imagjpeg.obj \ ..\common\$D\imagjpeg.obj \
@@ -384,9 +386,11 @@ COMLIBOBJS2 = \
hashmap.obj \ hashmap.obj \
helpbase.obj \ helpbase.obj \
http.obj \ http.obj \
iconbndl.obj \
imagall.obj \ imagall.obj \
imagbmp.obj \ imagbmp.obj \
image.obj \ image.obj \
imagfill.obj \
imaggif.obj \ imaggif.obj \
imagiff.obj \ imagiff.obj \
imagjpeg.obj \ imagjpeg.obj \
@@ -410,11 +414,11 @@ COMLIBOBJS2 = \
mstream.obj \ mstream.obj \
nbkbase.obj \ nbkbase.obj \
object.obj \ object.obj \
odbc.obj \ odbc.obj
paper.obj \
popupcmn.obj
COMLIBOBJS3 = \ COMLIBOBJS3 = \
paper.obj \
popupcmn.obj \
prntbase.obj \ prntbase.obj \
process.obj \ process.obj \
protocol.obj \ protocol.obj \
@@ -752,9 +756,11 @@ $(COMLIBOBJS2):
copy ..\common\$D\hashmap.obj copy ..\common\$D\hashmap.obj
copy ..\common\$D\helpbase.obj copy ..\common\$D\helpbase.obj
copy ..\common\$D\http.obj copy ..\common\$D\http.obj
copy ..\common\$D\iconbndl.obj
copy ..\common\$D\imagall.obj copy ..\common\$D\imagall.obj
copy ..\common\$D\imagbmp.obj copy ..\common\$D\imagbmp.obj
copy ..\common\$D\image.obj copy ..\common\$D\image.obj
copy ..\common\$D\imagfill.obj
copy ..\common\$D\imaggif.obj copy ..\common\$D\imaggif.obj
copy ..\common\$D\imagiff.obj copy ..\common\$D\imagiff.obj
copy ..\common\$D\imagjpeg.obj copy ..\common\$D\imagjpeg.obj
@@ -779,10 +785,10 @@ $(COMLIBOBJS2):
copy ..\common\$D\nbkbase.obj copy ..\common\$D\nbkbase.obj
copy ..\common\$D\object.obj copy ..\common\$D\object.obj
copy ..\common\$D\odbc.obj copy ..\common\$D\odbc.obj
copy ..\common\$D\paper.obj
copy ..\common\$D\popupcmn.obj
$(COMLIBOBJS3): $(COMLIBOBJS3):
copy ..\common\$D\paper.obj
copy ..\common\$D\popupcmn.obj
copy ..\common\$D\prntbase.obj copy ..\common\$D\prntbase.obj
copy ..\common\$D\process.obj copy ..\common\$D\process.obj
copy ..\common\$D\protocol.obj copy ..\common\$D\protocol.obj

View File

@@ -170,7 +170,7 @@ wxMutexError wxMutex::Unlock()
class wxConditionInternal class wxConditionInternal
{ {
public: public:
inline wxConditionInternal () inline wxConditionInternal (wxMutex& rMutex) : m_vMutex(rMutex)
{ {
::DosCreateEventSem(NULL, &m_vEvent, DC_SEM_SHARED, FALSE); ::DosCreateEventSem(NULL, &m_vEvent, DC_SEM_SHARED, FALSE);
if (!m_vEvent) if (!m_vEvent)
@@ -208,14 +208,15 @@ public:
HEV m_vEvent; HEV m_vEvent;
int m_nWaiters; int m_nWaiters;
wxMutex& m_vMutex;
}; };
wxCondition::wxCondition() wxCondition::wxCondition(wxMutex& rMutex)
{ {
APIRET ulrc; APIRET ulrc;
ULONG ulCount; ULONG ulCount;
m_internal = new wxConditionInternal; m_internal = new wxConditionInternal(rMutex);
ulrc = ::DosCreateEventSem(NULL, &m_internal->m_vEvent, 0L, FALSE); ulrc = ::DosCreateEventSem(NULL, &m_internal->m_vEvent, 0L, FALSE);
if (ulrc != 0) if (ulrc != 0)
{ {
@@ -239,10 +240,10 @@ void wxCondition::Wait()
} }
bool wxCondition::Wait( bool wxCondition::Wait(
unsigned long lSec unsigned long lMilliSec
, unsigned long lNsec) )
{ {
return m_internal->Wait(lSec*1000 + lNsec/1000000); return m_internal->Wait(lMilliSec);
} }
void wxCondition::Signal() void wxCondition::Signal()

View File

@@ -84,17 +84,19 @@ class wxToolBarTool : public wxToolBarToolBase
public: public:
inline wxToolBarTool( wxToolBar* pTbar inline wxToolBarTool( wxToolBar* pTbar
,int vId ,int vId
,const wxString& rsLabel
,const wxBitmap& rBitmap1 ,const wxBitmap& rBitmap1
,const wxBitmap& rBitmap2 ,const wxBitmap& rBitmap2
,bool bToggle ,wxItemKind vKind
,wxObject* pClientData ,wxObject* pClientData
,const wxString& rShortHelpString ,const wxString& rShortHelpString
,const wxString& rLongHelpString ,const wxString& rLongHelpString
) : wxToolBarToolBase( pTbar ) : wxToolBarToolBase( pTbar
,vId ,vId
,rsLabel
,rBitmap1 ,rBitmap1
,rBitmap2 ,rBitmap2
,bToggle ,vKind
,pClientData ,pClientData
,rShortHelpString ,rShortHelpString
,rLongHelpString ,rLongHelpString
@@ -132,9 +134,10 @@ private:
wxToolBarToolBase* wxToolBar::CreateTool( wxToolBarToolBase* wxToolBar::CreateTool(
int nId int nId
, const wxString& rsLabel
, const wxBitmap& rBitmap1 , const wxBitmap& rBitmap1
, const wxBitmap& rBitmap2 , const wxBitmap& rBitmap2
, bool bToggle , wxItemKind vKind
, wxObject* pClientData , wxObject* pClientData
, const wxString& rShortHelpString , const wxString& rShortHelpString
, const wxString& rLongHelpString , const wxString& rLongHelpString
@@ -142,9 +145,10 @@ wxToolBarToolBase* wxToolBar::CreateTool(
{ {
return(new wxToolBarTool( this return(new wxToolBarTool( this
,nId ,nId
,rsLabel
,rBitmap1 ,rBitmap1
,rBitmap2 ,rBitmap2
,bToggle ,vKind
,pClientData ,pClientData
,rShortHelpString ,rShortHelpString
,rLongHelpString ,rLongHelpString

View File

@@ -822,17 +822,26 @@ bool wxTopLevelWindowOS2::ShowFullScreen(
void wxTopLevelWindowOS2::SetIcon( void wxTopLevelWindowOS2::SetIcon(
const wxIcon& rIcon const wxIcon& rIcon
) )
{
SetIcons(wxIconBundle(rIcon));
} // end of wxTopLevelWindowOS2::SetIcon
void wxTopLevelWindowOS2::SetIcons(
const wxIconBundle& rIcons
)
{ {
// //
// This sets m_icon // This sets m_icon
// //
wxTopLevelWindowBase::SetIcon(rIcon); wxTopLevelWindowBase::SetIcons(rIcons);
if (m_icon.Ok()) const wxIcon& vIcon = rIcons.GetIcon(wxSize(32, 32));
if (vIcon.Ok() && vIcon.GetWidth() == 32 && vIcon.GetHeight() == 32)
{ {
::WinSendMsg( m_hFrame ::WinSendMsg( m_hFrame
,WM_SETICON ,WM_SETICON
,(MPARAM)((HPOINTER)m_icon.GetHICON()) ,(MPARAM)((HPOINTER)vIcon.GetHICON())
,NULL ,NULL
); );
::WinSendMsg( m_hFrame ::WinSendMsg( m_hFrame

View File

@@ -278,10 +278,11 @@ void wxWindowOS2::Init()
m_bDoubleClickAllowed = 0; m_bDoubleClickAllowed = 0;
m_bWinCaptured = FALSE; m_bWinCaptured = FALSE;
m_isBeingDeleted = FALSE; m_isBeingDeleted = FALSE;
m_fnOldWndProc = 0; m_fnOldWndProc = 0;
m_bUseCtl3D = FALSE; m_bUseCtl3D = FALSE;
m_bMouseInWindow = FALSE; m_bMouseInWindow = FALSE;
m_bLastKeydownProcessed = FALSE;
// //
// wxWnd // wxWnd
@@ -2705,12 +2706,14 @@ MRESULT wxWindowOS2::OS2WindowProc(
} }
else // keydown event else // keydown event
{ {
m_bLastKeydownProcessed = FALSE;
// //
// If this has been processed by an event handler, // If this has been processed by an event handler,
// return 0 now (we've handled it). DON't RETURN // return 0 now (we've handled it). DON't RETURN
// we still need to process further // we still need to process further
// //
HandleKeyDown((WXDWORD)wParam, lParam); HandleKeyDown((WXDWORD)wParam, lParam);
m_bLastKeydownProcessed = TRUE;
if (uKeyFlags & KC_VIRTUALKEY) if (uKeyFlags & KC_VIRTUALKEY)
{ {
USHORT uVk = SHORT2FROMMP((MPARAM)lParam); USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
@@ -4014,6 +4017,16 @@ bool wxWindowOS2::HandleChar(
bool bCtrlDown = FALSE; bool bCtrlDown = FALSE;
int vId; int vId;
if (m_bLastKeydownProcessed)
{
//
// The key was handled in the EVT_KEY_DOWN. Handling a key in an
// EVT_KEY_DOWN handler is meant, by design, to prevent EVT_CHARs
// from happening, so just bail out at this point.
//
m_bLastKeydownProcessed = FALSE;
return TRUE;
}
if (isASCII) if (isASCII)
{ {
// //