Commit 0935fcf8 authored by coppro's avatar coppro

Fixed some bugs to make GCC work. I needed to change SimpleValueAction to take...

Fixed some bugs to make GCC work. I needed to change SimpleValueAction to take the function as a variable as opposed to a template parameter - GCC won't accept pointers from a base class in templates.
parent d4914fae
This diff is collapsed.
...@@ -53,6 +53,8 @@ magicseteditor_SOURCES += ./src/gui/control/filtered_card_list.cpp ...@@ -53,6 +53,8 @@ magicseteditor_SOURCES += ./src/gui/control/filtered_card_list.cpp
magicseteditor_SOURCES += ./src/gui/control/package_list.cpp magicseteditor_SOURCES += ./src/gui/control/package_list.cpp
magicseteditor_SOURCES += ./src/gui/control/gallery_list.cpp magicseteditor_SOURCES += ./src/gui/control/gallery_list.cpp
magicseteditor_SOURCES += ./src/gui/control/card_viewer.cpp magicseteditor_SOURCES += ./src/gui/control/card_viewer.cpp
magicseteditor_SOURCES += ./src/gui/control/item_list.cpp
magicseteditor_SOURCES += ./src/gui/control/keyword_list.cpp
magicseteditor_SOURCES += ./src/gui/set/style_panel.cpp magicseteditor_SOURCES += ./src/gui/set/style_panel.cpp
magicseteditor_SOURCES += ./src/gui/set/panel.cpp magicseteditor_SOURCES += ./src/gui/set/panel.cpp
magicseteditor_SOURCES += ./src/gui/set/set_info_panel.cpp magicseteditor_SOURCES += ./src/gui/set/set_info_panel.cpp
...@@ -89,17 +91,17 @@ magicseteditor_SOURCES += ./src/gui/drop_down_list.cpp ...@@ -89,17 +91,17 @@ magicseteditor_SOURCES += ./src/gui/drop_down_list.cpp
magicseteditor_SOURCES += ./src/gui/image_slice_window.cpp magicseteditor_SOURCES += ./src/gui/image_slice_window.cpp
magicseteditor_SOURCES += ./src/script/script_manager.cpp magicseteditor_SOURCES += ./src/script/script_manager.cpp
magicseteditor_SOURCES += ./src/script/script.cpp magicseteditor_SOURCES += ./src/script/script.cpp
magicseteditor_SOURCES += ./src/script/functions/basic.cpp
magicseteditor_SOURCES += ./src/script/functions/export.cpp
magicseteditor_SOURCES += ./src/script/functions/image.cpp
magicseteditor_SOURCES += ./src/script/functions/editor.cpp
magicseteditor_SOURCES += ./src/script/functions/english.cpp
magicseteditor_SOURCES += ./src/script/value.cpp magicseteditor_SOURCES += ./src/script/value.cpp
magicseteditor_SOURCES += ./src/script/dependency.cpp magicseteditor_SOURCES += ./src/script/dependency.cpp
magicseteditor_SOURCES += ./src/script/image.cpp magicseteditor_SOURCES += ./src/script/image.cpp
magicseteditor_SOURCES += ./src/script/context.cpp magicseteditor_SOURCES += ./src/script/context.cpp
magicseteditor_SOURCES += ./src/script/scriptable.cpp magicseteditor_SOURCES += ./src/script/scriptable.cpp
magicseteditor_SOURCES += ./src/script/parser.cpp magicseteditor_SOURCES += ./src/script/parser.cpp
magicseteditor_SOURCES += ./src/script/functions/basic.cpp
magicseteditor_SOURCES += ./src/script/functions/image.cpp
magicseteditor_SOURCES += ./src/script/functions/editor.cpp
magicseteditor_SOURCES += ./src/script/functions/export.cpp
magicseteditor_SOURCES += ./src/script/functions/english.cpp
magicseteditor_SOURCES += ./src/data/field/color.cpp magicseteditor_SOURCES += ./src/data/field/color.cpp
magicseteditor_SOURCES += ./src/data/field/boolean.cpp magicseteditor_SOURCES += ./src/data/field/boolean.cpp
magicseteditor_SOURCES += ./src/data/field/image.cpp magicseteditor_SOURCES += ./src/data/field/image.cpp
...@@ -134,6 +136,7 @@ magicseteditor_SOURCES += ./src/data/stylesheet.cpp ...@@ -134,6 +136,7 @@ magicseteditor_SOURCES += ./src/data/stylesheet.cpp
magicseteditor_SOURCES += ./src/data/statistics.cpp magicseteditor_SOURCES += ./src/data/statistics.cpp
magicseteditor_SOURCES += ./src/data/set.cpp magicseteditor_SOURCES += ./src/data/set.cpp
magicseteditor_SOURCES += ./src/data/symbol_font.cpp magicseteditor_SOURCES += ./src/data/symbol_font.cpp
magicseteditor_SOURCES += ./src/data/export_template.cpp
magicseteditor_SOURCES += ./src/util/io/get_member.cpp magicseteditor_SOURCES += ./src/util/io/get_member.cpp
magicseteditor_SOURCES += ./src/util/io/reader.cpp magicseteditor_SOURCES += ./src/util/io/reader.cpp
magicseteditor_SOURCES += ./src/util/io/package_manager.cpp magicseteditor_SOURCES += ./src/util/io/package_manager.cpp
......
...@@ -91,5 +91,5 @@ ...@@ -91,5 +91,5 @@
/* Define to rpl_malloc if the replacement function should be used. */ /* Define to rpl_malloc if the replacement function should be used. */
#undef malloc #undef malloc
/* Define to `unsigned' if <sys/types.h> does not define. */ /* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t #undef size_t
...@@ -25,11 +25,12 @@ String ValueAction::getName(bool to_undo) const { ...@@ -25,11 +25,12 @@ String ValueAction::getName(bool to_undo) const {
// ----------------------------------------------------------------------------- : Simple // ----------------------------------------------------------------------------- : Simple
/// A ValueAction that swaps between old and new values /// A ValueAction that swaps between old and new values
template <typename T, typename T::ValueType T::*member, bool ALLOW_MERGE> template <typename T, bool ALLOW_MERGE>
class SimpleValueAction : public ValueAction { class SimpleValueAction : public ValueAction {
public: public:
inline SimpleValueAction(const shared_ptr<T>& value, const typename T::ValueType& new_value) inline SimpleValueAction(const shared_ptr<T>& value, const typename T::ValueType& new_value, typename T::ValueType T::*member)
: ValueAction(value), new_value(new_value) : ValueAction(value), new_value(new_value)
, member(member)
{} {}
virtual void perform(bool to_undo) { virtual void perform(bool to_undo) {
...@@ -50,13 +51,14 @@ class SimpleValueAction : public ValueAction { ...@@ -50,13 +51,14 @@ class SimpleValueAction : public ValueAction {
private: private:
typename T::ValueType new_value; typename T::ValueType new_value;
typename T::ValueType T::*member;
}; };
ValueAction* value_action(const ChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<ChoiceValue, &ChoiceValue::value, true> (value, new_value); } ValueAction* value_action(const ChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<ChoiceValue, true> (value, new_value, &ChoiceValue::value); }
ValueAction* value_action(const MultipleChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<MultipleChoiceValue, &MultipleChoiceValue::value, false>(value, new_value); } ValueAction* value_action(const MultipleChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<MultipleChoiceValue, false>(value, new_value, &MultipleChoiceValue::value); }
ValueAction* value_action(const ColorValueP& value, const Defaultable<Color>& new_value) { return new SimpleValueAction<ColorValue, &ColorValue::value, true> (value, new_value); } ValueAction* value_action(const ColorValueP& value, const Defaultable<Color>& new_value) { return new SimpleValueAction<ColorValue, true> (value, new_value, &ColorValue::value); }
ValueAction* value_action(const ImageValueP& value, const FileName& new_value) { return new SimpleValueAction<ImageValue, &ImageValue::filename, false>(value, new_value); } ValueAction* value_action(const ImageValueP& value, const FileName& new_value) { return new SimpleValueAction<ImageValue, false>(value, new_value, &ImageValue::filename); }
ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction<SymbolValue, &SymbolValue::filename, false>(value, new_value); } ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction<SymbolValue, false>(value, new_value, &SymbolValue::filename); }
// ----------------------------------------------------------------------------- : Text // ----------------------------------------------------------------------------- : Text
......
...@@ -48,7 +48,7 @@ void reflect_font(Reader& tag, Font& font) { ...@@ -48,7 +48,7 @@ void reflect_font(Reader& tag, Font& font) {
REFLECT(weight); REFLECT(weight);
REFLECT(style); REFLECT(style);
if (!name.empty()) font.font.SetFaceName(name); if (!name.empty()) font.font.SetFaceName(name);
if (size > 0) font.font.SetPointSize(font.size = size); if (size > 0) font.font.SetPointSize((int) (font.size = size));
if (!weight.empty()) font.font.SetWeight(weight == _("bold") ? wxBOLD : wxNORMAL); if (!weight.empty()) font.font.SetWeight(weight == _("bold") ? wxBOLD : wxNORMAL);
if (!style.empty()) font.font.SetWeight(style == _("italic") ? wxITALIC : wxNORMAL); if (!style.empty()) font.font.SetWeight(style == _("italic") ? wxITALIC : wxNORMAL);
} }
......
...@@ -34,7 +34,7 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) { ...@@ -34,7 +34,7 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) {
} }
RealSize size = viewer.getRotation().getExternalSize(); RealSize size = viewer.getRotation().getExternalSize();
// create bitmap & dc // create bitmap & dc
Bitmap bitmap(size.width, size.height); Bitmap bitmap((int) size.width, (int) size.height);
if (!bitmap.Ok()) throw InternalError(_("Unable to create bitmap")); if (!bitmap.Ok()) throw InternalError(_("Unable to create bitmap"));
wxMemoryDC dc; wxMemoryDC dc;
dc.SelectObject(bitmap); dc.SelectObject(bitmap);
......
...@@ -21,8 +21,8 @@ DECLARE_TYPEOF_COLLECTION(StatsDimensionP); ...@@ -21,8 +21,8 @@ DECLARE_TYPEOF_COLLECTION(StatsDimensionP);
IMPLEMENT_DYNAMIC_ARG(Game*, game_for_reading, nullptr); IMPLEMENT_DYNAMIC_ARG(Game*, game_for_reading, nullptr);
Game::Game() Game::Game()
: dependencies_initialized(false) : has_keywords(false)
, has_keywords(false) , dependencies_initialized(false)
{} {}
GameP Game::byName(const String& name) { GameP Game::byName(const String& name) {
......
...@@ -99,8 +99,8 @@ class SymbolInFont { ...@@ -99,8 +99,8 @@ class SymbolInFont {
}; };
SymbolInFont::SymbolInFont() SymbolInFont::SymbolInFont()
: actual_size(0,0) : enabled(true)
, enabled(true) , actual_size(0,0)
{ {
assert(symbol_font_for_reading()); assert(symbol_font_for_reading());
img_size = symbol_font_for_reading()->img_size; img_size = symbol_font_for_reading()->img_size;
...@@ -118,8 +118,8 @@ Bitmap SymbolInFont::getBitmap(Context& ctx, Package& pkg, double size) { ...@@ -118,8 +118,8 @@ Bitmap SymbolInFont::getBitmap(Context& ctx, Package& pkg, double size) {
Image img = image.generate(ctx, pkg)->image; Image img = image.generate(ctx, pkg)->image;
actual_size = wxSize(img.GetWidth(), img.GetHeight()); actual_size = wxSize(img.GetWidth(), img.GetHeight());
// scale to match expected size // scale to match expected size
Image resampled_image(actual_size.GetWidth() * size / img_size, Image resampled_image((int) (actual_size.GetWidth() * size / img_size),
actual_size.GetHeight() * size / img_size, false); (int) (actual_size.GetHeight() * size / img_size), false);
if (!resampled_image.Ok()) return Bitmap(1,1); if (!resampled_image.Ok()) return Bitmap(1,1);
resample(img, resampled_image); resample(img, resampled_image);
// convert to bitmap, store for later use // convert to bitmap, store for later use
...@@ -145,7 +145,7 @@ RealSize SymbolInFont::size(Context& ctx, Package& pkg, double size) { ...@@ -145,7 +145,7 @@ RealSize SymbolInFont::size(Context& ctx, Package& pkg, double size) {
// we don't know what size the image will be // we don't know what size the image will be
getBitmap(ctx, pkg, size); getBitmap(ctx, pkg, size);
} }
return wxSize(actual_size * size / img_size); return wxSize(actual_size * (int) (size) / (int) (img_size));
} }
void SymbolInFont::update(Context& ctx) { void SymbolInFont::update(Context& ctx) {
......
...@@ -67,8 +67,8 @@ END_EVENT_TABLE () ...@@ -67,8 +67,8 @@ END_EVENT_TABLE ()
HoverButton::HoverButton(Window* parent, int id, const String& name, const Color& background) HoverButton::HoverButton(Window* parent, int id, const String& name, const Color& background)
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, wxNO_BORDER ) : wxControl(parent, id, wxDefaultPosition, wxDefaultSize, wxNO_BORDER )
, hover(false), focus(false), mouse_down(false), key_down(false) , hover(false), focus(false), mouse_down(false), key_down(false)
, last_drawn(nullptr)
, background(background) , background(background)
, last_drawn(nullptr)
{ {
loadBitmaps(name); loadBitmaps(name);
SetSize(DoGetBestSize()); SetSize(DoGetBestSize());
......
...@@ -38,8 +38,8 @@ class GalleryList : public wxScrolledWindow { ...@@ -38,8 +38,8 @@ class GalleryList : public wxScrolledWindow {
static const size_t NO_SELECTION = (size_t)-1; static const size_t NO_SELECTION = (size_t)-1;
size_t selection; ///< The selected item, or NO_SELECTION if there is no selection size_t selection; ///< The selected item, or NO_SELECTION if there is no selection
wxSize item_size; ///< The size of a single item wxSize item_size; ///< The size of a single item
int scroll_increment; ///< How large are the scroll steps?
int direction; ///< Direction of the list, can be wxHORIZONTAL or wxVERTICAL int direction; ///< Direction of the list, can be wxHORIZONTAL or wxVERTICAL
int scroll_increment; ///< How large are the scroll steps?
/// Redraw the list after changing the selection or the number of items /// Redraw the list after changing the selection or the number of items
void update(); void update();
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
SymbolBasicShapeEditor::SymbolBasicShapeEditor(SymbolControl* control) SymbolBasicShapeEditor::SymbolBasicShapeEditor(SymbolControl* control)
: SymbolEditorBase(control) : SymbolEditorBase(control)
, drawing(false)
, mode(ID_SHAPE_CIRCLE) , mode(ID_SHAPE_CIRCLE)
, drawing(false)
{ {
control->SetCursor(*wxCROSS_CURSOR); control->SetCursor(*wxCROSS_CURSOR);
} }
......
...@@ -152,7 +152,7 @@ void SymbolControl::draw(DC& dc) { ...@@ -152,7 +152,7 @@ void SymbolControl::draw(DC& dc) {
wxSize s = dc.GetSize(); wxSize s = dc.GetSize();
int lines = settings.symbol_grid_size; int lines = settings.symbol_grid_size;
for (int i = 0 ; i <= lines ; ++i) { for (int i = 0 ; i <= lines ; ++i) {
int x = rotation.trS((double)i/lines-0.0001); int x = (int) rotation.trS(i/lines-0.0001);
//dc.SetPen(Color(0, i%5 == 0 ? 64 : 31, 0)); //dc.SetPen(Color(0, i%5 == 0 ? 64 : 31, 0));
//dc.SetPen(Color(i%5 == 0 ? 64 : 31, 0, 0)); //dc.SetPen(Color(i%5 == 0 ? 64 : 31, 0, 0));
dc.SetLogicalFunction(wxAND); dc.SetLogicalFunction(wxAND);
...@@ -270,4 +270,4 @@ BEGIN_EVENT_TABLE(SymbolControl, wxControl) ...@@ -270,4 +270,4 @@ BEGIN_EVENT_TABLE(SymbolControl, wxControl)
EVT_KEY_UP (SymbolControl::onKeyChange) EVT_KEY_UP (SymbolControl::onKeyChange)
EVT_KEY_DOWN (SymbolControl::onKeyChange) EVT_KEY_DOWN (SymbolControl::onKeyChange)
EVT_CHAR (SymbolControl::onChar) EVT_CHAR (SymbolControl::onChar)
END_EVENT_TABLE () END_EVENT_TABLE ()
\ No newline at end of file
...@@ -85,13 +85,13 @@ Image load_resource_image(const String& name) { ...@@ -85,13 +85,13 @@ Image load_resource_image(const String& name) {
char* data = (char *)::LockResource(hData); char* data = (char *)::LockResource(hData);
if ( !data ) throw InternalError(String::Format(_("Resource cannot be locked: %s"), name)); if ( !data ) throw InternalError(String::Format(_("Resource cannot be locked: %s"), name));
int len = ::SizeofResource(wxGetInstance(), hResource); int len = ::SizeofResource(wxGetInstance(), hResource);
wxMemoryInputStream stream(data, len); wxMemoryInputStream stream(data, len);
return wxImage(stream); return wxImage(stream);
#elif defined(__linux__) #elif defined(__linux__)
static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/"); static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/");
String file = path + name; // if the name is in upper case, fix the call String file = path + name;
wxImage resource; wxImage resource;
if (wxFileExists(file + _(".png"))) resource.LoadFile(file + _(".png")); if (wxFileExists(file + _(".png"))) resource.LoadFile(file + _(".png"));
else if (wxFileExists(file + _(".bmp"))) resource.LoadFile(file + _(".bmp")); else if (wxFileExists(file + _(".bmp"))) resource.LoadFile(file + _(".bmp"));
......
...@@ -186,7 +186,7 @@ void SymbolViewer::drawSymbolPart(const SymbolPart& part, DC* border, DC* interi ...@@ -186,7 +186,7 @@ void SymbolViewer::drawSymbolPart(const SymbolPart& part, DC* border, DC* interi
// white/black // white/black
border->SetBrush(Color(borderCol, borderCol, borderCol)); border->SetBrush(Color(borderCol, borderCol, borderCol));
} }
border->SetPen(wxPen(*wxWHITE, rotation.trS(border_radius))); border->SetPen(wxPen(*wxWHITE, (int) rotation.trS(border_radius)));
border->DrawPolygon((int)points.size(), &points[0]); border->DrawPolygon((int)points.size(), &points[0]);
} }
// draw interior // draw interior
......
...@@ -133,4 +133,4 @@ RealSize CompoundTextElement::charSize(RotatedDC& dc, double scale, size_t index ...@@ -133,4 +133,4 @@ RealSize CompoundTextElement::charSize(RotatedDC& dc, double scale, size_t index
return elements.charSize(rot, scale, index); return elements.charSize(rot, scale, index);
} }
*/ */
\ No newline at end of file
...@@ -30,7 +30,7 @@ void ChoiceValueViewer::draw(RotatedDC& dc) { ...@@ -30,7 +30,7 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
i = img.update(viewer.getContext(), *viewer.stylesheet, 0, 0); i = img.update(viewer.getContext(), *viewer.stylesheet, 0, 0);
} else { } else {
i = img.update(viewer.getContext(), *viewer.stylesheet, i = img.update(viewer.getContext(), *viewer.stylesheet,
dc.trS(style().width), dc.trS(style().height), (int) dc.trS(style().width), (int) dc.trS(style().height),
style().alignment == ALIGN_STRETCH ? ASPECT_STRETCH : ASPECT_FIT style().alignment == ALIGN_STRETCH ? ASPECT_STRETCH : ASPECT_FIT
); );
} }
......
...@@ -70,7 +70,7 @@ void ImageValueViewer::onStyleChange() { ...@@ -70,7 +70,7 @@ void ImageValueViewer::onStyleChange() {
void ImageValueViewer::loadMask(const Rotation& rot) const { void ImageValueViewer::loadMask(const Rotation& rot) const {
if (style().mask_filename().empty()) return; // no mask if (style().mask_filename().empty()) return; // no mask
int w = rot.trS(style().width), h = rot.trS(style().height); int w = (int) rot.trS(style().width), h = (int) rot.trS(style().height);
if (alpha_mask && alpha_mask->size == wxSize(w,h)) return; // mask loaded and right size if (alpha_mask && alpha_mask->size == wxSize(w,h)) return; // mask loaded and right size
// (re) load the mask // (re) load the mask
Image image; Image image;
......
...@@ -30,7 +30,7 @@ void SymbolValueViewer::draw(RotatedDC& dc) { ...@@ -30,7 +30,7 @@ void SymbolValueViewer::draw(RotatedDC& dc) {
// render and filter variations // render and filter variations
FOR_EACH(variation, style().variations) { FOR_EACH(variation, style().variations) {
Image img = render_symbol(symbol, *variation->filter, variation->border_radius); Image img = render_symbol(symbol, *variation->filter, variation->border_radius);
Image resampled(wh, wh, false); Image resampled((int) wh, (int) wh, false);
resample(img, resampled); resample(img, resampled);
symbols.push_back(Bitmap(resampled)); symbols.push_back(Bitmap(resampled));
} }
......
...@@ -60,13 +60,13 @@ SCRIPT_FUNCTION(contains) { ...@@ -60,13 +60,13 @@ SCRIPT_FUNCTION(contains) {
SCRIPT_RULE_1(format, String, format) { SCRIPT_RULE_1(format, String, format) {
String fmt = _("%") + replace_all(format, _("%"), _("")); String fmt = _("%") + replace_all(format, _("%"), _(""));
// determine type expected by format string // determine type expected by format string
if (format.find_first_of(_("DdIiOoXx")) != String.npos) { if (format.find_first_of(_("DdIiOoXx")) != String::npos) {
SCRIPT_PARAM(int, input); SCRIPT_PARAM(int, input);
SCRIPT_RETURN(String::Format(fmt, input)); SCRIPT_RETURN(String::Format(fmt, input));
} else if (format.find_first_of(_("EeFfGg")) != String.npos) { } else if (format.find_first_of(_("EeFfGg")) != String::npos) {
SCRIPT_PARAM(double, input); SCRIPT_PARAM(double, input);
SCRIPT_RETURN(String::Format(fmt, input)); SCRIPT_RETURN(String::Format(fmt, input));
} else if (format.find_first_of(_("Ss")) != String.npos) { } else if (format.find_first_of(_("Ss")) != String::npos) {
SCRIPT_PARAM(String, input); SCRIPT_PARAM(String, input);
SCRIPT_RETURN(format_string(fmt, input)); SCRIPT_RETURN(format_string(fmt, input));
} else { } else {
......
...@@ -136,4 +136,4 @@ SCRIPT_FUNCTION_DEPENDENCIES(combined_editor) { ...@@ -136,4 +136,4 @@ SCRIPT_FUNCTION_DEPENDENCIES(combined_editor) {
void init_script_editor_functions(Context& ctx) { void init_script_editor_functions(Context& ctx) {
ctx.setVariable(_("forward editor"), script_combined_editor); // combatability ctx.setVariable(_("forward editor"), script_combined_editor); // combatability
ctx.setVariable(_("combined editor"), script_combined_editor); ctx.setVariable(_("combined editor"), script_combined_editor);
} }
\ No newline at end of file
...@@ -33,6 +33,7 @@ String english_number(int i) { ...@@ -33,6 +33,7 @@ String english_number(int i) {
case 18: return _("eighteen"); case 18: return _("eighteen");
case 20: return _("twenty"); case 20: return _("twenty");
case 30: return _("thirty"); case 30: return _("thirty");
case 40: return _("forty");
case 50: return _("fifty"); case 50: return _("fifty");
case 80: return _("eighty"); case 80: return _("eighty");
default: { default: {
...@@ -40,7 +41,7 @@ String english_number(int i) { ...@@ -40,7 +41,7 @@ String english_number(int i) {
// number too large, keep as digits // number too large, keep as digits
return (String() << i); return (String() << i);
} else if (i < 20) { } else if (i < 20) {
return english_number(i%10) + english_number(10); return english_number(i%10) + _("teen");
} else if (i % 10 == 0) { } else if (i % 10 == 0) {
return english_number(i/10) + _("ty"); return english_number(i/10) + _("ty");
} else { } else {
......
...@@ -205,7 +205,7 @@ inline ScriptValueP to_script(long v) { return to_script((int) v); } ...@@ -205,7 +205,7 @@ inline ScriptValueP to_script(long v) { return to_script((int) v); }
ScriptValueP to_script(double v); ScriptValueP to_script(double v);
ScriptValueP to_script(const String& v); ScriptValueP to_script(const String& v);
ScriptValueP to_script(const Color& v); ScriptValueP to_script(const Color& v);
inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; } inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; }
template <typename T> template <typename T>
inline ScriptValueP to_script(const vector<T>* v) { return new_intrusive1<ScriptCollection<vector<T> > >(v); } inline ScriptValueP to_script(const vector<T>* v) { return new_intrusive1<ScriptCollection<vector<T> > >(v); }
template <typename K, typename V> template <typename K, typename V>
......
...@@ -245,21 +245,21 @@ class ScriptCustomCollectionIterator : public ScriptIterator { ...@@ -245,21 +245,21 @@ class ScriptCustomCollectionIterator : public ScriptIterator {
: pos(0), col(col), colP(colP) {} : pos(0), col(col), colP(colP) {}
virtual ScriptValueP next() { virtual ScriptValueP next() {
if (pos < col->size()) { if (pos < col->size()) {
return to_script(col->at(pos++)); return col->at(pos++);
} else { } else {
return ScriptValueP(); return ScriptValueP();
} }
} }
private: private:
size_t pos; size_t pos;
ScriptValueP colP; // for ownership of the collection
const vector<ScriptValueP>* col; const vector<ScriptValueP>* col;
ScriptValueP colP; // for ownership of the collection
}; };
ScriptValueP ScriptCustomCollection::getMember(const String& name) const { ScriptValueP ScriptCustomCollection::getMember(const String& name) const {
long index; long index;
if (name.ToLong(&index) && index >= 0 && (size_t)index < value.size()) { if (name.ToLong(&index) && index >= 0 && (size_t)index < value.size()) {
return to_script(value.at(index)); return value.at(index);
} else { } else {
return ScriptValue::getMember(name); return ScriptValue::getMember(name);
} }
......
...@@ -53,35 +53,35 @@ ...@@ -53,35 +53,35 @@
#define TYPEOF_CREF(Value) TypeOf<typeid(Value)>::const_reference #define TYPEOF_CREF(Value) TypeOf<typeid(Value)>::const_reference
/// Declare typeof magic for a specific type /// Declare typeof magic for a specific type
#define DECLARE_TYPEOF(T) \ #define DECLARE_TYPEOF(T) \
template<> struct TypeOf<typeid(T)> { \ template<> struct TypeOf<typeid(T)> { \
typedef T type; \ typedef T type; \
typedef T::iterator iterator; \ typedef T::iterator iterator; \
typedef T::const_iterator const_iterator; \ typedef T::const_iterator const_iterator; \
typedef T::reverse_iterator reverse_iterator; \ typedef T::reverse_iterator reverse_iterator; \
typedef T::const_reverse_iterator const_reverse_iterator; \ typedef T::const_reverse_iterator const_reverse_iterator; \
typedef T::reference reference; \ typedef T::reference reference; \
typedef T::const_reference const_reference; \ typedef T::const_reference const_reference; \
} }
/// Declare typeof magic for a specific type that doesn't support reverse iterators /// Declare typeof magic for a specific type that doesn't support reverse iterators
#define DECLARE_TYPEOF_NO_REV(T) \ #define DECLARE_TYPEOF_NO_REV(T) \
template<> struct TypeOf<typeid(T)> { \ template<> struct TypeOf<typeid(T)> { \
typedef T type; \ typedef T type; \
typedef T::iterator iterator; \ typedef T::iterator iterator; \
typedef T::const_iterator const_iterator; \ typedef T::const_iterator const_iterator; \
typedef T::reference reference; \ typedef T::reference reference; \
typedef T::const_reference const_reference; \ typedef T::const_reference const_reference; \
} }
/// Declare typeof magic for a specific type, using const iterators /// Declare typeof magic for a specific type, using const iterators
#define DECLARE_TYPEOF_CONST(T) \ #define DECLARE_TYPEOF_CONST(T) \
template<> struct TypeOf<typeid(T)> { \ template<> struct TypeOf<typeid(T)> { \
typedef T type; \ typedef T type; \
typedef T::const_iterator iterator; \ typedef T::const_iterator iterator; \
typedef T::const_iterator const_iterator; \ typedef T::const_iterator const_iterator; \
typedef T::const_reverse_iterator reverse_iterator; \ typedef T::const_reverse_iterator reverse_iterator; \
typedef T::const_reverse_iterator const_reverse_iterator; \ typedef T::const_reverse_iterator const_reverse_iterator; \
typedef T::const_reference reference; \ typedef T::const_reference reference; \
typedef T::const_reference const_reference; \ typedef T::const_reference const_reference; \
} }
/// Declare typeof magic for a specific std::vector type /// Declare typeof magic for a specific std::vector type
...@@ -103,33 +103,33 @@ ...@@ -103,33 +103,33 @@
/// Iterate over a collection, using an iterator it of type Type /// Iterate over a collection, using an iterator it of type Type
/** Usage: FOR_EACH_IT_T(Type,it,collect) { body-of-loop } /** Usage: FOR_EACH_IT_T(Type,it,collect) { body-of-loop }
*/ */
#define FOR_EACH_IT_T(Type,Iterator,Collection) \ #define FOR_EACH_IT_T(Type,Iterator,Collection) \
for(Type Iterator = Collection.begin() ; \ for(Type Iterator = Collection.begin() ; \
Iterator != Collection.end() ; \ Iterator != Collection.end() ; \
++Iterator) ++Iterator)
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
/** Usage: FOR_EACH_IT(it,collect) { body-of-loop } /** Usage: FOR_EACH_IT(it,collect) { body-of-loop }
*/ */
#define FOR_EACH_IT(Iterator,Collection) \ #define FOR_EACH_IT(Iterator,Collection) \
FOR_EACH_IT_T(TYPEOF_IT(Collection), Iterator, Collection) FOR_EACH_IT_T(TYPEOF_IT(Collection), Iterator, Collection)
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
/** Uses a const_iterator /** Uses a const_iterator
* Usage: FOR_EACH_IT(it,collect) { body-of-loop } * Usage: FOR_EACH_IT(it,collect) { body-of-loop }
*/ */
#define FOR_EACH_CONST_IT(Iterator,Collection) \ #define FOR_EACH_CONST_IT(Iterator,Collection) \
FOR_EACH_IT_T(TYPEOF_CIT(Collection), Iterator, Collection) FOR_EACH_IT_T(TYPEOF_CIT(Collection), Iterator, Collection)
/// Iterate over a collection in whos type must be declared with DECLARE_TYPEOF /// Iterate over a collection in whos type must be declared with DECLARE_TYPEOF
/** Iterates using a reverse_iterator /** Iterates using a reverse_iterator
* Usage: FOR_EACH_REVERSE_IT(it,collect) { body-of-loop } * Usage: FOR_EACH_REVERSE_IT(it,collect) { body-of-loop }
*/ */
#define FOR_EACH_REVERSE_IT(Iterator,Collection) \ #define FOR_EACH_REVERSE_IT(Iterator,Collection) \
for(TYPEOF_RIT(Collection) \ for(TYPEOF_RIT(Collection) \
Iterator = Collection.rbegin() ; \ Iterator = Collection.rbegin() ; \
Iterator != Collection.rend() ; \ Iterator != Collection.rend() ; \
++Iterator) ++Iterator)
// ----------------------------------------------------------------------------- : Looping macros // ----------------------------------------------------------------------------- : Looping macros
...@@ -140,32 +140,32 @@ ...@@ -140,32 +140,32 @@
* To do this we use a nested for loop that is only executed once, and which is optimized away. * To do this we use a nested for loop that is only executed once, and which is optimized away.
* To terminate this loop we need an extra bool, which we set to false after the first iteration. * To terminate this loop we need an extra bool, which we set to false after the first iteration.
*/ */
#define FOR_EACH_T(TypeIt,TypeElem,Elem,Collection, begin, end) \ #define FOR_EACH_T(TypeIt,TypeElem,Elem,Collection, begin, end) \
for(std::pair<TypeIt,bool> Elem##_IT(Collection.begin(), true) ; \ for(std::pair<TypeIt,bool> Elem##_IT(Collection.begin(), true) ; \
Elem##_IT.second && Elem##_IT.first != Collection.end() ; \ Elem##_IT.second && Elem##_IT.first != Collection.end() ; \
++Elem##_IT.first, Elem##_IT.second = !Elem##_IT.second) \ ++Elem##_IT.first, Elem##_IT.second = !Elem##_IT.second) \
for(TypeElem Elem = *Elem##_IT.first ; \ for(TypeElem Elem = *Elem##_IT.first ; \
Elem##_IT.second ; \ Elem##_IT.second ; \
Elem##_IT.second = false) Elem##_IT.second = false)
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
/** Usage: FOR_EACH(e,collect) { body-of-loop } /** Usage: FOR_EACH(e,collect) { body-of-loop }
*/ */
#define FOR_EACH(Elem,Collection) \ #define FOR_EACH(Elem,Collection) \
FOR_EACH_T(TYPEOF_IT(Collection), TYPEOF_REF(Collection), Elem, Collection, begin, end) FOR_EACH_T(TYPEOF_IT(Collection), TYPEOF_REF(Collection), Elem, Collection, begin, end)
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
/** Uses a const iterator /** Uses a const iterator
* Usage: FOR_EACH_CONST(e,collect) { body-of-loop } * Usage: FOR_EACH_CONST(e,collect) { body-of-loop }
*/ */
#define FOR_EACH_CONST(Elem,Collection) \ #define FOR_EACH_CONST(Elem,Collection) \
FOR_EACH_T(TYPEOF_CIT(Collection), TYPEOF_CREF(Collection), Elem, Collection, begin, end) FOR_EACH_T(TYPEOF_CIT(Collection), TYPEOF_CREF(Collection), Elem, Collection, begin, end)
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
/** Iterates using a reverse_iterator /** Iterates using a reverse_iterator
* Usage: FOR_EACH_REVERSE(e,collect) { body-of-loop } * Usage: FOR_EACH_REVERSE(e,collect) { body-of-loop }
*/ */
#define FOR_EACH_REVERSE(Elem,Collection) \ #define FOR_EACH_REVERSE(Elem,Collection) \
FOR_EACH_T(TYPEOF_RIT(Collection), TYPEOF_REF(Collection), Elem, Collection, rbegin, rend) FOR_EACH_T(TYPEOF_RIT(Collection), TYPEOF_REF(Collection), Elem, Collection, rbegin, rend)
/// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF
...@@ -181,31 +181,31 @@ ...@@ -181,31 +181,31 @@
* Note: This has got to be one of the craziest pieces of code I have ever written :) * Note: This has got to be one of the craziest pieces of code I have ever written :)
* It is just an extension of the idea of FOR_EACH_T. * It is just an extension of the idea of FOR_EACH_T.
*/ */
#define FOR_EACH_2_T(TypeIt1,TypeElem1,Elem1,Coll1,TypeIt2,TypeElem2,Elem2,Coll2) \ #define FOR_EACH_2_T(TypeIt1,TypeElem1,Elem1,Coll1,TypeIt2,TypeElem2,Elem2,Coll2) \
for(std::pair<std::pair<TypeIt1,TypeIt2>, bool> \ for(std::pair<std::pair<TypeIt1,TypeIt2>, bool> \
Elem1##_IT(make_pair(Coll1.begin(), Coll2.begin()), true) ; \ Elem1##_IT(make_pair(Coll1.begin(), Coll2.begin()), true) ; \
Elem1##_IT.first.first != Coll1.end() && \ Elem1##_IT.first.first != Coll1.end() && \
Elem1##_IT.first.second != Coll2.end() ; \ Elem1##_IT.first.second != Coll2.end() ; \
++Elem1##_IT.first.first, ++Elem1##_IT.first.second, \ ++Elem1##_IT.first.first, ++Elem1##_IT.first.second, \
Elem1##_IT.second = true) \ Elem1##_IT.second = true) \
for(TypeElem1 Elem1 = *Elem1##_IT.first.first ; \ for(TypeElem1 Elem1 = *Elem1##_IT.first.first ; \
Elem1##_IT.second ; \ Elem1##_IT.second ; \
Elem1##_IT.second = false) \ Elem1##_IT.second = false) \
for(TypeElem2 Elem2 = *Elem1##_IT.first.second ; \ for(TypeElem2 Elem2 = *Elem1##_IT.first.second ; \
Elem1##_IT.second ; \ Elem1##_IT.second ; \
Elem1##_IT.second = false) Elem1##_IT.second = false)
/// Iterate over two collections in parallel, their type must be declared with DECLARE_TYPEOF. /// Iterate over two collections in parallel, their type must be declared with DECLARE_TYPEOF.
/** Usage: FOR_EACH_2(e1,collect1, e2,collect2) { body-of-loop } /** Usage: FOR_EACH_2(e1,collect1, e2,collect2) { body-of-loop }
*/ */
#define FOR_EACH_2(Elem1,Collection1, Elem2,Collection2) \ #define FOR_EACH_2(Elem1,Collection1, Elem2,Collection2) \
FOR_EACH_2_T(TYPEOF_IT(Collection1), TYPEOF_REF(Collection1), Elem1, Collection1, \ FOR_EACH_2_T(TYPEOF_IT(Collection1), TYPEOF_REF(Collection1), Elem1, Collection1, \
TYPEOF_IT(Collection2), TYPEOF_REF(Collection2), Elem2, Collection2) TYPEOF_IT(Collection2), TYPEOF_REF(Collection2), Elem2, Collection2)
/// Iterate over two constants collections in parallel, their type must be declared with DECLARE_TYPEOF. /// Iterate over two constants collections in parallel, their type must be declared with DECLARE_TYPEOF.
/** Usage: FOR_EACH_2_CONST(e1,collect1, e2,collect2) { body-of-loop } /** Usage: FOR_EACH_2_CONST(e1,collect1, e2,collect2) { body-of-loop }
*/ */
#define FOR_EACH_2_CONST(Elem1,Collection1, Elem2,Collection2) \ #define FOR_EACH_2_CONST(Elem1,Collection1, Elem2,Collection2) \
FOR_EACH_2_T(TYPEOF_CIT(Collection1), TYPEOF_CREF(Collection1), Elem1, Collection1, \ FOR_EACH_2_T(TYPEOF_CIT(Collection1), TYPEOF_CREF(Collection1), Elem1, Collection1, \
TYPEOF_CIT(Collection2), TYPEOF_CREF(Collection2), Elem2, Collection2) TYPEOF_CIT(Collection2), TYPEOF_CREF(Collection2), Elem2, Collection2)
......
...@@ -125,7 +125,7 @@ void Package::saveAs(const String& name, bool removeUnused) { ...@@ -125,7 +125,7 @@ void Package::saveAs(const String& name, bool removeUnused) {
// ----------------------------------------------------------------------------- : Package : inside // ----------------------------------------------------------------------------- : Package : inside
/* #if 0
/// Class that is a wxZipInputStream over a wxFileInput stream /// Class that is a wxZipInputStream over a wxFileInput stream
/** Note that wxFileInputStream is also a base class, because it must be constructed first /** Note that wxFileInputStream is also a base class, because it must be constructed first
* This class requires a patch in wxWidgets (2.5.4) * This class requires a patch in wxWidgets (2.5.4)
...@@ -136,7 +136,7 @@ void Package::saveAs(const String& name, bool removeUnused) { ...@@ -136,7 +136,7 @@ void Package::saveAs(const String& name, bool removeUnused) {
* It seems that in 2.6.3 this is no longer necessary (TODO: test) * It seems that in 2.6.3 this is no longer necessary (TODO: test)
* *
* NOTE: Not used with wx 2.6.3, since it doesn't support seeking * NOTE: Not used with wx 2.6.3, since it doesn't support seeking
* / */
class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream { class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream {
public: public:
ZipFileInputStream(const String& filename, wxZipEntry* entry) ZipFileInputStream(const String& filename, wxZipEntry* entry)
...@@ -146,7 +146,7 @@ class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream { ...@@ -146,7 +146,7 @@ class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream {
OpenEntry(*entry); OpenEntry(*entry);
} }
}; };
*/ #endif
InputStreamP Package::openIn(const String& file) { InputStreamP Package::openIn(const String& file) {
if (!file.empty() && file.GetChar(0) == _('/')) { if (!file.empty() && file.GetChar(0) == _('/')) {
......
...@@ -115,6 +115,9 @@ inline String format_string(const String& format, const String& a0) { ...@@ -115,6 +115,9 @@ inline String format_string(const String& format, const String& a0) {
inline String format_string(const String& format, const String& a0, const String& a1) { inline String format_string(const String& format, const String& a0, const String& a1) {
return String::Format(format, a0.c_str(), a1.c_str()); return String::Format(format, a0.c_str(), a1.c_str());
} }
inline String format_string(const String& format, const String& a0, const String& a1, const String& a2) {
return String::Format(format, a0.c_str(), a1.c_str(), a2.c_str());
}
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -131,14 +131,14 @@ void RotatedDC::DrawText (const String& text, const RealPoint& pos) { ...@@ -131,14 +131,14 @@ void RotatedDC::DrawText (const String& text, const RealPoint& pos) {
draw_resampled_text(dc, r_ext, revX(), revY(), angle, text); draw_resampled_text(dc, r_ext, revX(), revY(), angle, text);
} else { } else {
RealPoint p_ext = tr(pos); RealPoint p_ext = tr(pos);
dc.DrawRotatedText(text, p_ext.x, p_ext.y, angle); dc.DrawRotatedText(text, (int) p_ext.x, (int) p_ext.y, angle);
} }
} }
void RotatedDC::DrawBitmap(const Bitmap& bitmap, const RealPoint& pos) { void RotatedDC::DrawBitmap(const Bitmap& bitmap, const RealPoint& pos) {
if (angle == 0) { if (angle == 0) {
RealPoint p_ext = tr(pos); RealPoint p_ext = tr(pos);
dc.DrawBitmap(bitmap, p_ext.x, p_ext.y, true); dc.DrawBitmap(bitmap, (int) p_ext.x, (int) p_ext.y, true);
} else { } else {
DrawImage(bitmap.ConvertToImage(), pos); DrawImage(bitmap.ConvertToImage(), pos);
} }
...@@ -175,7 +175,7 @@ void RotatedDC::SetFont(const wxFont& font) { ...@@ -175,7 +175,7 @@ void RotatedDC::SetFont(const wxFont& font) {
SetFont(font, font.GetPointSize()); SetFont(font, font.GetPointSize());
} }
void RotatedDC::SetFont(wxFont font, double size) { void RotatedDC::SetFont(wxFont font, double size) {
font.SetPointSize(trS(size) * (high_quality ? text_scaling : 1)); font.SetPointSize((int) (trS(size) * (high_quality ? text_scaling : 1)));
dc.SetFont(font); dc.SetFont(font);
} }
......
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