Commit 88919557 authored by twanvl's avatar twanvl

Switched to a new coding style, which plays nicely with the Reader/Writer....

Switched to a new coding style, which plays nicely with the Reader/Writer. This new style allows REFLECT to be used instead of REFLECT_N in most places.
parent 3fd47ec7
...@@ -23,15 +23,15 @@ SymbolPartMoveAction::SymbolPartMoveAction(const set<SymbolPartP>& parts) ...@@ -23,15 +23,15 @@ SymbolPartMoveAction::SymbolPartMoveAction(const set<SymbolPartP>& parts)
, constrain(false) , constrain(false)
{} {}
String SymbolPartMoveAction::getName(bool toUndo) const { String SymbolPartMoveAction::getName(bool to_undo) const {
return parts.size() == 1 ? _("Move shape") : _("Move shapes"); return parts.size() == 1 ? _("Move shape") : _("Move shapes");
} }
void SymbolPartMoveAction::perform(bool toUndo) { void SymbolPartMoveAction::perform(bool to_undo) {
// move the points back // move the points back
FOR_EACH(p, parts) { FOR_EACH(p, parts) {
p->minPos -= moved; p->min_pos -= moved;
p->maxPos -= moved; p->max_pos -= moved;
FOR_EACH(pnt, p->points) { FOR_EACH(pnt, p->points) {
pnt->pos -= moved; pnt->pos -= moved;
} }
...@@ -45,8 +45,8 @@ void SymbolPartMoveAction::move(const Vector2D& deltaDelta) { ...@@ -45,8 +45,8 @@ void SymbolPartMoveAction::move(const Vector2D& deltaDelta) {
Vector2D d = constrainVector(delta, constrain); Vector2D d = constrainVector(delta, constrain);
Vector2D dd = d - moved; Vector2D dd = d - moved;
FOR_EACH(p, parts) { FOR_EACH(p, parts) {
p->minPos += dd; p->min_pos += dd;
p->maxPos += dd; p->max_pos += dd;
FOR_EACH(pnt, p->points) { FOR_EACH(pnt, p->points) {
pnt->pos += dd; pnt->pos += dd;
} }
...@@ -66,8 +66,8 @@ void SymbolPartMatrixAction::transform(const Vector2D& mx, const Vector2D& my) { ...@@ -66,8 +66,8 @@ void SymbolPartMatrixAction::transform(const Vector2D& mx, const Vector2D& my) {
FOR_EACH(p, parts) { FOR_EACH(p, parts) {
FOR_EACH(pnt, p->points) { FOR_EACH(pnt, p->points) {
pnt->pos = (pnt->pos - center).mul(mx,my) + center; pnt->pos = (pnt->pos - center).mul(mx,my) + center;
pnt->deltaBefore = pnt->deltaBefore.mul(mx,my); pnt->delta_before = pnt->delta_before.mul(mx,my);
pnt->deltaAfter = pnt->deltaAfter .mul(mx,my); pnt->delta_after = pnt->delta_after .mul(mx,my);
} }
// bounds change after transforming // bounds change after transforming
p->calculateBounds(); p->calculateBounds();
...@@ -81,11 +81,11 @@ SymbolPartRotateAction::SymbolPartRotateAction(const set<SymbolPartP>& parts, co ...@@ -81,11 +81,11 @@ SymbolPartRotateAction::SymbolPartRotateAction(const set<SymbolPartP>& parts, co
, angle(0) , angle(0)
{} {}
String SymbolPartRotateAction::getName(bool toUndo) const { String SymbolPartRotateAction::getName(bool to_undo) const {
return parts.size() == 1 ? _("Rotate shape") : _("Rotate shapes"); return parts.size() == 1 ? _("Rotate shape") : _("Rotate shapes");
} }
void SymbolPartRotateAction::perform(bool toUndo) { void SymbolPartRotateAction::perform(bool to_undo) {
// move the points back // move the points back
rotateBy(-angle); rotateBy(-angle);
angle = -angle; angle = -angle;
...@@ -119,11 +119,11 @@ SymbolPartShearAction::SymbolPartShearAction(const set<SymbolPartP>& parts, cons ...@@ -119,11 +119,11 @@ SymbolPartShearAction::SymbolPartShearAction(const set<SymbolPartP>& parts, cons
, constrain(false) , constrain(false)
{} {}
String SymbolPartShearAction::getName(bool toUndo) const { String SymbolPartShearAction::getName(bool to_undo) const {
return parts.size() == 1 ? _("Shear shape") : _("Shear shapes"); return parts.size() == 1 ? _("Shear shape") : _("Shear shapes");
} }
void SymbolPartShearAction::perform(bool toUndo) { void SymbolPartShearAction::perform(bool to_undo) {
// move the points back // move the points back
// the vector shear = (x,y) is used as: // the vector shear = (x,y) is used as:
// <1 x> // <1 x>
...@@ -161,19 +161,19 @@ SymbolPartScaleAction::SymbolPartScaleAction(const set<SymbolPartP>& parts, int ...@@ -161,19 +161,19 @@ SymbolPartScaleAction::SymbolPartScaleAction(const set<SymbolPartP>& parts, int
oldMin = Vector2D::infinity(); oldMin = Vector2D::infinity();
Vector2D oldMax = -Vector2D::infinity(); Vector2D oldMax = -Vector2D::infinity();
FOR_EACH(p, parts) { FOR_EACH(p, parts) {
oldMin = piecewise_min(oldMin, p->minPos); oldMin = piecewise_min(oldMin, p->min_pos);
oldMax = piecewise_max(oldMax, p->maxPos); oldMax = piecewise_max(oldMax, p->max_pos);
} }
// new == old // new == old
newMin = newRealMin = oldMin; newMin = newRealMin = oldMin;
newSize = newRealSize = oldSize = oldMax - oldMin; newSize = newRealSize = oldSize = oldMax - oldMin;
} }
String SymbolPartScaleAction::getName(bool toUndo) const { String SymbolPartScaleAction::getName(bool to_undo) const {
return parts.size() == 1 ? _("Scale shape") : _("Scale shapes"); return parts.size() == 1 ? _("Scale shape") : _("Scale shapes");
} }
void SymbolPartScaleAction::perform(bool toUndo) { void SymbolPartScaleAction::perform(bool to_undo) {
swap(oldMin, newMin); swap(oldMin, newMin);
swap(oldSize, newSize); swap(oldSize, newSize);
transformAll(); transformAll();
...@@ -207,17 +207,17 @@ void SymbolPartScaleAction::update() { ...@@ -207,17 +207,17 @@ void SymbolPartScaleAction::update() {
void SymbolPartScaleAction::transformAll() { void SymbolPartScaleAction::transformAll() {
Vector2D scale = newSize.div(oldSize); Vector2D scale = newSize.div(oldSize);
FOR_EACH(p, parts) { FOR_EACH(p, parts) {
p->minPos = transform(p->minPos); p->min_pos = transform(p->min_pos);
p->maxPos = transform(p->maxPos); p->max_pos = transform(p->max_pos);
// make sure that max >= min // make sure that max >= min
if (p->minPos.x > p->maxPos.x) swap(p->minPos.x, p->maxPos.x); if (p->min_pos.x > p->max_pos.x) swap(p->min_pos.x, p->max_pos.x);
if (p->minPos.y > p->maxPos.y) swap(p->minPos.y, p->maxPos.y); if (p->min_pos.y > p->max_pos.y) swap(p->min_pos.y, p->max_pos.y);
// scale all points // scale all points
FOR_EACH(pnt, p->points) { FOR_EACH(pnt, p->points) {
pnt->pos = transform(pnt->pos); pnt->pos = transform(pnt->pos);
// also scale handles // also scale handles
pnt->deltaBefore = pnt->deltaBefore.mul(scale); pnt->delta_before = pnt->delta_before.mul(scale);
pnt->deltaAfter = pnt->deltaAfter .mul(scale); pnt->delta_after = pnt->delta_after .mul(scale);
} }
} }
} }
...@@ -230,11 +230,11 @@ CombiningModeAction::CombiningModeAction(const set<SymbolPartP>& parts, SymbolPa ...@@ -230,11 +230,11 @@ CombiningModeAction::CombiningModeAction(const set<SymbolPartP>& parts, SymbolPa
} }
} }
String CombiningModeAction::getName(bool toUndo) const { String CombiningModeAction::getName(bool to_undo) const {
return _("Change combine mode"); return _("Change combine mode");
} }
void CombiningModeAction::perform(bool toUndo) { void CombiningModeAction::perform(bool to_undo) {
FOR_EACH(pm, parts) { FOR_EACH(pm, parts) {
swap(pm.first->combine, pm.second); swap(pm.first->combine, pm.second);
} }
...@@ -246,11 +246,11 @@ SymbolPartNameAction::SymbolPartNameAction(const SymbolPartP& part, const String ...@@ -246,11 +246,11 @@ SymbolPartNameAction::SymbolPartNameAction(const SymbolPartP& part, const String
: part(part), partName(name) : part(part), partName(name)
{} {}
String SymbolPartNameAction::getName(bool toUndo) const { String SymbolPartNameAction::getName(bool to_undo) const {
return _("Change shape name"); return _("Change shape name");
} }
void SymbolPartNameAction::perform(bool toUndo) { void SymbolPartNameAction::perform(bool to_undo) {
swap(part->name, partName); swap(part->name, partName);
} }
...@@ -260,12 +260,12 @@ AddSymbolPartAction::AddSymbolPartAction(Symbol& symbol, const SymbolPartP& part ...@@ -260,12 +260,12 @@ AddSymbolPartAction::AddSymbolPartAction(Symbol& symbol, const SymbolPartP& part
: symbol(symbol), part(part) : symbol(symbol), part(part)
{} {}
String AddSymbolPartAction::getName(bool toUndo) const { String AddSymbolPartAction::getName(bool to_undo) const {
return _("Add ") + part->name; return _("Add ") + part->name;
} }
void AddSymbolPartAction::perform(bool toUndo) { void AddSymbolPartAction::perform(bool to_undo) {
if (toUndo) { if (to_undo) {
assert(!symbol.parts.empty()); assert(!symbol.parts.empty());
symbol.parts.erase (symbol.parts.begin()); symbol.parts.erase (symbol.parts.begin());
} else { } else {
...@@ -287,12 +287,12 @@ RemoveSymbolPartsAction::RemoveSymbolPartsAction(Symbol& symbol, const set<Symbo ...@@ -287,12 +287,12 @@ RemoveSymbolPartsAction::RemoveSymbolPartsAction(Symbol& symbol, const set<Symbo
} }
} }
String RemoveSymbolPartsAction::getName(bool toUndo) const { String RemoveSymbolPartsAction::getName(bool to_undo) const {
return removals.size() == 1 ? _("Remove shape") : _("Remove shapes"); return removals.size() == 1 ? _("Remove shape") : _("Remove shapes");
} }
void RemoveSymbolPartsAction::perform(bool toUndo) { void RemoveSymbolPartsAction::perform(bool to_undo) {
if (toUndo) { if (to_undo) {
// reinsert the parts // reinsert the parts
// ascending order, this is the reverse of removal // ascending order, this is the reverse of removal
FOR_EACH(r, removals) { FOR_EACH(r, removals) {
...@@ -325,12 +325,12 @@ DuplicateSymbolPartsAction::DuplicateSymbolPartsAction(Symbol& symbol, const set ...@@ -325,12 +325,12 @@ DuplicateSymbolPartsAction::DuplicateSymbolPartsAction(Symbol& symbol, const set
} }
} }
String DuplicateSymbolPartsAction::getName(bool toUndo) const { String DuplicateSymbolPartsAction::getName(bool to_undo) const {
return duplications.size() == 1 ? _("Duplicate shape") : _("Duplicate shapes"); return duplications.size() == 1 ? _("Duplicate shape") : _("Duplicate shapes");
} }
void DuplicateSymbolPartsAction::perform(bool toUndo) { void DuplicateSymbolPartsAction::perform(bool to_undo) {
if (toUndo) { if (to_undo) {
// remove the clones // remove the clones
// walk in reverse order, otherwise we will shift the vector // walk in reverse order, otherwise we will shift the vector
FOR_EACH_REVERSE(d, duplications) { FOR_EACH_REVERSE(d, duplications) {
...@@ -359,11 +359,11 @@ ReorderSymbolPartsAction::ReorderSymbolPartsAction(Symbol& symbol, size_t partId ...@@ -359,11 +359,11 @@ ReorderSymbolPartsAction::ReorderSymbolPartsAction(Symbol& symbol, size_t partId
: symbol(symbol), partId1(partId1), partId2(partId2) : symbol(symbol), partId1(partId1), partId2(partId2)
{} {}
String ReorderSymbolPartsAction::getName(bool toUndo) const { String ReorderSymbolPartsAction::getName(bool to_undo) const {
return _("Reorder"); return _("Reorder");
} }
void ReorderSymbolPartsAction::perform(bool toUndo) { void ReorderSymbolPartsAction::perform(bool to_undo) {
assert(partId1 < symbol.parts.size()); assert(partId1 < symbol.parts.size());
assert(partId2 < symbol.parts.size()); assert(partId2 < symbol.parts.size());
swap(symbol.parts[partId1], symbol.parts[partId2]); swap(symbol.parts[partId1], symbol.parts[partId2]);
......
...@@ -33,8 +33,8 @@ class SymbolPartMoveAction : public SymbolPartAction { ...@@ -33,8 +33,8 @@ class SymbolPartMoveAction : public SymbolPartAction {
public: public:
SymbolPartMoveAction(const set<SymbolPartP>& parts); SymbolPartMoveAction(const set<SymbolPartP>& parts);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
/// Update this action to move some more /// Update this action to move some more
void move(const Vector2D& delta); void move(const Vector2D& delta);
...@@ -70,8 +70,8 @@ class SymbolPartRotateAction : public SymbolPartMatrixAction { ...@@ -70,8 +70,8 @@ class SymbolPartRotateAction : public SymbolPartMatrixAction {
public: public:
SymbolPartRotateAction(const set<SymbolPartP>& parts, const Vector2D& center); SymbolPartRotateAction(const set<SymbolPartP>& parts, const Vector2D& center);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
/// Update this action to rotate to a different angle /// Update this action to rotate to a different angle
void rotateTo(double newAngle); void rotateTo(double newAngle);
...@@ -93,8 +93,8 @@ class SymbolPartShearAction : public SymbolPartMatrixAction { ...@@ -93,8 +93,8 @@ class SymbolPartShearAction : public SymbolPartMatrixAction {
public: public:
SymbolPartShearAction(const set<SymbolPartP>& parts, const Vector2D& center); SymbolPartShearAction(const set<SymbolPartP>& parts, const Vector2D& center);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
/// Change shear by a given amount /// Change shear by a given amount
void move(const Vector2D& deltaShear); void move(const Vector2D& deltaShear);
...@@ -114,8 +114,8 @@ class SymbolPartScaleAction : public SymbolPartAction { ...@@ -114,8 +114,8 @@ class SymbolPartScaleAction : public SymbolPartAction {
public: public:
SymbolPartScaleAction(const set<SymbolPartP>& parts, int scaleX, int scaleY); SymbolPartScaleAction(const set<SymbolPartP>& parts, int scaleX, int scaleY);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
/// Change min and max coordinates /// Change min and max coordinates
void move(const Vector2D& deltaMin, const Vector2D& deltaMax); void move(const Vector2D& deltaMin, const Vector2D& deltaMax);
...@@ -145,8 +145,8 @@ class CombiningModeAction : public SymbolPartListAction { ...@@ -145,8 +145,8 @@ class CombiningModeAction : public SymbolPartListAction {
public: public:
CombiningModeAction(const set<SymbolPartP>& parts, SymbolPartCombine mode); CombiningModeAction(const set<SymbolPartP>& parts, SymbolPartCombine mode);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
private: private:
vector<pair<SymbolPartP,SymbolPartCombine> > parts; ///< Affected parts with new combining modes vector<pair<SymbolPartP,SymbolPartCombine> > parts; ///< Affected parts with new combining modes
...@@ -159,8 +159,8 @@ class SymbolPartNameAction : public SymbolPartListAction { ...@@ -159,8 +159,8 @@ class SymbolPartNameAction : public SymbolPartListAction {
public: public:
SymbolPartNameAction(const SymbolPartP& part, const String& name); SymbolPartNameAction(const SymbolPartP& part, const String& name);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
private: private:
SymbolPartP part; ///< Affected part SymbolPartP part; ///< Affected part
...@@ -174,8 +174,8 @@ class AddSymbolPartAction : public SymbolPartListAction { ...@@ -174,8 +174,8 @@ class AddSymbolPartAction : public SymbolPartListAction {
public: public:
AddSymbolPartAction(Symbol& symbol, const SymbolPartP& part); AddSymbolPartAction(Symbol& symbol, const SymbolPartP& part);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
private: private:
Symbol& symbol; ///< Symbol to add the part to Symbol& symbol; ///< Symbol to add the part to
...@@ -189,8 +189,8 @@ class RemoveSymbolPartsAction : public SymbolPartListAction { ...@@ -189,8 +189,8 @@ class RemoveSymbolPartsAction : public SymbolPartListAction {
public: public:
RemoveSymbolPartsAction(Symbol& symbol, const set<SymbolPartP>& parts); RemoveSymbolPartsAction(Symbol& symbol, const set<SymbolPartP>& parts);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
private: private:
Symbol& symbol; Symbol& symbol;
...@@ -205,8 +205,8 @@ class DuplicateSymbolPartsAction : public SymbolPartListAction { ...@@ -205,8 +205,8 @@ class DuplicateSymbolPartsAction : public SymbolPartListAction {
public: public:
DuplicateSymbolPartsAction(Symbol& symbol, const set<SymbolPartP>& parts); DuplicateSymbolPartsAction(Symbol& symbol, const set<SymbolPartP>& parts);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
/// Fill a set with all the new parts /// Fill a set with all the new parts
void getParts(set<SymbolPartP>& parts); void getParts(set<SymbolPartP>& parts);
...@@ -225,8 +225,8 @@ class ReorderSymbolPartsAction : public SymbolPartListAction { ...@@ -225,8 +225,8 @@ class ReorderSymbolPartsAction : public SymbolPartListAction {
public: public:
ReorderSymbolPartsAction(Symbol& symbol, size_t partId1, size_t partId2); ReorderSymbolPartsAction(Symbol& symbol, size_t partId1, size_t partId2);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
private: private:
Symbol& symbol; ///< Symbol to swap the parts in Symbol& symbol; ///< Symbol to swap the parts in
......
This diff is collapsed.
...@@ -31,8 +31,8 @@ class ControlPointMoveAction : public Action { ...@@ -31,8 +31,8 @@ class ControlPointMoveAction : public Action {
public: public:
ControlPointMoveAction(const set<ControlPointP>& points); ControlPointMoveAction(const set<ControlPointP>& points);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
/// Update this action to move some more /// Update this action to move some more
void move(const Vector2D& delta); void move(const Vector2D& delta);
...@@ -52,16 +52,16 @@ class HandleMoveAction : public Action { ...@@ -52,16 +52,16 @@ class HandleMoveAction : public Action {
public: public:
HandleMoveAction(const SelectedHandle& handle); HandleMoveAction(const SelectedHandle& handle);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
/// Update this action to move some more /// Update this action to move some more
void move(const Vector2D& delta); void move(const Vector2D& delta);
private: private:
SelectedHandle handle; ///< The handle to move SelectedHandle handle; ///< The handle to move
Vector2D oldHandle; ///< Old value of this handle Vector2D old_handle; ///< Old value of this handle
Vector2D oldOther; ///< Old value of other handle, needed for contraints Vector2D old_other; ///< Old value of other handle, needed for contraints
Vector2D delta; ///< Amount we moved Vector2D delta; ///< Amount we moved
public: public:
bool constrain; ///< Constrain movement? bool constrain; ///< Constrain movement?
...@@ -90,8 +90,8 @@ class SegmentModeAction : public Action { ...@@ -90,8 +90,8 @@ class SegmentModeAction : public Action {
public: public:
SegmentModeAction(const ControlPointP& p1, const ControlPointP& p2, SegmentMode mode); SegmentModeAction(const ControlPointP& p1, const ControlPointP& p2, SegmentMode mode);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
protected: protected:
ControlPointUpdate point1, point2; ControlPointUpdate point1, point2;
...@@ -104,8 +104,8 @@ class LockModeAction : public Action { ...@@ -104,8 +104,8 @@ class LockModeAction : public Action {
public: public:
LockModeAction(const ControlPointP& p, LockMode mode); LockModeAction(const ControlPointP& p, LockMode mode);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
private: private:
ControlPointUpdate point; ///< The affected point ControlPointUpdate point; ///< The affected point
...@@ -120,8 +120,8 @@ class CurveDragAction : public SegmentModeAction { ...@@ -120,8 +120,8 @@ class CurveDragAction : public SegmentModeAction {
public: public:
CurveDragAction(const ControlPointP& point1, const ControlPointP& point2); CurveDragAction(const ControlPointP& point1, const ControlPointP& point2);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
// Move the curve by this much, it is grabbed at time t // Move the curve by this much, it is grabbed at time t
void move(const Vector2D& delta, double t); void move(const Vector2D& delta, double t);
...@@ -133,17 +133,17 @@ class CurveDragAction : public SegmentModeAction { ...@@ -133,17 +133,17 @@ class CurveDragAction : public SegmentModeAction {
class ControlPointAddAction : public Action { class ControlPointAddAction : public Action {
public: public:
/// Insert a new point in part, after position insertAfter_, at the time t on the segment /// Insert a new point in part, after position insertAfter_, at the time t on the segment
ControlPointAddAction(const SymbolPartP& part, UInt insertAfter, double t); ControlPointAddAction(const SymbolPartP& part, UInt insert_after, double t);
virtual String getName(bool toUndo) const; virtual String getName(bool to_undo) const;
virtual void perform(bool toUndo); virtual void perform(bool to_undo);
inline ControlPointP getNewPoint() const { return newPoint; } inline ControlPointP getNewPoint() const { return new_point; }
private: private:
SymbolPartP part; ///< SymbolPart we are in SymbolPartP part; ///< SymbolPart we are in
ControlPointP newPoint; ///< The point to insert ControlPointP new_point; ///< The point to insert
UInt insertAfter; ///< Insert after index .. in the array UInt insert_after; ///< Insert after index .. in the array
ControlPointUpdate point1, point2; ///< Update the points around the new point ControlPointUpdate point1, point2; ///< Update the points around the new point
}; };
......
...@@ -22,11 +22,11 @@ Card::Card() { ...@@ -22,11 +22,11 @@ Card::Card() {
if (!game_for_new_cards()) { if (!game_for_new_cards()) {
throw InternalError(_("game_for_new_cards not set")); throw InternalError(_("game_for_new_cards not set"));
} }
data.init(game_for_new_cards()->cardFields); data.init(game_for_new_cards()->card_fields);
} }
Card::Card(const Game& game) { Card::Card(const Game& game) {
data.init(game.cardFields); data.init(game.card_fields);
} }
String Card::identification() const { String Card::identification() const {
......
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
// ----------------------------------------------------------------------------- : Field // ----------------------------------------------------------------------------- : Field
Field::Field() Field::Field()
: index (0) // sensible default? : index (0) // sensible default?
, editable (true) , editable (true)
, saveValue (true) , save_value (true)
, showStatistics (true) , show_statistics (true)
, identifying (false) , identifying (false)
, cardListColumn (-1) , card_list_column (-1)
, cardListWidth (100) , card_list_width (100)
, cardListAllow (true) , card_list_allow (true)
// , cardListAlign (ALIGN_LEFT) // , card_list_align (ALIGN_LEFT)
, tabIndex (0) , tab_index (0)
{} {}
Field::~Field() {} Field::~Field() {}
...@@ -29,8 +29,17 @@ Field::~Field() {} ...@@ -29,8 +29,17 @@ Field::~Field() {}
IMPLEMENT_REFLECTION(Field) { IMPLEMENT_REFLECTION(Field) {
if (!tag.reading()) { if (!tag.reading()) {
String type = typeName(); String type = typeName();
REFLECT_N("type", type); REFLECT(type);
} }
REFLECT(editable);
REFLECT(save_value);
REFLECT(show_statistics);
REFLECT(identifying);
REFLECT(card_list_column);
REFLECT(card_list_width);
REFLECT(card_list_allow);
// REFLECT(card_list_align);
REFLECT(tab_index);
} }
template <> template <>
...@@ -49,6 +58,8 @@ shared_ptr<Field> read_new<Field>(Reader& reader) { ...@@ -49,6 +58,8 @@ shared_ptr<Field> read_new<Field>(Reader& reader) {
// ----------------------------------------------------------------------------- : Style // ----------------------------------------------------------------------------- : Style
Style::~Style() {}
IMPLEMENT_REFLECTION(Style) { IMPLEMENT_REFLECTION(Style) {
} }
...@@ -58,6 +69,8 @@ void initObject(const FieldP& field, StyleP& style) { ...@@ -58,6 +69,8 @@ void initObject(const FieldP& field, StyleP& style) {
// ----------------------------------------------------------------------------- : Value // ----------------------------------------------------------------------------- : Value
Value::~Value() {}
IMPLEMENT_REFLECTION(Value) { IMPLEMENT_REFLECTION(Value) {
} }
......
...@@ -24,19 +24,19 @@ class Field { ...@@ -24,19 +24,19 @@ class Field {
Field(); Field();
virtual ~Field(); virtual ~Field();
UInt index; ///< Used by IndexMap UInt index; ///< Used by IndexMap
String name; ///< Name of the field, for refering to it from scripts and files String name; ///< Name of the field, for refering to it from scripts and files
String description; ///< Description, used in status bar String description; ///< Description, used in status bar
bool editable; ///< Can values of this field be edited? bool editable; ///< Can values of this field be edited?
bool saveValue; ///< Should values of this field be written to files? Can be false for script generated fields. bool save_value; ///< Should values of this field be written to files? Can be false for script generated fields.
bool showStatistics; ///< Should this field appear as a group by choice in the statistics panel? bool show_statistics; ///< Should this field appear as a group by choice in the statistics panel?
bool identifying; ///< Does this field give Card::identification()? bool identifying; ///< Does this field give Card::identification()?
int cardListColumn; ///< What column to use in the card list? -1 = don't list int card_list_column; ///< What column to use in the card list? -1 = don't list
UInt cardListWidth; ///< Width of the card list column (pixels). UInt card_list_width; ///< Width of the card list column (pixels).
bool cardListAllow; ///< Is this field allowed to appear in the card list. bool card_list_allow; ///< Is this field allowed to appear in the card list.
String cardListName; ///< Alternate name to use in card list. String card_list_name; ///< Alternate name to use in card list.
// Alignment cardListAlign; ///< Alignment of the card list colummn. // Alignment card_list_align; ///< Alignment of the card list colummn.
int tabIndex; ///< Tab index in editor int tab_index; ///< Tab index in editor
// Vector<DependendScript> dependendScripts; // scripts that depend on values of this field // Vector<DependendScript> dependendScripts; // scripts that depend on values of this field
/// Creates a new Value corresponding to this Field /// Creates a new Value corresponding to this Field
......
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/field/text.hpp>
// ----------------------------------------------------------------------------- : TextField
TextField::TextField()
: multi_line(false), move_cursor_with_sort(false)
, default_name(_("Default"))
{}
StyleP TextField::newStyle(const FieldP& thisP) const {
assert(thisP.get() == this);
return new_shared<TextStyle>();
}
ValueP TextField::newValue(const FieldP& thisP) const {
assert(thisP.get() == this);
return new_shared<TextValue>();
}
FieldP TextField::clone() const {
return new_shared1<TextField>(*this);
}
String TextField::typeName() const {
return _("text");
}
IMPLEMENT_REFLECTION(TextField) {
REFLECT_BASE(Field);
REFLECT(multi_line);
// REFLECT(script);
// REFLECT_N("default", default_script);
REFLECT(move_cursor_with_sort);
REFLECT(default_name);
}
// ----------------------------------------------------------------------------- : TextStyle
StyleP TextStyle::clone() const {
return new_shared1<TextStyle>(*this);
}
IMPLEMENT_REFLECTION(TextStyle) {
REFLECT_BASE(Style);
}
// ----------------------------------------------------------------------------- : TextValue
ValueP TextValue::clone() const {
return new_shared1<TextValue>(*this);
}
IMPLEMENT_REFLECTION(TextValue) {
REFLECT_BASE(Value);
}
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_FIELD_TEXT
#define HEADER_DATA_FIELD_TEXT
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field.hpp>
// ----------------------------------------------------------------------------- : TextField
/// A field that stores tagged text
class TextField : public Field {
public:
TextField();
// Script script;
// Script default_script;
bool multi_line; ///< Are newlines allowed in the text?
bool move_cursor_with_sort; ///< When the text is reordered by a script should the cursor position be updated?
String default_name; ///< Name of "default" value
virtual ValueP newValue(const FieldP& thisP) const;
virtual StyleP newStyle(const FieldP& thisP) const;
virtual FieldP clone() const;
virtual String typeName() const;
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : TextStyle
/// The Style for a TextField
class TextStyle : public Style {
public:
// FontInfo font; ///< Font to use for the text
// SymbolFontInfo symbol_font; ///< Symbol font for symbols in the text
bool always_symbol; ///< Should everything be drawn as symbols?
bool allow_formatting; ///< Is formating (bold/italic/..) allowed?
// Alignment alignment; ///< Alignment inside the box
int angle; ///< Angle of the text inside the box
int padding_left, padding_left_min; ///< Padding
int padding_right, padding_right_min; ///< Padding
int padding_top, padding_top_min; ///< Padding
int padding_bottom, padding_bottom_min; ///< Padding
double line_height_soft; ///< Line height for soft linebreaks
double line_height_hard; ///< Line height for hard linebreaks
double line_height_line; ///< Line height for <line> tags
String mask_filename; ///< Filename of the mask
// ContourMaskP mask; ///< Mask to fit the text to (may be null)
virtual StyleP clone() const;
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : TextValue
/// The Value in a TextField
class TextValue : public Value {
public:
virtual ValueP clone() const;
String value;
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -25,18 +25,18 @@ String Game::typeName() const { return _("game"); } ...@@ -25,18 +25,18 @@ String Game::typeName() const { return _("game"); }
IMPLEMENT_REFLECTION(Game) { IMPLEMENT_REFLECTION(Game) {
// ioMseVersion(io, fileName, fileVersion); // ioMseVersion(io, fileName, fileVersion);
REFLECT_N("full name", fullName); REFLECT(full_name);
REFLECT_N("icon", iconFilename); REFLECT_N("icon", icon_filename);
// REFLECT_N("init script", initScript); // REFLECT(init_script);
REFLECT_N("set field", setFields); REFLECT(set_fields);
REFLECT_N("card field", cardFields); REFLECT(card_fields);
// REFLECT_N("keyword parameter type", keywordParams); // REFLECT_N("keyword parameter type", keyword_params);
// REFLECT_N("keyword separator type", keywordSeparators); // REFLECT_N("keyword separator type", keyword_separators);
// REFLECT_N("keyword", keywords); // REFLECT_N("keyword", keywords);
// REFLECT_N("word list", wordLists); // REFLECT_N("word list", word_lists);
} }
void Game::validate() { void Game::validate() {
// a default for the full name // a default for the full name
if (fullName.empty()) fullName = name(); if (full_name.empty()) full_name = name();
} }
\ No newline at end of file
...@@ -19,10 +19,10 @@ DECLARE_POINTER_TYPE(Game); ...@@ -19,10 +19,10 @@ DECLARE_POINTER_TYPE(Game);
class Game : public Packaged { class Game : public Packaged {
public: public:
String fullName; String full_name;
String iconFilename; String icon_filename;
vector<FieldP> setFields; vector<FieldP> set_fields;
vector<FieldP> cardFields; vector<FieldP> card_fields;
/// Loads the game with a particular name, for example "magic" /// Loads the game with a particular name, for example "magic"
static GameP byName(const String& name); static GameP byName(const String& name);
......
...@@ -30,11 +30,11 @@ IMPLEMENT_REFLECTION(ColumnSettings) { ...@@ -30,11 +30,11 @@ IMPLEMENT_REFLECTION(ColumnSettings) {
} }
IMPLEMENT_REFLECTION(GameSettings) { IMPLEMENT_REFLECTION(GameSettings) {
REFLECT_N("default style", defaultStyle); REFLECT(default_style);
REFLECT_N("default export", defaultExport); REFLECT(default_export);
// REFLECT_N("cardlist columns", columns); // REFLECT_N("cardlist columns", columns);
REFLECT_N("sort cards by", sortCardsBy); REFLECT(sort_cards_by);
REFLECT_N("sort cards ascending", sortCardsAscending); REFLECT(sort_cards_ascending);
} }
IMPLEMENT_REFLECTION(StyleSettings) { IMPLEMENT_REFLECTION(StyleSettings) {
...@@ -46,12 +46,12 @@ IMPLEMENT_REFLECTION(StyleSettings) { ...@@ -46,12 +46,12 @@ IMPLEMENT_REFLECTION(StyleSettings) {
Settings settings; Settings settings;
Settings::Settings() Settings::Settings()
: setWindowMaximized (false) : set_window_maximized (false)
, setWindowWidth (790) , set_window_width (790)
, setWindowHeight (300) , set_window_height (300)
, cardNotesHeight (40) , card_notes_height (40)
, updatesUrl (_("http://magicseteditor.sourceforge.net/updates")) , updates_url (_("http://magicseteditor.sourceforge.net/updates"))
, checkUpdates (CHECK_IF_CONNECTED) , check_updates (CHECK_IF_CONNECTED)
{} {}
void Settings::addRecentFile(const String& filename) { void Settings::addRecentFile(const String& filename) {
...@@ -60,18 +60,18 @@ void Settings::addRecentFile(const String& filename) { ...@@ -60,18 +60,18 @@ void Settings::addRecentFile(const String& filename) {
fn.Normalize(); fn.Normalize();
String filenameAbs = fn.GetFullPath(); String filenameAbs = fn.GetFullPath();
// remove duplicates // remove duplicates
recentSets.erase( recent_sets.erase(
remove(recentSets.begin(), recentSets.end(), filenameAbs), remove(recent_sets.begin(), recent_sets.end(), filenameAbs),
recentSets.end() recent_sets.end()
); );
// add to front of list // add to front of list
recentSets.insert(recentSets.begin(), filenameAbs); recent_sets.insert(recent_sets.begin(), filenameAbs);
// enforce size limit // enforce size limit
if (recentSets.size() > maxRecentSets) recentSets.resize(maxRecentSets); if (recent_sets.size() > max_recent_sets) recent_sets.resize(max_recent_sets);
} }
GameSettings& Settings::gameSettingsFor(const Game& game) { GameSettings& Settings::gameSettingsFor(const Game& game) {
GameSettingsP& gs = settings.gameSettings[game.name()]; GameSettingsP& gs = settings.game_settings[game.name()];
if (!gs) gs.reset(new GameSettings); if (!gs) gs.reset(new GameSettings);
return *gs; return *gs;
} }
...@@ -84,29 +84,29 @@ StyleSettings& Settings::styleSettingsFor(const CardStyle& style) { ...@@ -84,29 +84,29 @@ StyleSettings& Settings::styleSettingsFor(const CardStyle& style) {
} }
*/ */
String userSettingsDir() { String user_settings_dir() {
return _(""); // TODO return _(""); // TODO
} }
String Settings::settingsFile() { String Settings::settingsFile() {
// return userSettingsDir() + _("mse.config"); // return user_settings_dir() + _("mse.config");
return userSettingsDir() + _("mse8.config"); // use different file during development of C++ port return user_settings_dir() + _("mse8.config"); // use different file during development of C++ port
} }
IMPLEMENT_REFLECTION(Settings) { IMPLEMENT_REFLECTION(Settings) {
// ioMseVersion(io, "settings", fileVersion); // ioMseVersion(io, "settings", file_version);
REFLECT_N("recent set", recentSets); REFLECT_N("recent_set", recent_sets);
REFLECT_N("window maximized", setWindowMaximized); REFLECT(set_window_maximized);
REFLECT_N("window width", setWindowWidth); REFLECT(set_window_width);
REFLECT_N("window height", setWindowHeight); REFLECT(set_window_height);
REFLECT_N("card notes height", cardNotesHeight); REFLECT(card_notes_height);
REFLECT_N("default game", defaultGame); REFLECT(default_game);
REFLECT_N("apprentice location", apprenticeLocation); REFLECT(apprentice_location);
REFLECT_N("updates url", updatesUrl); REFLECT(updates_url);
REFLECT_N("check updates", checkUpdates); REFLECT(check_updates);
// ioAll(io, "game settings", gameSettings); // ioAll(io, game_settings);
// ioStyleSettings(io); // ioStyleSettings(io);
// REFLECT_N("default style settings", defaultStyleSettings); // REFLECT(default_style_settings);
} }
void Settings::read() { void Settings::read() {
......
...@@ -40,11 +40,11 @@ class ColumnSettings { ...@@ -40,11 +40,11 @@ class ColumnSettings {
/// Settings for a Game /// Settings for a Game
class GameSettings { class GameSettings {
public: public:
String defaultStyle; String default_style;
String defaultExport; String default_export;
map<String, ColumnSettings> columns; map<String, ColumnSettings> columns;
String sortCardsBy; String sort_cards_by;
bool sortCardsAscending; bool sort_cards_ascending;
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
...@@ -53,11 +53,11 @@ class GameSettings { ...@@ -53,11 +53,11 @@ class GameSettings {
class StyleSettings { class StyleSettings {
public: public:
// Rendering/display settings // Rendering/display settings
/* SimpleDefaultable<double> cardZoom = 1.0; /* SimpleDefaultable<double> card_zoom = 1.0;
SimpleDefaultable<int> cardAngle = 0; SimpleDefaultable<int> card_angle = 0;
SimpleDefaultable<bool> cardAntiAlias = true; SimpleDefaultable<bool> card_anti_alias = true;
SimpleDefaultable<bool> cardBorders = true; SimpleDefaultable<bool> card_borders = true;
SimpleDefaultable<bool> cardNormalExport = true; SimpleDefaultable<bool> card_normal_export = true;
*/ */
DECLARE_REFLECTION(); DECLARE_REFLECTION();
...@@ -77,20 +77,20 @@ class Settings { ...@@ -77,20 +77,20 @@ class Settings {
Settings(); Settings();
// --------------------------------------------------- : Recently opened sets // --------------------------------------------------- : Recently opened sets
vector<String> recentSets; vector<String> recent_sets;
static const UInt maxRecentSets = 4; // store this many recent sets static const UInt max_recent_sets = 4; // store this many recent sets
/// Add a file to the list of recent files /// Add a file to the list of recent files
void addRecentFile(const String& filename); void addRecentFile(const String& filename);
// --------------------------------------------------- : Set window size // --------------------------------------------------- : Set window size
bool setWindowMaximized; bool set_window_maximized;
UInt setWindowWidth; UInt set_window_width;
UInt setWindowHeight; UInt set_window_height;
UInt cardNotesHeight; UInt card_notes_height;
// --------------------------------------------------- : Default pacakge selections // --------------------------------------------------- : Default pacakge selections
String defaultGame; String default_game;
// --------------------------------------------------- : Game/style specific // --------------------------------------------------- : Game/style specific
...@@ -100,18 +100,18 @@ class Settings { ...@@ -100,18 +100,18 @@ class Settings {
StyleSettings& styleSettingsFor(const CardStyle& style); StyleSettings& styleSettingsFor(const CardStyle& style);
private: private:
map<String,GameSettingsP> gameSettings; map<String,GameSettingsP> game_settings;
map<String,StyleSettingsP> styleSettings; map<String,StyleSettingsP> style_settings;
StyleSettings defaultStyleSettings; StyleSettings default_style_settings;
public: public:
// --------------------------------------------------- : Special game stuff // --------------------------------------------------- : Special game stuff
String apprenticeLocation; String apprentice_location;
String mwsLocation; String mws_location;
// --------------------------------------------------- : Update checking // --------------------------------------------------- : Update checking
String updatesUrl; String updates_url;
CheckUpdates checkUpdates; CheckUpdates check_updates;
// --------------------------------------------------- : The io // --------------------------------------------------- : The io
......
...@@ -27,30 +27,30 @@ IMPLEMENT_REFLECTION_ENUM(SegmentMode) { ...@@ -27,30 +27,30 @@ IMPLEMENT_REFLECTION_ENUM(SegmentMode) {
IMPLEMENT_REFLECTION(ControlPoint) { IMPLEMENT_REFLECTION(ControlPoint) {
REFLECT_N("position", pos); REFLECT_N("position", pos);
REFLECT_N("lock", lock); REFLECT_N("lock", lock);
REFLECT_N("line after", segmentAfter); REFLECT_N("line_after", segment_after);
if (tag.reading() || segmentBefore == SEGMENT_CURVE) { if (tag.reading() || segment_before == SEGMENT_CURVE) {
REFLECT_N("handle before", deltaBefore); REFLECT_N("handle_before", delta_before);
} }
if (tag.reading() || segmentAfter == SEGMENT_CURVE) { if (tag.reading() || segment_after == SEGMENT_CURVE) {
REFLECT_N("handle after", deltaAfter); REFLECT_N("handle_after", delta_after);
} }
} }
ControlPoint::ControlPoint() ControlPoint::ControlPoint()
: segmentBefore(SEGMENT_LINE), segmentAfter(SEGMENT_LINE) : segment_before(SEGMENT_LINE), segment_after(SEGMENT_LINE)
, lock(LOCK_FREE) , lock(LOCK_FREE)
{} {}
ControlPoint::ControlPoint(double x, double y) ControlPoint::ControlPoint(double x, double y)
: segmentBefore(SEGMENT_LINE), segmentAfter(SEGMENT_LINE) : segment_before(SEGMENT_LINE), segment_after(SEGMENT_LINE)
, lock(LOCK_FREE) , lock(LOCK_FREE)
, pos(x,y) , 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)
: segmentBefore(SEGMENT_CURVE), segmentAfter(SEGMENT_CURVE) : segment_before(SEGMENT_CURVE), segment_after(SEGMENT_CURVE)
, lock(lock) , lock(lock)
, pos(x,y) , pos(x,y)
, deltaBefore(xb,yb) , delta_before(xb,yb)
, deltaAfter(xa,ya) , delta_after(xa,ya)
{} {}
void ControlPoint::onUpdateHandle(WhichHandle wh) { void ControlPoint::onUpdateHandle(WhichHandle wh) {
...@@ -64,31 +64,31 @@ void ControlPoint::onUpdateHandle(WhichHandle wh) { ...@@ -64,31 +64,31 @@ void ControlPoint::onUpdateHandle(WhichHandle wh) {
void ControlPoint::onUpdateLock() { void ControlPoint::onUpdateLock() {
// The lock has changed, avarage the handle values // The lock has changed, avarage the handle values
if (lock == LOCK_DIR) { if (lock == LOCK_DIR) {
// deltaBefore = x * deltaAfter // delta_before = x * delta_after
Vector2D dir = (deltaBefore - deltaAfter).normalized(); Vector2D dir = (delta_before - delta_after).normalized();
deltaBefore = dir * deltaBefore.length(); delta_before = dir * delta_before.length();
deltaAfter = dir * -deltaAfter.length(); delta_after = dir * -delta_after.length();
} else if (lock == LOCK_SIZE) { } else if (lock == LOCK_SIZE) {
// deltaBefore = -deltaAfter // delta_before = -delta_after
deltaBefore = (deltaBefore - deltaAfter) * 0.5; delta_before = (delta_before - delta_after) * 0.5;
deltaAfter = -deltaBefore; delta_after = -delta_before;
} }
} }
Vector2D& ControlPoint::getHandle(WhichHandle wh) { Vector2D& ControlPoint::getHandle(WhichHandle wh) {
if (wh == HANDLE_BEFORE) { if (wh == HANDLE_BEFORE) {
return deltaBefore; return delta_before;
} else { } else {
assert(wh == HANDLE_AFTER); assert(wh == HANDLE_AFTER);
return deltaAfter; return delta_after;
} }
} }
Vector2D& ControlPoint::getOther(WhichHandle wh) { Vector2D& ControlPoint::getOther(WhichHandle wh) {
if (wh == HANDLE_BEFORE) { if (wh == HANDLE_BEFORE) {
return deltaAfter; return delta_after;
} else { } else {
assert(wh == HANDLE_AFTER); assert(wh == HANDLE_AFTER);
return deltaBefore; return delta_before;
} }
} }
...@@ -112,13 +112,13 @@ IMPLEMENT_REFLECTION(SymbolPart) { ...@@ -112,13 +112,13 @@ IMPLEMENT_REFLECTION(SymbolPart) {
// enforce constraints // enforce constraints
enforceConstraints(); enforceConstraints();
calculateBounds(); calculateBounds();
if (maxPos.x > 100 && maxPos.y > 100) { if (max_pos.x > 100 && max_pos.y > 100) {
// this is a <= 0.1.2 symbol, points range [0...500] instead of [0...1] // this is a <= 0.1.2 symbol, points range [0...500] instead of [0...1]
// adjust it // adjust it
FOR_EACH(p, points) { FOR_EACH(p, points) {
p->pos /= 500.0; p->pos /= 500.0;
p->deltaBefore /= 500.0; p->delta_before /= 500.0;
p->deltaAfter /= 500.0; p->delta_after /= 500.0;
} }
if (name.empty()) name = _("Shape"); if (name.empty()) name = _("Shape");
calculateBounds(); calculateBounds();
...@@ -127,7 +127,7 @@ IMPLEMENT_REFLECTION(SymbolPart) { ...@@ -127,7 +127,7 @@ IMPLEMENT_REFLECTION(SymbolPart) {
} }
SymbolPart::SymbolPart() SymbolPart::SymbolPart()
: combine(PART_OVERLAP), rotationCenter(.5, .5) : combine(PART_OVERLAP), rotation_center(.5, .5)
{} {}
SymbolPartP SymbolPart::clone() const { SymbolPartP SymbolPart::clone() const {
...@@ -143,16 +143,16 @@ void SymbolPart::enforceConstraints() { ...@@ -143,16 +143,16 @@ void SymbolPart::enforceConstraints() {
for (int i = 0 ; i < (int)points.size() ; ++i) { for (int i = 0 ; i < (int)points.size() ; ++i) {
ControlPointP p1 = getPoint(i); ControlPointP p1 = getPoint(i);
ControlPointP p2 = getPoint(i + 1); ControlPointP p2 = getPoint(i + 1);
p2->segmentBefore = p1->segmentAfter; p2->segment_before = p1->segment_after;
p1->onUpdateLock(); p1->onUpdateLock();
} }
} }
void SymbolPart::calculateBounds() { void SymbolPart::calculateBounds() {
minPos = Vector2D::infinity(); min_pos = Vector2D::infinity();
maxPos = -Vector2D::infinity(); max_pos = -Vector2D::infinity();
for (int i = 0 ; i < (int)points.size() ; ++i) { for (int i = 0 ; i < (int)points.size() ; ++i) {
segmentBounds(*getPoint(i), *getPoint(i + 1), minPos, maxPos); segment_bounds(*getPoint(i), *getPoint(i + 1), min_pos, max_pos);
} }
} }
......
...@@ -21,12 +21,12 @@ DECLARE_POINTER_TYPE(Symbol); ...@@ -21,12 +21,12 @@ DECLARE_POINTER_TYPE(Symbol);
// ----------------------------------------------------------------------------- : ControlPoint // ----------------------------------------------------------------------------- : ControlPoint
/// Mode of locking for control points in a bezier curve /// Mode of locking for control points in a bezier curve
/** Specificly: the relation between deltaBefore and deltaAfter /** Specificly: the relation between delta_before and delta_after
*/ */
enum LockMode enum LockMode
{ LOCK_FREE ///< no locking { LOCK_FREE ///< no locking
, LOCK_DIR ///< deltaBefore = x * deltaAfter , LOCK_DIR ///< delta_before = x * delta_after
, LOCK_SIZE ///< deltaBefore = -deltaAfter , LOCK_SIZE ///< delta_before = -delta_after
}; };
/// Is the segment between two ControlPoints a line or a curve? /// Is the segment between two ControlPoints a line or a curve?
...@@ -47,19 +47,19 @@ enum WhichHandle ...@@ -47,19 +47,19 @@ enum WhichHandle
class ControlPoint { class ControlPoint {
public: public:
Vector2D pos; ///< position of the control point itself Vector2D pos; ///< position of the control point itself
Vector2D deltaBefore; ///< delta to bezier control point, for curve before point Vector2D delta_before; ///< delta to bezier control point, for curve before point
Vector2D deltaAfter; ///< delta to bezier control point, for curve after point Vector2D delta_after; ///< delta to bezier control point, for curve after point
SegmentMode segmentBefore, segmentAfter; SegmentMode segment_before, segment_after;
LockMode lock; LockMode lock;
/// Default constructor /// Default constructor
ControlPoint(); ControlPoint();
/// Constructor for straight lines, takes only the position /// Constructor for straight lines, takes only the position
ControlPoint(double x, double y); ControlPoint(double x, double y);
/// Constructor for curves lines, takes postions, deltaBefore, deltaAfter and lock mode /// Constructor for curves lines, takes postions, delta_before, delta_after and lock mode
ControlPoint(double x, double y, double xb, double yb, double xa, double ya, LockMode lock = LOCK_FREE); ControlPoint(double x, double y, double xb, double yb, double xa, double ya, LockMode lock = LOCK_FREE);
/// Must be called after deltaBefore/deltaAfter has changed, enforces lock constraints /// Must be called after delta_before/delta_after has changed, enforces lock constraints
void onUpdateHandle(WhichHandle wh); void onUpdateHandle(WhichHandle wh);
/// Must be called after lock has changed, enforces lock constraints /// Must be called after lock has changed, enforces lock constraints
void onUpdateLock(); void onUpdateLock();
...@@ -124,10 +124,10 @@ class SymbolPart { ...@@ -124,10 +124,10 @@ class SymbolPart {
/// How is this part combined with parts below it? /// How is this part combined with parts below it?
SymbolPartCombine combine; SymbolPartCombine combine;
// Center of rotation, relative to the part, when the part is scaled to [0..1] // Center of rotation, relative to the part, when the part is scaled to [0..1]
Vector2D rotationCenter; Vector2D rotation_center;
/// Position and size of the part /// Position and size of the part
/// this is the smallest axis aligned bounding box that fits around the part /// this is the smallest axis aligned bounding box that fits around the part
Vector2D minPos, maxPos; Vector2D min_pos, max_pos;
SymbolPart(); SymbolPart();
......
This diff is collapsed.
...@@ -67,7 +67,7 @@ void deCasteljau(const Vector2D& a1, Vector2D& a21, Vector2D& a34, const Vector2 ...@@ -67,7 +67,7 @@ void deCasteljau(const Vector2D& a1, Vector2D& a21, Vector2D& a34, const Vector2
/** Adds the resulting corner points of those lines to out, the last point is not added. /** Adds the resulting corner points of those lines to out, the last point is not added.
* All points are converted to display coordinates using rot.tr * All points are converted to display coordinates using rot.tr
*/ */
void segmentSubdivide(const ControlPoint& p0, const ControlPoint& p1, const Rotation& rot, vector<wxPoint>& out); void segment_subdivide(const ControlPoint& p0, const ControlPoint& p1, const Rotation& rot, vector<wxPoint>& out);
// ----------------------------------------------------------------------------- : Bounds // ----------------------------------------------------------------------------- : Bounds
...@@ -76,30 +76,30 @@ void segmentSubdivide(const ControlPoint& p0, const ControlPoint& p1, const Rota ...@@ -76,30 +76,30 @@ void segmentSubdivide(const ControlPoint& p0, const ControlPoint& p1, const Rota
* min is only changed if the minimum is smaller then the current value in min, * min is only changed if the minimum is smaller then the current value in min,
* max only if the maximum is larger. * max only if the maximum is larger.
*/ */
void segmentBounds(const ControlPoint& p1, const ControlPoint& p2, Vector2D& min, Vector2D& max); void segment_bounds(const ControlPoint& p1, const ControlPoint& p2, Vector2D& min, Vector2D& max);
/// Find a bounding box that fits a curve between p1 and p2, stores the results in min and max. /// Find a bounding box that fits a curve between p1 and p2, stores the results in min and max.
/** min is only changed if the minimum is smaller then the current value in min, /** min is only changed if the minimum is smaller then the current value in min,
* max only if the maximum is larger * max only if the maximum is larger
*/ */
void bezierBounds(const ControlPoint& p1, const ControlPoint& p2, Vector2D& min, Vector2D& max); void bezier_bounds(const ControlPoint& p1, const ControlPoint& p2, Vector2D& min, Vector2D& max);
/// Find a bounding box that fits around p1 and p2, stores the result in min and max /// Find a bounding box that fits around p1 and p2, stores the result in min and max
/** min is only changed if the minimum is smaller then the current value in min, /** min is only changed if the minimum is smaller then the current value in min,
* max only if the maximum is larger * max only if the maximum is larger
*/ */
void lineBounds(const Vector2D& p1, const Vector2D& p2, Vector2D& min, Vector2D& max); void line_bounds(const Vector2D& p1, const Vector2D& p2, Vector2D& min, Vector2D& max);
/// Find a bounding 'box' that fits around a single point /// Find a bounding 'box' that fits around a single point
/** min is only changed if the minimum is smaller then the current value in min, /** min is only changed if the minimum is smaller then the current value in min,
* max only if the maximum is larger * max only if the maximum is larger
*/ */
void pointBounds(const Vector2D& p, Vector2D& min, Vector2D& max); void point_bounds(const Vector2D& p, Vector2D& min, Vector2D& max);
// ----------------------------------------------------------------------------- : Point tests // ----------------------------------------------------------------------------- : Point tests
/// Is a point inside the given symbol part? /// Is a point inside the given symbol part?
bool pointInPart(const Vector2D& p, const SymbolPart& part); bool point_in_part(const Vector2D& p, const SymbolPart& part);
// ----------------------------------------------------------------------------- : Finding points // ----------------------------------------------------------------------------- : Finding points
...@@ -107,24 +107,24 @@ bool pointInPart(const Vector2D& p, const SymbolPart& part); ...@@ -107,24 +107,24 @@ bool pointInPart(const Vector2D& p, const SymbolPart& part);
/// the line between p1 and p2 can also be a bezier curve /// the line between p1 and p2 can also be a bezier curve
/** Returns the time on the segment in tOut, and the point on the segment in pOut /** Returns the time on the segment in tOut, and the point on the segment in pOut
*/ */
bool posOnSegment(const Vector2D& pos, double range, const ControlPoint& p1, const ControlPoint& p2, Vector2D& pOut, double& tOut); bool pos_on_segment(const Vector2D& pos, double range, const ControlPoint& p1, const ControlPoint& p2, Vector2D& pOut, double& tOut);
/// Finds the position of p0 on the line between p1 and p2, returns true if the point is on (or near) /// Finds the position of p0 on the line between p1 and p2, returns true if the point is on (or near)
/// the bezier curve between p1 and p2 /// the bezier curve between p1 and p2
bool posOnBezier (const Vector2D& pos, double range, const ControlPoint& p1, const ControlPoint& p2, Vector2D& pOut, double& tOut); bool pos_on_bezier (const Vector2D& pos, double range, const ControlPoint& p1, const ControlPoint& p2, Vector2D& pOut, double& tOut);
/// Finds the position of p0 on the line p1-p2, returns true if the point is withing range of the line /// Finds the position of p0 on the line p1-p2, returns true if the point is withing range of the line
/// if that is the case then (x,y) = p1 + (p2-p1) * out /// if that is the case then (x,y) = p1 + (p2-p1) * out
bool posOnLine (const Vector2D& pos, double range, const Vector2D& p1, const Vector2D& p2, Vector2D& pOut, double& tOut); bool pos_on_line (const Vector2D& pos, double range, const Vector2D& p1, const Vector2D& p2, Vector2D& pOut, double& tOut);
// ----------------------------------------------------------------------------- : Intersection // ----------------------------------------------------------------------------- : Intersection
/// Counts the number of intersections between the ray/halfline from (-inf, pos.y) to pos /// Counts the number of intersections between the ray/halfline from (-inf, pos.y) to pos
/// and the bezier curve between p1 and p2. /// and the bezier curve between p1 and p2.
UInt intersectBezierRay(const ControlPoint& p1, const ControlPoint& p2, const Vector2D& pos); UInt intersect_bezier_ray(const ControlPoint& p1, const ControlPoint& p2, const Vector2D& pos);
// Does the line between p1 and p2 intersect the ray (half line) from (-inf, pos.y) to pos? // Does the line between p1 and p2 intersect the ray (half line) from (-inf, pos.y) to pos?
bool intersectLineRay(const Vector2D& p1, const Vector2D& p2, const Vector2D& pos); bool intersect_line_ray(const Vector2D& p1, const Vector2D& p2, const Vector2D& pos);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -88,7 +88,7 @@ COMBINE_FUN(COMBINE_SHADOW, (b * a * a) / (255 * 255) ) ...@@ -88,7 +88,7 @@ COMBINE_FUN(COMBINE_SHADOW, (b * a * a) / (255 * 255) )
/// Combine image b onto image a using some combining mode. /// Combine image b onto image a using some combining mode.
/// The results are stored in the image A. /// The results are stored in the image A.
template <ImageCombine combine> template <ImageCombine combine>
void combineImageDo(Image& a, Image b) { void combine_image_do(Image& a, Image b) {
UInt size = a.GetWidth() * a.GetHeight() * 3; UInt size = a.GetWidth() * a.GetHeight() * 3;
Byte *dataA = a.GetData(), *dataB = b.GetData(); Byte *dataA = a.GetData(), *dataB = b.GetData();
// for each pixel: apply function // for each pixel: apply function
...@@ -97,7 +97,7 @@ void combineImageDo(Image& a, Image b) { ...@@ -97,7 +97,7 @@ void combineImageDo(Image& a, Image b) {
} }
} }
void combineImage(Image& a, const Image& b, ImageCombine combine) { void combine_image(Image& a, const Image& b, ImageCombine combine) {
// Images must have same size // Images must have same size
assert(a.GetWidth() == b.GetWidth()); assert(a.GetWidth() == b.GetWidth());
assert(a.GetHeight() == b.GetHeight()); assert(a.GetHeight() == b.GetHeight());
...@@ -108,7 +108,7 @@ void combineImage(Image& a, const Image& b, ImageCombine combine) { ...@@ -108,7 +108,7 @@ void combineImage(Image& a, const Image& b, ImageCombine combine) {
} }
// Combine image data, by dispatching to combineImageDo // Combine image data, by dispatching to combineImageDo
switch(combine) { switch(combine) {
#define DISPATCH(comb) case comb: combineImageDo<comb>(a,b); return #define DISPATCH(comb) case comb: combine_image_do<comb>(a,b); return
DISPATCH(COMBINE_NORMAL); DISPATCH(COMBINE_NORMAL);
DISPATCH(COMBINE_ADD); DISPATCH(COMBINE_ADD);
DISPATCH(COMBINE_SUBTRACT); DISPATCH(COMBINE_SUBTRACT);
...@@ -135,5 +135,6 @@ void combineImage(Image& a, const Image& b, ImageCombine combine) { ...@@ -135,5 +135,6 @@ void combineImage(Image& a, const Image& b, ImageCombine combine) {
} }
} }
void drawCombineImage(DC& dc, UInt x, UInt y, const Image& img, ImageCombine combine) { void draw_combine_image(DC& dc, UInt x, UInt y, const Image& img, ImageCombine combine) {
// todo
} }
\ No newline at end of file
...@@ -41,7 +41,7 @@ void resample_and_clip(const Image& imgIn, Image& imgOut, wxRect rect); ...@@ -41,7 +41,7 @@ void resample_and_clip(const Image& imgIn, Image& imgOut, wxRect rect);
/// Rotates an image counter clockwise /// Rotates an image counter clockwise
/// angle must be a multiple of 90, i.e. {0,90,180,270} /// angle must be a multiple of 90, i.e. {0,90,180,270}
Image rotateImageBy(const Image& image, int angle); Image rotate_image(const Image& image, int angle);
// ----------------------------------------------------------------------------- : Blending // ----------------------------------------------------------------------------- : Blending
...@@ -59,7 +59,7 @@ void vblend(Image& img1, const Image& img2); ...@@ -59,7 +59,7 @@ void vblend(Image& img1, const Image& img2);
* mask is used as a mask, white pixels are taken from img1, black pixels from img2 * mask is used as a mask, white pixels are taken from img1, black pixels from img2
* color channels are blended separatly * color channels are blended separatly
*/ */
void maskBlend(Image& img1, const Image& img2, const Image& mask); void mask_blend(Image& img1, const Image& img2, const Image& mask);
// ----------------------------------------------------------------------------- : Combining // ----------------------------------------------------------------------------- : Combining
...@@ -94,10 +94,10 @@ enum ImageCombine ...@@ -94,10 +94,10 @@ enum ImageCombine
/// The results are stored in the image A. /// The results are stored in the image A.
/// This image gets the alpha channel from B, it should then be /// This image gets the alpha channel from B, it should then be
/// drawn onto the area where A originated. /// drawn onto the area where A originated.
void combineImage(Image& a, const Image& b, ImageCombine combine); void combine_image(Image& a, const Image& b, ImageCombine combine);
/// Draw an image to a DC using a combining function /// Draw an image to a DC using a combining function
void drawCombineImage(DC& dc, UInt x, UInt y, const Image& img, ImageCombine combine); void draw_combine_image(DC& dc, UInt x, UInt y, const Image& img, ImageCombine combine);
// ----------------------------------------------------------------------------- : Utility // ----------------------------------------------------------------------------- : Utility
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
// ----------------------------------------------------------------------------- : Solving // ----------------------------------------------------------------------------- : Solving
UInt solveLinear(double a, double b, double* root) { UInt solve_linear(double a, double b, double* root) {
if (a == 0) { if (a == 0) {
if (b == 0) { if (b == 0) {
root[0] = 0; root[0] = 0;
...@@ -25,9 +25,9 @@ UInt solveLinear(double a, double b, double* root) { ...@@ -25,9 +25,9 @@ UInt solveLinear(double a, double b, double* root) {
} }
} }
UInt solveQuadratic(double a, double b, double c, double* roots) { UInt solve_quadratic(double a, double b, double c, double* roots) {
if (a == 0) { if (a == 0) {
return solveLinear(b, c, roots); return solve_linear(b, c, roots);
} else { } else {
double d = b*b - 4*a*c; double d = b*b - 4*a*c;
if (d < 0) return 0; if (d < 0) return 0;
...@@ -37,11 +37,11 @@ UInt solveQuadratic(double a, double b, double c, double* roots) { ...@@ -37,11 +37,11 @@ UInt solveQuadratic(double a, double b, double c, double* roots) {
} }
} }
UInt solveCubic(double a, double b, double c, double d, double* roots) { UInt solve_cubic(double a, double b, double c, double d, double* roots) {
if (a == 0) { if (a == 0) {
return solveQuadratic(b, c, d, roots); return solve_quadratic(b, c, d, roots);
} else { } else {
return solveCubic(b/a, c/a, d/a, roots); return solve_cubic(b/a, c/a, d/a, roots);
} }
} }
...@@ -49,7 +49,7 @@ UInt solveCubic(double a, double b, double c, double d, double* roots) { ...@@ -49,7 +49,7 @@ UInt solveCubic(double a, double b, double c, double d, double* roots) {
template <typename T> template <typename T>
inline T curt(T x) { return pow(x, 1.0 / 3); } inline T curt(T x) { return pow(x, 1.0 / 3); }
UInt solveCubic(double a, double b, double c, double* roots) { UInt solve_cubic(double a, double b, double c, double* roots) {
double p = b - a*a / 3; double p = b - a*a / 3;
double q = c + (2 * a*a*a - 9 * a * b) / 27; double q = c + (2 * a*a*a - 9 * a * b) / 27;
if (p == 0 && q == 0) { if (p == 0 && q == 0) {
......
...@@ -21,23 +21,23 @@ ...@@ -21,23 +21,23 @@
/// Solve a linear equation a x + b = 0 /// Solve a linear equation a x + b = 0
/** Returns the number of real roots, and the roots themselfs in the output parameter. /** Returns the number of real roots, and the roots themselfs in the output parameter.
*/ */
UInt solveLinear(double a, double b, double* root); UInt solve_linear(double a, double b, double* root);
/// Solve a quadratic equation a x^2 + b x + c == 0 /// Solve a quadratic equation a x^2 + b x + c == 0
/** Returns the number of real roots, and the roots themselfs in the output parameter. /** Returns the number of real roots, and the roots themselfs in the output parameter.
*/ */
UInt solveQuadratic(double a, double b, double c, double* roots); UInt solve_quadratic(double a, double b, double c, double* roots);
// Solve a cubic equation a x^3 + b x^2 + c x + d == 0 // Solve a cubic equation a x^3 + b x^2 + c x + d == 0
/** Returns the number of real roots, and the roots themselfs in the output parameter. /** Returns the number of real roots, and the roots themselfs in the output parameter.
*/ */
UInt solveCubic(double a, double b, double c, double d, double* roots); UInt solve_cubic(double a, double b, double c, double d, double* roots);
// Solve a cubic equation x^3 + a x^2 + b x + c == 0 // Solve a cubic equation x^3 + a x^2 + b x + c == 0
/** Returns the number of real roots, and the roots themselfs in the output parameter. /** Returns the number of real roots, and the roots themselfs in the output parameter.
* Based on http://en.wikipedia.org/wiki/Cubic_equation * Based on http://en.wikipedia.org/wiki/Cubic_equation
*/ */
UInt solveCubic(double a, double b, double c, double* roots); UInt solve_cubic(double a, double b, double c, double* roots);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// Rotates an image // Rotates an image
// 'Rotater' is a function object that knows how to 'rotate' a pixel coordinate // 'Rotater' is a function object that knows how to 'rotate' a pixel coordinate
template <class Rotater> template <class Rotater>
Image rotateImageImpl(Image img) { Image rotate_image_impl(Image img) {
UInt width = img.GetWidth(), height = img.GetHeight(); UInt width = img.GetWidth(), height = img.GetHeight();
// initialize the return image // initialize the return image
Image ret; Image ret;
...@@ -83,13 +83,13 @@ struct Rotate270 { ...@@ -83,13 +83,13 @@ struct Rotate270 {
// ----------------------------------------------------------------------------- : Interface // ----------------------------------------------------------------------------- : Interface
Image rotateImageBy(const Image& image, int angle) { Image rotate_image(const Image& image, int angle) {
if (angle == 90) { if (angle == 90) {
return rotateImageImpl<Rotate90>(image); return rotate_image_impl<Rotate90>(image);
} else if (angle == 180){ } else if (angle == 180){
return rotateImageImpl<Rotate180>(image); return rotate_image_impl<Rotate180>(image);
} else if (angle == 270){ } else if (angle == 270){
return rotateImageImpl<Rotate270>(image); return rotate_image_impl<Rotate270>(image);
} else{ } else{
return image; return image;
} }
......
...@@ -26,8 +26,8 @@ DECLARE_TYPEOF_COLLECTION(SetWindowPanel*); ...@@ -26,8 +26,8 @@ DECLARE_TYPEOF_COLLECTION(SetWindowPanel*);
SetWindow::SetWindow(Window* parent, const SetP& set) SetWindow::SetWindow(Window* parent, const SetP& set)
: wxFrame(parent, wxID_ANY, _("Magic Set Editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) : wxFrame(parent, wxID_ANY, _("Magic Set Editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
, currentPanel(nullptr) , current_panel(nullptr)
, findDialog(nullptr) , find_dialog(nullptr)
{ {
SetIcon(wxIcon(_("ICON_APP"))); SetIcon(wxIcon(_("ICON_APP")));
...@@ -43,7 +43,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set) ...@@ -43,7 +43,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
menuExport->Append(ID_FILE_EXPORT_IMAGE, _("Card &Image..."), _("Export the selected card to an image file")); menuExport->Append(ID_FILE_EXPORT_IMAGE, _("Card &Image..."), _("Export the selected card to an image file"));
menuExport->Append(ID_FILE_EXPORT_IMAGES, _("All Card I&mages..."), _("Export images for all cards")); menuExport->Append(ID_FILE_EXPORT_IMAGES, _("All Card I&mages..."), _("Export images for all cards"));
menuExport->Append(ID_FILE_EXPORT_APPR, _("&Apprentice..."), _("Export the set so it can be played with in Apprentice")); menuExport->Append(ID_FILE_EXPORT_APPR, _("&Apprentice..."), _("Export the set so it can be played with in Apprentice"));
menuExport->Append(ID_FILE_EXPORT_MWS, _("Magic &Workstation..."), _("Export the set so it can be played with in Magic Workstation")); menuExport->Append(ID_FILE_EXPORT_MWS, _("Magic &Workstation..."), _("Export the set so it can be played with in Magic Workstation"));
menuFile->Append(ID_FILE_EXPORT, _("&Export"), _("Export the set..."), menuExport); menuFile->Append(ID_FILE_EXPORT, _("&Export"), _("Export the set..."), menuExport);
menuFile->AppendSeparator(); menuFile->AppendSeparator();
menuFile->Append(ID_FILE_INSPECT, _("Inspect Internal Data..."), _("Shows a the data in the set using a tree structure")); menuFile->Append(ID_FILE_INSPECT, _("Inspect Internal Data..."), _("Shows a the data in the set using a tree structure"));
...@@ -126,8 +126,8 @@ SetWindow::SetWindow(Window* parent, const SetP& set) ...@@ -126,8 +126,8 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
// loose ends // loose ends
tabBar->Realize(); tabBar->Realize();
SetSize(settings.setWindowWidth, settings.setWindowHeight); SetSize(settings.set_window_width, settings.set_window_height);
if (settings.setWindowMaximized) { if (settings.set_window_maximized) {
Maximize(); Maximize();
} }
// SetWindows.push_back(&this); // register this window // SetWindows.push_back(&this); // register this window
...@@ -144,15 +144,15 @@ SetWindow::SetWindow(Window* parent, const SetP& set) ...@@ -144,15 +144,15 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
SetWindow::~SetWindow() { SetWindow::~SetWindow() {
// store window size in settings // store window size in settings
wxSize s = GetSize(); wxSize s = GetSize();
settings.setWindowMaximized = IsMaximized(); settings.set_window_maximized = IsMaximized();
if (!IsMaximized()) { if (!IsMaximized()) {
settings.setWindowWidth = s.GetWidth(); settings.set_window_width = s.GetWidth();
settings.setWindowHeight = s.GetHeight(); settings.set_window_height = s.GetHeight();
} }
// destroy ui of selected panel // destroy ui of selected panel
currentPanel->destroyUI(GetToolBar(), GetMenuBar()); current_panel->destroyUI(GetToolBar(), GetMenuBar());
// cleanup (see find stuff) // cleanup (see find stuff)
delete findDialog; delete find_dialog;
// remove from list of main windows // remove from list of main windows
// SetWindows.erase(remove(SetWindows.begin(), SetWindows.end(), &this)); // SetWindows.erase(remove(SetWindows.begin(), SetWindows.end(), &this));
// stop updating // stop updating
...@@ -177,11 +177,11 @@ void SetWindow::addPanel(wxMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel* ...@@ -177,11 +177,11 @@ void SetWindow::addPanel(wxMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel*
void SetWindow::selectPanel(int id) { void SetWindow::selectPanel(int id) {
SetWindowPanel* toSelect = panels.at(id - ID_WINDOW_MIN); SetWindowPanel* toSelect = panels.at(id - ID_WINDOW_MIN);
if (currentPanel != toSelect) { if (current_panel != toSelect) {
// destroy & create menus // destroy & create menus
if (currentPanel) currentPanel->destroyUI(GetToolBar(), GetMenuBar()); if (current_panel) current_panel->destroyUI(GetToolBar(), GetMenuBar());
currentPanel = toSelect; current_panel = toSelect;
currentPanel->initUI(GetToolBar(), GetMenuBar()); current_panel->initUI(GetToolBar(), GetMenuBar());
} }
// show/hide panels and select tabs // show/hide panels and select tabs
wxSizer* sizer = GetSizer(); wxSizer* sizer = GetSizer();
...@@ -189,9 +189,9 @@ void SetWindow::selectPanel(int id) { ...@@ -189,9 +189,9 @@ void SetWindow::selectPanel(int id) {
wxMenuBar* menuBar = GetMenuBar(); wxMenuBar* menuBar = GetMenuBar();
int wid = ID_WINDOW_MIN; int wid = ID_WINDOW_MIN;
FOR_EACH(p, panels) { FOR_EACH(p, panels) {
sizer->Show (p, p == currentPanel); sizer->Show (p, p == current_panel);
tabBar->ToggleTool(wid, p == currentPanel); tabBar->ToggleTool(wid, p == current_panel);
menuBar->Check (wid, p == currentPanel); menuBar->Check (wid, p == current_panel);
++wid; ++wid;
} }
// fix sizer stuff // fix sizer stuff
...@@ -322,7 +322,7 @@ void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) { ...@@ -322,7 +322,7 @@ void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) {
switch (ev.GetId()) { switch (ev.GetId()) {
// file menu // file menu
case ID_FILE_SAVE_AS: ev.Enable(!set->actions.atSavePoint() || set->needSaveAs()); break; case ID_FILE_SAVE_AS: ev.Enable(!set->actions.atSavePoint() || set->needSaveAs()); break;
case ID_FILE_EXPORT_IMAGE: ev.Enable(!!currentPanel->selectedCard()); break; case ID_FILE_EXPORT_IMAGE: ev.Enable(!!current_panel->selectedCard()); break;
case ID_FILE_EXPORT_APPR: ev.Enable(set->game->isMagic()); break; case ID_FILE_EXPORT_APPR: ev.Enable(set->game->isMagic()); break;
case ID_FILE_EXPORT_MWS: ev.Enable(set->game->isMagic()); break; case ID_FILE_EXPORT_MWS: ev.Enable(set->game->isMagic()); break;
/*case ID_FILE_INSPECT: { /*case ID_FILE_INSPECT: {
...@@ -346,15 +346,15 @@ void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) { ...@@ -346,15 +346,15 @@ void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) {
break; break;
} }
// copy & paste & find // copy & paste & find
case ID_EDIT_CUT : ev.Enable(currentPanel->canCut()); break; case ID_EDIT_CUT : ev.Enable(current_panel->canCut()); break;
case ID_EDIT_COPY : ev.Enable(currentPanel->canCopy()); break; case ID_EDIT_COPY : ev.Enable(current_panel->canCopy()); break;
case ID_EDIT_PASTE : ev.Enable(currentPanel->canPaste()); break; case ID_EDIT_PASTE : ev.Enable(current_panel->canPaste()); break;
case ID_EDIT_FIND : ev.Enable(currentPanel->canFind()); break; case ID_EDIT_FIND : ev.Enable(current_panel->canFind()); break;
case ID_EDIT_FIND_NEXT : ev.Enable(currentPanel->canFind()); break; case ID_EDIT_FIND_NEXT : ev.Enable(current_panel->canFind()); break;
case ID_EDIT_REPLACE : ev.Enable(currentPanel->canReplace()); break; case ID_EDIT_REPLACE : ev.Enable(current_panel->canReplace()); break;
default: default:
// items created by the panel, and cut/copy/paste and find/replace // items created by the panel, and cut/copy/paste and find/replace
currentPanel->onUpdateUI(ev); current_panel->onUpdateUI(ev);
} }
} }
...@@ -401,7 +401,7 @@ void SetWindow::onFileInspect(wxCommandEvent&) { ...@@ -401,7 +401,7 @@ void SetWindow::onFileInspect(wxCommandEvent&) {
}*/ }*/
void SetWindow::onFileExportImage(wxCommandEvent&) { void SetWindow::onFileExportImage(wxCommandEvent&) {
CardP card = currentPanel->selectedCard(); CardP card = current_panel->selectedCard();
if (!card) return; // no card selected if (!card) return; // no card selected
String name = wxFileSelector(_("Save image"), _(""), card->identification(), _(""), String name = wxFileSelector(_("Save image"), _(""), card->identification(), _(""),
_("JPEG images (*.jpg)|*.jpg|Windows bitmaps (*.bmp)|*.bmp|PNG images (*.png)|*.png|GIF images (*.gif)|*.gif|TIFF images (*.tif)|*.tif"), _("JPEG images (*.jpg)|*.jpg|Windows bitmaps (*.bmp)|*.bmp|PNG images (*.png)|*.png|GIF images (*.gif)|*.gif|TIFF images (*.tif)|*.tif"),
...@@ -465,38 +465,38 @@ void SetWindow::onEditRedo(wxCommandEvent&) { ...@@ -465,38 +465,38 @@ void SetWindow::onEditRedo(wxCommandEvent&) {
} }
void SetWindow::onEditCut (wxCommandEvent&) { void SetWindow::onEditCut (wxCommandEvent&) {
currentPanel->doCut(); current_panel->doCut();
} }
void SetWindow::onEditCopy (wxCommandEvent&) { void SetWindow::onEditCopy (wxCommandEvent&) {
currentPanel->doCopy(); current_panel->doCopy();
} }
void SetWindow::onEditPaste(wxCommandEvent&) { void SetWindow::onEditPaste(wxCommandEvent&) {
currentPanel->doPaste(); current_panel->doPaste();
} }
void SetWindow::onEditFind(wxCommandEvent&) { void SetWindow::onEditFind(wxCommandEvent&) {
delete findDialog; delete find_dialog;
findDialog = new wxFindReplaceDialog(this, &findData, _("Find")); find_dialog = new wxFindReplaceDialog(this, &find_data, _("Find"));
findDialog->Show(); find_dialog->Show();
} }
void SetWindow::onEditFindNext(wxCommandEvent&) { void SetWindow::onEditFindNext(wxCommandEvent&) {
currentPanel->doFind(findData); current_panel->doFind(find_data);
} }
void SetWindow::onEditReplace(wxCommandEvent&) { void SetWindow::onEditReplace(wxCommandEvent&) {
delete findDialog; delete find_dialog;
findDialog = new wxFindReplaceDialog(this, &findData, _("Replace"), wxFR_REPLACEDIALOG); find_dialog = new wxFindReplaceDialog(this, &find_data, _("Replace"), wxFR_REPLACEDIALOG);
findDialog->Show(); find_dialog->Show();
} }
// find events // find events
void SetWindow::onFind (wxFindDialogEvent&) { void SetWindow::onFind (wxFindDialogEvent&) {
currentPanel->doFind(findData); current_panel->doFind(find_data);
} }
void SetWindow::onFindNext (wxFindDialogEvent&) { void SetWindow::onFindNext (wxFindDialogEvent&) {
currentPanel->doFind(findData); current_panel->doFind(find_data);
} }
void SetWindow::onReplace (wxFindDialogEvent&) { void SetWindow::onReplace (wxFindDialogEvent&) {
currentPanel->doReplace(findData); current_panel->doReplace(find_data);
} }
void SetWindow::onReplaceAll(wxFindDialogEvent&) { void SetWindow::onReplaceAll(wxFindDialogEvent&) {
// todo // todo
...@@ -541,7 +541,7 @@ void SetWindow::onHelpAbout(wxCommandEvent&) { ...@@ -541,7 +541,7 @@ void SetWindow::onHelpAbout(wxCommandEvent&) {
// ----------------------------------------------------------------------------- : Window events - menu - for child panel // ----------------------------------------------------------------------------- : Window events - menu - for child panel
void SetWindow::onChildMenu(wxCommandEvent& ev) { void SetWindow::onChildMenu(wxCommandEvent& ev) {
currentPanel->onCommand(ev.GetId()); current_panel->onCommand(ev.GetId());
} }
// ----------------------------------------------------------------------------- : Event table // ----------------------------------------------------------------------------- : Event table
......
...@@ -41,14 +41,14 @@ class SetWindow : public wxFrame, public SetView { ...@@ -41,14 +41,14 @@ class SetWindow : public wxFrame, public SetView {
// gui items // gui items
vector<SetWindowPanel*> panels; ///< All panels on this window vector<SetWindowPanel*> panels; ///< All panels on this window
SetWindowPanel* currentPanel; SetWindowPanel* current_panel;
/// Number of items in the recent sets list /// Number of items in the recent sets list
size_t numberOfRecentSets; size_t number_of_recentSets;
// data for find/replace // data for find/replace
wxDialog* findDialog; wxDialog* find_dialog;
wxFindReplaceData findData; wxFindReplaceData find_data;
// --------------------------------------------------- : Panel managment // --------------------------------------------------- : Panel managment
......
...@@ -35,7 +35,7 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) { ...@@ -35,7 +35,7 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) {
} }
void SymbolControl::onChangeSymbol() { void SymbolControl::onChangeSymbol() {
selectedParts.clear(); selected_parts.clear();
switchEditor(new_shared2<SymbolSelectEditor>(this, false)); switchEditor(new_shared2<SymbolSelectEditor>(this, false));
Refresh(false); Refresh(false);
} }
...@@ -49,14 +49,14 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) { ...@@ -49,14 +49,14 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) {
switchEditor(new_shared2<SymbolSelectEditor>(this, true)); switchEditor(new_shared2<SymbolSelectEditor>(this, true));
break; break;
case ID_MODE_POINTS: case ID_MODE_POINTS:
if (selectedParts.size() == 1) { if (selected_parts.size() == 1) {
singleSelection = *selectedParts.begin(); single_selection = *selected_parts.begin();
switchEditor(new_shared2<SymbolPointEditor>(this, singleSelection)); switchEditor(new_shared2<SymbolPointEditor>(this, single_selection));
} }
break; break;
case ID_MODE_SHAPES: case ID_MODE_SHAPES:
if (!selectedParts.empty()) { if (!selected_parts.empty()) {
selectedParts.clear(); selected_parts.clear();
signalSelectionChange(); signalSelectionChange();
} }
switchEditor(new_shared1<SymbolBasicShapeEditor>(this)); switchEditor(new_shared1<SymbolBasicShapeEditor>(this));
...@@ -78,26 +78,26 @@ void SymbolControl::onUpdateSelection() { ...@@ -78,26 +78,26 @@ void SymbolControl::onUpdateSelection() {
switch(editor->modeToolId()) { switch(editor->modeToolId()) {
case ID_MODE_POINTS: case ID_MODE_POINTS:
// can only select a single part! // can only select a single part!
if (selectedParts.size() > 1) { if (selected_parts.size() > 1) {
SymbolPartP part = *selectedParts.begin(); SymbolPartP part = *selected_parts.begin();
selectedParts.clear(); selected_parts.clear();
selectedParts.insert(part); selected_parts.insert(part);
signalSelectionChange(); signalSelectionChange();
} else if (selectedParts.empty()) { } else if (selected_parts.empty()) {
selectedParts.insert(singleSelection); selected_parts.insert(single_selection);
signalSelectionChange(); signalSelectionChange();
} }
if (singleSelection != *selectedParts.begin()) { if (single_selection != *selected_parts.begin()) {
// begin editing another part // begin editing another part
singleSelection = *selectedParts.begin(); single_selection = *selected_parts.begin();
editor = new_shared2<SymbolPointEditor>(this, singleSelection); editor = new_shared2<SymbolPointEditor>(this, single_selection);
Refresh(false); Refresh(false);
} }
break; break;
case ID_MODE_SHAPES: case ID_MODE_SHAPES:
if (!selectedParts.empty()) { if (!selected_parts.empty()) {
// there can't be a selection // there can't be a selection
selectedParts.clear(); selected_parts.clear();
signalSelectionChange(); signalSelectionChange();
} }
break; break;
...@@ -108,15 +108,15 @@ void SymbolControl::onUpdateSelection() { ...@@ -108,15 +108,15 @@ void SymbolControl::onUpdateSelection() {
} }
void SymbolControl::selectPart(const SymbolPartP& part) { void SymbolControl::selectPart(const SymbolPartP& part) {
selectedParts.clear(); selected_parts.clear();
selectedParts.insert(part); selected_parts.insert(part);
switchEditor(new_shared2<SymbolSelectEditor>(this, false)); switchEditor(new_shared2<SymbolSelectEditor>(this, false));
signalSelectionChange(); signalSelectionChange();
} }
void SymbolControl::activatePart(const SymbolPartP& part) { void SymbolControl::activatePart(const SymbolPartP& part) {
selectedParts.clear(); selected_parts.clear();
selectedParts.insert(part); selected_parts.insert(part);
switchEditor(new_shared2<SymbolPointEditor>(this, part)); switchEditor(new_shared2<SymbolPointEditor>(this, part));
} }
...@@ -154,34 +154,34 @@ void SymbolControl::onPaint(wxPaintEvent& e) { ...@@ -154,34 +154,34 @@ void SymbolControl::onPaint(wxPaintEvent& e) {
void SymbolControl::onLeftDown(wxMouseEvent& ev) { void SymbolControl::onLeftDown(wxMouseEvent& ev) {
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY())); Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
if (editor) editor->onLeftDown(pos, ev); if (editor) editor->onLeftDown(pos, ev);
lastPos = pos; last_pos = pos;
ev.Skip(); // for focus ev.Skip(); // for focus
} }
void SymbolControl::onLeftUp(wxMouseEvent& ev) { void SymbolControl::onLeftUp(wxMouseEvent& ev) {
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY())); Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
if (editor) editor->onLeftUp(pos, ev); if (editor) editor->onLeftUp(pos, ev);
lastPos = pos; last_pos = pos;
} }
void SymbolControl::onLeftDClick(wxMouseEvent& ev) { void SymbolControl::onLeftDClick(wxMouseEvent& ev) {
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY())); Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
if (editor) editor->onLeftDClick(pos, ev); if (editor) editor->onLeftDClick(pos, ev);
lastPos = pos; last_pos = pos;
} }
void SymbolControl::onRightDown(wxMouseEvent& ev) { void SymbolControl::onRightDown(wxMouseEvent& ev) {
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY())); Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
if (editor) editor->onRightDown(pos, ev); if (editor) editor->onRightDown(pos, ev);
lastPos = pos; last_pos = pos;
} }
void SymbolControl::onMotion(wxMouseEvent& ev) { void SymbolControl::onMotion(wxMouseEvent& ev) {
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY())); Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
// Dragging something? // Dragging something?
if (ev.LeftIsDown()) { if (ev.LeftIsDown()) {
if (editor) editor->onMouseDrag(lastPos, pos, ev); if (editor) editor->onMouseDrag(last_pos, pos, ev);
} else { } else {
if (editor) editor->onMouseMove(lastPos, pos, ev); if (editor) editor->onMouseMove(last_pos, pos, ev);
} }
lastPos = pos; last_pos = pos;
} }
// Key events, just forward // Key events, just forward
...@@ -207,7 +207,7 @@ void SymbolControl::onUpdateUI(wxUpdateUIEvent& ev) { ...@@ -207,7 +207,7 @@ void SymbolControl::onUpdateUI(wxUpdateUIEvent& ev) {
ev.Check(editor->modeToolId() == ev.GetId()); ev.Check(editor->modeToolId() == ev.GetId());
if (ev.GetId() == ID_MODE_POINTS) { if (ev.GetId() == ID_MODE_POINTS) {
// can only edit points when a single part is selected <TODO?> // can only edit points when a single part is selected <TODO?>
ev.Enable(selectedParts.size() == 1); ev.Enable(selected_parts.size() == 1);
} }
break; break;
case ID_MODE_PAINT: case ID_MODE_PAINT:
......
...@@ -71,8 +71,8 @@ class SymbolControl : public wxControl, public SymbolViewer { ...@@ -71,8 +71,8 @@ class SymbolControl : public wxControl, public SymbolViewer {
public: public:
/// What parts are selected /// What parts are selected
set<SymbolPartP> selectedParts; set<SymbolPartP> selected_parts;
SymbolPartP singleSelection; SymbolPartP single_selection;
/// Parent window /// Parent window
SymbolWindow* parent; SymbolWindow* parent;
...@@ -82,7 +82,7 @@ class SymbolControl : public wxControl, public SymbolViewer { ...@@ -82,7 +82,7 @@ class SymbolControl : public wxControl, public SymbolViewer {
SymbolEditorBaseP editor; SymbolEditorBaseP editor;
/// Last mouse position /// Last mouse position
Vector2D lastPos; Vector2D last_pos;
// --------------------------------------------------- : Events // --------------------------------------------------- : Events
......
...@@ -20,12 +20,12 @@ SymbolPartList::SymbolPartList(Window* parent, int id, SymbolP symbol) ...@@ -20,12 +20,12 @@ SymbolPartList::SymbolPartList(Window* parent, int id, SymbolP symbol)
// Create image list // Create image list
wxImageList* images = new wxImageList(16,16); wxImageList* images = new wxImageList(16,16);
// NOTE: this is based on the order of the SymbolPartCombine enum! // NOTE: this is based on the order of the SymbolPartCombine enum!
images->Add(loadResourceImage(_("COMBINE_OR"))); images->Add(load_resource_image(_("COMBINE_OR")));
images->Add(loadResourceImage(_("COMBINE_SUB"))); images->Add(load_resource_image(_("COMBINE_SUB")));
images->Add(loadResourceImage(_("COMBINE_AND"))); images->Add(load_resource_image(_("COMBINE_AND")));
images->Add(loadResourceImage(_("COMBINE_XOR"))); images->Add(load_resource_image(_("COMBINE_XOR")));
images->Add(loadResourceImage(_("COMBINE_OVER"))); images->Add(load_resource_image(_("COMBINE_OVER")));
images->Add(loadResourceImage(_("COMBINE_BORDER"))); images->Add(load_resource_image(_("COMBINE_BORDER")));
AssignImageList(images, wxIMAGE_LIST_SMALL); AssignImageList(images, wxIMAGE_LIST_SMALL);
// create columns // create columns
InsertColumn(0, _("Name")); InsertColumn(0, _("Name"));
...@@ -74,7 +74,7 @@ void SymbolPartList::selectItem(long item) { ...@@ -74,7 +74,7 @@ void SymbolPartList::selectItem(long item) {
} }
} }
void SymbolPartList::getSelectedParts(set<SymbolPartP>& sel) { void SymbolPartList::getselected_parts(set<SymbolPartP>& sel) {
sel.clear(); sel.clear();
long count = GetItemCount(); long count = GetItemCount();
for (long i = 0 ; i < count ; ++ i) { for (long i = 0 ; i < count ; ++ i) {
......
...@@ -31,7 +31,7 @@ class SymbolPartList : public wxListCtrl, public SymbolView { ...@@ -31,7 +31,7 @@ class SymbolPartList : public wxListCtrl, public SymbolView {
inline SymbolPartP getSelection() const { return getPart(selected); } inline SymbolPartP getSelection() const { return getPart(selected); }
/// Get a set of selected parts /// Get a set of selected parts
void getSelectedParts(set<SymbolPartP>& sel); void getselected_parts(set<SymbolPartP>& sel);
/// Select the specified parts, and nothing else /// Select the specified parts, and nothing else
void selectParts(const set<SymbolPartP>& sel); void selectParts(const set<SymbolPartP>& sel);
......
This diff is collapsed.
...@@ -99,23 +99,23 @@ class SymbolPointEditor : public SymbolEditorBase { ...@@ -99,23 +99,23 @@ class SymbolPointEditor : public SymbolEditorBase {
}; };
Selection selection; Selection selection;
// points // points
set<ControlPointP> selectedPoints; set<ControlPointP> selected_points;
// handle // handle
SelectedHandle selectedHandle; SelectedHandle selected_handle;
// line // line
ControlPointP selectedLine1, selectedLine2; // selected the line between these points ControlPointP selected_line1, selected_line2; // selected the line between these points
double selectedLineT; // time on the line of the selection double selected_line_t; // time on the line of the selection
// Mouse feedback // Mouse feedback
Selection hovering; Selection hovering;
// handle // handle
SelectedHandle hoverHandle; // the handle currently under the cursor SelectedHandle hover_handle; // the handle currently under the cursor
// new point // new point
Vector2D newPoint; Vector2D new_point;
// line // line
ControlPointP hoverLine1, hoverLine2; // hovering on the line between these points ControlPointP hover_line_1, hover_line_2; // hovering on the line between these points
double hoverLineT; double hover_line_t;
int hoverLine1Idx; // index of hoverLine1 in the list of points int hover_line_1_idx; // index of hover_line_1 in the list of points
// Gui stock // Gui stock
wxBitmap background; wxBitmap background;
......
This diff is collapsed.
...@@ -105,7 +105,7 @@ class SymbolSelectEditor : public SymbolEditorBase { ...@@ -105,7 +105,7 @@ class SymbolSelectEditor : public SymbolEditorBase {
/// Find the first part at the given position /// Find the first part at the given position
SymbolPartP findPart(const Vector2D& pos); SymbolPartP findPart(const Vector2D& pos);
/// Update minV and maxV to be the bounding box of the selectedParts /// Update minV and maxV to be the bounding box of the selected_parts
/// Updates center to be the rotation center of the parts /// Updates center to be the rotation center of the parts
void updateBoundingBox(); void updateBoundingBox();
......
...@@ -103,7 +103,7 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolPart& part, HighlightStyle ...@@ -103,7 +103,7 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolPart& part, HighlightStyle
vector<wxPoint> points; vector<wxPoint> points;
size_t size = part.points.size(); size_t size = part.points.size();
for(size_t i = 0 ; i < size ; ++i) { for(size_t i = 0 ; i < size ; ++i) {
segmentSubdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points); segment_subdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points);
} }
// draw // draw
if (style == HIGHLIGHT_BORDER) { if (style == HIGHLIGHT_BORDER) {
...@@ -165,7 +165,7 @@ void SymbolViewer::drawSymbolPart(const SymbolPart& part, DC* border, DC* interi ...@@ -165,7 +165,7 @@ void SymbolViewer::drawSymbolPart(const SymbolPart& part, DC* border, DC* interi
vector<wxPoint> points; vector<wxPoint> points;
size_t size = part.points.size(); size_t size = part.points.size();
for(size_t i = 0 ; i < size ; ++i) { for(size_t i = 0 ; i < size ; ++i) {
segmentSubdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points); segment_subdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points);
} }
// draw border // draw border
if (border) { if (border) {
......
...@@ -218,7 +218,7 @@ void SymbolWindow::onUpdateUI(wxUpdateUIEvent& ev) { ...@@ -218,7 +218,7 @@ void SymbolWindow::onUpdateUI(wxUpdateUIEvent& ev) {
void SymbolWindow::onSelectFromList(wxListEvent& ev) { void SymbolWindow::onSelectFromList(wxListEvent& ev) {
if (inSelectionEvent) return ; if (inSelectionEvent) return ;
inSelectionEvent = true; inSelectionEvent = true;
parts->getSelectedParts(control->selectedParts); parts->getselected_parts(control->selected_parts);
control->onUpdateSelection(); control->onUpdateSelection();
inSelectionEvent = false; inSelectionEvent = false;
} }
...@@ -229,7 +229,7 @@ void SymbolWindow::onActivateFromList(wxListEvent& ev) { ...@@ -229,7 +229,7 @@ void SymbolWindow::onActivateFromList(wxListEvent& ev) {
void SymbolWindow::onSelectFromControl() { void SymbolWindow::onSelectFromControl() {
if (inSelectionEvent) return ; if (inSelectionEvent) return ;
inSelectionEvent = true; inSelectionEvent = true;
parts->selectParts(control->selectedParts); parts->selectParts(control->selected_parts);
inSelectionEvent = false; inSelectionEvent = false;
} }
......
...@@ -22,7 +22,7 @@ void clearDC(DC& dc, const wxBrush& brush) { ...@@ -22,7 +22,7 @@ void clearDC(DC& dc, const wxBrush& brush) {
// ----------------------------------------------------------------------------- : Image related // ----------------------------------------------------------------------------- : Image related
Image loadResourceImage(String name) { Image load_resource_image(String name) {
#ifdef __WXMSW__ #ifdef __WXMSW__
// Load resource // Load resource
// based on wxLoadUserResource // based on wxLoadUserResource
......
...@@ -23,7 +23,7 @@ void clearDC(DC& dc, const wxBrush& brush = *wxBLACK_BRUSH); ...@@ -23,7 +23,7 @@ void clearDC(DC& dc, const wxBrush& brush = *wxBLACK_BRUSH);
// ----------------------------------------------------------------------------- : Resource related // ----------------------------------------------------------------------------- : Resource related
/// Load an image from a resource /// Load an image from a resource
Image loadResourceImage(String name); Image load_resource_image(String name);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;__WINDOWS__;__WXMSW__;DEBUG=1;__WXDEBUG__;__WIN95__;__WIN32__;WINVER=0x0400;STRICT;UNICODE;_UNICODE;wxUSE_UNICODE" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;__WINDOWS__;__WXMSW__;DEBUG=1;__WXDEBUG__;__WIN95__;__WIN32__;WINVER=0x0400;STRICT;UNICODE;_UNICODE;wxUSE_UNICODE"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="5" RuntimeLibrary="3"
BufferSecurityCheck="TRUE" BufferSecurityCheck="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
......
...@@ -63,8 +63,8 @@ class TokenIterator { ...@@ -63,8 +63,8 @@ class TokenIterator {
private: private:
String input; String input;
size_t pos; size_t pos;
vector<Token> buffer; // buffer of unread tokens, front() = current vector<Token> buffer; // buffer of unread tokens, front() = current
stack<bool> openBraces; // braces we entered, true if the brace was from a smart string escape stack<bool> open_braces; // braces we entered, true if the brace was from a smart string escape
/// Read the next token, and add it to the buffer /// Read the next token, and add it to the buffer
void addToken(); void addToken();
/// Read the next token which is a string (after the opening ") /// Read the next token which is a string (after the opening ")
...@@ -125,7 +125,7 @@ void TokenIterator::addToken() { ...@@ -125,7 +125,7 @@ void TokenIterator::addToken() {
// name // name
size_t start = pos - 1; size_t start = pos - 1;
while (pos < input.size() && isAlnum_(input.GetChar(pos))) ++pos; while (pos < input.size() && isAlnum_(input.GetChar(pos))) ++pos;
Token t = {TOK_NAME, cannocialNameForm(input.substr(start, pos-start)) }; // convert name to cannocial form Token t = {TOK_NAME, cannocial_name_form(input.substr(start, pos-start)) }; // convert name to cannocial form
buffer.push_back(t); buffer.push_back(t);
} else if (isDigit(c)) { } else if (isDigit(c)) {
// number // number
...@@ -151,21 +151,21 @@ void TokenIterator::addToken() { ...@@ -151,21 +151,21 @@ void TokenIterator::addToken() {
} else if (c==_('"')) { } else if (c==_('"')) {
// string // string
addStringToken(); addStringToken();
} else if (c == _('}') && !openBraces.empty() && openBraces.top()) { } else if (c == _('}') && !open_braces.empty() && open_braces.top()) {
// closing smart string, resume to string parsing // closing smart string, resume to string parsing
// "a{e}b" --> "a" "{ e }" "b" // "a{e}b" --> "a" "{ e }" "b"
openBraces.pop(); open_braces.pop();
Token t2 = {TOK_RPAREN, _("}\"")}; Token t2 = {TOK_RPAREN, _("}\"")};
buffer.push_back(t2); buffer.push_back(t2);
addStringToken(); addStringToken();
} else if (isLparen(c)) { } else if (isLparen(c)) {
// paranthesis/brace // paranthesis/brace
openBraces.push(false); open_braces.push(false);
Token t = { TOK_LPAREN, String(1,c) }; Token t = { TOK_LPAREN, String(1,c) };
buffer.push_back(t); buffer.push_back(t);
} else if (isRparen(c)) { } else if (isRparen(c)) {
// paranthesis/brace // paranthesis/brace
if (!openBraces.empty()) openBraces.pop(); if (!open_braces.empty()) open_braces.pop();
Token t = { TOK_RPAREN, String(1,c) }; Token t = { TOK_RPAREN, String(1,c) };
buffer.push_back(t); buffer.push_back(t);
} else if(c==_('#')) { } else if(c==_('#')) {
...@@ -197,7 +197,7 @@ void TokenIterator::addStringToken() { ...@@ -197,7 +197,7 @@ void TokenIterator::addStringToken() {
// smart string // smart string
// "a{e}b" --> "a" "{ e }" "b" // "a{e}b" --> "a" "{ e }" "b"
buffer.push_back(t); buffer.push_back(t);
openBraces.push(true); open_braces.push(true);
Token t2 = {TOK_LPAREN, _("\"{")}; Token t2 = {TOK_LPAREN, _("\"{")};
buffer.push_back(t2); buffer.push_back(t2);
return; return;
......
...@@ -16,77 +16,77 @@ DECLARE_TYPEOF_COLLECTION(Action*); ...@@ -16,77 +16,77 @@ DECLARE_TYPEOF_COLLECTION(Action*);
DECLARE_TYPEOF_COLLECTION(ActionListener*); DECLARE_TYPEOF_COLLECTION(ActionListener*);
ActionStack::ActionStack() ActionStack::ActionStack()
: savePoint(nullptr) : save_point(nullptr)
{} {}
ActionStack::~ActionStack() { ActionStack::~ActionStack() {
// we own the actions, delete them // we own the actions, delete them
FOR_EACH(a, undoActions) delete a; FOR_EACH(a, undo_actions) delete a;
FOR_EACH(a, redoActions) delete a; FOR_EACH(a, redo_actions) delete a;
} }
void ActionStack::add(Action* action, bool allowMerge) { void ActionStack::add(Action* action, bool allow_merge) {
if (!action) return; // no action if (!action) return; // no action
action->perform(false); // TODO: delete action if perform throws action->perform(false); // TODO: delete action if perform throws
redoActions.clear(); redo_actions.clear();
tellListeners(*action); tellListeners(*action);
// try to merge? // try to merge?
if (allowMerge && !undoActions.empty() && undoActions.back()->merge(action)) { if (allow_merge && !undo_actions.empty() && undo_actions.back()->merge(action)) {
// merged with top undo action // merged with top undo action
delete action; delete action;
} else { } else {
undoActions.push_back(action); undo_actions.push_back(action);
} }
} }
void ActionStack::undo() { void ActionStack::undo() {
assert(canUndo()); assert(canUndo());
Action* action = undoActions.back(); Action* action = undo_actions.back();
action->perform(true); action->perform(true);
// move to redo stack // move to redo stack
undoActions.pop_back(); undo_actions.pop_back();
redoActions.push_back(action); redo_actions.push_back(action);
} }
void ActionStack::redo() { void ActionStack::redo() {
assert(canRedo()); assert(canRedo());
Action* action = redoActions.back(); Action* action = redo_actions.back();
action->perform(false); action->perform(false);
// move to undo stack // move to undo stack
redoActions.pop_back(); redo_actions.pop_back();
undoActions.push_back(action); undo_actions.push_back(action);
} }
bool ActionStack::canUndo() const { bool ActionStack::canUndo() const {
return !undoActions.empty(); return !undo_actions.empty();
} }
bool ActionStack::canRedo() const { bool ActionStack::canRedo() const {
return !redoActions.empty(); return !redo_actions.empty();
} }
String ActionStack::undoName() const { String ActionStack::undoName() const {
if (canUndo()) { if (canUndo()) {
return _("Undo ") + capitalize(undoActions.back()->getName(true)); return _("Undo ") + capitalize(undo_actions.back()->getName(true));
} else { } else {
return _("Undo"); return _("Undo");
} }
} }
String ActionStack::redoName() const { String ActionStack::redoName() const {
if (canRedo()) { if (canRedo()) {
return _("Redo ") + capitalize(redoActions.back()->getName(false)); return _("Redo ") + capitalize(redo_actions.back()->getName(false));
} else { } else {
return _("Redo"); return _("Redo");
} }
} }
bool ActionStack::atSavePoint() const { bool ActionStack::atSavePoint() const {
return (undoActions.empty() && savePoint == nullptr) return (undo_actions.empty() && save_point == nullptr)
|| (undoActions.back() == savePoint); || (undo_actions.back() == save_point);
} }
void ActionStack::setSavePoint() { void ActionStack::setSavePoint() {
if (undoActions.empty()) { if (undo_actions.empty()) {
savePoint = nullptr; save_point = nullptr;
} else { } else {
savePoint = undoActions.back(); save_point = undo_actions.back();
} }
} }
......
...@@ -23,17 +23,17 @@ class Action { ...@@ -23,17 +23,17 @@ class Action {
virtual ~Action() {}; virtual ~Action() {};
/// Name of the action, for use in strings like "Undo <name>" /// Name of the action, for use in strings like "Undo <name>"
virtual String getName(bool toUndo) const = 0; virtual String getName(bool to_undo) const = 0;
/// Perform the action /// Perform the action
/** @param toUndo if true, undo the action instead of doing it /** @param to_undo if true, undo the action instead of doing it
* *
* Must be implemented in derived class. * Must be implemented in derived class.
* *
* Perform will only ever be called alternatingly with toUndo = true/false, * Perform will only ever be called alternatingly with to_undo = true/false,
* the first time with toUndo = false * the first time with to_undo = false
*/ */
virtual void perform(bool toUndo) = 0; virtual void perform(bool to_undo) = 0;
/// Try to merge another action to the end of this action. /// Try to merge another action to the end of this action.
/** Either: return false and do nothing /** Either: return false and do nothing
...@@ -103,12 +103,12 @@ class ActionStack { ...@@ -103,12 +103,12 @@ class ActionStack {
private: private:
/// Actions to be undone /// Actions to be undone
/// Owns the action objects! /// Owns the action objects!
vector<Action*> undoActions; vector<Action*> undo_actions;
/// Actions to be redone /// Actions to be redone
/// Owns the action objects! /// Owns the action objects!
vector<Action*> redoActions; vector<Action*> redo_actions;
/// Point at which the file was saved, corresponds to the top of the undo stack at that point /// Point at which the file was saved, corresponds to the top of the undo stack at that point
Action* savePoint; Action* save_point;
/// Objects that are listening to actions /// Objects that are listening to actions
vector<ActionListener*> listeners; vector<ActionListener*> listeners;
}; };
......
...@@ -13,19 +13,19 @@ ...@@ -13,19 +13,19 @@
// ----------------------------------------------------------------------------- : Reader // ----------------------------------------------------------------------------- : Reader
Reader::Reader(const InputStreamP& input, String filename) Reader::Reader(const InputStreamP& input, String filename)
: input(input), filename(filename), lineNumber(0) : input(input), filename(filename), line_number(0)
, indent(0), expectedIndent(0), justOpened(false) , indent(0), expected_indent(0), just_opened(false)
, stream(*input) , stream(*input)
{ {
moveNext(); moveNext();
} }
bool Reader::enterBlock(const Char* name) { bool Reader::enterBlock(const Char* name) {
if (justOpened) moveNext(); // on the key of the parent block, first move inside it if (just_opened) moveNext(); // on the key of the parent block, first move inside it
if (indent != expectedIndent) return false; // not enough indentation if (indent != expected_indent) return false; // not enough indentation
if (name == key) { if (name == key) {
justOpened = true; just_opened = true;
expectedIndent += 1; // the indent inside the block must be at least this much expected_indent += 1; // the indent inside the block must be at least this much
return true; return true;
} else { } else {
return false; return false;
...@@ -33,21 +33,21 @@ bool Reader::enterBlock(const Char* name) { ...@@ -33,21 +33,21 @@ bool Reader::enterBlock(const Char* name) {
} }
void Reader::exitBlock() { void Reader::exitBlock() {
assert(expectedIndent > 0); assert(expected_indent > 0);
expectedIndent -= 1; expected_indent -= 1;
multiLineStr.clear(); multi_line_str.clear();
if (justOpened) moveNext(); // leave this key if (just_opened) moveNext(); // leave this key
// Dump the remainder of the block // Dump the remainder of the block
// TODO: issue warnings? // TODO: issue warnings?
while (indent > expectedIndent) { while (indent > expected_indent) {
moveNext(); moveNext();
} }
} }
void Reader::moveNext() { void Reader::moveNext() {
justOpened = false; just_opened = false;
key.clear(); key.clear();
multiLineStr.clear(); multi_line_str.clear();
indent = -1; // if no line is read it never has the expected indentation indent = -1; // if no line is read it never has the expected indentation
// repeat until we have a good line // repeat until we have a good line
while (key.empty() && !input->Eof()) { while (key.empty() && !input->Eof()) {
...@@ -55,7 +55,7 @@ void Reader::moveNext() { ...@@ -55,7 +55,7 @@ void Reader::moveNext() {
} }
// did we reach the end of the file? // did we reach the end of the file?
if (key.empty() && input->Eof()) { if (key.empty() && input->Eof()) {
lineNumber += 1; line_number += 1;
indent = -1; indent = -1;
} }
} }
...@@ -70,10 +70,10 @@ void Reader::readLine() { ...@@ -70,10 +70,10 @@ void Reader::readLine() {
} }
// read key / value // read key / value
size_t pos = line.find_first_of(_(':'), indent); size_t pos = line.find_first_of(_(':'), indent);
key = trim(line.substr(indent, pos - indent)); key = cannocial_name_form(trim(line.substr(indent, pos - indent)));
value = pos == String::npos ? _("") : trimLeft(line.substr(pos+1)); value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
// we read a line // we read a line
lineNumber += 1; line_number += 1;
// was it a comment? // was it a comment?
if (!key.empty() && key.GetChar(0) == _('#')) { if (!key.empty() && key.GetChar(0) == _('#')) {
key.clear(); key.clear();
...@@ -83,25 +83,25 @@ void Reader::readLine() { ...@@ -83,25 +83,25 @@ void Reader::readLine() {
// ----------------------------------------------------------------------------- : Handling basic types // ----------------------------------------------------------------------------- : Handling basic types
template <> void Reader::handle(String& s) { template <> void Reader::handle(String& s) {
if (!multiLineStr.empty()) { if (!multi_line_str.empty()) {
s = multiLineStr; s = multi_line_str;
} else if (value.empty()) { } else if (value.empty()) {
// a multiline string // a multiline string
bool first = true; bool first = true;
// read all lines that are indented enough // read all lines that are indented enough
readLine(); readLine();
while (indent >= expectedIndent) { while (indent >= expected_indent) {
if (!first) value += '\n'; if (!first) value += '\n';
first = false; first = false;
multiLineStr += line.substr(expectedIndent); // strip expected indent multi_line_str += line.substr(expected_indent); // strip expected indent
readLine(); readLine();
} }
// moveNext(), but without emptying multiLineStr // moveNext(), but without emptying multiLineStr
justOpened = false; just_opened = false;
while (key.empty() && !input->Eof()) { while (key.empty() && !input->Eof()) {
readLine(); readLine();
} }
s = multiLineStr; s = multi_line_str;
} else { } else {
s = value; s = value;
} }
......
...@@ -64,18 +64,18 @@ class Reader { ...@@ -64,18 +64,18 @@ class Reader {
/// The key and value of the last line we read /// The key and value of the last line we read
String key, value; String key, value;
/// A string spanning multiple lines /// A string spanning multiple lines
String multiLineStr; String multi_line_str;
/// Indentation of the last line we read /// Indentation of the last line we read
int indent; int indent;
/// Indentation of the block we are in /// Indentation of the block we are in
int expectedIndent; int expected_indent;
/// Did we just open a block (i.e. not read any more lines of it)? /// Did we just open a block (i.e. not read any more lines of it)?
bool justOpened; bool just_opened;
/// Filename for error messages /// Filename for error messages
String filename; String filename;
/// Line number for error messages /// Line number for error messages
UInt lineNumber; UInt line_number;
/// Input stream we are reading from /// Input stream we are reading from
InputStreamP input; InputStreamP input;
/// Text stream wrapping the input stream /// Text stream wrapping the input stream
......
...@@ -16,7 +16,7 @@ Writer::Writer(const OutputStreamP& output) ...@@ -16,7 +16,7 @@ Writer::Writer(const OutputStreamP& output)
: output(output) : output(output)
, stream(*output) , stream(*output)
, indentation(0) , indentation(0)
, justOpened(false) , just_opened(false)
{ {
stream.WriteString(BYTE_ORDER_MARK); stream.WriteString(BYTE_ORDER_MARK);
} }
...@@ -24,25 +24,27 @@ Writer::Writer(const OutputStreamP& output) ...@@ -24,25 +24,27 @@ Writer::Writer(const OutputStreamP& output)
void Writer::enterBlock(const Char* name) { void Writer::enterBlock(const Char* name) {
// indenting into a sub-block? // indenting into a sub-block?
if (justOpened) { if (just_opened) {
writeKey(); writeKey();
stream.WriteString(_(":\n")); stream.WriteString(_(":\n"));
} }
// don't write the key yet // don't write the key yet
indentation += 1; indentation += 1;
openedKey = name; opened_key = name;
justOpened = true; just_opened = true;
} }
void Writer::exitBlock() { void Writer::exitBlock() {
assert(indentation > 0); assert(indentation > 0);
indentation -= 1; indentation -= 1;
justOpened = false; just_opened = false;
} }
void Writer::writeKey() { void Writer::writeKey() {
writeIndentation(); writeIndentation();
writeUTF8(stream, openedKey); // Use ' ' instead of '_' because it is more human readable
FOR_EACH(c, opened_key) if (c == _('_')) c = _(' ');
writeUTF8(stream, opened_key);
} }
void Writer::writeIndentation() { void Writer::writeIndentation() {
for(int i = 1 ; i < indentation ; ++i) { for(int i = 1 ; i < indentation ; ++i) {
...@@ -53,7 +55,7 @@ void Writer::writeIndentation() { ...@@ -53,7 +55,7 @@ void Writer::writeIndentation() {
// ----------------------------------------------------------------------------- : Handling basic types // ----------------------------------------------------------------------------- : Handling basic types
void Writer::handle(const String& value) { void Writer::handle(const String& value) {
if (!justOpened) { if (!just_opened) {
throw InternalError(_("Can only write a value in a key that was just opened")); throw InternalError(_("Can only write a value in a key that was just opened"));
} }
// write indentation and key // write indentation and key
...@@ -86,7 +88,7 @@ void Writer::handle(const String& value) { ...@@ -86,7 +88,7 @@ void Writer::handle(const String& value) {
writeUTF8(stream, value); writeUTF8(stream, value);
} }
stream.PutChar(_('\n')); stream.PutChar(_('\n'));
justOpened = false; just_opened = false;
} }
template <> void Writer::handle(const int& value) { template <> void Writer::handle(const int& value) {
......
...@@ -53,9 +53,9 @@ class Writer { ...@@ -53,9 +53,9 @@ class Writer {
/// Indentation of the current block /// Indentation of the current block
int indentation; int indentation;
/// Did we just open a block (i.e. not written any lines of it)? /// Did we just open a block (i.e. not written any lines of it)?
bool justOpened; bool just_opened;
/// Last key opened /// Last key opened
String openedKey; String opened_key;
/// Output stream we are writing to /// Output stream we are writing to
OutputStreamP output; OutputStreamP output;
...@@ -69,7 +69,7 @@ class Writer { ...@@ -69,7 +69,7 @@ class Writer {
/// Leave the block we are in /// Leave the block we are in
void exitBlock(); void exitBlock();
/// Write the openedKey and the required indentation /// Write the opened_key and the required indentation
void writeKey(); void writeKey();
/// Output some taps to represent the indentation level /// Output some taps to represent the indentation level
void writeIndentation(); void writeIndentation();
......
...@@ -52,7 +52,7 @@ String trim(const String& s){ ...@@ -52,7 +52,7 @@ String trim(const String& s){
} }
} }
String trimLeft(const String& s) { String trim_left(const String& s) {
size_t start = s.find_first_not_of(_(' ')); size_t start = s.find_first_not_of(_(' '));
if (start == String::npos) { if (start == String::npos) {
return String(); return String();
...@@ -63,7 +63,7 @@ String trimLeft(const String& s) { ...@@ -63,7 +63,7 @@ String trimLeft(const String& s) {
// ----------------------------------------------------------------------------- : Words // ----------------------------------------------------------------------------- : Words
String lastWord(const String& s) { String last_word(const String& s) {
size_t endLastWord = s.find_last_not_of(_(' ')); size_t endLastWord = s.find_last_not_of(_(' '));
size_t startLastWord = s.find_last_of( _(' '), endLastWord); size_t startLastWord = s.find_last_of( _(' '), endLastWord);
if (endLastWord == String::npos) { if (endLastWord == String::npos) {
...@@ -75,7 +75,7 @@ String lastWord(const String& s) { ...@@ -75,7 +75,7 @@ String lastWord(const String& s) {
} }
} }
String stripLastWord(const String& s) { String strip_last_word(const String& s) {
size_t endLastWord = s.find_last_not_of(_(' ')); size_t endLastWord = s.find_last_not_of(_(' '));
size_t startLastWord = s.find_last_of(_(' '), endLastWord); size_t startLastWord = s.find_last_of(_(' '), endLastWord);
if (endLastWord == String::npos || startLastWord == String::npos) { if (endLastWord == String::npos || startLastWord == String::npos) {
...@@ -116,3 +116,20 @@ String capitalize(const String& s) { ...@@ -116,3 +116,20 @@ String capitalize(const String& s) {
} }
return result; return result;
} }
String cannocial_name_form(const String& str) {
String ret;
ret.reserve(str.size());
bool leading = true;
FOR_EACH_CONST(c, str) {
if ((c == _('_') || c == _(' ')) && !leading) {
ret += _('_');
} else if (isAlnum(c)) {
ret += toLower(c);
leading = false;
} else {
// ignore non alpha numeric
}
}
return ret;
}
...@@ -52,9 +52,9 @@ typedef IF_UNICODE(wchar_t, char) Char; ...@@ -52,9 +52,9 @@ typedef IF_UNICODE(wchar_t, char) Char;
String decodeUTF8BOM(const String& s); String decodeUTF8BOM(const String& s);
/// UTF8 Byte order mark for writing at the start of files /// UTF8 Byte order mark for writing at the start of files
/** In non-unicode builds it is UTF8 encoded \xFEFF /** In non-unicode builds it is UTF8 encoded \xFEFF.
* In unicode builds it is a normal \xFEFF * In unicode builds it is a normal \xFEFF.
*/ */
const Char BYTE_ORDER_MARK[] = IF_UNICODE(L"\xFEFF", "\xEF\xBB\xBF"); const Char BYTE_ORDER_MARK[] = IF_UNICODE(L"\xFEFF", "\xEF\xBB\xBF");
/// Writes a string to an output stream, encoded as UTF8 /// Writes a string to an output stream, encoded as UTF8
...@@ -79,30 +79,32 @@ inline Char toLower(Char c) { return IF_UNICODE( towlower(c) , tolower(c) ); } ...@@ -79,30 +79,32 @@ inline Char toLower(Char c) { return IF_UNICODE( towlower(c) , tolower(c) ); }
String trim(const String&); String trim(const String&);
/// Remove whitespace from the start of a string /// Remove whitespace from the start of a string
String trimLeft(const String&); String trim_left(const String&);
// ----------------------------------------------------------------------------- : Words // ----------------------------------------------------------------------------- : Words
/// Returns the last word in a string /// Returns the last word in a string
String lastWord(const String&); String last_word(const String&);
/// Remove the last word from a string, leaves whitespace before that word /// Remove the last word from a string, leaves whitespace before that word
String stripLastWord(const String&); String strip_last_word(const String&);
// ----------------------------------------------------------------------------- : Caseing // ----------------------------------------------------------------------------- : Caseing
/// Make each word in a string start with an upper case character. /// Make each word in a string start with an upper case character.
/// for use in menus /** for use in menus */
String capitalize(const String&); String capitalize(const String&);
/// Make the first word in a string start with an upper case character. /// Make the first word in a string start with an upper case character.
/// for use in dialogs /** for use in dialogs */
String capitalizeSentence(const String&); String capitalize_sentence(const String&);
/// Convert a field name to cannocial form: lower case and ' ' instead of '_' /// Convert a field name to cannocial form
/// non alphanumeric characters are ignored /** - lower case and '_' instead of ' '.
/// "camalCase" is converted to words "camel case" * - non alphanumeric characters are droped
String cannocialNameForm(const String&); * - "camalCase" is converted to words "camel case" (TODO)
*/
String cannocial_name_form(const String&);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_UTIL_VERSION
#define HEADER_UTIL_VERSION
/** @file util/version.hpp
*
* @brief Utility functions related to version numbers.
* This header also stores the MSE version number.
*/
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
// ----------------------------------------------------------------------------- : Version datatype
/// A version number
struct Version {
public:
Version() : version(0) {}
Version(UInt version) : version(version) {}
bool operator < (Version v) { return version < v.versionSuffix; }
/// Convert a version number to a string
String toString();
/// Convert a string to a version number
static Version fromString(UInt version);
private:
UInt version; ///< Version number encoded as aabbcc, where a=major, b=minor, c=revision
};
// ----------------------------------------------------------------------------- : Versions
/// The verwsion number of MSE
const Version app_version = 000300; // 0.3.0
const Char* version_suffix = _(" (beta)");
/// File version, usually the same as program version,
/** When no files are changed the file version is not incremented
* Changes:
* 0.2.0 : start of version numbering practice
* 0.2.2 : _("include file")
* 0.2.6 : fix in settings loading
* 0.2.7 : new tag system, different style of close tags
* 0.3.0 : port of code to C++
*/
const Version file_version = 000300; // 0.3.0
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -214,7 +214,7 @@ COLLABORATION_GRAPH = NO ...@@ -214,7 +214,7 @@ COLLABORATION_GRAPH = NO
GROUP_GRAPHS = YES GROUP_GRAPHS = YES
UML_LOOK = NO UML_LOOK = NO
TEMPLATE_RELATIONS = YES TEMPLATE_RELATIONS = YES
INCLUDE_GRAPH = YES INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = YES INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO CALL_GRAPH = NO
CALLER_GRAPH = NO CALLER_GRAPH = NO
......
/** @page coding_conventions Coding conventions
MSE uses the following coding style:
@code
/// Doxygen documentation
class ClassName {
public:
void someMemberFunction();
private:
int some_member; ///< postfix doxygen documentation
};
void a_global_function();
enum MyEnumeration
{ MY_SOMETHING
, MY_SOMETHING_ELSE
};
@endcode
The rules are:
- Classes use CaptializationForEachWord
- Member functions use camelCase
- Data members and globals use lower_case_with_underscores
- Constants (enumeration values) and macros are UPPER_CASE_WITH_UNDERSCORES
The exceptions to this are:
- wxWidgets functions, which LookLikeThis
- wxWidget classes, which look like wxSomeClass
- C++ standard library and boost, lower_case for everything
- Person names, in particular deCasteljau
- Class names in function names, in particular clearDC
*/
/** \mainpage /** @mainpage
This is the documentation of the Magic Set Editor (MSE) source code, automatically generated using doxygen. This is the documentation of the Magic Set Editor (MSE) source code, automatically generated using doxygen.
<h2>Structure</h2> Before starting with the source code, you should take a look at the following:
- \subpage structure "Structure of the MSE source code"
The MSE source code is subdivided into several directories, with the following meaning: - \subpage dependencies "Libraries and dependencies"
- util: Utility functions and classes, stuff that would work equally well in another project - \subpage coding_conventions "Coding conventions"
- gfx: Graphics related functions, again mostly independent of MSE. - \subpage tricks "Tricks used by MSE"
This directory contains algorithms for image blending, scaling, and bezier curve functions.
- data: Data structures, like sets, cards, symbols, etc.
These data structures are documented in the <a href="http://magicseteditor.sourceforge.net/extending">'Extending MSE'</a> section of the official documentation.
- data/action: Actions that can be applied to those data structures.
- gui: Graphical User Interface
- resource: Resource files used (icons, cursors, etc.)
@page structure Structure of the MSE source code
<h2>Libraries/dependencies</h2> The MSE source code is subdivided into several directories, with the following meaning:
- <tt>util</tt>: Utility functions and classes, stuff that would work equally well in another project
- <tt>util/io</tt>: Classes related to input and output
- <tt>gfx</tt>: Graphics related functions, again mostly independent of MSE.
This directory contains algorithms for image blending, scaling, and bezier curve functions.
- <tt>data</tt>: Data structures, like sets, cards, symbols, etc.
These data structures are documented in the <a href="http://magicseteditor.sourceforge.net/extending">'Extending MSE'</a> section of the official documentation.
- <tt>data/action</tt>: Actions that can be applied to those data structures.
- <tt>data/field</tt>: Data types for fields, values and styles. One source file per type.
- <tt>data/format</tt>: File formats and import/export stuff.
- <tt>script</tt>: The scripting system.
- <tt>gui</tt>: Graphical User Interface
- <tt>set</tt>: SetWindow related
- <tt>symbol</tt>: SymbolWindow related
- <tt>resource</tt>: Resource files used (icons, cursors, etc.)
See <a href="dirs.html">the directory list</a> for details.
@page dependencies Libraries and dependencies
MSE depends on the following libraries: MSE depends on the following libraries:
- <a href="http://wxwidgets.org">wxWidgets</a> for the GUI. - <a href="http://wxwidgets.org">wxWidgets</a> for the GUI.
...@@ -25,99 +39,4 @@ Additional tools (not needed for building MSE) also depend on: ...@@ -25,99 +39,4 @@ Additional tools (not needed for building MSE) also depend on:
- <a href="http://doxygen.org">doxygen</a> for generating the documentation. - <a href="http://doxygen.org">doxygen</a> for generating the documentation.
- Perl for small utility scripts - Perl for small utility scripts
<h2>Coding style</h2>
MSE uses the following coding style:
@code
class ClassName {
public:
void someFunction();
private:
int someMember;
};
@endcode
The exception to this rule are wxWidgets functions, which LookLikeThis; and classes, which look like wxSomeClass.
As well as standard library functions.
<h2>Macro and template tricks</h2>
The source code uses several macro/preprocessor and template tricks to make the code more readable.
<h3>Smart pointers</h3>
MSE makes extensive use of boost::shared_ptr. To make the code more readable there are typedefs for these pointer types, using a suffix P.
These are defined using a macro:
@code
DECLARE_POINTER_TYPE(MyClass);
MyClassP someObject; // the same as boost::shared_ptr<MyClass> someObject
@endcode
To create new shared_ptrs the function new_shared# can be used (where # is the number of arguments):
@code
MyClassP someObject;
someObject = new_shared2<MyClass>(arg1, arg2);
@endcode
Implemented in: util/smart_ptr.hpp
<h3>Iterating</h3>
To iterate over containers the FOR_EACH macro is used:
@code
vector<CardP> cards;
FOR_EACH(card, cards) {
doSomething(card);
}
@endcode
Is equivalent to:
@code
vector<CardP> cards;
for(vector<CardP>::iterator it = cards.begin() ; it != cards.end() ; ++it) {
CardP& card = *it;
doSomething(card);
}
@endcode
The iterators are completely hidden!
There are several veriations to this macro, for using const iterators (FOR_EACH_CONST), iterating in reverse (FOR_EACH_REVERSE),
for iterating over two collections in parallel (FOR_EACH_2), and for getting access to the iterator (FOR_EACH_IT).
Each of these macros require that the collection type has been declared using:
@code
DECLARE_COLLECTION_TYPE(CardP);
@endcode
This allows the calling of TYPEOF(cards) to evaluate to vector<CardP>.
Implemented in: util/for_each.hpp
<h3>Reflection</h3>
The io (input/output) system is based on reflection.
For a class to support reflection the following must be declared:
@code
class SomeClass {
int member1, member2;
DECLARE_REFLECTION();
};
@endcode
Then in a source file the members of the class have to be specified:
@code
IMPLEMENT_REFLECTION(SomeClass) {
REFLECT(member1);
REFLECT_N("another_name", member2);
}
@endcode
Simlairly for enumerations (a declaration is not necessary):
@code
IMPLEMENT_REFLECTION_ENUM(MyEnum) {
VALUE(value_of_enum_1); // the default value
VALUE(value_of_enum_2);
}
@endcode
Implemented in: util/reflect.hpp
*/ */
\ No newline at end of file
/** @page tricks Macro and template tricks
The source code uses several macro/preprocessor and template tricks to make the code more readable.
<h2>Smart pointers</h2>
MSE makes extensive use of boost::shared_ptr. To make the code more readable there are typedefs for these pointer types, using a suffix P.
These are defined using a macro:
@code
DECLARE_POINTER_TYPE(MyClass);
MyClassP someObject; // the same as boost::shared_ptr<MyClass> someObject
@endcode
To create new shared_ptrs the function new_shared# can be used (where # is the number of arguments):
@code
MyClassP someObject;
someObject = new_shared2<MyClass>(arg1, arg2);
@endcode
Implemented in: util/smart_ptr.hpp
<h2>Iterating</h2>
To iterate over containers the FOR_EACH macro is used:
@code
vector<CardP> cards;
FOR_EACH(card, cards) {
doSomething(card);
}
@endcode
Is equivalent to:
@code
vector<CardP> cards;
for(vector<CardP>::iterator it = cards.begin() ; it != cards.end() ; ++it) {
CardP& card = *it;
doSomething(card);
}
@endcode
The iterators are completely hidden!
There are several veriations to this macro, for using const iterators (FOR_EACH_CONST), iterating in reverse (FOR_EACH_REVERSE),
for iterating over two collections in parallel (FOR_EACH_2), and for getting access to the iterator (FOR_EACH_IT).
Each of these macros require that the collection type has been declared using:
@code
DECLARE_COLLECTION_TYPE(CardP);
@endcode
This allows the calling of TYPEOF(cards) to evaluate to vector<CardP>.
Implemented in: util/for_each.hpp
<h2>Reflection</h2>
The io (input/output) system is based on reflection.
For a class to support reflection the following must be declared:
@code
class SomeClass {
int member1, member2;
DECLARE_REFLECTION();
};
@endcode
Then in a source file the members of the class have to be specified:
@code
IMPLEMENT_REFLECTION(SomeClass) {
REFLECT(member1);
REFLECT_N("another_name", member2);
}
@endcode
Simlairly for enumerations (a declaration is not necessary):
@code
IMPLEMENT_REFLECTION_ENUM(MyEnum) {
VALUE_N("value1", MY_VALUE1); // the first is the default value
VALUE_N("value2", MY_VALUE2);
}
@endcode
Reflection is used by the following classes:
- Reader
- Writer
- GetMember
Implemented in: util/reflect.hpp
*/
\ No newline at end of file
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