implemented symbol font

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@81 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-20 14:48:53 +00:00
parent dd34042c07
commit 141400d8aa
18 changed files with 346 additions and 44 deletions
+4 -2
View File
@@ -9,6 +9,8 @@
#include <util/io/package_manager.hpp>
#include <util/error.hpp>
#include <data/game.hpp>
#include <data/stylesheet.hpp>
#include <data/symbol_font.hpp>
// ----------------------------------------------------------------------------- : IncludePackage
@@ -68,10 +70,10 @@ PackagedP PackageManager::openAny(const String& name) {
} else {
// load with the right type, based on extension
if (fn.GetExt() == _("mse-game")) p = new_shared<Game>();
// else if (fn.GetExt() == _("mse-style")) p = new_shared<CardStyle>();
else if (fn.GetExt() == _("mse-style")) p = new_shared<StyleSheet>();
// else if (fn.GetExt() == _("mse-locale")) p = new_shared<Locale>();
else if (fn.GetExt() == _("mse-include")) p = new_shared<IncludePackage>();
// else if (fn.GetExt() == _("mse-symbol-font")) p = new_shared<SymbolFont>();
else if (fn.GetExt() == _("mse-symbol-font")) p = new_shared<SymbolFont>();
else {
throw PackageError(_("Unrecognized package type: '") + fn.GetExt() + _("'\nwhile trying to open: ") + name);
}
+35
View File
@@ -103,6 +103,17 @@ inline RealSize addVertical(const RealSize& a, const RealSize& b) {
return RealSize(max(a.width, b.width), a.height + b.height);
}
/// Add two sizes diagonally
/** #### $$$ ####...
* #### + $$$ = ####...
* #### ####...
* ....$$$
* ....$$$
*/
inline RealSize addDiagonal(const RealSize& a, const RealSize& b) {
return RealSize(a.width + b.width, a.height + b.height);
}
// ----------------------------------------------------------------------------- : Rectangle using doubles
/// A rectangle (postion and size) using real (double) coordinats
@@ -136,6 +147,30 @@ class RealRect {
}
};
/// Split a rectangle horizontally
/** Returns a section from the left of this rectangle witht the given width
* The rectangle will change to become the part remaining to the right
* For example given a rectangle:
* +------------+
* | R |
* +------------+
* A = split_left(R,5)
* +----+-------+
* | A | R |
* +----+-------+
*/
inline RealRect split_left(RealRect& r, double w) {
RealRect result(r.position.x, r.position.y, w, r.size.height);
r.size.width -= w;
r.position.x += w;
return result;
}
/// Split a rectangle horizontally
inline RealRect split_left(RealRect& r, const RealSize& s) {
return split_left(r, s.width);
}
// ----------------------------------------------------------------------------- : Operators
inline RealPoint operator + (const RealSize& s, const RealPoint& p) {
+5
View File
@@ -171,6 +171,11 @@ void RotatedDC::SetFont(wxFont font, double size) {
dc.SetFont(font);
}
double RotatedDC::getFontSizeStep() const {
return 1; // TODO
// return 1. / (high_quality ? text_scaling : 1);
}
RealSize RotatedDC::GetTextExtent(const String& text) const {
int w, h;
dc.GetTextExtent(text, &w, &h);
+6 -1
View File
@@ -56,7 +56,9 @@ class Rotation {
RealRect trNoNegNoZoom(const RealRect& r) const;
/// Translate a size or length back to internal 'coordinates'
inline double trInvS(double s) const { return s / zoom; }
inline double trInvS(double s) const { return s / zoom; }
/// Translate a size back to internal 'coordinates', doesn't rotate
inline RealSize trInvS(const RealSize& s) const { return RealSize(s.width / zoom, s.height / zoom); }
/// Translate a point back to internal coordinates
RealPoint trInv(const RealPoint& p) const;
@@ -142,6 +144,9 @@ class RotatedDC : public Rotation {
/** The font will get the given (internal) point size */
void SetFont(wxFont font, double size);
/// Steps to use when decrementing font size
double getFontSizeStep() const;
RealSize GetTextExtent(const String& text) const;
double GetCharHeight() const;
+10
View File
@@ -58,6 +58,16 @@ template <typename T, typename A0, typename A1, typename A2, typename A3>
inline shared_ptr<T> new_shared4(const A0& a0, const A1& a1, const A2& a2, const A3& a3) {
return shared_ptr<T>(new T(a0, a1, a2, a3));
}
/// Allocate a new shared-pointed object, given five arguments to pass to the ctor of T
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4>
inline shared_ptr<T> new_shared5(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4) {
return shared_ptr<T>(new T(a0, a1, a2, a3, a4));
}
/// Allocate a new shared-pointed object, given six arguments to pass to the ctor of T
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
inline shared_ptr<T> new_shared6(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) {
return shared_ptr<T>(new T(a0, a1, a2, a3, a4, a5));
}
/// Allocate a new shared-pointed object, given seven arguments to pass to the ctor of T
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
inline shared_ptr<T> new_shared7(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) {
+3
View File
@@ -195,6 +195,9 @@ bool is_substr(const String& str, size_t pos, const Char* cmp) {
}
return *cmp == _('\0');
}
bool is_substr(const String& str, size_t pos, const String& cmp) {
return is_substr(str, pos, cmp.c_str());
}
bool cannocial_name_compare(const String& as, const Char* b) {
const Char* a = as.c_str();
+2
View File
@@ -126,6 +126,8 @@ bool starts_with(const String& str, const String& start);
/// Return whether str contains the string cmp at position pos
bool is_substr(const String& str, size_t pos, const Char* cmp);
/// Return whether str contains the string cmp at position pos
bool is_substr(const String& str, size_t pos, const String& cmp);
/// Compare two strings for equality, b may contain '_' where a contains ' '
bool cannocial_name_compare(const String& a, const Char* b);