wxScrollBar drawing seems to work for wxGTK too

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8238 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-09-01 19:27:58 +00:00
parent 5096d88d2f
commit 7ba00152a6
12 changed files with 354 additions and 73 deletions

View File

@@ -27,7 +27,6 @@
WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
WXDLLEXPORT_DATA(extern wxWindowMSW*) wxWndHook;
class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxStatusBar; class WXDLLEXPORT wxStatusBar;

View File

@@ -16,6 +16,8 @@
#pragma interface "frame.h" #pragma interface "frame.h"
#endif #endif
WXDLLEXPORT_DATA(extern wxWindowMSW*) wxWndHook;
class WXDLLEXPORT wxFrame : public wxFrameBase class WXDLLEXPORT wxFrame : public wxFrameBase
{ {
public: public:

View File

@@ -156,11 +156,11 @@ protected:
void SetElementState(wxScrollBar *scrollbar, int flag, bool doIt); void SetElementState(wxScrollBar *scrollbar, int flag, bool doIt);
// [un]highlight the scrollbar element corresponding to m_htLast // [un]highlight the scrollbar element corresponding to m_htLast
void Highlight(wxScrollBar *scrollbar, bool doIt) virtual void Highlight(wxScrollBar *scrollbar, bool doIt)
{ SetElementState(scrollbar, wxCONTROL_CURRENT, doIt); } { SetElementState(scrollbar, wxCONTROL_CURRENT, doIt); }
// [un]press the scrollbar element corresponding to m_htLast // [un]press the scrollbar element corresponding to m_htLast
void Press(wxScrollBar *scrollbar, bool doIt) virtual void Press(wxScrollBar *scrollbar, bool doIt)
{ SetElementState(scrollbar, wxCONTROL_PRESSED, doIt); } { SetElementState(scrollbar, wxCONTROL_PRESSED, doIt); }
// stop scrolling because we reached the end point // stop scrolling because we reached the end point

View File

@@ -125,11 +125,13 @@ public:
// draw the scrollbar thumb // draw the scrollbar thumb
virtual void DrawScrollbarThumb(wxDC& dc, virtual void DrawScrollbarThumb(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0) = 0; int flags = 0) = 0;
// draw a (part of) scrollbar shaft // draw a (part of) scrollbar shaft
virtual void DrawScrollbarShaft(wxDC& dc, virtual void DrawScrollbarShaft(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0) = 0; int flags = 0) = 0;
@@ -255,13 +257,15 @@ public:
int flags = 0) int flags = 0)
{ m_renderer->DrawArrow(dc, dir, rect, flags); } { m_renderer->DrawArrow(dc, dir, rect, flags); }
virtual void DrawScrollbarThumb(wxDC& dc, virtual void DrawScrollbarThumb(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0) int flags = 0)
{ m_renderer->DrawScrollbarThumb(dc, rect, flags); } { m_renderer->DrawScrollbarThumb(dc, orient, rect, flags); }
virtual void DrawScrollbarShaft(wxDC& dc, virtual void DrawScrollbarShaft(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0) int flags = 0)
{ m_renderer->DrawScrollbarShaft(dc, rect, flags); } { m_renderer->DrawScrollbarShaft(dc, orient, rect, flags); }
virtual void DrawItem(wxDC& dc, virtual void DrawItem(wxDC& dc,
const wxString& label, const wxString& label,
const wxRect& rect, const wxRect& rect,

View File

@@ -48,7 +48,8 @@
#include "wx/univ/theme.h" #include "wx/univ/theme.h"
//#define DEBUG_SCROLL #define DEBUG_SCROLL
//#define DEBUG_LISTBOX
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// resources // resources
@@ -190,7 +191,9 @@ bool MyUnivApp::OnInit()
#ifdef DEBUG_SCROLL #ifdef DEBUG_SCROLL
wxLog::AddTraceMask(_T("scroll")); wxLog::AddTraceMask(_T("scroll"));
#endif #endif
#ifdef DEBUG_LISTBOX
wxLog::AddTraceMask(_T("listbox")); wxLog::AddTraceMask(_T("listbox"));
#endif
return TRUE; return TRUE;
} }

