2001-11-27 20:44:08 +03:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
2001-11-27 20:44:08 +03:00
|
|
|
//
|
|
|
|
// Mac header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2010-11-29 00:06:39 +03:00
|
|
|
// Copyright 1998-2010 by Bill Spitzak and others.
|
2001-11-27 20:44:08 +03:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
2001-11-27 20:44:08 +03:00
|
|
|
//
|
|
|
|
|
|
|
|
// Do not directly include this file, instead use <FL/x.H>. It will
|
|
|
|
// include this file if "__APPLE__" is defined. This is to encourage
|
|
|
|
// portability of even the system-specific code...
|
2008-09-18 23:09:34 +04:00
|
|
|
#ifndef FL_DOXYGEN
|
2001-11-27 20:44:08 +03:00
|
|
|
|
2008-09-18 23:09:34 +04:00
|
|
|
#if !defined(Fl_X_H)
|
2002-06-07 19:06:32 +04:00
|
|
|
# error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
|
|
|
|
#endif // !Fl_X_H
|
2001-11-27 20:44:08 +03:00
|
|
|
|
|
|
|
// Standard MacOS Carbon API includes...
|
2002-06-07 19:06:32 +04:00
|
|
|
#include <Carbon/Carbon.h>
|
2009-12-09 02:15:30 +03:00
|
|
|
|
|
|
|
#ifndef MAC_OS_X_VERSION_10_3
|
|
|
|
#define MAC_OS_X_VERSION_10_3 1030
|
|
|
|
#endif
|
|
|
|
#ifndef MAC_OS_X_VERSION_10_4
|
|
|
|
#define MAC_OS_X_VERSION_10_4 1040
|
|
|
|
#endif
|
|
|
|
#ifndef MAC_OS_X_VERSION_10_5
|
|
|
|
#define MAC_OS_X_VERSION_10_5 1050
|
|
|
|
#endif
|
|
|
|
#ifndef MAC_OS_X_VERSION_10_6
|
|
|
|
#define MAC_OS_X_VERSION_10_6 1060
|
|
|
|
#endif
|
|
|
|
#ifndef MAC_OS_X_VERSION_MAX_ALLOWED
|
|
|
|
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
|
|
|
|
#if defined(__LP64__) && __LP64__
|
|
|
|
typedef double CGFloat;
|
|
|
|
#else
|
2009-12-07 01:21:55 +03:00
|
|
|
typedef float CGFloat;
|
|
|
|
#endif
|
2010-01-30 00:16:20 +03:00
|
|
|
#endif // CGFLOAT_DEFINED
|
2009-12-09 02:15:30 +03:00
|
|
|
|
2001-11-27 20:44:08 +03:00
|
|
|
|
|
|
|
// Now make some fixes to the headers...
|
2002-06-07 19:06:32 +04:00
|
|
|
#undef check // Dunno where this comes from...
|
2001-11-27 20:44:08 +03:00
|
|
|
|
|
|
|
// Some random X equivalents
|
|
|
|
struct XPoint { int x, y; };
|
|
|
|
struct XRectangle {int x, y, width, height;};
|
2009-12-07 01:21:55 +03:00
|
|
|
|
2010-01-30 00:16:20 +03:00
|
|
|
typedef void *Window; // this is really a pter to the subclass FLWindow of NSWindow
|
|
|
|
typedef struct flCocoaRegion {
|
2009-12-07 01:21:55 +03:00
|
|
|
int count;
|
|
|
|
CGRect *rects;
|
|
|
|
} *Fl_Region; // a region is the union of a series of rectangles
|
2010-03-14 21:07:24 +03:00
|
|
|
extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h);
|
|
|
|
|
2009-12-07 01:21:55 +03:00
|
|
|
inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
|
|
|
|
Fl_Region R = (Fl_Region)malloc(sizeof(*R));
|
|
|
|
R->count = 1;
|
|
|
|
R->rects = (CGRect *)malloc(sizeof(CGRect));
|
2010-03-14 21:07:24 +03:00
|
|
|
*(R->rects) = fl_cgrectmake_cocoa(x, y, w, h);
|
2009-12-07 01:21:55 +03:00
|
|
|
return R;
|
|
|
|
}
|
|
|
|
inline void XDestroyRegion(Fl_Region r) {
|
|
|
|
if(r) {
|
|
|
|
free(r->rects);
|
|
|
|
free(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extern void *fl_default_cursor;
|
|
|
|
extern void *fl_system_menu;
|
|
|
|
typedef CGContextRef Fl_Offscreen;
|
|
|
|
typedef CGImageRef Fl_Bitmask;
|
|
|
|
|
|
|
|
void fl_clip_region(Fl_Region);
|
2001-11-27 20:44:08 +03:00
|
|
|
|
|
|
|
# include "Fl_Window.H"
|
|
|
|
|
|
|
|
// This object contains all mac-specific stuff about a window:
|
|
|
|
// WARNING: this object is highly subject to change!
|
|
|
|
class Fl_X
|
|
|
|
{
|
|
|
|
public:
|
2010-12-19 01:31:01 +03:00
|
|
|
Window xid; // pointer to the Cocoa window object (FLWindow*)
|
2009-12-07 01:21:55 +03:00
|
|
|
Fl_Offscreen other_xid; // pointer for offscreen bitmaps (doublebuffer)
|
2002-01-03 11:08:21 +03:00
|
|
|
Fl_Window *w; // FLTK window for
|
2001-11-27 20:44:08 +03:00
|
|
|
Fl_Region region;
|
2002-01-03 11:08:21 +03:00
|
|
|
Fl_Region subRegion; // region for this specific subwindow
|
|
|
|
Fl_X *next; // linked tree to support subwindows
|
|
|
|
Fl_X *xidChildren, *xidNext; // more subwindow tree
|
2001-11-27 20:44:08 +03:00
|
|
|
int wait_for_expose;
|
2010-12-19 01:31:01 +03:00
|
|
|
void *cursor; // is really NSCursor*
|
2001-11-27 20:44:08 +03:00
|
|
|
static Fl_X* first;
|
|
|
|
static Fl_X* i(const Fl_Window* w) {return w->i;}
|
|
|
|
static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
|
|
|
|
static void make(Fl_Window*);
|
|
|
|
void flush();
|
2004-08-28 00:02:45 +04:00
|
|
|
// Quartz additions:
|
|
|
|
CGContextRef gc; // graphics context (NULL when using QD)
|
|
|
|
static void q_fill_context(); // fill a Quartz context with current FLTK state
|
|
|
|
static void q_clear_clipping(); // remove all clipping from a Quartz context
|
|
|
|
static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc
|
2004-09-01 02:00:49 +04:00
|
|
|
static void q_begin_image(CGRect&, int x, int y, int w, int h);
|
2004-08-31 04:27:40 +04:00
|
|
|
static void q_end_image();
|
2010-12-19 01:31:01 +03:00
|
|
|
// Cocoa additions
|
|
|
|
void destroy(void);
|
|
|
|
void map(void);
|
|
|
|
void unmap(void);
|
|
|
|
int unlink(Fl_X* start = NULL);
|
|
|
|
void collapse(void);
|
|
|
|
WindowRef window_ref(void);
|
|
|
|
void contains_GL_subwindow(void);
|
|
|
|
void set_key_window(void);
|
|
|
|
void set_cursor(Fl_Cursor);
|
|
|
|
static int screen_init(XRectangle screens[]);
|
|
|
|
static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
|
|
|
|
static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
|
|
|
|
static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h);
|
|
|
|
static CGContextRef watch_cursor_image(void);
|
|
|
|
static CGContextRef help_cursor_image(void);
|
|
|
|
static CGContextRef nesw_cursor_image(void);
|
|
|
|
static CGContextRef nwse_cursor_image(void);
|
|
|
|
static CGContextRef none_cursor_image(void);
|
|
|
|
private:
|
|
|
|
static void relink(Fl_Window*, Fl_Window*);
|
2001-11-27 20:44:08 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
inline Window fl_xid(const Fl_Window*w)
|
|
|
|
{
|
|
|
|
return Fl_X::i(w)->xid;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern struct Fl_XMap {
|
|
|
|
RGBColor rgb;
|
|
|
|
ulong pen;
|
|
|
|
} *fl_current_xmap;
|
|
|
|
|
2001-12-18 14:00:09 +03:00
|
|
|
extern FL_EXPORT void *fl_display;
|
2001-11-27 20:44:08 +03:00
|
|
|
extern FL_EXPORT Window fl_window;
|
2004-08-26 04:18:43 +04:00
|
|
|
extern FL_EXPORT CGContextRef fl_gc;
|
2001-11-27 20:44:08 +03:00
|
|
|
extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
|
|
|
|
|
|
|
|
|
|
|
|
extern Fl_Offscreen fl_create_offscreen(int w, int h);
|
|
|
|
extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy);
|
|
|
|
extern void fl_delete_offscreen(Fl_Offscreen gWorld);
|
|
|
|
extern void fl_begin_offscreen(Fl_Offscreen gWorld);
|
|
|
|
extern void fl_end_offscreen();
|
|
|
|
|
|
|
|
|
|
|
|
extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
|
2002-04-15 16:19:01 +04:00
|
|
|
extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
|
2001-11-27 20:44:08 +03:00
|
|
|
extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
|
|
|
|
|
|
|
|
extern void fl_open_display();
|
|
|
|
|
|
|
|
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
|
2008-09-18 23:09:34 +04:00
|
|
|
#endif // FL_DOXYGEN
|
2010-03-16 17:47:40 +03:00
|
|
|
|
|
|
|
/** \defgroup group_macosx Mac OS X-specific functions
|
2010-12-01 20:48:59 +03:00
|
|
|
Mac OS X-specific functions declared in <FL/x.H> or <FL/gl.h>
|
2010-03-16 17:47:40 +03:00
|
|
|
@{ */
|
|
|
|
|
2010-07-01 20:51:28 +04:00
|
|
|
/** @brief Register a function called for each file dropped onto an application icon
|
|
|
|
*/
|
|
|
|
extern void fl_open_callback(void (*cb)(const char *));
|
|
|
|
|
2010-03-16 17:47:40 +03:00
|
|
|
/**
|
2010-07-01 20:51:28 +04:00
|
|
|
* \brief Attaches a callback to the "About myprog" item of the system application menu.
|
2010-03-16 17:47:40 +03:00
|
|
|
*
|
|
|
|
* \param cb a callback that will be called by "About myprog" menu item
|
|
|
|
* with NULL 1st argument.
|
|
|
|
* \param user_data a pointer transmitted as 2nd argument to the callback.
|
|
|
|
* \param shortcut optional shortcut to attach to the "About myprog" menu item (e.g., FL_META+'a')
|
|
|
|
*/
|
|
|
|
extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0);
|
2010-11-25 21:21:21 +03:00
|
|
|
|
2010-12-01 20:38:29 +03:00
|
|
|
/** \brief The version number of the running Mac OS X (e.g., 0x1064 for 10.6.4)
|
2010-11-25 21:21:21 +03:00
|
|
|
*/
|
|
|
|
extern int fl_mac_os_version;
|
|
|
|
|
2010-03-16 17:47:40 +03:00
|
|
|
/** @} */
|
|
|
|
|
2001-11-27 20:44:08 +03:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
2001-11-27 20:44:08 +03:00
|
|
|
//
|
|
|
|
|