From d0b9653f6cd85085ae397e5009c0e63280cc4021 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 5 Sep 2000 19:21:57 +0000 Subject: [PATCH] attempts to fix GTK refresh - completely fruitless so far git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8264 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/univ/renderer.h | 2 +- src/univ/control.cpp | 2 +- src/univ/renderer.cpp | 9 ++++++-- src/univ/themes/gtk.cpp | 40 ++++++++++++++++++++++++++------- src/univ/winuniv.cpp | 46 +++++++++++++++++++++++--------------- 5 files changed, 69 insertions(+), 30 deletions(-) diff --git a/include/wx/univ/renderer.h b/include/wx/univ/renderer.h index fedc58176b..870b8d9067 100644 --- a/include/wx/univ/renderer.h +++ b/include/wx/univ/renderer.h @@ -289,7 +289,7 @@ public: virtual void AdjustSize(wxSize *size, const wxWindow *window) { m_renderer->AdjustSize(size, window); } virtual wxRect GetBorderDimensions(wxBorder border) const - { m_renderer->GetBorderDimensions(border); } + { return m_renderer->GetBorderDimensions(border); } virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar, wxScrollBar::Element elem, diff --git a/src/univ/control.cpp b/src/univ/control.cpp index 1bd4a65ee5..79797b78a9 100644 --- a/src/univ/control.cpp +++ b/src/univ/control.cpp @@ -79,7 +79,7 @@ bool wxControl::Create(wxWindow *parent, m_handler = CreateInputHandler(); - SetBackgroundColour(parent->GetBackgroundColour()); + //SetBackgroundColour(parent->GetBackgroundColour()); return TRUE; } diff --git a/src/univ/renderer.cpp b/src/univ/renderer.cpp index 5f03a976b4..d1e55c82fe 100644 --- a/src/univ/renderer.cpp +++ b/src/univ/renderer.cpp @@ -376,8 +376,13 @@ void wxControlRenderer::DrawButtonBorder() m_renderer->DrawButtonBorder(m_dc, m_rect, flags, &m_rect); - m_renderer->DrawBackground(m_dc, m_window->GetBackgroundColour(), - m_rect, flags); + wxColour colBg; + if ( !(flags & wxCONTROL_CURRENT) ) + { + colBg = m_window->GetBackgroundColour(); + } + + m_renderer->DrawBackground(m_dc, colBg, m_rect, flags); } void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap) diff --git a/src/univ/themes/gtk.cpp b/src/univ/themes/gtk.cpp index 6bcc16454a..e8c813b8e6 100644 --- a/src/univ/themes/gtk.cpp +++ b/src/univ/themes/gtk.cpp @@ -374,7 +374,15 @@ wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col, return wxColour(0xd6d6d6); } - case CONTROL_TEXT: return *wxBLACK; + case CONTROL_TEXT: if ( flags & wxCONTROL_DISABLED ) + { + return wxColour(0x757575); + } + else + { + return *wxBLACK; + } + case SCROLLBAR: return wxColour(0xc3c3c3); case HIGHLIGHT: return wxColour(0x9c0000); @@ -733,12 +741,12 @@ void wxGTKRenderer::DrawLabel(wxDC& dc, if ( flags & wxCONTROL_DISABLED ) { // make the text grey and draw a shade for it - dc.SetTextForeground(0xe0e0e0); + dc.SetTextForeground(*wxWHITE); // FIXME hardcoded colour wxRect rectShadow = rect; rectShadow.x++; rectShadow.y++; dc.DrawLabel(label, rectShadow, alignment, indexAccel); - dc.SetTextForeground(0x7f7f7f); + dc.SetTextForeground(m_scheme->Get(wxColourScheme::CONTROL_TEXT, flags)); } dc.DrawLabel(label, image, rect, alignment, indexAccel, rectBounds); @@ -808,10 +816,17 @@ void wxGTKRenderer::DrawBackground(wxDC& dc, const wxRect& rect, int flags) { - DoDrawBackground(dc, - col.Ok() ? col - : GetBackgroundColour(flags), - rect); + wxColour colBg; + if ( !col.Ok() ) + { + colBg = m_scheme->Get(wxColourScheme::CONTROL, flags); + } + else + { + colBg = col; + } + + DoDrawBackground(dc, colBg, rect); } // ---------------------------------------------------------------------------- @@ -1142,8 +1157,17 @@ wxRect wxGTKRenderer::GetScrollbarRect(const wxScrollBar *scrollbar, wxScrollBar::Element elem, int thumbPos) const { + // as GTK scrollbars can't be disabled, it makes no sense to remove the + // thumb for a scrollbar with range 0 - instead, make it fill the entire + // scrollbar shaft + if ( (elem == wxScrollBar::Element_Thumb) && !scrollbar->GetRange() ) + { + elem = wxScrollBar::Element_Bar_2; + } + return StandardGetScrollbarRect(scrollbar, elem, - thumbPos, GetScrollbarArrowSize(scrollbar)); + thumbPos, + GetScrollbarArrowSize(scrollbar)); } wxCoord wxGTKRenderer::GetScrollbarSize(const wxScrollBar *scrollbar) diff --git a/src/univ/winuniv.cpp b/src/univ/winuniv.cpp index 04878ed7a6..e2350597dd 100644 --- a/src/univ/winuniv.cpp +++ b/src/univ/winuniv.cpp @@ -143,10 +143,8 @@ void wxWindow::OnErase(wxEraseEvent& event) if ( m_scrollbarVert && m_scrollbarHorz ) { wxRect rectCorner; - wxPoint ptOrigin = GetClientAreaOrigin(); - wxSize sizeClient = GetClientSize(); - rectCorner.x = ptOrigin.x + m_scrollbarHorz->GetSize().x; - rectCorner.y = ptOrigin.y + m_scrollbarVert->GetSize().y; + rectCorner.x = m_scrollbarHorz->GetSize().x; + rectCorner.y = m_scrollbarVert->GetSize().y; rectCorner.width = m_scrollbarVert->GetSize().x; rectCorner.height = m_scrollbarHorz->GetSize().y; m_renderer->DrawScrollCorner(*event.GetDC(), rectCorner); @@ -306,20 +304,27 @@ void wxWindow::DoGetClientSize(int *width, int *height) const if ( m_renderer ) rectBorder = m_renderer->GetBorderDimensions(GetBorder()); + // TODO these calculations suppose that we position the scrollbars in such + // way that they overwrite some borders - when this is changed (see + // the next todo item below) this code must be updated too if ( width ) { if ( m_scrollbarVert ) *width -= m_scrollbarVert->GetSize().x; + else + *width -= rectBorder.width; - *width -= rectBorder.x + rectBorder.width; + *width -= rectBorder.x; } if ( height ) { if ( m_scrollbarHorz ) *height -= m_scrollbarHorz->GetSize().y; + else + *height -= rectBorder.height; - *height -= rectBorder.y + rectBorder.height; + *height -= rectBorder.y; } } @@ -331,25 +336,30 @@ void wxWindow::DoGetClientSize(int *width, int *height) const void wxWindow::PositionScrollbars() { - wxRect rectClient = GetClientRect(); - - int width = m_scrollbarVert ? m_scrollbarVert->GetSize().x : 0; - int height = m_scrollbarHorz ? m_scrollbarHorz->GetSize().y : 0; + wxRect rectClient = GetClientRect(), + rectTotal = wxRect(wxPoint(0, 0), GetSize()); + // TODO we should be smarter about combining the scrollbar borders with + // the window ones - so far we just blend the right and bottom + // borders of the vertical scrollbar (and left/bottom of the + // horizontal one) into the window border, but this risks to look + // ugly with other renderers/border styles if ( m_scrollbarVert ) { - m_scrollbarVert->SetSize(rectClient.GetRight() - 1, - rectClient.GetTop() - 2, - width, - rectClient.GetHeight()); + m_scrollbarVert->SetSize(rectClient.GetRight() + 1, + rectTotal.GetTop(), + m_scrollbarVert->GetSize().x, + m_scrollbarHorz ? rectClient.GetBottom() + 1 + : rectTotal.GetBottom() + 1); } if ( m_scrollbarHorz ) { - m_scrollbarHorz->SetSize(rectClient.GetLeft() - 2, - rectClient.GetBottom() - 1, - rectClient.GetWidth(), - height); + m_scrollbarHorz->SetSize(rectTotal.GetLeft(), + rectClient.GetBottom() + 1, + m_scrollbarVert ? rectClient.GetRight() + 1 + : rectTotal.GetRight() + 1, + m_scrollbarHorz->GetSize().y); } }