diff --git a/samples/univ/univ.cpp b/samples/univ/univ.cpp index fdd7e417ca..d2c020ba38 100644 --- a/samples/univ/univ.cpp +++ b/samples/univ/univ.cpp @@ -259,7 +259,7 @@ MyUnivFrame::MyUnivFrame(const wxString& title) wxPoint(10, 150), wxSize(500, 120)); box->SetForegroundColour(*wxRED); - box->SetBackground(wxBITMAP(bricks), 0, wxTILE); + box->SetBackground(bricks_xpm, 0, wxTILE); x = 15; #define CREATE_STATIC_ALIGN_DEMO(align) \ @@ -280,8 +280,8 @@ MyUnivFrame::MyUnivFrame(const wxString& title) new wxButton(this, Univ_Button1, _T("&Press me"), wxPoint(10, 300)); new wxButton(this, Univ_Button2, _T("&And me"), wxPoint(100, 300)); - new wxStaticBitmap(this, wxBITMAP(tip), wxPoint(10, 350)); - new wxStaticBitmap(this, -1, wxBITMAP(tip), wxPoint(50, 350), + new wxStaticBitmap(this, tip_xpm, wxPoint(10, 350)); + new wxStaticBitmap(this, -1, tip_xpm, wxPoint(50, 350), wxDefaultSize, wxSUNKEN_BORDER); #if 0 @@ -306,7 +306,7 @@ MyUnivFrame::MyUnivFrame(const wxString& title) //win->Scroll(10, 0); #endif - new wxButton(this, -1, wxBITMAP(open), _T("&Open..."), wxPoint(10, 420)); + new wxButton(this, -1, open_xpm, _T("&Open..."), wxPoint(10, 420)); wxBitmap bmp1(wxTheApp->GetStdIcon(wxICON_INFORMATION)), bmp2(wxTheApp->GetStdIcon(wxICON_WARNING)), diff --git a/src/univ/radiobut.cpp b/src/univ/radiobut.cpp index 2780fc2539..b6f5bbfb01 100644 --- a/src/univ/radiobut.cpp +++ b/src/univ/radiobut.cpp @@ -74,7 +74,10 @@ bool wxRadioButton::Create(wxWindow *parent, void wxRadioButton::ChangeValue(bool value) { - if ( !IsChecked() && value ) + if ( value == IsChecked() ) + return; + + if ( !IsChecked() ) { // clear all others radio buttons in our group: for this we need to // find the radio button which is the first in the group, i.e. the one @@ -119,8 +122,11 @@ void wxRadioButton::ChangeValue(bool value) SendEvent(); } - //else: either nothign chanegd or an attempt was made to clear a checked - // radio button which can't be done + else // attempt to clear a radio button - this can't be done + { + // but still refresh as ou PRESSED flag changed + Refresh(); + } } void wxRadioButton::ClearValue() diff --git a/src/univ/renderer.cpp b/src/univ/renderer.cpp index cc1d7d65db..7f4db879a7 100644 --- a/src/univ/renderer.cpp +++ b/src/univ/renderer.cpp @@ -441,6 +441,7 @@ void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap, { for ( y = 0; y < rect.height; y += height ) { + // no need to use mask here as we cover the entire window area m_dc.DrawBitmap(bmp, x, y); } } diff --git a/src/univ/themes/win32.cpp b/src/univ/themes/win32.cpp index 9e530f1c7b..6fc6da3eb5 100644 --- a/src/univ/themes/win32.cpp +++ b/src/univ/themes/win32.cpp @@ -206,8 +206,18 @@ protected: wxArrowDirection arrowDir, wxArrowStyle arrowStyle); - // helper of DrawCheckButton + // DrawCheckButton/DrawRadioButton helper + void DrawCheckOrRadioButton(wxDC& dc, + const wxString& label, + const wxBitmap& bitmap, + const wxRect& rect, + int flags, + wxAlignment align, + int indexAccel); + + // get the standard check/radio button bitmap wxBitmap GetCheckBitmap(int flags); + wxBitmap GetRadioBitmap(int flags); private: const wxColourScheme *m_scheme; @@ -1254,6 +1264,106 @@ static char *pressed_unchecked_xpm[] = { "hhhhhhhhhhhhh" }; +static char *checked_radio_xpm[] = { +/* columns rows colors chars-per-pixel */ +"13 13 6 1", +" c None", +"w c white", +"b c black", +"d c #7f7f7f", +"g c #c0c0c0", +"h c #e0e0e0", +/* pixels */ +" dddd ", +" ddbbbbdd ", +" dbbwwwwbbh ", +" dbwwwwwwgh ", +" dbwwwbbwwwgh", +" dbwwbbbbwwgh", +" dbwwbbbbwwgh", +" dbwwwbbwwwgh", +" dbwwwwwwgh ", +" dggwwwwggh ", +" hhgggghh ", +" hhhh ", +" " +}; + +static char *pressed_checked_radio_xpm[] = { +/* columns rows colors chars-per-pixel */ +"13 13 6 1", +" c None", +"w c white", +"b c black", +"d c #7f7f7f", +"g c #c0c0c0", +"h c #e0e0e0", +/* pixels */ +" dddd ", +" ddbbbbdd ", +" dbbggggbbh ", +" dbgggggggh ", +" dbgggbbggggh", +" dbggbbbbgggh", +" dbggbbbbgggh", +" dbgggbbggggh", +" dbgggggggh ", +" dggggggggh ", +" hhgggghh ", +" hhhh ", +" " +}; + +static char *unchecked_radio_xpm[] = { +/* columns rows colors chars-per-pixel */ +"13 13 6 1", +" c None", +"w c white", +"b c black", +"d c #7f7f7f", +"g c #c0c0c0", +"h c #e0e0e0", +/* pixels */ +" dddd ", +" ddbbbbdd ", +" dbbwwwwbbh ", +" dbwwwwwwgh ", +" dbwwwwwwwwgh", +" dbwwwwwwwwgh", +" dbwwwwwwwwgh", +" dbwwwwwwwwgh", +" dbwwwwwwgh ", +" dggwwwwggh ", +" hhgggghh ", +" hhhh ", +" " +}; + +static char *pressed_unchecked_radio_xpm[] = { +/* columns rows colors chars-per-pixel */ +"13 13 6 1", +" c None", +"w c white", +"b c black", +"d c #7f7f7f", +"g c #c0c0c0", +"h c #e0e0e0", +/* pixels */ +" dddd ", +" ddbbbbdd ", +" dbbggggbbh ", +" dbgggggggh ", +" dbgggggggggh", +" dbgggggggggh", +" dbgggggggggh", +" dbgggggggggh", +" dbgggggggh ", +" dggggggggh ", +" hhgggghh ", +" hhhh ", +" " +}; + wxBitmap wxWin32Renderer::GetCheckBitmap(int flags) { char **xpm; @@ -1271,13 +1381,30 @@ wxBitmap wxWin32Renderer::GetCheckBitmap(int flags) return wxBitmap(xpm); } -void wxWin32Renderer::DrawCheckButton(wxDC& dc, - const wxString& label, - const wxBitmap& bitmap, - const wxRect& rect, - int flags, - wxAlignment align, - int indexAccel) +wxBitmap wxWin32Renderer::GetRadioBitmap(int flags) +{ + char **xpm; + if ( flags & wxCONTROL_CHECKED ) + { + xpm = flags & wxCONTROL_PRESSED ? pressed_checked_radio_xpm + : checked_radio_xpm; + } + else // unchecked + { + xpm = flags & wxCONTROL_PRESSED ? pressed_unchecked_radio_xpm + : unchecked_radio_xpm; + } + + return wxBitmap(xpm); +} + +void wxWin32Renderer::DrawCheckOrRadioButton(wxDC& dc, + const wxString& label, + const wxBitmap& bitmap, + const wxRect& rect, + int flags, + wxAlignment align, + int indexAccel) { // calculate the position of the bitmap and of the label wxCoord xBmp, @@ -1285,7 +1412,7 @@ void wxWin32Renderer::DrawCheckButton(wxDC& dc, wxRect rectLabel; dc.GetMultiLineTextExtent(label, NULL, &rectLabel.height); - rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2 - 1; + rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2; if ( align == wxALIGN_RIGHT ) { @@ -1314,8 +1441,22 @@ void wxWin32Renderer::DrawRadioButton(wxDC& dc, wxAlignment align, int indexAccel) { - // FIXME TODO - DrawCheckButton(dc, label, bitmap, rect, flags, align, indexAccel); + DrawCheckOrRadioButton(dc, label, + bitmap.Ok() ? bitmap : GetRadioBitmap(flags), + rect, flags, align, indexAccel); +} + +void wxWin32Renderer::DrawCheckButton(wxDC& dc, + const wxString& label, + const wxBitmap& bitmap, + const wxRect& rect, + int flags, + wxAlignment align, + int indexAccel) +{ + DrawCheckOrRadioButton(dc, label, + bitmap.Ok() ? bitmap : GetCheckBitmap(flags), + rect, flags, align, indexAccel); } // ---------------------------------------------------------------------------- @@ -1698,8 +1839,8 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxControl *control, // ---------------------------------------------------------------------------- bool wxWin32CheckboxInputHandler::HandleKey(wxControl *control, - const wxKeyEvent& event, - bool pressed) + const wxKeyEvent& event, + bool pressed) { if ( pressed ) { @@ -1711,19 +1852,21 @@ bool wxWin32CheckboxInputHandler::HandleKey(wxControl *control, action = wxACTION_CHECKBOX_TOGGLE; break; - case '-': + case WXK_SUBTRACT: + case WXK_NUMPAD_SUBTRACT: action = wxACTION_CHECKBOX_CHECK; break; - case '+': - case '=': + case WXK_ADD: + case WXK_NUMPAD_ADD: + case WXK_NUMPAD_EQUAL: action = wxACTION_CHECKBOX_CLEAR; break; } if ( !!action ) { - control->PerformAction(wxACTION_CHECKBOX_TOGGLE); + control->PerformAction(action); return TRUE; }