mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Cleaned up handling of what things should be drawn by using the DrawWhat enumeration type.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1072 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -39,26 +39,24 @@ ValueViewerP DataEditor::makeViewer(const StyleP& style) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utility for ValueViewers
|
||||
|
||||
bool DataEditor::drawBorders() const {
|
||||
return !nativeLook() &&
|
||||
settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_borders();
|
||||
}
|
||||
bool DataEditor::drawEditing() const {
|
||||
return nativeLook() ||
|
||||
settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_draw_editing();
|
||||
}
|
||||
bool DataEditor::drawFocus() const {
|
||||
return FindFocus() == this;
|
||||
DrawWhat DataEditor::drawWhat(const ValueViewer* viewer) const {
|
||||
int what = DRAW_NORMAL
|
||||
| DRAW_ACTIVE * viewerIsCurrent(viewer);
|
||||
if (nativeLook()) {
|
||||
what |= DRAW_BOXES | DRAW_EDITING | DRAW_NATIVELOOK;
|
||||
} else {
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(set->stylesheetFor(card));
|
||||
what |= DRAW_BORDERS * ss.card_borders()
|
||||
| (DRAW_BOXES | DRAW_EDITING) * ss.card_draw_editing()
|
||||
| DRAW_ERRORS;
|
||||
}
|
||||
return (DrawWhat)what;
|
||||
}
|
||||
|
||||
wxPen DataEditor::borderPen(bool active) const {
|
||||
return active ? wxPen(Color(0,128,255), 1, wxSOLID)
|
||||
: wxPen(Color(128,128,128), 1, wxDOT);
|
||||
bool DataEditor::viewerIsCurrent(const ValueViewer* viewer) const {
|
||||
return viewer == current_viewer && FindFocus() == this;
|
||||
}
|
||||
|
||||
ValueViewer* DataEditor::focusedViewer() const {
|
||||
return FindFocus() == this ? current_viewer : nullptr;
|
||||
}
|
||||
|
||||
void DataEditor::addAction(Action* action) {
|
||||
set->actions.addAction(action);
|
||||
|
||||
@@ -24,11 +24,8 @@ class DataEditor : public CardViewer {
|
||||
|
||||
// --------------------------------------------------- : Utility for ValueViewers/Editors
|
||||
|
||||
virtual bool drawBorders() const;
|
||||
virtual bool drawEditing() const;
|
||||
virtual bool drawFocus() const;
|
||||
virtual wxPen borderPen(bool active) const;
|
||||
virtual ValueViewer* focusedViewer() const;
|
||||
virtual DrawWhat drawWhat(const ValueViewer*) const;
|
||||
virtual bool viewerIsCurrent(const ValueViewer*) const;
|
||||
|
||||
virtual void addAction(Action* action);
|
||||
inline SetP getSetForActions() { return set; }
|
||||
|
||||
@@ -23,7 +23,6 @@ class NativeLookEditor : public DataEditor {
|
||||
|
||||
/// Uses a native look
|
||||
virtual bool nativeLook() const { return true; }
|
||||
virtual bool drawBorders() const { return false; }
|
||||
virtual Rotation getRotation() const;
|
||||
|
||||
virtual void draw(DC& dc);
|
||||
|
||||
@@ -50,7 +50,6 @@ class TextCtrl : public DataEditor {
|
||||
|
||||
/// Uses a native look
|
||||
virtual bool nativeLook() const { return true; }
|
||||
virtual bool drawBorders() const { return false; }
|
||||
virtual Rotation getRotation() const;
|
||||
|
||||
virtual void draw(DC& dc);
|
||||
|
||||
@@ -1318,7 +1318,8 @@ void TextValueEditor::redrawWordListIndicators(bool toggling_dropdown) {
|
||||
|
||||
void TextValueEditor::drawWordListIndicators(RotatedDC& dc, bool redrawing) {
|
||||
if (word_lists.empty()) return;
|
||||
bool current = isCurrent();
|
||||
DrawWhat what = viewer.drawWhat(this);
|
||||
bool current = what & DRAW_ACTIVE;
|
||||
// Draw lines around fields
|
||||
FOR_EACH(wl, word_lists) {
|
||||
RealRect& r = wl->rect;
|
||||
@@ -1345,7 +1346,7 @@ void TextValueEditor::drawWordListIndicators(RotatedDC& dc, bool redrawing) {
|
||||
if (!redrawing) {
|
||||
wl->behind = dc.GetBackground(RealRect(r.right(), r.top() - 1, 10, r.height + 3));
|
||||
}
|
||||
if (current || viewer.drawEditing()) {
|
||||
if (what & (DRAW_ACTIVE | DRAW_BOXES)) {
|
||||
// draw rectangle around value
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(r.move(-1,-1,2,2));
|
||||
@@ -1368,7 +1369,7 @@ void TextValueEditor::drawWordListIndicators(RotatedDC& dc, bool redrawing) {
|
||||
small = (wl.get() != hovered_words);
|
||||
}
|
||||
if (small) {
|
||||
if (viewer.drawEditing()) {
|
||||
if (what & DRAW_BOXES) {
|
||||
dc.DrawRectangle(RealRect(r.right(), r.top() - 1, 2, r.height + 2));
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user