don't use GetThemeMetric(HP_HEADERITEM, TMT_HEIGHT) as it doesn't seem to work; implement GetHeaderButtonHeight() in wxRendererMSW instead of doing it in wxRendererXP using HDM_LAYOUT; added test for this renderer method to the sample
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48535 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -133,8 +133,10 @@ public:
|
|||||||
dc.DrawText(_T("Below is the standard header button drawn"), 10, 10);
|
dc.DrawText(_T("Below is the standard header button drawn"), 10, 10);
|
||||||
dc.DrawText(_T("using the current renderer:"), 10, 40);
|
dc.DrawText(_T("using the current renderer:"), 10, 40);
|
||||||
|
|
||||||
wxRendererNative::Get().DrawHeaderButton(this, dc,
|
wxRendererNative& renderer = wxRendererNative::Get();
|
||||||
wxRect(20, 70, 100, 60));
|
const wxCoord height = renderer.GetHeaderButtonHeight(this);
|
||||||
|
|
||||||
|
renderer.DrawHeaderButton(this, dc, wxRect(20, 70, 100, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#endif //WX_PRECOMP
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
|
#include "wx/scopeguard.h"
|
||||||
#include "wx/splitter.h"
|
#include "wx/splitter.h"
|
||||||
#include "wx/renderer.h"
|
#include "wx/renderer.h"
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
@@ -115,7 +116,13 @@ public:
|
|||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
|
|
||||||
virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
|
virtual void DrawFocusRect(wxWindow* win,
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0);
|
||||||
|
|
||||||
|
virtual int GetHeaderButtonHeight(wxWindow *win);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_NO_COPY_CLASS(wxRendererMSW)
|
DECLARE_NO_COPY_CLASS(wxRendererMSW)
|
||||||
};
|
};
|
||||||
@@ -139,7 +146,6 @@ public:
|
|||||||
int flags = 0,
|
int flags = 0,
|
||||||
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
|
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
|
||||||
wxHeaderButtonParams* params = NULL);
|
wxHeaderButtonParams* params = NULL);
|
||||||
virtual int GetHeaderButtonHeight(wxWindow *win);
|
|
||||||
|
|
||||||
virtual void DrawTreeItemButton(wxWindow *win,
|
virtual void DrawTreeItemButton(wxWindow *win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
@@ -277,7 +283,10 @@ wxRendererMSW::DrawPushButton(wxWindow * WXUNUSED(win),
|
|||||||
::DrawFrameControl(GetHdcOf(dc), &rc, DFC_BUTTON, style);
|
::DrawFrameControl(GetHdcOf(dc), &rc, DFC_BUTTON, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRendererMSW::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags))
|
void wxRendererMSW::DrawFocusRect(wxWindow * WXUNUSED(win),
|
||||||
|
wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int WXUNUSED(flags))
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
wxCopyRectToRECT(rect, rc);
|
wxCopyRectToRECT(rect, rc);
|
||||||
@@ -285,6 +294,29 @@ void wxRendererMSW::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRec
|
|||||||
::DrawFocusRect(GetHdcOf(dc), &rc);
|
::DrawFocusRect(GetHdcOf(dc), &rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wxRendererMSW::GetHeaderButtonHeight(wxWindow * WXUNUSED(win))
|
||||||
|
{
|
||||||
|
// some "reasonable" value returned in case of error, it doesn't really
|
||||||
|
// correspond to anything but it's better than returning 0
|
||||||
|
static const int DEFAULT_HEIGHT = 20;
|
||||||
|
|
||||||
|
|
||||||
|
// create a temporary header window just to get its geometry
|
||||||
|
HWND hwndHeader = ::CreateWindow(WC_HEADER, NULL, NULL,
|
||||||
|
0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
||||||
|
if ( !hwndHeader )
|
||||||
|
return DEFAULT_HEIGHT;
|
||||||
|
|
||||||
|
wxON_BLOCK_EXIT1( ::DestroyWindow, hwndHeader );
|
||||||
|
|
||||||
|
// initialize the struct filled with the values by Header_Layout()
|
||||||
|
RECT parentRect = { 0, 0, 100, 100 };
|
||||||
|
WINDOWPOS wp = { 0 };
|
||||||
|
HDLAYOUT hdl = { &parentRect, &wp };
|
||||||
|
|
||||||
|
return Header_Layout(hwndHeader, &hdl) ? wp.cy : DEFAULT_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxRendererXP implementation
|
// wxRendererXP implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -383,31 +415,6 @@ wxRendererXP::DrawHeaderButton(wxWindow *win,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
wxRendererXP::GetHeaderButtonHeight(wxWindow *win)
|
|
||||||
{
|
|
||||||
wxUxThemeHandle hTheme(win, L"HEADER");
|
|
||||||
if ( !hTheme )
|
|
||||||
{
|
|
||||||
return m_rendererNative.GetHeaderButtonHeight(win);
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT hr;
|
|
||||||
int value = -1;
|
|
||||||
|
|
||||||
hr = wxUxThemeEngine::Get()->GetThemeMetric( hTheme,
|
|
||||||
NULL,
|
|
||||||
HP_HEADERITEM,
|
|
||||||
HIS_NORMAL,
|
|
||||||
TMT_HEIGHT,
|
|
||||||
&value );
|
|
||||||
if ( hr == S_OK )
|
|
||||||
return value;
|
|
||||||
else
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wxRendererXP::DrawTreeItemButton(wxWindow *win,
|
wxRendererXP::DrawTreeItemButton(wxWindow *win,
|
||||||
wxDC& dc,
|
wxDC& dc,
|
||||||
|
Reference in New Issue
Block a user