View File

@@ -32,7 +32,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/generic/scrolwin.h" #include "wx/scrolwin.h"
#include "wx/panel.h" #include "wx/panel.h"
#ifdef __WXMSW__ #ifdef __WXMSW__

View File

@@ -4,6 +4,7 @@ UNIVOBJS = \
colschem.o \ colschem.o \
control.o \ control.o \
inphand.o \ inphand.o \
listbox.o \
renderer.o \ renderer.o \
scrolbar.o \ scrolbar.o \
statbmp.o \ statbmp.o \
@@ -21,6 +22,7 @@ UNIVDEPS = \
colschem.d \ colschem.d \
control.d \ control.d \
inphand.d \ inphand.d \
listbox.d \
renderer.d \ renderer.d \
scrolbar.d \ scrolbar.d \
statbmp.d \ statbmp.d \

View File

@@ -30,6 +30,8 @@
#if wxUSE_LISTBOX #if wxUSE_LISTBOX
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/listbox.h" #include "wx/listbox.h"
#include "wx/validate.h" #include "wx/validate.h"

View File

@@ -31,6 +31,7 @@
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/app.h" #include "wx/app.h"
#include "wx/control.h" #include "wx/control.h"
#include "wx/listbox.h"
#include "wx/scrolbar.h" #include "wx/scrolbar.h"
#include "wx/dc.h" #include "wx/dc.h"
#endif // WX_PRECOMP #endif // WX_PRECOMP
@@ -475,6 +476,44 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
// we will only redraw the parts which must be redrawn and not everything // we will only redraw the parts which must be redrawn and not everything
wxRegion rgnUpdate = scrollbar->GetUpdateRegion(); wxRegion rgnUpdate = scrollbar->GetUpdateRegion();
{
wxRect rectUpdate = rgnUpdate.GetBox();
wxLogTrace(_T("scroll"), _T("%s redraw: update box is (%d, %d)-(%d, %d)"),
scrollbar->IsVertical() ? _T("vert") : _T("horz"),
rectUpdate.GetLeft(),
rectUpdate.GetTop(),
rectUpdate.GetRight(),
rectUpdate.GetBottom());
}
wxOrientation orient = scrollbar->IsVertical() ? wxVERTICAL
: wxHORIZONTAL;
// the shaft
for ( int nBar = 0; nBar < 2; nBar++ )
{
wxScrollBar::Element elem =
(wxScrollBar::Element)(wxScrollBar::Element_Bar_1 + nBar);
wxRect rectBar = m_renderer->GetScrollbarRect(scrollbar, elem);
if ( rgnUpdate.Contains(rectBar) )
{
wxLogTrace(_T("scroll"),
_T("drawing bar part %d at (%d, %d)-(%d, %d)"),
nBar + 1,
rectBar.GetLeft(),
rectBar.GetTop(),
rectBar.GetRight(),
rectBar.GetBottom());
m_renderer->DrawScrollbarShaft(m_dc,
orient,
rectBar,
scrollbar->GetState(elem));
}
}
// arrows // arrows
static const wxDirection arrowDirs[2][2] = static const wxDirection arrowDirs[2][2] =
{ {
@@ -490,6 +529,14 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
wxRect rectArrow = m_renderer->GetScrollbarRect(scrollbar, elem); wxRect rectArrow = m_renderer->GetScrollbarRect(scrollbar, elem);
if ( rgnUpdate.Contains(rectArrow) ) if ( rgnUpdate.Contains(rectArrow) )
{ {
wxLogTrace(_T("scroll"),
_T("drawing arrow %d at (%d, %d)-(%d, %d)"),
nArrow + 1,
rectArrow.GetLeft(),
rectArrow.GetTop(),
rectArrow.GetRight(),
rectArrow.GetBottom());
m_renderer->DrawArrow(m_dc, m_renderer->DrawArrow(m_dc,
arrowDirs[scrollbar->IsVertical()][nArrow], arrowDirs[scrollbar->IsVertical()][nArrow],
rectArrow, rectArrow,
@@ -499,53 +546,20 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
// TODO: support for page arrows // TODO: support for page arrows
// the shaft
for ( int nBar = 0; nBar < 2; nBar++ )
{
wxScrollBar::Element elem =
(wxScrollBar::Element)(wxScrollBar::Element_Bar_1 + nBar);
wxRect rectBar = m_renderer->GetScrollbarRect(scrollbar, elem);
if ( rgnUpdate.Contains(rectBar) )
{
#if 0
// we try to avoid redrawing the entire shaft (which might be quite
// long) if possible by only redrawing the area between the old and
// current positions of the thumb
if ( thumbPosOld != -1 )
{
wxRect rectBarOld = m_renderer->GetScrollbarRect(scrollbar,
elem,
thumbPosOld);
if ( scrollbar->IsVertical() )
{
if ( nBar )
rectBar.SetBottom(rectBar.GetTop());
else
rectBar.SetTop(rectBarOld.GetBottom());
}
else // horizontal
{
if ( nBar )
rectBar.SetRight(rectBar.GetLeft());
else
rectBar.SetLeft(rectBarOld.GetRight());
}
}
#endif // 0
m_renderer->DrawScrollbarShaft(m_dc, rectBar,
scrollbar->GetState(elem));
}
}
// and the thumb // and the thumb
wxScrollBar::Element elem = wxScrollBar::Element_Thumb; wxScrollBar::Element elem = wxScrollBar::Element_Thumb;
wxRect rectThumb = m_renderer->GetScrollbarRect(scrollbar, elem); wxRect rectThumb = m_renderer->GetScrollbarRect(scrollbar, elem);
if ( rgnUpdate.Contains(rectThumb) ) if ( rgnUpdate.Contains(rectThumb) )
{ {
m_renderer->DrawScrollbarThumb(m_dc, rectThumb, wxLogTrace(_T("scroll"), _T("drawing thumb at (%d, %d)-(%d, %d)"),
rectThumb.GetLeft(),
rectThumb.GetTop(),
rectThumb.GetRight(),
rectThumb.GetBottom());
m_renderer->DrawScrollbarThumb(m_dc,
orient,
rectThumb,
scrollbar->GetState(elem)); scrollbar->GetState(elem));
} }
} }

View File

@@ -216,12 +216,35 @@ void wxScrollBar::OnIdle(wxIdleEvent& event)
if ( m_elementsState[n] & wxCONTROL_DIRTY ) if ( m_elementsState[n] & wxCONTROL_DIRTY )
{ {
wxRect rect = GetRenderer()->GetScrollbarRect(this, (Element)n); wxRect rect = GetRenderer()->GetScrollbarRect(this, (Element)n);
if ( rect.width && rect.height ) if ( rect.width && rect.height )
{ {
// don't refresh the background when refreshing the shaft // we try to avoid redrawing the entire shaft (which might
Refresh(TRUE, //(n != Element_Bar_1) && (n != Element_Bar_2) // be quite long) if possible by only redrawing the area
&rect); // between the old and current positions of the thumb
if ( m_thumbPosOld != -1 )
{
wxRect rectOld =
GetRenderer()->GetScrollbarRect(this,
(Element)n,
m_thumbPosOld);
if ( IsVertical() )
{
if ( n == Element_Bar_1 )
rect.SetTop(rectOld.GetBottom());
else
rect.SetBottom(rect.GetTop());
}
else // horizontal
{
if ( n == Element_Bar_1 )
rect.SetLeft(rectOld.GetRight());
else
rect.SetRight(rect.GetLeft());
}
}
Refresh(TRUE, &rect);
} }
m_elementsState[n] &= ~wxCONTROL_DIRTY; m_elementsState[n] &= ~wxCONTROL_DIRTY;
@@ -247,7 +270,7 @@ void wxScrollBar::DoDraw(wxControlRenderer *renderer)
void wxScrollBar::SetState(Element which, int flags) void wxScrollBar::SetState(Element which, int flags)
{ {
if ( (m_elementsState[which] & ~wxCONTROL_DIRTY) != flags ) if ( (m_elementsState[which] & ~wxCONTROL_DIRTY) != (unsigned)flags )
{ {
m_elementsState[which] = flags | wxCONTROL_DIRTY; m_elementsState[which] = flags | wxCONTROL_DIRTY;

View File

@@ -88,9 +88,11 @@ public:
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawScrollbarThumb(wxDC& dc, virtual void DrawScrollbarThumb(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawScrollbarShaft(wxDC& dc, virtual void DrawScrollbarShaft(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawItem(wxDC& dc, virtual void DrawItem(wxDC& dc,
@@ -141,9 +143,45 @@ protected:
void DrawAntiShadedRect(wxDC& dc, wxRect *rect, void DrawAntiShadedRect(wxDC& dc, wxRect *rect,
const wxPen& pen1, const wxPen& pen2); const wxPen& pen1, const wxPen& pen2);
// used for drawing opened rectangles - draws only one side of it at once
// (and doesn't adjust the rect)
void DrawAntiShadedRectSide(wxDC& dc,
const wxRect& rect,
const wxPen& pen1,
const wxPen& pen2,
wxDirection dir);
// draw an opened rect for the arrow in given direction
void DrawArrowBorder(wxDC& dc,
wxRect *rect,
wxDirection dir);
// draw two sides of the rectangle
void DrawThumbBorder(wxDC& dc,
wxRect *rect,
wxOrientation orient);
// draw the normal 3D border // draw the normal 3D border
void DrawRaisedBorder(wxDC& dc, wxRect *rect); void DrawRaisedBorder(wxDC& dc, wxRect *rect);
// returns the size of the arrow for the scrollbar (depends on
// orientation)
wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar)
{
wxSize size;
if ( scrollbar->IsVertical() )
{
size = m_sizeScrollbarArrow;
}
else
{
size.x = m_sizeScrollbarArrow.y;
size.y = m_sizeScrollbarArrow.x;
}
return size;
}
private: private:
const wxColourScheme *m_scheme; const wxColourScheme *m_scheme;
@@ -186,7 +224,31 @@ public:
: wxStdScrollBarInputHandler(renderer, handler) { } : wxStdScrollBarInputHandler(renderer, handler) { }
protected: protected:
virtual void Highlight(wxScrollBar *scrollbar, bool doIt)
{
// only arrows and the thumb can be highlighted
if ( !IsArrow() && m_htLast != wxHT_SCROLLBAR_THUMB )
return;
wxStdScrollBarInputHandler::Highlight(scrollbar, doIt);
}
virtual void Press(wxScrollBar *scrollbar, bool doIt)
{
// only arrows can be pressed
if ( !IsArrow() )
return;
wxStdScrollBarInputHandler::Press(scrollbar, doIt);
}
virtual bool IsAllowedButton(int WXUNUSED(button)) { return TRUE; } virtual bool IsAllowedButton(int WXUNUSED(button)) { return TRUE; }
bool IsArrow() const
{
return m_htLast == wxHT_SCROLLBAR_ARROW_LINE_1 ||
m_htLast == wxHT_SCROLLBAR_ARROW_LINE_2;
}
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -262,6 +324,8 @@ wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control)
else if ( control == _T("wxScrollBar") ) else if ( control == _T("wxScrollBar") )
handler = new wxGTKScrollBarInputHandler(m_renderer, handler = new wxGTKScrollBarInputHandler(m_renderer,
GetInputHandler(_T("wxControl"))); GetInputHandler(_T("wxControl")));
else if ( control == _T("wxListBox") )
handler = new wxStdListboxInputHandler(GetInputHandler(_T("wxControl")));
else else
handler = new wxGTKInputHandler(m_renderer); handler = new wxGTKInputHandler(m_renderer);
@@ -329,7 +393,7 @@ wxGTKRenderer::wxGTKRenderer(const wxColourScheme *scheme)
{ {
// init data // init data
m_scheme = scheme; m_scheme = scheme;
m_sizeScrollbarArrow = wxSize(12, 12); m_sizeScrollbarArrow = wxSize(16, 14);
// init pens // init pens
m_penBlack = wxPen(scheme->Get(wxColourScheme::SHADOW_DARK), 0, wxSOLID); m_penBlack = wxPen(scheme->Get(wxColourScheme::SHADOW_DARK), 0, wxSOLID);
@@ -387,6 +451,41 @@ void wxGTKRenderer::DrawShadedRect(wxDC& dc, wxRect *rect,
rect->Inflate(-1); rect->Inflate(-1);
} }
void wxGTKRenderer::DrawAntiShadedRectSide(wxDC& dc,
const wxRect& rect,
const wxPen& pen1,
const wxPen& pen2,
wxDirection dir)
{
dc.SetPen(dir == wxLEFT || dir == wxUP ? pen1 : pen2);
switch ( dir )
{
case wxLEFT:
dc.DrawLine(rect.GetLeft(), rect.GetTop(),
rect.GetLeft(), rect.GetBottom() + 1);
break;
case wxUP:
dc.DrawLine(rect.GetLeft(), rect.GetTop(),
rect.GetRight() + 1, rect.GetTop());
break;
case wxRIGHT:
dc.DrawLine(rect.GetRight(), rect.GetTop(),
rect.GetRight(), rect.GetBottom() + 1);
break;
case wxDOWN:
dc.DrawLine(rect.GetLeft(), rect.GetBottom(),
rect.GetRight() + 1, rect.GetBottom());
break;
default:
wxFAIL_MSG(_T("unknown rectangle side"));
}
}
void wxGTKRenderer::DrawAntiShadedRect(wxDC& dc, wxRect *rect, void wxGTKRenderer::DrawAntiShadedRect(wxDC& dc, wxRect *rect,
const wxPen& pen1, const wxPen& pen2) const wxPen& pen1, const wxPen& pen2)
{ {
@@ -656,13 +755,98 @@ void wxGTKRenderer::DrawBackground(wxDC& dc,
// scrollbar // scrollbar
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxGTKRenderer::DrawArrowBorder(wxDC& dc,
wxRect *rect,
wxDirection dir)
{
static const wxDirection sides[] =
{
wxUP, wxLEFT, wxRIGHT, wxDOWN
};
wxRect rect1, rect2, rectInner;
rect1 =
rect2 =
rectInner = *rect;
rect2.Inflate(-1);
rectInner.Inflate(-2);
// find the side not to draw and also adjust the rectangles to compensate
// for it
wxDirection sideToOmit;
switch ( dir )
{
case wxUP:
sideToOmit = wxDOWN;
rect2.height += 1;
rectInner.height += 2;
break;
case wxDOWN:
sideToOmit = wxUP;
rect2.y -= 1;
rect2.height += 1;
rectInner.y -= 2;
rectInner.height += 2;
break;
case wxLEFT:
sideToOmit = wxRIGHT;
rect2.width += 1;
rectInner.width += 2;
break;
case wxRIGHT:
sideToOmit = wxLEFT;
rect2.x -= 1;
rect2.width += 1;
rectInner.x -= 2;
rectInner.width += 2;
break;
default:
wxFAIL_MSG(_T("unknown arrow direction"));
return;
}
// the outer rect first
size_t n;
for ( n = 0; n < WXSIZEOF(sides); n++ )
{
wxDirection side = sides[n];
if ( side == sideToOmit )
continue;
DrawAntiShadedRectSide(dc, rect1, m_penDarkGrey, m_penHighlight, side);
}
// and then the inner one
for ( n = 0; n < WXSIZEOF(sides); n++ )
{
wxDirection side = sides[n];
if ( side == sideToOmit )
continue;
DrawAntiShadedRectSide(dc, rect2, m_penBlack, m_penGrey, side);
}
*rect = rectInner;
DoDrawBackground(dc, m_scheme->Get(wxColourScheme::SCROLLBAR), rectInner);
}
// gtk_default_draw_arrow() takes ~350 lines and we can't do much better here // gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
// these people are just crazy :-( // these people are just crazy :-(
void wxGTKRenderer::DrawArrow(wxDC& dc, void wxGTKRenderer::DrawArrow(wxDC& dc,
wxDirection dir, wxDirection dir,
const wxRect& rect, const wxRect& rectArrow,
int flags) int flags)
{ {
// first of all, draw the border around it - but we don't want the border
// on the side opposite to the arrow point
wxRect rect = rectArrow;
DrawArrowBorder(dc, &rect, dir);
enum enum
{ {
Point_First, Point_First,
@@ -743,7 +927,6 @@ void wxGTKRenderer::DrawArrow(wxDC& dc,
default: default:
wxFAIL_MSG(_T("unknown arrow direction")); wxFAIL_MSG(_T("unknown arrow direction"));
return;
} }
dc.DrawPolygon(WXSIZEOF(ptArrow), ptArrow); dc.DrawPolygon(WXSIZEOF(ptArrow), ptArrow);
@@ -825,7 +1008,42 @@ void wxGTKRenderer::DrawArrow(wxDC& dc,
} }
} }
void wxGTKRenderer::DrawThumbBorder(wxDC& dc,
wxRect *rect,
wxOrientation orient)
{
if ( orient == wxVERTICAL )
{
DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight,
wxLEFT);
DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight,
wxRIGHT);
rect->Inflate(-1, 0);
DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey,
wxLEFT);
DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey,
wxRIGHT);
rect->Inflate(-1, 0);
}
else
{
DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight,
wxUP);
DrawAntiShadedRectSide(dc, *rect, m_penDarkGrey, m_penHighlight,
wxDOWN);
rect->Inflate(0, -1);
DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey,
wxUP);
DrawAntiShadedRectSide(dc, *rect, m_penBlack, m_penGrey,
wxDOWN);
rect->Inflate(0, -1);
}
}
void wxGTKRenderer::DrawScrollbarThumb(wxDC& dc, void wxGTKRenderer::DrawScrollbarThumb(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags) int flags)
{ {
@@ -833,18 +1051,21 @@ void wxGTKRenderer::DrawScrollbarThumb(wxDC& dc,
// scrollbar background never changes at all // scrollbar background never changes at all
int flagsThumb = flags & ~(wxCONTROL_PRESSED | wxCONTROL_FOCUSED); int flagsThumb = flags & ~(wxCONTROL_PRESSED | wxCONTROL_FOCUSED);
// we don't want the border in the direction of the scrollbar movement
wxRect rectThumb = rect; wxRect rectThumb = rect;
DrawThumbBorder(dc, &rectThumb, orient);
DrawButtonBorder(dc, rectThumb, flagsThumb, &rectThumb); DrawButtonBorder(dc, rectThumb, flagsThumb, &rectThumb);
DrawBackground(dc, wxNullColour, rectThumb, flagsThumb); DrawBackground(dc, wxNullColour, rectThumb, flagsThumb);
} }
void wxGTKRenderer::DrawScrollbarShaft(wxDC& dc, void wxGTKRenderer::DrawScrollbarShaft(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags) int flags)
{ {
wxRect rectBar = rect; wxRect rectBar = rect;
DrawAntiShadedRect(dc, &rectBar, m_penDarkGrey, m_penHighlight); DrawThumbBorder(dc, &rectBar, orient);
DrawAntiShadedRect(dc, &rectBar, m_penBlack, m_penGrey);
DoDrawBackground(dc, m_scheme->Get(wxColourScheme::SCROLLBAR), rectBar); DoDrawBackground(dc, m_scheme->Get(wxColourScheme::SCROLLBAR), rectBar);
} }
@@ -853,25 +1074,28 @@ wxRect wxGTKRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
int thumbPos) const int thumbPos) const
{ {
return StandardGetScrollbarRect(scrollbar, elem, return StandardGetScrollbarRect(scrollbar, elem,
thumbPos, m_sizeScrollbarArrow); thumbPos, GetScrollbarArrowSize(scrollbar));
} }
wxHitTest wxGTKRenderer::HitTestScrollbar(const wxScrollBar *scrollbar, wxHitTest wxGTKRenderer::HitTestScrollbar(const wxScrollBar *scrollbar,
const wxPoint& pt) const const wxPoint& pt) const
{ {
return StandardHitTestScrollbar(scrollbar, pt, m_sizeScrollbarArrow); return StandardHitTestScrollbar(scrollbar, pt,
GetScrollbarArrowSize(scrollbar));
} }
wxCoord wxGTKRenderer::ScrollbarToPixel(const wxScrollBar *scrollbar, wxCoord wxGTKRenderer::ScrollbarToPixel(const wxScrollBar *scrollbar,
int thumbPos) int thumbPos)
{ {
return StandardScrollbarToPixel(scrollbar, thumbPos, m_sizeScrollbarArrow); return StandardScrollbarToPixel(scrollbar, thumbPos,
GetScrollbarArrowSize(scrollbar));
} }
int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar,
wxCoord coord) wxCoord coord)
{ {
return StandardPixelToScrollbar(scrollbar, coord, m_sizeScrollbarArrow); return StandardPixelToScrollbar(scrollbar, coord,
GetScrollbarArrowSize(scrollbar));
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -891,18 +1115,17 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
// button border width // button border width
size->y += 4; size->y += 4;
} }
else if ( wxDynamicCast(window, wxScrollBar) )
{
// we only set the width of vert scrollbars and height of the
// horizontal ones
if ( window->GetWindowStyle() & wxSB_HORIZONTAL )
size->y = m_sizeScrollbarArrow.x;
else
size->x = m_sizeScrollbarArrow.x;
}
else else
{ {
if ( wxDynamicCast(window, wxScrollBar) )
{
// we only set the width of vert scrollbars and height of the
// horizontal ones
if ( window->GetWindowStyle() & wxSB_HORIZONTAL )
size->y = m_sizeScrollbarArrow.y;
else
size->x = m_sizeScrollbarArrow.x;
}
// take into account the border width // take into account the border width
wxBorder border = (wxBorder)(window->GetWindowStyle() & wxBORDER_MASK); wxBorder border = (wxBorder)(window->GetWindowStyle() & wxBORDER_MASK);
switch ( border ) switch ( border )

View File

@@ -106,9 +106,11 @@ public:
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawScrollbarThumb(wxDC& dc, virtual void DrawScrollbarThumb(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawScrollbarShaft(wxDC& dc, virtual void DrawScrollbarShaft(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawItem(wxDC& dc, virtual void DrawItem(wxDC& dc,
@@ -219,6 +221,11 @@ public:
protected: protected:
virtual bool IsAllowedButton(int button) { return button == 1; } virtual bool IsAllowedButton(int button) { return button == 1; }
virtual void Highlight(wxScrollBar *scrollbar, bool doIt)
{
// we don't highlight anything
}
// the first and last event which caused the thumb to move // the first and last event which caused the thumb to move
wxMouseEvent m_eventStartDrag, wxMouseEvent m_eventStartDrag,
m_eventLastDrag; m_eventLastDrag;
@@ -1033,6 +1040,7 @@ void wxWin32Renderer::DrawArrowButton(wxDC& dc,
} }
void wxWin32Renderer::DrawScrollbarThumb(wxDC& dc, void wxWin32Renderer::DrawScrollbarThumb(wxDC& dc,
wxOrientation orient,
const wxRect& rect, const wxRect& rect,
int flags) int flags)
{ {
@@ -1043,6 +1051,7 @@ void wxWin32Renderer::DrawScrollbarThumb(wxDC& dc,
} }
void wxWin32Renderer::DrawScrollbarShaft(wxDC& dc, void wxWin32Renderer::DrawScrollbarShaft(wxDC& dc,
wxOrientation orient,
const wxRect& rectBar, const wxRect& rectBar,
int flags) int flags)
{ {