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
magicseteditor_SOURCES += ./src/gui/control/package_list.cpp
magicseteditor_SOURCES += ./src/gui/control/gallery_list.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/panel.cpp
magicseteditor_SOURCES += ./src/gui/set/set_info_panel.cpp
......@@ -89,17 +91,17 @@ magicseteditor_SOURCES += ./src/gui/drop_down_list.cpp
magicseteditor_SOURCES += ./src/gui/image_slice_window.cpp
magicseteditor_SOURCES += ./src/script/script_manager.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/dependency.cpp
magicseteditor_SOURCES += ./src/script/image.cpp
magicseteditor_SOURCES += ./src/script/context.cpp
magicseteditor_SOURCES += ./src/script/scriptable.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/boolean.cpp
magicseteditor_SOURCES += ./src/data/field/image.cpp
......@@ -134,6 +136,7 @@ magicseteditor_SOURCES += ./src/data/stylesheet.cpp
magicseteditor_SOURCES += ./src/data/statistics.cpp
magicseteditor_SOURCES += ./src/data/set.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/reader.cpp
magicseteditor_SOURCES += ./src/util/io/package_manager.cpp
......
......@@ -91,5 +91,5 @@
/* Define to rpl_malloc if the replacement function should be used. */
#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
......@@ -25,11 +25,12 @@ String ValueAction::getName(bool to_undo) const {
// ----------------------------------------------------------------------------- : Simple
/// 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 {
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)
, member(member)
{}
virtual void perform(bool to_undo) {
......@@ -50,13 +51,14 @@ class SimpleValueAction : public ValueAction {
private:
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 MultipleChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<MultipleChoiceValue, &MultipleChoiceValue::value, false>(value, new_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 ImageValueP& value, const FileName& new_value) { return new SimpleValueAction<ImageValue, &ImageValue::filename, false>(value, new_value); }
ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction<SymbolValue, &SymbolValue::filename, false>(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, false>(value, new_value, &MultipleChoiceValue::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, false>(value, new_value, &ImageValue::filename); }
ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction<SymbolValue, false>(value, new_value, &SymbolValue::filename); }
// ----------------------------------------------------------------------------- : Text
......
......@@ -48,7 +48,7 @@ void reflect_font(Reader& tag, Font& font) {
REFLECT(weight);
REFLECT(style);
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 (!style.empty()) font.font.SetWeight(style == _("italic") ? wxITALIC : wxNORMAL);
}
......
......@@ -34,7 +34,7 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) {
}
RealSize size = viewer.getRotation().getExternalSize();
// 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"));
wxMemoryDC dc;
dc.SelectObject(bitmap);
......
......@@ -21,8 +21,8 @@ DECLARE_TYPEOF_COLLECTION(StatsDimensionP);
IMPLEMENT_DYNAMIC_ARG(Game*, game_for_reading, nullptr);
Game::Game()
: dependencies_initialized(false)
, has_keywords(false)
: has_keywords(false)
, dependencies_initialized(false)
{}
GameP Game::byName(const String& name) {
......
......@@ -99,8 +99,8 @@ class SymbolInFont {
};
SymbolInFont::SymbolInFont()
: actual_size(0,0)
, enabled(true)
: enabled(true)
, actual_size(0,0)
{
assert(symbol_font_for_reading());
img_size = symbol_font_for_reading()->img_size;
......@@ -118,8 +118,8 @@ Bitmap SymbolInFont::getBitmap(Context& ctx, Package& pkg, double size) {
Image img = image.generate(ctx, pkg)->image;
actual_size = wxSize(img.GetWidth(), img.GetHeight());
// scale to match expected size
Image resampled_image(actual_size.GetWidth() * size / img_size,
actual_size.GetHeight() * size / img_size, false);
Image resampled_image((int) (actual_size.GetWidth() * size / img_size),
(int) (actual_size.GetHeight() * size / img_size), false);
if (!resampled_image.Ok()) return Bitmap(1,1);
resample(img, resampled_image);
// convert to bitmap, store for later use
......@@ -145,7 +145,7 @@ RealSize SymbolInFont::size(Context& ctx, Package& pkg, double size) {
// we don't know what size the image will be
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) {
......
......@@ -67,8 +67,8 @@ END_EVENT_TABLE ()
HoverButton::HoverButton(Window* parent, int id, const String& name, const Color& background)
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, wxNO_BORDER )
, hover(false), focus(false), mouse_down(false), key_down(false)
, last_drawn(nullptr)
, background(background)
, last_drawn(nullptr)
{
loadBitmaps(name);
SetSize(DoGetBestSize());
......
......@@ -38,8 +38,8 @@ class GalleryList : public wxScrolledWindow {
static const size_t NO_SELECTION = (size_t)-1;
size_t selection; ///< The selected item, or NO_SELECTION if there is no selection
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 scroll_increment; ///< How large are the scroll steps?
/// Redraw the list after changing the selection or the number of items
void update();
......
......@@ -16,8 +16,8 @@
SymbolBasicShapeEditor::SymbolBasicShapeEditor(SymbolControl* control)
: SymbolEditorBase(control)
, drawing(false)
, mode(ID_SHAPE_CIRCLE)
, drawing(false)
{
control->SetCursor(*wxCROSS_CURSOR);
}
......
......@@ -152,7 +152,7 @@ void SymbolControl::draw(DC& dc) {
wxSize s = dc.GetSize();
int lines = settings.symbol_grid_size;
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(i%5 == 0 ? 64 : 31, 0, 0));
dc.SetLogicalFunction(wxAND);
......
......@@ -91,7 +91,7 @@ Image load_resource_image(const String& name) {
return wxImage(stream);
#elif defined(__linux__)
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;
if (wxFileExists(file + _(".png"))) resource.LoadFile(file + _(".png"));
else if (wxFileExists(file + _(".bmp"))) resource.LoadFile(file + _(".bmp"));
......
......@@ -186,7 +186,7 @@ void SymbolViewer::drawSymbolPart(const SymbolPart& part, DC* border, DC* interi
// white/black
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]);
}
// draw interior
......
......@@ -30,7 +30,7 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
i = img.update(viewer.getContext(), *viewer.stylesheet, 0, 0);
} else {
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
);
}
......
......@@ -70,7 +70,7 @@ void ImageValueViewer::onStyleChange() {
void ImageValueViewer::loadMask(const Rotation& rot) const {
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
// (re) load the mask
Image image;
......
......@@ -30,7 +30,7 @@ void SymbolValueViewer::draw(RotatedDC& dc) {
// render and filter variations
FOR_EACH(variation, style().variations) {
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);
symbols.push_back(Bitmap(resampled));
}
......
......@@ -60,13 +60,13 @@ SCRIPT_FUNCTION(contains) {
SCRIPT_RULE_1(format, String, format) {
String fmt = _("%") + replace_all(format, _("%"), _(""));
// 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_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_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_RETURN(format_string(fmt, input));
} else {
......
......@@ -33,6 +33,7 @@ String english_number(int i) {
case 18: return _("eighteen");
case 20: return _("twenty");
case 30: return _("thirty");
case 40: return _("forty");
case 50: return _("fifty");
case 80: return _("eighty");
default: {
......@@ -40,7 +41,7 @@ String english_number(int i) {
// number too large, keep as digits
return (String() << i);
} else if (i < 20) {
return english_number(i%10) + english_number(10);
return english_number(i%10) + _("teen");
} else if (i % 10 == 0) {
return english_number(i/10) + _("ty");
} else {
......
......@@ -245,21 +245,21 @@ class ScriptCustomCollectionIterator : public ScriptIterator {
: pos(0), col(col), colP(colP) {}
virtual ScriptValueP next() {
if (pos < col->size()) {
return to_script(col->at(pos++));
return col->at(pos++);
} else {
return ScriptValueP();
}
}
private:
size_t pos;
ScriptValueP colP; // for ownership of the collection
const vector<ScriptValueP>* col;
ScriptValueP colP; // for ownership of the collection
};
ScriptValueP ScriptCustomCollection::getMember(const String& name) const {
long index;
if (name.ToLong(&index) && index >= 0 && (size_t)index < value.size()) {
return to_script(value.at(index));
return value.at(index);
} else {
return ScriptValue::getMember(name);
}
......
......@@ -125,7 +125,7 @@ void Package::saveAs(const String& name, bool removeUnused) {
// ----------------------------------------------------------------------------- : Package : inside
/*
#if 0
/// Class that is a wxZipInputStream over a wxFileInput stream
/** Note that wxFileInputStream is also a base class, because it must be constructed first
* This class requires a patch in wxWidgets (2.5.4)
......@@ -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)
*
* NOTE: Not used with wx 2.6.3, since it doesn't support seeking
* /
*/
class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream {
public:
ZipFileInputStream(const String& filename, wxZipEntry* entry)
......@@ -146,7 +146,7 @@ class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream {
OpenEntry(*entry);
}
};
*/
#endif
InputStreamP Package::openIn(const String& file) {
if (!file.empty() && file.GetChar(0) == _('/')) {
......
......@@ -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) {
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
#endif
......@@ -131,14 +131,14 @@ void RotatedDC::DrawText (const String& text, const RealPoint& pos) {
draw_resampled_text(dc, r_ext, revX(), revY(), angle, text);
} else {
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) {
if (angle == 0) {
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 {
DrawImage(bitmap.ConvertToImage(), pos);
}
......@@ -175,7 +175,7 @@ void RotatedDC::SetFont(const wxFont& font) {
SetFont(font, font.GetPointSize());
}
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);
}
......
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