~ubuntu-branches/debian/experimental/geany/experimental

« back to all changes in this revision

Viewing changes to scintilla/include/Platform.h

  • Committer: Bazaar Package Importer
  • Author(s): Damián Viano
  • Date: 2008-05-02 11:37:45 UTC
  • mfrom: (1.2.1 upstream) (3.1.6 hardy)
  • Revision ID: james.westby@ubuntu.com-20080502113745-xzp4g6dmovrpoj17
Tags: 0.14-1
New upstream release (Closes: #478126)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Scintilla source code edit control
 
1
/* Scintilla source code edit control */
2
2
/** @file Platform.h
3
3
 ** Interface to platform facilities. Also includes some basic utilities.
4
4
 ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
5
5
 **/
6
 
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
7
 
// The License.txt file describes the conditions under which this software may be distributed.
 
6
/* Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
 
7
 * The License.txt file describes the conditions under which this software may be distributed. */
8
8
 
9
9
#ifndef PLATFORM_H
10
10
#define PLATFORM_H
11
11
 
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
15
 
// PLAT_WX is wxWindows on any supported platform
 
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
 
15
 * PLAT_WX is wxWindows on any supported platform */
16
16
 
17
17
#define PLAT_GTK 0
18
18
#define PLAT_GTK_WIN32 0
 
19
#define PLAT_MACOSX 0
19
20
#define PLAT_WIN 0
20
21
#define PLAT_WX  0
21
22
#define PLAT_FOX 0
32
33
#undef PLAT_GTK
33
34
#define PLAT_GTK 1
34
35
 
35
 
#ifdef _MSC_VER
 
36
#if defined(__WIN32__) || defined(_MSC_VER)
36
37
#undef PLAT_GTK_WIN32
37
38
#define PLAT_GTK_WIN32 1
38
39
#endif
39
40
 
 
41
#elif defined(MACOSX)
 
42
#undef PLAT_MACOSX
 
43
#define PLAT_MACOSX 1
 
44
 
40
45
#else
41
46
#undef PLAT_WIN
42
47
#define PLAT_WIN 1
43
48
 
44
49
#endif
45
50
 
 
51
#ifdef SCI_NAMESPACE
 
52
namespace Scintilla {
 
53
#endif
46
54
 
47
 
// Underlying the implementation of the platform classes are platform specific types.
48
 
// Sometimes these need to be passed around by client code so they are defined here
 
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 */
49
57
 
50
58
typedef void *FontID;
51
59
typedef void *SurfaceID;
67
75
        explicit Point(int x_=0, int y_=0) : x(x_), y(y_) {
68
76
        }
69
77
 
70
 
        // Other automatically defined methods (assignment, copy constructor, destructor) are fine
 
78
        /* Other automatically defined methods (assignment, copy constructor, destructor) are fine */
71
79
 
72
80
        static Point FromLong(long lpoint);
73
81
};
88
96
                left(left_), top(top_), right(right_), bottom(bottom_) {
89
97
        }
90
98
 
91
 
        // Other automatically defined methods (assignment, copy constructor, destructor) are fine
 
99
        /* Other automatically defined methods (assignment, copy constructor, destructor) are fine */
92
100
 
93
101
        bool operator==(PRectangle &rc) {
94
102
                return (rc.left == left) && (rc.right == right) &&
114
122
        }
115
123
        int Width() { return right - left; }
116
124
        int Height() { return bottom - top; }
 
125
        bool Empty() {
 
126
                return (Height() <= 0) || (Width() <= 0);
 
127
        }
117
128
};
118
129
 
119
130
/**
229
240
        }
230
241
};
231
242
 
232
 
class Window;   // Forward declaration for Palette
 
243
class Window;   /* Forward declaration for Palette */
233
244
 
234
245
/**
235
246
 * Colour palette management.
239
250
        int size;
240
251
        ColourPair *entries;
241
252
#if PLAT_GTK
242
 
        void *allocatedPalette; // GdkColor *
 
253
        void *allocatedPalette; /* GdkColor * */
243
254
        int allocatedLen;
244
255
#endif
245
 
        // Private so Palette objects can not be copied
 
256
        /* Private so Palette objects can not be copied */
246
257
        Palette(const Palette &) {}
247
258
        Palette &operator=(const Palette &) { return *this; }
