From eadd6e87f12acaccf478458f769404b5b1e6641b Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 13 Sep 2014 16:49:47 +0000 Subject: Removed several compilation warnings with OS X SDK 10.10 git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10306 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 35 ++++++++++++++++++++++++++++++----- src/fl_diamond_box.cxx | 28 ++++++++++++++-------------- 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index ffdb27ac4..5c96fb255 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -51,6 +51,7 @@ extern "C" { #include #include #include +#include #import @@ -639,9 +640,28 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data) */ - (BOOL)containsGLsubwindow; - (void)containsGLsubwindow:(BOOL)contains; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +- (NSPoint)convertBaseToScreen:(NSPoint)aPoint; +#endif @end @implementation FLWindow +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +- (NSPoint)convertBaseToScreen:(NSPoint)aPoint +{ + if (fl_mac_os_version >= 100700) { + NSRect r = [self convertRectToScreen:NSMakeRect(aPoint.x, aPoint.y, 0, 0)]; + return r.origin; + } + else { + // replaces return [super convertBaseToScreen:aPoint] that may trigger a compiler warning + typedef NSPoint (*convertIMP)(id, SEL, NSPoint); + convertIMP addr = (convertIMP)[NSWindow instanceMethodForSelector:@selector(convertBaseToScreen:)]; + return addr(self, @selector(convertBaseToScreen:), aPoint); + } +} +#endif + - (FLWindow*)initWithFl_W:(Fl_Window *)flw contentRect:(NSRect)rect styleMask:(NSUInteger)windowStyle @@ -1349,7 +1369,7 @@ static void cocoaMouseHandler(NSEvent *theEvent) */ void fl_open_callback(void (*cb)(const char *)) { fl_open_display(); - [[NSApp delegate] open_cb:cb]; + [(FLAppDelegate*)[NSApp delegate] open_cb:cb]; } @implementation FLApplication @@ -1424,8 +1444,14 @@ void fl_open_display() { { Boolean same_psn; ProcessSerialNumber front_psn; - i_am_in_front = (!GetFrontProcess( &front_psn ) && - !SameProcess( &front_psn, &cur_psn, &same_psn ) && same_psn ); + //avoid compilation warnings triggered by GetFrontProcess() and SameProcess() + void* h = dlopen(NULL, RTLD_LAZY); + typedef OSErr (*GetFrontProcess_type)(ProcessSerialNumber*); + GetFrontProcess_type GetFrontProcess_ = (GetFrontProcess_type)dlsym(h, "GetFrontProcess"); + typedef OSErr (*SameProcess_type)(ProcessSerialNumber*, ProcessSerialNumber*, Boolean*); + SameProcess_type SameProcess_ = (SameProcess_type)dlsym(h, "SameProcess"); + i_am_in_front = (!GetFrontProcess_( &front_psn ) && + !SameProcess_( &front_psn, &cur_psn, &same_psn ) && same_psn ); } if (!i_am_in_front) { // only transform the application type for unbundled apps @@ -2311,7 +2337,7 @@ static void cocoaKeyboardHandler(NSEvent *theEvent) } // Convert the rect to screen coordinates glyphRect.origin.y = wfocus->h() - glyphRect.origin.y; - glyphRect.origin = [[self window] convertBaseToScreen:glyphRect.origin]; + glyphRect.origin = [(FLWindow*)[self window] convertBaseToScreen:glyphRect.origin]; if (actualRange) *actualRange = aRange; fl_unlock_function(); return glyphRect; @@ -3845,7 +3871,6 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) this->print_widget(win, x_offset, y_offset + bt); // print the window inner part } -#include /* Returns the address of a Carbon function after dynamically loading the Carbon library if needed. Supports old Mac OS X versions that may use a couple of Carbon calls: diff --git a/src/fl_diamond_box.cxx b/src/fl_diamond_box.cxx index bc85b64f8..9aa3aad88 100644 --- a/src/fl_diamond_box.cxx +++ b/src/fl_diamond_box.cxx @@ -34,13 +34,13 @@ static void fl_diamond_up_box(int x,int y,int w,int h,Fl_Color bgcolor) { int y1 = y+h/2; fl_color(bgcolor); fl_polygon(x+3, y1, x1,y+3, x+w-3,y1, x1,y+h-3); const uchar *g = fl_gray_ramp(); - fl_color(g['W']); fl_line(x+1, y1, x1, y+1, x+w-1, y1); - fl_color(g['U']); fl_line(x+2, y1, x1, y+2, x+w-2, y1); - fl_color(g['S']); fl_line(x+3, y1, x1, y+3, x+w-3, y1); - fl_color(g['P']); fl_line(x+3, y1, x1, y+h-3, x+w-3, y1); - fl_color(g['N']); fl_line(x+2, y1, x1, y+h-2, x+w-2, y1); - fl_color(g['H']); fl_line(x+1, y1, x1, y+h-1, x+w-1, y1); - fl_color(g['A']); fl_loop(x, y1, x1, y, x+w, y1, x1, y+h); + fl_color(g[(int)'W']); fl_line(x+1, y1, x1, y+1, x+w-1, y1); + fl_color(g[(int)'U']); fl_line(x+2, y1, x1, y+2, x+w-2, y1); + fl_color(g[(int)'S']); fl_line(x+3, y1, x1, y+3, x+w-3, y1); + fl_color(g[(int)'P']); fl_line(x+3, y1, x1, y+h-3, x+w-3, y1); + fl_color(g[(int)'N']); fl_line(x+2, y1, x1, y+h-2, x+w-2, y1); + fl_color(g[(int)'H']); fl_line(x+1, y1, x1, y+h-1, x+w-1, y1); + fl_color(g[(int)'A']); fl_loop(x, y1, x1, y, x+w, y1, x1, y+h); } static void fl_diamond_down_box(int x,int y,int w,int h,Fl_Color bgcolor) { @@ -49,14 +49,14 @@ static void fl_diamond_down_box(int x,int y,int w,int h,Fl_Color bgcolor) { int x1 = x+w/2; int y1 = y+h/2; const uchar *g = fl_gray_ramp(); - fl_color(g['P']); fl_line(x+0, y1, x1, y+0, x+w-0, y1); - fl_color(g['N']); fl_line(x+1, y1, x1, y+1, x+w-1, y1); - fl_color(g['H']); fl_line(x+2, y1, x1, y+2, x+w-2, y1); - fl_color(g['W']); fl_line(x+2, y1, x1, y+h-2, x+w-2, y1); - fl_color(g['U']); fl_line(x+1, y1, x1, y+h-1, x+w-1, y1); - fl_color(g['S']); fl_line(x+0, y1, x1, y+h-0, x+w-0, y1); + fl_color(g[(int)'P']); fl_line(x+0, y1, x1, y+0, x+w-0, y1); + fl_color(g[(int)'N']); fl_line(x+1, y1, x1, y+1, x+w-1, y1); + fl_color(g[(int)'H']); fl_line(x+2, y1, x1, y+2, x+w-2, y1); + fl_color(g[(int)'W']); fl_line(x+2, y1, x1, y+h-2, x+w-2, y1); + fl_color(g[(int)'U']); fl_line(x+1, y1, x1, y+h-1, x+w-1, y1); + fl_color(g[(int)'S']); fl_line(x+0, y1, x1, y+h-0, x+w-0, y1); fl_color(bgcolor); fl_polygon(x+3, y1, x1,y+3, x+w-3,y1, x1,y+h-3); - fl_color(g['A']); fl_loop(x+3, y1, x1, y+3, x+w-3, y1, x1, y+h-3); + fl_color(g[(int)'A']); fl_loop(x+3, y1, x1, y+3, x+w-3, y1, x1, y+h-3); } extern void fl_internal_boxtype(Fl_Boxtype, Fl_Box_Draw_F*); -- cgit v1.2.3