attemps to make listbox refreshing to work - failed

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8239 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-09-01 20:17:10 +00:00
parent 7ba00152a6
commit afcd76dae8
4 changed files with 52 additions and 17 deletions

View File

@@ -106,6 +106,9 @@ public:
// override some more base class methods // override some more base class methods
virtual bool SetFont(const wxFont& font); virtual bool SetFont(const wxFont& font);
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *) NULL );
// the wxUniversal-specific additions // the wxUniversal-specific additions
// the current item is the same as the selected one for wxLB_SINGLE // the current item is the same as the selected one for wxLB_SINGLE

View File

@@ -48,8 +48,8 @@
#include "wx/univ/theme.h" #include "wx/univ/theme.h"
#define DEBUG_SCROLL //#define DEBUG_SCROLL
//#define DEBUG_LISTBOX #define DEBUG_LISTBOX
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// resources // resources

View File

@@ -264,6 +264,15 @@ int wxListBox::GetSelections(wxArrayInt& selections) const
// added/deleted/changed subsequently // 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) void wxListBox::RefreshItems(int from, int count)
{ {
switch ( m_updateCount ) switch ( m_updateCount )
@@ -342,14 +351,16 @@ void wxListBox::OnIdle(wxIdleEvent& event)
} }
else else
{ {
wxLogTrace(_T("listbox"), _T("Refreshing items %d..%d"),
m_updateFrom, m_updateFrom + m_updateCount);
wxRect rect; wxRect rect;
rect.x = 0; rect.x = 0;
rect.y = m_updateFrom*GetLineHeight(); rect.y = m_updateFrom*GetLineHeight();
rect.width = 32767; // larger than our size rect.width = 32767; // larger than our size
rect.height = m_updateCount*GetLineHeight(); 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); Refresh(TRUE, &rect);
} }
@@ -376,7 +387,8 @@ void wxListBox::DoDraw(wxControlRenderer *renderer)
GetViewStart(NULL, &y); GetViewStart(NULL, &y);
#endif #endif
wxCoord lineHeight = GetLineHeight(); wxCoord lineHeight = GetLineHeight();
wxRect rectUpdate = GetUpdateRegion().GetBox(); wxRegion rgnUpdate = GetUpdateRegion();
wxRect rectUpdate = rgnUpdate.GetBox();
size_t itemFirst = rectUpdate.GetTop() / lineHeight, size_t itemFirst = rectUpdate.GetTop() / lineHeight,
itemLast = (rectUpdate.GetBottom() + lineHeight - 1) / lineHeight, itemLast = (rectUpdate.GetBottom() + lineHeight - 1) / lineHeight,
itemMax = m_strings.GetCount(); itemMax = m_strings.GetCount();
@@ -390,6 +402,7 @@ void wxListBox::DoDraw(wxControlRenderer *renderer)
// do draw them // do draw them
wxLogTrace(_T("listbox"), _T("Repainting items %d..%d"), wxLogTrace(_T("listbox"), _T("Repainting items %d..%d"),
itemFirst, itemLast); itemFirst, itemLast);
dc.SetClippingRegion(rgnUpdate);
renderer->DrawItems(this, itemFirst, itemLast); renderer->DrawItems(this, itemFirst, itemLast);
} }
@@ -411,7 +424,7 @@ bool wxListBox::SetFont(const wxFont& font)
void wxListBox::CalcItemsPerPage() void wxListBox::CalcItemsPerPage()
{ {
m_lineHeight = wxClientDC(this).GetCharHeight(); m_lineHeight = wxClientDC(this).GetCharHeight() + 2;
m_itemsPerPage = GetClientSize().y / m_lineHeight; m_itemsPerPage = GetClientSize().y / m_lineHeight;
} }
@@ -671,7 +684,8 @@ bool wxStdListboxInputHandler::HandleMouse(wxControl *control,
bool wxStdListboxInputHandler::HandleMouseMove(wxControl *control, bool wxStdListboxInputHandler::HandleMouseMove(wxControl *control,
const wxMouseEvent& event) const wxMouseEvent& event)
{ {
return wxStdInputHandler::HandleMouseMove(control, event); // we don't react to this at all
return FALSE;
} }
#endif // wxUSE_LISTBOX #endif // wxUSE_LISTBOX

View File

@@ -166,7 +166,7 @@ protected:
// returns the size of the arrow for the scrollbar (depends on // returns the size of the arrow for the scrollbar (depends on
// orientation) // orientation)
wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar) wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar) const
{ {
wxSize size; wxSize size;
if ( scrollbar->IsVertical() ) if ( scrollbar->IsVertical() )
@@ -371,8 +371,8 @@ wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col,
case CONTROL_TEXT: return *wxBLACK; case CONTROL_TEXT: return *wxBLACK;
case SCROLLBAR: return wxColour(0xc3c3c3); case SCROLLBAR: return wxColour(0xc3c3c3);
case HIGHLIGHT: return wxColour(0x0000ff); case HIGHLIGHT: return wxColour(0x9c0000);
case HIGHLIGHT_TEXT: return wxColour(0x00ffff); case HIGHLIGHT_TEXT: return wxColour(0xffffff);
case MAX: case MAX:
default: default:
@@ -705,24 +705,36 @@ void wxGTKRenderer::DrawItem(wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags) 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 ) 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.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 ) if ( flags & wxCONTROL_SELECTED )
{ {
dc.SetBackgroundMode(wxTRANSPARENT); dc.SetBackgroundMode(wxTRANSPARENT);
} }
if ( flags & wxCONTROL_FOCUSED ) // restore the text colour
if ( colFg.Ok() )
{ {
wxRect rectFocus = rect; dc.SetTextForeground(colFg);
DrawRect(dc, &rectFocus, m_penBlack);
} }
} }
@@ -1208,6 +1220,12 @@ bool wxGTKInputHandler::HandleMouseMove(wxControl *control,
return FALSE; return FALSE;
} }
// don't refresh static controls uselessly - they never react to this
if ( control->AcceptsFocus() )
{
control->Refresh();
}
return TRUE; return TRUE;
} }