1 | // |
---|
2 | // "$Id$" |
---|
3 | // |
---|
4 | // Mac header file for the Fast Light Tool Kit (FLTK). |
---|
5 | // |
---|
6 | // Copyright 1998-2005 by Bill Spitzak and others. |
---|
7 | // |
---|
8 | // This library is free software; you can redistribute it and/or |
---|
9 | // modify it under the terms of the GNU Library General Public |
---|
10 | // License as published by the Free Software Foundation; either |
---|
11 | // version 2 of the License, or (at your option) any later version. |
---|
12 | // |
---|
13 | // This library is distributed in the hope that it will be useful, |
---|
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | // Library General Public License for more details. |
---|
17 | // |
---|
18 | // You should have received a copy of the GNU Library General Public |
---|
19 | // License along with this library; if not, write to the Free Software |
---|
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
21 | // USA. |
---|
22 | // |
---|
23 | // Please report all bugs and problems on the following page: |
---|
24 | // |
---|
25 | // http://www.fltk.org/str.php |
---|
26 | // |
---|
27 | |
---|
28 | // Do not directly include this file, instead use <FL/x.H>. It will |
---|
29 | // include this file if "__APPLE__" is defined. This is to encourage |
---|
30 | // portability of even the system-specific code... |
---|
31 | |
---|
32 | #ifndef Fl_X_H |
---|
33 | # error "Never use <FL/mac.H> directly; include <FL/x.H> instead." |
---|
34 | #endif // !Fl_X_H |
---|
35 | |
---|
36 | // Standard MacOS Carbon API includes... |
---|
37 | #include <Carbon/Carbon.h> |
---|
38 | |
---|
39 | // Now make some fixes to the headers... |
---|
40 | #undef check // Dunno where this comes from... |
---|
41 | |
---|
42 | // Some random X equivalents |
---|
43 | typedef WindowPtr Window; |
---|
44 | struct XPoint { int x, y; }; |
---|
45 | struct XRectangle {int x, y, width, height;}; |
---|
46 | typedef RgnHandle Fl_Region; |
---|
47 | void fl_clip_region(Fl_Region); |
---|
48 | inline Fl_Region XRectangleRegion(int x, int y, int w, int h) { |
---|
49 | Fl_Region R = NewRgn(); |
---|
50 | SetRectRgn(R, x, y, x+w, y+h); |
---|
51 | return R; |
---|
52 | } |
---|
53 | inline void XDestroyRegion(Fl_Region r) { |
---|
54 | DisposeRgn(r); |
---|
55 | } |
---|
56 | |
---|
57 | # include "Fl_Window.H" |
---|
58 | |
---|
59 | // This object contains all mac-specific stuff about a window: |
---|
60 | // WARNING: this object is highly subject to change! |
---|
61 | class Fl_X |
---|
62 | { |
---|
63 | public: |
---|
64 | Window xid; // Mac WindowPtr |
---|
65 | GWorldPtr other_xid; // pointer for offscreen bitmaps (doublebuffer) |
---|
66 | Fl_Window *w; // FLTK window for |
---|
67 | Fl_Region region; |
---|
68 | Fl_Region subRegion; // region for this specific subwindow |
---|
69 | Fl_X *next; // linked tree to support subwindows |
---|
70 | Fl_X *xidChildren, *xidNext; // more subwindow tree |
---|
71 | int wait_for_expose; |
---|
72 | CursHandle cursor; |
---|
73 | static Fl_X* first; |
---|
74 | static Fl_X* i(const Fl_Window* w) {return w->i;} |
---|
75 | static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&); |
---|
76 | static void make(Fl_Window*); |
---|
77 | void flush(); |
---|
78 | // Quartz additions: |
---|
79 | CGContextRef gc; // graphics context (NULL when using QD) |
---|
80 | static ATSUTextLayout atsu_layout; // windows share a global font |
---|
81 | static ATSUStyle atsu_style; |
---|
82 | static void q_fill_context(); // fill a Quartz context with current FLTK state |
---|
83 | static void q_clear_clipping(); // remove all clipping from a Quartz context |
---|
84 | static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc |
---|
85 | static void q_begin_image(CGRect&, int x, int y, int w, int h); |
---|
86 | static void q_end_image(); |
---|
87 | }; |
---|
88 | |
---|
89 | extern void MacDestroyWindow(Fl_Window*,WindowPtr); |
---|
90 | extern void MacMapWindow(Fl_Window*,WindowPtr); |
---|
91 | extern void MacUnmapWindow(Fl_Window*,WindowPtr); |
---|
92 | extern int MacUnlinkWindow(Fl_X*,Fl_X*start=0L); |
---|
93 | |
---|
94 | inline Window fl_xid(const Fl_Window*w) |
---|
95 | { |
---|
96 | return Fl_X::i(w)->xid; |
---|
97 | } |
---|
98 | |
---|
99 | extern CursHandle fl_default_cursor; |
---|
100 | |
---|
101 | extern struct Fl_XMap { |
---|
102 | RGBColor rgb; |
---|
103 | ulong pen; |
---|
104 | } *fl_current_xmap; |
---|
105 | |
---|
106 | extern FL_EXPORT void *fl_display; |
---|
107 | extern FL_EXPORT Window fl_window; |
---|
108 | extern FL_EXPORT CGContextRef fl_gc; |
---|
109 | extern FL_EXPORT Handle fl_system_menu; |
---|
110 | extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar; |
---|
111 | |
---|
112 | typedef GWorldPtr Fl_Offscreen; |
---|
113 | |
---|
114 | extern Fl_Offscreen fl_create_offscreen(int w, int h); |
---|
115 | extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy); |
---|
116 | extern void fl_delete_offscreen(Fl_Offscreen gWorld); |
---|
117 | extern void fl_begin_offscreen(Fl_Offscreen gWorld); |
---|
118 | extern void fl_end_offscreen(); |
---|
119 | |
---|
120 | typedef GWorldPtr Fl_Bitmask; // Carbon requires a 1-bit GWorld instead of a BitMap |
---|
121 | |
---|
122 | extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); |
---|
123 | extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); |
---|
124 | extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); |
---|
125 | |
---|
126 | extern void fl_open_display(); |
---|
127 | |
---|
128 | // Register a function for opening files via the finder... |
---|
129 | extern void fl_open_callback(void (*cb)(const char *)); |
---|
130 | |
---|
131 | extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); |
---|
132 | |
---|
133 | // |
---|
134 | // End of "$Id$". |
---|
135 | // |
---|
136 | |
---|