- }
-}
-
-// ----------------------------------------------------------------------------
-// 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 flags,
- 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 )
- {
- indexAccel = -1;
- }
-
- if ( flags & wxCONTROL_DISABLED )
- {
- // the combination of wxCONTROL_SELECTED and wxCONTROL_DISABLED
- // currently only can happen for a menu item and it seems that Windows
- // doesn't draw the shadow in this case, so we don't do it neither
- 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);
- }
- }
-
- wxRect rectLabel;
- dc.DrawLabel(label, wxNullBitmap, rect, alignment, indexAccel, &rectLabel);
-
- if ( flags & wxCONTROL_DISABLED )
- {
- // restore the fg colour
- dc.SetTextForeground(*wxBLACK);
- }
-
- if ( flags & wxCONTROL_FOCUSED )
- {
- if ( focusOffset.x || focusOffset.y )
- {
- rectLabel.Inflate(focusOffset.x, focusOffset.y);
- }
-
- DrawFocusRect(dc, rectLabel);
- }
-
- if ( rectBounds )
- *rectBounds = rectLabel;
-}
-
-void wxWin32Renderer::DrawButtonLabel(wxDC& dc,
- const wxString& label,
- const wxBitmap& image,
- const wxRect& rect,
- int flags,
- int alignment,
- int indexAccel,
- wxRect *rectBounds)
-{
- // the underscores are not drawn for focused controls in wxMSW
- if ( flags & wxCONTROL_PRESSED )
- {
- indexAccel = -1;
- }
-
- wxRect rectLabel = rect;
- if ( !label.empty() )
- {
- // shift the label if a button is pressed
- if ( flags & wxCONTROL_PRESSED )
- {
- rectLabel.x++;
- rectLabel.y++;
- }
-
- if ( flags & wxCONTROL_DISABLED )
- {
- DrawLabelShadow(dc, label, rectLabel, alignment, indexAccel);
- }
-
- // leave enough space for the focus rectangle
- if ( flags & wxCONTROL_FOCUSED )
- {
- rectLabel.Inflate(-2);
- }
- }
-
- dc.DrawLabel(label, image, rectLabel, alignment, indexAccel, rectBounds);
-
- if ( !label.empty() && (flags & wxCONTROL_FOCUSED) )
- {
- if ( flags & wxCONTROL_PRESSED )
- {
- // the focus rectangle is never pressed, so undo the shift done
- // above
- rectLabel.x--;
- rectLabel.y--;
- rectLabel.width--;
- rectLabel.height--;
- }
-
- DrawFocusRect(dc, rectLabel);
- }