diff --git a/include/wx/univ/listbox.h b/include/wx/univ/listbox.h index 1bf6758f4f..78b12de14c 100644 --- a/include/wx/univ/listbox.h +++ b/include/wx/univ/listbox.h @@ -106,6 +106,9 @@ public: // override some more base class methods virtual bool SetFont(const wxFont& font); + virtual void Refresh( bool eraseBackground = TRUE, + const wxRect *rect = (const wxRect *) NULL ); + // the wxUniversal-specific additions // the current item is the same as the selected one for wxLB_SINGLE diff --git a/samples/univ/univ.cpp b/samples/univ/univ.cpp index 2c342b9f40..2f4ea75aa8 100644 --- a/samples/univ/univ.cpp +++ b/samples/univ/univ.cpp @@ -48,8 +48,8 @@ #include "wx/univ/theme.h" -#define DEBUG_SCROLL -//#define DEBUG_LISTBOX +//#define DEBUG_SCROLL +#define DEBUG_LISTBOX // ---------------------------------------------------------------------------- // resources diff --git a/src/univ/listbox.cpp b/src/univ/listbox.cpp index ef8a7a0e39..4079b36812 100644 --- a/src/univ/listbox.cpp +++ b/src/univ/listbox.cpp @@ -264,6 +264,15 @@ int wxListBox::GetSelections(wxArrayInt& selections) const // added/deleted/changed subsequently // ---------------------------------------------------------------------------- +void wxListBox::Refresh(bool eraseBackground, const wxRect *rect) +{ + // do nothing here if we didn't call it ourselves + if ( m_updateCount ) + { + wxControl::Refresh(eraseBackground, rect); + } +} + void wxListBox::RefreshItems(int from, int count) { switch ( m_updateCount ) @@ -342,14 +351,16 @@ void wxListBox::OnIdle(wxIdleEvent& event) } else { - wxLogTrace(_T("listbox"), _T("Refreshing items %d..%d"), - m_updateFrom, m_updateFrom + m_updateCount); - wxRect rect; rect.x = 0; rect.y = m_updateFrom*GetLineHeight(); rect.width = 32767; // larger than our size rect.height = m_updateCount*GetLineHeight(); + + wxLogTrace(_T("listbox"), _T("Refreshing items %d..%d (%d-%d)"), + m_updateFrom, m_updateFrom + m_updateCount, + rect.GetTop(), rect.GetBottom()); + Refresh(TRUE, &rect); } @@ -376,7 +387,8 @@ void wxListBox::DoDraw(wxControlRenderer *renderer) GetViewStart(NULL, &y); #endif wxCoord lineHeight = GetLineHeight(); - wxRect rectUpdate = GetUpdateRegion().GetBox(); + wxRegion rgnUpdate = GetUpdateRegion(); + wxRect rectUpdate = rgnUpdate.GetBox(); size_t itemFirst = rectUpdate.GetTop() / lineHeight, itemLast = (rectUpdate.GetBottom() + lineHeight - 1) / lineHeight, itemMax = m_strings.GetCount(); @@ -390,6 +402,7 @@ void wxListBox::DoDraw(wxControlRenderer *renderer) // do draw them wxLogTrace(_T("listbox"), _T("Repainting items %d..%d"), itemFirst, itemLast); + dc.SetClippingRegion(rgnUpdate); renderer->DrawItems(this, itemFirst, itemLast); } @@ -411,7 +424,7 @@ bool wxListBox::SetFont(const wxFont& font) void wxListBox::CalcItemsPerPage() { - m_lineHeight = wxClientDC(this).GetCharHeight(); + m_lineHeight = wxClientDC(this).GetCharHeight() + 2; m_itemsPerPage = GetClientSize().y / m_lineHeight; } @@ -671,7 +684,8 @@ bool wxStdListboxInputHandler::HandleMouse(wxControl *control, bool wxStdListboxInputHandler::HandleMouseMove(wxControl *control, const wxMouseEvent& event) { - return wxStdInputHandler::HandleMouseMove(control, event); + // we don't react to this at all + return FALSE; } #endif // wxUSE_LISTBOX diff --git a/src/univ/themes/gtk.cpp b/src/univ/themes/gtk.cpp index d2aa36e077..d7d75f4adf 100644 --- a/src/univ/themes/gtk.cpp +++ b/src/univ/themes/gtk.cpp @@ -166,7 +166,7 @@ protected: // returns the size of the arrow for the scrollbar (depends on // orientation) - wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar) + wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar) const { wxSize size; if ( scrollbar->IsVertical() ) @@ -371,8 +371,8 @@ wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col, case CONTROL_TEXT: return *wxBLACK; case SCROLLBAR: return wxColour(0xc3c3c3); - case HIGHLIGHT: return wxColour(0x0000ff); - case HIGHLIGHT_TEXT: return wxColour(0x00ffff); + case HIGHLIGHT: return wxColour(0x9c0000); + case HIGHLIGHT_TEXT: return wxColour(0xffffff); case MAX: default: @@ -705,24 +705,36 @@ void wxGTKRenderer::DrawItem(wxDC& dc, const wxRect& rect, int flags) { + wxLogTrace(_T("listbox"), _T("drawing item '%s' at (%d, %d)-(%d, %d)"), + label.c_str(), + rect.x, rect.y, + rect.x + rect.width, rect.y + rect.height); + + wxColour colFg; if ( flags & wxCONTROL_SELECTED ) { - dc.SetTextBackground(m_scheme->Get(wxColourScheme::HIGHLIGHT)); + dc.SetBrush(wxBrush(m_scheme->Get(wxColourScheme::HIGHLIGHT), wxSOLID)); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(rect); + + colFg = dc.GetTextForeground(); dc.SetTextForeground(m_scheme->Get(wxColourScheme::HIGHLIGHT_TEXT)); - dc.SetBackgroundMode(wxSOLID); } - dc.DrawLabel(label, wxNullBitmap, rect); + wxRect rectText = rect; + rectText.x += 2; + rectText.y++; + dc.DrawLabel(label, wxNullBitmap, rectText); if ( flags & wxCONTROL_SELECTED ) { dc.SetBackgroundMode(wxTRANSPARENT); } - if ( flags & wxCONTROL_FOCUSED ) + // restore the text colour + if ( colFg.Ok() ) { - wxRect rectFocus = rect; - DrawRect(dc, &rectFocus, m_penBlack); + dc.SetTextForeground(colFg); } } @@ -1208,6 +1220,12 @@ bool wxGTKInputHandler::HandleMouseMove(wxControl *control, return FALSE; } + // don't refresh static controls uselessly - they never react to this + if ( control->AcceptsFocus() ) + { + control->Refresh(); + } + return TRUE; }