X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e76372220ef34c80cd801eff2e0523c87fb00bdb..2028c33ab5a39a12bd410ac953731a56ad6377ba:/src/univ/themes/win32.cpp diff --git a/src/univ/themes/win32.cpp b/src/univ/themes/win32.cpp index 1a08bde723..37943fb3ef 100644 --- a/src/univ/themes/win32.cpp +++ b/src/univ/themes/win32.cpp @@ -35,6 +35,7 @@ #include "wx/window.h" #include "wx/dcmemory.h" + #include "wx/dcclient.h" #include "wx/button.h" #include "wx/bmpbuttn.h" @@ -307,6 +308,52 @@ protected: virtual wxBitmap GetFrameButtonBitmap(FrameButtonType type); +#if wxUSE_SLIDER + // Fill the arguments with true or false if this slider has labels on + // left/right side (or top/bottom for horizontal sliders) respectively + static + void GetSliderLabelsSides(wxOrientation orient, long style, + bool *left, bool *right) + { + // should we draw ticks at all? + if ( !(style & wxSL_AUTOTICKS) ) + { + *left = + *right = false; + return; + } + + // should we draw them on both sides? + if ( style & wxSL_BOTH ) + { + *left = + *right = true; + return; + } + + // we draw them on one side only, determine which one + if ( ((style & wxSL_TOP) && (orient == wxHORIZONTAL)) || + ((style & wxSL_LEFT) && (orient == wxVERTICAL)) ) + { + *left = true; + *right = false; + } + else if ( ((style & wxSL_BOTTOM) && (orient == wxHORIZONTAL)) || + ((style & wxSL_RIGHT) && (orient == wxVERTICAL)) ) + { + *left = false; + *right = true; + } + else + { + wxFAIL_MSG( "inconsistent wxSlider flags" ); + + *left = + *right = false; + } + } +#endif // wxUSE_SLIDER + private: // the sizing parameters (TODO make them changeable) wxSize m_sizeScrollbarArrow; @@ -1283,6 +1330,7 @@ wxColour wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col) const case TITLEBAR_ACTIVE_TEXT: return wxColour(GetSysColor(COLOR_CAPTIONTEXT)); case DESKTOP: return wxColour(0x808000); + case FRAME: return wxColour(GetSysColor(COLOR_APPWORKSPACE)); #else // !__WXMSW__ // use the standard Windows colours elsewhere case WINDOW: return *wxWHITE; @@ -1315,13 +1363,14 @@ wxColour wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col) const case TITLEBAR_ACTIVE_TEXT:return *wxWHITE; case DESKTOP: return wxColour(0x808000); + case FRAME: return wxColour(0x808080); #endif // __WXMSW__ case GAUGE: return Get(HIGHLIGHT); case MAX: default: - wxFAIL_MSG(_T("invalid standard colour")); + wxFAIL_MSG(wxT("invalid standard colour")); return *wxBLACK; } } @@ -1561,7 +1610,7 @@ void wxWin32Renderer::DrawFrameWithLabel(wxDC& dc, int indexAccel) { wxString label2; - label2 << _T(' ') << label << _T(' '); + label2 << wxT(' ') << label << wxT(' '); if ( indexAccel != -1 ) { // adjust it as we prepended a space @@ -1720,7 +1769,7 @@ void wxWin32Renderer::DrawToolBarButton(wxDC& dc, { 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); + dc.DrawBitmap(bitmap, xpoint, ypoint, bitmap.GetMask() != NULL); } } else if (style == wxTOOL_STYLE_SEPARATOR) @@ -1780,7 +1829,7 @@ void wxWin32Renderer::DrawTab(wxDC& dc, switch ( dir ) { default: - wxFAIL_MSG(_T("invaild notebook tab orientation")); + wxFAIL_MSG(wxT("invaild notebook tab orientation")); // fall through case wxTOP: @@ -1970,21 +2019,15 @@ wxRect wxWin32Renderer::GetSliderShaftRect(const wxRect& rectOrig, wxOrientation orient, long style) const { - bool transpose = (orient == wxVERTICAL); - bool left = ((style & wxSL_AUTOTICKS) != 0) & - (((style & wxSL_TOP) != 0) & !transpose | - ((style & wxSL_LEFT) != 0) & transpose | - ((style & wxSL_BOTH) != 0)); - bool right = ((style & wxSL_AUTOTICKS) != 0) & - (((style & wxSL_BOTTOM) != 0) & !transpose | - ((style & wxSL_RIGHT) != 0) & transpose | - ((style & wxSL_BOTH) != 0)); + bool left, right; + GetSliderLabelsSides(orient, style, &left, &right); wxRect rect = rectOrig; wxSize sizeThumb = GetSliderThumbSize (rect, lenThumb, orient); - if (orient == wxHORIZONTAL) { + if (orient == wxHORIZONTAL) + { rect.x += SLIDER_MARGIN; if (left & right) { @@ -2001,8 +2044,8 @@ wxRect wxWin32Renderer::GetSliderShaftRect(const wxRect& rectOrig, rect.width -= 2*SLIDER_MARGIN; rect.height = 2*BORDER_THICKNESS; } - else - { // == wxVERTICAL + else // == wxVERTICAL + { rect.y += SLIDER_MARGIN; if (left & right) { @@ -2049,9 +2092,8 @@ void wxWin32Renderer::DrawSliderShaft(wxDC& dc, y1 y2 */ - if (flags & wxCONTROL_FOCUSED) { - DrawFocusRect(dc, rectOrig); - } + if (flags & wxCONTROL_FOCUSED) + DrawFocusRect(NULL, dc, rectOrig); wxRect rect = GetSliderShaftRect(rectOrig, lenThumb, orient, style); @@ -2095,72 +2137,70 @@ void wxWin32Renderer::DrawSliderThumb(wxDC& dc, DrawBackground(dc, wxNullColour, rect, flags); - bool transpose = (orient == wxVERTICAL); - bool left = ((style & wxSL_AUTOTICKS) != 0) & - (((style & wxSL_TOP) != 0) & !transpose | - ((style & wxSL_LEFT) != 0) & transpose) & - ((style & wxSL_BOTH) == 0); - bool right = ((style & wxSL_AUTOTICKS) != 0) & - (((style & wxSL_BOTTOM) != 0) & !transpose | - ((style & wxSL_RIGHT) != 0) & transpose) & - ((style & wxSL_BOTH) == 0); + bool left, right; + GetSliderLabelsSides(orient, style, &left, &right); + + bool isVertical = orient == wxVERTICAL; - wxCoord sizeArrow = (transpose ? rect.height : rect.width) / 2; - wxCoord c = ((transpose ? rect.height : rect.width) - 2*sizeArrow); + wxCoord sizeArrow = (isVertical ? rect.height : rect.width) / 2; + wxCoord c = ((isVertical ? rect.height : rect.width) - 2*sizeArrow); wxCoord x1, x2, x3, y1, y2, y3, y4; - x1 = (transpose ? rect.y : rect.x); - x2 = (transpose ? rect.GetBottom() : rect.GetRight()); + x1 = (isVertical ? rect.y : rect.x); + x2 = (isVertical ? rect.GetBottom() : rect.GetRight()); x3 = (x1-1+c) + sizeArrow; - y1 = (transpose ? rect.x : rect.y); - y2 = (transpose ? rect.GetRight() : rect.GetBottom()); + y1 = (isVertical ? rect.x : rect.y); + y2 = (isVertical ? rect.GetRight() : rect.GetBottom()); y3 = (left ? (y1-1+c) + sizeArrow : y1); y4 = (right ? (y2+1-c) - sizeArrow : y2); dc.SetPen(m_penBlack); - if (left) { - DrawLine(dc, x3+1-c, y1, x2, y3, transpose); + if (left) + { + DrawLine(dc, x3+1-c, y1, x2, y3, isVertical); } - DrawLine(dc, x2, y3, x2, y4, transpose); + DrawLine(dc, x2, y3, x2, y4, isVertical); if (right) { - DrawLine(dc, x3+1-c, y2, x2, y4, transpose); + DrawLine(dc, x3+1-c, y2, x2, y4, isVertical); } else { - DrawLine(dc, x1, y2, x2, y2, transpose); + DrawLine(dc, x1, y2, x2, y2, isVertical); } dc.SetPen(m_penDarkGrey); - DrawLine(dc, x2-1, y3+1, x2-1, y4-1, transpose); - if (right) { - DrawLine(dc, x3+1-c, y2-1, x2-1, y4, transpose); + DrawLine(dc, x2-1, y3+1, x2-1, y4-1, isVertical); + if (right) + { + DrawLine(dc, x3+1-c, y2-1, x2-1, y4, isVertical); } else { - DrawLine(dc, x1+1, y2-1, x2-1, y2-1, transpose); + DrawLine(dc, x1+1, y2-1, x2-1, y2-1, isVertical); } dc.SetPen(m_penHighlight); if (left) { - DrawLine(dc, x1, y3, x3, y1, transpose); - DrawLine(dc, x3+1-c, y1+1, x2-1, y3, transpose); + DrawLine(dc, x1, y3, x3, y1, isVertical); + DrawLine(dc, x3+1-c, y1+1, x2-1, y3, isVertical); } else { - DrawLine(dc, x1, y1, x2, y1, transpose); + DrawLine(dc, x1, y1, x2, y1, isVertical); } - DrawLine(dc, x1, y3, x1, y4, transpose); + DrawLine(dc, x1, y3, x1, y4, isVertical); if (right) { - DrawLine(dc, x1, y4, x3+c, y2+c, transpose); + DrawLine(dc, x1, y4, x3+c, y2+c, isVertical); } - if (flags & wxCONTROL_PRESSED) { + if (flags & wxCONTROL_PRESSED) + { // TODO: MSW fills the entire area inside, not just the rect wxRect rectInt = rect; - if ( transpose ) + if ( isVertical ) { rectInt.SetLeft(y3); rectInt.SetRight(y4); @@ -2234,55 +2274,56 @@ void wxWin32Renderer::DrawSliderTicks(wxDC& dc, */ // empty slider? - if (end == start) return; - - bool transpose = (orient == wxVERTICAL); - bool left = ((style & wxSL_AUTOTICKS) != 0) & - (((style & wxSL_TOP) != 0) & !transpose | - ((style & wxSL_LEFT) != 0) & transpose | - ((style & wxSL_BOTH) != 0)); - bool right = ((style & wxSL_AUTOTICKS) != 0) & - (((style & wxSL_BOTTOM) != 0) & !transpose | - ((style & wxSL_RIGHT) != 0) & transpose | - ((style & wxSL_BOTH) != 0)); + if ( end == start ) + return; + + bool left, right; + GetSliderLabelsSides(orient, style, &left, &right); + + bool isVertical = orient == wxVERTICAL; // default thumb size wxSize sizeThumb = GetSliderThumbSize (rect, 0, orient); - wxCoord defaultLen = (transpose ? sizeThumb.x : sizeThumb.y); + wxCoord defaultLen = (isVertical ? sizeThumb.x : sizeThumb.y); // normal thumb size sizeThumb = GetSliderThumbSize (rect, lenThumb, orient); - wxCoord widthThumb = (transpose ? sizeThumb.y : sizeThumb.x); + wxCoord widthThumb = (isVertical ? sizeThumb.y : sizeThumb.x); wxRect rectShaft = GetSliderShaftRect (rect, lenThumb, orient, style); wxCoord x1, x2, y1, y2, y3, y4 , len; - x1 = (transpose ? rectShaft.y : rectShaft.x) + widthThumb/2; - x2 = (transpose ? rectShaft.GetBottom() : rectShaft.GetRight()) - widthThumb/2; - y1 = (transpose ? rectShaft.x : rectShaft.y) - defaultLen/2; - y2 = (transpose ? rectShaft.GetRight() : rectShaft.GetBottom()) + defaultLen/2; - y3 = (transpose ? rect.x : rect.y); - y4 = (transpose ? rect.GetRight() : rect.GetBottom()); + x1 = (isVertical ? rectShaft.y : rectShaft.x) + widthThumb/2; + x2 = (isVertical ? rectShaft.GetBottom() : rectShaft.GetRight()) - widthThumb/2; + y1 = (isVertical ? rectShaft.x : rectShaft.y) - defaultLen/2; + y2 = (isVertical ? rectShaft.GetRight() : rectShaft.GetBottom()) + defaultLen/2; + y3 = (isVertical ? rect.x : rect.y); + y4 = (isVertical ? rect.GetRight() : rect.GetBottom()); len = x2 - x1; dc.SetPen(m_penBlack); int range = end - start; - for ( int n = 0; n < range; n += step ) { + for ( int n = 0; n < range; n += step ) + { wxCoord x = x1 + (len*n) / range; - if (left & (y1 > y3)) { + if (left & (y1 > y3)) + { DrawLine(dc, x, y1, x, y3, orient == wxVERTICAL); } - if (right & (y4 > y2)) { + if (right & (y4 > y2)) + { DrawLine(dc, x, y2, x, y4, orient == wxVERTICAL); } } // always draw the line at the end position - if (left & (y1 > y3)) { + if (left & (y1 > y3)) + { DrawLine(dc, x2, y1, x2, y3, orient == wxVERTICAL); } - if (right & (y4 > y2)) { + if (right & (y4 > y2)) + { DrawLine(dc, x2, y2, x2, y4, orient == wxVERTICAL); } } @@ -2502,7 +2543,7 @@ wxMenuGeometryInfo *wxWin32Renderer::GetMenuGeometry(wxWindow *win, h = heightText; wxCoord widthLabel; - dc.GetTextExtent(item->GetLabel(), &widthLabel, NULL); + dc.GetTextExtent(item->GetItemLabelText(), &widthLabel, NULL); if ( widthLabel > widthLabelMax ) { widthLabelMax = widthLabel; @@ -2774,7 +2815,7 @@ void wxWin32Renderer::DrawScrollbarShaft(wxDC& dc, // ---------------------------------------------------------------------------- /* Copyright (c) Julian Smart */ -static char *error_xpm[]={ +static const char *error_xpm[]={ /* columns rows colors chars-per-pixel */ "32 32 70 1", "- c #BF0101", @@ -2883,7 +2924,7 @@ static char *error_xpm[]={ }; /* Copyright (c) Julian Smart */ -static char *info_xpm[]={ +static const char *info_xpm[]={ /* columns rows colors chars-per-pixel */ "32 32 17 1", "* c #A1A3FB", @@ -2939,7 +2980,7 @@ static char *info_xpm[]={ }; /* Copyright (c) Julian Smart */ -static char *question_xpm[]={ +static const char *question_xpm[]={ /* columns rows colors chars-per-pixel */ "32 32 16 1", "O c #A3A3FF", @@ -2994,7 +3035,7 @@ static char *question_xpm[]={ }; /* Copyright (c) Julian Smart */ -static char *warning_xpm[]={ +static const char *warning_xpm[]={ /* columns rows colors chars-per-pixel */ "32 32 9 1", "@ c Black", @@ -3193,10 +3234,9 @@ bool wxWin32InputHandler::HandleMouse(wxInputConsumer *control, // clicking on the control gives it focus if ( event.ButtonDown() ) { - wxWindow *win = control->GetInputWindow(); + wxWindow * const win = control->GetInputWindow(); - if ( (wxWindow::FindFocus() != control->GetInputWindow()) && - win->AcceptsFocus() ) + if ( win->CanAcceptFocus() && wxWindow::FindFocus() != win ) { win->SetFocus(); @@ -3229,13 +3269,11 @@ bool wxWin32ScrollBarInputHandler::OnScrollTimer(wxScrollBar *scrollbar, bool stop = false; if ( action == wxACTION_SCROLL_PAGE_DOWN ) { - stop = m_renderer->HitTestScrollbar(scrollbar, m_ptStartScrolling) - != wxHT_SCROLLBAR_BAR_2; + stop = scrollbar->HitTestBar(m_ptStartScrolling) != wxHT_SCROLLBAR_BAR_2; } else if ( action == wxACTION_SCROLL_PAGE_UP ) { - stop = m_renderer->HitTestScrollbar(scrollbar, m_ptStartScrolling) - != wxHT_SCROLLBAR_BAR_1; + stop = scrollbar->HitTestBar(m_ptStartScrolling) != wxHT_SCROLLBAR_BAR_1; } if ( stop ) @@ -3297,7 +3335,7 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control, return false; } - ht = m_renderer->HitTestScrollbar(scrollbar, event.GetPosition()); + ht = scrollbar->HitTestBar(event.GetPosition()); if ( ht == m_htLast ) { // yes it did, resume scrolling @@ -3327,7 +3365,7 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control, // Always let thumb jump back if we leave the scrollbar if ( event.Moving() ) { - ht = m_renderer->HitTestScrollbar(scrollbar, event.GetPosition()); + ht = scrollbar->HitTestBar(event.GetPosition()); } else // event.Leaving() { @@ -3346,7 +3384,7 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control, if (pos.y > -40 && pos.y < scrollbar->GetSize().y+40) pos.y = 5; } - ht = m_renderer->HitTestScrollbar(scrollbar, pos ); + ht = scrollbar->HitTestBar(pos); #endif // if we're dragging the thumb and the mouse stays in the scrollbar, it @@ -3502,7 +3540,7 @@ bool wxWin32StatusBarInputHandler::IsOnGrip(wxWindow *statbar, parentTLW = wxDynamicCast(statbar->GetParent(), wxTopLevelWindow); wxCHECK_MSG( parentTLW, false, - _T("the status bar should be a child of a TLW") ); + wxT("the status bar should be a child of a TLW") ); // a maximized window can't be resized anyhow if ( !parentTLW->IsMaximized() ) @@ -3610,7 +3648,7 @@ wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler *handler) void wxWin32SystemMenuEvtHandler::Attach(wxInputConsumer *consumer) { - wxASSERT_MSG( m_wnd == NULL, _T("can't attach the handler twice!") ); + wxASSERT_MSG( m_wnd == NULL, wxT("can't attach the handler twice!") ); m_wnd = wxStaticCast(consumer->GetInputWindow(), wxTopLevelWindow); m_wnd->PushEventHandler(this);