mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
redrawing of editors (for drop down lists)
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@155 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <gui/control/card_viewer.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <render/value/viewer.hpp>
|
||||
#include <wx/dcbuffer.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
@@ -29,9 +30,14 @@ wxSize CardViewer::DoGetBestSize() const {
|
||||
return cs;
|
||||
}
|
||||
|
||||
void CardViewer::onChange() {
|
||||
Refresh(false);
|
||||
void CardViewer::redraw(const ValueViewer& v) {
|
||||
up_to_date = false;
|
||||
RefreshRect(v.boundingBox(), false);
|
||||
}
|
||||
|
||||
void CardViewer::onChange() {
|
||||
up_to_date = false;
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void CardViewer::onChangeSize() {
|
||||
@@ -43,7 +49,6 @@ void CardViewer::onChangeSize() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
DECLARE_DYNAMIC_ARG(bool, inOnPaint);
|
||||
IMPLEMENT_DYNAMIC_ARG(bool, inOnPaint, false);
|
||||
@@ -61,6 +66,7 @@ void CardViewer::onPaint(wxPaintEvent&) {
|
||||
up_to_date = false;
|
||||
}
|
||||
wxBufferedPaintDC dc(this, buffer);
|
||||
dc.SetClippingRegion(GetUpdateRegion());
|
||||
if (!up_to_date) {
|
||||
up_to_date = true;
|
||||
dc.BeginDrawing();
|
||||
@@ -69,6 +75,14 @@ void CardViewer::onPaint(wxPaintEvent&) {
|
||||
}
|
||||
}
|
||||
|
||||
void CardViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
if (shouldDraw(v)) v.draw(dc);
|
||||
}
|
||||
|
||||
bool CardViewer::shouldDraw(const ValueViewer& v) const {
|
||||
return GetUpdateRegion().Contains((wxRect)v.boundingBox()) != wxOutRegion;
|
||||
}
|
||||
|
||||
// helper class for overdrawDC()
|
||||
class CardViewer::OverdrawDC : private wxClientDC, public wxBufferedDC {
|
||||
public:
|
||||
|
||||
@@ -30,6 +30,9 @@ class CardViewer : public wxControl, public DataViewer {
|
||||
/** May NOT be called while in onPaint/draw */
|
||||
shared_ptr<DC> overdrawDC();
|
||||
|
||||
/// Invalidate and redraw (the area of) a single value viewer
|
||||
void redraw(const ValueViewer&);
|
||||
|
||||
protected:
|
||||
/// Return the desired size of control
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
@@ -37,6 +40,11 @@ class CardViewer : public wxControl, public DataViewer {
|
||||
virtual void onChange();
|
||||
virtual void onChangeSize();
|
||||
|
||||
/// Should the given viewer be drawn?
|
||||
bool shouldDraw(const ValueViewer&) const;
|
||||
|
||||
virtual void drawViewer(RotatedDC& dc, ValueViewer& v);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ void NativeLookEditor::draw(DC& dc) {
|
||||
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
}
|
||||
void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
if (!shouldDraw(v)) return;
|
||||
// draw background
|
||||
Style& s = *v.getStyle();
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
|
||||
@@ -29,10 +29,6 @@ void TextCtrl::draw(DC& dc) {
|
||||
RotatedDC rdc(dc, getRotation(), false);
|
||||
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
}
|
||||
void TextCtrl::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
// draw viewer
|
||||
v.draw(dc);
|
||||
}
|
||||
|
||||
|
||||
void TextCtrl::setValue(String* value) {
|
||||
|
||||
@@ -38,7 +38,6 @@ class TextCtrl : public DataEditor {
|
||||
virtual Rotation getRotation() const;
|
||||
|
||||
virtual void draw(DC& dc);
|
||||
virtual void drawViewer(RotatedDC& dc, ValueViewer& v);
|
||||
|
||||
/// When an action is received, change the underlying value
|
||||
virtual void onAction(const Action&, bool undone);
|
||||
|
||||
Reference in New Issue
Block a user