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') 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 +- include/Scintilla.h | 8 ++++++++ include/Scintilla.iface | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'include') 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; } diff --git a/include/Scintilla.h b/include/Scintilla.h index 34e4f793d..c7b9944d8 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -221,6 +221,14 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_STYLEGETCHANGEABLE 2492 #define SCI_STYLEGETHOTSPOT 2493 #define SCI_STYLESETCASE 2060 +#define SC_FONT_SIZE_MULTIPLIER 100 +#define SCI_STYLESETSIZEFRACTIONAL 2061 +#define SCI_STYLEGETSIZEFRACTIONAL 2062 +#define SC_WEIGHT_NORMAL 400 +#define SC_WEIGHT_SEMIBOLD 600 +#define SC_WEIGHT_BOLD 700 +#define SCI_STYLESETWEIGHT 2063 +#define SCI_STYLEGETWEIGHT 2064 #define SCI_STYLESETCHARACTERSET 2066 #define SCI_STYLESETHOTSPOT 2409 #define SCI_SETSELFORE 2067 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 36ead0ece..c604f621a 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -482,6 +482,25 @@ get bool StyleGetHotSpot=2493(int style,) # Set a style to be mixed case, or to force upper or lower case. set void StyleSetCase=2060(int style, int caseForce) +val SC_FONT_SIZE_MULTIPLIER=100 + +# Set the size of characters of a style. Size is in points multiplied by 100. +set void StyleSetSizeFractional=2061(int style, int caseForce) + +# Get the weight of characters of a style in points multiplied by 100 +get int StyleGetSizeFractional=2062(int style,) + +enu FontWeight=SC_WEIGHT_ +val SC_WEIGHT_NORMAL=400 +val SC_WEIGHT_SEMIBOLD=600 +val SC_WEIGHT_BOLD=700 + +# Get the weight of characters of a style. +set void StyleSetWeight=2063(int style, int weight) + +# Get the weight of characters of a style. +get int StyleGetWeight=2064(int style,) + # Set the character set of the font in a style. set void StyleSetCharacterSet=2066(int style, int characterSet) -- 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') 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 ++++++++++++++++++++++++++++++++++---- include/Scintilla.h | 4 ++++ include/Scintilla.iface | 9 +++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) (limited to 'include') 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; diff --git a/include/Scintilla.h b/include/Scintilla.h index c7b9944d8..0aec0c8df 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -827,6 +827,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_REGISTERRGBAIMAGE 2627 #define SCI_SCROLLTOSTART 2628 #define SCI_SCROLLTOEND 2629 +#define SC_TECHNOLOGY_DEFAULT 0 +#define SC_TECHNOLOGY_DIRECTWRITE 0 +#define SCI_SETTECHNOLOGY 2630 +#define SCI_GETTECHNOLOGY 2631 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index c604f621a..a578bf3fc 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2194,6 +2194,15 @@ fun void ScrollToStart=2628(,) # Scroll to end of document. fun void ScrollToEnd=2629(,) +val SC_TECHNOLOGY_DEFAULT=0 +val SC_TECHNOLOGY_DIRECTWRITE=0 + +# Set the technolgy used. +set void SetTechnology=2630(int technology,) + +# Get the tech. +get int GetTechnology=2631(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) -- cgit v1.2.3 From f09627bdb8c597bcc8055b6ce370062a06ad1c37 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 11 Aug 2011 10:32:39 +1000 Subject: Implemented parallel stacks for GDI and DirectWrite. GDI works but DirectWrite does not draw well and eventuall crashes. --- include/Scintilla.h | 2 +- include/Scintilla.iface | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Scintilla.h b/include/Scintilla.h index 0aec0c8df..c8ffba04e 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -828,7 +828,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SCROLLTOSTART 2628 #define SCI_SCROLLTOEND 2629 #define SC_TECHNOLOGY_DEFAULT 0 -#define SC_TECHNOLOGY_DIRECTWRITE 0 +#define SC_TECHNOLOGY_DIRECTWRITE 1 #define SCI_SETTECHNOLOGY 2630 #define SCI_GETTECHNOLOGY 2631 #define SCI_STARTRECORD 3001 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index a578bf3fc..c5b58caae 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2195,7 +2195,7 @@ fun void ScrollToStart=2628(,) fun void ScrollToEnd=2629(,) val SC_TECHNOLOGY_DEFAULT=0 -val SC_TECHNOLOGY_DIRECTWRITE=0 +val SC_TECHNOLOGY_DIRECTWRITE=1 # Set the technolgy used. set void SetTechnology=2630(int technology,) -- cgit v1.2.3 From 8ab9f0c333bb0c9ef944d91d940c516b65b0384e Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 12 Aug 2011 23:12:47 +1000 Subject: Added SCI_STYLESETSIZEFRACTIONAL, SCI_STYLESETWEIGHT, and SCI_SETTECHNOLOGY. --- include/Scintilla.iface | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Scintilla.iface b/include/Scintilla.iface index c5b58caae..08a77b605 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -487,7 +487,7 @@ val SC_FONT_SIZE_MULTIPLIER=100 # Set the size of characters of a style. Size is in points multiplied by 100. set void StyleSetSizeFractional=2061(int style, int caseForce) -# Get the weight of characters of a style in points multiplied by 100 +# Get the size of characters of a style in points multiplied by 100 get int StyleGetSizeFractional=2062(int style,) enu FontWeight=SC_WEIGHT_ @@ -495,7 +495,7 @@ val SC_WEIGHT_NORMAL=400 val SC_WEIGHT_SEMIBOLD=600 val SC_WEIGHT_BOLD=700 -# Get the weight of characters of a style. +# Set the weight of characters of a style. set void StyleSetWeight=2063(int style, int weight) # Get the weight of characters of a style. -- cgit v1.2.3