248
259
public:
275
286
#if PLAT_WX
276
287
        int ascent;
277
288
#endif
278
 
        // Private so Font objects can not be copied
 
289
        /* Private so Font objects can not be copied */
279
290
        Font(const Font &) {}
280
291
        Font &operator=(const Font &) { id=0; return *this; }
281
292
public:
287
298
        virtual void Release();
288
299
 
289
300
        FontID GetID() { return id; }
290
 
        // Alias another font - caller guarantees not to Release
 
301
        /* Alias another font - caller guarantees not to Release */
291
302
        void SetID(FontID id_) { id = id_; }
292
303
        friend class Surface;
293
304
        friend class SurfaceImpl;
298
309
 */
299
310
class Surface {
300
311
private:
301
 
        // Private so Surface objects can not be copied
 
312
        /* Private so Surface objects can not be copied */
302
313
        Surface(const Surface &) {}
303
314
        Surface &operator=(const Surface &) { return *this; }
304
315
public:
360
371
class Window {
361
372
protected:
362
373
        WindowID id;
 
374
#if PLAT_MACOSX
 
375
        void *windowRef;
 
376
        void *control;
 
377
#endif
363
378
public:
364
 
        Window() : id(0), cursorLast(cursorInvalid) {}
365
 
        Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
 
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
        }
366
391
        virtual ~Window();
367
392
        Window &operator=(WindowID id_) {
368
393
                id = id_;
383
408
        enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };
384
409
        void SetCursor(Cursor curs);
385
410
        void SetTitle(const char *s);
 
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
386
416
private:
387
417
        Cursor cursorLast;
388
418
};
445
475
public:
446
476
        virtual ~DynamicLibrary() {};
447
477
 
448
 
        /// @return Pointer to function "name", or NULL on failure.
 
478
        /** @return Pointer to function "name", or NULL on failure. */
449
479
        virtual Function FindFunction(const char *name) = 0;
450
480
 
451
 
        /// @return true if the library was loaded successfully.
 
481
        /** @return true if the library was loaded successfully. */
452
482
        virtual bool IsValid() = 0;
453
483
 
454
 
        /// @return An instance of a DynamicLibrary subclass with "modulePath" loaded.
 
484
        /** @return An instance of a DynamicLibrary subclass with "modulePath" loaded. */
455
485
        static DynamicLibrary *Load(const char *modulePath);
456
486
};
457
487
 
460
490
 * and chrome colour. Not a creatable object, more of a module with several functions.
461
491
 */
462
492
class Platform {
463
 
        // Private so Platform objects can not be copied
 
493
        /* Private so Platform objects can not be copied */
464
494
        Platform(const Platform &) {}
465
495
        Platform &operator=(const Platform &) { return *this; }
466
496
public:
467
 
        // Should be private because no new Platforms are ever created
468
 
        // but gcc warns about this
 
497
        /* Should be private because no new Platforms are ever created
 
498
         * but gcc warns about this */
469
499
        Platform() {}
470
500
        ~Platform() {}
471
501
        static ColourDesired Chrome();
484
514
        static int DBCSCharLength(int codePage, const char *s);
485
515
        static int DBCSCharMaxLength();
486
516
 
487
 
        // These are utility functions not really tied to a platform
 
517
        /* These are utility functions not really tied to a platform */
488
518
        static int Minimum(int a, int b);
489
519
        static int Maximum(int a, int b);
490
 
        // Next three assume 16 bit shorts and 32 bit longs
 
520
        /* Next three assume 16 bit shorts and 32 bit longs */
491
521
        static long LongFromTwoShorts(short a,short b) {
492
522
                return (a) | ((b) << 16);
493
523
        }
506
536
#ifdef  NDEBUG
507
537
#define PLATFORM_ASSERT(c) ((void)0)
508
538
#else
 
539
#ifdef SCI_NAMESPACE
 
540
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__))
 
541
#else
509
542
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
510
543
#endif
511
 
 
512
 
// Shut up annoying Visual C++ warnings:
 
544
#endif
 
545
 
 
546
#ifdef SCI_NAMESPACE
 
547
}
 
548
#endif
 
549
 
 
550
/* Shut up annoying Visual C++ warnings: */
513
551
#ifdef _MSC_VER
514
552
#pragma warning(disable: 4244 4309 4514 4710)
515
553
#endif