Commit d5e3a027 authored by coppro's avatar coppro

More warnings/minor fixes

parent fcb54c05
......@@ -328,7 +328,7 @@ void CombiningModeAction::perform(bool to_undo) {
SymbolPartNameAction::SymbolPartNameAction(const SymbolPartP& part, const String& name, size_t old_cursor, size_t new_cursor)
: part(part), part_name(name)
, new_cursor(old_cursor), old_cursor(new_cursor) // will be swapped
, old_cursor(new_cursor), new_cursor(old_cursor) // will be swapped
{}
String SymbolPartNameAction::getName(bool to_undo) const {
......
......@@ -35,7 +35,7 @@ DECLARE_POINTER_TYPE(PackageChoiceValue);
/// An Action the changes a Value
class ValueAction : public Action {
public:
inline ValueAction(const Card* card, const ValueP& value) : card(card), valueP(value) {}
inline ValueAction(const Card* card, const ValueP& value) : valueP(value), card(card) {}
virtual String getName(bool to_undo) const;
......
......@@ -161,11 +161,11 @@ int Style::update(Context& ctx) {
if (automatic_side & AUTO_LEFT) left = right - width;
else if (automatic_side & AUTO_WIDTH) width = right - left;
else if (automatic_side & AUTO_RIGHT) right = left + width;
else {int lr = left + right; left = (lr - width) / 2; right = (lr + width) / 2; }
else {int lr = int(left + right); left = (lr - width) / 2; right = (lr + width) / 2; }
if (automatic_side & AUTO_TOP) top = bottom - height;
else if (automatic_side & AUTO_HEIGHT) height = bottom - top;
else if (automatic_side & AUTO_BOTTOM) bottom = top + height;
else {int tb = top + bottom; top = (tb - height) / 2; bottom = (tb + height) / 2; }
else {int tb = int(top + bottom); top = (tb - height) / 2; bottom = (tb + height) / 2; }
// adjust rotation point
if (angle != 0 && (automatic_side & (AUTO_LEFT | AUTO_TOP))) {
double s = sin(angle * M_PI / 180), c = cos(angle * M_PI / 180);
......
......@@ -46,12 +46,13 @@ IMPLEMENT_REFLECTION(ChoiceField) {
// ----------------------------------------------------------------------------- : ChoiceField::Choice
ChoiceField::Choice::Choice()
: first_id(0)
, line_below(false), enabled(true), type(CHOICE_TYPE_CHECK)
: line_below(false), enabled(true), type(CHOICE_TYPE_CHECK)
, first_id(0)
{}
ChoiceField::Choice::Choice(const String& name)
: name(name), first_id(0)
: name(name)
, line_below(false), enabled(true), type(CHOICE_TYPE_CHECK)
, first_id(0)
{}
......
......@@ -88,7 +88,7 @@ wxFont Font::toWxFont(double scale) const {
}
} else if (name().empty()) {
font = *wxNORMAL_FONT;
font.SetPointSize(size > 1 ? size_i : scale * font.GetPointSize());
font.SetPointSize(size > 1 ? size_i : int(scale * font.GetPointSize()));
return font;
} else if (flags & FONT_ITALIC && !italic_name().empty()) {
font = wxFont(size_i, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, weight_i, underline(), italic_name());
......
......@@ -38,7 +38,7 @@ IMPLEMENT_REFLECTION(Installer) {
REFLECT(packages);
}
/*
#if 0
// ----------------------------------------------------------------------------- : Installing
void Installer::installFrom(const String& filename, bool message_on_success, bool local) {
......@@ -135,12 +135,14 @@ void Installer::install(bool local, bool check_dependencies) {
}
os.Write(*is);
}
* /
*/
}
void Installer::install(const String& package) {
// TODO
}*/
}
#endif
// ----------------------------------------------------------------------------- : Creating
......@@ -255,14 +257,14 @@ DownloadableInstaller::~DownloadableInstaller() {
InstallablePackage::InstallablePackage(const PackageVersionP& installed, const PackageDescriptionP& description)
: installed(installed)
, description(description)
, action(PACKAGE_NOTHING)
, status(PACKAGE_INSTALLED)
, action(PACKAGE_NOTHING)
{}
InstallablePackage::InstallablePackage(const PackageDescriptionP& description , const DownloadableInstallerP& installer)
: description(description)
, installer(installer)
, action(PACKAGE_NOTHING)
, status(PACKAGE_INSTALLABLE)
, action(PACKAGE_NOTHING)
{}
void InstallablePackage::determineStatus() {
......
......@@ -157,8 +157,8 @@ Settings::Settings()
, installer_list_url (_("http://magicseteditor.sourceforge.net/installers"))
, check_updates (CHECK_IF_CONNECTED)
, check_updates_all (true)
, install_type (INSTALL_DEFAULT)
, website_url (_("http://magicseteditor.sourceforge.net/"))
, install_type (INSTALL_DEFAULT)
{}
void Settings::addRecentFile(const String& filename) {
......
......@@ -107,7 +107,7 @@ void set_alpha(Image& img, Byte* al, const wxSize& alpha_size) {
}
void set_alpha(Image& img, double alpha) {
Byte b_alpha = alpha * 255;
Byte b_alpha = Byte(alpha * 255);
if (!img.HasAlpha()) {
img.InitAlpha();
memset(img.GetAlpha(), b_alpha, img.GetWidth() * img.GetHeight());
......
......@@ -31,7 +31,7 @@ Image conform_image(const Image& img, const GeneratedImage::Options& options) {
if ((iw == options.width && ih == options.height) || (options.width == 0 && options.height == 0)) {
// zoom?
if (options.zoom != 1.0) {
image = resample(image, iw * options.zoom, ih * options.zoom);
image = resample(image, int(iw * options.zoom), int(ih * options.zoom));
} else {
// already the right size
}
......
......@@ -18,7 +18,7 @@ void saturate(Image& image, double amount) {
Byte* end = pix + image.GetWidth() * image.GetHeight() * 3;
if (amount > 0) {
amount = min(amount,0.99);
int factor = 256 * amount;
int factor = int(256 * amount);
int div = 768 - 3 * factor;
while (pix != end) {
int r = pix[0], g = pix[1], b = pix[2];
......@@ -35,7 +35,7 @@ void saturate(Image& image, double amount) {
pix += 3;
}
} else {
int factor1 = 256 * -amount;
int factor1 = int(256 * -amount);
int factor2 = 768 - 3*factor1;
while (pix != end) {
int r = pix[0], g = pix[1], b = pix[2];
......
......@@ -185,8 +185,8 @@ void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, dou
// get image
mdc.SelectObject(wxNullBitmap);
// step 2. sample down
if (!sideways(angle)) w *= stretch;
else h *= stretch;
if (!sideways(angle)) w = int(w * stretch); // GCC makes annoying conversion warnings if *= is used here.
else h = int(h * stretch);
Image img_small(w, h, false);
fill_image(img_small, dc.GetTextForeground());
downsample_to_alpha(buffer, img_small);
......
......@@ -29,7 +29,7 @@ wxSize CardViewer::DoGetBestSize() const {
if (set) {
if (!stylesheet) stylesheet = set->stylesheet;
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
wxSize size(stylesheet->card_width * ss.card_zoom(), stylesheet->card_height * ss.card_zoom());
wxSize size(int(stylesheet->card_width * ss.card_zoom()), int(stylesheet->card_height * ss.card_zoom()));
if (sideways(ss.card_angle())) swap(size.x, size.y);
return size + ws - cs;
}
......
......@@ -116,9 +116,9 @@ size_t TreeList::findParent(size_t start) const {
TreeList::TreeList(Window* parent, int id, long style)
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, style | wxWANTS_CHARS | wxVSCROLL)
, selection(NOTHING)
, total_lines(0)
, first_line(0)
, selection(NOTHING)
{
// determine item size
wxClientDC dc(this);
......
......@@ -55,7 +55,7 @@ class TextBufferDC : public wxMemoryDC {
double user_scale_x, user_scale_y;
TextDraw(wxFont font, Color color, double user_scale_x, double user_scale_y, int x, int y, String text, double angle = 0)
: font(font), color(color), user_scale_x(user_scale_x), user_scale_y(user_scale_y), x(x), y(y), text(text), angle(angle)
: font(font), color(color), x(x), y(y), text(text), angle(angle), user_scale_x(user_scale_x), user_scale_y(user_scale_y)
{}
};
public:
......@@ -127,8 +127,8 @@ PageLayout::PageLayout(const StyleSheet& stylesheet, const RealSize& page_size)
card_size.width = stylesheet.card_width * 25.4 / stylesheet.card_dpi;
card_size.height = stylesheet.card_height * 25.4 / stylesheet.card_dpi;
card_landscape = card_size.width > card_size.height;
cols = floor(page_size.width / card_size.width);
rows = floor(page_size.height / card_size.height);
cols = int(floor(page_size.width / card_size.width));
rows = int(floor(page_size.height / card_size.height));
// distribute whitespace evenly
margin_left = margin_right = card_spacing.width = (page_size.width - (cols * card_size.width )) / (cols + 1);
margin_top = margin_bottom = card_spacing.height = (page_size.height - (rows * card_size.height)) / (rows + 1);
......@@ -228,7 +228,7 @@ void CardsPrintout::drawCard(DC& dc, const CardP& card, int card_nr) {
*/
// create buffers
int w = stylesheet.card_width, h = stylesheet.card_height; // in pixels
int w = int(stylesheet.card_width), h = int(stylesheet.card_height); // in pixels
if (rotation == 90) swap(w,h);
// Draw using text buffer
//TextBufferDC bufferDC(w,h,true);
......@@ -241,7 +241,7 @@ void CardsPrintout::drawCard(DC& dc, const CardP& card, int card_nr) {
// render buffer to device
double px_per_mm = 4 * stylesheet.card_dpi / 25.4;
dc.SetUserScale(scale_x / px_per_mm, scale_y / px_per_mm);
dc.SetDeviceOrigin(scale_x * pos.x, scale_y * pos.y);
dc.SetDeviceOrigin(int(scale_x * pos.x), int(scale_y * pos.y));
bufferDC.drawToDevice(dc, 0, 0); // adjust for scaling
}
......
......@@ -38,16 +38,16 @@ void SymbolSymmetryEditor::draw(DC& dc) {
if (symmetry->kind == SYMMETRY_REFLECTION) {
// draw line to handle
dc.SetPen(wxPen(color,1,wxDOT));
dc.DrawLine(center.x, center.y, handle.x, handle.y);
dc.DrawLine(int(center.x), int(center.y), int(handle.x), int(handle.y));
// draw handle
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(color);
dc.DrawCircle(handle.x, handle.y, hovered == SELECTION_HANDLE ? 7 : 4);
dc.DrawCircle(int(handle.x), int(handle.y), hovered == SELECTION_HANDLE ? 7 : 4);
}
// draw center
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(color);
dc.DrawCircle(center.x, center.y, hovered == SELECTION_CENTER ? 8 : 5);
dc.DrawCircle(int(center.x), int(center.y), hovered == SELECTION_CENTER ? 8 : 5);
}
}
......
......@@ -117,4 +117,4 @@ void PackageChoiceValueEditor::change(const String& c) {
void PackageChoiceValueEditor::initDropDown() {
if (drop_down) return;
drop_down = new_shared2<DropDownPackageChoiceList>(&editor(), this);
}
\ No newline at end of file
}
......@@ -21,9 +21,9 @@ Image render_symbol(const SymbolP& symbol, double border_radius, int width, int
double ar = symbol->aspectRatio();
double par = (double)width/height;
if (par > ar && (ar > 1 || (allow_smaller && height < width))) {
width = height * ar;
width = int(height * ar);
} else if (par < ar && (ar < 1 || (allow_smaller && width < height))) {
height = width / ar;
height = int(width / ar);
}
if (width > height) {
viewer.setZoom(width);
......@@ -354,12 +354,12 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolSymmetry& sym, HighlightSty
double a = angle + (i + 0.5) * 2 * M_PI / copies;
Vector2D dir(cos(a), sin(a));
Vector2D dir2 = rotation.tr(sym.center + 2 * dir);
dc.DrawLine(center.x, center.y, dir2.x, dir2.y);
dc.DrawLine(int(center.x), int(center.y), int(dir2.x), int(dir2.y));
}
// draw center
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(color);
dc.DrawCircle(center.x, center.y, sym.kind == SYMMETRY_ROTATION ? 7 : 5);
dc.DrawCircle(int(center.x), int(center.y), sym.kind == SYMMETRY_ROTATION ? 7 : 5);
}
void SymbolViewer::highlightPart(DC& dc, const SymbolGroup& group, HighlightStyle style) {
......
......@@ -651,7 +651,7 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars,
}
}
// how many paragraphs would fit?
int n = floor(0.5 + (dc.getInternalSize().height - style.padding_bottom) / style.paragraph_height);
int n = int(floor(0.5 + (dc.getInternalSize().height - style.padding_bottom) / style.paragraph_height));
lines.back().top = max_height * n - lines.back().line_height;
}
return lines.back().bottom() <= dc.getInternalSize().height - style.padding_bottom;
......
......@@ -35,8 +35,8 @@ void SymbolValueViewer::draw(RotatedDC& dc) {
ar = min(style().max_aspect_ratio, max(style().min_aspect_ratio, ar));
// render and filter variations
FOR_EACH(variation, style().variations) {
Image img = render_symbol(symbol, *variation->filter, variation->border_radius, 200 * ar, 200);
Image resampled((int) (wh * ar), (int) wh, false);
Image img = render_symbol(symbol, *variation->filter, variation->border_radius, int(200 * ar), 200);
Image resampled(int(wh * ar), int(wh), false);
resample(img, resampled);
symbols.push_back(Bitmap(resampled));
}
......
......@@ -575,4 +575,4 @@ String IncludePackage::typeName() const { return _("include"); }
IMPLEMENT_REFLECTION(IncludePackage) {
REFLECT_BASE(Packaged);
}
\ No newline at end of file
}
......@@ -17,8 +17,8 @@
Reader::Reader(const InputStreamP& input, Packaged* package, const String& filename, bool ignore_invalid)
: indent(0), expected_indent(0), state(OUTSIDE)
, package(package), filename(filename), line_number(0), previous_line_number(0)
, ignore_invalid(ignore_invalid)
, filename(filename), package(package), line_number(0), previous_line_number(0)
, input(input)
{
moveNext();
......@@ -27,10 +27,10 @@ Reader::Reader(const InputStreamP& input, Packaged* package, const String& filen
Reader::Reader(Packaged* pkg, const String& filename)
: indent(0), expected_indent(0), state(OUTSIDE)
, package(pkg), filename(filename), line_number(0), previous_line_number(0)
, ignore_invalid(false)
, filename(filename), package(pkg), line_number(0), previous_line_number(0)
, input(packages.openFileFromPackage(package, filename))
{
input = packages.openFileFromPackage(package, filename);
moveNext();
handleAppVersion();
}
......@@ -175,7 +175,7 @@ String read_utf8_line(wxInputStream& input, bool eat_bom, bool until_eof) {
// convert to string
buffer.push_back('\0');
size_t size = wxConvUTF8.MB2WC(nullptr, buffer.get(), 0);
if (size == -1) {
if (size == size_t(-1)) {
throw ParseError(_("Invalid UTF-8 sequence"));
} else if (size == 0) {
return _("");
......
......@@ -163,7 +163,7 @@
* When reading the first value declared is the default value
*
* Currently creates the methods:
* - Reader::handle(Enum&
* - Reader::handle(Enum&)
* - Writer::handle(const Enum&)
* - GetDefaultMember::handle(const Enum&)
*/
......
......@@ -286,7 +286,7 @@ void RotatedDC::DrawRoundedRectangle(const RealRect& r, double radius) {
void RotatedDC::DrawCircle(const RealPoint& center, double radius) {
wxPoint p = tr(center);
dc.DrawCircle(p.x + 1, p.y + 1, trS(radius));
dc.DrawCircle(p.x + 1, p.y + 1, int(trS(radius)));
}
void RotatedDC::DrawEllipticArc(const RealPoint& center, const RealSize& size, double start, double end) {
......
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