#ifndef FL_COCOA_WINDOW_DRIVER_H
#define FL_COCOA_WINDOW_DRIVER_H
#include "../../Fl_Window_Driver.H"
#include <FL/Fl_Plugin.H>
#include <ApplicationServices/ApplicationServices.h>
class Fl_Image;
class Fl_Window;
#ifdef __OBJC__
@class CALayer;
@class NSCursor;
@class NSImage;
@class FLWindow;
@class NSOpenGLContext;
@class NSOpenGLPixelFormat;
@class NSView;
@class NSWindow;
#else
class CALayer;
class NSCursor;
class NSImage;
class FLWindow;
class NSOpenGLContext;
class NSOpenGLPixelFormat;
class NSView;
class NSWindow;
#endif
class Fl_Cocoa_Window_Driver : public Fl_Window_Driver
{
private:
struct shape_data_type {
Fl_Image* shape_; CGImageRef mask;
} *shape_data_;
void shape_bitmap_(Fl_Image* b);
void shape_alpha_(Fl_Image* img, int offset) FL_OVERRIDE;
CGRect* subRect_; unsigned window_flags_;
public:
Fl_Cocoa_Window_Driver(Fl_Window*);
~Fl_Cocoa_Window_Driver();
static inline Fl_Cocoa_Window_Driver* driver(const Fl_Window *w) {return (Fl_Cocoa_Window_Driver*)Fl_Window_Driver::driver(w);}
CGContextRef gc; NSCursor *cursor;
static void q_release_context(Fl_Cocoa_Window_Driver *x = 0); static void clip_to_rounded_corners(CGContextRef gc, int w, int h);
static CGImageRef capture_decorated_window_10_5(NSWindow *nswin);
void set_key_window();
bool mapped_to_retina(); void mapped_to_retina(bool); bool changed_resolution(); void changed_resolution(bool); bool view_resized(); void view_resized(bool b); bool through_resize(); void through_resize(bool b); CGRect* subRect() { return subRect_; } void subRect(CGRect *r) { subRect_ = r; } static void destroy(FLWindow*);
CGImageRef CGImage_from_window_rect(int x, int y, int w, int h, bool capture_subwins = true);
int decorated_w() FL_OVERRIDE;
int decorated_h() FL_OVERRIDE;
const Fl_Image* shape() FL_OVERRIDE;
void makeWindow() FL_OVERRIDE;
void take_focus() FL_OVERRIDE;
void flush() FL_OVERRIDE;
void flush_overlay() FL_OVERRIDE;
void draw_begin() FL_OVERRIDE;
void draw_end() FL_OVERRIDE;
void make_current() FL_OVERRIDE;
void label(const char *name, const char *mininame) FL_OVERRIDE;
void show() FL_OVERRIDE;
void resize(int X,int Y,int W,int H) FL_OVERRIDE;
void hide() FL_OVERRIDE;
void map() FL_OVERRIDE;
void unmap() FL_OVERRIDE;
void fullscreen_on() FL_OVERRIDE;
void fullscreen_off(int X, int Y, int W, int H) FL_OVERRIDE;
void fullscreen_screens(bool on_off) FL_OVERRIDE;
void maximize() FL_OVERRIDE;
void un_maximize() FL_OVERRIDE;
void use_border() FL_OVERRIDE;
void size_range() FL_OVERRIDE;
void iconize() FL_OVERRIDE;
void decoration_sizes(int *top, int *left, int *right, int *bottom) FL_OVERRIDE;
int set_cursor(Fl_Cursor) FL_OVERRIDE;
int set_cursor(const Fl_RGB_Image*, int, int) FL_OVERRIDE;
void shape(const Fl_Image* img) FL_OVERRIDE;
void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right) FL_OVERRIDE;
void wait_for_expose() FL_OVERRIDE;
void draw_titlebar_to_context(CGContextRef gc, int w, int h);
int scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, void (*draw_area)(void*, int,int,int,int), void* data) FL_OVERRIDE;
void icons(const Fl_RGB_Image *icons[], int count) FL_OVERRIDE;
NSImage *icon_image;
fl_uintptr_t os_id() FL_OVERRIDE;
};
class Fl_Cocoa_Plugin : public Fl_Plugin {
public:
Fl_Cocoa_Plugin(const char *pluginName) : Fl_Plugin(klass(), pluginName) { }
virtual const char *klass() { return "fltk:cocoa"; }
virtual const char *name() = 0;
virtual void resize(Fl_Gl_Window *glw, int x, int y, int w, int h) = 0;
};
#endif