src/univ/statline.cpp
src/univ/stattext.cpp
src/univ/statusbr.cpp
+ src/univ/stdrend.cpp
src/univ/textctrl.cpp
src/univ/tglbtn.cpp
src/univ/theme.cpp
wx/univ/statline.h
wx/univ/stattext.h
wx/univ/statusbr.h
+ wx/univ/stdrend.h
wx/univ/textctrl.h
wx/univ/theme.h
wx/univ/toolbar.h
const wxColour& col,
const wxRect& rect,
int flags,
- wxWindow *window = NULL ) = 0;
+ wxWindow *window = NULL) = 0;
// draw the button surface
virtual void DrawButtonSurface(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- int flags )
- { DrawBackground( dc, col, rect, flags ); }
+ const wxColour& col,
+ const wxRect& rect,
+ int flags) = 0;
+ // draw the focus rectangle around the label contained in the given rect
+ virtual void DrawFocusRect(wxDC& dc, const wxRect& rect) = 0;
+
// draw the label inside the given rectangle with the specified alignment
// and optionally emphasize the character with the given index
virtual void DrawLabel(wxDC& dc,
int indexAccel = -1,
wxRect *rectBounds = NULL) = 0;
+
// draw the border and optionally return the rectangle containing the
// region inside the border
virtual void DrawBorder(wxDC& dc,
int tbarStyle = 0) = 0;
#endif // wxUSE_TOOLBAR
+#if wxUSE_TEXTCTRL
// draw a (part of) line in the text control
virtual void DrawTextLine(wxDC& dc,
const wxString& text,
// draw a line wrap indicator
virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) = 0;
+#endif // wxUSE_TEXTCTRL
+#if wxUSE_NOTEBOOK
// draw a notebook tab
virtual void DrawTab(wxDC& dc,
const wxRect& rect,
const wxBitmap& bitmap = wxNullBitmap,
int flags = 0,
int indexAccel = -1) = 0;
+#endif // wxUSE_NOTEBOOK
#if wxUSE_SLIDER
// misc functions
// --------------
+#if wxUSE_COMBOBOX
// return the bitmaps to use for combobox button
virtual void GetComboBitmaps(wxBitmap *bmpNormal,
wxBitmap *bmpFocus,
wxBitmap *bmpPressed,
wxBitmap *bmpDisabled) = 0;
+#endif // wxUSE_COMBOBOX
// geometry functions
// ------------------
wxCoord *extraSpaceBeyond) const = 0;
#endif // wxUSE_TEXTCTRL
+#if wxUSE_NOTEBOOK
// get the overhang of a selected tab
virtual wxSize GetTabIndent() const = 0;
// get the padding around the text in a tab
virtual wxSize GetTabPadding() const = 0;
+#endif // wxUSE_NOTEBOOK
#if wxUSE_SLIDER
// get the default size of the slider in lesser dimension (i.e. height of a
// virtual dtor for any base class
virtual ~wxRenderer();
-
-
-protected:
- // draw a frame around rectFrame rectangle but not touching the rectLabel
- // one: this is used by DrawFrame()
- void StandardDrawFrame(wxDC& dc,
- const wxRect& rectFrame,
- const wxRect& rectLabel);
-
- // standard text line drawing: just use DrawText() and highlight the
- // selected part
- static void StandardDrawTextLine(wxDC& dc,
- const wxString& text,
- const wxRect& rect,
- int selStart, int selEnd,
- int flags);
-
-#if wxUSE_SCROLLBAR
- // standard scrollbar hit testing: this assumes that it only has 2 arrows
- // and a thumb, so the themes which have more complicated scrollbars (e.g.
- // BeOS) can't use this method
- static wxRect StandardGetScrollbarRect(const wxScrollBar *scrollbar,
- wxScrollBar::Element elem,
- int thumbPos,
- const wxSize& sizeArrow);
- static wxHitTest StandardHitTestScrollbar(const wxScrollBar *scrollbar,
- const wxPoint& pt,
- const wxSize& sizeArrow);
- static wxCoord StandardScrollbarToPixel(const wxScrollBar *scrollbar,
- int thumbPos,
- const wxSize& sizeArrow);
- static int StandardPixelToScrollbar(const wxScrollBar *scrollbar,
- wxCoord coord,
- const wxSize& sizeArrow);
- static wxCoord StandardScrollBarSize(const wxScrollBar *scrollbar,
- const wxSize& sizeArrow);
- static void StandardScrollBarThumbSize(wxCoord lenBar,
- int thumbPos,
- int thumbSize,
- int range,
- wxCoord *thumbStart,
- wxCoord *thumbEnd);
-#endif // wxUSE_SCROLLBAR
-
};
// ----------------------------------------------------------------------------
int flags,
wxWindow *window = NULL )
{ m_renderer->DrawBackground(dc, col, rect, flags, window ); }
+ virtual void DrawButtonSurface(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags)
+ { m_renderer->DrawButtonSurface(dc, col, rect, flags); }
+ virtual void DrawFocusRect(wxDC& dc, const wxRect& rect)
+ { m_renderer->DrawFocusRect(dc, rect); }
virtual void DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
int tbarStyle = 0)
{ m_renderer->DrawToolBarButton(dc, label, bitmap, rect, flags, style, tbarStyle); }
#endif // wxUSE_TOOLBAR
+
+#if wxUSE_TEXTCTRL
virtual void DrawTextLine(wxDC& dc,
const wxString& text,
const wxRect& rect,
{ m_renderer->DrawTextLine(dc, text, rect, selStart, selEnd, flags); }
virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect)
{ m_renderer->DrawLineWrapMark(dc, rect); }
+#endif // wxUSE_TEXTCTRL
+#if wxUSE_NOTEBOOK
virtual void DrawTab(wxDC& dc,
const wxRect& rect,
wxDirection dir,
int flags = 0,
int accel = -1)
{ m_renderer->DrawTab(dc, rect, dir, label, bitmap, flags, accel); }
+#endif // wxUSE_NOTEBOOK
#if wxUSE_SLIDER
int flags = 0)
{ m_renderer->DrawFrameButton(dc, x, y, button, flags); }
+#if wxUSE_COMBOBOX
virtual void GetComboBitmaps(wxBitmap *bmpNormal,
wxBitmap *bmpFocus,
wxBitmap *bmpPressed,
wxBitmap *bmpDisabled)
{ m_renderer->GetComboBitmaps(bmpNormal, bmpFocus,
bmpPressed, bmpDisabled); }
+#endif // wxUSE_COMBOBOX
virtual void AdjustSize(wxSize *size, const wxWindow *window)
{ m_renderer->AdjustSize(size, window); }
wxDC& dc,
const wxRect& rect,
int flags = 0,
- wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
- wxHeaderButtonParams* params=NULL)
- { m_renderer->DrawHeaderButton(win, dc, rect, flags, sortArrow, params); }
+ wxHeaderSortIconType sortIcon = wxHDR_SORT_ICON_NONE,
+ wxHeaderButtonParams* params = NULL)
+ { m_renderer->DrawHeaderButton(win, dc, rect, flags, sortIcon, params); }
virtual void DrawTreeItemButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/univ/stdrend.h
+// Purpose: wxStdRenderer class declaration
+// Author: Vadim Zeitlin
+// Created: 2006-09-18
+// RCS-ID: $Id$
+// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_UNIV_STDREND_H_
+#define _WX_UNIV_STDREND_H_
+
+#include "wx/univ/renderer.h"
+
+class WXDLLEXPORT wxColourScheme;
+
+// ----------------------------------------------------------------------------
+// wxStdRenderer: implements as much of wxRenderer API as possible generically
+// ----------------------------------------------------------------------------
+
+class wxStdRenderer : public wxRenderer
+{
+public:
+ // the renderer will use the given scheme, whose lifetime must be at least
+ // as long as of this object itself, to choose the colours for drawing
+ wxStdRenderer(const wxColourScheme *scheme);
+
+ virtual void DrawBackground(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags = 0,
+ wxWindow *window = NULL);
+ virtual void DrawButtonSurface(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags);
+
+
+ virtual void DrawFocusRect(wxDC& dc, const wxRect& rect);
+ virtual void DrawLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags = 0,
+ int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+ int indexAccel = -1,
+ wxRect *rectBounds = NULL);
+ virtual void DrawButtonLabel(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& image,
+ const wxRect& rect,
+ int flags = 0,
+ int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+ int indexAccel = -1,
+ wxRect *rectBounds = NULL);
+
+
+ virtual void DrawBorder(wxDC& dc,
+ wxBorder border,
+ const wxRect& rect,
+ int flags = 0,
+ wxRect *rectIn = NULL);
+ virtual void DrawTextBorder(wxDC& dc,
+ wxBorder border,
+ const wxRect& rect,
+ int flags = 0,
+ wxRect *rectIn = NULL);
+
+ virtual void DrawHorizontalLine(wxDC& dc,
+ wxCoord y, wxCoord x1, wxCoord x2);
+ virtual void DrawVerticalLine(wxDC& dc,
+ wxCoord x, wxCoord y1, wxCoord y2);
+ virtual void DrawFrame(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags = 0,
+ int alignment = wxALIGN_LEFT,
+ int indexAccel = -1);
+
+
+ virtual void DrawItem(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags = 0);
+
+ virtual void DrawCheckButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags = 0,
+ wxAlignment align = wxALIGN_LEFT,
+ int indexAccel = -1);
+ virtual void DrawRadioButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags = 0,
+ wxAlignment align = wxALIGN_LEFT,
+ int indexAccel = -1);
+
+#if wxUSE_TEXTCTRL
+ virtual void DrawTextLine(wxDC& dc,
+ const wxString& text,
+ const wxRect& rect,
+ int selStart = -1,
+ int selEnd = -1,
+ int flags = 0);
+
+ virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect);
+#endif // wxUSE_TEXTCTRL
+
+ virtual wxRect GetBorderDimensions(wxBorder border) const;
+
+ virtual bool AreScrollbarsInsideBorder() const;
+
+#if wxUSE_SCROLLBAR
+ virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
+ wxScrollBar::Element elem,
+ int thumbPos = -1) const;
+
+ virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
+
+ virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
+ const wxPoint& pt) const;
+
+ virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
+ int thumbPos = -1);
+ virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
+#endif // wxUSE_SCROLLBAR
+
+protected:
+ // various constants
+ enum IndicatorType
+ {
+ IndicatorType_Check,
+ IndicatorType_Radio,
+ IndicatorType_Menu,
+ IndicatorType_Max
+ };
+
+ enum IndicatorState
+ {
+ IndicatorState_Normal,
+ IndicatorState_Pressed, // this one is for check/radioboxes
+ IndicatorState_Disabled,
+ IndicatorState_MaxCtrl,
+
+ // the rest of the states are valid for menu items only
+ IndicatorState_Selected = IndicatorState_Pressed,
+ IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl,
+ IndicatorState_MaxMenu
+ };
+
+ enum IndicatorStatus
+ {
+ IndicatorStatus_Checked,
+ IndicatorStatus_Unchecked,
+ IndicatorStatus_Undetermined,
+ IndicatorStatus_Max
+ };
+
+ // translate the appropriate bits in flags to the above enum elements
+ static void GetIndicatorsFromFlags(int flags,
+ IndicatorState& state,
+ IndicatorStatus& status);
+
+ // fill the rectangle with a brush of given colour (must be valid)
+ void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);
+
+
+ // all the functions in this section adjust the rect parameter to
+ // correspond to the interiour of the drawn area
+
+ // draw complete rectangle
+ void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
+
+ // draw the rectange using the first pen for the left and top sides
+ // and the second one for the bottom and right ones
+ void DrawShadedRect(wxDC& dc, wxRect *rect,
+ const wxPen& pen1, const wxPen& pen2);
+
+ // border drawing routines, may be overridden in the derived class
+ virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect);
+ virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect);
+ virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect);
+
+
+ // draw the frame with non-empty label inside the given rectText
+ virtual void DrawFrameWithLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rectFrame,
+ const wxRect& rectText,
+ int flags,
+ int alignment,
+ int indexAccel);
+
+ // draw the (static box) frame without the part corresponding to rectLabel
+ void DrawFrameWithoutLabel(wxDC& dc,
+ const wxRect& rectFrame,
+ const wxRect& rectLabel);
+
+
+ // common routine for drawing check and radio buttons
+ void DrawCheckOrRadioButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags,
+ wxAlignment align,
+ int indexAccel);
+
+ // return the check/radio bitmap for the given flags
+ virtual wxBitmap GetRadioBitmap(int flags) = 0;
+ virtual wxBitmap GetCheckBitmap(int flags) = 0;
+
+
+ // return the starting and ending positions, in pixels, of the thumb of a
+ // scrollbar with the given logical position, thumb size and range and the
+ // given physical length
+ static void GetScrollBarThumbSize(wxCoord length,
+ int thumbPos,
+ int thumbSize,
+ int range,
+ wxCoord *thumbStart,
+ wxCoord *thumbEnd);
+
+ // GDI objects we often use
+ wxPen m_penBlack,
+ m_penDarkGrey,
+ m_penLightGrey,
+ m_penHighlight;
+
+ // the colours we use, they never change currently so we don't have to ever
+ // update m_penXXX objects above
+ const wxColourScheme * const m_scheme;
+
+ DECLARE_NO_COPY_CLASS(wxStdRenderer)
+};
+
+#endif // _WX_UNIV_STDREND_H_
+
// implementation
// ============================================================================
-// ----------------------------------------------------------------------------
-// wxRenderer: drawing helpers
-// ----------------------------------------------------------------------------
-
-void wxRenderer::StandardDrawFrame(wxDC& dc,
- const wxRect& rectFrame,
- const wxRect& rectLabel)
-{
- // draw left, bottom and right lines entirely
- DrawVerticalLine(dc, rectFrame.GetLeft(),
- rectFrame.GetTop(), rectFrame.GetBottom() - 2);
- DrawHorizontalLine(dc, rectFrame.GetBottom() - 1,
- rectFrame.GetLeft(), rectFrame.GetRight());
- DrawVerticalLine(dc, rectFrame.GetRight() - 1,
- rectFrame.GetTop(), rectFrame.GetBottom() - 1);
-
- // and 2 parts of the top line
- DrawHorizontalLine(dc, rectFrame.GetTop(),
- rectFrame.GetLeft() + 1, rectLabel.GetLeft());
- DrawHorizontalLine(dc, rectFrame.GetTop(),
- rectLabel.GetRight(), rectFrame.GetRight() - 2);
-}
-
-/* static */
-void wxRenderer::StandardDrawTextLine(wxDC& dc,
- const wxString& text,
- const wxRect& rect,
- int selStart, int selEnd,
- int flags)
-{
- if ( (selStart == -1) || !(flags & wxCONTROL_FOCUSED) )
- {
- // just draw it as is
- dc.DrawText(text, rect.x, rect.y);
- }
- else // we have selection
- {
- wxCoord width,
- x = rect.x;
-
- // draw the part before selection
- wxString s(text, (size_t)selStart);
- if ( !s.empty() )
- {
- dc.DrawText(s, x, rect.y);
-
- dc.GetTextExtent(s, &width, NULL);
- x += width;
- }
-
- // draw the selection itself
- s = wxString(text.c_str() + selStart, text.c_str() + selEnd);
- if ( !s.empty() )
- {
- wxColour colFg = dc.GetTextForeground(),
- colBg = dc.GetTextBackground();
- dc.SetTextForeground(wxTHEME_COLOUR(HIGHLIGHT_TEXT));
- dc.SetTextBackground(wxTHEME_COLOUR(HIGHLIGHT));
- dc.SetBackgroundMode(wxSOLID);
-
- dc.DrawText(s, x, rect.y);
- dc.GetTextExtent(s, &width, NULL);
- x += width;
-
- dc.SetBackgroundMode(wxTRANSPARENT);
- dc.SetTextBackground(colBg);
- dc.SetTextForeground(colFg);
- }
-
- // draw the final part
- s = text.c_str() + selEnd;
- if ( !s.empty() )
- {
- dc.DrawText(s, x, rect.y);
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// wxRenderer: scrollbar geometry
-// ----------------------------------------------------------------------------
-
-#if wxUSE_SCROLLBAR
-
-/* static */
-void wxRenderer::StandardScrollBarThumbSize(wxCoord length,
- int thumbPos,
- int thumbSize,
- int range,
- wxCoord *thumbStart,
- wxCoord *thumbEnd)
-{
- // the thumb can't be made less than this number of pixels
- static const wxCoord thumbMinWidth = 8; // FIXME: should be configurable
-
- *thumbStart = (length*thumbPos) / range;
- *thumbEnd = (length*(thumbPos + thumbSize)) / range;
-
- if ( *thumbEnd - *thumbStart < thumbMinWidth )
- {
- // adjust the end if possible
- if ( *thumbStart <= length - thumbMinWidth )
- {
- // yes, just make it wider
- *thumbEnd = *thumbStart + thumbMinWidth;
- }
- else // it is at the bottom of the scrollbar
- {
- // so move it a bit up
- *thumbStart = length - thumbMinWidth;
- *thumbEnd = length;
- }
- }
-}
-
-/* static */
-wxRect wxRenderer::StandardGetScrollbarRect(const wxScrollBar *scrollbar,
- wxScrollBar::Element elem,
- int thumbPos,
- const wxSize& sizeArrow)
-{
- if ( thumbPos == -1 )
- {
- thumbPos = scrollbar->GetThumbPosition();
- }
-
- wxSize sizeTotal = scrollbar->GetClientSize();
- wxCoord *start, *width;
- wxCoord length, arrow;
- wxRect rect;
- if ( scrollbar->IsVertical() )
- {
- rect.x = 0;
- rect.width = sizeTotal.x;
- length = sizeTotal.y;
- start = &rect.y;
- width = &rect.height;
- arrow = sizeArrow.y;
- }
- else // horizontal
- {
- rect.y = 0;
- rect.height = sizeTotal.y;
- length = sizeTotal.x;
- start = &rect.x;
- width = &rect.width;
- arrow = sizeArrow.x;
- }
-
- switch ( elem )
- {
- case wxScrollBar::Element_Arrow_Line_1:
- *start = 0;
- *width = arrow;
- break;
-
- case wxScrollBar::Element_Arrow_Line_2:
- *start = length - arrow;
- *width = arrow;
- break;
-
- case wxScrollBar::Element_Arrow_Page_1:
- case wxScrollBar::Element_Arrow_Page_2:
- // we don't have them at all
- break;
-
- case wxScrollBar::Element_Thumb:
- case wxScrollBar::Element_Bar_1:
- case wxScrollBar::Element_Bar_2:
- // we need to calculate the thumb position - do it
- {
- length -= 2*arrow;
- wxCoord thumbStart, thumbEnd;
- int range = scrollbar->GetRange();
- if ( !range )
- {
- thumbStart =
- thumbEnd = 0;
- }
- else
- {
- StandardScrollBarThumbSize(length,
- thumbPos,
- scrollbar->GetThumbSize(),
- range,
- &thumbStart,
- &thumbEnd);
- }
-
- if ( elem == wxScrollBar::Element_Thumb )
- {
- *start = thumbStart;
- *width = thumbEnd - thumbStart;
- }
- else if ( elem == wxScrollBar::Element_Bar_1 )
- {
- *start = 0;
- *width = thumbStart;
- }
- else // elem == wxScrollBar::Element_Bar_2
- {
- *start = thumbEnd;
- *width = length - thumbEnd;
- }
-
- // everything is relative to the start of the shaft so far
- *start += arrow;
- }
- break;
-
- case wxScrollBar::Element_Max:
- default:
- wxFAIL_MSG( _T("unknown scrollbar element") );
- }
-
- return rect;
-}
-
-/* static */
-wxCoord wxRenderer::StandardScrollBarSize(const wxScrollBar *scrollbar,
- const wxSize& sizeArrowSB)
-{
- wxCoord sizeArrow, sizeTotal;
- if ( scrollbar->GetWindowStyle() & wxVERTICAL )
- {
- sizeArrow = sizeArrowSB.y;
- sizeTotal = scrollbar->GetSize().y;
- }
- else // horizontal
- {
- sizeArrow = sizeArrowSB.x;
- sizeTotal = scrollbar->GetSize().x;
- }
-
- return sizeTotal - 2*sizeArrow;
-}
-
-/* static */
-wxCoord wxRenderer::StandardScrollbarToPixel(const wxScrollBar *scrollbar,
- int thumbPos,
- const wxSize& sizeArrow)
-{
- int range = scrollbar->GetRange();
- if ( !range )
- {
- // the only valid position anyhow
- return 0;
- }
-
- if ( thumbPos == -1 )
- {
- // by default use the current thumb position
- thumbPos = scrollbar->GetThumbPosition();
- }
-
- return ( thumbPos*StandardScrollBarSize(scrollbar, sizeArrow) ) / range
- + (scrollbar->IsVertical() ? sizeArrow.y : sizeArrow.x);
-}
-
-/* static */
-int wxRenderer::StandardPixelToScrollbar(const wxScrollBar *scrollbar,
- wxCoord coord,
- const wxSize& sizeArrow)
-{
- return ( (coord - (scrollbar->IsVertical() ? sizeArrow.y : sizeArrow.x)) *
- scrollbar->GetRange() ) /
- StandardScrollBarSize(scrollbar, sizeArrow);
-}
-
-/* static */
-wxHitTest wxRenderer::StandardHitTestScrollbar(const wxScrollBar *scrollbar,
- const wxPoint& pt,
- const wxSize& sizeArrowSB)
-{
- // we only need to work with either x or y coord depending on the
- // orientation, choose one (but still check the other one to verify if the
- // mouse is in the window at all)
- wxCoord coord, sizeArrow, sizeTotal;
- wxSize size = scrollbar->GetSize();
- if ( scrollbar->GetWindowStyle() & wxVERTICAL )
- {
- if ( pt.x < 0 || pt.x > size.x )
- return wxHT_NOWHERE;
-
- coord = pt.y;
- sizeArrow = sizeArrowSB.y;
- sizeTotal = size.y;
- }
- else // horizontal
- {
- if ( pt.y < 0 || pt.y > size.y )
- return wxHT_NOWHERE;
-
- coord = pt.x;
- sizeArrow = sizeArrowSB.x;
- sizeTotal = size.x;
- }
-
- // test for the arrows first as it's faster
- if ( coord < 0 || coord > sizeTotal )
- {
- return wxHT_NOWHERE;
- }
- else if ( coord < sizeArrow )
- {
- return wxHT_SCROLLBAR_ARROW_LINE_1;
- }
- else if ( coord > sizeTotal - sizeArrow )
- {
- return wxHT_SCROLLBAR_ARROW_LINE_2;
- }
- else
- {
- // calculate the thumb position in pixels
- sizeTotal -= 2*sizeArrow;
- wxCoord thumbStart, thumbEnd;
- int range = scrollbar->GetRange();
- if ( !range )
- {
- // clicking the scrollbar without range has no effect
- return wxHT_NOWHERE;
- }
- else
- {
- StandardScrollBarThumbSize(sizeTotal,
- scrollbar->GetThumbPosition(),
- scrollbar->GetThumbSize(),
- range,
- &thumbStart,
- &thumbEnd);
- }
-
- // now compare with the thumb position
- coord -= sizeArrow;
- if ( coord < thumbStart )
- return wxHT_SCROLLBAR_BAR_1;
- else if ( coord > thumbEnd )
- return wxHT_SCROLLBAR_BAR_2;
- else
- return wxHT_SCROLLBAR_THUMB;
- }
-}
-
-#endif // wxUSE_SCROLLBAR
-
wxRenderer::~wxRenderer()
{
}
void wxControlRenderer::DoDrawItems(const wxListBox *lbox,
size_t itemFirst, size_t itemLast,
#if wxUSE_CHECKLISTBOX
- bool isCheckLbox)
+ bool isCheckLbox
#else
- bool WXUNUSED(isCheckLbox))
+ bool WXUNUSED(isCheckLbox)
#endif
+ )
{
// prepare for the drawing: calc the initial position
wxCoord lineHeight = lbox->GetLineHeight();
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: src/univ/stdrend.cpp
+// Purpose: implementation of wxStdRenderer
+// Author: Vadim Zeitlin
+// Created: 2006-09-16
+// RCS-ID: $Id$
+// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif //WX_PRECOMP
+
+#include "wx/univ/stdrend.h"
+#include "wx/univ/colschem.h"
+
+// ============================================================================
+// wxStdRenderer implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// ctor
+// ----------------------------------------------------------------------------
+
+wxStdRenderer::wxStdRenderer(const wxColourScheme *scheme)
+ : m_scheme(scheme)
+{
+ m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK));
+ m_penDarkGrey = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_OUT));
+ m_penLightGrey = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_IN));
+ m_penHighlight = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_HIGHLIGHT));
+}
+
+// ----------------------------------------------------------------------------
+// helper functions
+// ----------------------------------------------------------------------------
+
+void
+wxStdRenderer::DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect)
+{
+ wxBrush brush(col, wxSOLID);
+ dc.SetBrush(brush);
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.DrawRectangle(rect);
+}
+
+void wxStdRenderer::DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen)
+{
+ // draw
+ dc.SetPen(pen);
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+ dc.DrawRectangle(*rect);
+
+ // adjust the rect
+ rect->Inflate(-1);
+}
+
+void wxStdRenderer::DrawShadedRect(wxDC& dc, wxRect *rect,
+ const wxPen& pen1, const wxPen& pen2)
+{
+ // draw the rectangle
+ dc.SetPen(pen1);
+ dc.DrawLine(rect->GetLeft(), rect->GetTop(),
+ rect->GetLeft(), rect->GetBottom());
+ dc.DrawLine(rect->GetLeft() + 1, rect->GetTop(),
+ rect->GetRight(), rect->GetTop());
+ dc.SetPen(pen2);
+ dc.DrawLine(rect->GetRight(), rect->GetTop(),
+ rect->GetRight(), rect->GetBottom());
+ dc.DrawLine(rect->GetLeft(), rect->GetBottom(),
+ rect->GetRight() + 1, rect->GetBottom());
+
+ // adjust the rect
+ rect->Inflate(-1);
+}
+
+// ----------------------------------------------------------------------------
+// background
+// ----------------------------------------------------------------------------
+
+void wxStdRenderer::DrawBackground(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int WXUNUSED(flags),
+ wxWindow *window)
+{
+ wxColour colBg = col.Ok() ? col
+ : window ? m_scheme->GetBackground(window)
+ : wxSCHEME_COLOUR(m_scheme, CONTROL);
+
+ DrawSolidRect(dc, colBg, rect);
+}
+
+
+void wxStdRenderer::DrawButtonSurface(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags)
+{
+ DrawBackground(dc, col, rect, flags);
+}
+
+// ----------------------------------------------------------------------------
+// text
+// ----------------------------------------------------------------------------
+
+void wxStdRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect)
+{
+ // draw the pixels manually because the "dots" in wxPen with wxDOT style
+ // may be short traits and not really dots
+ //
+ // note that to behave in the same manner as DrawRect(), we must exclude
+ // the bottom and right borders from the rectangle
+ wxCoord x1 = rect.GetLeft(),
+ y1 = rect.GetTop(),
+ x2 = rect.GetRight(),
+ y2 = rect.GetBottom();
+
+ dc.SetPen(m_penBlack);
+
+ // this seems to be closer than what Windows does than wxINVERT although
+ // I'm still not sure if it's correct
+ dc.SetLogicalFunction(wxAND_REVERSE);
+
+ wxCoord z;
+ for ( z = x1 + 1; z < x2; z += 2 )
+ dc.DrawPoint(z, rect.GetTop());
+
+ wxCoord shift = z == x2 ? 0 : 1;
+ for ( z = y1 + shift; z < y2; z += 2 )
+ dc.DrawPoint(x2, z);
+
+ shift = z == y2 ? 0 : 1;
+ for ( z = x2 - shift; z > x1; z -= 2 )
+ dc.DrawPoint(z, y2);
+
+ shift = z == x1 ? 0 : 1;
+ for ( z = y2 - shift; z > y1; z -= 2 )
+ dc.DrawPoint(x1, z);
+
+ dc.SetLogicalFunction(wxCOPY);
+}
+
+void wxStdRenderer::DrawLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags,
+ int alignment,
+ int indexAccel,
+ wxRect *rectBounds)
+{
+ DrawButtonLabel(dc, label, wxNullBitmap, rect, flags,
+ alignment, indexAccel, rectBounds);
+}
+
+void wxStdRenderer::DrawButtonLabel(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& image,
+ const wxRect& rect,
+ int flags,
+ int alignment,
+ int indexAccel,
+ wxRect *rectBounds)
+{
+ wxRect rectLabel = rect;
+ if ( !label.empty() && (flags & wxCONTROL_DISABLED) )
+ {
+ if ( flags & wxCONTROL_PRESSED )
+ {
+ // shift the label if a button is pressed
+ rectLabel.Offset(1, 1);
+ }
+
+ // draw shadow of the text
+ dc.SetTextForeground(m_penHighlight.GetColour());
+ wxRect rectShadow = rect;
+ rectShadow.Offset(1, 1);
+ dc.DrawLabel(label, rectShadow, alignment, indexAccel);
+
+ // make the main label text grey
+ dc.SetTextForeground(m_penDarkGrey.GetColour());
+
+ if ( flags & wxCONTROL_FOCUSED )
+ {
+ // leave enough space for the focus rect
+ rectLabel.Inflate(-2);
+ }
+ }
+
+ dc.DrawLabel(label, image, rectLabel, alignment, indexAccel, rectBounds);
+
+ if ( !label.empty() && (flags & wxCONTROL_FOCUSED) )
+ {
+ rectLabel.Inflate(-1);
+
+ DrawFocusRect(dc, rectLabel);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// borders
+// ----------------------------------------------------------------------------
+
+/*
+ We implement standard-looking 3D borders which have the following appearance:
+
+ The raised border:
+
+ WWWWWWWWWWWWWWWWWWWWWWB
+ WHHHHHHHHHHHHHHHHHHHHGB
+ WH GB W = white (HILIGHT)
+ WH GB H = light grey (LIGHT)
+ WH GB G = dark grey (SHADOI)
+ WH GB B = black (DKSHADOI)
+ WH GB
+ WH GB
+ WGGGGGGGGGGGGGGGGGGGGGB
+ BBBBBBBBBBBBBBBBBBBBBBB
+
+ The sunken border looks like this:
+
+ GGGGGGGGGGGGGGGGGGGGGGW
+ GBBBBBBBBBBBBBBBBBBBBHW
+ GB HW
+ GB HW
+ GB HW
+ GB HW
+ GB HW
+ GB HW
+ GHHHHHHHHHHHHHHHHHHHHHW
+ WWWWWWWWWWWWWWWWWWWWWWW
+
+ The static border (used for the controls which don't get focus) is like
+ this:
+
+ GGGGGGGGGGGGGGGGGGGGGGW
+ G W
+ G W
+ G W
+ G W
+ G W
+ G W
+ G W
+ WWWWWWWWWWWWWWWWWWWWWWW
+
+ The most complicated is the double border which is a combination of special
+ "anti-sunken" border and an extra border inside it:
+
+ HHHHHHHHHHHHHHHHHHHHHHB
+ HWWWWWWWWWWWWWWWWWWWWGB
+ HWHHHHHHHHHHHHHHHHHHHGB
+ HWH HGB
+ HWH HGB
+ HWH HGB
+ HWH HGB
+ HWHHHHHHHHHHHHHHHHHHHGB
+ HGGGGGGGGGGGGGGGGGGGGGB
+ BBBBBBBBBBBBBBBBBBBBBBB
+
+ And the simple border is, well, simple:
+
+ BBBBBBBBBBBBBBBBBBBBBBB
+ B B
+ B B
+ B B
+ B B
+ B B
+ B B
+ B B
+ B B
+ BBBBBBBBBBBBBBBBBBBBBBB
+*/
+
+void wxStdRenderer::DrawRaisedBorder(wxDC& dc, wxRect *rect)
+{
+ DrawShadedRect(dc, rect, m_penHighlight, m_penBlack);
+ DrawShadedRect(dc, rect, m_penLightGrey, m_penDarkGrey);
+}
+
+void wxStdRenderer::DrawSunkenBorder(wxDC& dc, wxRect *rect)
+{
+ DrawShadedRect(dc, rect, m_penDarkGrey, m_penHighlight);
+ DrawShadedRect(dc, rect, m_penBlack, m_penLightGrey);
+}
+
+void wxStdRenderer::DrawAntiSunkenBorder(wxDC& dc, wxRect *rect)
+{
+ DrawShadedRect(dc, rect, m_penLightGrey, m_penBlack);
+ DrawShadedRect(dc, rect, m_penHighlight, m_penDarkGrey);
+}
+
+void wxStdRenderer::DrawBorder(wxDC& dc,
+ wxBorder border,
+ const wxRect& rectTotal,
+ int WXUNUSED(flags),
+ wxRect *rectIn)
+{
+ wxRect rect = rectTotal;
+
+ switch ( border )
+ {
+ case wxBORDER_SUNKEN:
+ DrawSunkenBorder(dc, &rect);
+ break;
+
+ case wxBORDER_DOUBLE:
+ DrawAntiSunkenBorder(dc, &rect);
+ DrawRect(dc, &rect, m_penLightGrey);
+ break;
+
+ case wxBORDER_STATIC:
+ DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
+ break;
+
+ case wxBORDER_RAISED:
+ DrawRaisedBorder(dc, &rect);
+ break;
+
+ case wxBORDER_SIMPLE:
+ DrawRect(dc, &rect, m_penBlack);
+ break;
+
+ default:
+ wxFAIL_MSG(_T("unknown border type"));
+ // fall through
+
+ case wxBORDER_DEFAULT:
+ case wxBORDER_NONE:
+ break;
+ }
+
+ if ( rectIn )
+ *rectIn = rect;
+}
+
+wxRect wxStdRenderer::GetBorderDimensions(wxBorder border) const
+{
+ wxCoord width;
+ switch ( border )
+ {
+ case wxBORDER_SIMPLE:
+ case wxBORDER_STATIC:
+ width = 1;
+ break;
+
+ case wxBORDER_RAISED:
+ case wxBORDER_SUNKEN:
+ width = 2;
+ break;
+
+ case wxBORDER_DOUBLE:
+ width = 3;
+ break;
+
+ default:
+ wxFAIL_MSG(_T("unknown border type"));
+ // fall through
+
+ case wxBORDER_DEFAULT:
+ case wxBORDER_NONE:
+ width = 0;
+ break;
+ }
+
+ wxRect rect;
+ rect.x =
+ rect.y =
+ rect.width =
+ rect.height = width;
+
+ return rect;
+}
+
+bool wxStdRenderer::AreScrollbarsInsideBorder() const
+{
+ return false;
+}
+
+void wxStdRenderer::DrawTextBorder(wxDC& dc,
+ wxBorder border,
+ const wxRect& rect,
+ int flags,
+ wxRect *rectIn)
+{
+ DrawBorder(dc, border, rect, flags, rectIn);
+}
+
+// ----------------------------------------------------------------------------
+// lines and boxes
+// ----------------------------------------------------------------------------
+
+void
+wxStdRenderer::DrawHorizontalLine(wxDC& dc, wxCoord y, wxCoord x1, wxCoord x2)
+{
+ dc.SetPen(m_penDarkGrey);
+ dc.DrawLine(x1, y, x2 + 1, y);
+
+ dc.SetPen(m_penHighlight);
+ y++;
+ dc.DrawLine(x1, y, x2 + 1, y);
+}
+
+void
+wxStdRenderer::DrawVerticalLine(wxDC& dc, wxCoord x, wxCoord y1, wxCoord y2)
+{
+ dc.SetPen(m_penDarkGrey);
+ dc.DrawLine(x, y1, x, y2 + 1);
+
+ dc.SetPen(m_penHighlight);
+ x++;
+ dc.DrawLine(x, y1, x, y2 + 1);
+}
+
+void wxStdRenderer::DrawFrameWithoutLabel(wxDC& dc,
+ const wxRect& rectFrame,
+ const wxRect& rectLabel)
+{
+ // draw left, bottom and right lines entirely
+ DrawVerticalLine(dc, rectFrame.GetLeft(),
+ rectFrame.GetTop(), rectFrame.GetBottom() - 2);
+ DrawHorizontalLine(dc, rectFrame.GetBottom() - 1,
+ rectFrame.GetLeft(), rectFrame.GetRight());
+ DrawVerticalLine(dc, rectFrame.GetRight() - 1,
+ rectFrame.GetTop(), rectFrame.GetBottom() - 1);
+
+ // and 2 parts of the top line
+ DrawHorizontalLine(dc, rectFrame.GetTop(),
+ rectFrame.GetLeft() + 1, rectLabel.GetLeft());
+ DrawHorizontalLine(dc, rectFrame.GetTop(),
+ rectLabel.GetRight(), rectFrame.GetRight() - 2);
+}
+
+void wxStdRenderer::DrawFrameWithLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rectFrame,
+ const wxRect& rectText,
+ int flags,
+ int alignment,
+ int indexAccel)
+{
+ wxRect rectLabel;
+ DrawLabel(dc, label, rectText, flags, alignment, indexAccel, &rectLabel);
+
+ DrawFrameWithoutLabel(dc, rectFrame, rectLabel);
+}
+
+void wxStdRenderer::DrawFrame(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags,
+ int alignment,
+ int indexAccel)
+{
+ wxCoord height = 0; // of the label
+ wxRect rectFrame = rect;
+ if ( !label.empty() )
+ {
+ // the text should touch the top border of the rect, so the frame
+ // itself should be lower
+ dc.GetTextExtent(label, NULL, &height);
+ rectFrame.y += height / 2;
+ rectFrame.height -= height / 2;
+
+ // we have to draw each part of the frame individually as we can't
+ // erase the background beyond the label as it might contain some
+ // pixmap already, so drawing everything and then overwriting part of
+ // the frame with label doesn't work
+
+ // TODO: the +5 shouldn't be hard coded
+ wxRect rectText;
+ rectText.x = rectFrame.x + 5;
+ rectText.y = rect.y;
+ rectText.width = rectFrame.width - 7; // +2 border width
+ rectText.height = height;
+
+ DrawFrameWithLabel(dc, label, rectFrame, rectText, flags,
+ alignment, indexAccel);
+ }
+ else // no label
+ {
+ // just draw the complete frame
+ DrawShadedRect(dc, &rectFrame, m_penDarkGrey, m_penHighlight);
+ DrawShadedRect(dc, &rectFrame, m_penHighlight, m_penDarkGrey);
+ }
+}
+
+void wxStdRenderer::DrawItem(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags)
+{
+ wxDCTextColourChanger colChanger(dc);
+
+ if ( flags & wxCONTROL_SELECTED )
+ {
+ colChanger.Set(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
+
+ const wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT);
+ dc.SetBrush(colBg);
+ dc.SetPen(colBg);
+ dc.DrawRectangle(rect);
+ }
+
+ wxRect rectText = rect;
+ rectText.x += 2;
+ rectText.width -= 2;
+ dc.DrawLabel(label, wxNullBitmap, rectText);
+
+ if ( flags & wxCONTROL_FOCUSED )
+ {
+ DrawFocusRect(dc, rect);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// check and radio bitmaps
+// ----------------------------------------------------------------------------
+
+/* static */
+void wxStdRenderer::GetIndicatorsFromFlags(int flags,
+ IndicatorState& state,
+ IndicatorStatus& status)
+{
+ if ( flags & wxCONTROL_SELECTED )
+ state = flags & wxCONTROL_DISABLED ? IndicatorState_SelectedDisabled
+ : IndicatorState_Selected;
+ else if ( flags & wxCONTROL_DISABLED )
+ state = IndicatorState_Disabled;
+ else if ( flags & wxCONTROL_PRESSED )
+ state = IndicatorState_Pressed;
+ else
+ state = IndicatorState_Normal;
+
+ status = flags & wxCONTROL_CHECKED ? IndicatorStatus_Checked
+ : flags & wxCONTROL_UNDETERMINED
+ ? IndicatorStatus_Undetermined
+ : IndicatorStatus_Unchecked;
+}
+
+void wxStdRenderer::DrawCheckButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags,
+ wxAlignment align,
+ int indexAccel)
+{
+ wxBitmap bmp(bitmap.Ok() ? bitmap : GetCheckBitmap(flags));
+
+ DrawCheckOrRadioButton(dc, label, bmp, rect, flags, align, indexAccel);
+}
+
+void wxStdRenderer::DrawRadioButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags,
+ wxAlignment align,
+ int indexAccel)
+{
+ wxBitmap bmp(bitmap.Ok() ? bitmap : GetRadioBitmap(flags));
+
+ DrawCheckOrRadioButton(dc, label, bmp, rect, flags, align, indexAccel);
+}
+
+void wxStdRenderer::DrawCheckOrRadioButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags,
+ wxAlignment align,
+ int indexAccel)
+{
+ // calculate the position of the bitmap and of the label
+ wxCoord heightBmp = bitmap.GetHeight();
+ wxCoord xBmp,
+ yBmp = rect.y + (rect.height - heightBmp) / 2;
+
+ wxRect rectLabel;
+ dc.GetMultiLineTextExtent(label, NULL, &rectLabel.height);
+ rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2;
+
+ // align label vertically with the bitmap - looks nicer like this
+ rectLabel.y -= (rectLabel.height - heightBmp) % 2;
+
+ // calc horz position
+ if ( align == wxALIGN_RIGHT )
+ {
+ xBmp = rect.GetRight() - bitmap.GetWidth();
+ rectLabel.x = rect.x + 3;
+ rectLabel.SetRight(xBmp);
+ }
+ else // normal (checkbox to the left of the text) case
+ {
+ xBmp = rect.x;
+ rectLabel.x = xBmp + bitmap.GetWidth() + 5;
+ rectLabel.SetRight(rect.GetRight());
+ }
+
+ dc.DrawBitmap(bitmap, xBmp, yBmp, true /* use mask */);
+
+ DrawLabel(dc, label, rectLabel, flags,
+ wxALIGN_LEFT | wxALIGN_TOP, indexAccel);
+}
+
+#if wxUSE_TEXTCTRL
+
+void wxStdRenderer::DrawTextLine(wxDC& dc,
+ const wxString& text,
+ const wxRect& rect,
+ int selStart,
+ int selEnd,
+ int flags)
+{
+ if ( (selStart == -1) || !(flags & wxCONTROL_FOCUSED) )
+ {
+ // just draw it as is
+ dc.DrawText(text, rect.x, rect.y);
+ }
+ else // we have selection
+ {
+ wxCoord width,
+ x = rect.x;
+
+ // draw the part before selection
+ wxString s(text, (size_t)selStart);
+ if ( !s.empty() )
+ {
+ dc.DrawText(s, x, rect.y);
+
+ dc.GetTextExtent(s, &width, NULL);
+ x += width;
+ }
+
+ // draw the selection itself
+ s = wxString(text.c_str() + selStart, text.c_str() + selEnd);
+ if ( !s.empty() )
+ {
+ wxColour colFg = dc.GetTextForeground(),
+ colBg = dc.GetTextBackground();
+ dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
+ dc.SetTextBackground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT));
+ dc.SetBackgroundMode(wxSOLID);
+
+ dc.DrawText(s, x, rect.y);
+ dc.GetTextExtent(s, &width, NULL);
+ x += width;
+
+ dc.SetBackgroundMode(wxTRANSPARENT);
+ dc.SetTextBackground(colBg);
+ dc.SetTextForeground(colFg);
+ }
+
+ // draw the final part
+ s = text.c_str() + selEnd;
+ if ( !s.empty() )
+ {
+ dc.DrawText(s, x, rect.y);
+ }
+ }
+}
+
+void wxStdRenderer::DrawLineWrapMark(wxDC& WXUNUSED(dc),
+ const wxRect& WXUNUSED(rect))
+{
+ // nothing by default
+}
+
+#endif // wxUSE_TEXTCTRL
+
+// ----------------------------------------------------------------------------
+// scrollbars geometry
+// ----------------------------------------------------------------------------
+
+#if wxUSE_SCROLLBAR
+
+/* static */
+void wxStdRenderer::GetScrollBarThumbSize(wxCoord length,
+ int thumbPos,
+ int thumbSize,
+ int range,
+ wxCoord *thumbStart,
+ wxCoord *thumbEnd)
+{
+ // the thumb can't be made less than this number of pixels
+ static const wxCoord thumbMinWidth = 8; // FIXME: should be configurable
+
+ *thumbStart = (length*thumbPos) / range;
+ *thumbEnd = (length*(thumbPos + thumbSize)) / range;
+
+ if ( *thumbEnd - *thumbStart < thumbMinWidth )
+ {
+ // adjust the end if possible
+ if ( *thumbStart <= length - thumbMinWidth )
+ {
+ // yes, just make it wider
+ *thumbEnd = *thumbStart + thumbMinWidth;
+ }
+ else // it is at the bottom of the scrollbar
+ {
+ // so move it a bit up
+ *thumbStart = length - thumbMinWidth;
+ *thumbEnd = length;
+ }
+ }
+}
+
+wxRect wxStdRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
+ wxScrollBar::Element elem,
+ int thumbPos) const
+{
+ if ( thumbPos == -1 )
+ {
+ thumbPos = scrollbar->GetThumbPosition();
+ }
+
+ const wxSize sizeArrow = GetScrollbarArrowSize();
+
+ wxSize sizeTotal = scrollbar->GetClientSize();
+ wxCoord *start, *width;
+ wxCoord length, arrow;
+ wxRect rect;
+ if ( scrollbar->IsVertical() )
+ {
+ rect.x = 0;
+ rect.width = sizeTotal.x;
+ length = sizeTotal.y;
+ start = &rect.y;
+ width = &rect.height;
+ arrow = sizeArrow.y;
+ }
+ else // horizontal
+ {
+ rect.y = 0;
+ rect.height = sizeTotal.y;
+ length = sizeTotal.x;
+ start = &rect.x;
+ width = &rect.width;
+ arrow = sizeArrow.x;
+ }
+
+ switch ( elem )
+ {
+ case wxScrollBar::Element_Arrow_Line_1:
+ *start = 0;
+ *width = arrow;
+ break;
+
+ case wxScrollBar::Element_Arrow_Line_2:
+ *start = length - arrow;
+ *width = arrow;
+ break;
+
+ case wxScrollBar::Element_Arrow_Page_1:
+ case wxScrollBar::Element_Arrow_Page_2:
+ // we don't have them at all
+ break;
+
+ case wxScrollBar::Element_Thumb:
+ case wxScrollBar::Element_Bar_1:
+ case wxScrollBar::Element_Bar_2:
+ // we need to calculate the thumb position - do it
+ {
+ length -= 2*arrow;
+ wxCoord thumbStart, thumbEnd;
+ int range = scrollbar->GetRange();
+ if ( !range )
+ {
+ thumbStart =
+ thumbEnd = 0;
+ }
+ else
+ {
+ GetScrollBarThumbSize(length,
+ thumbPos,
+ scrollbar->GetThumbSize(),
+ range,
+ &thumbStart,
+ &thumbEnd);
+ }
+
+ if ( elem == wxScrollBar::Element_Thumb )
+ {
+ *start = thumbStart;
+ *width = thumbEnd - thumbStart;
+ }
+ else if ( elem == wxScrollBar::Element_Bar_1 )
+ {
+ *start = 0;
+ *width = thumbStart;
+ }
+ else // elem == wxScrollBar::Element_Bar_2
+ {
+ *start = thumbEnd;
+ *width = length - thumbEnd;
+ }
+
+ // everything is relative to the start of the shaft so far
+ *start += arrow;
+ }
+ break;
+
+ case wxScrollBar::Element_Max:
+ default:
+ wxFAIL_MSG( _T("unknown scrollbar element") );
+ }
+
+ return rect;
+}
+
+wxCoord wxStdRenderer::GetScrollbarSize(const wxScrollBar *scrollbar)
+{
+ const wxSize sizeArrowSB = GetScrollbarArrowSize();
+
+ wxCoord sizeArrow, sizeTotal;
+ if ( scrollbar->GetWindowStyle() & wxVERTICAL )
+ {
+ sizeArrow = sizeArrowSB.y;
+ sizeTotal = scrollbar->GetSize().y;
+ }
+ else // horizontal
+ {
+ sizeArrow = sizeArrowSB.x;
+ sizeTotal = scrollbar->GetSize().x;
+ }
+
+ return sizeTotal - 2*sizeArrow;
+}
+
+wxHitTest
+wxStdRenderer::HitTestScrollbar(const wxScrollBar *scrollbar, const wxPoint& pt) const
+{
+ // we only need to work with either x or y coord depending on the
+ // orientation, choose one (but still check the other one to verify if the
+ // mouse is in the window at all)
+ const wxSize sizeArrowSB = GetScrollbarArrowSize();
+
+ wxCoord coord, sizeArrow, sizeTotal;
+ wxSize size = scrollbar->GetSize();
+ if ( scrollbar->GetWindowStyle() & wxVERTICAL )
+ {
+ if ( pt.x < 0 || pt.x > size.x )
+ return wxHT_NOWHERE;
+
+ coord = pt.y;
+ sizeArrow = sizeArrowSB.y;
+ sizeTotal = size.y;
+ }
+ else // horizontal
+ {
+ if ( pt.y < 0 || pt.y > size.y )
+ return wxHT_NOWHERE;
+
+ coord = pt.x;
+ sizeArrow = sizeArrowSB.x;
+ sizeTotal = size.x;
+ }
+
+ // test for the arrows first as it's faster
+ if ( coord < 0 || coord > sizeTotal )
+ {
+ return wxHT_NOWHERE;
+ }
+ else if ( coord < sizeArrow )
+ {
+ return wxHT_SCROLLBAR_ARROW_LINE_1;
+ }
+ else if ( coord > sizeTotal - sizeArrow )
+ {
+ return wxHT_SCROLLBAR_ARROW_LINE_2;
+ }
+ else
+ {
+ // calculate the thumb position in pixels
+ sizeTotal -= 2*sizeArrow;
+ wxCoord thumbStart, thumbEnd;
+ int range = scrollbar->GetRange();
+ if ( !range )
+ {
+ // clicking the scrollbar without range has no effect
+ return wxHT_NOWHERE;
+ }
+ else
+ {
+ GetScrollBarThumbSize(sizeTotal,
+ scrollbar->GetThumbPosition(),
+ scrollbar->GetThumbSize(),
+ range,
+ &thumbStart,
+ &thumbEnd);
+ }
+
+ // now compare with the thumb position
+ coord -= sizeArrow;
+ if ( coord < thumbStart )
+ return wxHT_SCROLLBAR_BAR_1;
+ else if ( coord > thumbEnd )
+ return wxHT_SCROLLBAR_BAR_2;
+ else
+ return wxHT_SCROLLBAR_THUMB;
+ }
+}
+
+
+wxCoord
+wxStdRenderer::ScrollbarToPixel(const wxScrollBar *scrollbar, int thumbPos)
+{
+ int range = scrollbar->GetRange();
+ if ( !range )
+ {
+ // the only valid position anyhow
+ return 0;
+ }
+
+ if ( thumbPos == -1 )
+ {
+ // by default use the current thumb position
+ thumbPos = scrollbar->GetThumbPosition();
+ }
+
+ const wxSize sizeArrow = GetScrollbarArrowSize();
+ return (thumbPos*GetScrollbarSize(scrollbar)) / range
+ + (scrollbar->IsVertical() ? sizeArrow.y : sizeArrow.x);
+}
+
+int wxStdRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord)
+{
+ const wxSize sizeArrow = GetScrollbarArrowSize();
+ return ((coord - (scrollbar->IsVertical() ? sizeArrow.y : sizeArrow.x)) *
+ scrollbar->GetRange() ) / GetScrollbarSize(scrollbar);
+}
+
+#endif // wxUSE_SCROLLBAR
+
#include "wx/tglbtn.h"
#endif // wxUSE_TOGGLEBTN
-#include "wx/univ/renderer.h"
+#include "wx/univ/stdrend.h"
#include "wx/univ/inpcons.h"
#include "wx/univ/inphand.h"
#include "wx/univ/colschem.h"
class WXDLLEXPORT wxGTKMenuGeometryInfo;
// ----------------------------------------------------------------------------
-// constants (to be removed, for testing only)
+// constants
// ----------------------------------------------------------------------------
-static const size_t BORDER_THICKNESS = 1;
+// standard border size
+static const int BORDER_THICKNESS = 2;
// ----------------------------------------------------------------------------
// wxGTKRenderer: draw the GUI elements in GTK style
// ----------------------------------------------------------------------------
-class wxGTKRenderer : public wxRenderer
+class wxGTKRenderer : public wxStdRenderer
{
public:
wxGTKRenderer(const wxColourScheme *scheme);
- // implement the base class pure virtuals
- virtual void DrawBackground(wxDC& dc,
- const wxColour& col,
+ // wxRenderer methods
+ virtual void DrawFocusRect(wxDC& dc, const wxRect& rect);
+ virtual void DrawTextBorder(wxDC& dc,
+ wxBorder border,
const wxRect& rect,
int flags = 0,
- wxWindow *window = NULL );
- virtual void DrawLabel(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags = 0,
- int alignment = wxALIGN_LEFT | wxALIGN_TOP,
- int indexAccel = -1,
- wxRect *rectBounds = NULL);
+ wxRect *rectIn = NULL);
virtual void DrawButtonLabel(wxDC& dc,
const wxString& label,
const wxBitmap& image,
const wxRect& rect,
- int flags = 0,
- int alignment = wxALIGN_LEFT | wxALIGN_TOP,
- int indexAccel = -1,
- wxRect *rectBounds = NULL);
- virtual void DrawBorder(wxDC& dc,
- wxBorder border,
- const wxRect& rect,
- int flags = 0,
- wxRect *rectIn = (wxRect *)NULL);
- virtual void DrawHorizontalLine(wxDC& dc,
- wxCoord y, wxCoord x1, wxCoord x2);
- virtual void DrawVerticalLine(wxDC& dc,
- wxCoord x, wxCoord y1, wxCoord y2);
- virtual void DrawFrame(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags = 0,
- int alignment = wxALIGN_LEFT,
- int indexAccel = -1);
- virtual void DrawTextBorder(wxDC& dc,
- wxBorder border,
- const wxRect& rect,
- int flags = 0,
- wxRect *rectIn = (wxRect *)NULL);
+ int flags,
+ int alignment,
+ int indexAccel,
+ wxRect *rectBounds);
virtual void DrawButtonBorder(wxDC& dc,
const wxRect& rect,
int flags = 0,
- wxRect *rectIn = (wxRect *)NULL);
+ wxRect *rectIn = NULL);
virtual void DrawArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
int flags = 0);
virtual void DrawScrollCorner(wxDC& dc,
const wxRect& rect);
- virtual void DrawItem(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags = 0);
virtual void DrawCheckItem(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags = 0);
- virtual void DrawCheckButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rect,
- int flags = 0,
- wxAlignment align = wxALIGN_LEFT,
- int indexAccel = -1);
-
- virtual void DrawRadioButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rect,
- int flags = 0,
- wxAlignment align = wxALIGN_LEFT,
- int indexAccel = -1);
#if wxUSE_TOOLBAR
virtual void DrawToolBarButton(wxDC& dc,
int tbarStyle = 0);
#endif // wxUSE_TOOLBAR
- virtual void DrawTextLine(wxDC& dc,
- const wxString& text,
- const wxRect& rect,
- int selStart = -1,
- int selEnd = -1,
- int flags = 0);
+#if wxUSE_TEXTCTRL
virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect);
+#endif // wxUSE_TEXTCTRL
+
virtual void DrawTab(wxDC& dc,
const wxRect& rect,
wxDirection dir,
wxBitmap *bmpDisabled);
virtual void AdjustSize(wxSize *size, const wxWindow *window);
- virtual wxRect GetBorderDimensions(wxBorder border) const;
- virtual bool AreScrollbarsInsideBorder() const;
// geometry and hit testing
virtual wxSize GetScrollbarArrowSize() const
virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
int thumbPos = -1) const;
- virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
- virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
- const wxPoint& pt) const;
- virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
- int thumbPos = -1);
- virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
#endif // wxUSE_SCROLLBAR
virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
void DrawUndeterminedBitmap(wxDC& dc, const wxRect& rect, bool isPressed);
protected:
- // DrawBackground() helpers
+ virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect);
+
+ virtual void DrawFrameWithLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rectFrame,
+ const wxRect& rectText,
+ int flags,
+ int alignment,
+ int indexAccel);
// get the colour to use for background
wxColour GetBackgroundColour(int flags) const
return wxSCHEME_COLOUR(m_scheme, CONTROL);
}
- // draw the background with any colour, not only the default one(s)
- void DoDrawBackground(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- wxWindow *window = NULL);
-
- // DrawBorder() helpers: all of them shift and clip the DC after drawing
- // the border
-
- // just draw a rectangle with the given pen
- void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
-
- // draw the lower left part of rectangle
- void DrawHalfRect(wxDC& dc, wxRect *rect, const wxPen& pen);
-
- // draw the rectange using the first brush for the left and top sides and
- // the second one for the bottom and right ones
- void DrawShadedRect(wxDC& dc, wxRect *rect,
- const wxPen& pen1, const wxPen& pen2);
-
// as DrawShadedRect() but the pixels in the bottom left and upper right
// border are drawn with the pen1, not pen2
void DrawAntiShadedRect(wxDC& dc, wxRect *rect,
wxRect *rect,
wxOrientation orient);
- // draw the normal 3D border
- void DrawRaisedBorder(wxDC& dc, wxRect *rect);
-
// just as DrawRaisedBorder() except that the bottom left and up right
// pixels of the interior rect are drawn in another colour (i.e. the inner
// rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
void DrawAntiRaisedBorder(wxDC& dc, wxRect *rect);
+ // draw inner GTK shadow
+ void DrawInnerShadedRect(wxDC& dc, wxRect *rect);
+
#if wxUSE_SCROLLBAR
// returns the size of the arrow for the scrollbar (depends on
// orientation)
// get the line wrap indicator bitmap
wxBitmap GetLineWrapBitmap() const;
- // DrawCheckBitmap and DrawRadioBitmap helpers
-
- // draw the check bitmaps once and cache them for later use
- wxBitmap GetCheckBitmap(int flags);
+ virtual wxBitmap GetCheckBitmap(int flags);
+ virtual wxBitmap GetRadioBitmap(int flags);
// draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
// ((x1 + x2)/2, y2)
wxSize m_sizeScrollbarArrow;
// GDI objects
- wxPen m_penBlack,
- m_penDarkGrey,
- m_penGrey,
- m_penLightGrey,
- m_penHighlight;
+ wxPen m_penGrey;
- // the checkbox bitmaps: first row is for the normal, second for the
- // pressed state and the columns are for checked, unchecked and
- // undeterminated respectively
- wxBitmap m_bitmapsCheckbox[2][3];
+ // the checkbox and radio button bitmaps: first row is for the normal,
+ // second for the pressed state and the columns are for checked, unchecked
+ // and undeterminated respectively
+ wxBitmap m_bitmapsCheckbox[IndicatorState_MaxCtrl][IndicatorStatus_Max],
+ m_bitmapsRadiobtn[IndicatorState_MaxCtrl][IndicatorStatus_Max];
// the line wrap bitmap (drawn at the end of wrapped lines)
wxBitmap m_bmpLineWrap;
// ----------------------------------------------------------------------------
wxGTKRenderer::wxGTKRenderer(const wxColourScheme *scheme)
+ : wxStdRenderer(scheme)
{
- // init data
- m_scheme = scheme;
m_sizeScrollbarArrow = wxSize(15, 14);
- // init pens
- m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID);
- m_penDarkGrey = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_OUT), 0, wxSOLID);
- m_penGrey = wxPen(wxSCHEME_COLOUR(scheme, SCROLLBAR), 0, wxSOLID);
- m_penLightGrey = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_IN), 0, wxSOLID);
- m_penHighlight = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_HIGHLIGHT), 0, wxSOLID);
+ m_penGrey = wxPen(wxSCHEME_COLOUR(scheme, SCROLLBAR));
}
// ----------------------------------------------------------------------------
// border stuff
// ----------------------------------------------------------------------------
-void wxGTKRenderer::DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen)
-{
- // draw
- dc.SetPen(pen);
- dc.SetBrush(*wxTRANSPARENT_BRUSH);
- dc.DrawRectangle(*rect);
-
- // adjust the rect
- rect->Inflate(-1);
-}
-
-void wxGTKRenderer::DrawHalfRect(wxDC& dc, wxRect *rect, const wxPen& pen)
-{
- // draw the bottom and right sides
- dc.SetPen(pen);
- dc.DrawLine(rect->GetLeft(), rect->GetBottom(),
- rect->GetRight() + 1, rect->GetBottom());
- dc.DrawLine(rect->GetRight(), rect->GetTop(),
- rect->GetRight(), rect->GetBottom());
-
- // adjust the rect
- rect->width--;
- rect->height--;
-}
-
-void wxGTKRenderer::DrawShadedRect(wxDC& dc, wxRect *rect,
- const wxPen& pen1, const wxPen& pen2)
-{
- // draw the rectangle
- dc.SetPen(pen1);
- dc.DrawLine(rect->GetLeft(), rect->GetTop(),
- rect->GetLeft(), rect->GetBottom());
- dc.DrawLine(rect->GetLeft() + 1, rect->GetTop(),
- rect->GetRight(), rect->GetTop());
- dc.SetPen(pen2);
- dc.DrawLine(rect->GetRight(), rect->GetTop(),
- rect->GetRight(), rect->GetBottom());
- dc.DrawLine(rect->GetLeft(), rect->GetBottom(),
- rect->GetRight() + 1, rect->GetBottom());
-
- // adjust the rect
- rect->Inflate(-1);
-}
-
void wxGTKRenderer::DrawAntiShadedRectSide(wxDC& dc,
const wxRect& rect,
const wxPen& pen1,
rect->Inflate(-1);
}
-void wxGTKRenderer::DrawRaisedBorder(wxDC& dc, wxRect *rect)
+void wxGTKRenderer::DrawInnerShadedRect(wxDC& dc, wxRect *rect)
{
- DrawShadedRect(dc, rect, m_penHighlight, m_penBlack);
- DrawShadedRect(dc, rect, m_penLightGrey, m_penDarkGrey);
+ DrawAntiShadedRect(dc, rect, m_penDarkGrey, m_penHighlight);
+ DrawAntiShadedRect(dc, rect, m_penBlack, m_penHighlight);
}
void wxGTKRenderer::DrawAntiRaisedBorder(wxDC& dc, wxRect *rect)
DrawAntiShadedRect(dc, rect, m_penLightGrey, m_penDarkGrey);
}
-void wxGTKRenderer::DrawBorder(wxDC& dc,
- wxBorder border,
- const wxRect& rectTotal,
- int WXUNUSED(flags),
- wxRect *rectIn)
-{
- size_t width;
-
- wxRect rect = rectTotal;
-
- switch ( border )
- {
- case wxBORDER_SUNKEN:
- for ( width = 0; width < BORDER_THICKNESS; width++ )
- {
- DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
- DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
- }
- break;
-
- case wxBORDER_STATIC:
- for ( width = 0; width < BORDER_THICKNESS; width++ )
- {
- DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
- }
- break;
-
- case wxBORDER_RAISED:
- for ( width = 0; width < BORDER_THICKNESS; width++ )
- {
- DrawRaisedBorder(dc, &rect);
- }
- break;
-
- case wxBORDER_DOUBLE:
- for ( width = 0; width < BORDER_THICKNESS; width++ )
- {
- DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack);
- DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey);
- DrawRect(dc, &rect, m_penLightGrey);
- }
- break;
-
- case wxBORDER_SIMPLE:
- for ( width = 0; width < BORDER_THICKNESS; width++ )
- {
- DrawRect(dc, &rect, m_penBlack);
- }
- break;
-
- default:
- wxFAIL_MSG(_T("unknown border type"));
- // fall through
-
- case wxBORDER_DEFAULT:
- case wxBORDER_NONE:
- break;
- }
-
- if ( rectIn )
- *rectIn = rect;
-}
-
-wxRect wxGTKRenderer::GetBorderDimensions(wxBorder border) const
+void wxGTKRenderer::DrawSunkenBorder(wxDC& dc, wxRect *rect)
{
- wxCoord width;
- switch ( border )
- {
- case wxBORDER_RAISED:
- case wxBORDER_SUNKEN:
- width = 2*BORDER_THICKNESS;
- break;
-
- case wxBORDER_SIMPLE:
- case wxBORDER_STATIC:
- width = BORDER_THICKNESS;
- break;
-
- case wxBORDER_DOUBLE:
- width = 3*BORDER_THICKNESS;
- break;
-
- default:
- wxFAIL_MSG(_T("unknown border type"));
- // fall through
-
- case wxBORDER_DEFAULT:
- case wxBORDER_NONE:
- width = 0;
- break;
- }
-
- wxRect rect;
- rect.x =
- rect.y =
- rect.width =
- rect.height = width;
-
- return rect;
+ DrawAntiShadedRect(dc, rect, m_penDarkGrey, m_penHighlight);
+ DrawShadedRect(dc, rect, m_penBlack, m_penLightGrey);
}
-bool wxGTKRenderer::AreScrollbarsInsideBorder() const
+void wxGTKRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect)
{
- // no, the scrollbars are outside the border in GTK+
- return false;
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+ wxRect rectFocus = rect;
+ DrawRect(dc, &rectFocus, m_penBlack);
}
-// ----------------------------------------------------------------------------
-// special borders
-// ----------------------------------------------------------------------------
-
void wxGTKRenderer::DrawTextBorder(wxDC& dc,
wxBorder border,
const wxRect& rectOrig,
}
else // !focused
{
- DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
- DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight);
+ DrawInnerShadedRect(dc, &rect);
}
}
*rectIn = rect;
}
+void wxGTKRenderer::DrawButtonLabel(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& image,
+ const wxRect& rect,
+ int flags,
+ int alignment,
+ int indexAccel,
+ wxRect *rectBounds)
+{
+ // no focus rect around buttons label in GTK+
+ wxStdRenderer::DrawButtonLabel(dc, label, image, rect, flags,
+ alignment, indexAccel, rectBounds);
+}
+
void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
const wxRect& rectTotal,
int flags,
// button pressed: draw a black border around it and an inward shade
DrawRect(dc, &rect, m_penBlack);
- for ( size_t width = 0; width < BORDER_THICKNESS; width++ )
- {
- DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
- DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey);
- }
+ DrawInnerShadedRect(dc, &rect);
}
- else
+ else // button not pressed
{
- // button not pressed
-
if ( flags & wxCONTROL_ISDEFAULT )
{
// TODO
}
// now draw a normal button
- for ( size_t width = 0; width < BORDER_THICKNESS; width++ )
- {
- DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
- DrawAntiShadedRect(dc, &rect,
- wxPen(GetBackgroundColour(flags), 0, wxSOLID),
- m_penDarkGrey);
- }
+ DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
+ DrawAntiShadedRect(dc, &rect, GetBackgroundColour(flags), m_penDarkGrey);
}
if ( rectIn )
- {
*rectIn = rect;
- }
}
// ----------------------------------------------------------------------------
// lines and frames
// ----------------------------------------------------------------------------
-void wxGTKRenderer::DrawHorizontalLine(wxDC& dc,
- wxCoord y, wxCoord x1, wxCoord x2)
-{
- dc.SetPen(m_penDarkGrey);
- dc.DrawLine(x1, y, x2 + 1, y);
- dc.SetPen(m_penHighlight);
- y++;
- dc.DrawLine(x1, y, x2 + 1, y);
-}
-
-void wxGTKRenderer::DrawVerticalLine(wxDC& dc,
- wxCoord x, wxCoord y1, wxCoord y2)
-{
- dc.SetPen(m_penDarkGrey);
- dc.DrawLine(x, y1, x, y2 + 1);
- dc.SetPen(m_penHighlight);
- x++;
- dc.DrawLine(x, y1, x, y2 + 1);
-}
-
-void wxGTKRenderer::DrawFrame(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags,
- int alignment,
- int indexAccel)
+void wxGTKRenderer::DrawFrameWithLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rectFrame,
+ const wxRect& rectTextOrig,
+ int flags,
+ int alignment,
+ int indexAccel)
{
- wxCoord height = 0; // of the label
- wxRect rectFrame = rect;
- if ( !label.empty() )
- {
- // the text should touch the top border of the rect, so the frame
- // itself should be lower
- dc.GetTextExtent(label, NULL, &height);
- rectFrame.y += height / 2;
- rectFrame.height -= height / 2;
-
- // TODO: the +4 should be customizable
-
- wxRect rectText;
- rectText.x = rectFrame.x + 4;
- rectText.y = rect.y;
- rectText.width = rectFrame.width - 8;
- rectText.height = height;
+ wxRect rectText(rectTextOrig);
+ rectText.Inflate(1, 0);
- wxRect rectLabel;
- DrawLabel(dc, label, rectText, flags, alignment, indexAccel, &rectLabel);
- rectLabel.x -= 1;
- rectLabel.width += 2;
+ wxRect rectLabel;
+ DrawLabel(dc, label, rectText, flags, alignment, indexAccel, &rectLabel);
+ rectLabel.x -= 1;
+ rectLabel.width += 2;
- StandardDrawFrame(dc, rectFrame, rectLabel);
+ DrawFrameWithoutLabel(dc, rectFrame, rectLabel);
- // GTK+ does it like this
- dc.SetPen(m_penHighlight);
- dc.DrawPoint(rectText.x, rectFrame.y);
- dc.DrawPoint(rectText.x + rectLabel.width - 3, rectFrame.y);
- }
- else
- {
- // just draw the complete frame
- DrawShadedRect(dc, &rectFrame, m_penDarkGrey, m_penHighlight);
- DrawShadedRect(dc, &rectFrame, m_penHighlight, m_penDarkGrey);
- }
+ // GTK+ does it like this
+ dc.SetPen(m_penHighlight);
+ dc.DrawPoint(rectText.x, rectFrame.y);
+ dc.DrawPoint(rectText.x + rectLabel.width - 3, rectFrame.y);
}
// ----------------------------------------------------------------------------
// label
// ----------------------------------------------------------------------------
-void wxGTKRenderer::DrawLabel(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags,
- int alignment,
- int indexAccel,
- wxRect *rectBounds)
-{
- DrawButtonLabel(dc, label, wxNullBitmap, rect, flags,
- alignment, indexAccel, rectBounds);
-}
-
-void wxGTKRenderer::DrawButtonLabel(wxDC& dc,
- const wxString& label,
- const wxBitmap& image,
- const wxRect& rect,
- int flags,
- int alignment,
- int indexAccel,
- wxRect *rectBounds)
-{
- if ( flags & wxCONTROL_DISABLED )
- {
- // make the text grey and draw a shade for it
- dc.SetTextForeground(*wxWHITE); // FIXME hardcoded colour
- wxRect rectShadow = rect;
- rectShadow.x++;
- rectShadow.y++;
- dc.DrawLabel(label, rectShadow, alignment, indexAccel);
- dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, CONTROL_TEXT_DISABLED));
- }
- else
- {
- dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, CONTROL_TEXT));
- }
-
- dc.DrawLabel(label, image, rect, alignment, indexAccel, rectBounds);
-}
-
-void wxGTKRenderer::DrawItem(wxDC& dc,
- const wxString& label,
- 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.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT), wxSOLID));
- dc.SetPen(*wxTRANSPARENT_PEN);
- dc.DrawRectangle(rect);
-
- colFg = dc.GetTextForeground();
- dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
- }
-
- if ( flags & wxCONTROL_FOCUSED )
- {
- dc.SetBrush(*wxTRANSPARENT_BRUSH);
- wxRect rectFocus = rect;
- DrawRect(dc, &rectFocus, m_penBlack);
- }
-
- wxRect rectText = rect;
- rectText.x += 2;
- rectText.y++;
- dc.DrawLabel(label, wxNullBitmap, rectText);
-
- if ( flags & wxCONTROL_SELECTED )
- {
- dc.SetBackgroundMode(wxTRANSPARENT);
- }
-
- // restore the text colour
- if ( colFg.Ok() )
- {
- dc.SetTextForeground(colFg);
- }
-}
-
void wxGTKRenderer::DrawCheckItem(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
}
dc.SetPen(*wxTRANSPARENT_PEN);
- dc.SetBrush(wxBrush(col1, wxSOLID));
+ dc.SetBrush(col1);
dc.DrawRectangle(rect);
rect.Deflate(1);
- dc.SetBrush(wxBrush(col2, wxSOLID));
+ dc.SetBrush(col2);
dc.DrawRectangle(rect);
}
DrawAntiRaisedBorder(dc, &rect);
wxColour col = wxSCHEME_COLOUR(m_scheme, SHADOW_IN);
- dc.SetPen(wxPen(col, 0, wxSOLID));
+ dc.SetPen(wxPen(col));
dc.DrawPoint(rect.GetRight() - 1, rect.GetBottom() - 1);
if ( isPressed )
//else: it is SHADOW_IN, leave as is
dc.SetPen(*wxTRANSPARENT_PEN);
- dc.SetBrush(wxBrush(col, wxSOLID));
+ dc.SetBrush(col);
dc.DrawRectangle(rect);
}
DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
dc.SetPen(*wxTRANSPARENT_PEN);
- dc.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), wxSOLID));
+ dc.SetBrush(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED));
dc.DrawRectangle(rect);
}
wxCoord yMid = (y + yBottom) / 2;
- // this looks ugly when the background colour of the control is not the
- // same ours - radiobox is not transparent as it should be
-#if 0
- // first fill the middle: as FloodFill() is not implemented on all
- // platforms, this is the only thing to do
- wxColour colBg = flags & wxCONTROL_CURRENT
- ? wxSCHEME_COLOUR(m_scheme, CONTROL_CURRENT)
- : wxSCHEME_COLOUR(m_scheme, SHADOW_IN);
- dc.SetBrush(wxBrush(colBg, wxSOLID));
- dc.SetPen(*wxTRANSPARENT_PEN);
- dc.DrawRectangle(rect);
-#endif // 0
-
// then draw the upper half
dc.SetPen(flags & wxCONTROL_CHECKED ? m_penDarkGrey : m_penHighlight);
DrawUpZag(dc, x, xRight, yMid, y);
if ( flags & wxCONTROL_CHECKED )
dc.SetPen(m_penBlack);
else if ( flags & wxCONTROL_PRESSED )
- dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), 0, wxSOLID));
+ dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED)));
else // unchecked and unpressed
drawIt = false;
drawIt = true; // with the same pen
else if ( flags & wxCONTROL_PRESSED )
{
- dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), 0, wxSOLID));
+ dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED)));
drawIt = true;
}
else // checked and unpressed
DrawUndeterminedBitmap(dc, rect, true);
}
- int row = flags & wxCONTROL_PRESSED
- ? 1
- : 0;
- int col = flags & wxCONTROL_CHECKED
- ? 0
- : ( flags & wxCONTROL_UNDETERMINED
- ? 2
- : 1 );
+ IndicatorState state;
+ IndicatorStatus status;
+ GetIndicatorsFromFlags(flags, state, status);
+
+ // disabled looks the same as normal
+ if ( state == IndicatorState_Disabled )
+ state = IndicatorState_Normal;
+
+ return m_bitmapsCheckbox[state][status];
+}
+
+wxBitmap wxGTKRenderer::GetRadioBitmap(int flags)
+{
+ IndicatorState state;
+ IndicatorStatus status;
+ GetIndicatorsFromFlags(flags, state, status);
+
+ wxBitmap& bmp = m_bitmapsRadiobtn[state][status];
+ if ( !bmp.Ok() )
+ {
+ const wxSize size = GetRadioBitmapSize();
+
+ wxMemoryDC dc;
+ bmp.Create(size.x, size.y);
+ dc.SelectObject(bmp);
+
+ DrawRadioBitmap(dc, size, flags);
+ }
- return m_bitmapsCheckbox[row][col];
+ return bmp;
}
wxBitmap wxGTKRenderer::GetLineWrapBitmap() const
return m_bmpLineWrap;
}
-void wxGTKRenderer::DrawCheckButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmapOrig,
- const wxRect& rectTotal,
- int flags,
- wxAlignment align,
- int indexAccel)
-{
- wxBitmap bitmap;
- if ( bitmapOrig.Ok() )
- {
- bitmap = bitmapOrig;
- }
- else
- {
- bitmap = GetCheckBitmap(flags);
- }
-
- DoDrawCheckOrRadioBitmap(dc, label, bitmap, rectTotal,
- flags, align, indexAccel);
-}
-
-void wxGTKRenderer::DoDrawCheckOrRadioBitmap(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rectTotal,
- int flags,
- wxAlignment align,
- int indexAccel)
-{
- wxRect rect = rectTotal;
-
- if ( flags & wxCONTROL_FOCUSED )
- {
- // draw the focus border around everything
- DrawRect(dc, &rect, m_penBlack);
- }
- else
- {
- // the border does not offset the string under GTK
- rect.Inflate(-1);
- }
-
- // calculate the position of the bitmap and of the label
- wxCoord xBmp,
- yBmp = rect.y + (rect.height - bitmap.GetHeight()) / 2;
-
- wxRect rectLabel;
- dc.GetMultiLineTextExtent(label, NULL, &rectLabel.height);
- rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2;
-
- if ( align == wxALIGN_RIGHT )
- {
- xBmp = rect.GetRight() - bitmap.GetWidth();
- rectLabel.x = rect.x + 2;
- rectLabel.SetRight(xBmp);
- }
- else // normal (checkbox to the left of the text) case
- {
- xBmp = rect.x + 2;
- rectLabel.x = xBmp + bitmap.GetWidth() + 4;
- rectLabel.SetRight(rect.GetRight());
- }
-
- dc.DrawBitmap(bitmap, xBmp, yBmp, true /* use mask */);
-
- DrawLabel(dc, label, rectLabel, flags,
- wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, indexAccel);
-}
-
-void wxGTKRenderer::DrawRadioButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmapOrig,
- const wxRect& rectTotal,
- int flags,
- wxAlignment align,
- int indexAccel)
-{
- wxBitmap bitmap;
- if ( bitmapOrig.Ok() )
- {
- bitmap = bitmapOrig;
- }
- else
- {
- wxRect rect;
- wxSize size = GetRadioBitmapSize();
- rect.width = size.x;
- rect.height = size.y;
- bitmap.Create(rect.width, rect.height);
- wxMemoryDC dc;
- dc.SelectObject(bitmap);
- dc.SetBackground(*wxLIGHT_GREY_BRUSH);
- dc.Clear();
- DrawRadioBitmap(dc, rect, flags);
-
- // must unselect the bitmap before setting a mask for it because of the
- // MSW limitations
- dc.SelectObject(wxNullBitmap);
- bitmap.SetMask(new wxMask(bitmap, *wxLIGHT_GREY));
- }
-
- DoDrawCheckOrRadioBitmap(dc, label, bitmap, rectTotal,
- flags, align, indexAccel);
-}
-
#if wxUSE_TOOLBAR
void wxGTKRenderer::DrawToolBarButton(wxDC& dc,
const wxString& label,
#endif // wxUSE_TEXTCTRL
-void wxGTKRenderer::DrawTextLine(wxDC& dc,
- const wxString& text,
- const wxRect& rect,
- int selStart,
- int selEnd,
- int flags)
-{
- // TODO: GTK+ draws selection even for unfocused controls, just with
- // different colours
- StandardDrawTextLine(dc, text, rect, selStart, selEnd, flags);
-}
-
void wxGTKRenderer::DrawLineWrapMark(wxDC& dc, const wxRect& rect)
{
wxBitmap bmpLineWrap = GetLineWrapBitmap();
wxColour col = flags & wxCONTROL_SELECTED
? wxSCHEME_COLOUR(m_scheme, SHADOW_IN)
: wxSCHEME_COLOUR(m_scheme, SCROLLBAR);
- DoDrawBackground(dc, col, rect);
+ DrawSolidRect(dc, col, rect);
if ( flags & wxCONTROL_FOCUSED )
{
if ( flags & wxCONTROL_FOCUSED )
{
DrawRect(dc, &rect, m_penBlack);
- DrawAntiShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
}
else // not focused, normal
{
DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
- DrawAntiShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
}
+ DrawAntiShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
+
// and the background
- DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rect);
+ DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rect);
if ( rectShaft )
*rectShaft = rect;
int flags = comboButtonFlags[n];
dc.SelectObject(m_bitmapsCombo[n]);
- DoDrawBackground(dc, GetBackgroundColour(flags), rect);
+ DrawSolidRect(dc, GetBackgroundColour(flags), rect);
DrawArrow(dc, wxDOWN, rect, flags);
}
}
*bmpDisabled = m_bitmapsCombo[ComboState_Disabled];
}
-// ----------------------------------------------------------------------------
-// background
-// ----------------------------------------------------------------------------
-
-void wxGTKRenderer::DoDrawBackground(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- wxWindow * WXUNUSED(window))
-{
- wxBrush brush(col, wxSOLID);
- dc.SetBrush(brush);
- dc.SetPen(*wxTRANSPARENT_PEN);
- dc.DrawRectangle(rect);
-}
-
-void wxGTKRenderer::DrawBackground(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- int flags,
- wxWindow *window )
-{
- wxColour colBg = col.Ok() ? col : GetBackgroundColour(flags);
- DoDrawBackground(dc, colBg, rect, window );
-}
-
// ----------------------------------------------------------------------------
// scrollbar
// ----------------------------------------------------------------------------
rect2.Inflate(-1);
rectInner.Inflate(-2);
- DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), *rect);
+ DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), *rect);
// find the side not to draw and also adjust the rectangles to compensate
// for it
// draw the arrow interior
dc.SetPen(*wxTRANSPARENT_PEN);
- dc.SetBrush(wxBrush(colInside, wxSOLID));
+ dc.SetBrush(colInside);
switch ( dir )
{
{
wxRect rectBar = rect;
DrawThumbBorder(dc, &rectBar, orient);
- DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rectBar);
+ DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rectBar);
}
void wxGTKRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
{
- DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
+ DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
#if wxUSE_SCROLLBAR
elem = wxScrollBar::Element_Bar_2;
}
- return StandardGetScrollbarRect(scrollbar, elem,
- thumbPos,
- GetScrollbarArrowSize(scrollbar));
-}
-
-wxCoord wxGTKRenderer::GetScrollbarSize(const wxScrollBar *scrollbar)
-{
- return StandardScrollBarSize(scrollbar, GetScrollbarArrowSize(scrollbar));
+ return wxStdRenderer::GetScrollbarRect(scrollbar, elem, thumbPos);
}
-wxHitTest wxGTKRenderer::HitTestScrollbar(const wxScrollBar *scrollbar,
- const wxPoint& pt) const
-{
- return StandardHitTestScrollbar(scrollbar, pt,
- GetScrollbarArrowSize(scrollbar));
-}
-
-wxCoord wxGTKRenderer::ScrollbarToPixel(const wxScrollBar *scrollbar,
- int thumbPos)
-{
- return StandardScrollbarToPixel(scrollbar, thumbPos,
- GetScrollbarArrowSize(scrollbar));
-}
-
-int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar,
- wxCoord coord)
-{
- return StandardPixelToScrollbar(scrollbar, coord,
- GetScrollbarArrowSize(scrollbar));
-}
#endif // wxUSE_SCROLLBAR
// ----------------------------------------------------------------------------
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: src/univ/themes/mono.cpp
+// Purpose: wxUniversal theme for monochrome displays
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 2006-08-27
+// RCS-ID: $Id$
+// Copyright: (c) 2006 REA Elektronik GmbH
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ===========================================================================
+// declarations
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+// headers
+// ---------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif // WX_PRECOMP
+
+#include "wx/univ/renderer.h"
+#include "wx/univ/inphand.h"
+#include "wx/univ/colschem.h"
+#include "wx/univ/theme.h"
+
+class wxMonoColourScheme;
+
+#define wxMONO_BG_COL (*wxWHITE)
+#define wxMONO_FG_COL (*wxBLACK)
+
+// ----------------------------------------------------------------------------
+// wxMonoRenderer: draw the GUI elements in simplest possible way
+// ----------------------------------------------------------------------------
+
+// Warning: many of the methods here are not implemented, the code won't work
+// if any but a few wxUSE_XXXs are on
+class wxMonoRenderer : public wxStdRenderer
+{
+public:
+ wxMonoRenderer(const wxColourScheme *scheme);
+
+ virtual void DrawBackground(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int flags,
+ wxWindow *window = NULL);
+
+ virtual void DrawLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags = 0,
+ int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+ int indexAccel = -1,
+ wxRect *rectBounds = NULL);
+
+ virtual void DrawButtonLabel(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& image,
+ const wxRect& rect,
+ int flags = 0,
+ int alignment = wxALIGN_LEFT | wxALIGN_TOP,
+ int indexAccel = -1,
+ wxRect *rectBounds = NULL);
+
+ virtual void DrawBorder(wxDC& dc,
+ wxBorder border,
+ const wxRect& rect,
+ int flags = 0,
+ wxRect *rectIn = NULL);
+
+ virtual void DrawTextBorder(wxDC& dc,
+ wxBorder border,
+ const wxRect& rect,
+ int flags = 0,
+ wxRect *rectIn = NULL);
+
+ virtual void DrawButtonBorder(wxDC& dc,
+ const wxRect& rect,
+ int flags = 0,
+ wxRect *rectIn = NULL);
+
+ virtual void DrawHorizontalLine(wxDC& dc,
+ wxCoord y, wxCoord x1, wxCoord x2);
+
+ virtual void DrawVerticalLine(wxDC& dc,
+ wxCoord x, wxCoord y1, wxCoord y2);
+
+ virtual void DrawFrame(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags = 0,
+ int alignment = wxALIGN_LEFT,
+ int indexAccel = -1);
+
+ virtual void DrawArrow(wxDC& dc,
+ wxDirection dir,
+ const wxRect& rect,
+ int flags = 0);
+
+ virtual void DrawScrollbarArrow(wxDC& dc,
+ wxDirection dir,
+ const wxRect& rect,
+ int flags = 0);
+
+ virtual void DrawScrollbarThumb(wxDC& dc,
+ wxOrientation orient,
+ const wxRect& rect,
+ int flags = 0);
+
+ virtual void DrawScrollbarShaft(wxDC& dc,
+ wxOrientation orient,
+ const wxRect& rect,
+ int flags = 0);
+
+ virtual void DrawScrollCorner(wxDC& dc,
+ const wxRect& rect);
+
+ virtual void DrawItem(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags = 0);
+
+ virtual void DrawCheckItem(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags = 0);
+
+ virtual void DrawCheckButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags = 0,
+ wxAlignment align = wxALIGN_LEFT,
+ int indexAccel = -1);
+
+ virtual void DrawRadioButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags = 0,
+ wxAlignment align = wxALIGN_LEFT,
+ int indexAccel = -1);
+
+#if wxUSE_TOOLBAR
+ virtual void DrawToolBarButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags = 0,
+ long style = 0,
+ int tbarStyle = 0);
+#endif // wxUSE_TOOLBAR
+
+#if wxUSE_TEXTCTRL
+ virtual void DrawTextLine(wxDC& dc,
+ const wxString& text,
+ const wxRect& rect,
+ int selStart = -1,
+ int selEnd = -1,
+ int flags = 0);
+
+ virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect);
+#endif // wxUSE_TEXTCTRL
+
+#if wxUSE_NOTEBOOK
+ virtual void DrawTab(wxDC& dc,
+ const wxRect& rect,
+ wxDirection dir,
+ const wxString& label,
+ const wxBitmap& bitmap = wxNullBitmap,
+ int flags = 0,
+ int indexAccel = -1);
+#endif // wxUSE_NOTEBOOK
+
+#if wxUSE_SLIDER
+
+ virtual void DrawSliderShaft(wxDC& dc,
+ const wxRect& rect,
+ int lenThumb,
+ wxOrientation orient,
+ int flags = 0,
+ long style = 0,
+ wxRect *rectShaft = NULL);
+
+ virtual void DrawSliderThumb(wxDC& dc,
+ const wxRect& rect,
+ wxOrientation orient,
+ int flags = 0,
+ long style = 0);
+
+ virtual void DrawSliderTicks(wxDC& dc,
+ const wxRect& rect,
+ int lenThumb,
+ wxOrientation orient,
+ int start,
+ int end,
+ int step = 1,
+ int flags = 0,
+ long style = 0);
+#endif // wxUSE_SLIDER
+
+#if wxUSE_MENUS
+ virtual void DrawMenuBarItem(wxDC& dc,
+ const wxRect& rect,
+ const wxString& label,
+ int flags = 0,
+ int indexAccel = -1);
+
+ virtual void DrawMenuItem(wxDC& dc,
+ wxCoord y,
+ const wxMenuGeometryInfo& geometryInfo,
+ const wxString& label,
+ const wxString& accel,
+ const wxBitmap& bitmap = wxNullBitmap,
+ int flags = 0,
+ int indexAccel = -1);
+
+ virtual void DrawMenuSeparator(wxDC& dc,
+ wxCoord y,
+ const wxMenuGeometryInfo& geomInfo);
+#endif // wxUSE_MENUS
+
+#if wxUSE_STATUSBAR
+ virtual void DrawStatusField(wxDC& dc,
+ const wxRect& rect,
+ const wxString& label,
+ int flags = 0, int style = 0);
+#endif // wxUSE_STATUSBAR
+
+ virtual void DrawFrameTitleBar(wxDC& dc,
+ const wxRect& rect,
+ const wxString& title,
+ const wxIcon& icon,
+ int flags,
+ int specialButton = 0,
+ int specialButtonFlags = 0);
+
+ virtual void DrawFrameBorder(wxDC& dc,
+ const wxRect& rect,
+ int flags);
+
+ virtual void DrawFrameBackground(wxDC& dc,
+ const wxRect& rect,
+ int flags);
+
+ virtual void DrawFrameTitle(wxDC& dc,
+ const wxRect& rect,
+ const wxString& title,
+ int flags);
+
+ virtual void DrawFrameIcon(wxDC& dc,
+ const wxRect& rect,
+ const wxIcon& icon,
+ int flags);
+
+ virtual void DrawFrameButton(wxDC& dc,
+ wxCoord x, wxCoord y,
+ int button,
+ int flags = 0);
+
+
+ virtual void GetComboBitmaps(wxBitmap *bmpNormal,
+ wxBitmap *bmpFocus,
+ wxBitmap *bmpPressed,
+ wxBitmap *bmpDisabled);
+
+
+ virtual wxRect GetBorderDimensions(wxBorder border) const;
+
+ virtual bool AreScrollbarsInsideBorder() const;
+
+ virtual void AdjustSize(wxSize *size, const wxWindow *window);
+
+#if wxUSE_SCROLLBAR
+
+ virtual wxSize GetScrollbarArrowSize() const;
+
+ virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
+ wxScrollBar::Element elem,
+ int thumbPos = -1) const;
+
+ virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
+
+ virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
+ const wxPoint& pt) const;
+
+ virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
+ int thumbPos = -1);
+ virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
+ wxCoord coord);
+
+#endif // wxUSE_SCROLLBAR
+
+ virtual wxCoord GetListboxItemHeight(wxCoord fontHeight);
+
+ virtual wxSize GetCheckBitmapSize() const;
+ virtual wxSize GetRadioBitmapSize() const;
+ virtual wxCoord GetCheckItemMargin() const;
+
+ virtual wxSize GetToolBarButtonSize(wxCoord *separator) const;
+
+ virtual wxSize GetToolBarMargin() const;
+
+#if wxUSE_TEXTCTRL
+ virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
+ const wxRect& rectText) const;
+
+ virtual wxRect GetTextClientArea(const wxTextCtrl *text,
+ const wxRect& rectTotal,
+ wxCoord *extraSpaceBeyond) const;
+#endif // wxUSE_TEXTCTRL
+
+#if wxUSE_NOTEBOOK
+ virtual wxSize GetTabIndent() const;
+
+ virtual wxSize GetTabPadding() const;
+#endif // wxUSE_NOTEBOOK
+
+#if wxUSE_SLIDER
+ virtual wxCoord GetSliderDim() const;
+
+ virtual wxCoord GetSliderTickLen() const;
+
+ virtual wxRect GetSliderShaftRect(const wxRect& rect,
+ int lenThumb,
+ wxOrientation orient,
+ long style = 0) const;
+
+ virtual wxSize GetSliderThumbSize(const wxRect& rect,
+ int lenThumb,
+ wxOrientation orient) const;
+#endif // wxUSE_SLIDER
+
+ virtual wxSize GetProgressBarStep() const;
+
+#if wxUSE_MENUS
+ virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const;
+
+ virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
+ const wxMenu& menu) const;
+#endif // wxUSE_MENUS
+
+#if wxUSE_STATUSBAR
+ virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const;
+#endif // wxUSE_STATUSBAR
+
+ virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const;
+
+ virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const;
+
+ virtual wxSize GetFrameMinSize(int flags) const;
+
+ virtual wxSize GetFrameIconSize() const;
+
+ virtual int HitTestFrame(const wxRect& rect,
+ const wxPoint& pt,
+ int flags = 0) const;
+
+protected:
+ // draw the background with any colour, not only the default one(s)
+ void DoDrawBackground(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ wxWindow *window = NULL);
+
+ // DrawBorder() helpers: all of them shift and clip the DC after drawing
+ // the border
+
+ // just draw a rectangle with the given pen
+ void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
+
+ // 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);
+
+#if wxUSE_SCROLLBAR
+ // returns the size of the arrow for the scrollbar (depends on
+ // orientation)
+ wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar) const
+ {
+ wxSize size;
+ if ( scrollbar->IsVertical() )
+ {
+ size = m_sizeScrollbarArrow;
+ }
+ else
+ {
+ size.x = m_sizeScrollbarArrow.y;
+ size.y = m_sizeScrollbarArrow.x;
+ }
+
+ return size;
+ }
+#endif // wxUSE_SCROLLBAR
+
+ // DrawCheckBitmap and DrawRadioBitmap helpers
+
+ // draw the check bitmaps once and cache them for later use
+ wxBitmap GetCheckBitmap(int flags);
+
+ // draw a /\ or \/ line from (x1, y1) to (x2, y1) passing by the point
+ // ((x1 + x2)/2, y2)
+ void DrawUpZag(wxDC& dc,
+ wxCoord x1, wxCoord x2,
+ wxCoord y1, wxCoord y2);
+ void DrawDownZag(wxDC& dc,
+ wxCoord x1, wxCoord x2,
+ wxCoord y1, wxCoord y2);
+
+ // draw the radio button bitmap for the given state
+ void DrawRadioBitmap(wxDC& dc, const wxRect& rect, int flags);
+
+ // draw check/radio - the bitmap must be a valid one by now
+ void DoDrawCheckOrRadioBitmap(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rectTotal,
+ int flags,
+ wxAlignment align,
+ int indexAccel);
+
+ // common part of DrawMenuItem() and DrawMenuBarItem()
+ void DoDrawMenuItem(wxDC& dc,
+ const wxRect& rect,
+ const wxString& label,
+ int flags,
+ int indexAccel,
+ const wxString& accel = wxEmptyString,
+ const wxBitmap& bitmap = wxNullBitmap,
+ const wxMonoMenuGeometryInfo *geometryInfo = NULL);
+
+#if wxUSE_COMBOBOX
+ // initialize the combo bitmaps
+ void InitComboBitmaps();
+#endif // wxUSE_COMBOBOX
+
+private:
+ // data
+ wxSize m_sizeScrollbarArrow;
+
+ // the checkbox bitmaps: first row is for the normal, second for the
+ // pressed state and the columns are for checked, unchecked and
+ // undeterminated respectively
+ wxBitmap m_bitmapsCheckbox[2][3];
+
+ // the combobox bitmaps
+ enum
+ {
+ ComboState_Normal,
+ ComboState_Focus,
+ ComboState_Pressed,
+ ComboState_Disabled,
+ ComboState_Max
+ };
+
+ wxBitmap m_bitmapsCombo[ComboState_Max];
+};
+
+// ----------------------------------------------------------------------------
+// wxMonoInputHandler
+// ----------------------------------------------------------------------------
+
+class wxMonoInputHandler : public wxInputHandler
+{
+public:
+ wxMonoInputHandler(wxMonoRenderer *renderer);
+
+ virtual bool HandleKey(wxInputConsumer *control,
+ const wxKeyEvent& event,
+ bool pressed);
+ virtual bool HandleMouse(wxInputConsumer *control,
+ const wxMouseEvent& event);
+ virtual bool HandleMouseMove(wxInputConsumer *control, const wxMouseEvent& event);
+
+protected:
+ wxMonoRenderer *m_renderer;
+};
+
+// ----------------------------------------------------------------------------
+// wxMonoColourScheme: uses just white and black
+// ----------------------------------------------------------------------------
+
+class wxMonoColourScheme : public wxColourScheme
+{
+public:
+ // we use only 2 colours, white and black, but we avoid referring to them
+ // like this, instead use the functions below
+ wxColour GetFg() const { return wxMONO_FG_COL; }
+ wxColour GetBg() const { return wxMONO_BG_COL; }
+
+ // implement base class pure virtuals
+ virtual wxColour Get(StdColour col) const;
+ virtual wxColour GetBackground(wxWindow *win) const;
+};
+
+// ----------------------------------------------------------------------------
+// wxMonoArtProvider
+// ----------------------------------------------------------------------------
+
+class wxMonoArtProvider : public wxArtProvider
+{
+protected:
+ virtual wxBitmap CreateBitmap(const wxArtID& id,
+ const wxArtClient& client,
+ const wxSize& size);
+};
+
+// ----------------------------------------------------------------------------
+// wxMonoTheme
+// ----------------------------------------------------------------------------
+
+WX_DEFINE_ARRAY_PTR(wxInputHandler *, wxArrayHandlers);
+
+class wxMonoTheme : public wxTheme
+{
+public:
+ wxMonoTheme();
+ virtual ~wxMonoTheme();
+
+ virtual wxRenderer *GetRenderer();
+ virtual wxArtProvider *GetArtProvider();
+ virtual wxInputHandler *GetInputHandler(const wxString& control);
+ virtual wxColourScheme *GetColourScheme();
+
+private:
+ wxMonoRenderer *m_renderer;
+ wxMonoArtProvider *m_artProvider;
+ wxMonoColourScheme *m_scheme;
+
+ WX_DECLARE_THEME(gtk)
+};
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+WX_IMPLEMENT_THEME(wxMonoTheme, mono, wxTRANSLATE("Simple monochrome theme"));
+
+// ----------------------------------------------------------------------------
+// wxMonoTheme
+// ----------------------------------------------------------------------------
+
+wxMonoTheme::wxMonoTheme()
+{
+ m_scheme = NULL;
+ m_renderer = NULL;
+ m_artProvider = NULL;
+}
+
+wxMonoTheme::~wxMonoTheme()
+{
+ delete m_renderer;
+ delete m_scheme;
+ wxArtProvider::RemoveProvider(m_artProvider);
+}
+
+wxRenderer *wxMonoTheme::GetRenderer()
+{
+ if ( !m_renderer )
+ {
+ m_renderer = new wxMonoRenderer(GetColourScheme());
+ }
+
+ return m_renderer;
+}
+
+wxArtProvider *wxMonoTheme::GetArtProvider()
+{
+ if ( !m_artProvider )
+ {
+ m_artProvider = new wxMonoArtProvider;
+ }
+
+ return m_artProvider;
+}
+
+wxColourScheme *wxMonoTheme::GetColourScheme()
+{
+ if ( !m_scheme )
+ {
+ m_scheme = new wxMonoColourScheme;
+ }
+
+ return m_scheme;
+}
+
+wxInputHandler *wxMonoTheme::GetInputHandler(const wxString& WXUNUSED(control),
+ wxInputConsumer *consumer)
+{
+ // no special input handlers so far
+ return consumer->DoGetStdInputHandler(NULL);
+}
+
+// ============================================================================
+// wxMonoColourScheme
+// ============================================================================
+
+wxColour wxMonoColourScheme::GetBackground(wxWindow *win) const
+{
+ wxColour col;
+ if ( win->UseBgCol() )
+ {
+ // use the user specified colour
+ col = win->GetBackgroundColour();
+ }
+
+ // doesn't depend on the state
+ if ( !col.Ok() )
+ {
+ col = GetBg();
+ }
+}
+
+wxColour wxMonoColourScheme::Get(wxMonoColourScheme::StdColour col) const
+{
+ switch ( col )
+ {
+ case WINDOW:
+ case CONTROL:
+ case CONTROL_PRESSED:
+ case CONTROL_CURRENT:
+ case SCROLLBAR:
+ case SCROLLBAR_PRESSED:
+ case GAUGE:
+ case HIGHLIGHT:
+ case TITLEBAR:
+ case TITLEBAR_ACTIVE:
+ case DESKTOP:
+ return GetBg();
+
+ case MAX:
+ default:
+ wxFAIL_MSG(_T("invalid standard colour"));
+ // fall through
+
+ case SHADOW_DARK:
+ case SHADOW_HIGHLIGHT:
+ case SHADOW_IN:
+ case SHADOW_OUT:
+ case CONTROL_TEXT:
+ case CONTROL_TEXT_DISABLED:
+ case CONTROL_TEXT_DISABLED_SHADOW:
+ case HIGHLIGHT_TEXT:
+ case TITLEBAR_TEXT:
+ case TITLEBAR_ACTIVE_TEXT:
+ return GetFg();
+
+ }
+}
+
+// ============================================================================
+// wxMonoRenderer
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// construction
+// ----------------------------------------------------------------------------
+
+wxMonoRenderer::wxMonoRenderer(const wxColourScheme *scheme)
+ : wxStdRenderer(scheme)
+{
+ m_penFg = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_OUT));
+}
+
+// ----------------------------------------------------------------------------
+// border stuff
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// special borders
+// ----------------------------------------------------------------------------
+
+void wxMonoRenderer::DrawTextBorder(wxDC& dc,
+ wxBorder border,
+ const wxRect& rectOrig,
+ int flags,
+ wxRect *rectIn)
+{
+ DrawBorder(dc, border, rectOrig, flags, rectIn);
+}
+
+void wxMonoRenderer::DrawButtonBorder(wxDC& dc,
+ const wxRect& rectTotal,
+ int flags,
+ wxRect *rectIn)
+{
+ DrawBorder(dc, wxBORDER_SIMPLE, rectOrig, flags, rectIn);
+}
+
+// ----------------------------------------------------------------------------
+// lines and frames
+// ----------------------------------------------------------------------------
+
+void
+wxMonoRenderer::DrawHorizontalLine(wxDC& dc, wxCoord y, wxCoord x1, wxCoord x2)
+{
+ dc.SetPen(m_penFg);
+ dc.DrawLine(x1, y, x2 + 1, y);
+}
+
+void
+wxMonoRenderer::DrawVerticalLine(wxDC& dc, wxCoord x, wxCoord y1, wxCoord y2)
+{
+ dc.SetPen(m_penFg);
+ dc.DrawLine(x, y1, x, y2 + 1);
+}
+
+void wxMonoRenderer::DrawFrame(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags,
+ int alignment,
+ int indexAccel)
+{
+ wxCoord height = 0; // of the label
+ wxRect rectFrame = rect;
+ if ( !label.empty() )
+ {
+ // the text should touch the top border of the rect, so the frame
+ // itself should be lower
+ dc.GetTextExtent(label, NULL, &height);
+ rectFrame.y += height / 2;
+ rectFrame.height -= height / 2;
+
+ // TODO: the +4 should be customizable
+
+ wxRect rectText;
+ rectText.x = rectFrame.x + 4;
+ rectText.y = rect.y;
+ rectText.width = rectFrame.width - 8;
+ rectText.height = height;
+
+ wxRect rectLabel;
+ DrawLabel(dc, label, rectText, flags, alignment, indexAccel, &rectLabel);
+ rectLabel.x -= 1;
+ rectLabel.width += 2;
+
+ StandardDrawFrame(dc, rectFrame, rectLabel);
+ }
+ else // no label
+ {
+ // just draw the complete frame
+ DrawShadedRect(dc, &rectFrame, m_penDarkGrey, m_penHighlight);
+ DrawShadedRect(dc, &rectFrame, m_penHighlight, m_penDarkGrey);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// label
+// ----------------------------------------------------------------------------
+
+void wxMonoRenderer::DrawLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags,
+ int alignment,
+ int indexAccel,
+ wxRect *rectBounds)
+{
+ DrawButtonLabel(dc, label, wxNullBitmap, rect, flags,
+ alignment, indexAccel, rectBounds);
+}
+
+void wxMonoRenderer::DrawButtonLabel(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& image,
+ const wxRect& rect,
+ int flags,
+ int alignment,
+ int indexAccel,
+ wxRect *rectBounds)
+{
+ dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, CONTROL_TEXT));
+ dc.DrawLabel(label, image, rect, alignment, indexAccel, rectBounds);
+
+ if ( flags & wxCONTROL_DISABLED )
+ {
+ // this is ugly but I don't know how to show disabled button visually
+ // in monochrome theme otherwise
+ dc.SetPen(m_penFg);
+ dc.DrawLine(rect.GetTopLeft(), rect.GetBottomRight());
+ dc.DrawLine(rect.GetTopRight(), rect.GetBottomLeft());
+ }
+}
+
+void wxMonoRenderer::DrawItem(wxDC& dc,
+ const wxString& label,
+ const wxRect& rect,
+ int flags)
+{
+ wxColour colFg;
+ if ( flags & wxCONTROL_SELECTED )
+ {
+ dc.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT), wxSOLID));
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.DrawRectangle(rect);
+
+ colFg = dc.GetTextForeground();
+ dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
+ }
+
+ if ( flags & wxCONTROL_FOCUSED )
+ {
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+ wxRect rectFocus = rect;
+ DrawRect(dc, &rectFocus, m_penBlack);
+ }
+
+ wxRect rectText = rect;
+ rectText.x += 2;
+ rectText.y++;
+ dc.DrawLabel(label, wxNullBitmap, rectText);
+
+ if ( flags & wxCONTROL_SELECTED )
+ {
+ dc.SetBackgroundMode(wxTRANSPARENT);
+ }
+
+ // restore the text colour
+ if ( colFg.Ok() )
+ {
+ dc.SetTextForeground(colFg);
+ }
+}
+
+void wxMonoRenderer::DrawCheckItem(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rect,
+ int flags)
+{
+ wxRect rectBitmap = rect;
+ rectBitmap.x -= 1;
+ rectBitmap.width = GetCheckBitmapSize().x;
+
+ // never draw the focus rect around the check indicators here
+ DrawCheckButton(dc, wxEmptyString, bitmap, rectBitmap, flags & ~wxCONTROL_FOCUSED);
+
+ wxRect rectLabel = rect;
+ wxCoord shift = rectBitmap.width + 2*GetCheckItemMargin();
+ rectLabel.x += shift;
+ rectLabel.width -= shift;
+ DrawItem(dc, label, rectLabel, flags);
+}
+
+// ----------------------------------------------------------------------------
+// check/radion buttons
+// ----------------------------------------------------------------------------
+
+void wxMonoRenderer::DrawUndeterminedBitmap(wxDC& dc,
+ const wxRect& rectTotal,
+ bool isPressed)
+{
+ // FIXME: For sure it is not Mono look but it is better than nothing.
+ // Show me correct look and I will immediatelly make it better (ABX)
+ wxRect rect = rectTotal;
+
+ wxColour col1, col2;
+
+ if ( isPressed )
+ {
+ col1 = wxSCHEME_COLOUR(m_scheme, SHADOW_DARK);
+ col2 = wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED);
+ }
+ else
+ {
+ col1 = wxSCHEME_COLOUR(m_scheme, SHADOW_DARK);
+ col2 = wxSCHEME_COLOUR(m_scheme, SHADOW_IN);
+ }
+
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.SetBrush(wxBrush(col1, wxSOLID));
+ dc.DrawRectangle(rect);
+ rect.Deflate(1);
+ dc.SetBrush(wxBrush(col2, wxSOLID));
+ dc.DrawRectangle(rect);
+}
+
+void wxMonoRenderer::DrawUncheckBitmap(wxDC& dc,
+ const wxRect& rectTotal,
+ bool isPressed)
+{
+ wxRect rect = rectTotal;
+ DrawAntiRaisedBorder(dc, &rect);
+
+ wxColour col = wxSCHEME_COLOUR(m_scheme, SHADOW_IN);
+ dc.SetPen(wxPen(col, 0, wxSOLID));
+ dc.DrawPoint(rect.GetRight() - 1, rect.GetBottom() - 1);
+
+ if ( isPressed )
+ col = wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED);
+ //else: it is SHADOW_IN, leave as is
+
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.SetBrush(wxBrush(col, wxSOLID));
+ dc.DrawRectangle(rect);
+}
+
+void wxMonoRenderer::DrawCheckBitmap(wxDC& dc, const wxRect& rectTotal)
+{
+ wxRect rect = rectTotal;
+ DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
+ DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
+
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.SetBrush(wxBrush(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), wxSOLID));
+ dc.DrawRectangle(rect);
+}
+
+void wxMonoRenderer::DrawRadioBitmap(wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ wxCoord x = rect.x,
+ y = rect.y,
+ xRight = rect.GetRight(),
+ yBottom = rect.GetBottom();
+
+ wxCoord yMid = (y + yBottom) / 2;
+
+ // this looks ugly when the background colour of the control is not the
+ // same ours - radiobox is not transparent as it should be
+#if 0
+ // first fill the middle: as FloodFill() is not implemented on all
+ // platforms, this is the only thing to do
+ wxColour colBg = flags & wxCONTROL_CURRENT
+ ? wxSCHEME_COLOUR(m_scheme, CONTROL_CURRENT)
+ : wxSCHEME_COLOUR(m_scheme, SHADOW_IN);
+ dc.SetBrush(wxBrush(colBg, wxSOLID));
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.DrawRectangle(rect);
+#endif // 0
+
+ // then draw the upper half
+ dc.SetPen(flags & wxCONTROL_CHECKED ? m_penDarkGrey : m_penHighlight);
+ DrawUpZag(dc, x, xRight, yMid, y);
+ DrawUpZag(dc, x + 1, xRight - 1, yMid, y + 1);
+
+ bool drawIt = true;
+ if ( flags & wxCONTROL_CHECKED )
+ dc.SetPen(m_penBlack);
+ else if ( flags & wxCONTROL_PRESSED )
+ dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), 0, wxSOLID));
+ else // unchecked and unpressed
+ drawIt = false;
+
+ if ( drawIt )
+ DrawUpZag(dc, x + 2, xRight - 2, yMid, y + 2);
+
+ // and then the lower one
+ dc.SetPen(flags & wxCONTROL_CHECKED ? m_penHighlight : m_penBlack);
+ DrawDownZag(dc, x, xRight, yMid, yBottom);
+ if ( !(flags & wxCONTROL_CHECKED) )
+ dc.SetPen(m_penDarkGrey);
+ DrawDownZag(dc, x + 1, xRight - 1, yMid, yBottom - 1);
+
+ if ( !(flags & wxCONTROL_CHECKED) )
+ drawIt = true; // with the same pen
+ else if ( flags & wxCONTROL_PRESSED )
+ {
+ dc.SetPen(wxPen(wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), 0, wxSOLID));
+ drawIt = true;
+ }
+ else // checked and unpressed
+ drawIt = false;
+
+ if ( drawIt )
+ DrawDownZag(dc, x + 2, xRight - 2, yMid, yBottom - 2);
+}
+
+void wxMonoRenderer::DrawUpZag(wxDC& dc,
+ wxCoord x1,
+ wxCoord x2,
+ wxCoord y1,
+ wxCoord y2)
+{
+ wxCoord xMid = (x1 + x2) / 2;
+ dc.DrawLine(x1, y1, xMid, y2);
+ dc.DrawLine(xMid, y2, x2 + 1, y1 + 1);
+}
+
+void wxMonoRenderer::DrawDownZag(wxDC& dc,
+ wxCoord x1,
+ wxCoord x2,
+ wxCoord y1,
+ wxCoord y2)
+{
+ wxCoord xMid = (x1 + x2) / 2;
+ dc.DrawLine(x1 + 1, y1 + 1, xMid, y2);
+ dc.DrawLine(xMid, y2, x2, y1);
+}
+
+wxBitmap wxMonoRenderer::GetCheckBitmap(int flags)
+{
+ if ( !m_bitmapsCheckbox[0][0].Ok() )
+ {
+ // init the bitmaps once only
+ wxRect rect;
+ wxSize size = GetCheckBitmapSize();
+ rect.width = size.x;
+ rect.height = size.y;
+ for ( int i = 0; i < 2; i++ )
+ {
+ for ( int j = 0; j < 3; j++ )
+ m_bitmapsCheckbox[i][j].Create(rect.width, rect.height);
+ }
+
+ wxMemoryDC dc;
+
+ // normal checked
+ dc.SelectObject(m_bitmapsCheckbox[0][0]);
+ DrawCheckBitmap(dc, rect);
+
+ // normal unchecked
+ dc.SelectObject(m_bitmapsCheckbox[0][1]);
+ DrawUncheckBitmap(dc, rect, false);
+
+ // normal undeterminated
+ dc.SelectObject(m_bitmapsCheckbox[0][2]);
+ DrawUndeterminedBitmap(dc, rect, false);
+
+ // pressed checked
+ m_bitmapsCheckbox[1][0] = m_bitmapsCheckbox[0][0];
+
+ // pressed unchecked
+ dc.SelectObject(m_bitmapsCheckbox[1][1]);
+ DrawUncheckBitmap(dc, rect, true);
+
+ // pressed undeterminated
+ dc.SelectObject(m_bitmapsCheckbox[1][2]);
+ DrawUndeterminedBitmap(dc, rect, true);
+ }
+
+ int row = flags & wxCONTROL_PRESSED
+ ? 1
+ : 0;
+ int col = flags & wxCONTROL_CHECKED
+ ? 0
+ : ( flags & wxCONTROL_UNDETERMINED
+ ? 2
+ : 1 );
+
+ return m_bitmapsCheckbox[row][col];
+}
+
+void wxMonoRenderer::DrawCheckButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmapOrig,
+ const wxRect& rectTotal,
+ int flags,
+ wxAlignment align,
+ int indexAccel)
+{
+ wxBitmap bitmap;
+ if ( bitmapOrig.Ok() )
+ {
+ bitmap = bitmapOrig;
+ }
+ else
+ {
+ bitmap = GetCheckBitmap(flags);
+ }
+
+ DoDrawCheckOrRadioBitmap(dc, label, bitmap, rectTotal,
+ flags, align, indexAccel);
+}
+
+void wxMonoRenderer::DoDrawCheckOrRadioBitmap(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rectTotal,
+ int flags,
+ wxAlignment align,
+ int indexAccel)
+{
+ wxRect rect = rectTotal;
+
+ if ( flags & wxCONTROL_FOCUSED )
+ {
+ // draw the focus border around everything
+ DrawRect(dc, &rect, m_penBlack);
+ }
+ else
+ {
+ // the border does not offset the string under Mono
+ rect.Inflate(-1);
+ }
+
+ // calculate the position of the bitmap and of the label
+ wxCoord xBmp,
+ yBmp = rect.y + (rect.height - bitmap.GetHeight()) / 2;
+
+ wxRect rectLabel;
+ dc.GetMultiLineTextExtent(label, NULL, &rectLabel.height);
+ rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2;
+
+ if ( align == wxALIGN_RIGHT )
+ {
+ xBmp = rect.GetRight() - bitmap.GetWidth();
+ rectLabel.x = rect.x + 2;
+ rectLabel.SetRight(xBmp);
+ }
+ else // normal (checkbox to the left of the text) case
+ {
+ xBmp = rect.x + 2;
+ rectLabel.x = xBmp + bitmap.GetWidth() + 4;
+ rectLabel.SetRight(rect.GetRight());
+ }
+
+ dc.DrawBitmap(bitmap, xBmp, yBmp, true /* use mask */);
+
+ DrawLabel(dc, label, rectLabel, flags,
+ wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, indexAccel);
+}
+
+void wxMonoRenderer::DrawRadioButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmapOrig,
+ const wxRect& rectTotal,
+ int flags,
+ wxAlignment align,
+ int indexAccel)
+{
+ wxBitmap bitmap;
+ if ( bitmapOrig.Ok() )
+ {
+ bitmap = bitmapOrig;
+ }
+ else
+ {
+ wxRect rect;
+ wxSize size = GetRadioBitmapSize();
+ rect.width = size.x;
+ rect.height = size.y;
+ bitmap.Create(rect.width, rect.height);
+ wxMemoryDC dc;
+ dc.SelectObject(bitmap);
+ dc.SetBackground(*wxLIGHT_GREY_BRUSH);
+ dc.Clear();
+ DrawRadioBitmap(dc, rect, flags);
+
+ // must unselect the bitmap before setting a mask for it because of the
+ // MSW limitations
+ dc.SelectObject(wxNullBitmap);
+ bitmap.SetMask(new wxMask(bitmap, *wxLIGHT_GREY));
+ }
+
+ DoDrawCheckOrRadioBitmap(dc, label, bitmap, rectTotal,
+ flags, align, indexAccel);
+}
+
+#if wxUSE_TOOLBAR
+void wxMonoRenderer::DrawToolBarButton(wxDC& dc,
+ const wxString& label,
+ const wxBitmap& bitmap,
+ const wxRect& rectOrig,
+ int flags,
+ long WXUNUSED(style),
+ int tbarStyle)
+{
+ // we don't draw the separators at all
+ if ( !label.empty() || bitmap.Ok() )
+ {
+ wxRect rect = rectOrig;
+ rect.Deflate(BORDER_THICKNESS);
+
+ if ( flags & wxCONTROL_PRESSED )
+ {
+ DrawBorder(dc, wxBORDER_SUNKEN, rect, flags, &rect);
+
+ DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL_PRESSED), rect);
+ }
+ else if ( flags & wxCONTROL_CURRENT )
+ {
+ DrawBorder(dc, wxBORDER_RAISED, rect, flags, &rect);
+
+ DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL_CURRENT), rect);
+ }
+
+ if(tbarStyle & wxTB_TEXT)
+ {
+ if(tbarStyle & wxTB_HORIZONTAL)
+ {
+ dc.DrawLabel(label, bitmap, rect, wxALIGN_CENTRE);
+ }
+ else
+ {
+ dc.DrawLabel(label, bitmap, rect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
+ }
+ }
+ else
+ {
+ int xpoint = (rect.GetLeft() + rect.GetRight() + 1 - bitmap.GetWidth()) / 2;
+ int ypoint = (rect.GetTop() + rect.GetBottom() + 1 - bitmap.GetHeight()) / 2;
+ dc.DrawBitmap(bitmap, xpoint, ypoint);
+ }
+ }
+}
+#endif // wxUSE_TOOLBAR
+
+// ----------------------------------------------------------------------------
+// text control
+// ----------------------------------------------------------------------------
+
+#if wxUSE_TEXTCTRL
+
+wxRect wxMonoRenderer::GetTextTotalArea(const wxTextCtrl * WXUNUSED(text),
+ const wxRect& rect) const
+{
+ wxRect rectTotal = rect;
+ rectTotal.Inflate(2*BORDER_THICKNESS);
+ return rectTotal;
+}
+
+wxRect wxMonoRenderer::GetTextClientArea(const wxTextCtrl *text,
+ const wxRect& rect,
+ wxCoord *extraSpaceBeyond) const
+{
+ wxRect rectText = rect;
+ rectText.Deflate(2*BORDER_THICKNESS);
+
+ return rectText;
+}
+
+void wxMonoRenderer::DrawTextLine(wxDC& dc,
+ const wxString& text,
+ const wxRect& rect,
+ int selStart,
+ int selEnd,
+ int flags)
+{
+ StandardDrawTextLine(dc, text, rect, selStart, selEnd, flags);
+}
+
+void
+wxMonoRenderer::DrawLineWrapMark(wxDC& WXUNUSED(dc),
+ const wxRect& WXUNUSED(rect))
+{
+ // no line wrapping indicators
+}
+
+#endif // wxUSE_TEXTCTRL
+
+// ----------------------------------------------------------------------------
+// combobox
+// ----------------------------------------------------------------------------
+
+#if wxUSE_COMBOBOX
+
+void wxMonoRenderer::InitComboBitmaps()
+{
+ wxSize sizeArrow = m_sizeScrollbarArrow;
+ sizeArrow.x -= 2;
+ sizeArrow.y -= 2;
+
+ size_t n;
+
+ for ( n = ComboState_Normal; n < ComboState_Max; n++ )
+ {
+ m_bitmapsCombo[n].Create(sizeArrow.x, sizeArrow.y);
+ }
+
+ static const int comboButtonFlags[ComboState_Max] =
+ {
+ 0,
+ wxCONTROL_CURRENT,
+ wxCONTROL_PRESSED,
+ wxCONTROL_DISABLED,
+ };
+
+ wxRect rect(sizeArrow);
+
+ wxMemoryDC dc;
+ for ( n = ComboState_Normal; n < ComboState_Max; n++ )
+ {
+ int flags = comboButtonFlags[n];
+
+ dc.SelectObject(m_bitmapsCombo[n]);
+ DoDrawBackground(dc, GetBackgroundColour(flags), rect);
+ DrawArrow(dc, wxDOWN, rect, flags);
+ }
+}
+
+void wxMonoRenderer::GetComboBitmaps(wxBitmap *bmpNormal,
+ wxBitmap *bmpFocus,
+ wxBitmap *bmpPressed,
+ wxBitmap *bmpDisabled)
+{
+ if ( !m_bitmapsCombo[ComboState_Normal].Ok() )
+ {
+ InitComboBitmaps();
+ }
+
+ if ( bmpNormal )
+ *bmpNormal = m_bitmapsCombo[ComboState_Normal];
+ if ( bmpFocus )
+ *bmpFocus = m_bitmapsCombo[ComboState_Focus];
+ if ( bmpPressed )
+ *bmpPressed = m_bitmapsCombo[ComboState_Pressed];
+ if ( bmpDisabled )
+ *bmpDisabled = m_bitmapsCombo[ComboState_Disabled];
+}
+
+#endif // wxUSE_COMBOBOX
+
+// ----------------------------------------------------------------------------
+// background
+// ----------------------------------------------------------------------------
+
+void wxMonoRenderer::DoDrawBackground(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ wxWindow * WXUNUSED(window))
+{
+ wxBrush brush(col, wxSOLID);
+ dc.SetBrush(brush);
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.DrawRectangle(rect);
+}
+
+void wxMonoRenderer::DrawBackground(wxDC& dc,
+ const wxColour& col,
+ const wxRect& rect,
+ int WXUNUSED(flags),
+ wxWindow *window)
+{
+}
+
+// ----------------------------------------------------------------------------
+// scrollbar
+// ----------------------------------------------------------------------------
+
+void wxMonoRenderer::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);
+
+ DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), *rect);
+
+ // 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 += 1;
+ break;
+
+ case wxDOWN:
+ sideToOmit = wxUP;
+ rect2.y -= 1;
+ rect2.height += 1;
+ rectInner.y -= 2;
+ rectInner.height += 1;
+ break;
+
+ case wxLEFT:
+ sideToOmit = wxRIGHT;
+ rect2.width += 1;
+ rectInner.width += 1;
+ break;
+
+ case wxRIGHT:
+ sideToOmit = wxLEFT;
+ rect2.x -= 1;
+ rect2.width += 1;
+ rectInner.x -= 2;
+ rectInner.width += 1;
+ 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;
+}
+
+void wxMonoRenderer::DrawScrollbarArrow(wxDC& dc,
+ wxDirection dir,
+ const wxRect& rectArrow,
+ 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);
+
+ // then the arrow itself
+ DrawArrow(dc, dir, rect, flags);
+}
+
+// gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
+// these people are just crazy :-(
+void wxMonoRenderer::DrawArrow(wxDC& dc,
+ wxDirection dir,
+ const wxRect& rect,
+ int flags)
+{
+ enum
+ {
+ Point_First,
+ Point_Second,
+ Point_Third,
+ Point_Max
+ };
+
+ wxPoint ptArrow[Point_Max];
+
+ wxColour colInside = GetBackgroundColour(flags);
+ wxPen penShadow[4];
+ if ( flags & wxCONTROL_DISABLED )
+ {
+ penShadow[0] = m_penDarkGrey;
+ penShadow[1] = m_penDarkGrey;
+ penShadow[2] = wxNullPen;
+ penShadow[3] = wxNullPen;
+ }
+ else if ( flags & wxCONTROL_PRESSED )
+ {
+ penShadow[0] = m_penDarkGrey;
+ penShadow[1] = m_penHighlight;
+ penShadow[2] = wxNullPen;
+ penShadow[3] = m_penBlack;
+ }
+ else // normal arrow
+ {
+ penShadow[0] = m_penHighlight;
+ penShadow[1] = m_penBlack;
+ penShadow[2] = m_penDarkGrey;
+ penShadow[3] = wxNullPen;
+ }
+
+ wxCoord middle;
+ if ( dir == wxUP || dir == wxDOWN )
+ {
+ // horz middle
+ middle = (rect.GetRight() + rect.GetLeft() + 1) / 2;
+ }
+ else // horz arrow
+ {
+ middle = (rect.GetTop() + rect.GetBottom() + 1) / 2;
+ }
+
+ // draw the arrow interior
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.SetBrush(wxBrush(colInside, wxSOLID));
+
+ switch ( dir )
+ {
+ case wxUP:
+ ptArrow[Point_First].x = rect.GetLeft();
+ ptArrow[Point_First].y = rect.GetBottom();
+ ptArrow[Point_Second].x = middle;
+ ptArrow[Point_Second].y = rect.GetTop();
+ ptArrow[Point_Third].x = rect.GetRight();
+ ptArrow[Point_Third].y = rect.GetBottom();
+ break;
+
+ case wxDOWN:
+ ptArrow[Point_First] = rect.GetPosition();
+ ptArrow[Point_Second].x = middle;
+ ptArrow[Point_Second].y = rect.GetBottom();
+ ptArrow[Point_Third].x = rect.GetRight();
+ ptArrow[Point_Third].y = rect.GetTop();
+ break;
+
+ case wxLEFT:
+ ptArrow[Point_First].x = rect.GetRight();
+ ptArrow[Point_First].y = rect.GetTop();
+ ptArrow[Point_Second].x = rect.GetLeft();
+ ptArrow[Point_Second].y = middle;
+ ptArrow[Point_Third].x = rect.GetRight();
+ ptArrow[Point_Third].y = rect.GetBottom();
+ break;
+
+ case wxRIGHT:
+ ptArrow[Point_First] = rect.GetPosition();
+ ptArrow[Point_Second].x = rect.GetRight();
+ ptArrow[Point_Second].y = middle;
+ ptArrow[Point_Third].x = rect.GetLeft();
+ ptArrow[Point_Third].y = rect.GetBottom();
+ break;
+
+ default:
+ wxFAIL_MSG(_T("unknown arrow direction"));
+ }
+
+ dc.DrawPolygon(WXSIZEOF(ptArrow), ptArrow);
+
+ // draw the arrow border
+ dc.SetPen(penShadow[0]);
+ switch ( dir )
+ {
+ case wxUP:
+ dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_First]);
+ dc.DrawPoint(ptArrow[Point_First]);
+ if ( penShadow[3].Ok() )
+ {
+ dc.SetPen(penShadow[3]);
+ dc.DrawLine(ptArrow[Point_First].x + 1, ptArrow[Point_First].y,
+ ptArrow[Point_Second].x, ptArrow[Point_Second].y);
+ }
+ dc.SetPen(penShadow[1]);
+ dc.DrawLine(ptArrow[Point_Second].x + 1, ptArrow[Point_Second].y + 1,
+ ptArrow[Point_Third].x, ptArrow[Point_Third].y);
+ dc.DrawPoint(ptArrow[Point_Third]);
+ dc.DrawLine(ptArrow[Point_Third].x - 2, ptArrow[Point_Third].y,
+ ptArrow[Point_First].x + 1, ptArrow[Point_First].y);
+ if ( penShadow[2].Ok() )
+ {
+ dc.SetPen(penShadow[2]);
+ dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y,
+ ptArrow[Point_Second].x, ptArrow[Point_Second].y + 1);
+ dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y - 1,
+ ptArrow[Point_First].x + 2, ptArrow[Point_First].y - 1);
+ }
+ break;
+
+ case wxDOWN:
+ dc.DrawLine(ptArrow[Point_First], ptArrow[Point_Second]);
+ dc.DrawLine(ptArrow[Point_First].x + 2, ptArrow[Point_First].y,
+ ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y);
+ if ( penShadow[2].Ok() )
+ {
+ dc.SetPen(penShadow[2]);
+ dc.DrawLine(ptArrow[Point_Second].x, ptArrow[Point_Second].y - 1,
+ ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y - 1);
+ }
+ dc.SetPen(penShadow[1]);
+ dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_Third]);
+ dc.DrawPoint(ptArrow[Point_Third]);
+ break;
+
+ case wxLEFT:
+ dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_First]);
+ dc.DrawPoint(ptArrow[Point_First]);
+ if ( penShadow[2].Ok() )
+ {
+ dc.SetPen(penShadow[2]);
+ dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y,
+ ptArrow[Point_First].x - 1, ptArrow[Point_First].y + 2);
+ dc.DrawLine(ptArrow[Point_Third].x, ptArrow[Point_Third].y,
+ ptArrow[Point_Second].x + 2, ptArrow[Point_Second].y + 1);
+ }
+ dc.SetPen(penShadow[1]);
+ dc.DrawLine(ptArrow[Point_Third].x, ptArrow[Point_Third].y,
+ ptArrow[Point_First].x, ptArrow[Point_First].y + 1);
+ dc.DrawLine(ptArrow[Point_Second].x + 1, ptArrow[Point_Second].y + 1,
+ ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y);
+ break;
+
+ case wxRIGHT:
+ dc.DrawLine(ptArrow[Point_First], ptArrow[Point_Third]);
+ dc.DrawLine(ptArrow[Point_First].x + 2, ptArrow[Point_First].y + 1,
+ ptArrow[Point_Second].x, ptArrow[Point_Second].y);
+ dc.SetPen(penShadow[1]);
+ dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_Third]);
+ dc.DrawPoint(ptArrow[Point_Third]);
+ break;
+
+ default:
+ wxFAIL_MSG(_T("unknown arrow direction"));
+ return;
+ }
+}
+
+void wxMonoRenderer::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 wxMonoRenderer::DrawScrollbarThumb(wxDC& dc,
+ wxOrientation orient,
+ const wxRect& rect,
+ int flags)
+{
+ // the thumb is never pressed never has focus border under Mono and the
+ // scrollbar background never changes at all
+ int flagsThumb = flags & ~(wxCONTROL_PRESSED | wxCONTROL_FOCUSED);
+
+ // we don't want the border in the direction of the scrollbar movement
+ wxRect rectThumb = rect;
+ DrawThumbBorder(dc, &rectThumb, orient);
+
+ DrawButtonBorder(dc, rectThumb, flagsThumb, &rectThumb);
+ DrawBackground(dc, wxNullColour, rectThumb, flagsThumb);
+}
+
+void wxMonoRenderer::DrawScrollbarShaft(wxDC& dc,
+ wxOrientation orient,
+ const wxRect& rect,
+ int WXUNUSED(flags))
+{
+ wxRect rectBar = rect;
+ DrawThumbBorder(dc, &rectBar, orient);
+ DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rectBar);
+}
+
+void wxMonoRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
+{
+ DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
+}
+
+#if wxUSE_SCROLLBAR
+wxRect wxMonoRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
+ wxScrollBar::Element elem,
+ int thumbPos) const
+{
+ // as Mono 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));
+}
+
+wxCoord wxMonoRenderer::GetScrollbarSize(const wxScrollBar *scrollbar)
+{
+ return StandardScrollBarSize(scrollbar, GetScrollbarArrowSize(scrollbar));
+}
+
+wxHitTest wxMonoRenderer::HitTestScrollbar(const wxScrollBar *scrollbar,
+ const wxPoint& pt) const
+{
+ return StandardHitTestScrollbar(scrollbar, pt,
+ GetScrollbarArrowSize(scrollbar));
+}
+
+wxCoord wxMonoRenderer::ScrollbarToPixel(const wxScrollBar *scrollbar,
+ int thumbPos)
+{
+ return StandardScrollbarToPixel(scrollbar, thumbPos,
+ GetScrollbarArrowSize(scrollbar));
+}
+
+int wxMonoRenderer::PixelToScrollbar(const wxScrollBar *scrollbar,
+ wxCoord coord)
+{
+ return StandardPixelToScrollbar(scrollbar, coord,
+ GetScrollbarArrowSize(scrollbar));
+}
+#endif // wxUSE_SCROLLBAR
+
+// ----------------------------------------------------------------------------
+// size adjustments
+// ----------------------------------------------------------------------------
+
+void wxMonoRenderer::AdjustSize(wxSize *size, const wxWindow *window)
+{
+#if wxUSE_BMPBUTTON
+ if ( wxDynamicCast(window, wxBitmapButton) )
+ {
+ size->x += 4;
+ size->y += 4;
+ } else
+#endif // wxUSE_BMPBUTTON
+#if wxUSE_BUTTON || wxUSE_TOGGLEBTN
+ if ( 0
+# if wxUSE_BUTTON
+ || wxDynamicCast(window, wxButton)
+# endif // wxUSE_BUTTON
+# if wxUSE_TOGGLEBTN
+ || wxDynamicCast(window, wxToggleButton)
+# endif // wxUSE_TOGGLEBTN
+ )
+ {
+ if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) )
+ {
+ // TODO: this is ad hoc...
+ size->x += 3*window->GetCharWidth();
+ wxCoord minBtnHeight = 18;
+ if ( size->y < minBtnHeight )
+ size->y = minBtnHeight;
+
+ // button border width
+ size->y += 4;
+ }
+ } else
+#endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
+#if wxUSE_SCROLLBAR
+ 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
+#endif // wxUSE_SCROLLBAR
+ {
+ // take into account the border width
+ wxRect rectBorder = GetBorderDimensions(window->GetBorder());
+ size->x += rectBorder.x + rectBorder.width;
+ size->y += rectBorder.y + rectBorder.height;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// top level windows
+// ----------------------------------------------------------------------------
+
+void wxMonoRenderer::DrawFrameTitleBar(wxDC& WXUNUSED(dc),
+ const wxRect& WXUNUSED(rect),
+ const wxString& WXUNUSED(title),
+ const wxIcon& WXUNUSED(icon),
+ int WXUNUSED(flags),
+ int WXUNUSED(specialButton),
+ int WXUNUSED(specialButtonFlag))
+{
+}
+
+void wxMonoRenderer::DrawFrameBorder(wxDC& WXUNUSED(dc),
+ const wxRect& WXUNUSED(rect),
+ int WXUNUSED(flags))
+{
+}
+
+void wxMonoRenderer::DrawFrameBackground(wxDC& WXUNUSED(dc),
+ const wxRect& WXUNUSED(rect),
+ int WXUNUSED(flags))
+{
+}
+
+void wxMonoRenderer::DrawFrameTitle(wxDC& WXUNUSED(dc),
+ const wxRect& WXUNUSED(rect),
+ const wxString& WXUNUSED(title),
+ int WXUNUSED(flags))
+{
+}
+
+void wxMonoRenderer::DrawFrameIcon(wxDC& WXUNUSED(dc),
+ const wxRect& WXUNUSED(rect),
+ const wxIcon& WXUNUSED(icon),
+ int WXUNUSED(flags))
+{
+}
+
+void wxMonoRenderer::DrawFrameButton(wxDC& WXUNUSED(dc),
+ wxCoord WXUNUSED(x),
+ wxCoord WXUNUSED(y),
+ int WXUNUSED(button),
+ int WXUNUSED(flags))
+{
+}
+
+wxRect
+wxMonoRenderer::GetFrameClientArea(const wxRect& rect,
+ int WXUNUSED(flags)) const
+{
+ return rect;
+}
+
+wxSize
+wxMonoRenderer::GetFrameTotalSize(const wxSize& clientSize,
+ int WXUNUSED(flags)) const
+{
+ return clientSize;
+}
+
+wxSize wxMonoRenderer::GetFrameMinSize(int WXUNUSED(flags)) const
+{
+ return wxSize(0,0);
+}
+
+wxSize wxMonoRenderer::GetFrameIconSize() const
+{
+ return wxSize(wxDefaultCoord, wxDefaultCoord);
+}
+
+int
+wxMonoRenderer::HitTestFrame(const wxRect& WXUNUSED(rect),
+ const wxPoint& WXUNUSED(pt),
+ int WXUNUSED(flags)) const
+{
+ return wxHT_TOPLEVEL_CLIENT_AREA;
+}
+
+
+// ----------------------------------------------------------------------------
+// standard icons
+// ----------------------------------------------------------------------------
+
+/* Copyright (c) Julian Smart */
+static const char *error_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"48 48 4 1",
+" c None",
+"X c #242424",
+"o c #DCDF00",
+". c #C00000",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ",
+" ..... ",
+" ............. ",
+" ................. ",
+" ................... ",
+" ....................... ",
+" ......................... ",
+" ........................... ",
+" ...........................X ",
+" .............................X ",
+" ............................... ",
+" ...............................X ",
+" .................................X ",
+" .................................X ",
+" .................................XX ",
+" ...ooooooooooooooooooooooooooo...XX ",
+" ....ooooooooooooooooooooooooooo....X ",
+" ....ooooooooooooooooooooooooooo....X ",
+" ....ooooooooooooooooooooooooooo....XX ",
+" ....ooooooooooooooooooooooooooo....XX ",
+" ....ooooooooooooooooooooooooooo....XX ",
+" ...ooooooooooooooooooooooooooo...XXX ",
+" ...ooooooooooooooooooooooooooo...XXX ",
+" .................................XX ",
+" .................................XX ",
+" ...............................XXX ",
+" ...............................XXX ",
+" .............................XXX ",
+" ...........................XXXX ",
+" ...........................XXX ",
+" .........................XXX ",
+" .......................XXXX ",
+" X...................XXXXX ",
+" X.................XXXXX ",
+" X.............XXXXX ",
+" XXXX.....XXXXXXXX ",
+" XXXXXXXXXXXXX ",
+" XXXXX ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "
+};
+
+/* Copyright (c) Julian Smart */
+static const char *info_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"48 48 9 1",
+"$ c Black",
+"O c #FFFFFF",
+"@ c #808080",
+"+ c #000080",
+"o c #E8EB01",
+" c None",
+"X c #FFFF40",
+"# c #C0C0C0",
+". c #ABAD01",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ..... ",
+" ..XXXXX.. ",
+" ..XXXXXXXXo.. ",
+" .XXXOXXXXXXXoo. ",
+" .XOOXXX+XXXXXo. ",
+" .XOOOXX+++XXXXoo. ",
+" .XOOXXX+++XXXXXo. ",
+" .XOOOXXX+++XXXXXXo. ",
+" .XOOXXXX+++XXXXXXo. ",
+" .XXXXXXX+++XXXXXXX. ",
+" .XXXXXXX+++XXXXXXo. ",
+" .XXXXXXX+++XXXXXoo. ",
+" .XXXXXX+++XXXXXo. ",
+" .XXXXXXX+XXXXXXo. ",
+" .XXXXXXXXXXXXo. ",
+" .XXXXX+++XXXoo. ",
+" .XXXX+++XXoo. ",
+" .XXXXXXXXo. ",
+" ..XXXXXXo.. ",
+" .XXXXXo.. ",
+" @#######@ ",
+" @@@@@@@@@ ",
+" @#######@ ",
+" @@@@@@@@@ ",
+" @#######@ ",
+" @@@@@@@ ",
+" ### ",
+" $$$ ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "
+};
+
+/* Copyright (c) Julian Smart */
+static const char *warning_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"48 48 9 1",
+"@ c Black",
+"o c #A6A800",
+"+ c #8A8C00",
+"$ c #B8BA00",
+" c None",
+"O c #6E7000",
+"X c #DCDF00",
+". c #C00000",
+"# c #373800",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" . ",
+" ... ",
+" ... ",
+" ..... ",
+" ...X.. ",
+" ..XXX.. ",
+" ...XXX... ",
+" ..XXXXX.. ",
+" ..XXXXXX... ",
+" ...XXoO+XX.. ",
+" ..XXXO@#XXX.. ",
+" ..XXXXO@#XXX... ",
+" ...XXXXO@#XXXX.. ",
+" ..XXXXXO@#XXXX... ",
+" ...XXXXXo@OXXXXX.. ",
+" ...XXXXXXo@OXXXXXX.. ",
+" ..XXXXXXX$@OXXXXXX... ",
+" ...XXXXXXXX@XXXXXXXX.. ",
+" ...XXXXXXXXXXXXXXXXXX... ",
+" ..XXXXXXXXXXOXXXXXXXXX.. ",
+" ...XXXXXXXXXO@#XXXXXXXXX.. ",
+" ..XXXXXXXXXXX#XXXXXXXXXX... ",
+" ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
+" ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
+" .............................. ",
+" .............................. ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "
+};
+
+/* Copyright (c) Julian Smart */
+static const char *question_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"48 48 21 1",
+". c Black",
+"> c #696969",
+"O c #1F1F00",
+"+ c #181818",
+"o c #F6F900",
+"; c #3F3F00",
+"$ c #111111",
+" c None",
+"& c #202020",
+"X c #AAAA00",
+"@ c #949400",
+": c #303030",
+"1 c #383838",
+"% c #2A2A00",
+", c #404040",
+"= c #B4B400",
+"- c #484848",
+"# c #151500",
+"< c #9F9F00",
+"2 c #6A6A00",
+"* c #353500",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ......... ",
+" ...XXXXXXX.. ",
+" ..XXXXoooooXXXO+ ",
+" ..XXooooooooooooX@.. ",
+" ..XoooooooooooooooXX#. ",
+" $%XoooooooooooooooooXX#. ",
+" &.XoooooooXXXXXXooooooXX.. ",
+" .XooooooXX.$...$XXoooooX*. ",
+" $.XoooooX%.$ .*oooooo=.. ",
+" .XooooooX.. -.XoooooX.. ",
+" .XoooooX..+ .XoooooX;. ",
+" ...XXXX..: .XoooooX;. ",
+" ........ >.XoooooX;. ",
+" +.XoooooX.. ",
+" ,.Xoooooo<.. ",
+" 1#XooooooXO.. ",
+" &#XooooooX2.. ",
+" $%XooooooXX.. ",
+" $%XooooooXX.. ",
+" $%XooooooXX.. ",
+" &.XooooooXX.. ",
+" .XooooooXX.. ",
+" &.XoooooXX.. ",
+" ..XooooXX.. ",
+" ..XooooX... ",
+" ..XXooXX..& ",
+" ...XXXXX.. ",
+" ........ ",
+" ",
+" ",
+" ....... ",
+" ..XXXXX.. ",
+" ..XXoooXX.. ",
+" ..XoooooX.. ",
+" ..XoooooX.. ",
+" ..XXoooXX.. ",
+" ..XXXXX.. ",
+" ....... ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "
+};
+
+wxBitmap wxMonoArtProvider::CreateBitmap(const wxArtID& id,
+ const wxArtClient& WXUNUSED(client),
+ const wxSize& WXUNUSED(size))
+{
+ if ( id == wxART_INFORMATION )
+ return wxBitmap(info_xpm);
+ if ( id == wxART_ERROR )
+ return wxBitmap(error_xpm);
+ if ( id == wxART_WARNING )
+ return wxBitmap(warning_xpm);
+ if ( id == wxART_QUESTION )
+ return wxBitmap(question_xpm);
+ return wxNullBitmap;
+}
+
+
+// ============================================================================
+// wxInputHandler
+// ============================================================================
+
#endif // wxUSE_TOGGLEBTN
#include "wx/univ/scrtimer.h"
-#include "wx/univ/renderer.h"
+#include "wx/univ/stdrend.h"
#include "wx/univ/inpcons.h"
#include "wx/univ/inphand.h"
#include "wx/univ/colschem.h"
static const wxCoord SLIDER_THUMB_LENGTH = 18;
static const wxCoord SLIDER_TICK_LENGTH = 6;
-enum IndicatorType
-{
- IndicatorType_Check,
- IndicatorType_Radio,
- IndicatorType_Menu,
- IndicatorType_Max
-};
-
-enum IndicatorState
-{
- IndicatorState_Normal,
- IndicatorState_Pressed, // this one is for check/radioboxes
- IndicatorState_Selected = IndicatorState_Pressed, // for menus
- IndicatorState_Disabled,
- IndicatorState_SelectedDisabled, // only for the menus
- IndicatorState_Max
-};
-
-enum IndicatorStatus
-{
- IndicatorStatus_Checked,
- IndicatorStatus_Unchecked,
- IndicatorStatus_Undeterminated,
- IndicatorStatus_Max
-};
-
// wxWin32Renderer: draw the GUI elements in Win32 style
// ----------------------------------------------------------------------------
-class wxWin32Renderer : public wxRenderer
+class wxWin32Renderer : public wxStdRenderer
{
public:
// constants
// ctor
wxWin32Renderer(const wxColourScheme *scheme);
- // implement the base class pure virtuals
- virtual void DrawBackground(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- int flags = 0,
- wxWindow *window = NULL);
+ // reimplement the renderer methods which are different for this theme
virtual void DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
int indexAccel = -1,
wxRect *rectBounds = NULL);
- virtual void DrawBorder(wxDC& dc,
- wxBorder border,
- const wxRect& rect,
- int flags = 0,
- wxRect *rectIn = (wxRect *)NULL);
- virtual void DrawHorizontalLine(wxDC& dc,
- wxCoord y, wxCoord x1, wxCoord x2);
- virtual void DrawVerticalLine(wxDC& dc,
- wxCoord x, wxCoord y1, wxCoord y2);
- virtual void DrawFrame(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags = 0,
- int alignment = wxALIGN_LEFT,
- int indexAccel = -1);
- virtual void DrawTextBorder(wxDC& dc,
- wxBorder border,
- const wxRect& rect,
- int flags = 0,
- wxRect *rectIn = (wxRect *)NULL);
virtual void DrawButtonBorder(wxDC& dc,
const wxRect& rect,
int flags = 0,
- wxRect *rectIn = (wxRect *)NULL);
+ wxRect *rectIn = NULL);
virtual void DrawArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
int flags = 0);
virtual void DrawScrollCorner(wxDC& dc,
const wxRect& rect);
- virtual void DrawItem(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags = 0);
virtual void DrawCheckItem(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags = 0);
- virtual void DrawCheckButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rect,
- int flags = 0,
- wxAlignment align = wxALIGN_LEFT,
- int indexAccel = -1);
- virtual void DrawRadioButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rect,
- int flags = 0,
- wxAlignment align = wxALIGN_LEFT,
- int indexAccel = -1);
+
#if wxUSE_TOOLBAR
virtual void DrawToolBarButton(wxDC& dc,
const wxString& label,
long style = 0,
int tbarStyle = 0);
#endif // wxUSE_TOOLBAR
- virtual void DrawTextLine(wxDC& dc,
- const wxString& text,
- const wxRect& rect,
- int selStart = -1,
- int selEnd = -1,
- int flags = 0);
- virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect);
+
virtual void DrawTab(wxDC& dc,
const wxRect& rect,
wxDirection dir,
wxBitmap *bmpDisabled);
virtual void AdjustSize(wxSize *size, const wxWindow *window);
- virtual wxRect GetBorderDimensions(wxBorder border) const;
virtual bool AreScrollbarsInsideBorder() const;
virtual wxSize GetScrollbarArrowSize() const
{ return m_sizeScrollbarArrow; }
-#if wxUSE_SCROLLBAR
- virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
- wxScrollBar::Element elem,
- int thumbPos = -1) const;
- virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
- virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
- const wxPoint& pt) const;
- virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
- int thumbPos = -1);
- virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
-#endif // wxUSE_SCROLLBAR
-
virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
{ return fontHeight + 2; }
virtual wxSize GetCheckBitmapSize() const
#endif // wxUSE_STATUSBAR
protected:
- // helper of DrawLabel() and DrawCheckOrRadioButton()
- void DoDrawLabel(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags = 0,
- int alignment = wxALIGN_LEFT | wxALIGN_TOP,
- int indexAccel = -1,
- wxRect *rectBounds = NULL,
- const wxPoint& focusOffset
- = wxPoint(FOCUS_RECT_OFFSET_X, FOCUS_RECT_OFFSET_Y));
-
- // common part of DrawLabel() and DrawItem()
- void DrawFocusRect(wxDC& dc, const wxRect& rect);
-
- // DrawLabel() and DrawButtonLabel() helper
- void DrawLabelShadow(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int alignment,
- int indexAccel);
-
- // DrawButtonBorder() helper
- void DoDrawBackground(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- wxWindow *window = NULL );
-
- // DrawBorder() helpers: all of them shift and clip the DC after drawing
- // the border
-
- // just draw a rectangle with the given pen
- void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
-
- // draw the lower left part of rectangle
- void DrawHalfRect(wxDC& dc, wxRect *rect, const wxPen& pen);
-
- // draw the rectange using the first brush for the left and top sides and
- // the second one for the bottom and right ones
- void DrawShadedRect(wxDC& dc, wxRect *rect,
- const wxPen& pen1, const wxPen& pen2);
-
- // draw the normal 3D border
- void DrawRaisedBorder(wxDC& dc, wxRect *rect);
+ virtual void DrawFrameWithLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rectFrame,
+ const wxRect& rectText,
+ int flags,
+ int alignment,
+ int indexAccel);
- // draw the sunken 3D border
- void DrawSunkenBorder(wxDC& dc, wxRect *rect);
// draw the border used for scrollbar arrows
void DrawArrowBorder(wxDC& dc, wxRect *rect, bool isPressed = false);
wxArrowDirection arrowDir,
wxArrowStyle arrowStyle);
- // DrawCheckButton/DrawRadioButton helper
+ // DrawCheckButton helper
void DrawCheckOrRadioButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
{ return GetIndicator(IndicatorType_Radio, flags); }
private:
- const wxColourScheme *m_scheme;
-
// the sizing parameters (TODO make them changeable)
wxSize m_sizeScrollbarArrow;
- // GDI objects we use for drawing
- wxColour m_colDarkGrey,
- m_colHighlight;
-
- wxPen m_penBlack,
- m_penDarkGrey,
- m_penLightGrey,
- m_penHighlight;
-
wxFont m_titlebarFont;
// the checked and unchecked bitmaps for DrawCheckItem()
// the bitmaps returned by GetIndicator()
wxBitmap m_bmpIndicators[IndicatorType_Max]
- [IndicatorState_Max]
+ [IndicatorState_MaxMenu]
[IndicatorStatus_Max];
+ // standard defaults for m_bmpCheckBitmaps and m_bmpIndicators
+ static const char **ms_xpmChecked[IndicatorStatus_Max];
+ static const char **ms_xpmIndicators[IndicatorType_Max]
+ [IndicatorState_MaxMenu]
+ [IndicatorStatus_Max];
+
// titlebar icons:
wxBitmap m_bmpFrameButtons[FrameButton_Max];
" hhhh "
};
-static const char **
- xpmIndicators[IndicatorType_Max][IndicatorState_Max][IndicatorStatus_Max] =
+const char **wxWin32Renderer::ms_xpmIndicators[IndicatorType_Max]
+ [IndicatorState_MaxMenu]
+ [IndicatorStatus_Max] =
{
// checkboxes first
{
}
};
-static const char **xpmChecked[IndicatorStatus_Max] =
+const char **wxWin32Renderer::ms_xpmChecked[IndicatorStatus_Max] =
{
checked_item_xpm,
unchecked_item_xpm
// ----------------------------------------------------------------------------
wxWin32Renderer::wxWin32Renderer(const wxColourScheme *scheme)
+ : wxStdRenderer(scheme)
{
// init data
- m_scheme = scheme;
m_sizeScrollbarArrow = wxSize(16, 16);
- // init colours and pens
- m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID);
-
- m_colDarkGrey = wxSCHEME_COLOUR(scheme, SHADOW_OUT);
- m_penDarkGrey = wxPen(m_colDarkGrey, 0, wxSOLID);
-
- m_penLightGrey = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_IN), 0, wxSOLID);
-
- m_colHighlight = wxSCHEME_COLOUR(scheme, SHADOW_HIGHLIGHT);
- m_penHighlight = wxPen(m_colHighlight, 0, wxSOLID);
-
m_titlebarFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
m_titlebarFont.SetWeight(wxFONTWEIGHT_BOLD);
m_bmpFrameButtons[FrameButton_Help] = wxBitmap(frame_button_help_xpm);
}
-// ----------------------------------------------------------------------------
-// border stuff
-// ----------------------------------------------------------------------------
-
-/*
- The raised border in Win32 looks like this:
-
- IIIIIIIIIIIIIIIIIIIIIIB
- I GB
- I GB I = white (HILIGHT)
- I GB H = light grey (LIGHT)
- I GB G = dark grey (SHADOI)
- I GB B = black (DKSHADOI)
- I GB I = hIghlight (COLOR_3DHILIGHT)
- I GB
- IGGGGGGGGGGGGGGGGGGGGGB
- BBBBBBBBBBBBBBBBBBBBBBB
-
- The sunken border looks like this:
-
- GGGGGGGGGGGGGGGGGGGGGGI
- GBBBBBBBBBBBBBBBBBBBBHI
- GB HI
- GB HI
- GB HI
- GB HI
- GB HI
- GB HI
- GHHHHHHHHHHHHHHHHHHHHHI
- IIIIIIIIIIIIIIIIIIIIIII
-
- The static border (used for the controls which don't get focus) is like
- this:
-
- GGGGGGGGGGGGGGGGGGGGGGW
- G W
- G W
- G W
- G W
- G W
- G W
- G W
- WWWWWWWWWWWWWWWWWWWWWWW
-
- The most complicated is the double border:
-
- HHHHHHHHHHHHHHHHHHHHHHB
- HWWWWWWWWWWWWWWWWWWWWGB
- HWHHHHHHHHHHHHHHHHHHHGB
- HWH HGB
- HWH HGB
- HWH HGB
- HWH HGB
- HWHHHHHHHHHHHHHHHHHHHGB
- HGGGGGGGGGGGGGGGGGGGGGB
- BBBBBBBBBBBBBBBBBBBBBBB
-
- And the simple border is, well, simple:
-
- BBBBBBBBBBBBBBBBBBBBBBB
- B B
- B B
- B B
- B B
- B B
- B B
- B B
- B B
- BBBBBBBBBBBBBBBBBBBBBBB
-*/
-
-void wxWin32Renderer::DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen)
-{
- // draw
- dc.SetPen(pen);
- dc.SetBrush(*wxTRANSPARENT_BRUSH);
- dc.DrawRectangle(*rect);
-
- // adjust the rect
- rect->Inflate(-1);
-}
-
-void wxWin32Renderer::DrawHalfRect(wxDC& dc, wxRect *rect, const wxPen& pen)
-{
- // draw the bottom and right sides
- dc.SetPen(pen);
- dc.DrawLine(rect->GetLeft(), rect->GetBottom(),
- rect->GetRight() + 1, rect->GetBottom());
- dc.DrawLine(rect->GetRight(), rect->GetTop(),
- rect->GetRight(), rect->GetBottom());
-
- // adjust the rect
- rect->Inflate(-1);
-}
-
-void wxWin32Renderer::DrawShadedRect(wxDC& dc, wxRect *rect,
- const wxPen& pen1, const wxPen& pen2)
-{
- // draw the rectangle
- dc.SetPen(pen1);
- dc.DrawLine(rect->GetLeft(), rect->GetTop(),
- rect->GetLeft(), rect->GetBottom());
- dc.DrawLine(rect->GetLeft() + 1, rect->GetTop(),
- rect->GetRight(), rect->GetTop());
- dc.SetPen(pen2);
- dc.DrawLine(rect->GetRight(), rect->GetTop(),
- rect->GetRight(), rect->GetBottom());
- dc.DrawLine(rect->GetLeft(), rect->GetBottom(),
- rect->GetRight() + 1, rect->GetBottom());
-
- // adjust the rect
- rect->Inflate(-1);
-}
-
-void wxWin32Renderer::DrawRaisedBorder(wxDC& dc, wxRect *rect)
-{
- DrawShadedRect(dc, rect, m_penHighlight, m_penBlack);
- DrawShadedRect(dc, rect, m_penLightGrey, m_penDarkGrey);
-}
-
-void wxWin32Renderer::DrawSunkenBorder(wxDC& dc, wxRect *rect)
-{
- DrawShadedRect(dc, rect, m_penDarkGrey, m_penHighlight);
- DrawShadedRect(dc, rect, m_penBlack, m_penLightGrey);
-}
-
-void wxWin32Renderer::DrawArrowBorder(wxDC& dc, wxRect *rect, bool isPressed)
-{
- if ( isPressed )
- {
- DrawRect(dc, rect, m_penDarkGrey);
-
- // the arrow is usually drawn inside border of width 2 and is offset by
- // another pixel in both directions when it's pressed - as the border
- // in this case is more narrow as well, we have to adjust rect like
- // this:
- rect->Inflate(-1);
- rect->x++;
- rect->y++;
- }
- else
- {
- DrawShadedRect(dc, rect, m_penLightGrey, m_penBlack);
- DrawShadedRect(dc, rect, m_penHighlight, m_penDarkGrey);
- }
-}
-
-void wxWin32Renderer::DrawBorder(wxDC& dc,
- wxBorder border,
- const wxRect& rectTotal,
- int WXUNUSED(flags),
- wxRect *rectIn)
-{
- int i;
-
- wxRect rect = rectTotal;
-
- switch ( border )
- {
- case wxBORDER_SUNKEN:
- for ( i = 0; i < BORDER_THICKNESS / 2; i++ )
- {
- DrawSunkenBorder(dc, &rect);
- }
- break;
-
- case wxBORDER_STATIC:
- DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
- break;
-
- case wxBORDER_RAISED:
- for ( i = 0; i < BORDER_THICKNESS / 2; i++ )
- {
- DrawRaisedBorder(dc, &rect);
- }
- break;
-
- case wxBORDER_DOUBLE:
- DrawArrowBorder(dc, &rect);
- DrawRect(dc, &rect, m_penLightGrey);
- break;
-
- case wxBORDER_SIMPLE:
- for ( i = 0; i < BORDER_THICKNESS / 2; i++ )
- {
- DrawRect(dc, &rect, m_penBlack);
- }
- break;
-
- default:
- wxFAIL_MSG(_T("unknown border type"));
- // fall through
-
- case wxBORDER_DEFAULT:
- case wxBORDER_NONE:
- break;
- }
-
- if ( rectIn )
- *rectIn = rect;
-}
-
-wxRect wxWin32Renderer::GetBorderDimensions(wxBorder border) const
-{
- wxCoord width;
- switch ( border )
- {
- case wxBORDER_RAISED:
- case wxBORDER_SUNKEN:
- width = BORDER_THICKNESS;
- break;
-
- case wxBORDER_SIMPLE:
- case wxBORDER_STATIC:
- width = 1;
- break;
-
- case wxBORDER_DOUBLE:
- width = 3;
- break;
-
- default:
- {
- // char *crash = NULL;
- // *crash = 0;
- wxFAIL_MSG(_T("unknown border type"));
- // fall through
- }
-
- case wxBORDER_DEFAULT:
- case wxBORDER_NONE:
- width = 0;
- break;
- }
-
- wxRect rect;
- rect.x =
- rect.y =
- rect.width =
- rect.height = width;
-
- return rect;
-}
-
bool wxWin32Renderer::AreScrollbarsInsideBorder() const
{
return true;
}
-// ----------------------------------------------------------------------------
-// borders
-// ----------------------------------------------------------------------------
-
-void wxWin32Renderer::DrawTextBorder(wxDC& dc,
- wxBorder border,
- const wxRect& rect,
- int flags,
- wxRect *rectIn)
-{
- // text controls are not special under windows
- DrawBorder(dc, border, rect, flags, rectIn);
-}
-
-void wxWin32Renderer::DrawButtonBorder(wxDC& dc,
- const wxRect& rectTotal,
- int flags,
- wxRect *rectIn)
-{
- wxRect rect = rectTotal;
-
- if ( flags & wxCONTROL_PRESSED )
- {
- // button pressed: draw a double border around it
- DrawRect(dc, &rect, m_penBlack);
- DrawRect(dc, &rect, m_penDarkGrey);
- }
- else
- {
- // button not pressed
-
- if ( flags & (wxCONTROL_FOCUSED | wxCONTROL_ISDEFAULT) )
- {
- // button either default or focused (or both): add an extra border around it
- DrawRect(dc, &rect, m_penBlack);
- }
-
- // now draw a normal button
- DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
- DrawHalfRect(dc, &rect, m_penDarkGrey);
- }
-
- if ( rectIn )
- {
- *rectIn = rect;
- }
-}
-
-// ----------------------------------------------------------------------------
-// lines and frame
-// ----------------------------------------------------------------------------
-
-void wxWin32Renderer::DrawHorizontalLine(wxDC& dc,
- wxCoord y, wxCoord x1, wxCoord x2)
-{
- dc.SetPen(m_penDarkGrey);
- dc.DrawLine(x1, y, x2 + 1, y);
- dc.SetPen(m_penHighlight);
- y++;
- dc.DrawLine(x1, y, x2 + 1, y);
-}
-
-void wxWin32Renderer::DrawVerticalLine(wxDC& dc,
- wxCoord x, wxCoord y1, wxCoord y2)
-{
- dc.SetPen(m_penDarkGrey);
- dc.DrawLine(x, y1, x, y2 + 1);
- dc.SetPen(m_penHighlight);
- x++;
- dc.DrawLine(x, y1, x, y2 + 1);
-}
-
-void wxWin32Renderer::DrawFrame(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags,
- int alignment,
- int indexAccel)
-{
- wxCoord height = 0; // of the label
- wxRect rectFrame = rect;
- if ( !label.empty() )
- {
- // the text should touch the top border of the rect, so the frame
- // itself should be lower
- dc.GetTextExtent(label, NULL, &height);
- rectFrame.y += height / 2;
- rectFrame.height -= height / 2;
-
- // we have to draw each part of the frame individually as we can't
- // erase the background beyond the label as it might contain some
- // pixmap already, so drawing everything and then overwriting part of
- // the frame with label doesn't work
-
- // TODO: the +5 and space insertion should be customizable
-
- wxRect rectText;
- rectText.x = rectFrame.x + 5;
- rectText.y = rect.y;
- rectText.width = rectFrame.width - 7; // +2 border width
- rectText.height = height;
-
- wxString label2;
- label2 << _T(' ') << label << _T(' ');
- if ( indexAccel != -1 )
- {
- // adjust it as we prepended a space
- indexAccel++;
- }
-
- wxRect rectLabel;
- DrawLabel(dc, label2, rectText, flags, alignment, indexAccel, &rectLabel);
-
- StandardDrawFrame(dc, rectFrame, rectLabel);
- }
- else
- {
- // just draw the complete frame
- DrawShadedRect(dc, &rectFrame, m_penDarkGrey, m_penHighlight);
- DrawShadedRect(dc, &rectFrame, m_penHighlight, m_penDarkGrey);
- }
-}
-
// ----------------------------------------------------------------------------
// label
// ----------------------------------------------------------------------------
-void wxWin32Renderer::DrawFocusRect(wxDC& dc, const wxRect& rect)
-{
- // VZ: this doesn't work under Windows, the dotted pen has dots of 3
- // pixels each while we really need dots here... PS_ALTERNATE might
- // work, but it is for NT 5 only
-#if 0
- DrawRect(dc, &rect, wxPen(*wxBLACK, 0, wxDOT));
-#else
- // draw the pixels manually: note that to behave in the same manner as
- // DrawRect(), we must exclude the bottom and right borders from the
- // rectangle
- wxCoord x1 = rect.GetLeft(),
- y1 = rect.GetTop(),
- x2 = rect.GetRight(),
- y2 = rect.GetBottom();
-
- dc.SetPen(wxPen(*wxBLACK, 0, wxSOLID));
-
- // this seems to be closer than what Windows does than wxINVERT although
- // I'm still not sure if it's correct
- dc.SetLogicalFunction(wxAND_REVERSE);
-
- wxCoord z;
- for ( z = x1 + 1; z < x2; z += 2 )
- dc.DrawPoint(z, rect.GetTop());
-
- wxCoord shift = z == x2 ? 0 : 1;
- for ( z = y1 + shift; z < y2; z += 2 )
- dc.DrawPoint(x2, z);
-
- shift = z == y2 ? 0 : 1;
- for ( z = x2 - shift; z > x1; z -= 2 )
- dc.DrawPoint(z, y2);
-
- shift = z == x1 ? 0 : 1;
- for ( z = y2 - shift; z > y1; z -= 2 )
- dc.DrawPoint(x1, z);
-
- dc.SetLogicalFunction(wxCOPY);
-#endif // 0/1
-}
-
-void wxWin32Renderer::DrawLabelShadow(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int alignment,
- int indexAccel)
-{
- // draw shadow of the text
- dc.SetTextForeground(m_colHighlight);
- wxRect rectShadow = rect;
- rectShadow.x++;
- rectShadow.y++;
- dc.DrawLabel(label, rectShadow, alignment, indexAccel);
-
- // make the text grey
- dc.SetTextForeground(m_colDarkGrey);
-}
-
void wxWin32Renderer::DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
int alignment,
int indexAccel,
wxRect *rectBounds)
-{
- DoDrawLabel(dc, label, rect, flags, alignment, indexAccel, rectBounds);
-}
-
-void wxWin32Renderer::DoDrawLabel(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags,
- int alignment,
- int indexAccel,
- wxRect *rectBounds,
- const wxPoint& focusOffset)
{
// the underscores are not drawn for focused controls in wxMSW
if ( flags & wxCONTROL_FOCUSED )
if ( flags & wxCONTROL_SELECTED )
{
// just make the label text greyed out
- dc.SetTextForeground(m_colDarkGrey);
- }
- else // draw normal disabled label
- {
- DrawLabelShadow(dc, label, rect, alignment, indexAccel);
+ dc.SetTextForeground(m_penDarkGrey.GetColour());
+
+ flags &= ~wxCONTROL_DISABLED;
}
}
- wxRect rectLabel;
- dc.DrawLabel(label, wxNullBitmap, rect, alignment, indexAccel, &rectLabel);
-
- if ( flags & wxCONTROL_DISABLED )
- {
- // restore the fg colour
- dc.SetTextForeground(*wxBLACK);
- }
+ wxStdRenderer::DrawLabel(dc, label, rect, flags, alignment,
+ indexAccel, rectBounds);
+}
- if ( flags & wxCONTROL_FOCUSED )
+void wxWin32Renderer::DrawFrameWithLabel(wxDC& dc,
+ const wxString& label,
+ const wxRect& rectFrame,
+ const wxRect& rectText,
+ int flags,
+ int alignment,
+ int indexAccel)
+{
+ wxString label2;
+ label2 << _T(' ') << label << _T(' ');
+ if ( indexAccel != -1 )
{
- if ( focusOffset.x || focusOffset.y )
- {
- rectLabel.Inflate(focusOffset.x, focusOffset.y);
- }
-
- DrawFocusRect(dc, rectLabel);
+ // adjust it as we prepended a space
+ indexAccel++;
}
- if ( rectBounds )
- *rectBounds = rectLabel;
+ wxStdRenderer::DrawFrameWithLabel(dc, label2, rectFrame, rectText,
+ flags, alignment, indexAccel);
}
void wxWin32Renderer::DrawButtonLabel(wxDC& dc,
indexAccel = -1;
}
- wxRect rectLabel = rect;
- if ( !label.empty() )
- {
- // shift the label if a button is pressed
- if ( flags & wxCONTROL_PRESSED )
- {
- rectLabel.x++;
- rectLabel.y++;
- }
+ wxStdRenderer::DrawButtonLabel(dc, label, image, rect, flags, alignment,
+ indexAccel, rectBounds);
+}
- if ( flags & wxCONTROL_DISABLED )
- {
- DrawLabelShadow(dc, label, rectLabel, alignment, indexAccel);
- }
+void wxWin32Renderer::DrawButtonBorder(wxDC& dc,
+ const wxRect& rectTotal,
+ int flags,
+ wxRect *rectIn)
+{
+ wxRect rect = rectTotal;
- // leave enough space for the focus rectangle
- if ( flags & wxCONTROL_FOCUSED )
- {
- rectLabel.Inflate(-2);
- }
+ wxPen penOut(*wxBLACK);
+ if ( flags & wxCONTROL_PRESSED )
+ {
+ // button pressed: draw a double border around it
+ DrawRect(dc, &rect, penOut);
+ DrawRect(dc, &rect, m_penDarkGrey);
}
-
- dc.DrawLabel(label, image, rectLabel, alignment, indexAccel, rectBounds);
-
- if ( !label.empty() && (flags & wxCONTROL_FOCUSED) )
+ else // button not pressed
{
- if ( flags & wxCONTROL_PRESSED )
+ if ( flags & (wxCONTROL_FOCUSED | wxCONTROL_ISDEFAULT) )
{
- // the focus rectangle is never pressed, so undo the shift done
- // above
- rectLabel.x--;
- rectLabel.y--;
- rectLabel.width--;
- rectLabel.height--;
+ // button either default or focused (or both): add an extra border
+ // around it
+ DrawRect(dc, &rect, penOut);
}
- DrawFocusRect(dc, rectLabel);
+ // now draw a normal button border
+ DrawRaisedBorder(dc, &rect);
}
+
+ if ( rectIn )
+ *rectIn = rect;
}
// ----------------------------------------------------------------------------
// (check)listbox items
// ----------------------------------------------------------------------------
-void wxWin32Renderer::DrawItem(wxDC& dc,
- const wxString& label,
- const wxRect& rect,
- int flags)
-{
- wxDCTextColourChanger colChanger(dc);
-
- if ( flags & wxCONTROL_SELECTED )
- {
- colChanger.Set(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
-
- wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT);
- dc.SetBrush(wxBrush(colBg, wxSOLID));
- dc.SetPen(wxPen(colBg, 0, wxSOLID));
- dc.DrawRectangle(rect);
- }
-
- wxRect rectText = rect;
- rectText.x += 2;
- rectText.width -= 2;
- dc.DrawLabel(label, wxNullBitmap, rectText);
-
- if ( flags & wxCONTROL_FOCUSED )
- {
- DrawFocusRect(dc, rect);
- }
-}
-
void wxWin32Renderer::DrawCheckItem(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
if ( !m_bmpCheckBitmaps[i].Ok() )
{
- m_bmpCheckBitmaps[i] = wxBitmap(xpmChecked[i]);
+ m_bmpCheckBitmaps[i] = wxBitmap(ms_xpmChecked[i]);
}
bmp = m_bmpCheckBitmaps[i];
wxBitmap wxWin32Renderer::GetIndicator(IndicatorType indType, int flags)
{
IndicatorState indState;
- if ( flags & wxCONTROL_SELECTED )
- indState = flags & wxCONTROL_DISABLED ? IndicatorState_SelectedDisabled
- : IndicatorState_Selected;
- else if ( flags & wxCONTROL_DISABLED )
- indState = IndicatorState_Disabled;
- else if ( flags & wxCONTROL_PRESSED )
- indState = IndicatorState_Pressed;
- else
- indState = IndicatorState_Normal;
-
- IndicatorStatus indStatus = flags & wxCONTROL_CHECKED
- ? IndicatorStatus_Checked
- : ( flags & wxCONTROL_UNDETERMINED
- ? IndicatorStatus_Undeterminated
- : IndicatorStatus_Unchecked );
+ IndicatorStatus indStatus;
+ GetIndicatorsFromFlags(flags, indState, indStatus);
wxBitmap bmp = m_bmpIndicators[indType][indState][indStatus];
if ( !bmp.Ok() )
{
- const char **xpm = xpmIndicators[indType][indState][indStatus];
+ const char **xpm = ms_xpmIndicators[indType][indState][indStatus];
if ( xpm )
{
// create and cache it
return bmp;
}
-void wxWin32Renderer::DrawCheckOrRadioButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rect,
- int flags,
- wxAlignment align,
- int indexAccel,
- wxCoord focusOffsetY)
-{
- // calculate the position of the bitmap and of the label
- wxCoord heightBmp = bitmap.GetHeight();
- wxCoord xBmp,
- yBmp = rect.y + (rect.height - heightBmp) / 2;
-
- wxRect rectLabel;
- dc.GetMultiLineTextExtent(label, NULL, &rectLabel.height);
- rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2;
-
- // align label vertically with the bitmap - looks nicer like this
- rectLabel.y -= (rectLabel.height - heightBmp) % 2;
-
- // calc horz position
- if ( align == wxALIGN_RIGHT )
- {
- xBmp = rect.GetRight() - bitmap.GetWidth();
- rectLabel.x = rect.x + 3;
- rectLabel.SetRight(xBmp);
- }
- else // normal (checkbox to the left of the text) case
- {
- xBmp = rect.x;
- rectLabel.x = xBmp + bitmap.GetWidth() + 5;
- rectLabel.SetRight(rect.GetRight());
- }
-
- dc.DrawBitmap(bitmap, xBmp, yBmp, true /* use mask */);
-
- DoDrawLabel(
- dc, label, rectLabel,
- flags,
- wxALIGN_LEFT | wxALIGN_TOP,
- indexAccel,
- NULL, // we don't need bounding rect
- // use custom vert focus rect offset
- wxPoint(FOCUS_RECT_OFFSET_X, focusOffsetY)
- );
-}
-
-void wxWin32Renderer::DrawRadioButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rect,
- int flags,
- wxAlignment align,
- int indexAccel)
-{
- wxBitmap bmp;
- if ( bitmap.Ok() )
- bmp = bitmap;
- else
- bmp = GetRadioBitmap(flags);
-
- DrawCheckOrRadioButton(dc, label,
- bmp,
- rect, flags, align, indexAccel,
- FOCUS_RECT_OFFSET_Y); // default focus rect offset
-}
-
-void wxWin32Renderer::DrawCheckButton(wxDC& dc,
- const wxString& label,
- const wxBitmap& bitmap,
- const wxRect& rect,
- int flags,
- wxAlignment align,
- int indexAccel)
-{
- wxBitmap bmp;
- if ( bitmap.Ok() )
- bmp = bitmap;
- else
- bmp = GetCheckBitmap(flags);
-
- DrawCheckOrRadioButton(dc, label,
- bmp,
- rect, flags, align, indexAccel,
- 0); // no focus rect offset for checkboxes
-}
-
#if wxUSE_TOOLBAR
void wxWin32Renderer::DrawToolBarButton(wxDC& dc,
const wxString& label,
}
#endif // wxUSE_TOOLBAR
-// ----------------------------------------------------------------------------
-// text control
-// ----------------------------------------------------------------------------
-
-void wxWin32Renderer::DrawTextLine(wxDC& dc,
- const wxString& text,
- const wxRect& rect,
- int selStart,
- int selEnd,
- int flags)
-{
- // nothing special to do here
- StandardDrawTextLine(dc, text, rect, selStart, selEnd, flags);
-}
-
-void
-wxWin32Renderer::DrawLineWrapMark(wxDC& WXUNUSED(dc),
- const wxRect& WXUNUSED(rect))
-{
- // we don't draw them
-}
-
// ----------------------------------------------------------------------------
// notebook
// ----------------------------------------------------------------------------
{
colChanger.Set(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
- wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT);
- dc.SetBrush(wxBrush(colBg, wxSOLID));
- dc.SetPen(wxPen(colBg, 0, wxSOLID));
+ const wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT);
+ dc.SetBrush(colBg);
+ dc.SetPen(colBg);
dc.DrawRectangle(rect);
}
{
colChanger.Set(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
- wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT);
- dc.SetBrush(wxBrush(colBg, wxSOLID));
- dc.SetPen(wxPen(colBg, 0, wxSOLID));
+ const wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT);
+ dc.SetBrush(colBg);
+ dc.SetPen(colBg);
dc.DrawRectangle(rect);
}
}
// ----------------------------------------------------------------------------
-// background
+// scrollbar
// ----------------------------------------------------------------------------
-void wxWin32Renderer::DoDrawBackground(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- wxWindow * WXUNUSED(window))
+void wxWin32Renderer::DrawArrowBorder(wxDC& dc, wxRect *rect, bool isPressed)
{
- wxBrush brush(col, wxSOLID);
- dc.SetBrush(brush);
- dc.SetPen(*wxTRANSPARENT_PEN);
- dc.DrawRectangle(rect);
-}
+ if ( isPressed )
+ {
+ DrawRect(dc, rect, m_penDarkGrey);
-void wxWin32Renderer::DrawBackground(wxDC& dc,
- const wxColour& col,
- const wxRect& rect,
- int WXUNUSED(flags),
- wxWindow *window)
-{
- // just fill it with the given or default bg colour
- wxColour colBg = col.Ok() ? col : wxSCHEME_COLOUR(m_scheme, CONTROL);
- DoDrawBackground(dc, colBg, rect, window );
+ // the arrow is usually drawn inside border of width 2 and is offset by
+ // another pixel in both directions when it's pressed - as the border
+ // in this case is more narrow as well, we have to adjust rect like
+ // this:
+ rect->Inflate(-1);
+ rect->x++;
+ rect->y++;
+ }
+ else // !pressed
+ {
+ DrawAntiSunkenBorder(dc, rect);
+ }
}
-// ----------------------------------------------------------------------------
-// scrollbar
-// ----------------------------------------------------------------------------
-
void wxWin32Renderer::DrawArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
wxArrowStyle arrowStyle)
{
wxRect rect = rectAll;
- DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
+ DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
DrawArrowBorder(dc, &rect, arrowStyle == Arrow_Pressed);
DrawArrow(dc, rect, arrowDir, arrowStyle);
}
wxColourScheme::StdColour col = flags & wxCONTROL_PRESSED
? wxColourScheme::SCROLLBAR_PRESSED
: wxColourScheme::SCROLLBAR;
- DoDrawBackground(dc, m_scheme->Get(col), rectBar);
+ DrawBackground(dc, m_scheme->Get(col), rectBar);
}
void wxWin32Renderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
{
- DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
-}
-
-#if wxUSE_SCROLLBAR
-
-wxRect wxWin32Renderer::GetScrollbarRect(const wxScrollBar *scrollbar,
- wxScrollBar::Element elem,
- int thumbPos) const
-{
- return StandardGetScrollbarRect(scrollbar, elem,
- thumbPos, m_sizeScrollbarArrow);
-}
-
-wxCoord wxWin32Renderer::GetScrollbarSize(const wxScrollBar *scrollbar)
-{
- return StandardScrollBarSize(scrollbar, m_sizeScrollbarArrow);
-}
-
-wxHitTest wxWin32Renderer::HitTestScrollbar(const wxScrollBar *scrollbar,
- const wxPoint& pt) const
-{
- return StandardHitTestScrollbar(scrollbar, pt, m_sizeScrollbarArrow);
-}
-
-wxCoord wxWin32Renderer::ScrollbarToPixel(const wxScrollBar *scrollbar,
- int thumbPos)
-{
- return StandardScrollbarToPixel(scrollbar, thumbPos, m_sizeScrollbarArrow);
+ DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
-int wxWin32Renderer::PixelToScrollbar(const wxScrollBar *scrollbar,
- wxCoord coord)
-{
- return StandardPixelToScrollbar(scrollbar, coord, m_sizeScrollbarArrow);
-}
-
-#endif // wxUSE_SCROLLBAR
-
// ----------------------------------------------------------------------------
// top level windows
// ----------------------------------------------------------------------------