00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FL_DOXYGEN
00023
00024 #if !defined(Fl_X_H)
00025 # error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
00026 #endif // !Fl_X_H
00027
00028 #ifdef __OBJC__
00029 @class FLWindow;
00030 typedef FLWindow *Window;
00031 #else
00032 typedef class FLWindow *Window;
00033 #endif // __OBJC__
00034
00035 #if !(defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part is used when compiling an application program
00036 # include <FL/Fl_Widget.H>
00037
00038 typedef struct flCocoaRegion* Fl_Region;
00039 typedef struct CGContext* CGContextRef;
00040 typedef struct OpaquePMPrintSettings* PMPrintSettings;
00041 typedef struct OpaquePMPageFormat* PMPageFormat;
00042 typedef struct OpaquePMPrintSession* PMPrintSession;
00043 typedef struct CGImage* CGImageRef;
00044 typedef struct __CFData* CFMutableDataRef;
00045 typedef CGContextRef Fl_Offscreen;
00046
00047 #else // this part must be compiled when building the FLTK libraries
00048
00049
00050 #include <ApplicationServices/ApplicationServices.h>
00051 #undef check // because of Fl::check()
00052
00053 #ifndef MAC_OS_X_VERSION_10_4
00054 #define MAC_OS_X_VERSION_10_4 1040
00055 #endif
00056 #ifndef MAC_OS_X_VERSION_10_5
00057 #define MAC_OS_X_VERSION_10_5 1050
00058 #endif
00059 #ifndef MAC_OS_X_VERSION_10_6
00060 #define MAC_OS_X_VERSION_10_6 1060
00061 #endif
00062 #ifndef MAC_OS_X_VERSION_10_7
00063 #define MAC_OS_X_VERSION_10_7 1070
00064 #endif
00065 #ifndef MAC_OS_X_VERSION_10_8
00066 #define MAC_OS_X_VERSION_10_8 1080
00067 #endif
00068 #ifndef MAC_OS_X_VERSION_10_9
00069 #define MAC_OS_X_VERSION_10_9 1090
00070 #endif
00071 #ifndef MAC_OS_X_VERSION_10_10
00072 #define MAC_OS_X_VERSION_10_10 101000
00073 #endif
00074 #ifndef MAC_OS_X_VERSION_10_11
00075 #define MAC_OS_X_VERSION_10_11 101100
00076 #endif
00077 #ifndef MAC_OS_X_VERSION_10_12
00078 #define MAC_OS_X_VERSION_10_12 101200
00079 #endif
00080 #ifndef MAC_OS_X_VERSION_10_13
00081 #define MAC_OS_X_VERSION_10_13 101300
00082 #endif
00083 #ifndef MAC_OS_X_VERSION_10_14
00084 #define MAC_OS_X_VERSION_10_14 101400
00085 #endif
00086
00087 #ifndef NSINTEGER_DEFINED // appears with 10.5 in NSObjCRuntime.h
00088 #if defined(__LP64__) && __LP64__
00089 typedef long NSInteger;
00090 typedef unsigned long NSUInteger;
00091 #else
00092 typedef int NSInteger;
00093 typedef unsigned int NSUInteger;
00094 #endif
00095 #endif
00096
00097 #ifdef __OBJC__
00098 @class NSCursor;
00099 @class NSOpenGLPixelFormat;
00100 @class NSOpenGLContext;
00101 #else
00102 class NSCursor;
00103 class NSOpenGLPixelFormat;
00104 class NSOpenGLContext;
00105 #endif // __OBJC__
00106
00107 typedef CGContextRef Fl_Offscreen;
00108 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
00109 typedef CGImageAlphaInfo CGBitmapInfo;
00110 #endif
00111
00112 typedef struct flCocoaRegion {
00113 int count;
00114 CGRect *rects;
00115 } *Fl_Region;
00116
00117 # include "Fl_Window.H"
00118 # include "../src/Fl_Font.H"
00119
00120
00121 struct XPoint { int x, y; };
00122 struct XRectangle {int x, y, width, height;};
00123 #ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
00124 #if defined(__LP64__) && __LP64__
00125 typedef double CGFloat;
00126 #else
00127 typedef float CGFloat;
00128 #endif
00129 #endif // CGFLOAT_DEFINED
00130
00131 extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h);
00132 inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
00133 Fl_Region R = (Fl_Region)malloc(sizeof(*R));
00134 R->count = 1;
00135 R->rects = (CGRect *)malloc(sizeof(CGRect));
00136 *(R->rects) = fl_cgrectmake_cocoa(x, y, w, h);
00137 return R;
00138 }
00139 inline void XDestroyRegion(Fl_Region r) {
00140 if(r) {
00141 free(r->rects);
00142 free(r);
00143 }
00144 }
00145 extern NSCursor *fl_default_cursor;
00146
00147
00148
00149 class Fl_X {
00150
00151 public:
00152 Window xid;
00153 Fl_Offscreen other_xid;
00154 Fl_Window *w;
00155 Fl_Region region;
00156 #if FLTK_ABI_VERSION < 10304
00157 Fl_Region subRegion;
00158 #endif
00159 Fl_X *next;
00160 #if FLTK_ABI_VERSION < 10304
00161 Fl_X *xidChildren;
00162 Fl_X *xidNext;
00163 #endif
00164 int wait_for_expose;
00165 NSCursor *cursor;
00166 static Fl_X* first;
00167 static Fl_X* i(const Fl_Window* w) {return w->i;}
00168 static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
00169 static void make(Fl_Window*);
00170 void flush();
00171 static void set_high_resolution(bool);
00172 #if FLTK_ABI_VERSION >= 10304
00173 CGRect* subRect() { return subRect_; }
00174 void subRect(CGRect *r) { subRect_ = r; }
00175 #else
00176 CGRect* subRect() { return (CGRect*)subRegion; }
00177 void subRect(CGRect *r) { subRegion = (Fl_Region)r; }
00178 #endif
00179 bool mapped_to_retina();
00180 void mapped_to_retina(bool);
00181 bool changed_resolution();
00182 void changed_resolution(bool);
00183 bool in_windowDidResize();
00184 void in_windowDidResize(bool);
00185
00186 CGContextRef gc;
00187 static void q_fill_context();
00188 static void q_clear_clipping();
00189 static void q_release_context(Fl_X *x=0);
00190 static void q_begin_image(CGRect&, int x, int y, int w, int h);
00191 static void q_end_image();
00192
00193 static NSOpenGLPixelFormat *mode_to_NSOpenGLPixelFormat(int mode, const int*);
00194 static NSOpenGLContext* create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat, NSOpenGLContext *shared_ctx, Fl_Window *window);
00195 static void GLcontext_update(NSOpenGLContext*);
00196 static void GLcontext_flushbuffer(NSOpenGLContext*);
00197 static void GLcontext_release(NSOpenGLContext*);
00198 static void GLcontext_makecurrent(NSOpenGLContext*);
00199 static void GL_cleardrawable(void);
00200 static void gl_start(NSOpenGLContext*);
00201 void destroy(void);
00202 void map(void);
00203 void unmap(void);
00204 void collapse(void);
00205 WindowRef window_ref(void);
00206 void set_key_window(void);
00207
00208 static void set_default_icons(const Fl_RGB_Image*[], int) {};
00209 void set_icons() {};
00210 int set_cursor(Fl_Cursor);
00211 int set_cursor(const Fl_RGB_Image*, int, int);
00212 static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
00213 static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
00214 static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h);
00215 static void *get_carbon_function(const char *name);
00216 static void screen_work_area(int &X, int &Y, int &W, int &H, int n);
00217 static int next_marked_length;
00218 static int insertion_point_location(int *px, int *py, int *pheight);
00219 static const int CoreText_threshold;
00220 static Fl_Fontdesc* calc_fl_fonts(void);
00221 static int dnd(int use_selection);
00222 static int calc_mac_os_version(void);
00223 static void clip_to_rounded_corners(CGContextRef gc, int w, int h);
00224 static void *get_titlebar_layer(Fl_Window *win);
00225 static void draw_layer_to_context(void *layer, CGContextRef ctxt, int w, int h);
00226 private:
00227 #if FLTK_ABI_VERSION >= 10304
00228 CGRect* subRect_;
00229
00230
00231 unsigned mapped_to_retina_;
00232 #else
00233 bool subwindow;
00234 #endif
00235 };
00236
00237 extern Window fl_window;
00238
00239 #endif // FL_LIBRARY || FL_INTERNALS
00240
00241 typedef CGImageRef Fl_Bitmask;
00242
00243 extern CGContextRef fl_gc;
00244
00245 extern Window fl_xid(const Fl_Window*);
00246 extern Fl_Window* fl_find(Window xid);
00247 void fl_clip_region(Fl_Region);
00248
00249 extern Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
00250 extern Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
00251 extern void fl_delete_bitmask(Fl_Bitmask bm);
00252 extern Fl_Offscreen fl_create_offscreen(int w, int h);
00253 extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy);
00254 extern void fl_delete_offscreen(Fl_Offscreen gWorld);
00255 extern void fl_begin_offscreen(Fl_Offscreen gWorld);
00256 extern void fl_end_offscreen();
00257
00258 extern int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
00259 extern void fl_open_display();
00260
00261 #endif // FL_DOXYGEN
00262
00275 extern void fl_open_callback(void (*cb)(const char *));
00276
00285 extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0);
00286
00289 extern int fl_mac_os_version;
00290
00297 extern int fl_mac_quit_early;
00298
00301 extern class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
00302
00303 struct Fl_Menu_Item;
00304
00305 class Fl_Mac_App_Menu {
00306 public:
00308 static const char *about;
00313 static const char *print;
00315 static const char *services;
00317 static const char *hide;
00319 static const char *hide_others;
00321 static const char *show;
00323 static const char *quit;
00324 static void custom_application_menu_items(const Fl_Menu_Item *m);
00325 };
00326
00329
00330
00331
00332