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