From b8b07fd80a40c96a0f38e3601b14eda905eae470 Mon Sep 17 00:00:00 2001 From: twanvl Date: Tue, 7 Dec 2010 22:01:44 +0000 Subject: [PATCH] * compatibility with wxWdigets 2.9+: use HandleWindowEvent instead of ProcessEvent * overload wxEVT_ERASE_BACKGROUND, to reduce flicker * use wxBORDER_THEME for custom controls * tweaked style of GalleryList a tiny bit git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1558 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/control/gallery_list.cpp | 9 +++++---- src/gui/control/gallery_list.hpp | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/control/gallery_list.cpp b/src/gui/control/gallery_list.cpp index eca89abc..60456bc2 100644 --- a/src/gui/control/gallery_list.cpp +++ b/src/gui/control/gallery_list.cpp @@ -21,7 +21,7 @@ DEFINE_EVENT_TYPE(EVENT_GALLERY_ACTIVATE); // ----------------------------------------------------------------------------- : GalleryList GalleryList::GalleryList(Window* parent, int id, int direction, bool always_focused) - : wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxWANTS_CHARS | (direction == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL) ) + : wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME | wxWANTS_CHARS | (direction == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL) ) , active_subcolumn(0) , direction(direction) , column_count(1) @@ -247,7 +247,7 @@ void GalleryList::onChar(wxKeyEvent& ev) { // we need this because tabs of wxWANTS_CHARS wxNavigationKeyEvent nev; nev.SetDirection(!ev.ShiftDown()); - GetParent()->ProcessEvent(nev); + GetParent()->HandleWindowEvent(nev); } break; case WXK_RETURN: { // same thing: press dialog box default button @@ -256,7 +256,7 @@ void GalleryList::onChar(wxKeyEvent& ev) { if ( btn && btn->IsEnabled() ) { // if we do have a default button, do press it wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, btn->GetId()); - btn->ProcessEvent(evt); + btn->HandleWindowEvent(evt); } }break; @@ -309,7 +309,7 @@ void GalleryList::OnDraw(DC& dc) { ) : unselected; dc.SetPen(c); - dc.SetBrush(saturate(lerp(background, c, 0.3), selected ? 0.5 : 0)); + dc.SetBrush(lerp(background, c, 0.3)); dc.DrawRectangle(pos.x + col.offset.x - BORDER, pos.y + col.offset.y - BORDER, col.size.x + 2*BORDER, col.size.y + 2*BORDER); } @@ -339,4 +339,5 @@ BEGIN_EVENT_TABLE(GalleryList, wxPanel) EVT_PAINT (GalleryList::onPaint) EVT_SIZE (GalleryList::onSize) EVT_SCROLLWIN (GalleryList::onScroll) + EVT_ERASE_BACKGROUND(GalleryList::onEraseBackground) END_EVENT_TABLE () diff --git a/src/gui/control/gallery_list.hpp b/src/gui/control/gallery_list.hpp index d2b1a518..39d701d2 100644 --- a/src/gui/control/gallery_list.hpp +++ b/src/gui/control/gallery_list.hpp @@ -92,6 +92,7 @@ class GalleryList : public wxPanel { void onChar(wxKeyEvent& ev); void onFocus(wxFocusEvent&); void onPaint(wxPaintEvent&); + void onEraseBackground(wxEraseEvent&) {} void onSize(wxSizeEvent&); void onScroll(wxScrollWinEvent&); void OnDraw(DC& dc); @@ -133,7 +134,7 @@ class GalleryList : public wxPanel { void sendEvent(WXTYPE type); static const int MARGIN = 1; // margin between items (excluding border) - static const int BORDER = 1; // border aroung items + static const int BORDER = 0; // border around items static const int SPACING = MARGIN + 2*BORDER; // distance between items };