From 1c344e89c6dbe3776e529fb86bdeb2829d36fb2f Mon Sep 17 00:00:00 2001 From: David Webster Date: Mon, 18 Feb 2002 04:32:01 +0000 Subject: [PATCH] wxOS2 no longer relies on xpmlib git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14295 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/bitmap.cpp | 55 +++++----- src/os2/gdiimage.cpp | 7 -- src/os2/makefile.va | 19 +--- src/os2/wx23.def | 34 ++---- src/os2/xpmhand.cpp | 241 ------------------------------------------- 5 files changed, 35 insertions(+), 321 deletions(-) delete mode 100644 src/os2/xpmhand.cpp diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index eb52b51de1..9ce09578e5 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -33,6 +33,7 @@ //#include "wx/msw/dib.h" #include "wx/image.h" +#include "wx/xpmdecod.h" // ---------------------------------------------------------------------------- // macros @@ -211,37 +212,6 @@ wxBitmap::wxBitmap( SetHBITMAP((WXHBITMAP)hBmp); } // end of wxBitmap::wxBitmap -// -// Create from XPM data -// -wxBitmap::wxBitmap( - char** ppData -) -{ - Init(); - - (void)Create( (void *)ppData - ,wxBITMAP_TYPE_XPM_DATA - ,0 - ,0 - ,0 - ); -} // end of wxBitmap::wxBitmap - -wxBitmap::wxBitmap( - const char** ppData -) -{ - Init(); - - (void)Create( (void *)ppData - ,wxBITMAP_TYPE_XPM_DATA - ,0 - ,0 - ,0 - ); -} // end of wxBitmap::wxBitmap - wxBitmap::wxBitmap( int nW , int nH @@ -361,6 +331,27 @@ bool wxBitmap::Create( return Ok(); } // end of wxBitmap::Create +bool wxBitmap::CreateFromXpm( + const char** ppData +) +{ +#if wxUSE_IMAGE && wxUSE_XPM + Init(); + + wxCHECK_MSG(ppData != NULL, FALSE, wxT("invalid bitmap data")) + + wxXPMDecoder vDecoder; + wxImage vImg = vDecoder.ReadData(ppData); + + wxCHECK_MSG(vImg.Ok(), FALSE, wxT("invalid bitmap data")) + + *this = wxBitmap(vImg); + return TRUE; +#else + return FALSE; +#endif +} // end of wxBitmap::CreateFromXpm + bool wxBitmap::LoadFile( const wxString& rFilename , long lType @@ -671,7 +662,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) wxImage wxBitmap::ConvertToImage() const { wxImage image; - + wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); // create an wxImage object diff --git a/src/os2/gdiimage.cpp b/src/os2/gdiimage.cpp index 82ec08a00c..33c15169e2 100644 --- a/src/os2/gdiimage.cpp +++ b/src/os2/gdiimage.cpp @@ -31,7 +31,6 @@ #include "wx/os2/private.h" #include "wx/app.h" -#include "wx/xpmhand.h" #include "wx/os2/gdiimage.h" // ---------------------------------------------------------------------------- @@ -345,12 +344,6 @@ void wxGDIImage::InitStandardHandlers() { AddHandler(new wxBMPResourceHandler); AddHandler(new wxBMPFileHandler); - -#if wxUSE_XPM_IN_OS2 - AddHandler(new wxXPMFileHandler); - AddHandler(new wxXPMDataHandler); -#endif - AddHandler(new wxICOResourceHandler); AddHandler(new wxICOFileHandler); } diff --git a/src/os2/makefile.va b/src/os2/makefile.va index 561136fc39..3ab391d99e 100644 --- a/src/os2/makefile.va +++ b/src/os2/makefile.va @@ -533,8 +533,7 @@ OS2OBJS = \ ..\os2\$D\utils.obj \ ..\os2\$D\utilsexc.obj \ ..\os2\$D\wave.obj \ - ..\os2\$D\window.obj \ - ..\os2\$D\xpmhand.obj + ..\os2\$D\window.obj OS2LIBOBJS1 = \ accel.obj \ @@ -617,8 +616,7 @@ OS2LIBOBJS2 = \ utils.obj \ utilsexc.obj \ wave.obj \ - window.obj \ - xpmhand.obj + window.obj HTMLOBJS = \ ..\html\$D\helpctrl.obj \ @@ -670,7 +668,7 @@ HTMLLIBOBJS = \ OBJECTS = $(COMMONOBJS) $(GENERICOBJS) $(HTMLOBJS) $(NONESSENTIALOBJS) $(OS2OBJS) # Normal, static library -all: $(WXDIR)\include\wx\setup.h $(DUMMYOBJ) $(OBJECTS) $(PERIPH_TARGET) zlib png jpeg xpm tiff $(LIBTARGET) +all: $(WXDIR)\include\wx\setup.h $(DUMMYOBJ) $(OBJECTS) $(PERIPH_TARGET) zlib png jpeg tiff $(LIBTARGET) dirs: $(OS2DIR)\$D $(COMMDIR)\$D $(GENDIR)\$D $(HTMLDIR)\$D @@ -971,7 +969,6 @@ $(OS2LIBOBJS2): copy ..\os2\$D\utilsexc.obj copy ..\os2\$D\wave.obj copy ..\os2\$D\window.obj - copy ..\os2\$D\xpmhand.obj # wxWindows library as DLL dll: @@ -1158,16 +1155,6 @@ clean_jpeg: nmake -f makefile.va clean cd $(WXDIR)\src\os2 -xpm: - cd $(WXDIR)\src\xpm - nmake -f makefile.va FINAL=$(FINAL) DLL=$(DLL) WXMAKINGDLL=$(WXMAKINGDLL) - cd $(WXDIR)\src\os2 - -clean_xpm: - cd $(WXDIR)\src\xpm - nmake -f makefile.va clean - cd $(WXDIR)\src\os2 - tiff: cd $(WXDIR)\src\tiff nmake -f makefile.va FINAL=$(FINAL) DLL=$(DLL) WXMAKINGDLL=$(WXMAKINGDLL) diff --git a/src/os2/wx23.def b/src/os2/wx23.def index 00eaaeec51..8f05577557 100644 --- a/src/os2/wx23.def +++ b/src/os2/wx23.def @@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL CODE LOADONCALL EXPORTS -;From library: H:\Dev\Wx2\WxWindows\lib\wx.lib +;From library: F:\DEV\WX2\WXWINDOWS\LIB\wx.lib ;From object file: dummy.cpp ;PUBDEFs (Symbols available from object file): wxDummyChar @@ -1777,7 +1777,7 @@ EXPORTS wxEVT_NC_LEFT_DCLICK wxEVT_INIT_DIALOG wxEVT_COMMAND_SET_FOCUS - ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c + ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c ;PUBDEFs (Symbols available from object file): ConvertToIeeeExtended ConvertFromIeeeExtended @@ -5810,7 +5810,7 @@ EXPORTS Read32__17wxTextInputStreamFv ;wxTextInputStream::SkipIfEndOfLine(char) SkipIfEndOfLine__17wxTextInputStreamFc - ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c + ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c ;PUBDEFs (Symbols available from object file): unzReadCurrentFile unzGetCurrentFileInfo @@ -9743,6 +9743,8 @@ EXPORTS OnSetCursor__16wxSplitterWindowFR16wxSetCursorEvent ;wxSplitterWindow::DoSplit(wxSplitMode,wxWindow*,wxWindow*,int) DoSplit__16wxSplitterWindowF11wxSplitModeP8wxWindowT2i + ;wxSplitterWindow::SetMinimumPaneSize(int) + SetMinimumPaneSize__16wxSplitterWindowFi ;wxSplitterWindow::DrawSashTracker(int,int) DrawSashTracker__16wxSplitterWindowFiT1 ;wxConstructorForwxSplitterWindow() @@ -9771,6 +9773,8 @@ EXPORTS OnIdle__16wxSplitterWindowFR11wxIdleEvent ;wxSplitterWindow::OnDoubleClick(wxSplitterEvent&) OnDoubleClick__16wxSplitterWindowFR15wxSplitterEvent + ;wxSplitterWindow::DoSetSashPosition(int) + DoSetSashPosition__16wxSplitterWindowFi ;wxSplitterWindow::Init() Init__16wxSplitterWindowFv ;wxSplitterWindow::GetEventTable() const @@ -11257,8 +11261,6 @@ EXPORTS wxInvertMask__FUliT2 ;wxMask::wxMask() __ct__6wxMaskFv - ;wxBitmap::wxBitmap(const char**) - __ct__8wxBitmapFPPCc ;wxMask::sm_classwxMask sm_classwxMask__6wxMask __vft8wxBitmap8wxObject @@ -11301,8 +11303,8 @@ EXPORTS wxConstructorForwxBitmap__Fv ;wxConstructorForwxMask() wxConstructorForwxMask__Fv - ;wxBitmap::wxBitmap(char**) - __ct__8wxBitmapFPPc + ;wxBitmap::CreateFromXpm(const char**) + CreateFromXpm__8wxBitmapFPPCc ;wxBitmap::SetMask(wxMask*) SetMask__8wxBitmapFP6wxMask ;From object file: ..\os2\bmpbuttn.cpp @@ -14763,21 +14765,3 @@ EXPORTS SetTitle__8wxWindowFRC8wxString ;wxWindow::sm_eventTableEntries sm_eventTableEntries__8wxWindow - ;From object file: ..\os2\xpmhand.cpp - ;PUBDEFs (Symbols available from object file): - ;wxXPMDataHandler::Create(wxBitmap*,void*,long,int,int,int) - Create__16wxXPMDataHandlerFP8wxBitmapPvliN24 - __vft16wxXPMDataHandler8wxObject - ;wxConstructorForwxXPMFileHandler() - wxConstructorForwxXPMFileHandler__Fv - __vft16wxXPMFileHandler8wxObject - ;wxConstructorForwxXPMDataHandler() - wxConstructorForwxXPMDataHandler__Fv - ;wxXPMFileHandler::LoadFile(wxBitmap*,const wxString&,long,int,int) - LoadFile__16wxXPMFileHandlerFP8wxBitmapRC8wxStringliT4 - ;wxXPMFileHandler::SaveFile(wxBitmap*,const wxString&,int,const wxPalette*) - SaveFile__16wxXPMFileHandlerFP8wxBitmapRC8wxStringiPC9wxPalette - ;wxXPMDataHandler::sm_classwxXPMDataHandler - sm_classwxXPMDataHandler__16wxXPMDataHandler - ;wxXPMFileHandler::sm_classwxXPMFileHandler - sm_classwxXPMFileHandler__16wxXPMFileHandler diff --git a/src/os2/xpmhand.cpp b/src/os2/xpmhand.cpp deleted file mode 100644 index 494bcf6008..0000000000 --- a/src/os2/xpmhand.cpp +++ /dev/null @@ -1,241 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: os2/xpmhand.cpp -// Purpose: wxBitmap: XPM handler and constructors -// Author: Julian Smart -// Modified for OS/2 by: Evgeny Kotsuba -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ - #pragma implementation "xpmhand.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -//#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/list.h" - #include "wx/utils.h" - #include "wx/app.h" - #include "wx/palette.h" - #include "wx/dcmemory.h" - #include "wx/bitmap.h" - #include "wx/icon.h" -#endif - -#include "wx/os2/private.h" -#include "wx/log.h" - - -#if wxUSE_XPM_IN_OS2 - #define FOR_MSW 1 - #include "xpm.h" -#endif - -#include "wx/xpmhand.h" - -#if wxUSE_XPM_IN_OS2 - -static void XpmToBitmap( - wxBitmap* pBitmap -, const XImage* pXimage -, const XImage* pXmask -, const XpmAttributes& rXpmAttr -) -{ - wxBitmapRefData* pRefData = pBitmap->GetBitmapData(); - pRefData->m_hBitmap = (WXHBITMAP)pXimage->bitmap; - - // - // First set the bitmap width, height, depth... - // - BITMAPINFOHEADER vBm; - - if (!::GpiQueryBitmapParameters( GetHbitmapOf(*pBitmap) - ,&vBm - )) - { - wxLogLastError(wxT("GetObject(pBitmap)")); - } - - pRefData->m_nWidth = vBm.cx; - pRefData->m_nHeight = vBm.cy; - pRefData->m_nDepth = vBm.cPlanes * vBm.cBitCount; - pRefData->m_nNumColors = rXpmAttr.npixels; - - if (pXmask) - { - wxMask* pMask = new wxMask(); - - pMask->SetMaskBitmap((WXHBITMAP) wxInvertMask( pXmask->bitmap - ,vBm.cx - ,vBm.cy - )); - pBitmap->SetMask(pMask); - } -} // end of XpmToBitmap - -IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler) - -bool wxXPMFileHandler::LoadFile( - wxBitmap* pBitmap -, const wxString& rName -, long lFlags -, int lDesiredWidth -, int lDesiredHeight -) -{ - XImage* pXimage = NULL; - XImage* pXmask = NULL; - XpmAttributes vXpmAttr; - HDC hDC; - HPS hPS; - DEVOPENSTRUC dOP = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; - SIZEL vSizl; - - hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dOP, NULLHANDLE); - hPS = ::GpiCreatePS(vHabmain, hDC, &vSizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC); - if (hPS) - { - vXpmAttr.valuemask = XpmReturnPixels | XpmColorTable; - - int nErrorStatus = XpmReadFileToImage( &hPS - ,wxMBSTRINGCAST rName.fn_str() - ,&pXimage - ,&pXmask - ,&vXpmAttr - ); - ::GpiDestroyPS(hPS); - ::DevCloseDC(hDC); - if (nErrorStatus == XpmSuccess) - { - XpmToBitmap( pBitmap - ,pXimage - ,pXmask - ,vXpmAttr - ); - XpmFree(vXpmAttr.pixels); - XpmFreeAttributes(&vXpmAttr); - XImageFree(pXimage); - if (pXmask) - XDestroyImage(pXmask); - } - return pBitmap->Ok(); - } - return FALSE; -} // end of wxXPMFileHandler::LoadFile - -bool wxXPMFileHandler::SaveFile( - wxBitmap* pBitmap -, const wxString& rName -, int lType -, const wxPalette* pPalette -) -{ - XImage vXimage; - XImage vXmask; - bool bHasmask = FALSE; - HDC hDC; - HPS hPS; - DEVOPENSTRUC dOP = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; - SIZEL vSizl; - - hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dOP, NULLHANDLE); - hPS = ::GpiCreatePS(vHabmain, hDC, &vSizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC); - if (hPS) - { - // fill the XImage struct 'by hand' - wxBitmapRefData* pRefData = pBitmap->GetBitmapData(); - - vXimage.width = pRefData->m_nWidth; - vXimage.height = pRefData->m_nHeight; - vXimage.depth = pRefData->m_nDepth; - vXimage.bitmap = (HBITMAP)pRefData->m_hBitmap; - - bHasmask = (pRefData->m_pBitmapMask != NULL); - if (bHasmask) - { - // - // Strangely enough, the MSW version of xpmlib is not - // coherent with itself regarding masks; we have to invert - // the mask we get when loading, but we still must pass it - // 'as is' when saving... - // - vXmask.bitmap = (HBITMAP)pRefData->m_pBitmapMask->GetMaskBitmap(); - vXmask.width = pRefData->m_nWidth; - vXmask.height = pRefData->m_nHeight; - vXmask.depth = 1; - } - - int nErrorStatus = XpmWriteFileFromImage( &hPS - ,wxMBSTRINGCAST rName.fn_str() - ,&vXimage - ,(bHasmask? &vXmask : (XImage *)NULL) - ,(XpmAttributes *) NULL - ); - ::GpiDestroyPS(hPS); - ::DevCloseDC(hDC); - return (nErrorStatus == XpmSuccess); - } - return FALSE; -} // end of wxXPMFileHandler::SaveFile - -IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler) - -bool wxXPMDataHandler::Create( - wxBitmap* pBitmap -, void* pData -, long lFlags -, int nWidth -, int nHeight -, int nDepth -) -{ - XImage* pXimage = NULL; - XImage* pXmask = NULL; - XpmAttributes vXpmAttr; - HDC hDC; - HPS hPS; - DEVOPENSTRUC dOP = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; - SIZEL vSizl; - - hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dOP, NULLHANDLE); - hPS = ::GpiCreatePS(vHabmain, hDC, &vSizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC); - if (hPS) - { - vXpmAttr.valuemask = XpmReturnInfos | XpmColorTable; - - int nErrorStatus = XpmCreateImageFromData( &hPS - ,(char **)pData - ,&pXimage - ,&pXmask - ,&vXpmAttr - ); - ::GpiDestroyPS(hPS); - ::DevCloseDC(hDC); - if (nErrorStatus == XpmSuccess) - { - XpmToBitmap( pBitmap - ,pXimage - ,pXmask - ,vXpmAttr - ); - XpmFree(vXpmAttr.pixels); - XpmFreeAttributes(&vXpmAttr); - XImageFree(pXimage); // releases the malloc, but does not destroy bitmap - if (pXmask) - XDestroyImage(pXmask); - } - return pBitmap->Ok(); - } - return FALSE; -} // end of wxXPMDataHandler::Create - -#endif // wxUSE_XPM_IN_OS2