diff options
Diffstat (limited to 'scintilla/include/Platform.h')
-rw-r--r-- | scintilla/include/Platform.h | 185 |
1 files changed, 66 insertions, 119 deletions
diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h index 99a2302..46c3642 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -59,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
@@ -76,10 +80,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 +98,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,32 +125,20 @@ 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);
}
};
/**
- * In some circumstances, including Win32 in paletted mode and GTK+, each colour
- * must be allocated before use. The desired colours are held in the ColourDesired class,
- * and after allocation the allocation entry is stored in the ColourAllocated class. In other
- * circumstances, such as Win32 in true colour mode, the allocation process just copies
- * the RGB values from the desired to the allocated class.
- * As each desired colour requires allocation before it can be used, the ColourPair class
- * holds both a ColourDesired and a ColourAllocated
- * The Palette class is responsible for managing the palette of colours which contains a
- * list of ColourPair objects and performs the allocation.
- */
-
-/**
* Holds a desired RGB colour.
*/
class ColourDesired {
@@ -211,82 +203,39 @@ public: };
/**
- * Holds an allocated RGB colour which may be an approximation to the desired colour.
- */
-class ColourAllocated {
- long coAllocated;
-
-public:
-
- ColourAllocated(long lcol=0) {
- coAllocated = lcol;
- }
-
- void Set(long lcol) {
- coAllocated = lcol;
- }
-
- long AsLong() const {
- return coAllocated;
- }
-};
-
-/**
- * Colour pairs hold a desired colour and an allocated colour.
+ * Font management.
*/
-struct ColourPair {
- ColourDesired desired;
- ColourAllocated allocated;
- ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
- desired = desired_;
- allocated.Set(desired.AsLong());
- }
- void Copy() {
- allocated.Set(desired.AsLong());
+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 Window; // Forward declaration for Palette
-
-/**
- * Colour palette management.
- */
-class Palette {
- int used;
- int size;
- ColourPair *entries;
-#if PLAT_GTK
- void *allocatedPalette; // GdkColor *
- int allocatedLen;
-#endif
- // Private so Palette objects can not be copied
- Palette(const Palette &);
- Palette &operator=(const Palette &);
-public:
-#if PLAT_WIN
- void *hpal;
-#endif
- bool allowRealization;
-
- Palette();
- ~Palette();
-
- void Release();
-
- /**
- * This method either adds a colour to the list of wanted colours (want==true)
- * or retrieves the allocated colour back to the ColourPair.
- * This is one method to make it easier to keep the code for wanting and retrieving in sync.
- */
- void WantFind(ColourPair &cp, bool want);
-
- void Allocate(Window &w);
};
-/**
- * Font management.
- */
class Font {
protected:
FontID fid;
@@ -300,8 +249,7 @@ public: Font();
virtual ~Font();
- virtual void Create(const char *faceName, int characterSet, int size,
- bool bold, bool italic, int extraFontFlag=0);
+ virtual void Create(const FontParameters &fp);
virtual void Release();
FontID GetID() { return fid; }
@@ -325,7 +273,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;
@@ -333,36 +281,35 @@ public: virtual void Release()=0;
virtual bool Initialised()=0;
- virtual void PenColour(ColourAllocated fore)=0;
+ virtual void PenColour(ColourDesired fore)=0;
virtual int LogPixelsY()=0;
virtual int DeviceHeightFont(int points)=0;
virtual void MoveTo(int x_, int y_)=0;
virtual void LineTo(int x_, int y_)=0;
- virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
- virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
- virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
+ virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back)=0;
+ virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
+ virtual void FillRectangle(PRectangle rc, ColourDesired back)=0;
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
- virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
- virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
- ColourAllocated outline, int alphaOutline, int flags)=0;
+ virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
+ virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+ ColourDesired outline, int alphaOutline, int flags)=0;
virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0;
- virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired 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 int SetPalette(Palette *pal, bool inBackGround)=0;
+ virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
+ virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
+ virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired 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 void SetClip(PRectangle rc)=0;
virtual void FlushCachedState()=0;
@@ -439,7 +386,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;
|