FLTK 1.3.0
|
00001 // 00002 // "$Id: mac.H 8657 2011-05-12 11:50:43Z manolo $" 00003 // 00004 // Mac header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2011 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 #include <AvailabilityMacros.h> 00043 #ifndef MAC_OS_X_VERSION_10_3 00044 #define MAC_OS_X_VERSION_10_3 1030 00045 #endif 00046 #ifndef MAC_OS_X_VERSION_10_4 00047 #define MAC_OS_X_VERSION_10_4 1040 00048 #endif 00049 #ifndef MAC_OS_X_VERSION_10_5 00050 #define MAC_OS_X_VERSION_10_5 1050 00051 #endif 00052 #ifndef MAC_OS_X_VERSION_10_6 00053 #define MAC_OS_X_VERSION_10_6 1060 00054 #endif 00055 00056 #if !(defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part is used when compiling an application program 00057 00058 typedef void* Fl_Region; 00059 typedef void* Fl_CGContextRef; 00060 typedef void* Fl_PMPrintSettings; 00061 typedef void* Fl_PMPageFormat; 00062 typedef void* Fl_PMPrintSession; 00063 00064 #else // this part must be compiled when building the FLTK libraries 00065 00066 // Standard MacOS C/C++ includes... 00067 #include <ApplicationServices/ApplicationServices.h> 00068 #undef check // because of Fl::check() 00069 00070 typedef CGContextRef Fl_CGContextRef; 00071 typedef PMPrintSettings Fl_PMPrintSettings; 00072 typedef PMPageFormat Fl_PMPageFormat; 00073 typedef PMPrintSession Fl_PMPrintSession; 00074 00075 typedef struct flCocoaRegion { 00076 int count; 00077 CGRect *rects; 00078 } *Fl_Region; // a region is the union of a series of rectangles 00079 00080 # include "Fl_Window.H" 00081 00082 // Some random X equivalents 00083 struct XPoint { int x, y; }; 00084 struct XRectangle {int x, y, width, height;}; 00085 #ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h 00086 #if defined(__LP64__) && __LP64__ 00087 typedef double CGFloat; 00088 #else 00089 typedef float CGFloat; 00090 #endif 00091 #endif // CGFLOAT_DEFINED 00092 00093 extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h); 00094 inline Fl_Region XRectangleRegion(int x, int y, int w, int h) { 00095 Fl_Region R = (Fl_Region)malloc(sizeof(*R)); 00096 R->count = 1; 00097 R->rects = (CGRect *)malloc(sizeof(CGRect)); 00098 *(R->rects) = fl_cgrectmake_cocoa(x, y, w, h); 00099 return R; 00100 } 00101 inline void XDestroyRegion(Fl_Region r) { 00102 if(r) { 00103 free(r->rects); 00104 free(r); 00105 } 00106 } 00107 extern void *fl_system_menu; 00108 extern void *fl_default_cursor; 00109 00110 // This object contains all mac-specific stuff about a window: 00111 // WARNING: this object is highly subject to change! 00112 class Fl_X { 00113 00114 public: 00115 Window xid; // pointer to the Cocoa window object (FLWindow*) 00116 Fl_Offscreen other_xid; // pointer for offscreen bitmaps (overlay window) 00117 Fl_Window *w; // FLTK window for 00118 Fl_Region region; 00119 Fl_Region subRegion; // region for this specific subwindow 00120 Fl_X *next; // linked tree to support subwindows 00121 Fl_X *xidChildren, *xidNext; // more subwindow tree 00122 int wait_for_expose; 00123 void *cursor; // is really NSCursor* 00124 static Fl_X* first; 00125 static Fl_X* i(const Fl_Window* w) {return w->i;} 00126 static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&); 00127 static void make(Fl_Window*); 00128 void flush(); 00129 // Quartz additions: 00130 CGContextRef gc; // graphics context (NULL when using QD) 00131 static void q_fill_context(); // fill a Quartz context with current FLTK state 00132 static void q_clear_clipping(); // remove all clipping from a Quartz context 00133 static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc 00134 static void q_begin_image(CGRect&, int x, int y, int w, int h); 00135 static void q_end_image(); 00136 // Cocoa additions 00137 void destroy(void); 00138 void map(void); 00139 void unmap(void); 00140 int unlink(Fl_X* start = NULL); 00141 void collapse(void); 00142 WindowRef window_ref(void); 00143 void set_key_window(void); 00144 void set_cursor(Fl_Cursor); 00145 static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h); 00146 static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel); 00147 static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h); 00148 static CGContextRef watch_cursor_image(void); 00149 static CGContextRef help_cursor_image(void); 00150 static CGContextRef nesw_cursor_image(void); 00151 static CGContextRef nwse_cursor_image(void); 00152 static CGContextRef none_cursor_image(void); 00153 static void *get_carbon_function(const char *name); 00154 private: 00155 static void relink(Fl_Window*, Fl_Window*); 00156 bool subwindow; 00157 }; 00158 00159 extern struct Fl_XMap { 00160 RGBColor rgb; 00161 ulong pen; 00162 } *fl_current_xmap; 00163 extern FL_EXPORT Window fl_window; 00164 00165 #endif // FL_LIBRARY || FL_INTERNALS 00166 00167 extern FL_EXPORT Fl_CGContextRef fl_gc; 00168 extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar; 00169 00170 extern Window fl_xid(const Fl_Window*); 00171 void fl_clip_region(Fl_Region); 00172 00173 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); 00174 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); 00175 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); 00176 extern Fl_Offscreen fl_create_offscreen(int w, int h); 00177 extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy); 00178 extern void fl_delete_offscreen(Fl_Offscreen gWorld); 00179 extern void fl_begin_offscreen(Fl_Offscreen gWorld); 00180 extern void fl_end_offscreen(); 00181 00182 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); 00183 extern void fl_open_display(); 00184 00185 #endif // FL_DOXYGEN 00186 00195 extern void fl_open_callback(void (*cb)(const char *)); 00196 00205 extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0); 00206 00209 extern int fl_mac_os_version; 00210 00211 class Fl_Mac_App_Menu { 00212 public: 00214 static const char *about; 00219 static const char *print; 00221 static const char *services; 00223 static const char *hide; 00225 static const char *hide_others; 00227 static const char *show; 00229 static const char *quit; 00230 }; 00231 00234 // 00235 // End of "$Id: mac.H 8657 2011-05-12 11:50:43Z manolo $". 00236 // 00237