]>
Commit | Line | Data |
---|---|---|
9ce192d4 | 1 | // Scintilla source code edit control |
65ec6247 RD |
2 | /** @file Platform.h |
3 | ** Interface to platform facilities. Also includes some basic utilities. | |
7e0c58e9 | 4 | ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows. |
65ec6247 | 5 | **/ |
9e96e16f | 6 | // Copyright 1998-2009 by Neil Hodgson <neilh@scintilla.org> |
9ce192d4 RD |
7 | // The License.txt file describes the conditions under which this software may be distributed. |
8 | ||
9 | #ifndef PLATFORM_H | |
10 | #define PLATFORM_H | |
11 | ||
65ec6247 RD |
12 | // PLAT_GTK = GTK+ on Linux or Win32 |
13 | // PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32 | |
14 | // PLAT_WIN = Win32 API on Win32 OS | |
7e0c58e9 | 15 | // PLAT_WX is wxWindows on any supported platform |
9ce192d4 RD |
16 | |
17 | #define PLAT_GTK 0 | |
65ec6247 | 18 | #define PLAT_GTK_WIN32 0 |
7e0c58e9 | 19 | #define PLAT_MACOSX 0 |
9ce192d4 RD |
20 | #define PLAT_WIN 0 |
21 | #define PLAT_WX 0 | |
1a2fb4cd | 22 | #define PLAT_FOX 0 |
9ce192d4 | 23 | |
1a2fb4cd RD |
24 | #if defined(FOX) |
25 | #undef PLAT_FOX | |
26 | #define PLAT_FOX 1 | |
27 | ||
28 | #elif defined(__WX__) | |
9ce192d4 RD |
29 | #undef PLAT_WX |
30 | #define PLAT_WX 1 | |
31 | ||
32 | #elif defined(GTK) | |
33 | #undef PLAT_GTK | |
34 | #define PLAT_GTK 1 | |
35 | ||
9e96e16f | 36 | #if defined(__WIN32__) || defined(_MSC_VER) |
65ec6247 RD |
37 | #undef PLAT_GTK_WIN32 |
38 | #define PLAT_GTK_WIN32 1 | |
39 | #endif | |
40 | ||
9e96e16f RD |
41 | #elif defined(__APPLE__) |
42 | ||
7e0c58e9 RD |
43 | #undef PLAT_MACOSX |
44 | #define PLAT_MACOSX 1 | |
45 | ||
9ce192d4 RD |
46 | #else |
47 | #undef PLAT_WIN | |
48 | #define PLAT_WIN 1 | |
49 | ||
50 | #endif | |
51 | ||
7e0c58e9 RD |
52 | #ifdef SCI_NAMESPACE |
53 | namespace Scintilla { | |
54 | #endif | |
9ce192d4 | 55 | |
9ce192d4 RD |
56 | // Underlying the implementation of the platform classes are platform specific types. |
57 | // Sometimes these need to be passed around by client code so they are defined here | |
58 | ||
1a2fb4cd RD |
59 | typedef void *FontID; |
60 | typedef void *SurfaceID; | |
61 | typedef void *WindowID; | |
62 | typedef void *MenuID; | |
63 | typedef void *TickerID; | |
e14d10b0 | 64 | typedef void *Function; |
8e54aaed | 65 | typedef void *IdlerID; |
9ce192d4 | 66 | |
65ec6247 RD |
67 | /** |
68 | * A geometric point class. | |
69 | * Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably. | |
70 | */ | |
9ce192d4 RD |
71 | class Point { |
72 | public: | |
73 | int x; | |
74 | int y; | |
65ec6247 | 75 | |
a33203cb | 76 | explicit Point(int x_=0, int y_=0) : x(x_), y(y_) { |
9ce192d4 RD |
77 | } |
78 | ||
79 | // Other automatically defined methods (assignment, copy constructor, destructor) are fine | |
65ec6247 | 80 | |
9ce192d4 RD |
81 | static Point FromLong(long lpoint); |
82 | }; | |
83 | ||
65ec6247 RD |
84 | /** |
85 | * A geometric rectangle class. | |
86 | * PRectangle is exactly the same as the Win32 RECT so can be used interchangeably. | |
87 | * PRectangles contain their top and left sides, but not their right and bottom sides. | |
88 | */ | |
9ce192d4 RD |
89 | class PRectangle { |
90 | public: | |
91 | int left; | |
92 | int top; | |
93 | int right; | |
94 | int bottom; | |
95 | ||
96 | PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) : | |
97 | left(left_), top(top_), right(right_), bottom(bottom_) { | |
98 | } | |
99 | ||
100 | // Other automatically defined methods (assignment, copy constructor, destructor) are fine | |
101 | ||
65ec6247 RD |
102 | bool operator==(PRectangle &rc) { |
103 | return (rc.left == left) && (rc.right == right) && | |
104 | (rc.top == top) && (rc.bottom == bottom); | |
105 | } | |
9ce192d4 RD |
106 | bool Contains(Point pt) { |
107 | return (pt.x >= left) && (pt.x <= right) && | |
108 | (pt.y >= top) && (pt.y <= bottom); | |
109 | } | |
110 | bool Contains(PRectangle rc) { | |
111 | return (rc.left >= left) && (rc.right <= right) && | |
112 | (rc.top >= top) && (rc.bottom <= bottom); | |
113 | } | |
114 | bool Intersects(PRectangle other) { | |
a834585d RD |
115 | return (right > other.left) && (left < other.right) && |
116 | (bottom > other.top) && (top < other.bottom); | |
9ce192d4 | 117 | } |
9e730a78 RD |
118 | void Move(int xDelta, int yDelta) { |
119 | left += xDelta; | |
120 | top += yDelta; | |
121 | right += xDelta; | |
122 | bottom += yDelta; | |
123 | } | |
9ce192d4 RD |
124 | int Width() { return right - left; } |
125 | int Height() { return bottom - top; } | |
9e96e16f | 126 | bool Empty() { |
7e0c58e9 RD |
127 | return (Height() <= 0) || (Width() <= 0); |
128 | } | |
9ce192d4 RD |
129 | }; |
130 | ||
1a2fb4cd RD |
131 | /** |
132 | * In some circumstances, including Win32 in paletted mode and GTK+, each colour | |
133 | * must be allocated before use. The desired colours are held in the ColourDesired class, | |
134 | * and after allocation the allocation entry is stored in the ColourAllocated class. In other | |
135 | * circumstances, such as Win32 in true colour mode, the allocation process just copies | |
136 | * the RGB values from the desired to the allocated class. | |
137 | * As each desired colour requires allocation before it can be used, the ColourPair class | |
138 | * holds both a ColourDesired and a ColourAllocated | |
139 | * The Palette class is responsible for managing the palette of colours which contains a | |
140 | * list of ColourPair objects and performs the allocation. | |
141 | */ | |
9ce192d4 | 142 | |
65ec6247 | 143 | /** |
1a2fb4cd | 144 | * Holds a desired RGB colour. |
65ec6247 | 145 | */ |
1a2fb4cd RD |
146 | class ColourDesired { |
147 | long co; | |
9ce192d4 | 148 | public: |
1a2fb4cd RD |
149 | ColourDesired(long lcol=0) { |
150 | co = lcol; | |
151 | } | |
65ec6247 | 152 | |
1a2fb4cd | 153 | ColourDesired(unsigned int red, unsigned int green, unsigned int blue) { |
9e730a78 | 154 | Set(red, green, blue); |
1a2fb4cd RD |
155 | } |
156 | ||
157 | bool operator==(const ColourDesired &other) const { | |
158 | return co == other.co; | |
159 | } | |
160 | ||
161 | void Set(long lcol) { | |
162 | co = lcol; | |
163 | } | |
164 | ||
9e730a78 RD |
165 | void Set(unsigned int red, unsigned int green, unsigned int blue) { |
166 | co = red | (green << 8) | (blue << 16); | |
167 | } | |
168 | ||
169 | static inline unsigned int ValueOfHex(const char ch) { | |
170 | if (ch >= '0' && ch <= '9') | |
171 | return ch - '0'; | |
172 | else if (ch >= 'A' && ch <= 'F') | |
173 | return ch - 'A' + 10; | |
174 | else if (ch >= 'a' && ch <= 'f') | |
175 | return ch - 'a' + 10; | |
176 | else | |
177 | return 0; | |
178 | } | |
179 | ||
180 | void Set(const char *val) { | |
181 | if (*val == '#') { | |
182 | val++; | |
183 | } | |
184 | unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]); | |
185 | unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]); | |
186 | unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]); | |
187 | Set(r, g, b); | |
188 | } | |
189 | ||
1a2fb4cd RD |
190 | long AsLong() const { |
191 | return co; | |
192 | } | |
193 | ||
194 | unsigned int GetRed() { | |
195 | return co & 0xff; | |
196 | } | |
197 | ||
198 | unsigned int GetGreen() { | |
199 | return (co >> 8) & 0xff; | |
200 | } | |
201 | ||
202 | unsigned int GetBlue() { | |
203 | return (co >> 16) & 0xff; | |
204 | } | |
9ce192d4 RD |
205 | }; |
206 | ||
65ec6247 | 207 | /** |
1a2fb4cd RD |
208 | * Holds an allocated RGB colour which may be an approximation to the desired colour. |
209 | */ | |
210 | class ColourAllocated { | |
211 | long coAllocated; | |
212 | ||
213 | public: | |
214 | ||
215 | ColourAllocated(long lcol=0) { | |
216 | coAllocated = lcol; | |
217 | } | |
218 | ||
219 | void Set(long lcol) { | |
220 | coAllocated = lcol; | |
221 | } | |
222 | ||
223 | long AsLong() const { | |
224 | return coAllocated; | |
225 | } | |
226 | }; | |
227 | ||
228 | /** | |
229 | * Colour pairs hold a desired colour and an allocated colour. | |
65ec6247 | 230 | */ |
9ce192d4 | 231 | struct ColourPair { |
1a2fb4cd RD |
232 | ColourDesired desired; |
233 | ColourAllocated allocated; | |
9ce192d4 | 234 | |
1a2fb4cd | 235 | ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) { |
9ce192d4 | 236 | desired = desired_; |
1a2fb4cd | 237 | allocated.Set(desired.AsLong()); |
9ce192d4 | 238 | } |
9e730a78 RD |
239 | void Copy() { |
240 | allocated.Set(desired.AsLong()); | |
241 | } | |
9ce192d4 RD |
242 | }; |
243 | ||
244 | class Window; // Forward declaration for Palette | |
245 | ||
65ec6247 RD |
246 | /** |
247 | * Colour palette management. | |
248 | */ | |
9ce192d4 RD |
249 | class Palette { |
250 | int used; | |
b8193d80 RD |
251 | int size; |
252 | ColourPair *entries; | |
9ce192d4 | 253 | #if PLAT_GTK |
1a2fb4cd | 254 | void *allocatedPalette; // GdkColor * |
9ce192d4 | 255 | int allocatedLen; |
9ce192d4 | 256 | #endif |
b8193d80 RD |
257 | // Private so Palette objects can not be copied |
258 | Palette(const Palette &) {} | |
259 | Palette &operator=(const Palette &) { return *this; } | |
9ce192d4 | 260 | public: |
1a2fb4cd RD |
261 | #if PLAT_WIN |
262 | void *hpal; | |
263 | #endif | |
9ce192d4 | 264 | bool allowRealization; |
65ec6247 | 265 | |
9ce192d4 RD |
266 | Palette(); |
267 | ~Palette(); | |
268 | ||
269 | void Release(); | |
65ec6247 RD |
270 | |
271 | /** | |
272 | * This method either adds a colour to the list of wanted colours (want==true) | |
273 | * or retrieves the allocated colour back to the ColourPair. | |
274 | * This is one method to make it easier to keep the code for wanting and retrieving in sync. | |
275 | */ | |
9ce192d4 RD |
276 | void WantFind(ColourPair &cp, bool want); |
277 | ||
278 | void Allocate(Window &w); | |
9ce192d4 RD |
279 | }; |
280 | ||
65ec6247 RD |
281 | /** |
282 | * Font management. | |
283 | */ | |
9ce192d4 | 284 | class Font { |
d134f170 | 285 | protected: |
9e96e16f | 286 | FontID fid; |
9ce192d4 RD |
287 | #if PLAT_WX |
288 | int ascent; | |
289 | #endif | |
290 | // Private so Font objects can not be copied | |
291 | Font(const Font &) {} | |
9e96e16f | 292 | Font &operator=(const Font &) { fid=0; return *this; } |
9ce192d4 RD |
293 | public: |
294 | Font(); | |
d134f170 | 295 | virtual ~Font(); |
9ce192d4 | 296 | |
591d01be | 297 | virtual void Create(const char *faceName, int characterSet, int size, |
9e96e16f | 298 | bool bold, bool italic, int extraFontFlag=0); |
d134f170 | 299 | virtual void Release(); |
9ce192d4 | 300 | |
9e96e16f | 301 | FontID GetID() { return fid; } |
f6bcfd97 | 302 | // Alias another font - caller guarantees not to Release |
9e96e16f | 303 | void SetID(FontID fid_) { fid = fid_; } |
9ce192d4 | 304 | friend class Surface; |
1a2fb4cd | 305 | friend class SurfaceImpl; |
9ce192d4 RD |
306 | }; |
307 | ||
65ec6247 RD |
308 | /** |
309 | * A surface abstracts a place to draw. | |
310 | */ | |
9ce192d4 RD |
311 | class Surface { |
312 | private: | |
9ce192d4 RD |
313 | // Private so Surface objects can not be copied |
314 | Surface(const Surface &) {} | |
315 | Surface &operator=(const Surface &) { return *this; } | |
9ce192d4 | 316 | public: |
7e0c58e9 RD |
317 | Surface() {}; |
318 | virtual ~Surface() {}; | |
1a2fb4cd RD |
319 | static Surface *Allocate(); |
320 | ||
9e730a78 RD |
321 | virtual void Init(WindowID wid)=0; |
322 | virtual void Init(SurfaceID sid, WindowID wid)=0; | |
323 | virtual void InitPixMap(int width, int height, Surface *surface_, WindowID wid)=0; | |
1a2fb4cd RD |
324 | |
325 | virtual void Release()=0; | |
326 | virtual bool Initialised()=0; | |
327 | virtual void PenColour(ColourAllocated fore)=0; | |
328 | virtual int LogPixelsY()=0; | |
329 | virtual int DeviceHeightFont(int points)=0; | |
330 | virtual void MoveTo(int x_, int y_)=0; | |
331 | virtual void LineTo(int x_, int y_)=0; | |
332 | virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0; | |
333 | virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; | |
334 | virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0; | |
335 | virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0; | |
336 | virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; | |
b8193d80 RD |
337 | virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, |
338 | ColourAllocated outline, int alphaOutline, int flags)=0; | |
1a2fb4cd RD |
339 | virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; |
340 | virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0; | |
341 | ||
342 | virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; | |
343 | virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; | |
9e730a78 | 344 | virtual void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore)=0; |
1a2fb4cd RD |
345 | virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0; |
346 | virtual int WidthText(Font &font_, const char *s, int len)=0; | |
347 | virtual int WidthChar(Font &font_, char ch)=0; | |
348 | virtual int Ascent(Font &font_)=0; | |
349 | virtual int Descent(Font &font_)=0; | |
350 | virtual int InternalLeading(Font &font_)=0; | |
351 | virtual int ExternalLeading(Font &font_)=0; | |
352 | virtual int Height(Font &font_)=0; | |
353 | virtual int AverageCharWidth(Font &font_)=0; | |
354 | ||
355 | virtual int SetPalette(Palette *pal, bool inBackGround)=0; | |
356 | virtual void SetClip(PRectangle rc)=0; | |
357 | virtual void FlushCachedState()=0; | |
358 | ||
359 | virtual void SetUnicodeMode(bool unicodeMode_)=0; | |
9e730a78 | 360 | virtual void SetDBCSMode(int codePage)=0; |
9ce192d4 RD |
361 | }; |
362 | ||
1a2fb4cd RD |
363 | /** |
364 | * A simple callback action passing one piece of untyped user data. | |
365 | */ | |
366 | typedef void (*CallBackAction)(void*); | |
367 | ||
65ec6247 RD |
368 | /** |
369 | * Class to hide the details of window manipulation. | |
370 | * Does not own the window which will normally have a longer life than this object. | |
371 | */ | |
9ce192d4 | 372 | class Window { |
9ce192d4 | 373 | protected: |
9e96e16f | 374 | WindowID wid; |
7e0c58e9 RD |
375 | #if PLAT_MACOSX |
376 | void *windowRef; | |
377 | void *control; | |
378 | #endif | |
9ce192d4 | 379 | public: |
9e96e16f | 380 | Window() : wid(0), cursorLast(cursorInvalid) { |
7e0c58e9 RD |
381 | #if PLAT_MACOSX |
382 | windowRef = 0; | |
383 | control = 0; | |
384 | #endif | |
385 | } | |
9e96e16f | 386 | Window(const Window &source) : wid(source.wid), cursorLast(cursorInvalid) { |
7e0c58e9 RD |
387 | #if PLAT_MACOSX |
388 | windowRef = 0; | |
389 | control = 0; | |
390 | #endif | |
391 | } | |
9ce192d4 | 392 | virtual ~Window(); |
9e96e16f RD |
393 | Window &operator=(WindowID wid_) { |
394 | wid = wid_; | |
9ce192d4 RD |
395 | return *this; |
396 | } | |
9e96e16f RD |
397 | WindowID GetID() const { return wid; } |
398 | bool Created() const { return wid != 0; } | |
9ce192d4 RD |
399 | void Destroy(); |
400 | bool HasFocus(); | |
401 | PRectangle GetPosition(); | |
402 | void SetPosition(PRectangle rc); | |
403 | void SetPositionRelative(PRectangle rc, Window relativeTo); | |
404 | PRectangle GetClientPosition(); | |
405 | void Show(bool show=true); | |
406 | void InvalidateAll(); | |
407 | void InvalidateRectangle(PRectangle rc); | |
d134f170 | 408 | virtual void SetFont(Font &font); |
9e730a78 | 409 | enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand }; |
9ce192d4 RD |
410 | void SetCursor(Cursor curs); |
411 | void SetTitle(const char *s); | |
7e0c58e9 RD |
412 | PRectangle GetMonitorRect(Point pt); |
413 | #if PLAT_MACOSX | |
414 | void SetWindow(void *ref) { windowRef = ref; }; | |
415 | void SetControl(void *_control) { control = _control; }; | |
416 | #endif | |
1a2fb4cd RD |
417 | private: |
418 | Cursor cursorLast; | |
9ce192d4 RD |
419 | }; |
420 | ||
65ec6247 RD |
421 | /** |
422 | * Listbox management. | |
423 | */ | |
1a2fb4cd | 424 | |
9ce192d4 | 425 | class ListBox : public Window { |
9ce192d4 RD |
426 | public: |
427 | ListBox(); | |
428 | virtual ~ListBox(); | |
9e730a78 RD |
429 | static ListBox *Allocate(); |
430 | ||
431 | virtual void SetFont(Font &font)=0; | |
1e9bafca | 432 | virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_)=0; |
9e730a78 RD |
433 | virtual void SetAverageCharWidth(int width)=0; |
434 | virtual void SetVisibleRows(int rows)=0; | |
1e9bafca | 435 | virtual int GetVisibleRows() const=0; |
9e730a78 RD |
436 | virtual PRectangle GetDesiredRect()=0; |
437 | virtual int CaretFromEdge()=0; | |
438 | virtual void Clear()=0; | |
439 | virtual void Append(char *s, int type = -1)=0; | |
440 | virtual int Length()=0; | |
441 | virtual void Select(int n)=0; | |
442 | virtual int GetSelection()=0; | |
443 | virtual int Find(const char *prefix)=0; | |
444 | virtual void GetValue(int n, char *value, int len)=0; | |
9e730a78 RD |
445 | virtual void RegisterImage(int type, const char *xpm_data)=0; |
446 | virtual void ClearRegisteredImages()=0; | |
447 | virtual void SetDoubleClickAction(CallBackAction, void *)=0; | |
1e9bafca | 448 | virtual void SetList(const char* list, char separator, char typesep)=0; |
9ce192d4 RD |
449 | }; |
450 | ||
65ec6247 RD |
451 | /** |
452 | * Menu management. | |
453 | */ | |
9ce192d4 | 454 | class Menu { |
9e96e16f | 455 | MenuID mid; |
9ce192d4 RD |
456 | public: |
457 | Menu(); | |
9e96e16f | 458 | MenuID GetID() { return mid; } |
9ce192d4 RD |
459 | void CreatePopUp(); |
460 | void Destroy(); | |
461 | void Show(Point pt, Window &w); | |
462 | }; | |
463 | ||
1a2fb4cd RD |
464 | class ElapsedTime { |
465 | long bigBit; | |
466 | long littleBit; | |
467 | public: | |
468 | ElapsedTime(); | |
469 | double Duration(bool reset=false); | |
470 | }; | |
471 | ||
e14d10b0 RD |
472 | /** |
473 | * Dynamic Library (DLL/SO/...) loading | |
474 | */ | |
475 | class DynamicLibrary { | |
476 | public: | |
7e0c58e9 | 477 | virtual ~DynamicLibrary() {}; |
e14d10b0 RD |
478 | |
479 | /// @return Pointer to function "name", or NULL on failure. | |
480 | virtual Function FindFunction(const char *name) = 0; | |
481 | ||
482 | /// @return true if the library was loaded successfully. | |
483 | virtual bool IsValid() = 0; | |
484 | ||
485 | /// @return An instance of a DynamicLibrary subclass with "modulePath" loaded. | |
486 | static DynamicLibrary *Load(const char *modulePath); | |
487 | }; | |
488 | ||
65ec6247 RD |
489 | /** |
490 | * Platform class used to retrieve system wide parameters such as double click speed | |
491 | * and chrome colour. Not a creatable object, more of a module with several functions. | |
492 | */ | |
9ce192d4 RD |
493 | class Platform { |
494 | // Private so Platform objects can not be copied | |
495 | Platform(const Platform &) {} | |
496 | Platform &operator=(const Platform &) { return *this; } | |
497 | public: | |
498 | // Should be private because no new Platforms are ever created | |
499 | // but gcc warns about this | |
500 | Platform() {} | |
501 | ~Platform() {} | |
1a2fb4cd RD |
502 | static ColourDesired Chrome(); |
503 | static ColourDesired ChromeHighlight(); | |
9ce192d4 RD |
504 | static const char *DefaultFont(); |
505 | static int DefaultFontSize(); | |
506 | static unsigned int DoubleClickTime(); | |
9e730a78 | 507 | static bool MouseButtonBounce(); |
9ce192d4 RD |
508 | static void DebugDisplay(const char *s); |
509 | static bool IsKeyDown(int key); | |
510 | static long SendScintilla( | |
511 | WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0); | |
a834585d RD |
512 | static long SendScintillaPointer( |
513 | WindowID w, unsigned int msg, unsigned long wParam=0, void *lParam=0); | |
1a2fb4cd | 514 | static bool IsDBCSLeadByte(int codePage, char ch); |
9e730a78 RD |
515 | static int DBCSCharLength(int codePage, const char *s); |
516 | static int DBCSCharMaxLength(); | |
65ec6247 | 517 | |
9ce192d4 RD |
518 | // These are utility functions not really tied to a platform |
519 | static int Minimum(int a, int b); | |
520 | static int Maximum(int a, int b); | |
d134f170 RD |
521 | // Next three assume 16 bit shorts and 32 bit longs |
522 | static long LongFromTwoShorts(short a,short b) { | |
523 | return (a) | ((b) << 16); | |
524 | } | |
525 | static short HighShortFromLong(long x) { | |
526 | return static_cast<short>(x >> 16); | |
527 | } | |
528 | static short LowShortFromLong(long x) { | |
529 | return static_cast<short>(x & 0xffff); | |
530 | } | |
9ce192d4 | 531 | static void DebugPrintf(const char *format, ...); |
65ec6247 RD |
532 | static bool ShowAssertionPopUps(bool assertionPopUps_); |
533 | static void Assert(const char *c, const char *file, int line); | |
9ce192d4 RD |
534 | static int Clamp(int val, int minVal, int maxVal); |
535 | }; | |
536 | ||
65ec6247 RD |
537 | #ifdef NDEBUG |
538 | #define PLATFORM_ASSERT(c) ((void)0) | |
539 | #else | |
7e0c58e9 RD |
540 | #ifdef SCI_NAMESPACE |
541 | #define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__)) | |
542 | #else | |
65ec6247 RD |
543 | #define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__)) |
544 | #endif | |
7e0c58e9 RD |
545 | #endif |
546 | ||
547 | #ifdef SCI_NAMESPACE | |
548 | } | |
549 | #endif | |
65ec6247 | 550 | |
1a2fb4cd RD |
551 | // Shut up annoying Visual C++ warnings: |
552 | #ifdef _MSC_VER | |
553 | #pragma warning(disable: 4244 4309 4514 4710) | |
554 | #endif | |
555 | ||
9ce192d4 | 556 | #endif |