mirror of
https://github.com/fltk/fltk.git
synced 2026-05-22 07:01:34 +08:00
Mac OS: replaced several global functions by new member functions of Mac OS-specific Fl_X class.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8055 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -103,7 +103,7 @@ void fl_clip_region(Fl_Region);
|
||||
class Fl_X
|
||||
{
|
||||
public:
|
||||
Window xid; // Cocoa: FLWindow* ; Carbon: WindowRef
|
||||
Window xid; // pointer to the Cocoa window object (FLWindow*)
|
||||
Fl_Offscreen other_xid; // pointer for offscreen bitmaps (doublebuffer)
|
||||
Fl_Window *w; // FLTK window for
|
||||
Fl_Region region;
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
Fl_X *next; // linked tree to support subwindows
|
||||
Fl_X *xidChildren, *xidNext; // more subwindow tree
|
||||
int wait_for_expose;
|
||||
void *cursor; // is really NSCursor*
|
||||
void *cursor; // is really NSCursor*
|
||||
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&);
|
||||
@@ -124,17 +124,29 @@ public:
|
||||
static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc
|
||||
static void q_begin_image(CGRect&, int x, int y, int w, int h);
|
||||
static void q_end_image();
|
||||
// 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*);
|
||||
};
|
||||
|
||||
extern void MacDestroyWindow(Fl_Window*,void *);
|
||||
extern void MacMapWindow(Fl_Window*,void *);
|
||||
extern void MacUnmapWindow(Fl_Window*,void *);
|
||||
extern WindowRef MACwindowRef(Fl_Window *w);
|
||||
extern Fl_Region MacRectRegionIntersect(Fl_Region current, int x,int y,int w, int h);
|
||||
extern void MacCollapseWindow(Window w);
|
||||
|
||||
extern int MacUnlinkWindow(Fl_X*,Fl_X*start=0L);
|
||||
|
||||
inline Window fl_xid(const Fl_Window*w)
|
||||
{
|
||||
return Fl_X::i(w)->xid;
|
||||
|
||||
+6
-6
@@ -60,7 +60,7 @@ void fl_cleanup_pens(void);
|
||||
void fl_release_dc(HWND,HDC);
|
||||
void fl_cleanup_dc_list(void);
|
||||
#elif defined(__APPLE__)
|
||||
extern double fl_MAC_flush_and_wait(double time_to_wait, char in_idle);
|
||||
extern double fl_mac_flush_and_wait(double time_to_wait, char in_idle);
|
||||
#endif // WIN32
|
||||
|
||||
//
|
||||
@@ -418,7 +418,7 @@ double Fl::wait(double time_to_wait) {
|
||||
// the idle function may turn off idle, we can then wait:
|
||||
if (idle) time_to_wait = 0.0;
|
||||
}
|
||||
return fl_MAC_flush_and_wait(time_to_wait, in_idle);
|
||||
return fl_mac_flush_and_wait(time_to_wait, in_idle);
|
||||
|
||||
#else
|
||||
|
||||
@@ -1218,7 +1218,7 @@ void Fl_Window::hide() {
|
||||
for (; *pp != ip; pp = &(*pp)->next) if (!*pp) return;
|
||||
*pp = ip->next;
|
||||
#ifdef __APPLE__
|
||||
MacUnlinkWindow(ip);
|
||||
ip->unlink();
|
||||
// MacOS X manages a single pointer per application. Make sure that hiding
|
||||
// a toplevel window will not leave us with some random pointer shape, or
|
||||
// worst case, an invisible pointer
|
||||
@@ -1291,7 +1291,7 @@ void Fl_Window::hide() {
|
||||
}
|
||||
XDestroyWindow(fl_display, ip->xid);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
MacDestroyWindow(this, ip->xid);
|
||||
ip->destroy();
|
||||
#else
|
||||
# error unsupported platform
|
||||
#endif
|
||||
@@ -1329,7 +1329,7 @@ int Fl_Window::handle(int ev)
|
||||
#if defined(USE_X11) || defined(WIN32)
|
||||
XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
MacMapWindow(this, i->xid);
|
||||
i->map();
|
||||
#else
|
||||
# error unsupported platform
|
||||
#endif // __APPLE__
|
||||
@@ -1351,7 +1351,7 @@ int Fl_Window::handle(int ev)
|
||||
#if defined(USE_X11) || defined(WIN32)
|
||||
XUnmapWindow(fl_display, fl_xid(this));
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
MacUnmapWindow(this, i->xid);
|
||||
i->unmap();
|
||||
#else
|
||||
# error platform unsupported
|
||||
#endif
|
||||
|
||||
@@ -312,17 +312,17 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if __LP64__
|
||||
// 64 bit version
|
||||
aglSetWindowRef(context, MACwindowRef(window) );
|
||||
aglSetWindowRef(context, Fl_X::i(window)->window_ref()/*fl_mac_windowref(window)*/ );
|
||||
#else
|
||||
// 32 bit version >= 10.5
|
||||
if (aglSetWindowRef != NULL)
|
||||
aglSetWindowRef(context, MACwindowRef(window) );
|
||||
aglSetWindowRef(context, Fl_X::i(window)->window_ref()/*fl_mac_windowref(window)*/ );
|
||||
else
|
||||
aglSetDrawable( context, GetWindowPort( MACwindowRef(window) ) );
|
||||
aglSetDrawable( context, GetWindowPort( Fl_X::i(window)->window_ref()/*fl_mac_windowref(window)*/ ) );
|
||||
#endif
|
||||
#else
|
||||
// 32 bit version < 10.5
|
||||
aglSetDrawable( context, GetWindowPort( MACwindowRef(window) ) );
|
||||
aglSetDrawable( context, GetWindowPort( Fl_X::i(window)->window_ref()/*fl_mac_windowref(window)*/ ) );
|
||||
#endif
|
||||
return (context);
|
||||
}
|
||||
@@ -352,17 +352,17 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
#if __LP64__
|
||||
// 64 bit version
|
||||
aglSetWindowRef(context, MACwindowRef(w) );
|
||||
aglSetWindowRef(context, Fl_X::i(w)->window_ref()/*fl_mac_windowref(w)*/ );
|
||||
#else
|
||||
// 32 bit version >= 10.5
|
||||
if (aglSetWindowRef != NULL)
|
||||
aglSetWindowRef(context, MACwindowRef(w) );
|
||||
aglSetWindowRef(context, Fl_X::i(w)->window_ref()/*fl_mac_windowref(w)*/ );
|
||||
else
|
||||
aglSetDrawable( context, GetWindowPort( MACwindowRef(w) ) );
|
||||
aglSetDrawable( context, GetWindowPort( Fl_X::i(w)->window_ref()/*fl_mac_windowref(w)*/ ) );
|
||||
#endif
|
||||
#else
|
||||
// 32 bit version < 10.5
|
||||
aglSetDrawable( context, GetWindowPort( MACwindowRef(w) ) );
|
||||
aglSetDrawable( context, GetWindowPort( Fl_X::i(w)->window_ref()/*fl_mac_windowref(w)*/ ) );
|
||||
#endif
|
||||
aglSetCurrentContext(context);
|
||||
# else
|
||||
|
||||
@@ -91,9 +91,8 @@ void Fl_Gl_Window::show() {
|
||||
Fl_X::make_xid(this, g->vis, g->colormap);
|
||||
if (overlay && overlay != this) ((Fl_Gl_Window*)overlay)->show();
|
||||
#elif defined(__APPLE__)
|
||||
extern void MACsetContainsGLsubwindow(Fl_Window *);
|
||||
if( ! parent() ) need_redraw=1;
|
||||
else MACsetContainsGLsubwindow( window() );
|
||||
else Fl_X::i(window())->contains_GL_subwindow();
|
||||
#endif
|
||||
}
|
||||
Fl_Window::show();
|
||||
@@ -278,7 +277,7 @@ void Fl_Gl_Window::flush() {
|
||||
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
|
||||
//: clear previous clipping in this shared port
|
||||
#if ! __LP64__
|
||||
GrafPtr port = GetWindowPort( MACwindowRef(this) );
|
||||
GrafPtr port = GetWindowPort( Fl_X::i(this)->window_ref() );
|
||||
Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
|
||||
GrafPtr old; GetPort( &old );
|
||||
SetPort( port );
|
||||
|
||||
@@ -37,7 +37,7 @@ void Fl_Window::iconize() {
|
||||
#ifdef WIN32
|
||||
ShowWindow(i->xid, SW_SHOWMINNOACTIVE);
|
||||
#elif defined(__APPLE__)
|
||||
MacCollapseWindow((Window)i->xid);
|
||||
i->collapse();
|
||||
#else
|
||||
XIconifyWindow(fl_display, i->xid, fl_screen);
|
||||
#endif
|
||||
|
||||
+53
-77
@@ -105,11 +105,6 @@ typedef unsigned int NSUInteger;
|
||||
// external functions
|
||||
extern void fl_fix_focus();
|
||||
extern Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h);
|
||||
extern CGContextRef CreateWatchImage(void);
|
||||
extern CGContextRef CreateHelpImage(void);
|
||||
extern CGContextRef CreateNESWImage(void);
|
||||
extern CGContextRef CreateNWSEImage(void);
|
||||
extern CGContextRef CreateNoneImage(void);
|
||||
|
||||
// forward definition of functions in this file
|
||||
// converting cr lf converter function
|
||||
@@ -703,7 +698,7 @@ int fl_wait( double time )
|
||||
return (got_events);
|
||||
}
|
||||
|
||||
double fl_MAC_flush_and_wait(double time_to_wait, char in_idle) {
|
||||
double fl_mac_flush_and_wait(double time_to_wait, char in_idle) {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
Fl::flush();
|
||||
if (Fl::idle && !in_idle) // 'idle' may have been set within flush()
|
||||
@@ -728,7 +723,7 @@ static void update_e_xy_and_e_xy_root(NSWindow *nsw)
|
||||
/*
|
||||
* Cocoa Mousewheel handler
|
||||
*/
|
||||
void cocoaMouseWheelHandler(NSEvent *theEvent)
|
||||
static void cocoaMouseWheelHandler(NSEvent *theEvent)
|
||||
{
|
||||
// Handle the new "MightyMouse" mouse wheel events. Please, someone explain
|
||||
// to me why Apple changed the API on this even though the current API
|
||||
@@ -885,7 +880,7 @@ static void calc_e_text(CFStringRef s, char *buffer, size_t len, unsigned sym)
|
||||
|
||||
|
||||
// this gets called by CJK character palette input
|
||||
OSStatus carbonTextHandler( EventHandlerCallRef nextHandler, EventRef event, void *unused )
|
||||
static OSStatus carbonTextHandler( EventHandlerCallRef nextHandler, EventRef event, void *unused )
|
||||
{
|
||||
// make sure the key window is an FLTK window
|
||||
NSWindow *keywindow = [NSApp keyWindow];
|
||||
@@ -923,7 +918,7 @@ OSStatus carbonTextHandler( EventHandlerCallRef nextHandler, EventRef event, voi
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSStatus cocoaKeyboardHandler(NSEvent *theEvent);
|
||||
static OSStatus cocoaKeyboardHandler(NSEvent *theEvent);
|
||||
|
||||
@interface FLTextView : NSTextView
|
||||
{
|
||||
@@ -973,7 +968,7 @@ Events during a character composition sequence:
|
||||
replace the temporary character by this one
|
||||
- keyup -> [theEvent characters] contains the standard character
|
||||
*/
|
||||
OSStatus cocoaKeyboardHandler(NSEvent *theEvent)
|
||||
static OSStatus cocoaKeyboardHandler(NSEvent *theEvent)
|
||||
{
|
||||
static char buffer[32];
|
||||
int sendEvent = 0, retval = 0;
|
||||
@@ -1363,8 +1358,7 @@ void fl_open_display() {
|
||||
beenHereDoneThat = 1;
|
||||
|
||||
[FLApplication sharedApplication];
|
||||
NSAutoreleasePool *localPool;
|
||||
localPool = [[NSAutoreleasePool alloc] init];
|
||||
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init]; // never released
|
||||
mydelegate = [[FLDelegate alloc] init];
|
||||
[NSApp setDelegate:mydelegate];
|
||||
[NSApp finishLaunching];
|
||||
@@ -2277,22 +2271,6 @@ void Fl_X::q_release_context(Fl_X *x) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* the former implementation
|
||||
void Fl_X::q_begin_image(CGRect &rect, int cx, int cy, int w, int h) {
|
||||
CGContextSaveGState(fl_gc);
|
||||
CGAffineTransform mx = CGContextGetCTM(fl_gc);
|
||||
CGRect r2 = rect;
|
||||
r2.origin.x -= 0.5f;
|
||||
r2.origin.y -= 0.5f;
|
||||
CGContextClipToRect(fl_gc, r2);
|
||||
mx.d = -1.0; mx.tx = -mx.tx;
|
||||
CGContextConcatCTM(fl_gc, mx);
|
||||
rect.origin.x = -(mx.tx+0.5f) + rect.origin.x - cx;
|
||||
rect.origin.y = (mx.ty+0.5f) - rect.origin.y - h + cy;
|
||||
rect.size.width = w;
|
||||
rect.size.height = h;
|
||||
}
|
||||
*/
|
||||
void Fl_X::q_begin_image(CGRect &rect, int cx, int cy, int w, int h) {
|
||||
CGContextSaveGState(fl_gc);
|
||||
CGRect r2 = rect;
|
||||
@@ -2518,35 +2496,36 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data)
|
||||
}
|
||||
}
|
||||
|
||||
int MacUnlinkWindow(Fl_X *ip, Fl_X *start) {
|
||||
if (!ip) return 0;
|
||||
int Fl_X::unlink(Fl_X *start) {
|
||||
if (start) {
|
||||
Fl_X *pc = start;
|
||||
while (pc) {
|
||||
if (pc->xidNext == ip) {
|
||||
pc->xidNext = ip->xidNext;
|
||||
if (pc->xidNext == this) {
|
||||
pc->xidNext = xidNext;
|
||||
return 1;
|
||||
}
|
||||
if (pc->xidChildren) {
|
||||
if (pc->xidChildren == ip) {
|
||||
pc->xidChildren = ip->xidNext;
|
||||
if (pc->xidChildren == this) {
|
||||
pc->xidChildren = xidNext;
|
||||
return 1;
|
||||
}
|
||||
if (MacUnlinkWindow(ip, pc->xidChildren))
|
||||
if (unlink(pc->xidChildren))
|
||||
return 1;
|
||||
}
|
||||
pc = pc->xidNext;
|
||||
}
|
||||
} else {
|
||||
for ( Fl_X *pc = Fl_X::first; pc; pc = pc->next ) {
|
||||
if (MacUnlinkWindow(ip, pc))
|
||||
if (unlink(pc))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void MacRelinkWindow(Fl_X *x, Fl_X *p) {
|
||||
void Fl_X::relink(Fl_Window *w, Fl_Window *wp) {
|
||||
Fl_X *x = Fl_X::i(w);
|
||||
Fl_X *p = Fl_X::i(wp);
|
||||
if (!x || !p) return;
|
||||
// first, check if 'x' is already registered as a child of 'p'
|
||||
for (Fl_X *i = p->xidChildren; i; i=i->xidNext) {
|
||||
@@ -2557,35 +2536,35 @@ static void MacRelinkWindow(Fl_X *x, Fl_X *p) {
|
||||
p->xidChildren = x;
|
||||
}
|
||||
|
||||
void MacDestroyWindow(Fl_Window *w, void *p) {
|
||||
if (w && !w->parent() && p) {
|
||||
[[(NSWindow *)p contentView] release];
|
||||
[(NSWindow *)p close];
|
||||
void Fl_X::destroy() {
|
||||
if (w && !w->parent() && xid) {
|
||||
[[(NSWindow *)xid contentView] release];
|
||||
[(NSWindow *)xid close];
|
||||
}
|
||||
}
|
||||
|
||||
void MacMapWindow(Fl_Window *w, void *p) {
|
||||
if (w && p) {
|
||||
[(NSWindow *)p orderFront:nil];
|
||||
void Fl_X::map() {
|
||||
if (w && xid) {
|
||||
[(NSWindow *)xid orderFront:nil];
|
||||
}
|
||||
//+ link to window list
|
||||
if (w && w->parent()) {
|
||||
MacRelinkWindow(Fl_X::i(w), Fl_X::i(w->window()));
|
||||
Fl_X::relink(w, w->window() );
|
||||
w->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void MacUnmapWindow(Fl_Window *w, void *p) {
|
||||
if (w && !w->parent() && p) {
|
||||
[(NSWindow *)p orderOut:nil];
|
||||
void Fl_X::unmap() {
|
||||
if (w && !w->parent() && xid) {
|
||||
[(NSWindow *)xid orderOut:nil];
|
||||
}
|
||||
if (w && Fl_X::i(w))
|
||||
MacUnlinkWindow(Fl_X::i(w));
|
||||
Fl_X::i(w)->unlink();
|
||||
}
|
||||
|
||||
|
||||
// removes x,y,w,h rectangle from region r and returns result as a new Fl_Region
|
||||
static Fl_Region MacRegionMinusRect(Fl_Region r, int x,int y,int w,int h)
|
||||
/* removes x,y,w,h rectangle from region r and returns result as a new Fl_Region
|
||||
*/
|
||||
{
|
||||
Fl_Region outr = (Fl_Region)malloc(sizeof(*outr));
|
||||
outr->rects = (CGRect*)malloc(4 * r->count * sizeof(CGRect));
|
||||
@@ -2630,9 +2609,8 @@ static Fl_Region MacRegionMinusRect(Fl_Region r, int x,int y,int w,int h)
|
||||
return outr;
|
||||
}
|
||||
|
||||
Fl_Region MacRectRegionIntersect(Fl_Region current, int x,int y,int w, int h)
|
||||
/* intersects current and x,y,w,h rectangle and returns result as a new Fl_Region
|
||||
*/
|
||||
// intersects current and x,y,w,h rectangle and returns result as a new Fl_Region
|
||||
Fl_Region Fl_X::intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h)
|
||||
{
|
||||
if (current == NULL) return XRectangleRegion(x,y,w,h);
|
||||
CGRect r = fl_cgrectmake_cocoa(x, y, w, h);
|
||||
@@ -2655,9 +2633,8 @@ Fl_Region MacRectRegionIntersect(Fl_Region current, int x,int y,int w, int h)
|
||||
return outr;
|
||||
}
|
||||
|
||||
void MacCollapseWindow(Window w)
|
||||
{
|
||||
[(NSWindow*)w miniaturize:nil];
|
||||
void Fl_X::collapse() {
|
||||
[(NSWindow *)xid miniaturize:nil];
|
||||
}
|
||||
|
||||
static NSImage *CGBitmapContextToNSImage(CGContextRef c)
|
||||
@@ -2691,14 +2668,14 @@ static NSCursor *PrepareCursor(NSCursor *cursor, CGContextRef (*f)() )
|
||||
return cursor;
|
||||
}
|
||||
|
||||
void *MACSetCursor(Fl_Cursor c)
|
||||
void Fl_X::set_cursor(Fl_Cursor c)
|
||||
{
|
||||
NSCursor *icrsr;
|
||||
switch (c) {
|
||||
case FL_CURSOR_CROSS: icrsr = [NSCursor crosshairCursor]; break;
|
||||
case FL_CURSOR_WAIT:
|
||||
static NSCursor *watch = nil;
|
||||
watch = PrepareCursor(watch, CreateWatchImage);
|
||||
watch = PrepareCursor(watch, &Fl_X::watch_cursor_image);
|
||||
icrsr = watch;
|
||||
break;
|
||||
case FL_CURSOR_INSERT: icrsr = [NSCursor IBeamCursor]; break;
|
||||
@@ -2707,7 +2684,7 @@ void *MACSetCursor(Fl_Cursor c)
|
||||
case FL_CURSOR_NS: icrsr = [NSCursor resizeUpDownCursor]; break;
|
||||
case FL_CURSOR_HELP:
|
||||
static NSCursor *help = nil;
|
||||
help = PrepareCursor(help, CreateHelpImage);
|
||||
help = PrepareCursor(help, &Fl_X::help_cursor_image);
|
||||
icrsr = help;
|
||||
break;
|
||||
case FL_CURSOR_HAND: icrsr = [NSCursor pointingHandCursor]; break;
|
||||
@@ -2716,7 +2693,7 @@ void *MACSetCursor(Fl_Cursor c)
|
||||
case FL_CURSOR_SW:
|
||||
case FL_CURSOR_NESW:
|
||||
static NSCursor *nesw = nil;
|
||||
nesw = PrepareCursor(nesw, CreateNESWImage);
|
||||
nesw = PrepareCursor(nesw, &Fl_X::nesw_cursor_image);
|
||||
icrsr = nesw;
|
||||
break;
|
||||
case FL_CURSOR_E: icrsr = [NSCursor resizeRightCursor]; break;
|
||||
@@ -2726,12 +2703,12 @@ void *MACSetCursor(Fl_Cursor c)
|
||||
case FL_CURSOR_NW:
|
||||
case FL_CURSOR_NWSE:
|
||||
static NSCursor *nwse = nil;
|
||||
nwse = PrepareCursor(nwse, CreateNWSEImage);
|
||||
nwse = PrepareCursor(nwse, &Fl_X::nwse_cursor_image);
|
||||
icrsr = nwse;
|
||||
break;
|
||||
case FL_CURSOR_NONE:
|
||||
static NSCursor *none = nil;
|
||||
none = PrepareCursor(none, CreateNoneImage);
|
||||
none = PrepareCursor(none, &Fl_X::none_cursor_image);
|
||||
icrsr = none;
|
||||
break;
|
||||
case FL_CURSOR_ARROW:
|
||||
@@ -2740,13 +2717,12 @@ void *MACSetCursor(Fl_Cursor c)
|
||||
break;
|
||||
}
|
||||
[icrsr set];
|
||||
return icrsr;
|
||||
cursor = icrsr;
|
||||
}
|
||||
|
||||
int MACscreen_init(XRectangle screens[])
|
||||
int Fl_X::screen_init(XRectangle screens[])
|
||||
{
|
||||
NSAutoreleasePool *localPool;
|
||||
localPool = [[NSAutoreleasePool alloc] init];
|
||||
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
|
||||
NSArray *a = [NSScreen screens];
|
||||
int count = (int)[a count];
|
||||
NSRect r;
|
||||
@@ -3101,9 +3077,9 @@ void *Fl_Sys_Menu_Bar::doMenuOrItemOperation(Fl_Sys_Menu_Bar::menuOrItemOperatio
|
||||
return retval;
|
||||
}
|
||||
|
||||
void MACsetkeywindow(void *nsw)
|
||||
void Fl_X::set_key_window()
|
||||
{
|
||||
[(NSWindow*)nsw makeKeyAndOrderFront:nil];
|
||||
[(NSWindow*)xid makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
static NSImage *imageFromText(const char *text, int *pwidth, int *pheight)
|
||||
@@ -3170,7 +3146,7 @@ static NSImage *defaultDragImage(int *pwidth, int *pheight)
|
||||
return image;
|
||||
}
|
||||
|
||||
int MACpreparedrag(void)
|
||||
int Fl::dnd(void)
|
||||
{
|
||||
CFDataRef text = CFDataCreate(kCFAllocatorDefault, (UInt8*)fl_selection_buffer[0], fl_selection_length[0]);
|
||||
if (text==NULL) return false;
|
||||
@@ -3216,7 +3192,7 @@ int MACpreparedrag(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned char *MACbitmapFromRectOfWindow(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel)
|
||||
unsigned char *Fl_X::bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel)
|
||||
// delete the returned pointer after use
|
||||
{
|
||||
while(win->window()) {
|
||||
@@ -3257,11 +3233,11 @@ void imgProviderReleaseData (void *info, const void *data, size_t size)
|
||||
delete (unsigned char *)data;
|
||||
}
|
||||
|
||||
CGImageRef MAC_CGImageFromRectOfWindow(Fl_Window *win, int x, int y, int w, int h)
|
||||
CGImageRef Fl_X::CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h)
|
||||
// CFRelease the returned CGImageRef after use
|
||||
{
|
||||
int bpp;
|
||||
unsigned char *bitmap = MACbitmapFromRectOfWindow(win, x, y, w, h, &bpp);
|
||||
unsigned char *bitmap = bitmap_from_window_rect(win, x, y, w, h, &bpp);
|
||||
CGImageRef img;
|
||||
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
|
||||
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, bitmap, w*h*bpp, imgProviderReleaseData);
|
||||
@@ -3273,14 +3249,14 @@ CGImageRef MAC_CGImageFromRectOfWindow(Fl_Window *win, int x, int y, int w, int
|
||||
return img;
|
||||
}
|
||||
|
||||
void MACsetContainsGLsubwindow(Fl_Window *w)
|
||||
void Fl_X::contains_GL_subwindow()
|
||||
{
|
||||
[(FLWindow*)Fl_X::i(w)->xid setContainsGLsubwindow:YES];
|
||||
[(FLWindow*)xid setContainsGLsubwindow:YES];
|
||||
}
|
||||
|
||||
WindowRef MACwindowRef(Fl_Window *w)
|
||||
WindowRef Fl_X::window_ref()
|
||||
{
|
||||
return (WindowRef)[(FLWindow*)Fl_X::i(w)->xid windowRef];
|
||||
return (WindowRef)[(FLWindow*)xid windowRef];
|
||||
}
|
||||
|
||||
// so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes
|
||||
|
||||
+1
-2
@@ -47,7 +47,6 @@ extern HWND fl_capture;
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
extern void MACsetkeywindow(void *nsw);
|
||||
extern void *fl_capture;
|
||||
#endif
|
||||
|
||||
@@ -59,7 +58,7 @@ void Fl::grab(Fl_Window* win) {
|
||||
SetCapture(fl_capture);
|
||||
#elif defined(__APPLE__)
|
||||
fl_capture = Fl_X::i(first_window())->xid;
|
||||
MACsetkeywindow(fl_capture);
|
||||
Fl_X::i(first_window())->set_key_window();
|
||||
#else
|
||||
XGrabPointer(fl_display,
|
||||
fl_xid(first_window()),
|
||||
|
||||
+6
-10
@@ -134,11 +134,10 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color c1, Fl_Color c2) {
|
||||
# error "Either __LITTLE_ENDIAN__ or __BIG_ENDIAN__ must be defined"
|
||||
#endif
|
||||
|
||||
extern void *MACSetCursor(Fl_Cursor c);
|
||||
extern Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h);
|
||||
|
||||
|
||||
CGContextRef CreateHelpImage(void)
|
||||
CGContextRef Fl_X::help_cursor_image(void)
|
||||
{
|
||||
int w = 20, h = 20;
|
||||
Fl_Offscreen off = fl_create_offscreen_with_alpha(w, h);
|
||||
@@ -152,7 +151,7 @@ CGContextRef CreateHelpImage(void)
|
||||
return (CGContextRef)off;
|
||||
}
|
||||
|
||||
CGContextRef CreateNoneImage(void)
|
||||
CGContextRef Fl_X::none_cursor_image(void)
|
||||
{
|
||||
int w = 20, h = 20;
|
||||
Fl_Offscreen off = fl_create_offscreen_with_alpha(w, h);
|
||||
@@ -163,7 +162,7 @@ CGContextRef CreateNoneImage(void)
|
||||
return (CGContextRef)off;
|
||||
}
|
||||
|
||||
CGContextRef CreateWatchImage(void)
|
||||
CGContextRef Fl_X::watch_cursor_image(void)
|
||||
{
|
||||
int w, h, r = 5;
|
||||
w = 2*r+6;
|
||||
@@ -188,7 +187,7 @@ CGContextRef CreateWatchImage(void)
|
||||
return (CGContextRef)off;
|
||||
}
|
||||
|
||||
CGContextRef CreateNESWImage(void)
|
||||
CGContextRef Fl_X::nesw_cursor_image(void)
|
||||
{
|
||||
int c = 7, r = 2*c;
|
||||
int w = r, h = r;
|
||||
@@ -208,7 +207,7 @@ CGContextRef CreateNESWImage(void)
|
||||
return (CGContextRef)off;
|
||||
}
|
||||
|
||||
CGContextRef CreateNWSEImage(void)
|
||||
CGContextRef Fl_X::nwse_cursor_image(void)
|
||||
{
|
||||
int c = 7, r = 2*c;
|
||||
int w = r, h = r;
|
||||
@@ -232,10 +231,7 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color, Fl_Color) {
|
||||
if (c == FL_CURSOR_DEFAULT) {
|
||||
c = cursor_default;
|
||||
}
|
||||
void *cursor = MACSetCursor( c );
|
||||
if (i) {
|
||||
i->cursor = cursor;
|
||||
}
|
||||
if (i) i->set_cursor(c);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
#ifdef WIN32
|
||||
# include "fl_dnd_win32.cxx"
|
||||
#elif defined(__APPLE__)
|
||||
# include "fl_dnd_mac.cxx"
|
||||
//# include "fl_dnd_mac.cxx"
|
||||
#else
|
||||
# include "fl_dnd_x.cxx"
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -30,11 +30,11 @@
|
||||
|
||||
#include <FL/Fl.H>
|
||||
|
||||
extern int MACpreparedrag(void);
|
||||
extern int fl_mac_prepare_drag(void);
|
||||
|
||||
int Fl::dnd()
|
||||
{
|
||||
return MACpreparedrag();
|
||||
return fl_mac_prepare_drag();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
//
|
||||
|
||||
#include <config.h>
|
||||
extern unsigned char *MACbitmapFromRectOfWindow(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
|
||||
|
||||
//
|
||||
// 'fl_read_image()' - Read an image from the current window or off-screen buffer.
|
||||
@@ -54,7 +53,7 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
||||
else { // reading from current window
|
||||
Fl_Window *window = Fl_Window::current();
|
||||
while(window->window()) window = window->window();
|
||||
base = MACbitmapFromRectOfWindow(window,x,y,w,h,&delta);
|
||||
base = Fl_X::bitmap_from_window_rect(window,x,y,w,h,&delta);
|
||||
rowBytes = delta*w;
|
||||
x = y = 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -580,7 +580,7 @@ void Fl_Graphics_Driver::push_clip(int x, int y, int w, int h) {
|
||||
CombineRgn(r,r,current,RGN_AND);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
XDestroyRegion(r);
|
||||
r = MacRectRegionIntersect(current, x,y,w,h);
|
||||
r = Fl_X::intersect_region_and_rect(current, x,y,w,h);
|
||||
#else
|
||||
# error unsupported platform
|
||||
#endif
|
||||
|
||||
@@ -151,8 +151,7 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
|
||||
BitBlt(fl_gc, dest_x, dest_y, src_w, src_h, fl_gc, src_x, src_y,SRCCOPY);
|
||||
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
extern CGImageRef MAC_CGImageFromRectOfWindow(Fl_Window*, int x, int y, int w, int h);
|
||||
CGImageRef img = MAC_CGImageFromRectOfWindow(Fl_Window::current(), src_x, src_y, src_w, src_h);
|
||||
CGImageRef img = Fl_X::CGImage_from_window_rect(Fl_Window::current(), src_x, src_y, src_w, src_h);
|
||||
CGRect rect = { { dest_x, dest_y }, { src_w, src_h } };
|
||||
Fl_X::q_begin_image(rect, 0, 0, src_w, src_h);
|
||||
CGContextDrawImage(fl_gc, rect, img);
|
||||
|
||||
+1
-2
@@ -107,9 +107,8 @@ static void screen_init() {
|
||||
#elif defined(__APPLE__)
|
||||
XRectangle screens[16];
|
||||
|
||||
extern int MACscreen_init(XRectangle screens[]);
|
||||
static void screen_init() {
|
||||
num_screens = MACscreen_init(screens);
|
||||
num_screens = Fl_X::screen_init(screens);
|
||||
}
|
||||
#elif HAVE_XINERAMA
|
||||
# include <X11/extensions/Xinerama.h>
|
||||
|
||||
Reference in New Issue
Block a user