diff --git a/src/data/field.hpp b/src/data/field.hpp index ed4c9b58..0d1b1787 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -247,6 +247,7 @@ inline String type_name(const Value&) { // ----------------------------------------------------------------------------- : Utilities #define DECLARE_FIELD_TYPE(Type) \ + DECLARE_REFLECTION(); public: \ virtual ValueP newValue(const FieldP& thisP) const; \ virtual StyleP newStyle(const FieldP& thisP) const; \ virtual String typeName() const @@ -269,10 +270,18 @@ inline String type_name(const Value&) { } #define DECLARE_STYLE_TYPE(Type) \ + DECLARE_REFLECTION(); public: \ DECLARE_HAS_FIELD(Type) \ virtual StyleP clone() const; \ virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \ - virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP); + virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP) + +#define DECLARE_VALUE_TYPE(Type,ValueType_) \ + DECLARE_REFLECTION(); public: \ + DECLARE_HAS_FIELD(Type) \ + virtual ValueP clone() const; \ + virtual String toString() const; \ + typedef ValueType_ ValueType // implement field() which returns a field with the right (derived) type #define DECLARE_HAS_FIELD(Type) \ diff --git a/src/data/field/boolean.hpp b/src/data/field/boolean.hpp index 7f83bd54..dba586de 100644 --- a/src/data/field/boolean.hpp +++ b/src/data/field/boolean.hpp @@ -25,9 +25,6 @@ class BooleanField : public ChoiceField { DECLARE_FIELD_TYPE(Boolean); // no extra data - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : BooleanStyle diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index 25a6be9a..e53bcd69 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -42,9 +42,6 @@ class ChoiceField : public Field { map choice_colors_cardlist; ///< Colors for the various choices, for in the card list virtual void initDependencies(Context&, const Dependency&) const; - - private: - DECLARE_REFLECTION(); }; @@ -166,9 +163,6 @@ class ChoiceStyle : public Style { virtual int update(Context&); virtual void initDependencies(Context&, const Dependency&) const; virtual void invalidate(); - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : ChoiceValue @@ -181,17 +175,11 @@ class ChoiceValue : public Value { an explicit initial value */ ChoiceValue(const ChoiceFieldP& field, bool initial_first_choice = true); - DECLARE_HAS_FIELD(Choice) + DECLARE_VALUE_TYPE(Choice, Defaultable); - typedef Defaultable ValueType; ValueType value; /// The name of the selected choice - virtual ValueP clone() const; - virtual String toString() const; virtual bool update(Context&); - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : EOF diff --git a/src/data/field/color.hpp b/src/data/field/color.hpp index d50a3dcc..75c439e8 100644 --- a/src/data/field/color.hpp +++ b/src/data/field/color.hpp @@ -37,9 +37,6 @@ class ColorField : public Field { String default_name; ///< Name of "default" value virtual void initDependencies(Context&, const Dependency&) const; - - private: - DECLARE_REFLECTION(); }; /// A color that can be chosen for this field @@ -67,9 +64,6 @@ class ColorStyle : public Style { Scriptable mask_filename; ///< Filename of an additional mask over the images virtual int update(Context&); - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : ColorValue @@ -78,17 +72,11 @@ class ColorStyle : public Style { class ColorValue : public Value { public: ColorValue(const ColorFieldP& field); - DECLARE_HAS_FIELD(Color) + DECLARE_VALUE_TYPE(Color, Defaultable); - typedef Defaultable ValueType; ValueType value; ///< The value - virtual ValueP clone() const; - virtual String toString() const; virtual bool update(Context&); - - private: - DECLARE_REFLECTION(); }; diff --git a/src/data/field/image.hpp b/src/data/field/image.hpp index 17d1a176..60a4e26b 100644 --- a/src/data/field/image.hpp +++ b/src/data/field/image.hpp @@ -25,9 +25,6 @@ class ImageField : public Field { public: // no extra data DECLARE_FIELD_TYPE(Image); - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : ImageStyle @@ -42,9 +39,6 @@ class ImageStyle : public Style { ScriptableImage default_image; ///< Placeholder virtual int update(Context&); - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : ImageValue @@ -53,16 +47,10 @@ class ImageStyle : public Style { class ImageValue : public Value { public: inline ImageValue(const ImageFieldP& field) : Value(field) {} + DECLARE_VALUE_TYPE(Image, FileName); - typedef FileName ValueType; ValueType filename; ///< Filename of the image (in the current package), or "" Age last_update; ///< When was the image last changed? - - virtual ValueP clone() const; - virtual String toString() const; - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : EOF diff --git a/src/data/field/information.hpp b/src/data/field/information.hpp index 61110d00..92d2b504 100644 --- a/src/data/field/information.hpp +++ b/src/data/field/information.hpp @@ -32,9 +32,6 @@ class InfoField : public Field { OptionalScript script; ///< Script to apply to all values virtual void initDependencies(Context&, const Dependency&) const; - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : InfoStyle @@ -53,9 +50,6 @@ class InfoStyle : public Style { virtual int update(Context&); virtual void initDependencies(Context&, const Dependency&) const; - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : InfoValue @@ -64,16 +58,11 @@ class InfoStyle : public Style { class InfoValue : public Value { public: inline InfoValue(const InfoFieldP& field) : Value(field) {} - DECLARE_HAS_FIELD(Info) + DECLARE_VALUE_TYPE(Info, String); - String value; + ValueType value; - virtual ValueP clone() const; - virtual String toString() const; virtual bool update(Context&); - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : EOF diff --git a/src/data/field/multiple_choice.hpp b/src/data/field/multiple_choice.hpp index cf0042ee..2ee2a9b7 100644 --- a/src/data/field/multiple_choice.hpp +++ b/src/data/field/multiple_choice.hpp @@ -26,9 +26,6 @@ class MultipleChoiceField : public ChoiceField { UInt minimum_selection, maximum_selection; ///< How many choices can be selected simultaniously? String empty_choice; ///< Name to use when nothing is selected - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : MultipleChoiceStyle @@ -41,9 +38,6 @@ class MultipleChoiceStyle : public ChoiceStyle { Direction direction; ///< In what direction are choices layed out? double spacing; ///< Spacing between choices (images) in pixels - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : MultipleChoiceValue diff --git a/src/data/field/symbol.hpp b/src/data/field/symbol.hpp index a99c319e..257a102e 100644 --- a/src/data/field/symbol.hpp +++ b/src/data/field/symbol.hpp @@ -25,11 +25,9 @@ DECLARE_POINTER_TYPE(SymbolValue); /// A field for image values class SymbolField : public Field { public: - // no extra data DECLARE_FIELD_TYPE(Symbol); - private: - DECLARE_REFLECTION(); + // no extra data }; // ----------------------------------------------------------------------------- : SymbolStyle @@ -46,9 +44,6 @@ class SymbolStyle : public Style { double max_aspect_ratio; ///< Bounds for the symbol's aspect ratio vector variations; ///< Different variantions of the same symbol - - private: - DECLARE_REFLECTION(); }; /// Styling for a symbol variation, defines color, border, etc. @@ -71,17 +66,10 @@ class SymbolVariation : public IntrusivePtrBase { class SymbolValue : public Value { public: inline SymbolValue(const SymbolFieldP& field) : Value(field) {} - DECLARE_HAS_FIELD(Symbol) + DECLARE_VALUE_TYPE(Symbol, FileName); - typedef FileName ValueType; ValueType filename; ///< Filename of the symbol (in the current package) Age last_update; ///< When was the symbol last changed? - - virtual ValueP clone() const; - virtual String toString() const; - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : EOF diff --git a/src/data/field/text.hpp b/src/data/field/text.hpp index 8ebd6ca3..bc57a726 100644 --- a/src/data/field/text.hpp +++ b/src/data/field/text.hpp @@ -41,9 +41,6 @@ class TextField : public Field { String default_name; ///< Name of "default" value virtual void initDependencies(Context&, const Dependency&) const; - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : TextStyle @@ -83,9 +80,6 @@ class TextStyle : public Style { /// Stretch factor to use double getStretch() const; - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : TextValue @@ -94,18 +88,12 @@ class TextStyle : public Style { class TextValue : public Value { public: inline TextValue(const TextFieldP& field) : Value(field), last_update(1) {} - DECLARE_HAS_FIELD(Text) + DECLARE_VALUE_TYPE(Text, Defaultable); - typedef Defaultable ValueType; ValueType value; ///< The text of this value Age last_update; ///< When was the text last changed? - virtual ValueP clone() const; - virtual String toString() const; virtual bool update(Context&); - - private: - DECLARE_REFLECTION(); }; // ----------------------------------------------------------------------------- : TextValue diff --git a/src/data/font.hpp b/src/data/font.hpp index 9b10d92a..bf459d53 100644 --- a/src/data/font.hpp +++ b/src/data/font.hpp @@ -54,7 +54,9 @@ class Font : public IntrusivePtrBase { void initDependencies(Context&, const Dependency&) const; /// Does this font have a shadow? - inline bool hasShadow() { return shadow_displacement.width != 0 || shadow_displacement.height != 0; } + inline bool hasShadow() const { + return shadow_displacement.width != 0 || shadow_displacement.height != 0; + } /// Add style to a font, and optionally change the color FontP make(int add_flags, Color* other_color) const; diff --git a/src/data/symbol_font.cpp b/src/data/symbol_font.cpp index 2c07c2c3..749acd8e 100644 --- a/src/data/symbol_font.cpp +++ b/src/data/symbol_font.cpp @@ -338,12 +338,7 @@ void SymbolFont::drawWithText(RotatedDC& dc, const RealRect& rect, double font_s // align text RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect); // draw text - if (text_font->hasShadow()) { - dc.SetTextForeground(text_font->shadow_color); - dc.DrawText(text, text_pos + text_font->shadow_displacement * font_size, 0, 1, stretch); - } - dc.SetTextForeground(text_font->color); - dc.DrawText(text, text_pos, 0, 1, stretch); + dc.DrawTextWithShadow(text, *text_font, text_pos, font_size, stretch); } Image SymbolFont::getImage(double font_size, const DrawableSymbol& sym) { @@ -388,12 +383,7 @@ Image SymbolFont::getImage(double font_size, const DrawableSymbol& sym) { // align text RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect); // draw text - if (text_font->hasShadow()) { - rdc.SetTextForeground(text_font->shadow_color); - rdc.DrawText(sym.text, text_pos + text_font->shadow_displacement * font_size, 0, 1, stretch); - } - rdc.SetTextForeground(text_font->color); - rdc.DrawText(sym.text, text_pos, 0, 1, stretch); + rdc.DrawTextWithShadow(sym.text, *text_font, text_pos, font_size, stretch); // done dc.SelectObject(wxNullBitmap); return bmp.ConvertToImage(); diff --git a/src/mse.vcproj b/src/mse.vcproj index fc2be90d..89e13770 100644 --- a/src/mse.vcproj +++ b/src/mse.vcproj @@ -87,6 +87,7 @@ Optimization="2" GlobalOptimizations="TRUE" InlineFunctionExpansion="1" + ImproveFloatingPointConsistency="TRUE" OmitFramePointers="TRUE" OptimizeForProcessor="0" OptimizeForWindowsApplication="TRUE" @@ -225,6 +226,7 @@ Optimization="3" GlobalOptimizations="TRUE" InlineFunctionExpansion="1" + ImproveFloatingPointConsistency="TRUE" FavorSizeOrSpeed="1" OmitFramePointers="TRUE" OptimizeForProcessor="3" @@ -300,6 +302,7 @@ Optimization="3" GlobalOptimizations="TRUE" InlineFunctionExpansion="1" + ImproveFloatingPointConsistency="TRUE" FavorSizeOrSpeed="1" OmitFramePointers="TRUE" OptimizeForProcessor="3" @@ -375,6 +378,7 @@ Optimization="3" GlobalOptimizations="TRUE" InlineFunctionExpansion="1" + ImproveFloatingPointConsistency="TRUE" FavorSizeOrSpeed="1" OmitFramePointers="TRUE" OptimizeForProcessor="3" @@ -2172,12 +2176,6 @@ - - - - @@ -2187,9 +2185,6 @@ - - @@ -2208,12 +2203,6 @@ - - - - + + + + + + + + + + + + start, end - start); if (!text.empty() && text.GetChar(text.size() - 1) == _('\n')) { text = text.substr(0, text.size() - 1); // don't draw last \n } - if (font->hasShadow()) { - dc.SetTextForeground(font->shadow_color); - dc.DrawText(text, rect.position() + font->shadow_displacement); - } // draw - dc.SetTextForeground(font->color); - dc.DrawText(text, rect.position()); + dc.SetFont(*font, scale); + dc.DrawTextWithShadow(text, *font, rect.position()); } void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector& out) const { diff --git a/src/render/value/choice.cpp b/src/render/value/choice.cpp index 2e882e24..26222109 100644 --- a/src/render/value/choice.cpp +++ b/src/render/value/choice.cpp @@ -12,27 +12,38 @@ // ----------------------------------------------------------------------------- : ChoiceValueViewer +void get_options(Rotation& rot, DataViewer& viewer, const ChoiceStyle& style, GeneratedImage::Options& opts); + bool ChoiceValueViewer::prepare(RotatedDC& dc) { - if (style().render_style & RENDER_IMAGE) { - style().initImage(); - CachedScriptableImage& img = style().image; + return prepare_choice_viewer(dc, viewer, style(), value().value()); +} +void ChoiceValueViewer::draw(RotatedDC& dc) { + drawFieldBorder(dc); + if (style().render_style & RENDER_HIDDEN) return; + draw_choice_viewer(dc, viewer, style(), value().value()); +} + +bool prepare_choice_viewer(RotatedDC& dc, DataViewer& viewer, ChoiceStyle& style, const String& value) { + if (style.render_style & RENDER_IMAGE) { + style.initImage(); + CachedScriptableImage& img = style.image; Context& ctx = viewer.getContext(); - ctx.setVariable(SCRIPT_VAR_input, to_script(value().value())); + ctx.setVariable(SCRIPT_VAR_input, to_script(value)); // generate to determine the size if (img.update(ctx) && img.isReady()) { GeneratedImage::Options img_options; - getOptions(dc, img_options); + get_options(dc, viewer, style, img_options); // Generate image/bitmap (whichever is available) // don't worry, we cache the image - ImageCombine combine = style().combine; - style().loadMask(*viewer.stylesheet); + ImageCombine combine = style.combine; + style.loadMask(*viewer.stylesheet); Bitmap bitmap; Image image; RealSize size; - img.generateCached(img_options, &style().mask, &combine, &bitmap, &image, &size); + img.generateCached(img_options, &style.mask, &combine, &bitmap, &image, &size); // store content properties - if (style().content_width != size.width || style().content_height != size.height) { - style().content_width = size.width; - style().content_height = size.height; + if (style.content_width != size.width || style.content_height != size.height) { + style.content_width = size.width; + style.content_height = size.height; return true; } } @@ -40,25 +51,23 @@ bool ChoiceValueViewer::prepare(RotatedDC& dc) { return false; } -void ChoiceValueViewer::draw(RotatedDC& dc) { - drawFieldBorder(dc); - if (style().render_style & RENDER_HIDDEN) return; - if (value().value().empty()) return; +void draw_choice_viewer(RotatedDC& dc, DataViewer& viewer, ChoiceStyle& style, const String& value) { + if (value.empty()) return; double margin = 0; - if (style().render_style & RENDER_IMAGE) { + if (style.render_style & RENDER_IMAGE) { // draw image - CachedScriptableImage& img = style().image; + CachedScriptableImage& img = style.image; if (img.isReady()) { GeneratedImage::Options img_options; - getOptions(dc, img_options); + get_options(dc, viewer, style, img_options); // Generate image/bitmap - ImageCombine combine = style().combine; - style().loadMask(*viewer.stylesheet); + ImageCombine combine = style.combine; + style.loadMask(*viewer.stylesheet); Bitmap bitmap; Image image; RealSize size; - img.generateCached(img_options, &style().mask, &combine, &bitmap, &image, &size); + img.generateCached(img_options, &style.mask, &combine, &bitmap, &image, &size); size = dc.trInvS(size); - RealRect rect(align_in_rect(style().alignment, size, dc.getInternalRect()), size); + RealRect rect(align_in_rect(style.alignment, size, dc.getInternalRect()), size); if (bitmap.Ok()) { // just draw it dc.DrawPreRotatedBitmap(bitmap,rect); @@ -67,42 +76,36 @@ void ChoiceValueViewer::draw(RotatedDC& dc) { dc.DrawPreRotatedImage(image,rect,combine); } margin = size.width + 1; - } else if (nativeLook()) { + } else if (viewer.nativeLook()) { // always have the margin margin = 17; } } - if (style().render_style & RENDER_TEXT) { - // draw text - dc.SetFont(style().font, 1.0); - String text = tr(*viewer.stylesheet, value().value(), capitalize(value().value())); + if (style.render_style & RENDER_TEXT) { + String text = tr(*viewer.stylesheet, value, capitalize(value)); + dc.SetFont(style.font, 1.0); RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(margin, 0); - if (style().font.hasShadow()) { - dc.SetTextForeground(style().font.shadow_color); - dc.DrawText(text, pos + style().font.shadow_displacement); - } - dc.SetTextForeground(style().font.color()); - dc.DrawText(text, pos); + dc.DrawTextWithShadow(text, style.font, pos); + } +} + +void get_options(Rotation& rot, DataViewer& viewer, const ChoiceStyle& style, GeneratedImage::Options& opts) { + opts.package = viewer.stylesheet.get(); + opts.local_package = viewer.getSet().get(); + opts.angle = rot.trAngle(0); + if (viewer.nativeLook()) { + opts.width = opts.height = 16; + opts.preserve_aspect = ASPECT_BORDER; + } else if(style.render_style & RENDER_TEXT) { + // also drawing text, use original size + } else { + opts.width = (int) rot.trX(style.width); + opts.height = (int) rot.trY(style.height); + opts.preserve_aspect = (style.alignment & ALIGN_STRETCH) ? ASPECT_STRETCH : ASPECT_FIT; } } void ChoiceValueViewer::onStyleChange(int changes) { if (changes & CHANGE_MASK) style().image.clearCache(); ValueViewer::onStyleChange(changes); -} - -void ChoiceValueViewer::getOptions(Rotation& rot, GeneratedImage::Options& opts) { - opts.package = viewer.stylesheet.get(); - opts.local_package = &getSet(); - opts.angle = rot.trAngle(0); - if (nativeLook()) { - opts.width = opts.height = 16; - opts.preserve_aspect = ASPECT_BORDER; - } else if(style().render_style & RENDER_TEXT) { - // also drawing text, use original size - } else { - opts.width = (int) rot.trX(style().width); - opts.height = (int) rot.trY(style().height); - opts.preserve_aspect = (style().alignment & ALIGN_STRETCH) ? ASPECT_STRETCH : ASPECT_FIT; - } -} +} \ No newline at end of file diff --git a/src/render/value/choice.hpp b/src/render/value/choice.hpp index 5860fa7d..3d22a6f6 100644 --- a/src/render/value/choice.hpp +++ b/src/render/value/choice.hpp @@ -23,9 +23,10 @@ class ChoiceValueViewer : public ValueViewer { virtual bool prepare(RotatedDC& dc); virtual void draw(RotatedDC& dc); virtual void onStyleChange(int); - private: - void getOptions(Rotation& rot, GeneratedImage::Options& opts); }; +bool prepare_choice_viewer(RotatedDC& dc, DataViewer& viewer, ChoiceStyle& style, const String& value); +void draw_choice_viewer(RotatedDC& dc, DataViewer& viewer, ChoiceStyle& style, const String& value); + // ----------------------------------------------------------------------------- : EOF #endif diff --git a/src/render/value/multiple_choice.cpp b/src/render/value/multiple_choice.cpp index f1a73703..a0ffa238 100644 --- a/src/render/value/multiple_choice.cpp +++ b/src/render/value/multiple_choice.cpp @@ -7,6 +7,7 @@ // ----------------------------------------------------------------------------- : Includes #include +#include #include #include #include @@ -15,6 +16,11 @@ DECLARE_TYPEOF_COLLECTION(String); // ----------------------------------------------------------------------------- : MultipleChoiceValueViewer +bool MultipleChoiceValueViewer::prepare(RotatedDC& dc) { + if (style().render_style & (RENDER_CHECKLIST | RENDER_LIST)) return false; + return prepare_choice_viewer(dc, viewer, style(), value().value()); +} + void MultipleChoiceValueViewer::draw(RotatedDC& dc) { drawFieldBorder(dc); if (style().render_style & RENDER_HIDDEN) return; @@ -38,44 +44,7 @@ void MultipleChoiceValueViewer::draw(RotatedDC& dc) { drawChoice(dc, pos, choice); } } else { - // COPY FROM ChoiceValueViewer - if (value().value().empty()) return; - double margin = 0; - if (style().render_style & RENDER_IMAGE) { - // draw image - style().initImage(); - CachedScriptableImage& img = style().image; - Context& ctx = viewer.getContext(); - ctx.setVariable(SCRIPT_VAR_input, to_script(value().value())); - img.update(ctx); - if (img.isReady()) { - GeneratedImage::Options img_options; - getOptions(dc, img_options); - // Generate image/bitmap - ImageCombine combine = style().combine; - style().loadMask(*viewer.stylesheet); - Bitmap bitmap; Image image; - RealSize size; - img.generateCached(img_options, &style().mask, &combine, &bitmap, &image, &size); - size = dc.trInvS(size); - RealRect rect(align_in_rect(style().alignment, size, dc.getInternalRect()), size); - if (bitmap.Ok()) { - // just draw it - dc.DrawPreRotatedBitmap(bitmap,rect); - } else { - // use combine mode - dc.DrawPreRotatedImage(image,rect,combine); - } - margin = size.width + 1; - } - } - if (style().render_style & RENDER_TEXT) { - // draw text - dc.DrawText(tr(*viewer.stylesheet, value().value(), capitalize(value().value())), - align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(margin, 0) - ); - } - // COPY ENDS HERE + draw_choice_viewer(dc, viewer, style(), value().value()); } } @@ -111,20 +80,3 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const // next position pos = move_in_direction(style().direction, pos, size, style().spacing); } - -// COPY from ChoiceValueViewer -void MultipleChoiceValueViewer::getOptions(Rotation& rot, GeneratedImage::Options& opts) { - opts.package = viewer.stylesheet.get(); - opts.local_package = &getSet(); - opts.angle = rot.trAngle(0); //%% - if (nativeLook()) { - opts.width = opts.height = 16; - opts.preserve_aspect = ASPECT_BORDER; - } else if(style().render_style & RENDER_TEXT) { - // also drawing text, use original size - } else { - opts.width = (int) rot.trX(style().width); - opts.height = (int) rot.trY(style().height); - opts.preserve_aspect = (style().alignment & ALIGN_STRETCH) ? ASPECT_STRETCH : ASPECT_FIT; - } -} diff --git a/src/render/value/multiple_choice.hpp b/src/render/value/multiple_choice.hpp index 0f449a8a..cc1183de 100644 --- a/src/render/value/multiple_choice.hpp +++ b/src/render/value/multiple_choice.hpp @@ -20,12 +20,12 @@ class MultipleChoiceValueViewer : public ValueViewer { public: DECLARE_VALUE_VIEWER(MultipleChoice) : ValueViewer(parent,style), item_height(0) {} + virtual bool prepare(RotatedDC& dc); virtual void draw(RotatedDC& dc); protected: double item_height; ///< Height of a single item, or 0 if non uniform private: void drawChoice(RotatedDC& dc, RealPoint& pos, const String& choice, bool active = true); - void getOptions(Rotation& rot, GeneratedImage::Options& opts); }; // ----------------------------------------------------------------------------- : EOF diff --git a/src/util/rotation.cpp b/src/util/rotation.cpp index f6cfae62..87fc252b 100644 --- a/src/util/rotation.cpp +++ b/src/util/rotation.cpp @@ -216,6 +216,15 @@ void RotatedDC::DrawText (const String& text, const RealPoint& pos, int blur_ra } } +void RotatedDC::DrawTextWithShadow(const String& text, const Font& font, const RealPoint& pos, double scale, double stretch) { + if (font.hasShadow()) { + SetTextForeground(font.shadow_color); + DrawText(text, pos + font.shadow_displacement * scale, 0, 1, stretch); + } + SetTextForeground(font.color); + DrawText(text, pos, 0, 1, stretch); +} + void RotatedDC::DrawBitmap(const Bitmap& bitmap, const RealPoint& pos) { if (angle == 0) { RealPoint p_ext = tr(pos); diff --git a/src/util/rotation.hpp b/src/util/rotation.hpp index c0e0f4df..fa1ac72b 100644 --- a/src/util/rotation.hpp +++ b/src/util/rotation.hpp @@ -163,7 +163,10 @@ class RotatedDC : public Rotation { // --------------------------------------------------- : Drawing + /// Draw text void DrawText (const String& text, const RealPoint& pos, int blur_radius = 0, int boldness = 1, double stretch = 1.0); + /// Draw text with the shadow and color settings of the given font + void DrawTextWithShadow(const String& text, const Font& font, const RealPoint& pos, double scale = 1.0, double stretch = 1.0); /// Draw abitmap, it must already be zoomed! void DrawBitmap(const Bitmap& bitmap, const RealPoint& pos); /// Draw an image using the given combining mode, the image must already be zoomed!