Layout() always called when editor/viewer control changes size

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@145 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-12-22 15:33:14 +00:00
parent 274cb1117f
commit a16c098eac
10 changed files with 41 additions and 35 deletions
+14
View File
@@ -10,6 +10,10 @@
#include <data/stylesheet.hpp>
#include <wx/dcbuffer.h>
// ----------------------------------------------------------------------------- : Events
DEFINE_EVENT_TYPE(EVENT_SIZE_CHANGE);
// ----------------------------------------------------------------------------- : CardViewer
CardViewer::CardViewer(Window* parent, int id, long style)
@@ -30,6 +34,16 @@ void CardViewer::onChange() {
up_to_date = false;
}
void CardViewer::onChangeSize() {
wxSize ws = GetSize(), cs = GetClientSize();
wxSize desired_cs = (wxSize)getRotation().getExternalSize() + ws - cs;
if (desired_cs != cs) {
wxCommandEvent ev(EVENT_SIZE_CHANGE, GetId());
ProcessEvent(ev);
}
}
#ifdef _DEBUG
DECLARE_DYNAMIC_ARG(bool, inOnPaint);
IMPLEMENT_DYNAMIC_ARG(bool, inOnPaint, false);
+8
View File
@@ -12,6 +12,13 @@
#include <util/prec.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : Events
/// Event that indicates the size of a CardViewer has changed
DECLARE_EVENT_TYPE(EVENT_SIZE_CHANGE, <not used>)
/// Handle EVENT_SIZE_CHANGE events
#define EVT_SIZE_CHANGE(id, handler) EVT_COMMAND(id, EVENT_SIZE_CHANGE, handler)
// ----------------------------------------------------------------------------- : CardViewer
/// A control to view a single card
@@ -28,6 +35,7 @@ class CardViewer : public wxControl, public DataViewer {
virtual wxSize DoGetBestSize() const;
virtual void onChange();
virtual void onChangeSize();
private:
DECLARE_EVENT_TABLE();