src/jpeg/make*
-src/jpeg/JpegVC.dsp
-src/jpeg/JpegVC.dsw
+src/jpeg/jpeg.dsp
+src/jpeg/jpeg.dsw
src/jpeg/*.c
src/jpeg/*.h
src/jpeg/README
src/tiff/make*
-src/tiff/TiffVC.dsp
-src/tiff/TiffVC.dsw
+src/tiff/tiff.dsp
+src/tiff/tiff.dsw
src/tiff/*.c
src/tiff/*.h
src/tiff/README
wxMSW/wxMicroWindows port itself.
+Errors/warnings
+===============
+
+In file ../../src/msw/window.cpp at line 1294: 'UpdateWindow' failed with error 0x00000000 (Success).
+
+ - caused because there are no paint messages pending. Presumed
+ harmless.
+
+In file ../../src/msw/dc.cpp at line 1838: 'BitBlt' failed with error 0x00000000 (Success).
+
+ - caused because the window isn't mapped, and MwPrepareDC in wingdi.c
+ fails (hwnd->unmapcount is non-zero). Presumed harmless.
+
+Recursive paint problem, e.g. when clicking the 'Press Me!'
+button in the widgets sample a few times, until the text control
+is full.
+
+ - possibly the scrollbar is causing the text control to be
+ updated, which somehow effects the scrollbar, which causes
+ a window update, etc.
+
+Sluggish updates.
+
+ - probably because many image to bitmap conversions are being
+ done on update, and bitmaps should probably be cached.
+
+
Things missing from MicroWindows that need to be worked around
==============================================================
Well, a simple-minded way would be to use CreateCompatibleBitmap
which returns an HBITMAP, select it into an HDC, and draw
the pixels from the wxImage to the HDC one by one with SetPixel.
-This is now implemented, but without any mask handling, which will
-be needed.
-
-Unfortunately, there's a crash in malloc, within DeleteObject, when
-passed a bitmap created by CreateCompatibleBitmap, but only after a few
-deletions. This has yet to be tracked down, maybe by trying to create/delete
-some wxBitmaps from XPMs, from within e.g. the minimal sample.
+This is now implemented, but there are problems with masks.
+(a) masks have to be created at screen depth because BitBlt/GrDraw
+can't cope with differing depths, and (b) masked blitting
+is still not working (try enabling mask creation in
+wxBitmap::CreateFromImage by setting USE_MASKS to 1).
Other missing features
LPCSCROLLINFO lpsi, BOOL fRedraw);
BOOL GetScrollInfo(HWND hWnd, int iSBar, LPSCROLLINFO lpsi);
BOOL ShowScrollBar (HWND hWnd, int iSBar, BOOL bShow);
+HBITMAP WINAPI
+CreateBitmap( int width, int height, int nPlanes, int bPP, LPCVOID lpData);
#ifdef __cplusplus
}
include $(TOP)/Makefile.rules
# List of objects to compile
-OBJS = widgets.o button.o # combobox.o gauge.o listbox.o notebook.o radiobox.o # slider.o spinbtn.o \
+OBJS = widgets.o button.o combobox.o gauge.o listbox.o notebook.o radiobox.o slider.o spinbtn.o \
static.o textctrl.o
all: widgets
#include "wx/icon.h"
#endif
+//#include "device.h"
+
#include "wx/msw/private.h"
#include "wx/log.h"
if ( m_hBitmap)
{
// printf("About to delete bitmap %d\n", (int) (HBITMAP) m_hBitmap);
+#if 1
if ( !::DeleteObject((HBITMAP)m_hBitmap) )
{
wxLogLastError(wxT("DeleteObject(hbitmap)"));
}
+#endif
}
delete m_bitmapMask;
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
{
#ifdef __WXMICROWIN__
+
+ // Set this to 1 to experiment with mask code,
+ // which currently doesn't work
+#define USE_MASKS 0
+
m_refData = new wxBitmapRefData();
// Initial attempt at a simple-minded implementation.
// The bitmap will always be created at the screen depth,
// so the 'depth' argument is ignored.
- // TODO: transparency (create a mask image)
HDC hScreenDC = ::GetDC(NULL);
+ // printf("Screen planes = %d, bpp = %d\n", hScreenDC->psd->planes, hScreenDC->psd->bpp);
int screenDepth = ::GetDeviceCaps(hScreenDC, BITSPIXEL);
HBITMAP hBitmap = ::CreateCompatibleBitmap(hScreenDC, image.GetWidth(), image.GetHeight());
+ HBITMAP hMaskBitmap = NULL;
+ HBITMAP hOldMaskBitmap = NULL;
+ HDC hMaskDC = NULL;
+ unsigned char maskR = 0;
+ unsigned char maskG = 0;
+ unsigned char maskB = 0;
+
// printf("Created bitmap %d\n", (int) hBitmap);
if (hBitmap == NULL)
{
return FALSE;
}
HDC hMemDC = ::CreateCompatibleDC(hScreenDC);
- ::ReleaseDC(NULL, hScreenDC);
HBITMAP hOldBitmap = ::SelectObject(hMemDC, hBitmap);
+ ::ReleaseDC(NULL, hScreenDC);
+
+ // created an mono-bitmap for the possible mask
+ bool hasMask = image.HasMask();
+
+ if ( hasMask )
+ {
+#if USE_MASKS
+ // FIXME: we should be able to pass bpp = 1, but
+ // GdBlit can't handle a different depth
+#if 0
+ hMaskBitmap = ::CreateBitmap( (WORD)image.GetWidth(), (WORD)image.GetHeight(), 1, 1, NULL );
+#else
+ hMaskBitmap = ::CreateCompatibleBitmap( hMemDC, (WORD)image.GetWidth(), (WORD)image.GetHeight());
+#endif
+ maskR = image.GetMaskRed();
+ maskG = image.GetMaskGreen();
+ maskB = image.GetMaskBlue();
+
+ if (!hMaskBitmap)
+ {
+ hasMask = FALSE;
+ }
+ else
+ {
+ hScreenDC = ::GetDC(NULL);
+ hMaskDC = ::CreateCompatibleDC(hScreenDC);
+ ::ReleaseDC(NULL, hScreenDC);
+
+ hOldMaskBitmap = ::SelectObject( hMaskDC, hMaskBitmap);
+ }
+#else
+ hasMask = FALSE;
+#endif
+ }
int i, j;
for (i = 0; i < image.GetWidth(); i++)
unsigned char blue = image.GetBlue(i, j);
::SetPixel(hMemDC, i, j, PALETTERGB(red, green, blue));
+
+ if (hasMask)
+ {
+ // scan the bitmap for the transparent colour and set the corresponding
+ // pixels in the mask to BLACK and the rest to WHITE
+ if (maskR == red && maskG == green && maskB == blue)
+ ::SetPixel(hMaskDC, i, j, PALETTERGB(0, 0, 0));
+ else
+ ::SetPixel(hMaskDC, i, j, PALETTERGB(255, 255, 255));
+ }
}
}
::SelectObject(hMemDC, hOldBitmap);
::DeleteDC(hMemDC);
+ if (hasMask)
+ {
+ ::SelectObject(hMaskDC, hOldMaskBitmap);
+ ::DeleteDC(hMaskDC);
+
+ ((wxBitmapRefData*)m_refData)->m_bitmapMask = new wxMask((WXHBITMAP) hMaskBitmap);
+ }
SetWidth(image.GetWidth());
SetHeight(image.GetHeight());
useMask = FALSE;
}
}
-
if ( useMask )
{
#ifdef __WIN32__
{
HDC cdc = GetHdc();
HDC hdcMem = ::CreateCompatibleDC(GetHdc());
- ::SelectObject(hdcMem, GetHbitmapOf(bmp));
-
+ HBITMAP hOldBitmap = ::SelectObject(hdcMem, GetHbitmapOf(bmp));
#if wxUSE_PALETTE
wxPalette *pal = bmp.GetPalette();
if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 )
::SelectPalette(hdcMem, oldPal, FALSE);
#endif // wxUSE_PALETTE
+ ::SelectObject(hdcMem, hOldBitmap);
::DeleteDC(hdcMem);
}
}
#if wxUSE_PALETTE
- wxPalette *pal = bmp.GetPalette();
- if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 )
- {
- oldPal = ::SelectPalette(memdc, GetHpaletteOf(pal), FALSE);
- ::RealizePalette(memdc);
- }
+ wxPalette *pal = bmp.GetPalette();
+ if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 )
+ {
+ oldPal = ::SelectPalette(memdc, GetHpaletteOf(pal), FALSE);
+ ::RealizePalette(memdc);
+ }
#endif // wxUSE_PALETTE
- ::SelectObject( memdc, hbitmap );
+ HBITMAP hOldBitmap = ::SelectObject( memdc, hbitmap );
::BitBlt( cdc, x, y, width, height, memdc, 0, 0, SRCCOPY);
#if wxUSE_PALETTE
::SelectPalette(memdc, oldPal, FALSE);
#endif // wxUSE_PALETTE
+ ::SelectObject( memdc, hOldBitmap );
::DeleteDC( memdc );
::SetTextColor(GetHdc(), old_textground);
dc_buffer = ::CreateCompatibleDC(GetHdc());
buffer_bmap = ::CreateCompatibleBitmap(GetHdc(), width, height);
#endif // wxUSE_DC_CACHEING/!wxUSE_DC_CACHEING
- ::SelectObject(dc_mask, (HBITMAP) mask->GetMaskBitmap());
- ::SelectObject(dc_buffer, buffer_bmap);
+ HBITMAP hOldMaskBitmap = ::SelectObject(dc_mask, (HBITMAP) mask->GetMaskBitmap());
+ HBITMAP hOldBufferBitmap = ::SelectObject(dc_buffer, buffer_bmap);
// copy dest to buffer
if ( !::BitBlt(dc_buffer, 0, 0, (int)width, (int)height,
}
// tidy up temporary DCs and bitmap
- ::SelectObject(dc_mask, 0);
- ::SelectObject(dc_buffer, 0);
+ ::SelectObject(dc_mask, hOldMaskBitmap);
+ ::SelectObject(dc_buffer, hOldBufferBitmap);
#if !wxUSE_DC_CACHEING
{
return 0;
}
}
+
+/* Not in wingdi.c in earlier versions of MicroWindows */
+#if 0
+HBITMAP WINAPI
+CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight)
+{
+ MWBITMAPOBJ * hbitmap;
+ int size;
+ int linelen;
+
+ if(!hdc)
+ return NULL;
+
+ nWidth = MWMAX(nWidth, 1);
+ nHeight = MWMAX(nHeight, 1);
+
+ /* calc memory allocation size and linelen from width and height*/
+ if(!GdCalcMemGCAlloc(hdc->psd, nWidth, nHeight, 0, 0, &size, &linelen))
+ return NULL;
+
+ /* allocate gdi object*/
+ hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size);
+ if(!hbitmap)
+ return NULL;
+ hbitmap->hdr.type = OBJ_BITMAP;
+ hbitmap->hdr.stockobj = FALSE;
+ hbitmap->width = nWidth;
+ hbitmap->height = nHeight;
+
+ /* create compatible with hdc*/
+ hbitmap->planes = hdc->psd->planes;
+ hbitmap->bpp = hdc->psd->bpp;
+ hbitmap->linelen = linelen;
+ hbitmap->size = size;
+
+ return (HBRUSH)hbitmap;
+}
+#endif
+
+/* Attempt by JACS to create arbitrary bitmap
+ * TODO: make use of lpData
+ */
+
+HBITMAP WINAPI
+CreateBitmap( int nWidth, int nHeight, int nPlanes, int bPP, LPCVOID lpData)
+{
+ MWBITMAPOBJ * hbitmap;
+ int size;
+ int linelen;
+
+ HDC hScreenDC;
+
+ hScreenDC = GetDC(NULL);
+
+ nWidth = MWMAX(nWidth, 1);
+ nHeight = MWMAX(nHeight, 1);
+
+ /* calc memory allocation size and linelen from width and height*/
+ if(!GdCalcMemGCAlloc(hScreenDC->psd, nWidth, nHeight, nPlanes, bPP, &size, &linelen))
+ {
+ ReleaseDC(NULL, hScreenDC);
+ return NULL;
+ }
+ ReleaseDC(NULL, hScreenDC);
+
+ /* allocate gdi object*/
+ hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size);
+ if(!hbitmap)
+ return NULL;
+ hbitmap->hdr.type = OBJ_BITMAP;
+ hbitmap->hdr.stockobj = FALSE;
+ hbitmap->width = nWidth;
+ hbitmap->height = nHeight;
+
+ /* create with specified parameters */
+ hbitmap->planes = nPlanes;
+ hbitmap->bpp = bPP;
+ hbitmap->linelen = linelen;
+ hbitmap->size = size;
+
+ /* TODO: copy data */
+
+ return (HBRUSH)hbitmap;
+}
void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height)
{
+ // TODO: is this consistent with other platforms?
+ // Still, negative width or height shouldn't be allowed
+ if (width < 0)
+ width = 0;
+ if (height < 0)
+ height = 0;
if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) )
{
wxLogLastError(wxT("MoveWindow"));
if ( m_status == Status_Checked )
flags |= wxCONTROL_CHECKED;
+ wxBitmap bitmap(GetBitmap(GetState(flags), m_status));
+
renderer->GetRenderer()->
DrawCheckButton(dc,
GetLabel(),
- GetBitmap(GetState(flags), m_status),
+ bitmap,
renderer->GetRect(),
flags,
GetWindowStyle() & wxALIGN_RIGHT ? wxALIGN_RIGHT
dc.SelectObject(bmp);
dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID));
m_imageList->Draw(image, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL, TRUE);
+ dc.SelectObject(wxNullBitmap);
#else
bmp = *m_imageList->GetBitmap(image);
#endif
rectLabel.SetRight(rect.GetRight());
}
+ // THIS IS THE CULPRIT -- JACS
dc.DrawBitmap(bitmap, xBmp, yBmp, TRUE /* use mask */);
DoDrawLabel(
else
{
wxBitmap cbitmap(GetCheckBitmap(flags));
+#if 1
DrawCheckOrRadioButton(dc, label,
cbitmap,
rect, flags, align, indexAccel,
0); // no focus rect offset for checkboxes
+#endif
}
}