FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

mac.H
Go to the documentation of this file.
1 //
2 // "$Id: mac.H 9719 2012-11-13 14:45:42Z manolo $"
3 //
4 // Mac header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2011 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18
19 // Do not directly include this file, instead use <FL/x.H>. It will
20 // include this file if "__APPLE__" is defined. This is to encourage
21 // portability of even the system-specific code...
22 #ifndef FL_DOXYGEN
23
24 #if !defined(Fl_X_H)
25 # error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
26 #endif // !Fl_X_H
27
28 #ifdef __OBJC__
29 @class FLWindow; // a subclass of the NSWindow Cocoa class
30 typedef FLWindow *Window;
31 #else
32 typedef class FLWindow_opaque *Window; // pointer to the FLWindow objective-c class
33 #endif // __OBJC__
34
35 #if !(defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part is used when compiling an application program
36 # include <FL/Fl_Widget.H>
37
38 typedef struct flCocoaRegion* Fl_Region;
39 typedef struct CGContext* CGContextRef;
40 typedef struct OpaquePMPrintSettings* PMPrintSettings;
41 typedef struct OpaquePMPageFormat* PMPageFormat;
42 typedef struct OpaquePMPrintSession* PMPrintSession;
43 typedef struct CGImage* CGImageRef;
44 typedef CGContextRef Fl_Offscreen;
45
46 #else // this part must be compiled when building the FLTK libraries
47
48 // Standard MacOS C/C++ includes...
49 #include <ApplicationServices/ApplicationServices.h>
50 #undef check // because of Fl::check()
51
52 typedef CGContextRef Fl_Offscreen;
53
54 typedef struct flCocoaRegion {
55 int count;
56 CGRect *rects;
57 } *Fl_Region; // a region is the union of a series of rectangles
58
59 # include "Fl_Window.H"
60
61 // Some random X equivalents
62 struct XPoint { int x, y; };
63 struct XRectangle {int x, y, width, height;};
64 #ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
65 #if defined(__LP64__) && __LP64__
66 typedef double CGFloat;
67 #else
68 typedef float CGFloat;
69 #endif
70 #endif // CGFLOAT_DEFINED
71
72 extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h);
73 inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
74 Fl_Region R = (Fl_Region)malloc(sizeof(*R));
75 R->count = 1;
76 R->rects = (CGRect *)malloc(sizeof(CGRect));
77 *(R->rects) = fl_cgrectmake_cocoa(x, y, w, h);
78 return R;
79 }
80 inline void XDestroyRegion(Fl_Region r) {
81 if(r) {
82 free(r->rects);
83 free(r);
84 }
85 }
86 extern void *fl_system_menu;
87 extern void *fl_default_cursor;
88
89 // This object contains all mac-specific stuff about a window:
90 // WARNING: this object is highly subject to change!
91 class Fl_X {
92
93 public:
94 Window xid; // pointer to the Cocoa window object (FLWindow*)
95 Fl_Offscreen other_xid; // pointer for offscreen bitmaps (overlay window)
96 Fl_Window *w; // FLTK window for
97 Fl_Region region;
98 Fl_Region subRegion; // region for this specific subwindow
99 Fl_X *next; // linked tree to support subwindows
100 Fl_X *xidChildren, *xidNext; // more subwindow tree
101 int wait_for_expose;
102 void *cursor; // is really NSCursor*
103 static Fl_X* first;
104 static Fl_X* i(const Fl_Window* w) {return w->i;}
105 static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
106 static void make(Fl_Window*);
107 void flush();
108 // Quartz additions:
109 CGContextRef gc; // graphics context (NULL when using QD)
110 static void q_fill_context(); // fill a Quartz context with current FLTK state
111 static void q_clear_clipping(); // remove all clipping from a Quartz context
112 static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc
113 static void q_begin_image(CGRect&, int x, int y, int w, int h);
114 static void q_end_image();
115 // Cocoa additions
116 void destroy(void);
117 void map(void);
118 void unmap(void);
119 int unlink(Fl_X* start = NULL);
120 void collapse(void);
121 WindowRef window_ref(void);
122 void set_key_window(void);
123 // OS X doesn't have per window icons
124 static void set_default_icons(const Fl_RGB_Image*[], int) {};
125 void set_icons() {};
126 int set_cursor(Fl_Cursor);
127 int set_cursor(const Fl_RGB_Image*, int, int);
128 static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
129 static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
130 static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h);
131 static CGContextRef watch_cursor_image(void);
132 static CGContextRef help_cursor_image(void);
133 static CGContextRef nesw_cursor_image(void);
134 static CGContextRef nwse_cursor_image(void);
135 static CGContextRef none_cursor_image(void);
136 static void *get_carbon_function(const char *name);
137 static void screen_work_area(int &X, int &Y, int &W, int &H, int n); // compute work area of a given screen
138 private:
139 static void relink(Fl_Window*, Fl_Window*);
140 bool subwindow;
141 };
142
143 extern Window fl_window;
144
145 #endif // FL_LIBRARY || FL_INTERNALS
146
147 #ifndef MAC_OS_X_VERSION_10_4
148 #define MAC_OS_X_VERSION_10_4 1040
149 #endif
150 #ifndef MAC_OS_X_VERSION_10_5
151 #define MAC_OS_X_VERSION_10_5 1050
152 #endif
153 #ifndef MAC_OS_X_VERSION_10_6
154 #define MAC_OS_X_VERSION_10_6 1060
155 #endif
156 #ifndef MAC_OS_X_VERSION_10_7
157 #define MAC_OS_X_VERSION_10_7 1070
158 #endif
159 #ifndef MAC_OS_X_VERSION_10_8
160 #define MAC_OS_X_VERSION_10_8 1080
161 #endif
162
163 typedef CGImageRef Fl_Bitmask;
164
165 extern CGContextRef fl_gc;
166 extern class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
167
168 extern Window fl_xid(const Fl_Window*);
169 extern Fl_Window* fl_find(Window xid);
170 void fl_clip_region(Fl_Region);
171
172 extern Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
173 extern Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
174 extern void fl_delete_bitmask(Fl_Bitmask bm);
175 extern Fl_Offscreen fl_create_offscreen(int w, int h);
176 extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy);
177 extern void fl_delete_offscreen(Fl_Offscreen gWorld);
178 extern void fl_begin_offscreen(Fl_Offscreen gWorld);
179 extern void fl_end_offscreen();
180
181 extern int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
182 extern void fl_open_display();
183
184 #endif // FL_DOXYGEN
185
197 extern void fl_open_callback(void (*cb)(const char *));
198
207 extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0);
208
211 extern int fl_mac_os_version;
212
213 class Fl_Mac_App_Menu {
214 public:
216 static const char *about;
221 static const char *print;
223 static const char *services;
225 static const char *hide;
227 static const char *hide_others;
229 static const char *show;
231 static const char *quit;
232 };
233
236 //
237 // End of "$Id: mac.H 9719 2012-11-13 14:45:42Z manolo $".
238 //
239
Fl_Window
This widget produces an actual window.
Definition: Fl_Window.H:54
Fl_Cursor
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:887
Fl_Widget::user_data
void * user_data() const
Gets the user data for this widget.
Definition: Fl_Widget.H:582
fl_clip_region
void fl_clip_region(Fl_Region r)
Replaces the top of the clipping stack with a clipping region of any shape.
Definition: fl_draw.H:136
fl_delete_offscreen
void fl_delete_offscreen(Fl_Offscreen ctx)
Deletion of an offscreen graphics buffer.
Definition: Fl_Double_Window.cxx:301
fl_open_callback
void fl_open_callback(void(*cb)(const char *))
Register a function called for each file dropped onto an application icon.
fl_begin_offscreen
void fl_begin_offscreen(Fl_Offscreen ctx)
Send all subsequent drawing commands to this offscreen buffer.
Definition: Fl_Double_Window.cxx:318
Fl_RGB_Image
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:168
fl_create_offscreen
Fl_Offscreen fl_create_offscreen(int w, int h)
Creation of an offscreen graphics buffer.
Definition: Fl_Double_Window.cxx:260
Fl_Callback
void( Fl_Callback)(Fl_Widget *, void *)
Default callback type definition for all fltk widgets (by far the most used)
Definition: Fl_Widget.H:49
Fl_Widget.H
Fl_Widget, Fl_Label classes .
fl_mac_os_version
int fl_mac_os_version
The version number of the running Mac OS X (e.g., 100604 for 10.6.4)
fl_mac_set_about
void fl_mac_set_about(Fl_Callback *cb, void *user_data, int shortcut=0)
Attaches a callback to the &quot;About myprog&quot; item of the system application menu.
fl_copy_offscreen
void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
Definition: Fl_Double_Window.cxx:98
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
fl_end_offscreen
void fl_end_offscreen()
Quit sending drawing commands to the current offscreen buffer.
Definition: Fl_Double_Window.cxx:336
- © 1998-2012 by Bill Spitzak and others.