fltk/FL/mac.H
Manolo Gouy 9f78323574 Move GL-related static member functions of the Fl_X class on Mac OS to class Fl_Cocoa_Screen_Driver.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11662 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2016-04-19 16:58:17 +00:00

191 lines
5.4 KiB
Objective-C

//
// "$Id$"
//
// Mac header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2016 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
// 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...
#ifndef FL_DOXYGEN
#if !defined(Fl_X_H)
# error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
#endif // !Fl_X_H
#ifdef __OBJC__
@class FLWindow; // a subclass of the NSWindow Cocoa class
typedef FLWindow *Window;
#else
typedef class FLWindow *Window; // pointer to the FLWindow objective-c class
#endif // __OBJC__
#include <FL/Fl_System_Driver.H>
#include <FL/Fl_Widget.H> // for Fl_Callback
#if (defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part must be compiled when building the FLTK libraries
// Standard MacOS C/C++ includes...
#include <ApplicationServices/ApplicationServices.h>
#undef check // because of Fl::check()
#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_10_7
#define MAC_OS_X_VERSION_10_7 1070
#endif
#ifndef MAC_OS_X_VERSION_10_8
#define MAC_OS_X_VERSION_10_8 1080
#endif
#ifndef MAC_OS_X_VERSION_10_9
#define MAC_OS_X_VERSION_10_9 1090
#endif
#ifndef MAC_OS_X_VERSION_10_10
#define MAC_OS_X_VERSION_10_10 101000
#endif
#ifndef MAC_OS_X_VERSION_10_11
#define MAC_OS_X_VERSION_10_11 101100
#endif
#ifndef NSINTEGER_DEFINED // appears with 10.5 in NSObjCRuntime.h
#if defined(__LP64__) && __LP64__
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
typedef CGImageAlphaInfo CGBitmapInfo;
#endif
struct flCocoaRegion {
int count;
CGRect *rects;
}; // a region is the union of a series of rectangles
# include <FL/Fl_Window.H>
#ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
#if defined(__LP64__) && __LP64__
typedef double CGFloat;
#else
typedef float CGFloat;
#endif
#endif // CGFLOAT_DEFINED
// This object contains all mac-specific stuff about a window:
// WARNING: this object is highly subject to change!
class Fl_X {
public:
Window xid; // pointer to the Cocoa window object (FLWindow*)
Fl_Window *w; // FLTK window for
Fl_Region region;
Fl_X *next; // chain of mapped windows
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;}
};
extern Window fl_window;
#endif // FL_LIBRARY || FL_INTERNALS
extern CGContextRef fl_gc;
extern Window fl_xid(const Fl_Window*);
extern Fl_Window* fl_find(Window xid);
extern Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
extern Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
extern void fl_delete_bitmask(Fl_Bitmask bm);
extern int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
extern void fl_open_display();
#endif // FL_DOXYGEN
/** \file
Mac OS X-specific symbols.
*/
/** \defgroup group_macosx Mac OS X-specific symbols
Mac OS X-specific symbols declared in <FL/x.H> or <FL/gl.h>
\sa \ref osissues_macos
@{ */
/** @brief Register a function called for each file dropped onto an application icon.
\e cb will be called with a single Unix-style file name and path.
If multiple files were dropped, \e cb will be called multiple times.
*/
extern void fl_open_callback(void (*cb)(const char *));
/**
* \brief Attaches a callback to the "About myprog" item of the system application menu.
*
* \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);
/** \brief The version number of the running Mac OS X (e.g., 100604 for 10.6.4)
*/
extern int fl_mac_os_version;
/** The system menu bar.
*/
extern class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
struct Fl_Menu_Item;
class Fl_Mac_App_Menu {
public:
/** Localizable text for the "About xxx" application menu item */
static const char *about;
/** Localizable text for the "Print Front Window" application menu item.
This menu item won't be displayed if Fl_Mac_App_Menu::print
is set to an empty string.
*/
static const char *print;
/** Localizable text for the "Services" application menu item */
static const char *services;
/** Localizable text for the "Hide xxx" application menu item */
static const char *hide;
/** Localizable text for the "Hide Others" application menu item */
static const char *hide_others;
/** Localizable text for the "Show All" application menu item */
static const char *show;
/** Localizable text for the "Quit xxx" application menu item */
static const char *quit;
static void custom_application_menu_items(const Fl_Menu_Item *m);
};
/** @} */
//
// End of "$Id$".
//