From: Julian Smart Date: Fri, 21 Dec 2001 18:15:53 +0000 (+0000) Subject: More tinkering X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/54a96d029f6864182e5e49e7d5b2e133be6d3d51?ds=inline More tinkering git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13149 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/microwin/readme.txt b/docs/microwin/readme.txt index c2572f3d0a..980f125efe 100644 --- a/docs/microwin/readme.txt +++ b/docs/microwin/readme.txt @@ -83,8 +83,12 @@ they are one and the same binary. Status ====== -The minimal sample is almost fully-functional, apart from minor -menu presentation issues (no borders, for example). +The minimal sample is almost fully-functional, apart from some +presentation issues (no menu borders and status bar in the wrong +place. + +The widgets sample is crashing in DeleteObject (see notes below). + Implementation Notes ==================== @@ -103,6 +107,7 @@ in due course. But implementing missing functionality in this way is preferably to proliferating many #ifdefs in the wxMSW/wxMicroWindows port itself. + Things missing from MicroWindows that need to be worked around ============================================================== @@ -131,6 +136,13 @@ So how can we convert from wxImage to wxBitmap in MicroWindows? 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. Other missing features diff --git a/samples/widgets/makefile.mic b/samples/widgets/makefile.mic index 2efc49c71a..75dd78c8e8 100644 --- a/samples/widgets/makefile.mic +++ b/samples/widgets/makefile.mic @@ -50,8 +50,8 @@ LIBNAME = include $(TOP)/Makefile.rules # List of objects to compile -OBJS = button.o combobox.o gauge.o listbox.o notebook.o radiobox.o slider.o spinbtn.o \ - static.o textctrl.o widgets.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 diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 0118ff56bd..97a886aff9 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -88,6 +88,7 @@ void wxBitmapRefData::Free() if ( m_hBitmap) { + // printf("About to delete bitmap %d\n", (int) (HBITMAP) m_hBitmap); if ( !::DeleteObject((HBITMAP)m_hBitmap) ) { wxLogLastError(wxT("DeleteObject(hbitmap)")); @@ -380,6 +381,7 @@ bool wxBitmap::Create(int w, int h, int d) bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) { #ifdef __WXMICROWIN__ + m_refData = new wxBitmapRefData(); // Initial attempt at a simple-minded implementation. // The bitmap will always be created at the screen depth, @@ -390,6 +392,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) int screenDepth = ::GetDeviceCaps(hScreenDC, BITSPIXEL); HBITMAP hBitmap = ::CreateCompatibleBitmap(hScreenDC, image.GetWidth(), image.GetHeight()); + // printf("Created bitmap %d\n", (int) hBitmap); if (hBitmap == NULL) { ::ReleaseDC(NULL, hScreenDC); @@ -416,8 +419,6 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) ::SelectObject(hMemDC, hOldBitmap); ::DeleteDC(hMemDC); - m_refData = new wxBitmapRefData(); - SetWidth(image.GetWidth()); SetHeight(image.GetHeight()); SetDepth(screenDepth); @@ -428,6 +429,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) SetPalette(image.GetPalette()); #endif // wxUSE_PALETTE +#if WXWIN_COMPATIBILITY_2 + // check the wxBitmap object + GetBitmapData()->SetOk(); +#endif // WXWIN_COMPATIBILITY_2 + return TRUE; #else @@ -1020,7 +1026,7 @@ void wxBitmap::SetMask(wxMask *mask) wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const { #ifdef __WXMICROWIN__ - return wxBitmap(); + return *this; #else wxMemoryDC memDC; wxBitmap tmpBitmap(GetWidth(), GetHeight(), dc.GetDepth()); diff --git a/src/msw/makefile.mic b/src/msw/makefile.mic index a761c1f2f7..60d21f875b 100644 --- a/src/msw/makefile.mic +++ b/src/msw/makefile.mic @@ -341,6 +341,8 @@ cleanwx: -$(RM) ../generic/*.bak -$(RM) ../univ/*.o -$(RM) ../univ/*.bak + -$(RM) ../univ/themes/*.o + -$(RM) ../univ/themes/*.bak -$(RM) ../unix/*.o -$(RM) ../unix/*.bak -$(RM) ../html/*.o diff --git a/src/univ/themes/win32.cpp b/src/univ/themes/win32.cpp index 3261e10239..3de3e52415 100644 --- a/src/univ/themes/win32.cpp +++ b/src/univ/themes/win32.cpp @@ -2195,7 +2195,13 @@ wxBitmap wxWin32Renderer::GetIndicator(IndicatorType indType, int flags) : IndicatorStatus_Unchecked; const char **xpm = bmpIndicators[indType][indState][indStatus]; - return xpm ? wxBitmap(xpm) : wxNullBitmap; + if (xpm) + { + wxBitmap bmp(xpm); + return bmp; + } + else + return wxNullBitmap; } void wxWin32Renderer::DrawCheckOrRadioButton(wxDC& dc, @@ -2254,10 +2260,19 @@ void wxWin32Renderer::DrawRadioButton(wxDC& dc, wxAlignment align, int indexAccel) { - DrawCheckOrRadioButton(dc, label, - bitmap.Ok() ? bitmap : GetRadioBitmap(flags), + if (bitmap.Ok()) + DrawCheckOrRadioButton(dc, label, + bitmap, + rect, flags, align, indexAccel, + FOCUS_RECT_OFFSET_Y); // default focus rect offset + else + { + wxBitmap rbitmap(GetRadioBitmap(flags)); + DrawCheckOrRadioButton(dc, label, + rbitmap, rect, flags, align, indexAccel, - FOCUS_RECT_OFFSET_Y); // default focus rect offset + FOCUS_RECT_OFFSET_Y); // default focus rect offset + } } void wxWin32Renderer::DrawCheckButton(wxDC& dc, @@ -2268,10 +2283,19 @@ void wxWin32Renderer::DrawCheckButton(wxDC& dc, wxAlignment align, int indexAccel) { - DrawCheckOrRadioButton(dc, label, - bitmap.Ok() ? bitmap : GetCheckBitmap(flags), - rect, flags, align, indexAccel, - 0); // no focus rect offset for checkboxes + if (bitmap.Ok()) + DrawCheckOrRadioButton(dc, label, + bitmap, + rect, flags, align, indexAccel, + 0); // no focus rect offset for checkboxes + else + { + wxBitmap cbitmap(GetCheckBitmap(flags)); + DrawCheckOrRadioButton(dc, label, + cbitmap, + rect, flags, align, indexAccel, + 0); // no focus rect offset for checkboxes + } } // ----------------------------------------------------------------------------