Commit d02b12fc authored by twanvl's avatar twanvl

Added support for informational headings in native look editor.

parent dbb4bcac
...@@ -30,6 +30,7 @@ magicseteditor_SOURCES += ./src/render/value/text.cpp ...@@ -30,6 +30,7 @@ magicseteditor_SOURCES += ./src/render/value/text.cpp
magicseteditor_SOURCES += ./src/render/value/symbol.cpp magicseteditor_SOURCES += ./src/render/value/symbol.cpp
magicseteditor_SOURCES += ./src/render/value/multiple_choice.cpp magicseteditor_SOURCES += ./src/render/value/multiple_choice.cpp
magicseteditor_SOURCES += ./src/render/value/choice.cpp magicseteditor_SOURCES += ./src/render/value/choice.cpp
magicseteditor_SOURCES += ./src/render/value/information.cpp
magicseteditor_SOURCES += ./src/gfx/rotate_image.cpp magicseteditor_SOURCES += ./src/gfx/rotate_image.cpp
magicseteditor_SOURCES += ./src/gfx/color.cpp magicseteditor_SOURCES += ./src/gfx/color.cpp
magicseteditor_SOURCES += ./src/gfx/bezier.cpp magicseteditor_SOURCES += ./src/gfx/bezier.cpp
...@@ -73,6 +74,7 @@ magicseteditor_SOURCES += ./src/gui/value/symbol.cpp ...@@ -73,6 +74,7 @@ magicseteditor_SOURCES += ./src/gui/value/symbol.cpp
magicseteditor_SOURCES += ./src/gui/value/multiple_choice.cpp magicseteditor_SOURCES += ./src/gui/value/multiple_choice.cpp
magicseteditor_SOURCES += ./src/gui/value/editor.cpp magicseteditor_SOURCES += ./src/gui/value/editor.cpp
magicseteditor_SOURCES += ./src/gui/value/choice.cpp magicseteditor_SOURCES += ./src/gui/value/choice.cpp
magicseteditor_SOURCES += ./src/gui/value/information.cpp
magicseteditor_SOURCES += ./src/gui/util.cpp magicseteditor_SOURCES += ./src/gui/util.cpp
magicseteditor_SOURCES += ./src/gui/card_select_window.cpp magicseteditor_SOURCES += ./src/gui/card_select_window.cpp
magicseteditor_SOURCES += ./src/gui/about_window.cpp magicseteditor_SOURCES += ./src/gui/about_window.cpp
...@@ -101,6 +103,7 @@ magicseteditor_SOURCES += ./src/data/field/text.cpp ...@@ -101,6 +103,7 @@ magicseteditor_SOURCES += ./src/data/field/text.cpp
magicseteditor_SOURCES += ./src/data/field/symbol.cpp magicseteditor_SOURCES += ./src/data/field/symbol.cpp
magicseteditor_SOURCES += ./src/data/field/multiple_choice.cpp magicseteditor_SOURCES += ./src/data/field/multiple_choice.cpp
magicseteditor_SOURCES += ./src/data/field/choice.cpp magicseteditor_SOURCES += ./src/data/field/choice.cpp
magicseteditor_SOURCES += ./src/data/field/information.cpp
magicseteditor_SOURCES += ./src/data/format/clipboard.cpp magicseteditor_SOURCES += ./src/data/format/clipboard.cpp
magicseteditor_SOURCES += ./src/data/format/image.cpp magicseteditor_SOURCES += ./src/data/format/image.cpp
magicseteditor_SOURCES += ./src/data/format/html.cpp magicseteditor_SOURCES += ./src/data/format/html.cpp
......
...@@ -227,6 +227,9 @@ init script: ...@@ -227,6 +227,9 @@ init script:
############################################################## Set fields ############################################################## Set fields
set field:
type: info
name: Set Information
set field: set field:
type: text type: text
name: title name: title
...@@ -244,6 +247,9 @@ set field: ...@@ -244,6 +247,9 @@ set field:
type: symbol type: symbol
name: symbol name: symbol
description: The symbol for this set, double click to edit description: The symbol for this set, double click to edit
set field:
type: info
name: Defaults and Automation
set field: set field:
type: color type: color
name: border color name: border color
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <data/field/image.hpp> #include <data/field/image.hpp>
#include <data/field/symbol.hpp> #include <data/field/symbol.hpp>
#include <data/field/color.hpp> #include <data/field/color.hpp>
#include <data/field/information.hpp>
#include <util/error.hpp> #include <util/error.hpp>
// ----------------------------------------------------------------------------- : Field // ----------------------------------------------------------------------------- : Field
...@@ -69,6 +70,7 @@ shared_ptr<Field> read_new<Field>(Reader& reader) { ...@@ -69,6 +70,7 @@ shared_ptr<Field> read_new<Field>(Reader& reader) {
else if (type == _("image")) return new_shared<ImageField>(); else if (type == _("image")) return new_shared<ImageField>();
else if (type == _("symbol")) return new_shared<SymbolField>(); else if (type == _("symbol")) return new_shared<SymbolField>();
else if (type == _("color")) return new_shared<ColorField>(); else if (type == _("color")) return new_shared<ColorField>();
else if (type == _("info")) return new_shared<InfoField>();
else { else {
throw ParseError(_("Unsupported field type: '") + type + _("'")); throw ParseError(_("Unsupported field type: '") + type + _("'"));
} }
......
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/field/information.hpp>
#include <util/tagged_string.hpp>
#include <script/script.hpp>
// ----------------------------------------------------------------------------- : InfoField
IMPLEMENT_FIELD_TYPE(Info)
String InfoField::typeName() const {
return _("info");
}
void InfoField::initDependencies(Context& ctx, const Dependency& dep) const {
Field ::initDependencies(ctx, dep);
script. initDependencies(ctx, dep);
}
IMPLEMENT_REFLECTION(InfoField) {
REFLECT_BASE(Field);
REFLECT(script);
}
// ----------------------------------------------------------------------------- : InfoStyle
InfoStyle::InfoStyle(const InfoFieldP& field)
: Style(field)
, alignment(ALIGN_TOP_LEFT)
, padding_left (2)
, padding_right (2)
, padding_top (2)
, padding_bottom(2)
, background_color(255,255,255)
{}
bool InfoStyle::update(Context& ctx) {
return Style ::update(ctx)
| font .update(ctx);
}
void InfoStyle::initDependencies(Context& ctx, const Dependency& dep) const {
Style ::initDependencies(ctx, dep);
// font .initDependencies(ctx, dep);
}
IMPLEMENT_REFLECTION(InfoStyle) {
REFLECT_BASE(Style);
REFLECT(font);
REFLECT(alignment);
REFLECT(padding_left);
REFLECT(padding_right);
REFLECT(padding_top);
REFLECT(padding_bottom);
REFLECT(background_color);
}
// ----------------------------------------------------------------------------- : InfoValue
String InfoValue::toString() const {
return value;
}
bool InfoValue::update(Context& ctx) {
Value::update(ctx);
if (value.empty()) value = field().name;
return field().script.invokeOn(ctx, value);
}
IMPLEMENT_REFLECTION_NAMELESS(InfoValue) {
// never save
}
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_FIELD_INFORMATION
#define HEADER_DATA_FIELD_INFORMATION
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/defaultable.hpp>
#include <data/field.hpp>
#include <data/font.hpp>
#include <script/scriptable.hpp>
// ----------------------------------------------------------------------------- : InfoField
DECLARE_POINTER_TYPE(InfoField);
DECLARE_POINTER_TYPE(InfoStyle);
DECLARE_POINTER_TYPE(InfoValue);
/// A field for informational values.
/** These values are not editable, they are just headers, icons, labels, etc.
*/
class InfoField : public Field {
public:
InfoField() {}
DECLARE_FIELD_TYPE(Text);
OptionalScript script; ///< Script to apply to all values
virtual void initDependencies(Context&, const Dependency&) const;
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : InfoStyle
/// The Style for a InfoField
class InfoStyle : public Style {
public:
InfoStyle(const InfoFieldP&);
DECLARE_STYLE_TYPE(Info);
Font font; ///< Font to use for the text
Alignment alignment; ///< Alignment inside the box
double padding_left, padding_right; ///< Padding
double padding_top, padding_bottom;
Color background_color;
virtual bool update(Context&);
virtual void initDependencies(Context&, const Dependency&) const;
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : InfoValue
/// The Value in a InfoField
class InfoValue : public Value {
public:
inline InfoValue(const InfoFieldP& field) : Value(field) {}
DECLARE_HAS_FIELD(Info)
String value;
virtual String toString() const;
virtual bool update(Context&);
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -30,18 +30,21 @@ void NativeLookEditor::draw(DC& dc) { ...@@ -30,18 +30,21 @@ void NativeLookEditor::draw(DC& dc) {
} }
void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) { void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
if (!shouldDraw(v)) return; if (!shouldDraw(v)) return;
// draw background ValueEditor* e = v.getEditor();
Style& s = *v.getStyle(); if (!e || e->drawLabel()) {
dc.SetPen(*wxTRANSPARENT_PEN); // draw background
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); Style& s = *v.getStyle();
dc.DrawRectangle(s.getRect().grow(1)); dc.SetPen(*wxTRANSPARENT_PEN);
// draw label dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
dc.SetFont(*wxNORMAL_FONT); dc.DrawRectangle(s.getRect().grow(1));
// TODO : tr using stylesheet or using game? // draw label
dc.DrawText(tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name)), dc.SetFont(*wxNORMAL_FONT);
RealPoint(margin_left, s.top + 1)); // TODO : tr using stylesheet or using game?
// draw 3D border dc.DrawText(tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name)),
draw_control_border(this, dc.getDC(), RealRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2)); RealPoint(margin_left, s.top + 1));
// draw 3D border
draw_control_border(this, dc.getDC(), RealRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2));
}
// draw viewer // draw viewer
v.draw(dc); v.draw(dc);
} }
...@@ -55,11 +58,15 @@ void NativeLookEditor::resizeViewers() { ...@@ -55,11 +58,15 @@ void NativeLookEditor::resizeViewers() {
// Set editor sizes // Set editor sizes
FOR_EACH(v, viewers) { FOR_EACH(v, viewers) {
StyleP s = v->getStyle(); StyleP s = v->getStyle();
s->left = margin + label_width; ValueEditor* e = v->getEditor();
if (!e || e->drawLabel()) {
s->left = margin + label_width;
} else {
s->left = margin;
}
s->top = y; s->top = y;
s->width = w - s->left - margin; s->width = w - s->left - margin;
s->height = default_height; s->height = default_height;
ValueEditor* e = v->getEditor();
if (e) e->determineSize(); if (e) e->determineSize();
y += s->height + vspace; y += s->height + vspace;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <gui/value/image.hpp> #include <gui/value/image.hpp>
#include <gui/value/symbol.hpp> #include <gui/value/symbol.hpp>
#include <gui/value/color.hpp> #include <gui/value/color.hpp>
#include <gui/value/information.hpp>
// ----------------------------------------------------------------------------- : ValueEditor // ----------------------------------------------------------------------------- : ValueEditor
...@@ -30,3 +31,4 @@ IMPLEMENT_MAKE_EDITOR(MultipleChoice); ...@@ -30,3 +31,4 @@ IMPLEMENT_MAKE_EDITOR(MultipleChoice);
IMPLEMENT_MAKE_EDITOR(Color); IMPLEMENT_MAKE_EDITOR(Color);
IMPLEMENT_MAKE_EDITOR(Image); IMPLEMENT_MAKE_EDITOR(Image);
IMPLEMENT_MAKE_EDITOR(Symbol); IMPLEMENT_MAKE_EDITOR(Symbol);
IMPLEMENT_MAKE_EDITOR(Info);
...@@ -98,8 +98,10 @@ class ValueEditor { ...@@ -98,8 +98,10 @@ class ValueEditor {
/// The cursor type to use when the mouse is over this control /// The cursor type to use when the mouse is over this control
virtual wxCursor cursor() const { return wxCursor(); } virtual wxCursor cursor() const { return wxCursor(); }
/// determines prefered size in the native look, update the style /// Determines prefered size in the native look, update the style
virtual void determineSize(bool force_fit = false) {} virtual void determineSize(bool force_fit = false) {}
/// Should a label and control border be drawn in the native look?
virtual bool drawLabel() const { return true; }
/// The editor is shown or hidden /// The editor is shown or hidden
virtual void onShow(bool) {} virtual void onShow(bool) {}
......
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/information.hpp>
// ----------------------------------------------------------------------------- : InfoValueEditor
IMPLEMENT_VALUE_EDITOR(Info) {}
void InfoValueEditor::determineSize(bool) {
style().height = 26;
}
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_INFORMATION
#define HEADER_GUI_VALUE_INFORMATION
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/information.hpp>
// ----------------------------------------------------------------------------- : InfoValueEditor
/// An editor 'control' for editing InfoValues
class InfoValueEditor : public InfoValueViewer, public ValueEditor {
public:
DECLARE_VALUE_EDITOR(Info);
virtual void determineSize(bool);
virtual bool drawLabel() const { return false; }
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -1045,6 +1045,12 @@ ...@@ -1045,6 +1045,12 @@
<File <File
RelativePath=".\gui\value\image.hpp"> RelativePath=".\gui\value\image.hpp">
</File> </File>
<File
RelativePath=".\gui\value\information.cpp">
</File>
<File
RelativePath=".\gui\value\information.hpp">
</File>
<File <File
RelativePath=".\gui\value\multiple_choice.cpp"> RelativePath=".\gui\value\multiple_choice.cpp">
<FileConfiguration <FileConfiguration
...@@ -1492,6 +1498,48 @@ ...@@ -1492,6 +1498,48 @@
<File <File
RelativePath=".\data\field\image.hpp"> RelativePath=".\data\field\image.hpp">
</File> </File>
<File
RelativePath=".\data\field\information.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Profile Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode fast build|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\data\field\information.hpp">
</File>
<File <File
RelativePath=".\data\field\multiple_choice.cpp"> RelativePath=".\data\field\multiple_choice.cpp">
</File> </File>
...@@ -2283,6 +2331,48 @@ ...@@ -2283,6 +2331,48 @@
<File <File
RelativePath=".\render\value\image.hpp"> RelativePath=".\render\value\image.hpp">
</File> </File>
<File
RelativePath=".\render\value\information.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Profile Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode fast build|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)2.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\render\value\information.hpp">
</File>
<File <File
RelativePath=".\render\value\multiple_choice.cpp"> RelativePath=".\render\value\multiple_choice.cpp">
<FileConfiguration <FileConfiguration
......
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <render/value/information.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : InfoValueViewer
void InfoValueViewer::draw(RotatedDC& dc) {
if (nativeLook()) {
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
dc.SetFont(wxFont(16, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, _("Arial")));
} else {
dc.SetTextForeground(style().font.color);
dc.SetBrush(style().background_color);
dc.SetFont(style().font.font, style().font.size);
}
// draw background
RealRect rect = style().getRect();
dc.DrawRectangle(rect.grow(2));
// draw text
rect = rect.move(
style().padding_left,
style().padding_top,
-style().padding_left - style().padding_right,
-style().padding_top - style().padding_bottom
);
RealSize size = dc.GetTextExtent(value().value);
dc.DrawText(value().value, align_in_rect(style().alignment, size, rect));
}
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_RENDER_VALUE_INFORMATION
#define HEADER_RENDER_VALUE_INFORMATION
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <render/value/viewer.hpp>
#include <render/text/viewer.hpp>
#include <data/field/information.hpp>
// ----------------------------------------------------------------------------- : InfoValueViewer
/// Viewer that displays a text value
class InfoValueViewer : public ValueViewer {
public:
DECLARE_VALUE_VIEWER(Info) : ValueViewer(parent,style) {}
virtual void draw(RotatedDC& dc);
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <render/value/image.hpp> #include <render/value/image.hpp>
#include <render/value/symbol.hpp> #include <render/value/symbol.hpp>
#include <render/value/color.hpp> #include <render/value/color.hpp>
#include <render/value/information.hpp>
#include <render/card/viewer.hpp> #include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : ValueViewer // ----------------------------------------------------------------------------- : ValueViewer
...@@ -68,3 +69,4 @@ IMPLEMENT_MAKE_VIEWER(MultipleChoice); ...@@ -68,3 +69,4 @@ IMPLEMENT_MAKE_VIEWER(MultipleChoice);
IMPLEMENT_MAKE_VIEWER(Color); IMPLEMENT_MAKE_VIEWER(Color);
IMPLEMENT_MAKE_VIEWER(Image); IMPLEMENT_MAKE_VIEWER(Image);
IMPLEMENT_MAKE_VIEWER(Symbol); IMPLEMENT_MAKE_VIEWER(Symbol);
IMPLEMENT_MAKE_VIEWER(Info);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment