X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8cb172b4f12fae80b06d5936108a1bc7f2521674..850ed6e7b0aa954018746242a867038ede62481f:/src/univ/themes/gtk.cpp diff --git a/src/univ/themes/gtk.cpp b/src/univ/themes/gtk.cpp index 47f7749cc2..23f371ec8e 100644 --- a/src/univ/themes/gtk.cpp +++ b/src/univ/themes/gtk.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 06.08.00 // RCS-ID: $Id$ -// Copyright: (c) 2000 Vadim Zeitlin +// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows license /////////////////////////////////////////////////////////////////////////////// @@ -30,6 +30,7 @@ #include "wx/dcmemory.h" #include "wx/window.h" + #include "wx/bmpbuttn.h" #include "wx/button.h" #include "wx/checkbox.h" #include "wx/listbox.h" @@ -186,6 +187,7 @@ public: // we don't have the ticks in GTK version } +#if wxUSE_MENUS virtual void DrawMenuBarItem(wxDC& dc, const wxRect& rect, const wxString& label, @@ -202,8 +204,9 @@ public: virtual void DrawMenuSeparator(wxDC& dc, wxCoord y, const wxMenuGeometryInfo& geomInfo); - +#endif virtual void GetComboBitmaps(wxBitmap *bmpNormal, + wxBitmap *bmpFocus, wxBitmap *bmpPressed, wxBitmap *bmpDisabled); @@ -248,11 +251,12 @@ public: virtual wxSize GetSliderThumbSize(const wxRect& rect, wxOrientation orient) const; virtual wxSize GetProgressBarStep() const { return wxSize(16, 32); } +#if wxUSE_MENUS virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const; virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win, const wxMenu& menu) const; - +#endif // helpers for "wxBitmap wxColourScheme::Get()" void DrawCheckBitmap(wxDC& dc, const wxRect& rect); void DrawUncheckBitmap(wxDC& dc, const wxRect& rect, bool isPressed); @@ -368,6 +372,9 @@ protected: wxAlignment align, int indexAccel); + // initialize the combo bitmaps + void InitComboBitmaps(); + private: const wxColourScheme *m_scheme; @@ -388,6 +395,18 @@ private: // the line wrap bitmap (drawn at the end of wrapped lines) wxBitmap m_bmpLineWrap; + + // the combobox bitmaps + enum + { + ComboState_Normal, + ComboState_Focus, + ComboState_Pressed, + ComboState_Disabled, + ComboState_Max + }; + + wxBitmap m_bitmapsCombo[ComboState_Max]; }; // ---------------------------------------------------------------------------- @@ -847,7 +866,10 @@ void wxGTKRenderer::DrawBorder(wxDC& dc, break; case wxBORDER_STATIC: - DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); + for ( width = 0; width < BORDER_THICKNESS; width++ ) + { + DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); + } break; case wxBORDER_RAISED: @@ -858,13 +880,19 @@ void wxGTKRenderer::DrawBorder(wxDC& dc, break; case wxBORDER_DOUBLE: - DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack); - DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey); - DrawRect(dc, &rect, m_penLightGrey); + 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: - DrawRect(dc, &rect, m_penBlack); + for ( width = 0; width < BORDER_THICKNESS; width++ ) + { + DrawRect(dc, &rect, m_penBlack); + } break; default: @@ -892,11 +920,11 @@ wxRect wxGTKRenderer::GetBorderDimensions(wxBorder border) const case wxBORDER_SIMPLE: case wxBORDER_STATIC: - width = 1; + width = BORDER_THICKNESS; break; case wxBORDER_DOUBLE: - width = 3; + width = 3*BORDER_THICKNESS; break; default: @@ -936,15 +964,18 @@ void wxGTKRenderer::DrawTextBorder(wxDC& dc, { wxRect rect = rectOrig; - if ( flags & wxCONTROL_FOCUSED ) - { - DrawRect(dc, &rect, m_penBlack); - DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); - } - else // !focused + if ( border != wxBORDER_NONE ) { - DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); - DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight); + if ( flags & wxCONTROL_FOCUSED ) + { + DrawRect(dc, &rect, m_penBlack); + DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); + } + else // !focused + { + DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); + DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight); + } } if ( rectIn ) @@ -962,8 +993,12 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc, { // button pressed: draw a black border around it and an inward shade DrawRect(dc, &rect, m_penBlack); - DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); - DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey); + + for ( size_t width = 0; width < BORDER_THICKNESS; width++ ) + { + DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); + DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey); + } } else { @@ -981,10 +1016,13 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc, } // now draw a normal button - DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack); - DrawAntiShadedRect(dc, &rect, - wxPen(GetBackgroundColour(flags), 0, wxSOLID), - m_penDarkGrey); + 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); + } } if ( rectIn ) @@ -1458,7 +1496,7 @@ wxRect wxGTKRenderer::GetTextTotalArea(const wxTextCtrl *text, const wxRect& rect) { wxRect rectTotal = rect; - rectTotal.Inflate(2); + rectTotal.Inflate(2*BORDER_THICKNESS); return rectTotal; } @@ -1467,7 +1505,7 @@ wxRect wxGTKRenderer::GetTextClientArea(const wxTextCtrl *text, wxCoord *extraSpaceBeyond) { wxRect rectText = rect; - rectText.Inflate(-2); + rectText.Inflate(-2*BORDER_THICKNESS); if ( text->WrapLines() ) { @@ -1743,6 +1781,7 @@ void wxGTKRenderer::DrawSliderThumb(wxDC& dc, DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight); } +#if wxUSE_MENUS // ---------------------------------------------------------------------------- // menu and menubar // ---------------------------------------------------------------------------- @@ -1787,16 +1826,64 @@ wxMenuGeometryInfo *wxGTKRenderer::GetMenuGeometry(wxWindow *win, return NULL; } +#endif // wxUSE_MENUS // ---------------------------------------------------------------------------- // combobox // ---------------------------------------------------------------------------- +void wxGTKRenderer::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(wxPoint(0, 0), 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 wxGTKRenderer::GetComboBitmaps(wxBitmap *bmpNormal, + wxBitmap *bmpFocus, wxBitmap *bmpPressed, wxBitmap *bmpDisabled) { - // TODO + 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]; } // ---------------------------------------------------------------------------- @@ -2211,20 +2298,30 @@ int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window) { - if ( wxDynamicCast(window, wxButton) ) +#if wxUSE_BMPBUTTON + if ( wxDynamicCast(window, wxBitmapButton) ) { - // TODO: this is ad hoc... - size->x += 3*window->GetCharWidth(); - if ( size->x < 80 ) - size->x = 80; - wxCoord minBtnHeight = 22; - if ( size->y < minBtnHeight ) - size->y = minBtnHeight; - - // button border width + size->x += 4; size->y += 4; - } - else if ( wxDynamicCast(window, wxScrollBar) ) + } else +#endif // wxUSE_BMPBUTTON +#if wxUSE_BUTTON + if ( wxDynamicCast(window, wxButton) ) + { + 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 + if ( wxDynamicCast(window, wxScrollBar) ) { // we only set the width of vert scrollbars and height of the // horizontal ones