1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/ownerdrwcmn.cpp
3 // Purpose: wxOwnerDrawn class methods common to all platforms
4 // Author: Marcin Malich
8 // Copyright: (c) 2009 Marcin Malich <me@malcom.pl>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/ownerdrw.h"
32 #include "wx/window.h"
34 #include "wx/colour.h"
35 #include "wx/dcmemory.h"
36 #include "wx/settings.h"
40 // ============================================================================
42 // ============================================================================
44 bool wxOwnerDrawnBase::OnMeasureItem(size_t *width
, size_t *height
)
53 // item name/text without mnemonics
54 wxString name
= wxStripMenuCodes(GetName(), wxStrip_Mnemonics
);
57 dc
.GetTextExtent(name
, &w
, &h
);
59 *width
= w
+ m_margin
;
71 void wxOwnerDrawnBase::GetFontToUse(wxFont
& font
) const
73 font
= m_font
.IsOk() ? m_font
: *wxNORMAL_FONT
;
76 void wxOwnerDrawnBase::GetColourToUse(wxODStatus stat
, wxColour
& colText
, wxColour
& colBack
) const
78 if ( stat
& wxODSelected
)
80 colText
= wxSystemSettings::GetColour(
81 !(stat
& wxODDisabled
) ? wxSYS_COLOUR_HIGHLIGHTTEXT
82 : wxSYS_COLOUR_GRAYTEXT
);
84 colBack
= wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT
);
88 // fall back to default colors if none explicitly specified
90 if ( stat
& wxODDisabled
)
92 colText
= wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
);
96 colText
= m_colText
.IsOk() ? m_colText
97 : wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT
);
100 colBack
= m_colBack
.IsOk() ? m_colBack
101 : wxSystemSettings::GetColour(wxSYS_COLOUR_MENU
);
105 #endif // wxUSE_OWNER_DRAWN