1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/ownerdrwcmn.cpp
3 // Purpose: wxOwnerDrawn class methods common to all platforms
4 // Author: Marcin Malich
7 // Copyright: (c) 2009 Marcin Malich <me@malcom.pl>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
28 #include "wx/ownerdrw.h"
31 #include "wx/window.h"
33 #include "wx/colour.h"
34 #include "wx/dcmemory.h"
35 #include "wx/settings.h"
39 // ============================================================================
41 // ============================================================================
43 bool wxOwnerDrawnBase::OnMeasureItem(size_t *width
, size_t *height
)
52 // item name/text without mnemonics
53 wxString name
= wxStripMenuCodes(GetName(), wxStrip_Mnemonics
);
56 dc
.GetTextExtent(name
, &w
, &h
);
58 *width
= w
+ m_margin
;
70 void wxOwnerDrawnBase::GetFontToUse(wxFont
& font
) const
72 font
= m_font
.IsOk() ? m_font
: *wxNORMAL_FONT
;
75 void wxOwnerDrawnBase::GetColourToUse(wxODStatus stat
, wxColour
& colText
, wxColour
& colBack
) const
77 if ( stat
& wxODSelected
)
79 colText
= wxSystemSettings::GetColour(
80 !(stat
& wxODDisabled
) ? wxSYS_COLOUR_HIGHLIGHTTEXT
81 : wxSYS_COLOUR_GRAYTEXT
);
83 colBack
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
87 // fall back to default colors if none explicitly specified
89 if ( stat
& wxODDisabled
)
91 colText
= wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
);
95 colText
= m_colText
.IsOk() ? m_colText
96 : wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT
);
99 colBack
= m_colBack
.IsOk() ? m_colBack
100 : wxSystemSettings::GetColour(wxSYS_COLOUR_MENU
);
104 #endif // wxUSE_OWNER_DRAWN