1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/stdrend.cpp
3 // Purpose: implementation of wxStdRenderer
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
29 #include "wx/univ/stdrend.h"
30 #include "wx/univ/colschem.h"
32 // ============================================================================
33 // wxStdRenderer implementation
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 wxStdRenderer::wxStdRenderer(const wxColourScheme
*scheme
)
43 m_penBlack
= wxPen(wxSCHEME_COLOUR(scheme
, SHADOW_DARK
));
44 m_penDarkGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SHADOW_OUT
));
45 m_penLightGrey
= wxPen(wxSCHEME_COLOUR(scheme
, SHADOW_IN
));
46 m_penHighlight
= wxPen(wxSCHEME_COLOUR(scheme
, SHADOW_HIGHLIGHT
));
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
54 wxStdRenderer::DrawSolidRect(wxDC
& dc
, const wxColour
& col
, const wxRect
& rect
)
56 wxBrush
brush(col
, wxSOLID
);
58 dc
.SetPen(*wxTRANSPARENT_PEN
);
59 dc
.DrawRectangle(rect
);
62 void wxStdRenderer::DrawRect(wxDC
& dc
, wxRect
*rect
, const wxPen
& pen
)
66 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
67 dc
.DrawRectangle(*rect
);
73 void wxStdRenderer::DrawShadedRect(wxDC
& dc
, wxRect
*rect
,
74 const wxPen
& pen1
, const wxPen
& pen2
)
78 dc
.DrawLine(rect
->GetLeft(), rect
->GetTop(),
79 rect
->GetLeft(), rect
->GetBottom());
80 dc
.DrawLine(rect
->GetLeft() + 1, rect
->GetTop(),
81 rect
->GetRight(), rect
->GetTop());
83 dc
.DrawLine(rect
->GetRight(), rect
->GetTop(),
84 rect
->GetRight(), rect
->GetBottom());
85 dc
.DrawLine(rect
->GetLeft(), rect
->GetBottom(),
86 rect
->GetRight() + 1, rect
->GetBottom());
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 void wxStdRenderer::DrawBackground(wxDC
& dc
,
102 wxColour colBg
= col
.Ok() ? col
103 : window
? m_scheme
->GetBackground(window
)
104 : wxSCHEME_COLOUR(m_scheme
, CONTROL
);
106 DrawSolidRect(dc
, colBg
, rect
);
110 void wxStdRenderer::DrawButtonSurface(wxDC
& dc
,
115 DrawBackground(dc
, col
, rect
, flags
);
118 // ----------------------------------------------------------------------------
120 // ----------------------------------------------------------------------------
122 void wxStdRenderer::DrawFocusRect(wxDC
& dc
, const wxRect
& rect
)
124 // draw the pixels manually because the "dots" in wxPen with wxDOT style
125 // may be short traits and not really dots
127 // note that to behave in the same manner as DrawRect(), we must exclude
128 // the bottom and right borders from the rectangle
129 wxCoord x1
= rect
.GetLeft(),
131 x2
= rect
.GetRight(),
132 y2
= rect
.GetBottom();
134 dc
.SetPen(m_penBlack
);
136 // this seems to be closer than what Windows does than wxINVERT although
137 // I'm still not sure if it's correct
138 dc
.SetLogicalFunction(wxAND_REVERSE
);
141 for ( z
= x1
+ 1; z
< x2
; z
+= 2 )
142 dc
.DrawPoint(z
, rect
.GetTop());
144 wxCoord shift
= z
== x2
? 0 : 1;
145 for ( z
= y1
+ shift
; z
< y2
; z
+= 2 )
148 shift
= z
== y2
? 0 : 1;
149 for ( z
= x2
- shift
; z
> x1
; z
-= 2 )
152 shift
= z
== x1
? 0 : 1;
153 for ( z
= y2
- shift
; z
> y1
; z
-= 2 )
156 dc
.SetLogicalFunction(wxCOPY
);
159 void wxStdRenderer::DrawLabel(wxDC
& dc
,
160 const wxString
& label
,
167 DrawButtonLabel(dc
, label
, wxNullBitmap
, rect
, flags
,
168 alignment
, indexAccel
, rectBounds
);
171 void wxStdRenderer::DrawButtonLabel(wxDC
& dc
,
172 const wxString
& label
,
173 const wxBitmap
& image
,
180 wxRect rectLabel
= rect
;
181 if ( !label
.empty() && (flags
& wxCONTROL_DISABLED
) )
183 if ( flags
& wxCONTROL_PRESSED
)
185 // shift the label if a button is pressed
186 rectLabel
.Offset(1, 1);
189 // draw shadow of the text
190 dc
.SetTextForeground(m_penHighlight
.GetColour());
191 wxRect rectShadow
= rect
;
192 rectShadow
.Offset(1, 1);
193 dc
.DrawLabel(label
, rectShadow
, alignment
, indexAccel
);
195 // make the main label text grey
196 dc
.SetTextForeground(m_penDarkGrey
.GetColour());
198 if ( flags
& wxCONTROL_FOCUSED
)
200 // leave enough space for the focus rect
201 rectLabel
.Inflate(-2);
205 dc
.DrawLabel(label
, image
, rectLabel
, alignment
, indexAccel
, rectBounds
);
207 if ( !label
.empty() && (flags
& wxCONTROL_FOCUSED
) )
209 rectLabel
.Inflate(-1);
211 DrawFocusRect(dc
, rectLabel
);
215 // ----------------------------------------------------------------------------
217 // ----------------------------------------------------------------------------
220 We implement standard-looking 3D borders which have the following appearance:
224 WWWWWWWWWWWWWWWWWWWWWWB
225 WHHHHHHHHHHHHHHHHHHHHGB
226 WH GB W = white (HILIGHT)
227 WH GB H = light grey (LIGHT)
228 WH GB G = dark grey (SHADOI)
229 WH GB B = black (DKSHADOI)
232 WGGGGGGGGGGGGGGGGGGGGGB
233 BBBBBBBBBBBBBBBBBBBBBBB
235 The sunken border looks like this:
237 GGGGGGGGGGGGGGGGGGGGGGW
238 GBBBBBBBBBBBBBBBBBBBBHW
245 GHHHHHHHHHHHHHHHHHHHHHW
246 WWWWWWWWWWWWWWWWWWWWWWW
248 The static border (used for the controls which don't get focus) is like
251 GGGGGGGGGGGGGGGGGGGGGGW
259 WWWWWWWWWWWWWWWWWWWWWWW
261 The most complicated is the double border which is a combination of special
262 "anti-sunken" border and an extra border inside it:
264 HHHHHHHHHHHHHHHHHHHHHHB
265 HWWWWWWWWWWWWWWWWWWWWGB
266 HWHHHHHHHHHHHHHHHHHHHGB
271 HWHHHHHHHHHHHHHHHHHHHGB
272 HGGGGGGGGGGGGGGGGGGGGGB
273 BBBBBBBBBBBBBBBBBBBBBBB
275 And the simple border is, well, simple:
277 BBBBBBBBBBBBBBBBBBBBBBB
286 BBBBBBBBBBBBBBBBBBBBBBB
289 void wxStdRenderer::DrawRaisedBorder(wxDC
& dc
, wxRect
*rect
)
291 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penBlack
);
292 DrawShadedRect(dc
, rect
, m_penLightGrey
, m_penDarkGrey
);
295 void wxStdRenderer::DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
)
297 DrawShadedRect(dc
, rect
, m_penDarkGrey
, m_penHighlight
);
298 DrawShadedRect(dc
, rect
, m_penBlack
, m_penLightGrey
);
301 void wxStdRenderer::DrawAntiSunkenBorder(wxDC
& dc
, wxRect
*rect
)
303 DrawShadedRect(dc
, rect
, m_penLightGrey
, m_penBlack
);
304 DrawShadedRect(dc
, rect
, m_penHighlight
, m_penDarkGrey
);
307 void wxStdRenderer::DrawBorder(wxDC
& dc
,
309 const wxRect
& rectTotal
,
313 wxRect rect
= rectTotal
;
317 case wxBORDER_SUNKEN
:
318 DrawSunkenBorder(dc
, &rect
);
321 case wxBORDER_DOUBLE
:
322 DrawAntiSunkenBorder(dc
, &rect
);
323 DrawRect(dc
, &rect
, m_penLightGrey
);
326 case wxBORDER_STATIC
:
327 DrawShadedRect(dc
, &rect
, m_penDarkGrey
, m_penHighlight
);
330 case wxBORDER_RAISED
:
331 DrawRaisedBorder(dc
, &rect
);
334 case wxBORDER_SIMPLE
:
335 DrawRect(dc
, &rect
, m_penBlack
);
339 wxFAIL_MSG(_T("unknown border type"));
342 case wxBORDER_DEFAULT
:
351 wxRect
wxStdRenderer::GetBorderDimensions(wxBorder border
) const
356 case wxBORDER_SIMPLE
:
357 case wxBORDER_STATIC
:
361 case wxBORDER_RAISED
:
362 case wxBORDER_SUNKEN
:
366 case wxBORDER_DOUBLE
:
371 wxFAIL_MSG(_T("unknown border type"));
374 case wxBORDER_DEFAULT
:
389 bool wxStdRenderer::AreScrollbarsInsideBorder() const
394 void wxStdRenderer::DrawTextBorder(wxDC
& dc
,
400 DrawBorder(dc
, border
, rect
, flags
, rectIn
);
403 // ----------------------------------------------------------------------------
405 // ----------------------------------------------------------------------------
408 wxStdRenderer::DrawHorizontalLine(wxDC
& dc
, wxCoord y
, wxCoord x1
, wxCoord x2
)
410 dc
.SetPen(m_penDarkGrey
);
411 dc
.DrawLine(x1
, y
, x2
+ 1, y
);
413 dc
.SetPen(m_penHighlight
);
415 dc
.DrawLine(x1
, y
, x2
+ 1, y
);
419 wxStdRenderer::DrawVerticalLine(wxDC
& dc
, wxCoord x
, wxCoord y1
, wxCoord y2
)
421 dc
.SetPen(m_penDarkGrey
);
422 dc
.DrawLine(x
, y1
, x
, y2
+ 1);
424 dc
.SetPen(m_penHighlight
);
426 dc
.DrawLine(x
, y1
, x
, y2
+ 1);
429 void wxStdRenderer::DrawFrameWithoutLabel(wxDC
& dc
,
430 const wxRect
& rectFrame
,
431 const wxRect
& rectLabel
)
433 // draw left, bottom and right lines entirely
434 DrawVerticalLine(dc
, rectFrame
.GetLeft(),
435 rectFrame
.GetTop(), rectFrame
.GetBottom() - 2);
436 DrawHorizontalLine(dc
, rectFrame
.GetBottom() - 1,
437 rectFrame
.GetLeft(), rectFrame
.GetRight());
438 DrawVerticalLine(dc
, rectFrame
.GetRight() - 1,
439 rectFrame
.GetTop(), rectFrame
.GetBottom() - 1);
441 // and 2 parts of the top line
442 DrawHorizontalLine(dc
, rectFrame
.GetTop(),
443 rectFrame
.GetLeft() + 1, rectLabel
.GetLeft());
444 DrawHorizontalLine(dc
, rectFrame
.GetTop(),
445 rectLabel
.GetRight(), rectFrame
.GetRight() - 2);
448 void wxStdRenderer::DrawFrameWithLabel(wxDC
& dc
,
449 const wxString
& label
,
450 const wxRect
& rectFrame
,
451 const wxRect
& rectText
,
457 DrawLabel(dc
, label
, rectText
, flags
, alignment
, indexAccel
, &rectLabel
);
459 DrawFrameWithoutLabel(dc
, rectFrame
, rectLabel
);
462 void wxStdRenderer::DrawFrame(wxDC
& dc
,
463 const wxString
& label
,
469 wxCoord height
= 0; // of the label
470 wxRect rectFrame
= rect
;
471 if ( !label
.empty() )
473 // the text should touch the top border of the rect, so the frame
474 // itself should be lower
475 dc
.GetTextExtent(label
, NULL
, &height
);
476 rectFrame
.y
+= height
/ 2;
477 rectFrame
.height
-= height
/ 2;
479 // we have to draw each part of the frame individually as we can't
480 // erase the background beyond the label as it might contain some
481 // pixmap already, so drawing everything and then overwriting part of
482 // the frame with label doesn't work
484 // TODO: the +5 shouldn't be hard coded
486 rectText
.x
= rectFrame
.x
+ 5;
488 rectText
.width
= rectFrame
.width
- 7; // +2 border width
489 rectText
.height
= height
;
491 DrawFrameWithLabel(dc
, label
, rectFrame
, rectText
, flags
,
492 alignment
, indexAccel
);
496 // just draw the complete frame
497 DrawShadedRect(dc
, &rectFrame
, m_penDarkGrey
, m_penHighlight
);
498 DrawShadedRect(dc
, &rectFrame
, m_penHighlight
, m_penDarkGrey
);
502 void wxStdRenderer::DrawItem(wxDC
& dc
,
503 const wxString
& label
,
507 wxDCTextColourChanger
colChanger(dc
);
509 if ( flags
& wxCONTROL_SELECTED
)
511 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
513 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
516 dc
.DrawRectangle(rect
);
519 wxRect rectText
= rect
;
522 dc
.DrawLabel(label
, wxNullBitmap
, rectText
);
524 if ( flags
& wxCONTROL_FOCUSED
)
526 DrawFocusRect(dc
, rect
);
530 // ----------------------------------------------------------------------------
531 // check and radio bitmaps
532 // ----------------------------------------------------------------------------
535 void wxStdRenderer::GetIndicatorsFromFlags(int flags
,
536 IndicatorState
& state
,
537 IndicatorStatus
& status
)
539 if ( flags
& wxCONTROL_SELECTED
)
540 state
= flags
& wxCONTROL_DISABLED
? IndicatorState_SelectedDisabled
541 : IndicatorState_Selected
;
542 else if ( flags
& wxCONTROL_DISABLED
)
543 state
= IndicatorState_Disabled
;
544 else if ( flags
& wxCONTROL_PRESSED
)
545 state
= IndicatorState_Pressed
;
547 state
= IndicatorState_Normal
;
549 status
= flags
& wxCONTROL_CHECKED
? IndicatorStatus_Checked
550 : flags
& wxCONTROL_UNDETERMINED
551 ? IndicatorStatus_Undetermined
552 : IndicatorStatus_Unchecked
;
555 void wxStdRenderer::DrawCheckButton(wxDC
& dc
,
556 const wxString
& label
,
557 const wxBitmap
& bitmap
,
563 wxBitmap
bmp(bitmap
.Ok() ? bitmap
: GetCheckBitmap(flags
));
565 DrawCheckOrRadioButton(dc
, label
, bmp
, rect
, flags
, align
, indexAccel
);
568 void wxStdRenderer::DrawRadioButton(wxDC
& dc
,
569 const wxString
& label
,
570 const wxBitmap
& bitmap
,
576 wxBitmap
bmp(bitmap
.Ok() ? bitmap
: GetRadioBitmap(flags
));
578 DrawCheckOrRadioButton(dc
, label
, bmp
, rect
, flags
, align
, indexAccel
);
581 void wxStdRenderer::DrawCheckOrRadioButton(wxDC
& dc
,
582 const wxString
& label
,
583 const wxBitmap
& bitmap
,
589 // calculate the position of the bitmap and of the label
590 wxCoord heightBmp
= bitmap
.GetHeight();
592 yBmp
= rect
.y
+ (rect
.height
- heightBmp
) / 2;
595 dc
.GetMultiLineTextExtent(label
, NULL
, &rectLabel
.height
);
596 rectLabel
.y
= rect
.y
+ (rect
.height
- rectLabel
.height
) / 2;
598 // align label vertically with the bitmap - looks nicer like this
599 rectLabel
.y
-= (rectLabel
.height
- heightBmp
) % 2;
601 // calc horz position
602 if ( align
== wxALIGN_RIGHT
)
604 xBmp
= rect
.GetRight() - bitmap
.GetWidth();
605 rectLabel
.x
= rect
.x
+ 3;
606 rectLabel
.SetRight(xBmp
);
608 else // normal (checkbox to the left of the text) case
611 rectLabel
.x
= xBmp
+ bitmap
.GetWidth() + 5;
612 rectLabel
.SetRight(rect
.GetRight());
615 dc
.DrawBitmap(bitmap
, xBmp
, yBmp
, true /* use mask */);
617 DrawLabel(dc
, label
, rectLabel
, flags
,
618 wxALIGN_LEFT
| wxALIGN_TOP
, indexAccel
);
623 void wxStdRenderer::DrawTextLine(wxDC
& dc
,
624 const wxString
& text
,
630 if ( (selStart
== -1) || !(flags
& wxCONTROL_FOCUSED
) )
632 // just draw it as is
633 dc
.DrawText(text
, rect
.x
, rect
.y
);
635 else // we have selection
640 // draw the part before selection
641 wxString
s(text
, (size_t)selStart
);
644 dc
.DrawText(s
, x
, rect
.y
);
646 dc
.GetTextExtent(s
, &width
, NULL
);
650 // draw the selection itself
651 s
= wxString(text
.c_str() + selStart
, text
.c_str() + selEnd
);
654 wxColour colFg
= dc
.GetTextForeground(),
655 colBg
= dc
.GetTextBackground();
656 dc
.SetTextForeground(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
657 dc
.SetTextBackground(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
));
658 dc
.SetBackgroundMode(wxSOLID
);
660 dc
.DrawText(s
, x
, rect
.y
);
661 dc
.GetTextExtent(s
, &width
, NULL
);
664 dc
.SetBackgroundMode(wxTRANSPARENT
);
665 dc
.SetTextBackground(colBg
);
666 dc
.SetTextForeground(colFg
);
669 // draw the final part
670 s
= text
.c_str() + selEnd
;
673 dc
.DrawText(s
, x
, rect
.y
);
678 void wxStdRenderer::DrawLineWrapMark(wxDC
& WXUNUSED(dc
),
679 const wxRect
& WXUNUSED(rect
))
681 // nothing by default
684 #endif // wxUSE_TEXTCTRL
686 // ----------------------------------------------------------------------------
687 // scrollbars geometry
688 // ----------------------------------------------------------------------------
693 void wxStdRenderer::GetScrollBarThumbSize(wxCoord length
,
700 // the thumb can't be made less than this number of pixels
701 static const wxCoord thumbMinWidth
= 8; // FIXME: should be configurable
703 *thumbStart
= (length
*thumbPos
) / range
;
704 *thumbEnd
= (length
*(thumbPos
+ thumbSize
)) / range
;
706 if ( *thumbEnd
- *thumbStart
< thumbMinWidth
)
708 // adjust the end if possible
709 if ( *thumbStart
<= length
- thumbMinWidth
)
711 // yes, just make it wider
712 *thumbEnd
= *thumbStart
+ thumbMinWidth
;
714 else // it is at the bottom of the scrollbar
716 // so move it a bit up
717 *thumbStart
= length
- thumbMinWidth
;
723 wxRect
wxStdRenderer::GetScrollbarRect(const wxScrollBar
*scrollbar
,
724 wxScrollBar::Element elem
,
727 if ( thumbPos
== -1 )
729 thumbPos
= scrollbar
->GetThumbPosition();
732 const wxSize sizeArrow
= GetScrollbarArrowSize();
734 wxSize sizeTotal
= scrollbar
->GetClientSize();
735 wxCoord
*start
, *width
;
736 wxCoord length
, arrow
;
738 if ( scrollbar
->IsVertical() )
741 rect
.width
= sizeTotal
.x
;
742 length
= sizeTotal
.y
;
744 width
= &rect
.height
;
750 rect
.height
= sizeTotal
.y
;
751 length
= sizeTotal
.x
;
759 case wxScrollBar::Element_Arrow_Line_1
:
764 case wxScrollBar::Element_Arrow_Line_2
:
765 *start
= length
- arrow
;
769 case wxScrollBar::Element_Arrow_Page_1
:
770 case wxScrollBar::Element_Arrow_Page_2
:
771 // we don't have them at all
774 case wxScrollBar::Element_Thumb
:
775 case wxScrollBar::Element_Bar_1
:
776 case wxScrollBar::Element_Bar_2
:
777 // we need to calculate the thumb position - do it
780 wxCoord thumbStart
, thumbEnd
;
781 int range
= scrollbar
->GetRange();
789 GetScrollBarThumbSize(length
,
791 scrollbar
->GetThumbSize(),
797 if ( elem
== wxScrollBar::Element_Thumb
)
800 *width
= thumbEnd
- thumbStart
;
802 else if ( elem
== wxScrollBar::Element_Bar_1
)
807 else // elem == wxScrollBar::Element_Bar_2
810 *width
= length
- thumbEnd
;
813 // everything is relative to the start of the shaft so far
818 case wxScrollBar::Element_Max
:
820 wxFAIL_MSG( _T("unknown scrollbar element") );
826 wxCoord
wxStdRenderer::GetScrollbarSize(const wxScrollBar
*scrollbar
)
828 const wxSize sizeArrowSB
= GetScrollbarArrowSize();
830 wxCoord sizeArrow
, sizeTotal
;
831 if ( scrollbar
->GetWindowStyle() & wxVERTICAL
)
833 sizeArrow
= sizeArrowSB
.y
;
834 sizeTotal
= scrollbar
->GetSize().y
;
838 sizeArrow
= sizeArrowSB
.x
;
839 sizeTotal
= scrollbar
->GetSize().x
;
842 return sizeTotal
- 2*sizeArrow
;
846 wxStdRenderer::HitTestScrollbar(const wxScrollBar
*scrollbar
, const wxPoint
& pt
) const
848 // we only need to work with either x or y coord depending on the
849 // orientation, choose one (but still check the other one to verify if the
850 // mouse is in the window at all)
851 const wxSize sizeArrowSB
= GetScrollbarArrowSize();
853 wxCoord coord
, sizeArrow
, sizeTotal
;
854 wxSize size
= scrollbar
->GetSize();
855 if ( scrollbar
->GetWindowStyle() & wxVERTICAL
)
857 if ( pt
.x
< 0 || pt
.x
> size
.x
)
861 sizeArrow
= sizeArrowSB
.y
;
866 if ( pt
.y
< 0 || pt
.y
> size
.y
)
870 sizeArrow
= sizeArrowSB
.x
;
874 // test for the arrows first as it's faster
875 if ( coord
< 0 || coord
> sizeTotal
)
879 else if ( coord
< sizeArrow
)
881 return wxHT_SCROLLBAR_ARROW_LINE_1
;
883 else if ( coord
> sizeTotal
- sizeArrow
)
885 return wxHT_SCROLLBAR_ARROW_LINE_2
;
889 // calculate the thumb position in pixels
890 sizeTotal
-= 2*sizeArrow
;
891 wxCoord thumbStart
, thumbEnd
;
892 int range
= scrollbar
->GetRange();
895 // clicking the scrollbar without range has no effect
900 GetScrollBarThumbSize(sizeTotal
,
901 scrollbar
->GetThumbPosition(),
902 scrollbar
->GetThumbSize(),
908 // now compare with the thumb position
910 if ( coord
< thumbStart
)
911 return wxHT_SCROLLBAR_BAR_1
;
912 else if ( coord
> thumbEnd
)
913 return wxHT_SCROLLBAR_BAR_2
;
915 return wxHT_SCROLLBAR_THUMB
;
921 wxStdRenderer::ScrollbarToPixel(const wxScrollBar
*scrollbar
, int thumbPos
)
923 int range
= scrollbar
->GetRange();
926 // the only valid position anyhow
930 if ( thumbPos
== -1 )
932 // by default use the current thumb position
933 thumbPos
= scrollbar
->GetThumbPosition();
936 const wxSize sizeArrow
= GetScrollbarArrowSize();
937 return (thumbPos
*GetScrollbarSize(scrollbar
)) / range
938 + (scrollbar
->IsVertical() ? sizeArrow
.y
: sizeArrow
.x
);
941 int wxStdRenderer::PixelToScrollbar(const wxScrollBar
*scrollbar
, wxCoord coord
)
943 const wxSize sizeArrow
= GetScrollbarArrowSize();
944 return ((coord
- (scrollbar
->IsVertical() ? sizeArrow
.y
: sizeArrow
.x
)) *
945 scrollbar
->GetRange() ) / GetScrollbarSize(scrollbar
);
948 #endif // wxUSE_SCROLLBAR