X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a834585d7492ae8388ea109bf38d55c4a502753a..f5766910b6731eb03e82371416e9778203396ce7:/contrib/src/stc/scintilla/include/Platform.h?ds=sidebyside diff --git a/contrib/src/stc/scintilla/include/Platform.h b/contrib/src/stc/scintilla/include/Platform.h index 1a8dfaa96e..9dafa9f7d6 100644 --- a/contrib/src/stc/scintilla/include/Platform.h +++ b/contrib/src/stc/scintilla/include/Platform.h @@ -1,9 +1,9 @@ // Scintilla source code edit control /** @file Platform.h ** Interface to platform facilities. Also includes some basic utilities. - ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows. + ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWidgets. **/ -// Copyright 1998-2002 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef PLATFORM_H @@ -12,7 +12,7 @@ // 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 -// PLAT_WX is wxWindows on any supported platform +// PLAT_WX is wxWidgets on any supported platform #define PLAT_GTK 0 #define PLAT_GTK_WIN32 0 @@ -44,11 +44,6 @@ #endif -#if PLAT_WX -#include // For the global memory operators, if needed. -#endif - - // 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 @@ -57,6 +52,8 @@ typedef void *SurfaceID; typedef void *WindowID; typedef void *MenuID; typedef void *TickerID; +typedef void *Function; +typedef void *IdlerID; /** * A geometric point class. @@ -67,7 +64,7 @@ public: int x; int y; - Point(int x_=0, int y_=0) : x(x_), y(y_) { + explicit Point(int x_=0, int y_=0) : x(x_), y(y_) { } // Other automatically defined methods (assignment, copy constructor, destructor) are fine @@ -109,6 +106,12 @@ public: return (right > other.left) && (left < other.right) && (bottom > other.top) && (top < other.bottom); } + void Move(int xDelta, int yDelta) { + left += xDelta; + top += yDelta; + right += xDelta; + bottom += yDelta; + } int Width() { return right - left; } int Height() { return bottom - top; } }; @@ -136,7 +139,7 @@ public: } ColourDesired(unsigned int red, unsigned int green, unsigned int blue) { - co = red | (green << 8) | (blue << 16); + Set(red, green, blue); } bool operator==(const ColourDesired &other) const { @@ -147,6 +150,31 @@ public: co = lcol; } + void Set(unsigned int red, unsigned int green, unsigned int blue) { + co = red | (green << 8) | (blue << 16); + } + + static inline unsigned int ValueOfHex(const char ch) { + if (ch >= '0' && ch <= '9') + return ch - '0'; + else if (ch >= 'A' && ch <= 'F') + return ch - 'A' + 10; + else if (ch >= 'a' && ch <= 'f') + return ch - 'a' + 10; + else + return 0; + } + + void Set(const char *val) { + if (*val == '#') { + val++; + } + unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]); + unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]); + unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]); + Set(r, g, b); + } + long AsLong() const { return co; } @@ -196,6 +224,9 @@ struct ColourPair { desired = desired_; allocated.Set(desired.AsLong()); } + void Copy() { + allocated.Set(desired.AsLong()); + } }; class Window; // Forward declaration for Palette @@ -205,12 +236,15 @@ class Window; // Forward declaration for Palette */ class Palette { int used; - enum {numEntries = 100}; - ColourPair entries[numEntries]; + 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 &) { return *this; } public: #if PLAT_WIN void *hpal; @@ -248,7 +282,8 @@ public: Font(); virtual ~Font(); - virtual void Create(const char *faceName, int characterSet, int size, bool bold, bool italic); + virtual void Create(const char *faceName, int characterSet, int size, + bool bold, bool italic, bool extraFontFlag=false); virtual void Release(); FontID GetID() { return id; } @@ -271,9 +306,9 @@ public: virtual ~Surface() {}; static Surface *Allocate(); - virtual void Init()=0; - virtual void Init(SurfaceID sid)=0; - virtual void InitPixMap(int width, int height, Surface *surface_)=0; + virtual void Init(WindowID wid)=0; + virtual void Init(SurfaceID sid, WindowID wid)=0; + virtual void InitPixMap(int width, int height, Surface *surface_, WindowID wid)=0; virtual void Release()=0; virtual bool Initialised()=0; @@ -287,11 +322,14 @@ public: virtual void FillRectangle(PRectangle rc, ColourAllocated 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 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; @@ -307,6 +345,7 @@ public: virtual void FlushCachedState()=0; virtual void SetUnicodeMode(bool unicodeMode_)=0; + virtual void SetDBCSMode(int codePage)=0; }; /** @@ -329,8 +368,8 @@ public: id = id_; return *this; } - WindowID GetID() { return id; } - bool Created() { return id != 0; } + WindowID GetID() const { return id; } + bool Created() const { return id != 0; } void Destroy(); bool HasFocus(); PRectangle GetPosition(); @@ -341,7 +380,7 @@ public: void InvalidateAll(); void InvalidateRectangle(PRectangle rc); virtual void SetFont(Font &font); - enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow }; + enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand }; void SetCursor(Cursor curs); void SetTitle(const char *s); private: @@ -353,38 +392,29 @@ private: */ class ListBox : public Window { -private: -#if PLAT_GTK - WindowID list; - WindowID scroller; - int current; -#endif - int desiredVisibleRows; - unsigned int maxItemCharacters; - unsigned int aveCharWidth; -public: - CallBackAction doubleClickAction; - void *doubleClickActionData; public: ListBox(); virtual ~ListBox(); - void Create(Window &parent, int ctrlID); - virtual void SetFont(Font &font); - void SetAverageCharWidth(int width); - void SetVisibleRows(int rows); - PRectangle GetDesiredRect(); - void Clear(); - void Append(char *s); - int Length(); - void Select(int n); - int GetSelection(); - int Find(const char *prefix); - void GetValue(int n, char *value, int len); - void Sort(); - void SetDoubleClickAction(CallBackAction action, void *data) { - doubleClickAction = action; - doubleClickActionData = data; - } + 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 SetAverageCharWidth(int width)=0; + virtual void SetVisibleRows(int rows)=0; + virtual int GetVisibleRows() const=0; + virtual PRectangle GetDesiredRect()=0; + virtual int CaretFromEdge()=0; + virtual void Clear()=0; + virtual void Append(char *s, int type = -1)=0; + virtual int Length()=0; + virtual void Select(int n)=0; + virtual int GetSelection()=0; + virtual int Find(const char *prefix)=0; + virtual void GetValue(int n, char *value, int len)=0; + virtual void RegisterImage(int type, const char *xpm_data)=0; + virtual void ClearRegisteredImages()=0; + virtual void SetDoubleClickAction(CallBackAction, void *)=0; + virtual void SetList(const char* list, char separator, char typesep)=0; }; /** @@ -408,6 +438,23 @@ public: double Duration(bool reset=false); }; +/** + * Dynamic Library (DLL/SO/...) loading + */ +class DynamicLibrary { +public: + virtual ~DynamicLibrary() {}; + + /// @return Pointer to function "name", or NULL on failure. + virtual Function FindFunction(const char *name) = 0; + + /// @return true if the library was loaded successfully. + virtual bool IsValid() = 0; + + /// @return An instance of a DynamicLibrary subclass with "modulePath" loaded. + static DynamicLibrary *Load(const char *modulePath); +}; + /** * Platform class used to retrieve system wide parameters such as double click speed * and chrome colour. Not a creatable object, more of a module with several functions. @@ -426,6 +473,7 @@ public: static const char *DefaultFont(); static int DefaultFontSize(); static unsigned int DoubleClickTime(); + static bool MouseButtonBounce(); static void DebugDisplay(const char *s); static bool IsKeyDown(int key); static long SendScintilla( @@ -433,6 +481,8 @@ public: static long SendScintillaPointer( WindowID w, unsigned int msg, unsigned long wParam=0, void *lParam=0); static bool IsDBCSLeadByte(int codePage, char ch); + static int DBCSCharLength(int codePage, const char *s); + static int DBCSCharMaxLength(); // These are utility functions not really tied to a platform static int Minimum(int a, int b);