From c4ba4ab013dc711f9caa5521b635b68f92a87e33 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Tue, 2 Aug 2011 11:24:48 +1000 Subject: Allow floating point text positioning. --- include/Platform.h | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'include/Platform.h') diff --git a/include/Platform.h b/include/Platform.h index b0f3de0dc..d4c6bbfec 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -9,6 +9,9 @@ #ifndef PLATFORM_H #define PLATFORM_H +#define XYPOSITION float +//#define XYPOSITION int + // PLAT_GTK = GTK+ on Linux or Win32 // PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32 // PLAT_WIN = Win32 API on Win32 OS @@ -76,10 +79,10 @@ typedef void *IdlerID; */ class Point { public: - int x; - int y; + XYPOSITION x; + XYPOSITION y; - explicit Point(int x_=0, int y_=0) : x(x_), y(y_) { + explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) { } // Other automatically defined methods (assignment, copy constructor, destructor) are fine @@ -94,12 +97,12 @@ public: */ class PRectangle { public: - int left; - int top; - int right; - int bottom; + XYPOSITION left; + XYPOSITION top; + XYPOSITION right; + XYPOSITION bottom; - PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) : + PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) : left(left_), top(top_), right(right_), bottom(bottom_) { } @@ -121,14 +124,14 @@ public: return (right > other.left) && (left < other.right) && (bottom > other.top) && (top < other.bottom); } - void Move(int xDelta, int yDelta) { + void Move(XYPOSITION xDelta, XYPOSITION yDelta) { left += xDelta; top += yDelta; right += xDelta; bottom += yDelta; } - int Width() { return right - left; } - int Height() { return bottom - top; } + XYPOSITION Width() { return right - left; } + XYPOSITION Height() { return bottom - top; } bool Empty() { return (Height() <= 0) || (Width() <= 0); } @@ -300,7 +303,7 @@ public: Font(); virtual ~Font(); - virtual void Create(const char *faceName, int characterSet, int size, + virtual void Create(const char *faceName, int characterSet, float size, bool bold, bool italic, int extraFontFlag=0); virtual void Release(); @@ -349,18 +352,18 @@ public: virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0; - virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; - virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; - virtual void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore)=0; - virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0; - virtual int WidthText(Font &font_, const char *s, int len)=0; - virtual int WidthChar(Font &font_, char ch)=0; - virtual int Ascent(Font &font_)=0; - virtual int Descent(Font &font_)=0; - virtual int InternalLeading(Font &font_)=0; - virtual int ExternalLeading(Font &font_)=0; - virtual int Height(Font &font_)=0; - virtual int AverageCharWidth(Font &font_)=0; + virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; + virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; + virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore)=0; + virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0; + virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0; + virtual XYPOSITION WidthChar(Font &font_, char ch)=0; + virtual XYPOSITION Ascent(Font &font_)=0; + virtual XYPOSITION Descent(Font &font_)=0; + virtual XYPOSITION InternalLeading(Font &font_)=0; + virtual XYPOSITION ExternalLeading(Font &font_)=0; + virtual XYPOSITION Height(Font &font_)=0; + virtual XYPOSITION AverageCharWidth(Font &font_)=0; virtual int SetPalette(Palette *pal, bool inBackGround)=0; virtual void SetClip(PRectangle rc)=0; -- cgit v1.2.3 From b510d1fe619eff95c7e0d0a88421b8e3cad8f729 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 7 Aug 2011 13:41:35 +1000 Subject: Implement APIs for fractional font sizes and a range of weights. --- include/Platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Platform.h') diff --git a/include/Platform.h b/include/Platform.h index d4c6bbfec..d23a932e4 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -304,7 +304,7 @@ public: virtual ~Font(); virtual void Create(const char *faceName, int characterSet, float size, - bool bold, bool italic, int extraFontFlag=0); + int weight, bool italic, int extraFontFlag=0); virtual void Release(); FontID GetID() { return fid; } -- cgit v1.2.3 From ee3f851c522fbc475cc97f62af16bbf72ded6f98 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 7 Aug 2011 23:07:01 +1000 Subject: Add a new XYACCUMULATOR which is more precise than XYPOSITION for keeping track over long lines. Using typedefs rather than #defines so goes into namespace. --- include/Platform.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/Platform.h') diff --git a/include/Platform.h b/include/Platform.h index d23a932e4..6ba87aa7b 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -9,9 +9,6 @@ #ifndef PLATFORM_H #define PLATFORM_H -#define XYPOSITION float -//#define XYPOSITION int - // PLAT_GTK = GTK+ on Linux or Win32 // PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32 // PLAT_WIN = Win32 API on Win32 OS @@ -62,6 +59,10 @@ namespace Scintilla { #endif +typedef float XYPOSITION; +typedef double XYACCUMULATOR; +//#define XYPOSITION int + // Underlying the implementation of the platform classes are platform specific types. // Sometimes these need to be passed around by client code so they are defined here -- cgit v1.2.3 From 6860b289d19541ccb8d5be31c81c0f1aa992e9d7 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 10 Aug 2011 23:56:59 +1000 Subject: Implement 'technology' concept which will allow GDI and Direct2D/DirectWrite to run at the same time for different windows and operations. --- include/Platform.h | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'include/Platform.h') diff --git a/include/Platform.h b/include/Platform.h index 6ba87aa7b..499e78e5d 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -291,6 +291,37 @@ public: /** * Font management. */ + +struct FontParameters { + const char *faceName; + float size; + int weight; + bool italic; + int extraFontFlag; + int technology; + int characterSet; + + FontParameters( + const char *faceName_, + float size_=10, + int weight_=400, + bool italic_=false, + int extraFontFlag_=0, + int technology_=0, + int characterSet_=0) : + + faceName(faceName_), + size(size_), + weight(weight_), + italic(italic_), + extraFontFlag(extraFontFlag_), + technology(technology_), + characterSet(characterSet_) + { + } + +}; + class Font { protected: FontID fid; @@ -304,8 +335,7 @@ public: Font(); virtual ~Font(); - virtual void Create(const char *faceName, int characterSet, float size, - int weight, bool italic, int extraFontFlag=0); + virtual void Create(const FontParameters &fp); virtual void Release(); FontID GetID() { return fid; } @@ -329,7 +359,7 @@ private: public: Surface() {} virtual ~Surface() {} - static Surface *Allocate(); + static Surface *Allocate(int technology); virtual void Init(WindowID wid)=0; virtual void Init(SurfaceID sid, WindowID wid)=0; @@ -443,7 +473,7 @@ public: static ListBox *Allocate(); virtual void SetFont(Font &font)=0; - virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_)=0; + virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0; virtual void SetAverageCharWidth(int width)=0; virtual void SetVisibleRows(int rows)=0; virtual int GetVisibleRows() const=0; -- cgit v1.2.3