From 70471251e4a2eff3490b62217e99394740663002 Mon Sep 17 00:00:00 2001 From: twanvl Date: Tue, 7 Dec 2010 23:01:19 +0000 Subject: [PATCH] draw fancy windows explorer style selection rectangles git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1567 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/util.cpp | 26 ++++++++++++++++++++++++++ src/gui/util.hpp | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/gui/util.cpp b/src/gui/util.cpp index 07605b21..c3f7b1d0 100644 --- a/src/gui/util.cpp +++ b/src/gui/util.cpp @@ -338,3 +338,29 @@ void draw_radiobox(Window* win, DC& dc, const wxRect& rect, bool checked, bool e } #endif } + +void draw_selection_rectangle(Window* win, DC& dc, const wxRect& rect, bool selected, bool focused, bool hot) { + #if wxUSE_UXTHEME && defined(__WXMSW__) + wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get(); + if (themeEngine && themeEngine->IsAppThemed()) { + wxUxThemeHandle hTheme(win, L"LISTVIEW"); + RECT r; + r.left = rect.x; + r.top = rect.y; + r.right = rect.x + rect.width; + r.bottom = rect.y + rect.height; + if (hTheme) { + wxUxThemeEngine::Get()->SetWindowTheme((HWND)win->GetHWND(), L"Explorer", NULL); + wxUxThemeEngine::Get()->DrawThemeBackground( + (HTHEME)hTheme, + (HDC)dc.GetHDC(), + LVP_LISTITEM, + hot&&selected ? LISS_HOTSELECTED : hot ? LISS_HOT :selected&&focused ? LISS_SELECTED : selected ? LISS_SELECTEDNOTFOCUS : LISS_NORMAL, + &r, + NULL + ); + return; + } + } + #endif +} diff --git a/src/gui/util.hpp b/src/gui/util.hpp index db8c3ce2..3f7572df 100644 --- a/src/gui/util.hpp +++ b/src/gui/util.hpp @@ -75,5 +75,8 @@ void draw_checkbox(Window* win, DC& dc, const wxRect& rect, bool checked, bool e /// Draws a radio button void draw_radiobox(Window* win, DC& dc, const wxRect& rect, bool checked, bool enabled = true); +/// Draws a (fancy) selection rectangle +void draw_selection_rectangle(Window* win, DC& dc, const wxRect& rect, bool selected = true, bool focused = true, bool hot = false); + // ----------------------------------------------------------------------------- : EOF #endif