Commit 203282d0 authored by twanvl's avatar twanvl

Eliminated most build errors (gcc,linux,wxGTK).

What is left is mostly:
 - warning: converting double to int
     -> add a cast/to_int or ignore
 - wrong initialization order in ctor
     -> just swap the order to match the class
 - errors about wxCursors
     -> add a function loadResourceCursor
parent 8b272b15
...@@ -18,7 +18,7 @@ inline double sgn(double v) { return v > 0 ? 1 : -1; } ...@@ -18,7 +18,7 @@ inline double sgn(double v) { return v > 0 ? 1 : -1; }
Vector2D constrainVector(const Vector2D& v, bool constrain, bool onlyDiagonal) { Vector2D constrainVector(const Vector2D& v, bool constrain, bool onlyDiagonal) {
if (!constrain) return v; 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) { if (ax * 2 < ay && !onlyDiagonal) {
return Vector2D(0, v.y); // vertical return Vector2D(0, v.y); // vertical
} else if(ay * 2 < ax && !onlyDiagonal) { } else if(ay * 2 < ax && !onlyDiagonal) {
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <util/reflect.hpp> #include <util/reflect.hpp>
#include <util/error.hpp>
#include <data/field.hpp> // for Card::value
class Game; class Game;
class Dependency; class Dependency;
......
...@@ -35,7 +35,7 @@ class Font { ...@@ -35,7 +35,7 @@ class Font {
/// Update the scritables, returns true if there is a change /// Update the scritables, returns true if there is a change
bool update(Context& ctx); bool update(Context& ctx);
/// Add the given dependency to the dependent_scripts list for the variables this font depends on /// 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? /// Does this font have a shadow?
inline bool hasShadow() { return shadow_displacement.width != 0 || shadow_displacement.height != 0; } inline bool hasShadow() { return shadow_displacement.width != 0 || shadow_displacement.height != 0; }
......
...@@ -38,7 +38,7 @@ void read_compat(Reader& tag, Keyword* k) { ...@@ -38,7 +38,7 @@ void read_compat(Reader& tag, Keyword* k) {
KeywordExpansionP e(new KeywordExpansion); KeywordExpansionP e(new KeywordExpansion);
size_t start = separator.find_first_of('['); size_t start = separator.find_first_of('[');
size_t end = 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); e->after += separator.substr(start + 1, end - start - 1);
} }
if (!parameter.empty()) { if (!parameter.empty()) {
......
...@@ -37,8 +37,8 @@ Set::Set(const GameP& game) ...@@ -37,8 +37,8 @@ Set::Set(const GameP& game)
} }
Set::Set(const StyleSheetP& stylesheet) Set::Set(const StyleSheetP& stylesheet)
: stylesheet(stylesheet) : game(stylesheet->game)
, game(stylesheet->game) , stylesheet(stylesheet)
, script_manager(new SetScriptManager(*this)) , script_manager(new SetScriptManager(*this))
{ {
data.init(game->set_fields); data.init(game->set_fields);
......
...@@ -83,13 +83,13 @@ IMPLEMENT_REFLECTION(StyleSheetSettings) { ...@@ -83,13 +83,13 @@ IMPLEMENT_REFLECTION(StyleSheetSettings) {
Settings settings; Settings settings;
Settings::Settings() Settings::Settings()
: set_window_maximized (false) : locale (_("en"))
, set_window_maximized (false)
, set_window_width (790) , set_window_width (790)
, set_window_height (300) , set_window_height (300)
, card_notes_height (40) , card_notes_height (40)
, updates_url (_("http://magicseteditor.sourceforge.net/updates"))
, check_updates (CHECK_IF_CONNECTED) , check_updates (CHECK_IF_CONNECTED)
, locale (_("en")) , updates_url (_("http://magicseteditor.sourceforge.net/updates"))
{} {}
void Settings::addRecentFile(const String& filename) { void Settings::addRecentFile(const String& filename) {
......
...@@ -26,12 +26,12 @@ class StatsDimension { ...@@ -26,12 +26,12 @@ class StatsDimension {
StatsDimension(); StatsDimension();
StatsDimension(const Field&); StatsDimension(const Field&);
bool automatic; ///< Based on a card field?
String name; ///< Name of this dimension String name; ///< Name of this dimension
String description; ///< Description, used in status bar String description; ///< Description, used in status bar
String icon_filename; ///< Icon for lists String icon_filename; ///< Icon for lists
OptionalScript script; ///< Script that determines the value(s) OptionalScript script; ///< Script that determines the value(s)
bool numeric; ///< Are the values numeric? If so, they require special sorting bool numeric; ///< Are the values numeric? If so, they require special sorting
bool automatic; ///< Based on a card field?
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
...@@ -51,13 +51,13 @@ class StatsCategory { ...@@ -51,13 +51,13 @@ class StatsCategory {
StatsCategory(); StatsCategory();
StatsCategory(const StatsDimensionP&); StatsCategory(const StatsDimensionP&);
bool automatic; ///< Automatically generated?
String name; ///< Name/label String name; ///< Name/label
String description; ///< Description, used in status bar String description; ///< Description, used in status bar
String icon_filename; ///< Icon for lists String icon_filename; ///< Icon for lists
Bitmap icon; ///< The loaded icon (optional of course) Bitmap icon; ///< The loaded icon (optional of course)
vector<StatsDimensionP> dimensions; ///< The dimensions to use, higher dimensions may be null vector<StatsDimensionP> dimensions; ///< The dimensions to use, higher dimensions may be null
GraphType type; ///< Type of graph to use GraphType type; ///< Type of graph to use
bool automatic; ///< Automatically generated?
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
......
...@@ -41,16 +41,16 @@ ControlPoint::ControlPoint() ...@@ -41,16 +41,16 @@ ControlPoint::ControlPoint()
, lock(LOCK_FREE) , lock(LOCK_FREE)
{} {}
ControlPoint::ControlPoint(double x, double y) 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) , lock(LOCK_FREE)
, pos(x,y)
{} {}
ControlPoint::ControlPoint(double x, double y, double xb, double yb, double xa, double ya, LockMode lock) ControlPoint::ControlPoint(double x, double y, double xb, double yb, double xa, double ya, LockMode lock)
: segment_before(SEGMENT_CURVE), segment_after(SEGMENT_CURVE) : pos(x,y)
, lock(lock)
, pos(x,y)
, delta_before(xb,yb) , delta_before(xb,yb)
, delta_after(xa,ya) , delta_after(xa,ya)
, segment_before(SEGMENT_CURVE), segment_after(SEGMENT_CURVE)
, lock(lock)
{} {}
void ControlPoint::onUpdateHandle(WhichHandle wh) { void ControlPoint::onUpdateHandle(WhichHandle wh) {
......
...@@ -100,7 +100,7 @@ struct CompareTabIndex { ...@@ -100,7 +100,7 @@ struct CompareTabIndex {
Field& af = *as.fieldP, &bf = *bs.fieldP; Field& af = *as.fieldP, &bf = *bs.fieldP;
if (af.tab_index < bf.tab_index) return true; if (af.tab_index < bf.tab_index) return true;
if (af.tab_index > bf.tab_index) return false; 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' // the fields are almost on the same 'row'
// compare horizontally first // compare horizontally first
if (as.left < bs.left) return true; // horizontal sorting if (as.left < bs.left) return true; // horizontal sorting
......
...@@ -79,8 +79,10 @@ void CardListColumnSelectDialog::initList() { ...@@ -79,8 +79,10 @@ void CardListColumnSelectDialog::initList() {
// check // check
int i = list->GetCount() - 1; int i = list->GetCount() - 1;
list->Check(i, c.settings.visible); list->Check(i, c.settings.visible);
#ifdef _WX_MSW_
// fix the background color // fix the background color
list->GetItem(i)->SetBackgroundColour(window_color); list->GetItem(i)->SetBackgroundColour(window_color);
#endif
} }
} }
......
...@@ -80,7 +80,7 @@ void CardViewer::drawViewer(RotatedDC& dc, ValueViewer& v) { ...@@ -80,7 +80,7 @@ void CardViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
} }
bool CardViewer::shouldDraw(const ValueViewer& v) const { 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() // helper class for overdrawDC()
......
...@@ -22,13 +22,13 @@ const int BORDER = 1; // margin between items ...@@ -22,13 +22,13 @@ const int BORDER = 1; // margin between items
GalleryList::GalleryList(Window* parent, int id, int direction) GalleryList::GalleryList(Window* parent, int id, int direction)
: wxScrolledWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | (direction == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL) ) : wxScrolledWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | (direction == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL) )
, direction(direction)
, selection(NO_SELECTION) , selection(NO_SELECTION)
, direction(direction)
{} {}
void GalleryList::update() { void GalleryList::update() {
const int w = item_size.width + MARGIN + 2*BORDER; const int w = (int)item_size.width + MARGIN + 2*BORDER;
const int h = item_size.height + MARGIN + 2*BORDER; const int h = (int)item_size.height + MARGIN + 2*BORDER;
// resize and scroll // resize and scroll
if (direction == wxHORIZONTAL) { if (direction == wxHORIZONTAL) {
SetVirtualSize(w * (int)itemCount() + MARGIN, h + MARGIN); SetVirtualSize(w * (int)itemCount() + MARGIN, h + MARGIN);
...@@ -56,11 +56,11 @@ void GalleryList::update() { ...@@ -56,11 +56,11 @@ void GalleryList::update() {
size_t GalleryList::findItem(const wxMouseEvent& ev) const { size_t GalleryList::findItem(const wxMouseEvent& ev) const {
if (direction == wxHORIZONTAL) { 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); GetViewStart (&x, 0);
return static_cast<size_t>( x + ev.GetX() / w ); return static_cast<size_t>( x + ev.GetX() / w );
} else { // wxVERTICAL } else { // wxVERTICAL
int y, h = item_size.height + MARGIN + 2*BORDER; int y, h = (int)item_size.height + MARGIN + 2*BORDER;
GetViewStart (0, &y); GetViewStart (0, &y);
return static_cast<size_t>( y + ev.GetY() / h ); return static_cast<size_t>( y + ev.GetY() / h );
} }
......
...@@ -40,14 +40,14 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) { ...@@ -40,14 +40,14 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
dc.SetFont(*wxNORMAL_FONT); dc.SetFont(*wxNORMAL_FONT);
dc.DrawText(capitalize_sentence(s.fieldP->name), RealPoint(margin_left, s.top + 1)); dc.DrawText(capitalize_sentence(s.fieldP->name), RealPoint(margin_left, s.top + 1));
// draw 3D border // 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 // draw viewer
v.draw(dc); v.draw(dc);
} }
void NativeLookEditor::resizeViewers() { void NativeLookEditor::resizeViewers() {
// size stuff // size stuff
UInt y = margin; double y = margin;
int w; int w;
GetClientSize(&w, 0); GetClientSize(&w, 0);
const int default_height = 17; const int default_height = 17;
......
...@@ -35,12 +35,12 @@ void PackageList::drawItem(DC& dc, int x, int y, size_t item, bool selected) { ...@@ -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.SetFont(wxFont(12,wxSWISS,wxNORMAL,wxBOLD,false,_("Arial")));
dc.GetTextExtent(capitalize(d.package->short_name), &w, &h); dc.GetTextExtent(capitalize(d.package->short_name), &w, &h);
pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); 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 // draw name
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
dc.GetTextExtent(d.package->full_name, &w, &h); dc.GetTextExtent(d.package->full_name, &w, &h);
RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect); 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) { void PackageList::showData(const String& pattern) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <util/prec.hpp>
#include <util/error.hpp>
#include <gui/control/gallery_list.hpp> #include <gui/control/gallery_list.hpp>
DECLARE_POINTER_TYPE(Packaged); DECLARE_POINTER_TYPE(Packaged);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/control/card_list.hpp> #include <gui/control/card_list.hpp>
#include <set>
// ----------------------------------------------------------------------------- : SelectCardList // ----------------------------------------------------------------------------- : SelectCardList
...@@ -30,7 +31,7 @@ class SelectCardList : public CardListBase { ...@@ -30,7 +31,7 @@ class SelectCardList : public CardListBase {
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
set<CardP> selected; ///< which cards are selected? std::set<CardP> selected; ///< which cards are selected?
void toggle(const CardP& card); void toggle(const CardP& card);
......
...@@ -55,7 +55,7 @@ void TextCtrl::setValue(String* value) { ...@@ -55,7 +55,7 @@ void TextCtrl::setValue(String* value) {
style->width = cs.GetWidth() - 2; style->width = cs.GetWidth() - 2;
style->height = cs.GetHeight() - 2; style->height = cs.GetHeight() - 2;
viewers.front()->getEditor()->determineSize(true); viewers.front()->getEditor()->determineSize(true);
SetMinSize(wxSize(style->width + 6, style->height + 6)); SetMinSize(RealSize(style->width + 6, style->height + 6));
} }
valueChanged(); valueChanged();
} }
......
...@@ -56,15 +56,15 @@ class DropDownHider : public wxEvtHandler { ...@@ -56,15 +56,15 @@ class DropDownHider : public wxEvtHandler {
DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer) DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
: wxPopupWindow(parent) : wxPopupWindow(parent)
, mouse_down(false) , text_offset(1)
, item_size(100,1)
, icon_size(0,0)
, selected_item(NO_SELECTION) , selected_item(NO_SELECTION)
, mouse_down(false)
, open_sub_menu(nullptr) , open_sub_menu(nullptr)
, parent_menu(nullptr) , parent_menu(nullptr)
, hider(is_submenu ? nullptr : new DropDownHider(*this))
, viewer(viewer) , viewer(viewer)
, item_size(100,1) , hider(is_submenu ? nullptr : new DropDownHider(*this))
, icon_size(0,0)
, text_offset(1)
{ {
if (is_submenu) { if (is_submenu) {
parent_menu = &dynamic_cast<DropDownList&>(*GetParent()); parent_menu = &dynamic_cast<DropDownList&>(*GetParent());
...@@ -110,16 +110,16 @@ void DropDownList::show(bool in_place, wxPoint pos) { ...@@ -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) // Position the drop down list below the editor control (based on the style)
RealRect r = viewer->viewer.getRotation().trNoNeg(viewer->getStyle()->getRect()); RealRect r = viewer->viewer.getRotation().trNoNeg(viewer->getStyle()->getRect());
if (viewer->viewer.nativeLook()) { 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); size.width = max(size.width, r.width + 6);
parent_height = r.height + 6; parent_height = (int)r.height + 6;
} else { } 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); size.width = max(size.width, r.width + 2);
parent_height = r.height; parent_height = (int)r.height;
} }
} else if (parent_menu) { } else if (parent_menu) {
parent_height = -item_size.height - 1; parent_height = -(int)item_size.height - 1;
} }
pos = GetParent()->ClientToScreen(pos); pos = GetParent()->ClientToScreen(pos);
// move & resize // move & resize
...@@ -191,7 +191,7 @@ bool DropDownList::showSubMenu(size_t item, int y) { ...@@ -191,7 +191,7 @@ bool DropDownList::showSubMenu(size_t item, int y) {
wxSize size = GetSize(); wxSize size = GetSize();
sub_menu->show(true, sub_menu->show(true,
sub_menu->GetParent()->ScreenToClient(ClientToScreen( sub_menu->GetParent()->ScreenToClient(ClientToScreen(
wxPoint(size.GetWidth() - 1, y + item_size.height) wxPoint(size.GetWidth() - 1, y + (int)item_size.height)
))); )));
return true; return true;
} }
...@@ -201,7 +201,7 @@ int DropDownList::itemPosition(size_t item) const { ...@@ -201,7 +201,7 @@ int DropDownList::itemPosition(size_t item) const {
size_t count = itemCount(); size_t count = itemCount();
for (size_t i = 0 ; i < count ; ++i) { for (size_t i = 0 ; i < count ; ++i) {
if (i == item) return y; if (i == item) return y;
y += item_size.height + lineBelow(item); y += (int)item_size.height + lineBelow(item);
} }
// not found // not found
assert(false); assert(false);
...@@ -237,7 +237,7 @@ void DropDownList::draw(DC& dc) { ...@@ -237,7 +237,7 @@ void DropDownList::draw(DC& dc) {
size_t count = itemCount(); size_t count = itemCount();
for (size_t i = 0 ; i < count ; ++i) { for (size_t i = 0 ; i < count ; ++i) {
drawItem(dc, y, 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) { ...@@ -247,27 +247,27 @@ void DropDownList::drawItem(DC& dc, int y, size_t item) {
if (item == selected_item) { if (item == selected_item) {
dc.SetBrush (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.SetBrush (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); 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)) { } else if (highlightItem(item)) {
// mix a color between selection and window // mix a color between selection and window
dc.SetBrush (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), dc.SetBrush (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75)); wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75));
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); 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 { } else {
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
} }
// draw text and icon // draw text and icon
drawIcon(dc, marginW, y, item, item == selected_item); 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 // draw popup icon
if (submenu(item)) { 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 // draw line below
if (lineBelow(item)) { if (lineBelow(item)) {
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)); 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) { ...@@ -293,7 +293,7 @@ void DropDownList::onMotion(wxMouseEvent& ev) {
int startY = marginH; int startY = marginH;
size_t count = itemCount(); size_t count = itemCount();
for (size_t i = 0 ; i < count ; ++i) { 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) { if (ev.GetY() >= startY && ev.GetY() < endY) {
selected_item = i; selected_item = i;
showSubMenu(i, startY); showSubMenu(i, startY);
......
...@@ -47,6 +47,7 @@ Image generateDisabledImage(const Image& imgIn) { ...@@ -47,6 +47,7 @@ Image generateDisabledImage(const Image& imgIn) {
// ----------------------------------------------------------------------------- : IconMenu // ----------------------------------------------------------------------------- : IconMenu
void IconMenu::Append(int id, const String& resource, const String& text, const String& help, int style, wxMenu* submenu) { void IconMenu::Append(int id, const String& resource, const String& text, const String& help, int style, wxMenu* submenu) {
#ifdef __WXMSW__
// load bitmap // load bitmap
Bitmap bitmap(resource); Bitmap bitmap(resource);
bitmap = bitmap.GetSubBitmap(wxRect(0,0,16,16)); bitmap = bitmap.GetSubBitmap(wxRect(0,0,16,16));
...@@ -56,6 +57,14 @@ void IconMenu::Append(int id, const String& resource, const String& text, const ...@@ -56,6 +57,14 @@ void IconMenu::Append(int id, const String& resource, const String& text, const
item->SetBitmaps(bitmap, bitmap); item->SetBitmaps(bitmap, bitmap);
item->SetDisabledBitmap(disabledImage); item->SetDisabledBitmap(disabledImage);
wxMenu::Append(item); 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) { void IconMenu::Append(int id, const String& text, const String& help) {
......
...@@ -126,7 +126,7 @@ DisplayPreferencesPage::DisplayPreferencesPage(Window* parent) ...@@ -126,7 +126,7 @@ DisplayPreferencesPage::DisplayPreferencesPage(Window* parent)
borders-> SetValue( settings.default_stylesheet_settings.card_borders()); borders-> SetValue( settings.default_stylesheet_settings.card_borders());
non_normal_export->SetValue(!settings.default_stylesheet_settings.card_normal_export()); non_normal_export->SetValue(!settings.default_stylesheet_settings.card_normal_export());
zoom->SetRange(1, 1000); zoom->SetRange(1, 1000);
zoom-> SetValue( settings.default_stylesheet_settings.card_zoom() * 100); zoom-> SetValue(static_cast<int>(settings.default_stylesheet_settings.card_zoom() * 100));
// init sizer // init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL); wxSizer* s = new wxBoxSizer(wxVERTICAL);
wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Card Display")); wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Card Display"));
......
...@@ -149,7 +149,7 @@ class StatsFilter : public CardListFilter { ...@@ -149,7 +149,7 @@ class StatsFilter : public CardListFilter {
virtual bool keep(const CardP& card) { virtual bool keep(const CardP& card) {
Context& ctx = set.getContext(card); Context& ctx = set.getContext(card);
FOR_EACH(v, values) { 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; return true;
} }
......
...@@ -160,10 +160,10 @@ void SymbolBasicShapeEditor::makeShape(const Vector2D& a, const Vector2D& b, boo ...@@ -160,10 +160,10 @@ void SymbolBasicShapeEditor::makeShape(const Vector2D& a, const Vector2D& b, boo
// constrain // constrain
Vector2D size = b - a; Vector2D size = b - a;
if (constrained) { if (constrained) {
if (abs(size.x) > abs(size.y)) { if (fabs(size.x) > fabs(size.y)) {
size.y = sgn(size.y) * abs(size.x); size.y = sgn(size.y) * fabs(size.x);
} else { } else {
size.x = sgn(size.x) * abs(size.y); size.x = sgn(size.x) * fabs(size.y);
} }
} }
// make shape // make shape
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/renderer.h> #include <wx/renderer.h>
#if wxUSE_UXTHEME #if wxUSE_UXTHEME && defined(__WXMSW__)
#include <wx/msw/uxtheme.h> #include <wx/msw/uxtheme.h>
#include <tmschema.h> #include <tmschema.h>
#include <shlobj.h> #include <shlobj.h>
...@@ -109,7 +109,7 @@ void draw3DBorder(DC& dc, int x1, int y1, int x2, int y2) { ...@@ -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) { void draw_control_border(Window* win, DC& dc, const wxRect& rect) {
#if wxUSE_UXTHEME #if wxUSE_UXTHEME && defined(__WXMSW__)
RECT r; RECT r;
wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get(); wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
if (themeEngine && themeEngine->IsAppThemed()) { if (themeEngine && themeEngine->IsAppThemed()) {
......
...@@ -23,8 +23,8 @@ class ChoiceThumbnailRequest : public ThumbnailRequest { ...@@ -23,8 +23,8 @@ class ChoiceThumbnailRequest : public ThumbnailRequest {
virtual Image generate(); virtual Image generate();
virtual void store(const Image&); virtual void store(const Image&);
private: private:
int id;
StyleSheetP stylesheet; StyleSheetP stylesheet;
int id;
}; };
ChoiceThumbnailRequest::ChoiceThumbnailRequest(ChoiceValueEditor* cve, int id) ChoiceThumbnailRequest::ChoiceThumbnailRequest(ChoiceValueEditor* cve, int id)
...@@ -84,8 +84,8 @@ void ChoiceThumbnailRequest::store(const Image& img) { ...@@ -84,8 +84,8 @@ void ChoiceThumbnailRequest::store(const Image& img) {
DropDownChoiceList::DropDownChoiceList(Window* parent, bool is_submenu, ChoiceValueEditor& cve, ChoiceField::ChoiceP group) DropDownChoiceList::DropDownChoiceList(Window* parent, bool is_submenu, ChoiceValueEditor& cve, ChoiceField::ChoiceP group)
: DropDownList(parent, is_submenu, is_submenu ? nullptr : &cve) : DropDownList(parent, is_submenu, is_submenu ? nullptr : &cve)
, group(group)
, cve(cve) , cve(cve)
, group(group)
{ {
icon_size.width = 16; icon_size.width = 16;
icon_size.height = 16; icon_size.height = 16;
......
...@@ -53,7 +53,7 @@ DropDownColorList::DropDownColorList(Window* parent, ColorValueEditor& cve) ...@@ -53,7 +53,7 @@ DropDownColorList::DropDownColorList(Window* parent, ColorValueEditor& cve)
{ {
icon_size.width = 25; icon_size.width = 25;
if (item_size.height < 16) { if (item_size.height < 16) {
text_offset = (16 - item_size.height) / 2; text_offset = (16 - (int)item_size.height) / 2;
item_size.height = 16; item_size.height = 16;
} }
} }
...@@ -86,7 +86,7 @@ void DropDownColorList::drawIcon(DC& dc, int x, int y, size_t item, bool selecte ...@@ -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 // draw a rectangle with the right color
dc.SetPen(wxSystemSettings::GetColour(selected ? wxSYS_COLOUR_HIGHLIGHTTEXT : wxSYS_COLOUR_WINDOWTEXT)); dc.SetPen(wxSystemSettings::GetColour(selected ? wxSYS_COLOUR_HIGHLIGHTTEXT : wxSYS_COLOUR_WINDOWTEXT));
dc.SetBrush(col); 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);
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
*/ */
class ValueEditor { class ValueEditor {
public: public:
virtual ~ValueEditor();
// --------------------------------------------------- : Events // --------------------------------------------------- : Events
/// This editor gains focus /// This editor gains focus
......
...@@ -605,10 +605,10 @@ void TextValueEditor::determineSize(bool force_fit) { ...@@ -605,10 +605,10 @@ void TextValueEditor::determineSize(bool force_fit) {
if (!force_fit) style().height = 100; if (!force_fit) style().height = 100;
int sbw = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); int sbw = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
scrollbar->SetSize( scrollbar->SetSize(
style().left + style().width - sbw + 1, (int)style().left + style().width - sbw + 1,
style().top - 1, (int)style().top - 1,
sbw, (int)sbw,
style().height + 2); (int)style().height + 2);
v.reset(); v.reset();
} else { } else {
// Height depends on font // Height depends on font
......
...@@ -84,8 +84,9 @@ class TextValueEditor : public TextValueViewer, public ValueEditor { ...@@ -84,8 +84,9 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
private: private:
size_t selection_start, selection_end; ///< Cursor position/selection (if any), cursor positions 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 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 // --------------------------------------------------- : Selection / movement
...@@ -127,9 +128,6 @@ class TextValueEditor : public TextValueViewer, public ValueEditor { ...@@ -127,9 +128,6 @@ class TextValueEditor : public TextValueViewer, public ValueEditor {
friend class TextValueEditorScrollBar; friend class TextValueEditorScrollBar;
/// When the cursor moves, should the scrollposition change?
bool scroll_with_cursor;
/// Scroll to the given position, called by scrollbar /// Scroll to the given position, called by scrollbar
void scrollTo(int pos); void scrollTo(int pos);
/// Update the scrollbar to show the current scroll position /// Update the scrollbar to show the current scroll position
......
...@@ -107,8 +107,8 @@ END_EVENT_TABLE () ...@@ -107,8 +107,8 @@ END_EVENT_TABLE ()
HoverButtonExt::HoverButtonExt(Window* parent, int id, const String& icon_name, const String& label, const String& sub_label) HoverButtonExt::HoverButtonExt(Window* parent, int id, const String& icon_name, const String& label, const String& sub_label)
: HoverButton(parent, id, _("BTN")) : HoverButton(parent, id, _("BTN"))
, label(label), sub_label(sub_label)
, icon(load_resource_image(icon_name)) , icon(load_resource_image(icon_name))
, label(label), sub_label(sub_label)
, font_large(14, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial")) , font_large(14, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial"))
, font_small(8, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial")) , font_small(8, wxSWISS, wxNORMAL, wxNORMAL, false, _("Arial"))
{} {}
......
...@@ -122,7 +122,7 @@ AColor LinearGradientSymbolFilter::color(double x, double y, SymbolSet point) co ...@@ -122,7 +122,7 @@ AColor LinearGradientSymbolFilter::color(double x, double y, SymbolSet point) co
} }
double LinearGradientSymbolFilter::t(double x, double y) const { 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)); return min(1.,max(0.,t));
} }
......
...@@ -48,10 +48,10 @@ struct CharInfo { ...@@ -48,10 +48,10 @@ struct CharInfo {
/// A section of text that can be rendered using a TextViewer /// A section of text that can be rendered using a TextViewer
class TextElement { class TextElement {
public: public:
/// What section of the input string is this element?
size_t start, end;
/// The text of which a subsection is drawn /// The text of which a subsection is drawn
String text; 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) {} inline TextElement(const String& text, size_t start ,size_t end) : text(text), start(start), end(end) {}
virtual ~TextElement() {} virtual ~TextElement() {}
......
...@@ -43,7 +43,7 @@ void ColorValueViewer::draw(RotatedDC& dc) { ...@@ -43,7 +43,7 @@ void ColorValueViewer::draw(RotatedDC& dc) {
style().top_width < style().height && style().bottom_width < style().height; style().top_width < style().height && style().bottom_width < style().height;
if (clip) { if (clip) {
// clip away the inside of the rectangle // 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( r.Subtract(dc.tr(RealRect(
style().left + style().left_width, style().left + style().left_width,
style().top + style().top_width, style().top + style().top_width,
......
...@@ -22,7 +22,7 @@ void ImageValueViewer::draw(RotatedDC& dc) { ...@@ -22,7 +22,7 @@ void ImageValueViewer::draw(RotatedDC& dc) {
InputStreamP image_file = getSet().openIn(value().filename); InputStreamP image_file = getSet().openIn(value().filename);
Image image; Image image;
if (image.LoadFile(*image_file)) { 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 // apply mask to image
loadMask(dc); loadMask(dc);
if (alpha_mask) alpha_mask->setAlpha(image); if (alpha_mask) alpha_mask->setAlpha(image);
...@@ -34,7 +34,7 @@ void ImageValueViewer::draw(RotatedDC& dc) { ...@@ -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 there is no image, generate a placeholder, only if there is enough room for it
if (!bitmap.Ok() && style().width > 40) { 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); loadMask(dc);
if (alpha_mask) alpha_mask->setAlpha(bitmap); if (alpha_mask) alpha_mask->setAlpha(bitmap);
} }
...@@ -45,15 +45,15 @@ void ImageValueViewer::draw(RotatedDC& dc) { ...@@ -45,15 +45,15 @@ void ImageValueViewer::draw(RotatedDC& dc) {
} }
bool ImageValueViewer::containsPoint(const RealPoint& p) const { bool ImageValueViewer::containsPoint(const RealPoint& p) const {
int x = p.x - style().left; double x = p.x - style().left;
int y = p.y - style().top; double y = p.y - style().top;
if (x < 0 || y < 0 || x >= (int)style().width || y >= (int)style().height) { if (x < 0 || y < 0 || x >= style().width || y >= style().height) {
return false; // outside rectangle return false; // outside rectangle
} }
// check against mask // check against mask
if (!style().mask_filename().empty()) { if (!style().mask_filename().empty()) {
loadMask(viewer.getRotation()); loadMask(viewer.getRotation());
return !alpha_mask || !alpha_mask->isTransparent(x, y); return !alpha_mask || !alpha_mask->isTransparent((int)x, (int)y);
} else { } else {
return true; return true;
} }
...@@ -70,12 +70,13 @@ void ImageValueViewer::onStyleChange() { ...@@ -70,12 +70,13 @@ 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
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 // (re) load the mask
Image image; Image image;
InputStreamP image_file = viewer.stylesheet->openIn(style().mask_filename); InputStreamP image_file = viewer.stylesheet->openIn(style().mask_filename);
if (image.LoadFile(*image_file)) { if (image.LoadFile(*image_file)) {
Image resampled(rot.trS(style().width), rot.trS(style().height)); Image resampled(w,h);
resample(image, resampled); resample(image, resampled);
alpha_mask = new_shared1<AlphaMask>(resampled); alpha_mask = new_shared1<AlphaMask>(resampled);
} }
......
...@@ -238,7 +238,7 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) { ...@@ -238,7 +238,7 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) {
// operator on strings or doubles or ints // operator on strings or doubles or ints
#define OPERATOR_SDI(OP) \ #define OPERATOR_SDI(OP) \
if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { \ 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) { \ } else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \
a = toScript((double)*a OP (double)*b); \ a = toScript((double)*a OP (double)*b); \
} else { \ } else { \
...@@ -282,13 +282,13 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP& ...@@ -282,13 +282,13 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) { } else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
a = new_intrusive2<ScriptCompose>(a, b); a = new_intrusive2<ScriptCompose>(a, b);
} else if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { } 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) { } 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) { } else if (at == SCRIPT_INT || bt == SCRIPT_INT) {
a = toScript((int)*a + (int)*b); a = toScript((int)*a + (int)*b);
} else { } else {
a = toScript((String)*a + (String)*b); a = toScript(a->toString() + b->toString());
} }
break; break;
case I_SUB: OPERATOR_DI(-); case I_SUB: OPERATOR_DI(-);
......
...@@ -56,7 +56,7 @@ class ScriptReplaceRule : public ScriptValue { ...@@ -56,7 +56,7 @@ class ScriptReplaceRule : public ScriptValue {
ctx.setVariable(name, toScript(value)); ctx.setVariable(name, toScript(value));
} }
// call // call
inside = (String)*replacement_function->eval(ctx); inside = replacement_function->eval(ctx)->toString();
} else { } else {
regex.Replace(&inside, replacement, 1); // replace inside regex.Replace(&inside, replacement, 1); // replace inside
} }
...@@ -92,7 +92,7 @@ SCRIPT_FUNCTION(replace_rule) { ...@@ -92,7 +92,7 @@ SCRIPT_FUNCTION(replace_rule) {
if (replace->type() == SCRIPT_FUNCTION) { if (replace->type() == SCRIPT_FUNCTION) {
ret->replacement_function = replace; ret->replacement_function = replace;
} else { } else {
ret->replacement = (String)*replace; ret->replacement = replace->toString();
} }
// in_context // in_context
SCRIPT_OPTIONAL_PARAM_N(String, _("in context"), 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& ...@@ -354,7 +354,7 @@ String replace_tag_contents(String input, const String& tag, const ScriptValueP&
// replace // replace
ret += input.substr(0, pos); // before tag ret += input.substr(0, pos); // before tag
ret += tag; ret += tag;
ret += *contents->eval(ctx);// new contents (call) ret += contents->eval(ctx)->toString();// new contents (call)
ret += close_tag(tag); ret += close_tag(tag);
// next // next
input = input.substr(skip_tag(input,end)); input = input.substr(skip_tag(input,end));
...@@ -387,7 +387,7 @@ bool equal(const ScriptValue& a, const ScriptValue& b) { ...@@ -387,7 +387,7 @@ bool equal(const ScriptValue& a, const ScriptValue& b) {
} else if (at == SCRIPT_DOUBLE) { } else if (at == SCRIPT_DOUBLE) {
return (double)a == (double)b; return (double)a == (double)b;
} else if (at == SCRIPT_STRING) { } else if (at == SCRIPT_STRING) {
return (String)a == (String)b; return a.toString() == b.toString();
} else if (at == SCRIPT_OBJECT) { } else if (at == SCRIPT_OBJECT) {
// HACK for ScriptObject<shared_ptr<X> > // HACK for ScriptObject<shared_ptr<X> >
// assumes different types are layed out the same, and that // 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 ...@@ -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(); ScriptType of_t = of->type(), in_t = in->type();
if (of_t == SCRIPT_STRING || in_t == SCRIPT_STRING) { if (of_t == SCRIPT_STRING || in_t == SCRIPT_STRING) {
// string finding // 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) { } else if (order_by) {
ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>* >(in.get()); ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>* >(in.get());
ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(of.get()); ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(of.get());
......
...@@ -153,7 +153,7 @@ template <> void Reader::handle(ScriptableImage& s) { ...@@ -153,7 +153,7 @@ template <> void Reader::handle(ScriptableImage& s) {
if (starts_with(s.script.unparsed, _("script:"))) { if (starts_with(s.script.unparsed, _("script:"))) {
s.script.unparsed = s.script.unparsed.substr(7); s.script.unparsed = s.script.unparsed.substr(7);
s.script.parse(*this); 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); s.script.parse(*this, true);
} else { } else {
// script is a constant function // script is a constant function
......
...@@ -38,10 +38,10 @@ struct Token { ...@@ -38,10 +38,10 @@ struct Token {
String value; String value;
bool newline; ///< Is there a newline between this token and the previous one? bool newline; ///< Is there a newline between this token and the previous one?
inline operator == (TokenType t) const { return type == t; } inline bool operator == (TokenType t) const { return type == t; }
inline operator != (TokenType t) const { return type != t; } inline bool operator != (TokenType t) const { return type != t; }
inline operator == (const String& s) const { return type != TOK_STRING && value == s; } inline bool 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 != (const String& s) const { return type == TOK_STRING || value != s; }
}; };
enum OpenBrace enum OpenBrace
...@@ -521,7 +521,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc ...@@ -521,7 +521,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc
// for smart strings: "x" {{ e }} "y" // for smart strings: "x" {{ e }} "y"
// optimize: "" + e -> e // optimize: "" + e -> e
Instruction i = script.getInstructions().back(); 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(); script.getInstructions().pop_back();
parseOper(input, script, PREC_ALL); // e parseOper(input, script, PREC_ALL); // e
} else { } else {
...@@ -531,7 +531,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc ...@@ -531,7 +531,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc
parseOper(input, script, PREC_NONE); // y parseOper(input, script, PREC_NONE); // y
// optimize: e + "" -> e // optimize: e + "" -> e
i = script.getInstructions().back(); 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(); script.getInstructions().pop_back();
} else { } else {
script.addInstruction(I_BINARY, I_ADD); script.addInstruction(I_BINARY, I_ADD);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// ----------------------------------------------------------------------------- : Store // ----------------------------------------------------------------------------- : Store
void store(const ScriptValueP& val, String& var) { var = static_cast<String>(*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, int& var) { var = *val; }
void store(const ScriptValueP& val, double& var) { var = *val; } void store(const ScriptValueP& val, double& var) { var = *val; }
void store(const ScriptValueP& val, bool& var) { var = static_cast<int>(*val); } void store(const ScriptValueP& val, bool& var) { var = static_cast<int>(*val); }
...@@ -25,8 +25,8 @@ void store(const ScriptValueP& val, Defaultable<Color>& var) { var.assign(*val) ...@@ -25,8 +25,8 @@ void store(const ScriptValueP& val, Defaultable<Color>& var) { var.assign(*val)
// ----------------------------------------------------------------------------- : OptionalScript // ----------------------------------------------------------------------------- : OptionalScript
OptionalScript::OptionalScript(const String& script_) OptionalScript::OptionalScript(const String& script_)
: unparsed(script_) : script(::parse(script_))
, script(::parse(script_)) , unparsed(script_)
{} {}
OptionalScript::~OptionalScript() {} OptionalScript::~OptionalScript() {}
......
...@@ -58,6 +58,11 @@ class ScriptValue : public IntrusivePtrBase { ...@@ -58,6 +58,11 @@ class ScriptValue : public IntrusivePtrBase {
/// Convert this value to a color /// Convert this value to a color
virtual operator Color() const; 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 /// Get a member variable from this value
virtual ScriptValueP getMember(const String& name) const; virtual ScriptValueP getMember(const String& name) const;
/// Signal that a script depends on a member of this value /// Signal that a script depends on a member of this value
...@@ -246,10 +251,11 @@ class ScriptObject : public ScriptValue { ...@@ -246,10 +251,11 @@ class ScriptObject : public ScriptValue {
// ----------------------------------------------------------------------------- : Creating // ----------------------------------------------------------------------------- : Creating
/// Convert a value to a script value /// Convert a value to a script value
ScriptValueP toScript(int v); ScriptValueP toScript(int v);
ScriptValueP toScript(double v); inline ScriptValueP toScript(long v) { return toScript((int) v); }
ScriptValueP toScript(const String& v); ScriptValueP toScript(double v);
ScriptValueP toScript(const Color& v); ScriptValueP toScript(const String& v);
ScriptValueP toScript(const Color& v);
inline ScriptValueP toScript(bool v) { return v ? script_true : script_false; } inline ScriptValueP toScript(bool v) { return v ? script_true : script_false; }
template <typename T> template <typename T>
inline ScriptValueP toScript(const vector<T>* v) { return new_intrusive1<ScriptCollection<vector<T> > >(v); } inline ScriptValueP toScript(const vector<T>* v) { return new_intrusive1<ScriptCollection<vector<T> > >(v); }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
// ----------------------------------------------------------------------------- : AtomicInt : windows // ----------------------------------------------------------------------------- : AtomicInt : windows
#ifdef _WX_MSW_ #ifdef __WXMSW__
#ifdef _MSC_VER #ifdef _MSC_VER
extern "C" { extern "C" {
......
...@@ -57,14 +57,14 @@ OrderCache<T>::OrderCache(const vector<T>& keys, const vector<String>& values) { ...@@ -57,14 +57,14 @@ OrderCache<T>::OrderCache(const vector<T>& keys, const vector<String>& values) {
// initialize positions, use pos to point back to the values vector // initialize positions, use pos to point back to the values vector
positions.reserve(keys.size()); positions.reserve(keys.size());
int i = 0; int i = 0;
for (vector<T>::const_iterator it = keys.begin() ; it != keys.end() ; ++it, ++i) { for (typename vector<T>::const_iterator it = keys.begin() ; it != keys.end() ; ++it, ++i) {
positions.push_back(KV(&**it, i)); positions.push_back(KV(&**it, i));
} }
// sort the KVs by the values // sort the KVs by the values
sort(positions.begin(), positions.end(), CompareValues(values)); sort(positions.begin(), positions.end(), CompareValues(values));
// update positions, to point to sorted list // update positions, to point to sorted list
i = 0; i = 0;
for (vector<KV>::iterator it = positions.begin() ; it != positions.end() ; ++it, ++i) { for (typename vector<KV>::iterator it = positions.begin() ; it != positions.end() ; ++it, ++i) {
it->second = i; it->second = i;
} }
// sort the KVs by the keys // sort the KVs by the keys
......
...@@ -152,6 +152,11 @@ class RealRect : private RealPoint, private RealSize { ...@@ -152,6 +152,11 @@ class RealRect : private RealPoint, private RealSize {
int i_t = to_int(y), i_b = to_int(bottom()); 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); 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 /// Split a rectangle horizontally
......
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