diff --git a/src/data/action/symbol_part.cpp b/src/data/action/symbol_part.cpp index 82d1aaa0..afc2c611 100644 --- a/src/data/action/symbol_part.cpp +++ b/src/data/action/symbol_part.cpp @@ -18,7 +18,7 @@ inline double sgn(double v) { return v > 0 ? 1 : -1; } Vector2D constrainVector(const Vector2D& v, bool constrain, bool onlyDiagonal) { if (!constrain) return v; - double ax = abs(v.x), ay = abs(v.y); + double ax = fabs(v.x), ay = fabs(v.y); if (ax * 2 < ay && !onlyDiagonal) { return Vector2D(0, v.y); // vertical } else if(ay * 2 < ax && !onlyDiagonal) { diff --git a/src/data/card.hpp b/src/data/card.hpp index 317b4c79..dc5e76da 100644 --- a/src/data/card.hpp +++ b/src/data/card.hpp @@ -11,6 +11,8 @@ #include #include +#include +#include // for Card::value class Game; class Dependency; diff --git a/src/data/font.hpp b/src/data/font.hpp index 64fff1e0..9ebf4e02 100644 --- a/src/data/font.hpp +++ b/src/data/font.hpp @@ -35,7 +35,7 @@ class Font { /// Update the scritables, returns true if there is a change bool update(Context& ctx); /// Add the given dependency to the dependent_scripts list for the variables this font depends on - virtual void initDependencies(Context&, const Dependency&) const; + void initDependencies(Context&, const Dependency&) const; /// Does this font have a shadow? inline bool hasShadow() { return shadow_displacement.width != 0 || shadow_displacement.height != 0; } diff --git a/src/data/keyword.cpp b/src/data/keyword.cpp index 683bcc2b..ebdcf087 100644 --- a/src/data/keyword.cpp +++ b/src/data/keyword.cpp @@ -38,7 +38,7 @@ void read_compat(Reader& tag, Keyword* k) { KeywordExpansionP e(new KeywordExpansion); size_t start = separator.find_first_of('['); size_t end = separator.find_first_of(']'); - if (start != String.npos && end != String.npos) { + if (start != String::npos && end != String::npos) { e->after += separator.substr(start + 1, end - start - 1); } if (!parameter.empty()) { diff --git a/src/data/set.cpp b/src/data/set.cpp index ef1ff370..e8ff7be1 100644 --- a/src/data/set.cpp +++ b/src/data/set.cpp @@ -37,8 +37,8 @@ Set::Set(const GameP& game) } Set::Set(const StyleSheetP& stylesheet) - : stylesheet(stylesheet) - , game(stylesheet->game) + : game(stylesheet->game) + , stylesheet(stylesheet) , script_manager(new SetScriptManager(*this)) { data.init(game->set_fields); diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 02351cd4..4c55b4da 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -83,13 +83,13 @@ IMPLEMENT_REFLECTION(StyleSheetSettings) { Settings settings; Settings::Settings() - : set_window_maximized (false) + : locale (_("en")) + , set_window_maximized (false) , set_window_width (790) , set_window_height (300) , card_notes_height (40) - , updates_url (_("http://magicseteditor.sourceforge.net/updates")) , check_updates (CHECK_IF_CONNECTED) - , locale (_("en")) + , updates_url (_("http://magicseteditor.sourceforge.net/updates")) {} void Settings::addRecentFile(const String& filename) { diff --git a/src/data/statistics.hpp b/src/data/statistics.hpp index c986ab22..c2902079 100644 --- a/src/data/statistics.hpp +++ b/src/data/statistics.hpp @@ -26,12 +26,12 @@ class StatsDimension { StatsDimension(); StatsDimension(const Field&); + bool automatic; ///< Based on a card field? String name; ///< Name of this dimension String description; ///< Description, used in status bar String icon_filename; ///< Icon for lists OptionalScript script; ///< Script that determines the value(s) bool numeric; ///< Are the values numeric? If so, they require special sorting - bool automatic; ///< Based on a card field? DECLARE_REFLECTION(); }; @@ -51,13 +51,13 @@ class StatsCategory { StatsCategory(); StatsCategory(const StatsDimensionP&); + bool automatic; ///< Automatically generated? String name; ///< Name/label String description; ///< Description, used in status bar String icon_filename; ///< Icon for lists Bitmap icon; ///< The loaded icon (optional of course) vector dimensions; ///< The dimensions to use, higher dimensions may be null GraphType type; ///< Type of graph to use - bool automatic; ///< Automatically generated? DECLARE_REFLECTION(); }; diff --git a/src/data/symbol.cpp b/src/data/symbol.cpp index 5b57bc47..8be28842 100644 --- a/src/data/symbol.cpp +++ b/src/data/symbol.cpp @@ -41,16 +41,16 @@ ControlPoint::ControlPoint() , lock(LOCK_FREE) {} ControlPoint::ControlPoint(double x, double y) - : segment_before(SEGMENT_LINE), segment_after(SEGMENT_LINE) + : pos(x,y) + , segment_before(SEGMENT_LINE), segment_after(SEGMENT_LINE) , lock(LOCK_FREE) - , pos(x,y) {} ControlPoint::ControlPoint(double x, double y, double xb, double yb, double xa, double ya, LockMode lock) - : segment_before(SEGMENT_CURVE), segment_after(SEGMENT_CURVE) - , lock(lock) - , pos(x,y) + : pos(x,y) , delta_before(xb,yb) , delta_after(xa,ya) + , segment_before(SEGMENT_CURVE), segment_after(SEGMENT_CURVE) + , lock(lock) {} void ControlPoint::onUpdateHandle(WhichHandle wh) { diff --git a/src/gui/control/card_editor.cpp b/src/gui/control/card_editor.cpp index 8cf9760e..ed4105a0 100644 --- a/src/gui/control/card_editor.cpp +++ b/src/gui/control/card_editor.cpp @@ -100,7 +100,7 @@ struct CompareTabIndex { Field& af = *as.fieldP, &bf = *bs.fieldP; if (af.tab_index < bf.tab_index) return true; if (af.tab_index > bf.tab_index) return false; - if (abs(as.top - bs.top) < 15) { + if (fabs(as.top - bs.top) < 15) { // the fields are almost on the same 'row' // compare horizontally first if (as.left < bs.left) return true; // horizontal sorting diff --git a/src/gui/control/card_list_column_select.cpp b/src/gui/control/card_list_column_select.cpp index fe0ae5e2..0fd7bcd2 100644 --- a/src/gui/control/card_list_column_select.cpp +++ b/src/gui/control/card_list_column_select.cpp @@ -79,8 +79,10 @@ void CardListColumnSelectDialog::initList() { // check int i = list->GetCount() - 1; list->Check(i, c.settings.visible); - // fix the background color - list->GetItem(i)->SetBackgroundColour(window_color); + #ifdef _WX_MSW_ + // fix the background color + list->GetItem(i)->SetBackgroundColour(window_color); + #endif } } diff --git a/src/gui/control/card_viewer.cpp b/src/gui/control/card_viewer.cpp index 1687c01b..9b9b520d 100644 --- a/src/gui/control/card_viewer.cpp +++ b/src/gui/control/card_viewer.cpp @@ -80,7 +80,7 @@ void CardViewer::drawViewer(RotatedDC& dc, ValueViewer& v) { } bool CardViewer::shouldDraw(const ValueViewer& v) const { - return GetUpdateRegion().Contains((wxRect)v.boundingBox()) != wxOutRegion; + return GetUpdateRegion().Contains(v.boundingBox().toRect()) != wxOutRegion; } // helper class for overdrawDC() diff --git a/src/gui/control/gallery_list.cpp b/src/gui/control/gallery_list.cpp index 4d85173e..2dc64848 100644 --- a/src/gui/control/gallery_list.cpp +++ b/src/gui/control/gallery_list.cpp @@ -22,13 +22,13 @@ const int BORDER = 1; // margin between items GalleryList::GalleryList(Window* parent, int id, int direction) : wxScrolledWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | (direction == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL) ) - , direction(direction) , selection(NO_SELECTION) + , direction(direction) {} void GalleryList::update() { - const int w = item_size.width + MARGIN + 2*BORDER; - const int h = item_size.height + MARGIN + 2*BORDER; + const int w = (int)item_size.width + MARGIN + 2*BORDER; + const int h = (int)item_size.height + MARGIN + 2*BORDER; // resize and scroll if (direction == wxHORIZONTAL) { SetVirtualSize(w * (int)itemCount() + MARGIN, h + MARGIN); @@ -56,11 +56,11 @@ void GalleryList::update() { size_t GalleryList::findItem(const wxMouseEvent& ev) const { if (direction == wxHORIZONTAL) { - int x, w = item_size.width + MARGIN + 2*BORDER; + int x, w = (int)item_size.width + MARGIN + 2*BORDER; GetViewStart (&x, 0); return static_cast( x + ev.GetX() / w ); } else { // wxVERTICAL - int y, h = item_size.height + MARGIN + 2*BORDER; + int y, h = (int)item_size.height + MARGIN + 2*BORDER; GetViewStart (0, &y); return static_cast( y + ev.GetY() / h ); } diff --git a/src/gui/control/native_look_editor.cpp b/src/gui/control/native_look_editor.cpp index 615461e3..5dcaefe0 100644 --- a/src/gui/control/native_look_editor.cpp +++ b/src/gui/control/native_look_editor.cpp @@ -40,14 +40,14 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) { dc.SetFont(*wxNORMAL_FONT); dc.DrawText(capitalize_sentence(s.fieldP->name), RealPoint(margin_left, s.top + 1)); // draw 3D border - draw_control_border(this, dc.getDC(), wxRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2)); + draw_control_border(this, dc.getDC(), RealRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2)); // draw viewer v.draw(dc); } void NativeLookEditor::resizeViewers() { // size stuff - UInt y = margin; + double y = margin; int w; GetClientSize(&w, 0); const int default_height = 17; diff --git a/src/gui/control/package_list.cpp b/src/gui/control/package_list.cpp index 76d88a70..e26f9cda 100644 --- a/src/gui/control/package_list.cpp +++ b/src/gui/control/package_list.cpp @@ -35,12 +35,12 @@ void PackageList::drawItem(DC& dc, int x, int y, size_t item, bool selected) { dc.SetFont(wxFont(12,wxSWISS,wxNORMAL,wxBOLD,false,_("Arial"))); dc.GetTextExtent(capitalize(d.package->short_name), &w, &h); pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); - dc.DrawText(capitalize(d.package->short_name), pos.x, pos.y + 110); + dc.DrawText(capitalize(d.package->short_name), (int)pos.x, (int)pos.y + 110); // draw name dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); dc.GetTextExtent(d.package->full_name, &w, &h); RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); - dc.DrawText(d.package->full_name, text_pos.x, text_pos.y + 130); + dc.DrawText(d.package->full_name, (int)text_pos.x, (int)text_pos.y + 130); } void PackageList::showData(const String& pattern) { diff --git a/src/gui/control/package_list.hpp b/src/gui/control/package_list.hpp index 34aac9b2..2057976b 100644 --- a/src/gui/control/package_list.hpp +++ b/src/gui/control/package_list.hpp @@ -10,6 +10,7 @@ // ----------------------------------------------------------------------------- : Includes #include +#include #include DECLARE_POINTER_TYPE(Packaged); diff --git a/src/gui/control/select_card_list.hpp b/src/gui/control/select_card_list.hpp index 80a85e6d..fdcbd758 100644 --- a/src/gui/control/select_card_list.hpp +++ b/src/gui/control/select_card_list.hpp @@ -11,6 +11,7 @@ #include #include +#include // ----------------------------------------------------------------------------- : SelectCardList @@ -30,7 +31,7 @@ class SelectCardList : public CardListBase { private: DECLARE_EVENT_TABLE(); - set selected; ///< which cards are selected? + std::set selected; ///< which cards are selected? void toggle(const CardP& card); diff --git a/src/gui/control/text_ctrl.cpp b/src/gui/control/text_ctrl.cpp index fba3ea61..64d8eeae 100644 --- a/src/gui/control/text_ctrl.cpp +++ b/src/gui/control/text_ctrl.cpp @@ -55,7 +55,7 @@ void TextCtrl::setValue(String* value) { style->width = cs.GetWidth() - 2; style->height = cs.GetHeight() - 2; viewers.front()->getEditor()->determineSize(true); - SetMinSize(wxSize(style->width + 6, style->height + 6)); + SetMinSize(RealSize(style->width + 6, style->height + 6)); } valueChanged(); } diff --git a/src/gui/drop_down_list.cpp b/src/gui/drop_down_list.cpp index 471a7c75..2f5a30a2 100644 --- a/src/gui/drop_down_list.cpp +++ b/src/gui/drop_down_list.cpp @@ -56,15 +56,15 @@ class DropDownHider : public wxEvtHandler { DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer) : wxPopupWindow(parent) - , mouse_down(false) - , selected_item(NO_SELECTION) - , open_sub_menu(nullptr) - , parent_menu(nullptr) - , hider(is_submenu ? nullptr : new DropDownHider(*this)) - , viewer(viewer) + , text_offset(1) , item_size(100,1) , icon_size(0,0) - , text_offset(1) + , selected_item(NO_SELECTION) + , mouse_down(false) + , open_sub_menu(nullptr) + , parent_menu(nullptr) + , viewer(viewer) + , hider(is_submenu ? nullptr : new DropDownHider(*this)) { if (is_submenu) { parent_menu = &dynamic_cast(*GetParent()); @@ -110,16 +110,16 @@ void DropDownList::show(bool in_place, wxPoint pos) { // Position the drop down list below the editor control (based on the style) RealRect r = viewer->viewer.getRotation().trNoNeg(viewer->getStyle()->getRect()); if (viewer->viewer.nativeLook()) { - pos = wxPoint(r.x - 3, r.y - 3); + pos = RealPoint(r.x - 3, r.y - 3); size.width = max(size.width, r.width + 6); - parent_height = r.height + 6; + parent_height = (int)r.height + 6; } else { - pos = wxPoint(r.x - 1, r.y - 1); + pos = RealPoint(r.x - 1, r.y - 1); size.width = max(size.width, r.width + 2); - parent_height = r.height; + parent_height = (int)r.height; } } else if (parent_menu) { - parent_height = -item_size.height - 1; + parent_height = -(int)item_size.height - 1; } pos = GetParent()->ClientToScreen(pos); // move & resize @@ -191,7 +191,7 @@ bool DropDownList::showSubMenu(size_t item, int y) { wxSize size = GetSize(); sub_menu->show(true, sub_menu->GetParent()->ScreenToClient(ClientToScreen( - wxPoint(size.GetWidth() - 1, y + item_size.height) + wxPoint(size.GetWidth() - 1, y + (int)item_size.height) ))); return true; } @@ -201,7 +201,7 @@ int DropDownList::itemPosition(size_t item) const { size_t count = itemCount(); for (size_t i = 0 ; i < count ; ++i) { if (i == item) return y; - y += item_size.height + lineBelow(item); + y += (int)item_size.height + lineBelow(item); } // not found assert(false); @@ -237,7 +237,7 @@ void DropDownList::draw(DC& dc) { size_t count = itemCount(); for (size_t i = 0 ; i < count ; ++i) { drawItem(dc, y, i); - y += item_size.height + lineBelow(i); + y += (int)item_size.height + lineBelow(i); } } @@ -247,27 +247,27 @@ void DropDownList::drawItem(DC& dc, int y, size_t item) { if (item == selected_item) { dc.SetBrush (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); - dc.DrawRectangle(marginW, y, item_size.width, item_size.height); + dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height); } else if (highlightItem(item)) { // mix a color between selection and window dc.SetBrush (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - dc.DrawRectangle(marginW, y, item_size.width, item_size.height); + dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height); } else { dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } // draw text and icon drawIcon(dc, marginW, y, item, item == selected_item); - dc.DrawText(capitalize(itemText(item)), marginW + icon_size.width + 1, y + text_offset); + dc.DrawText(capitalize(itemText(item)), marginW + (int)icon_size.width + 1, y + text_offset); // draw popup icon if (submenu(item)) { - draw_menu_arrow(this, dc, wxRect(marginW, y, item_size.width, item_size.height), item == selected_item); + draw_menu_arrow(this, dc, RealRect(marginW, y, item_size.width, item_size.height), item == selected_item); } // draw line below if (lineBelow(item)) { dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)); - dc.DrawLine(marginW, y + item_size.height, marginW + item_size.width, y + item_size.height); + dc.DrawLine(marginW, y + (int)item_size.height, marginW + (int)item_size.width, y + (int)item_size.height); } } @@ -293,7 +293,7 @@ void DropDownList::onMotion(wxMouseEvent& ev) { int startY = marginH; size_t count = itemCount(); for (size_t i = 0 ; i < count ; ++i) { - int endY = startY + item_size.height; + int endY = startY + (int)item_size.height; if (ev.GetY() >= startY && ev.GetY() < endY) { selected_item = i; showSubMenu(i, startY); diff --git a/src/gui/icon_menu.cpp b/src/gui/icon_menu.cpp index 6f0fef36..a3273940 100644 --- a/src/gui/icon_menu.cpp +++ b/src/gui/icon_menu.cpp @@ -47,15 +47,24 @@ Image generateDisabledImage(const Image& imgIn) { // ----------------------------------------------------------------------------- : IconMenu void IconMenu::Append(int id, const String& resource, const String& text, const String& help, int style, wxMenu* submenu) { - // load bitmap - Bitmap bitmap(resource); - bitmap = bitmap.GetSubBitmap(wxRect(0,0,16,16)); - Image disabledImage = generateDisabledImage(bitmap.ConvertToImage()); - // add menu item - wxMenuItem* item = new wxMenuItem(this, id, text, help, style, submenu); - item->SetBitmaps(bitmap, bitmap); - item->SetDisabledBitmap(disabledImage); - wxMenu::Append(item); + #ifdef __WXMSW__ + // load bitmap + Bitmap bitmap(resource); + bitmap = bitmap.GetSubBitmap(wxRect(0,0,16,16)); + Image disabledImage = generateDisabledImage(bitmap.ConvertToImage()); + // add menu item + wxMenuItem* item = new wxMenuItem(this, id, text, help, style, submenu); + item->SetBitmaps(bitmap, bitmap); + item->SetDisabledBitmap(disabledImage); + wxMenu::Append(item); + #else + // load bitmap + Bitmap bitmap = loadResourceImage(resource); + // add menu + wxMenuItem* item = new wxMenuItem(this, id, text, help, style, submenu); + item->SetBitmaps(bitmap); + wxMenu::Append(item); + #endif } void IconMenu::Append(int id, const String& text, const String& help) { diff --git a/src/gui/preferences_window.cpp b/src/gui/preferences_window.cpp index 62859c3c..08870175 100644 --- a/src/gui/preferences_window.cpp +++ b/src/gui/preferences_window.cpp @@ -126,7 +126,7 @@ DisplayPreferencesPage::DisplayPreferencesPage(Window* parent) borders-> SetValue( settings.default_stylesheet_settings.card_borders()); non_normal_export->SetValue(!settings.default_stylesheet_settings.card_normal_export()); zoom->SetRange(1, 1000); - zoom-> SetValue( settings.default_stylesheet_settings.card_zoom() * 100); + zoom-> SetValue(static_cast(settings.default_stylesheet_settings.card_zoom() * 100)); // init sizer wxSizer* s = new wxBoxSizer(wxVERTICAL); wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Card Display")); diff --git a/src/gui/set/stats_panel.cpp b/src/gui/set/stats_panel.cpp index b8be5fe9..2a8cc452 100644 --- a/src/gui/set/stats_panel.cpp +++ b/src/gui/set/stats_panel.cpp @@ -149,7 +149,7 @@ class StatsFilter : public CardListFilter { virtual bool keep(const CardP& card) { Context& ctx = set.getContext(card); FOR_EACH(v, values) { - if ((String)*v.first->script.invoke(ctx) != v.second) return false; + if (v.first->script.invoke(ctx)->toString() != v.second) return false; } return true; } diff --git a/src/gui/symbol/basic_shape_editor.cpp b/src/gui/symbol/basic_shape_editor.cpp index 9c8710d8..3cd47554 100644 --- a/src/gui/symbol/basic_shape_editor.cpp +++ b/src/gui/symbol/basic_shape_editor.cpp @@ -160,10 +160,10 @@ void SymbolBasicShapeEditor::makeShape(const Vector2D& a, const Vector2D& b, boo // constrain Vector2D size = b - a; if (constrained) { - if (abs(size.x) > abs(size.y)) { - size.y = sgn(size.y) * abs(size.x); + if (fabs(size.x) > fabs(size.y)) { + size.y = sgn(size.y) * fabs(size.x); } else { - size.x = sgn(size.x) * abs(size.y); + size.x = sgn(size.x) * fabs(size.y); } } // make shape diff --git a/src/gui/util.cpp b/src/gui/util.cpp index 8e38f54b..0e2013a4 100644 --- a/src/gui/util.cpp +++ b/src/gui/util.cpp @@ -12,7 +12,7 @@ #include #include -#if wxUSE_UXTHEME +#if wxUSE_UXTHEME && defined(__WXMSW__) #include #include #include @@ -109,7 +109,7 @@ void draw3DBorder(DC& dc, int x1, int y1, int x2, int y2) { } void draw_control_border(Window* win, DC& dc, const wxRect& rect) { - #if wxUSE_UXTHEME + #if wxUSE_UXTHEME && defined(__WXMSW__) RECT r; wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get(); if (themeEngine && themeEngine->IsAppThemed()) { diff --git a/src/gui/value/choice.cpp b/src/gui/value/choice.cpp index 7c5981e1..d4b8c053 100644 --- a/src/gui/value/choice.cpp +++ b/src/gui/value/choice.cpp @@ -23,8 +23,8 @@ class ChoiceThumbnailRequest : public ThumbnailRequest { virtual Image generate(); virtual void store(const Image&); private: - int id; StyleSheetP stylesheet; + int id; }; ChoiceThumbnailRequest::ChoiceThumbnailRequest(ChoiceValueEditor* cve, int id) @@ -84,8 +84,8 @@ void ChoiceThumbnailRequest::store(const Image& img) { DropDownChoiceList::DropDownChoiceList(Window* parent, bool is_submenu, ChoiceValueEditor& cve, ChoiceField::ChoiceP group) : DropDownList(parent, is_submenu, is_submenu ? nullptr : &cve) - , group(group) , cve(cve) + , group(group) { icon_size.width = 16; icon_size.height = 16; diff --git a/src/gui/value/color.cpp b/src/gui/value/color.cpp index 64a7d01a..adc52ea5 100644 --- a/src/gui/value/color.cpp +++ b/src/gui/value/color.cpp @@ -53,7 +53,7 @@ DropDownColorList::DropDownColorList(Window* parent, ColorValueEditor& cve) { icon_size.width = 25; if (item_size.height < 16) { - text_offset = (16 - item_size.height) / 2; + text_offset = (16 - (int)item_size.height) / 2; item_size.height = 16; } } @@ -86,7 +86,7 @@ void DropDownColorList::drawIcon(DC& dc, int x, int y, size_t item, bool selecte // draw a rectangle with the right color dc.SetPen(wxSystemSettings::GetColour(selected ? wxSYS_COLOUR_HIGHLIGHTTEXT : wxSYS_COLOUR_WINDOWTEXT)); dc.SetBrush(col); - dc.DrawRectangle(x+1, y+1, icon_size.width-2, item_size.height-2); + dc.DrawRectangle(x+1, y+1, (int)icon_size.width-2, (int)item_size.height-2); } diff --git a/src/gui/value/editor.hpp b/src/gui/value/editor.hpp index 0be731c5..3229ab11 100644 --- a/src/gui/value/editor.hpp +++ b/src/gui/value/editor.hpp @@ -31,6 +31,7 @@ */ class ValueEditor { public: + virtual ~ValueEditor(); // --------------------------------------------------- : Events /// This editor gains focus diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index 3853ea8b..40b8486a 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -605,10 +605,10 @@ void TextValueEditor::determineSize(bool force_fit) { if (!force_fit) style().height = 100; int sbw = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); scrollbar->SetSize( - style().left + style().width - sbw + 1, - style().top - 1, - sbw, - style().height + 2); + (int)style().left + style().width - sbw + 1, + (int)style().top - 1, + (int)sbw, + (int)style().height + 2); v.reset(); } else { // Height depends on font @@ -681,4 +681,4 @@ void TextValueEditor::prepareDrawScrollbar(RotatedDC& dc) { updateScrollbar(); style().width.mutate() += scrollbar_width; } -} \ No newline at end of file +} diff --git a/src/gui/value/text.hpp b/src/gui/value/text.hpp index d9a02a73..8111fac8 100644 --- a/src/gui/value/text.hpp +++ b/src/gui/value/text.hpp @@ -84,8 +84,9 @@ class TextValueEditor : public TextValueViewer, public ValueEditor { private: size_t selection_start, selection_end; ///< Cursor position/selection (if any), cursor positions size_t selection_start_i, selection_end_i; ///< Cursor position/selection, character indices - TextValueEditorScrollBar* scrollbar; ///< Scrollbar for multiline fields in native look - bool select_words; ///< Select whole words when dragging the mouse? + bool select_words; ///< Select whole words when dragging the mouse? + TextValueEditorScrollBar* scrollbar; ///< Scrollbar for multiline fields in native look + bool scroll_with_cursor; ///< When the cursor moves, should the scrollposition change? // --------------------------------------------------- : Selection / movement @@ -126,10 +127,7 @@ class TextValueEditor : public TextValueViewer, public ValueEditor { // --------------------------------------------------- : Scrolling friend class TextValueEditorScrollBar; - - /// When the cursor moves, should the scrollposition change? - bool scroll_with_cursor; - + /// Scroll to the given position, called by scrollbar void scrollTo(int pos); /// Update the scrollbar to show the current scroll position diff --git a/src/gui/welcome_window.cpp b/src/gui/welcome_window.cpp index 428b0b54..2ef20cd1 100644 --- a/src/gui/welcome_window.cpp +++ b/src/gui/welcome_window.cpp @@ -107,8 +107,8 @@ END_EVENT_TABLE () HoverButtonExt::HoverButtonExt(Window* parent, int id, const String& icon_name, const String& label, const String& sub_label) : HoverButton(parent, id, _("BTN")) - , label(label), sub_label(sub_label) , icon(load_resource_image(icon_name)) + , label(label), sub_label(sub_label) , font_large(14, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial")) , font_small(8, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial")) {} diff --git a/src/render/symbol/filter.cpp b/src/render/symbol/filter.cpp index d370e374..4cae4f26 100644 --- a/src/render/symbol/filter.cpp +++ b/src/render/symbol/filter.cpp @@ -122,7 +122,7 @@ AColor LinearGradientSymbolFilter::color(double x, double y, SymbolSet point) co } double LinearGradientSymbolFilter::t(double x, double y) const { - double t= abs( (x - center_x) * (end_x - center_x) + (y - center_y) * (end_y - center_y)) / len; + double t= fabs( (x - center_x) * (end_x - center_x) + (y - center_y) * (end_y - center_y)) / len; return min(1.,max(0.,t)); } diff --git a/src/render/text/element.hpp b/src/render/text/element.hpp index a7a30096..7ab47689 100644 --- a/src/render/text/element.hpp +++ b/src/render/text/element.hpp @@ -48,10 +48,10 @@ struct CharInfo { /// A section of text that can be rendered using a TextViewer class TextElement { public: - /// What section of the input string is this element? - size_t start, end; /// The text of which a subsection is drawn String text; + /// What section of the input string is this element? + size_t start, end; inline TextElement(const String& text, size_t start ,size_t end) : text(text), start(start), end(end) {} virtual ~TextElement() {} diff --git a/src/render/value/color.cpp b/src/render/value/color.cpp index 085eb5f4..3ed536dc 100644 --- a/src/render/value/color.cpp +++ b/src/render/value/color.cpp @@ -43,7 +43,7 @@ void ColorValueViewer::draw(RotatedDC& dc) { style().top_width < style().height && style().bottom_width < style().height; if (clip) { // clip away the inside of the rectangle - wxRegion r = dc.tr(style().getRect()); + wxRegion r = dc.tr(style().getRect()).toRect(); r.Subtract(dc.tr(RealRect( style().left + style().left_width, style().top + style().top_width, diff --git a/src/render/value/image.cpp b/src/render/value/image.cpp index 6341f586..e0af0a3d 100644 --- a/src/render/value/image.cpp +++ b/src/render/value/image.cpp @@ -22,7 +22,7 @@ void ImageValueViewer::draw(RotatedDC& dc) { InputStreamP image_file = getSet().openIn(value().filename); Image image; if (image.LoadFile(*image_file)) { - image.Rescale(dc.trS(style().width), dc.trS(style().height)); + image.Rescale((int)dc.trS(style().width), (int)dc.trS(style().height)); // apply mask to image loadMask(dc); if (alpha_mask) alpha_mask->setAlpha(image); @@ -34,7 +34,7 @@ void ImageValueViewer::draw(RotatedDC& dc) { } // if there is no image, generate a placeholder, only if there is enough room for it if (!bitmap.Ok() && style().width > 40) { - bitmap = imagePlaceholder(dc, dc.trS(style().width), dc.trS(style().height), viewer.drawEditing()); + bitmap = imagePlaceholder(dc, (int)dc.trS(style().width), (int)dc.trS(style().height), viewer.drawEditing()); loadMask(dc); if (alpha_mask) alpha_mask->setAlpha(bitmap); } @@ -45,15 +45,15 @@ void ImageValueViewer::draw(RotatedDC& dc) { } bool ImageValueViewer::containsPoint(const RealPoint& p) const { - int x = p.x - style().left; - int y = p.y - style().top; - if (x < 0 || y < 0 || x >= (int)style().width || y >= (int)style().height) { + double x = p.x - style().left; + double y = p.y - style().top; + if (x < 0 || y < 0 || x >= style().width || y >= style().height) { return false; // outside rectangle } // check against mask if (!style().mask_filename().empty()) { loadMask(viewer.getRotation()); - return !alpha_mask || !alpha_mask->isTransparent(x, y); + return !alpha_mask || !alpha_mask->isTransparent((int)x, (int)y); } else { return true; } @@ -70,12 +70,13 @@ void ImageValueViewer::onStyleChange() { void ImageValueViewer::loadMask(const Rotation& rot) const { if (style().mask_filename().empty()) return; // no mask - if (alpha_mask && alpha_mask->size == wxSize(rot.trS(style().width), rot.trS(style().height))) return; // mask loaded and right size + int w = rot.trS(style().width), h = 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; InputStreamP image_file = viewer.stylesheet->openIn(style().mask_filename); if (image.LoadFile(*image_file)) { - Image resampled(rot.trS(style().width), rot.trS(style().height)); + Image resampled(w,h); resample(image, resampled); alpha_mask = new_shared1(resampled); } diff --git a/src/script/context.cpp b/src/script/context.cpp index 0c39309b..32f3b5d7 100644 --- a/src/script/context.cpp +++ b/src/script/context.cpp @@ -238,11 +238,11 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) { // operator on strings or doubles or ints #define OPERATOR_SDI(OP) \ if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { \ - a = toScript((String)*a OP (String)*b); \ + a = toScript(a->toString() OP b->toString()); \ } else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \ - a = toScript((double)*a OP (double)*b); \ + a = toScript((double)*a OP (double)*b); \ } else { \ - a = toScript((int)*a OP (int)*b); \ + a = toScript((int)*a OP (int)*b); \ } \ break @@ -282,13 +282,13 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP& } else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) { a = new_intrusive2(a, b); } else if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { - a = toScript((String)*a + (String)*b); + a = toScript(a->toString() + b->toString()); } else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { - a = toScript((double)*a + (double)*b); + a = toScript((double)*a + (double)*b); } else if (at == SCRIPT_INT || bt == SCRIPT_INT) { - a = toScript((int)*a + (int)*b); + a = toScript((int)*a + (int)*b); } else { - a = toScript((String)*a + (String)*b); + a = toScript(a->toString() + b->toString()); } break; case I_SUB: OPERATOR_DI(-); diff --git a/src/script/functions.cpp b/src/script/functions.cpp index 09c2dfbb..abbd2a64 100644 --- a/src/script/functions.cpp +++ b/src/script/functions.cpp @@ -56,7 +56,7 @@ class ScriptReplaceRule : public ScriptValue { ctx.setVariable(name, toScript(value)); } // call - inside = (String)*replacement_function->eval(ctx); + inside = replacement_function->eval(ctx)->toString(); } else { regex.Replace(&inside, replacement, 1); // replace inside } @@ -92,7 +92,7 @@ SCRIPT_FUNCTION(replace_rule) { if (replace->type() == SCRIPT_FUNCTION) { ret->replacement_function = replace; } else { - ret->replacement = (String)*replace; + ret->replacement = replace->toString(); } // in_context SCRIPT_OPTIONAL_PARAM_N(String, _("in context"), in_context) { @@ -354,7 +354,7 @@ String replace_tag_contents(String input, const String& tag, const ScriptValueP& // replace ret += input.substr(0, pos); // before tag ret += tag; - ret += *contents->eval(ctx);// new contents (call) + ret += contents->eval(ctx)->toString();// new contents (call) ret += close_tag(tag); // next input = input.substr(skip_tag(input,end)); @@ -387,7 +387,7 @@ bool equal(const ScriptValue& a, const ScriptValue& b) { } else if (at == SCRIPT_DOUBLE) { return (double)a == (double)b; } else if (at == SCRIPT_STRING) { - return (String)a == (String)b; + return a.toString() == b.toString(); } else if (at == SCRIPT_OBJECT) { // HACK for ScriptObject > // assumes different types are layed out the same, and that @@ -405,7 +405,7 @@ int position_in_vector(const ScriptValueP& of, const ScriptValueP& in, const Scr ScriptType of_t = of->type(), in_t = in->type(); if (of_t == SCRIPT_STRING || in_t == SCRIPT_STRING) { // string finding - return (int)((String)*of).find(*in); // (int)npos == -1 + return (int)of->toString().find(in->toString()); // (int)npos == -1 } else if (order_by) { ScriptObject* s = dynamic_cast* >(in.get()); ScriptObject* c = dynamic_cast*>(of.get()); diff --git a/src/script/image.cpp b/src/script/image.cpp index d6eb1d90..55867ca2 100644 --- a/src/script/image.cpp +++ b/src/script/image.cpp @@ -153,7 +153,7 @@ template <> void Reader::handle(ScriptableImage& s) { if (starts_with(s.script.unparsed, _("script:"))) { s.script.unparsed = s.script.unparsed.substr(7); s.script.parse(*this); - } else if (s.script.unparsed.find_first_of('{') != String.npos) { + } else if (s.script.unparsed.find_first_of('{') != String::npos) { s.script.parse(*this, true); } else { // script is a constant function diff --git a/src/script/parser.cpp b/src/script/parser.cpp index 12385763..8271e7c5 100644 --- a/src/script/parser.cpp +++ b/src/script/parser.cpp @@ -38,10 +38,10 @@ struct Token { String value; bool newline; ///< Is there a newline between this token and the previous one? - inline operator == (TokenType t) const { return type == t; } - inline operator != (TokenType t) const { return type != t; } - inline operator == (const String& s) const { return type != TOK_STRING && value == s; } - inline operator != (const String& s) const { return type == TOK_STRING || value != s; } + inline bool operator == (TokenType t) const { return type == t; } + inline bool operator != (TokenType t) const { return type != t; } + inline bool operator == (const String& s) const { return type != TOK_STRING && value == s; } + inline bool operator != (const String& s) const { return type == TOK_STRING || value != s; } }; enum OpenBrace @@ -521,7 +521,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc // for smart strings: "x" {{ e }} "y" // optimize: "" + e -> e Instruction i = script.getInstructions().back(); - if (i.instr == I_PUSH_CONST && String(*script.getConstants()[i.data]).empty()) { + if (i.instr == I_PUSH_CONST && script.getConstants()[i.data]->toString().empty()) { script.getInstructions().pop_back(); parseOper(input, script, PREC_ALL); // e } else { @@ -531,7 +531,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc parseOper(input, script, PREC_NONE); // y // optimize: e + "" -> e i = script.getInstructions().back(); - if (i.instr == I_PUSH_CONST && String(*script.getConstants()[i.data]).empty()) { + if (i.instr == I_PUSH_CONST && script.getConstants()[i.data]->toString().empty()) { script.getInstructions().pop_back(); } else { script.addInstruction(I_BINARY, I_ADD); diff --git a/src/script/scriptable.cpp b/src/script/scriptable.cpp index ec041dba..a0e0327b 100644 --- a/src/script/scriptable.cpp +++ b/src/script/scriptable.cpp @@ -14,7 +14,7 @@ // ----------------------------------------------------------------------------- : Store -void store(const ScriptValueP& val, String& var) { var = static_cast(*val); } +void store(const ScriptValueP& val, String& var) { var = val->toString(); } void store(const ScriptValueP& val, int& var) { var = *val; } void store(const ScriptValueP& val, double& var) { var = *val; } void store(const ScriptValueP& val, bool& var) { var = static_cast(*val); } @@ -25,8 +25,8 @@ void store(const ScriptValueP& val, Defaultable& var) { var.assign(*val) // ----------------------------------------------------------------------------- : OptionalScript OptionalScript::OptionalScript(const String& script_) - : unparsed(script_) - , script(::parse(script_)) + : script(::parse(script_)) + , unparsed(script_) {} OptionalScript::~OptionalScript() {} diff --git a/src/script/value.hpp b/src/script/value.hpp index 1da28030..e5c0c450 100644 --- a/src/script/value.hpp +++ b/src/script/value.hpp @@ -57,7 +57,12 @@ class ScriptValue : public IntrusivePtrBase { virtual operator int() const; /// Convert this value to a color virtual operator Color() const; - + + /// Explicit overload to convert to a string + /** This is sometimes necessary, because wxString has an int constructor, + * which confuses gcc. */ + inline String toString() const { return *this; } + /// Get a member variable from this value virtual ScriptValueP getMember(const String& name) const; /// Signal that a script depends on a member of this value @@ -246,10 +251,11 @@ class ScriptObject : public ScriptValue { // ----------------------------------------------------------------------------- : Creating /// Convert a value to a script value -ScriptValueP toScript(int v); -ScriptValueP toScript(double v); -ScriptValueP toScript(const String& v); -ScriptValueP toScript(const Color& v); + ScriptValueP toScript(int v); +inline ScriptValueP toScript(long v) { return toScript((int) v); } + ScriptValueP toScript(double v); + ScriptValueP toScript(const String& v); + ScriptValueP toScript(const Color& v); inline ScriptValueP toScript(bool v) { return v ? script_true : script_false; } template inline ScriptValueP toScript(const vector* v) { return new_intrusive1 > >(v); } diff --git a/src/util/atomic.hpp b/src/util/atomic.hpp index 3b3f0042..b3afb18e 100644 --- a/src/util/atomic.hpp +++ b/src/util/atomic.hpp @@ -16,7 +16,7 @@ // ----------------------------------------------------------------------------- : AtomicInt : windows -#ifdef _WX_MSW_ +#ifdef __WXMSW__ #ifdef _MSC_VER extern "C" { diff --git a/src/util/order_cache.hpp b/src/util/order_cache.hpp index af2c35c1..5e1f838a 100644 --- a/src/util/order_cache.hpp +++ b/src/util/order_cache.hpp @@ -57,14 +57,14 @@ OrderCache::OrderCache(const vector& keys, const vector& values) { // initialize positions, use pos to point back to the values vector positions.reserve(keys.size()); int i = 0; - for (vector::const_iterator it = keys.begin() ; it != keys.end() ; ++it, ++i) { + for (typename vector::const_iterator it = keys.begin() ; it != keys.end() ; ++it, ++i) { positions.push_back(KV(&**it, i)); } // sort the KVs by the values sort(positions.begin(), positions.end(), CompareValues(values)); // update positions, to point to sorted list i = 0; - for (vector::iterator it = positions.begin() ; it != positions.end() ; ++it, ++i) { + for (typename vector::iterator it = positions.begin() ; it != positions.end() ; ++it, ++i) { it->second = i; } // sort the KVs by the keys diff --git a/src/util/real_point.hpp b/src/util/real_point.hpp index d9ea76f9..c1ad857d 100644 --- a/src/util/real_point.hpp +++ b/src/util/real_point.hpp @@ -152,6 +152,11 @@ class RealRect : private RealPoint, private RealSize { int i_t = to_int(y), i_b = to_int(bottom()); return wxRect(i_l, i_t, i_r - i_l, i_b - i_t); } + + /// Explicit conversion to wxRect, to not confuse gcc + inline wxRect toRect() const { + return *this; + } }; /// Split a rectangle horizontally