FLTK 1.3.x
|
00001 // 00002 // "$Id: mac.H 8204 2011-01-07 01:01:04Z matt $" 00003 // 00004 // Mac header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 // Do not directly include this file, instead use <FL/x.H>. It will 00029 // include this file if "__APPLE__" is defined. This is to encourage 00030 // portability of even the system-specific code... 00031 #ifndef FL_DOXYGEN 00032 00033 #if !defined(Fl_X_H) 00034 # error "Never use <FL/mac.H> directly; include <FL/x.H> instead." 00035 #endif // !Fl_X_H 00036 #include <FL/Fl_Widget.H> 00037 00038 typedef void* Window; // this is really a pointer to the subclass FLWindow of NSWindow 00039 typedef void* Fl_Offscreen; // this is really a CGContextRef 00040 typedef void* Fl_Bitmask; // this is really a CGImageRef 00041 00042 #ifndef FL_LIBRARY // this part is used when compiling an application program 00043 00044 typedef void* Fl_Region; 00045 typedef void* Fl_CGContextRef; 00046 typedef void* Fl_PMPrintSettings; 00047 typedef void* Fl_PMPageFormat; 00048 typedef void* Fl_PMPrintSession; 00049 00050 #else // this part must be compiled when building the FLTK libraries 00051 00052 // Standard MacOS C/C++ includes... 00053 #include <ApplicationServices/ApplicationServices.h> 00054 #undef check // because of Fl::check() 00055 00056 typedef CGContextRef Fl_CGContextRef; 00057 typedef PMPrintSettings Fl_PMPrintSettings; 00058 typedef PMPageFormat Fl_PMPageFormat; 00059 typedef PMPrintSession Fl_PMPrintSession; 00060 00061 #ifndef MAC_OS_X_VERSION_10_3 00062 #define MAC_OS_X_VERSION_10_3 1030 00063 #endif 00064 #ifndef MAC_OS_X_VERSION_10_4 00065 #define MAC_OS_X_VERSION_10_4 1040 00066 #endif 00067 #ifndef MAC_OS_X_VERSION_10_5 00068 #define MAC_OS_X_VERSION_10_5 1050 00069 #endif 00070 #ifndef MAC_OS_X_VERSION_10_6 00071 #define MAC_OS_X_VERSION_10_6 1060 00072 #endif 00073 #ifndef MAC_OS_X_VERSION_MAX_ALLOWED 00074 #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3 00075 #endif 00076 00077 typedef struct flCocoaRegion { 00078 int count; 00079 CGRect *rects; 00080 } *Fl_Region; // a region is the union of a series of rectangles 00081 00082 # include "Fl_Window.H" 00083 00084 // Some random X equivalents 00085 struct XPoint { int x, y; }; 00086 struct XRectangle {int x, y, width, height;}; 00087 #ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h 00088 #if defined(__LP64__) && __LP64__ 00089 typedef double CGFloat; 00090 #else 00091 typedef float CGFloat; 00092 #endif 00093 #endif // CGFLOAT_DEFINED 00094 00095 extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h); 00096 inline Fl_Region XRectangleRegion(int x, int y, int w, int h) { 00097 Fl_Region R = (Fl_Region)malloc(sizeof(*R)); 00098 R->count = 1; 00099 R->rects = (CGRect *)malloc(sizeof(CGRect)); 00100 *(R->rects) = fl_cgrectmake_cocoa(x, y, w, h); 00101 return R; 00102 } 00103 inline void XDestroyRegion(Fl_Region r) { 00104 if(r) { 00105 free(r->rects); 00106 free(r); 00107 } 00108 } 00109 extern void *fl_system_menu; 00110 extern void *fl_default_cursor; 00111 00112 // This object contains all mac-specific stuff about a window: 00113 // WARNING: this object is highly subject to change! 00114 class Fl_X 00115 { 00116 public: 00117 Window xid; // pointer to the Cocoa window object (FLWindow*) 00118 Fl_Offscreen other_xid; // pointer for offscreen bitmaps (overlay window) 00119 Fl_Window *w; // FLTK window for 00120 Fl_Region region; 00121 Fl_Region subRegion; // region for this specific subwindow 00122 Fl_X *next; // linked tree to support subwindows 00123 Fl_X *xidChildren, *xidNext; // more subwindow tree 00124 int wait_for_expose; 00125 void *cursor; // is really NSCursor* 00126 static Fl_X* first; 00127 static Fl_X* i(const Fl_Window* w) {return w->i;} 00128 static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&); 00129 static void make(Fl_Window*); 00130 void flush(); 00131 // Quartz additions: 00132 CGContextRef gc; // graphics context (NULL when using QD) 00133 static void q_fill_context(); // fill a Quartz context with current FLTK state 00134 static void q_clear_clipping(); // remove all clipping from a Quartz context 00135 static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc 00136 static void q_begin_image(CGRect&, int x, int y, int w, int h); 00137 static void q_end_image(); 00138 // Cocoa additions 00139 void destroy(void); 00140 void map(void); 00141 void unmap(void); 00142 int unlink(Fl_X* start = NULL); 00143 void collapse(void); 00144 WindowRef window_ref(void); 00145 void contains_GL_subwindow(void); 00146 void set_key_window(void); 00147 void set_cursor(Fl_Cursor); 00148 static int screen_init(XRectangle screens[], float dpi[]); 00149 static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h); 00150 static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel); 00151 static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h); 00152 static CGContextRef watch_cursor_image(void); 00153 static CGContextRef help_cursor_image(void); 00154 static CGContextRef nesw_cursor_image(void); 00155 static CGContextRef nwse_cursor_image(void); 00156 static CGContextRef none_cursor_image(void); 00157 static void *get_carbon_function(const char *name); 00158 private: 00159 static void relink(Fl_Window*, Fl_Window*); 00160 }; 00161 00162 extern struct Fl_XMap { 00163 RGBColor rgb; 00164 ulong pen; 00165 } *fl_current_xmap; 00166 extern FL_EXPORT Window fl_window; 00167 00168 #endif // FL_LIBRARY 00169 00170 extern FL_EXPORT Fl_CGContextRef fl_gc; 00171 extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar; 00172 00173 extern Window fl_xid(const Fl_Window*); 00174 void fl_clip_region(Fl_Region); 00175 00176 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); 00177 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); 00178 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); 00179 extern Fl_Offscreen fl_create_offscreen(int w, int h); 00180 extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy); 00181 extern void fl_delete_offscreen(Fl_Offscreen gWorld); 00182 extern void fl_begin_offscreen(Fl_Offscreen gWorld); 00183 extern void fl_end_offscreen(); 00184 00185 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); 00186 extern void fl_open_display(); 00187 00188 #endif // FL_DOXYGEN 00189 00196 extern void fl_open_callback(void (*cb)(const char *)); 00197 00206 extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0); 00207 00210 extern int fl_mac_os_version; 00211 00214 // 00215 // End of "$Id: mac.H 8204 2011-01-07 01:01:04Z matt $". 00216 // 00217