-// ----------------------------------------------------------------------------
-// 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->width--;
- rect->height--;
-}
-
-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;
-}
-