Author: manolo
Date: 2011-11-12 05:06:54 -0800 (Sat, 12 Nov 2011)
New Revision: 9170
Log:
Mac OS: more accurate definition of the Window system-specific type.

Modified:
   branches/branch-1.3/FL/mac.H
   branches/branch-1.3/src/Fl_cocoa.mm

Modified: branches/branch-1.3/FL/mac.H
===================================================================
--- branches/branch-1.3/FL/mac.H        2011-11-11 11:58:28 UTC (rev 9169)
+++ branches/branch-1.3/FL/mac.H        2011-11-12 13:06:54 UTC (rev 9170)
@@ -25,7 +25,12 @@
 #  error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
 #endif // !Fl_X_H
 
-typedef void* Window;      // this is really a pointer to the subclass 
FLWindow of NSWindow
+#ifdef __OBJC__
+@class FLWindow; // a subclass of the NSWindow Cocoa class
+typedef FLWindow *Window;
+#else
+typedef class FLWindow_opaque *Window; // pointer to the FLWindow objective-c 
class
+#endif // __OBJC__
 
 #if !(defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part is used when 
compiling an application program
 #  include <FL/Fl_Widget.H>

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2011-11-11 11:58:28 UTC (rev 9169)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2011-11-12 13:06:54 UTC (rev 9170)
@@ -1028,7 +1028,7 @@
       w = Fl::next_window(w);
       }
     if (w) {
-      [(FLWindow*)Fl_X::i(w)->xid makeKeyWindow];
+      [Fl_X::i(w)->xid makeKeyWindow];
     }
   }
   fl_unlock_function();
@@ -1059,7 +1059,7 @@
   Fl_X *x;
   FLWindow *top = 0, *topModal = 0, *topNonModal = 0;
   for (x = Fl_X::first;x;x = x->next) {
-    FLWindow *cw = (FLWindow*)x->xid;
+    FLWindow *cw = x->xid;
     Fl_Window *win = x->w;
     if (win && cw && [cw isVisible]) {
       if (win->modal()) {
@@ -1107,7 +1107,7 @@
   FLWindow *top = 0;
   // sort in all regular windows
   for (x = Fl_X::first;x;x = x->next) {
-    FLWindow *cw = (FLWindow*)x->xid;
+    FLWindow *cw = x->xid;
     Fl_Window *win = x->w;
     if (win && cw) {
       if (win->modal()) {
@@ -1119,7 +1119,7 @@
   }
   // now sort in all modals
   for (x = Fl_X::first;x;x = x->next) {
-    FLWindow *cw = (FLWindow*)x->xid;
+    FLWindow *cw = x->xid;
     Fl_Window *win = x->w;
     if (win && cw && [cw isVisible]) {
       if (win->modal()) {
@@ -1130,7 +1130,7 @@
   }
   // finally all non-modals
   for (x = Fl_X::first;x;x = x->next) {
-    FLWindow *cw = (FLWindow*)x->xid;
+    FLWindow *cw = x->xid;
     Fl_Window *win = x->w;
     if (win && cw && [cw isVisible]) {
       if (win->non_modal()) {
@@ -1991,7 +1991,7 @@
     }
     if (w->as_gl_window()) { // if creating a sub-GL-window
       while (win->window()) win = win->window();
-      [(FLWindow*)Fl_X::i(win)->xid setContainsGLsubwindow:YES];
+      [Fl_X::i(win)->xid setContainsGLsubwindow:YES];
     }
     fl_show_iconic = 0;
   }
@@ -2153,8 +2153,8 @@
   NSSize minSize = { minw, minh + bt };
   NSSize maxSize = { maxw?maxw:32000, maxh?maxh + bt:32000 };
   if (i && i->xid) {
-    [(NSWindow*)i->xid setMinSize:minSize];
-    [(NSWindow*)i->xid setMaxSize:maxSize];
+    [i->xid setMinSize:minSize];
+    [i->xid setMaxSize:maxSize];
   }
 }
 
@@ -2187,8 +2187,7 @@
   Fl_Widget::label(name);
   iconlabel_ = mininame;
   if (shown() || i) {
-    NSWindow* nsw = (NSWindow*)i->xid;
-    q_set_window_title(nsw, name, mininame);
+    q_set_window_title(i->xid, name, mininame);
   }
 }
 
@@ -2209,12 +2208,12 @@
     Fl_X::make(this);
   } else {
     if ( !parent() ) {
-      if ([(NSWindow*)i->xid isMiniaturized]) {
+      if ([i->xid isMiniaturized]) {
        i->w->redraw();
-       [(NSWindow*)i->xid deminiaturize:nil];
+       [i->xid deminiaturize:nil];
       }
       if (!fl_capture) {
-       [(NSWindow*)i->xid makeKeyAndOrderFront:nil];
+       [i->xid makeKeyAndOrderFront:nil];
       }
     }
   }
@@ -2251,12 +2250,12 @@
       dim.origin.y = main_screen_height - (Y + H);
       dim.size.width = W;
       dim.size.height = H + bt;
-      [(NSWindow*)i->xid setFrame:dim display:YES];
+      [i->xid setFrame:dim display:YES];
     } else {
       NSPoint pt; 
       pt.x = X; 
       pt.y = main_screen_height - (Y + h());
-      [(NSWindow*)i->xid setFrameOrigin:pt];
+      [i->xid setFrameOrigin:pt];
     }
   }
   resize_from_system = 0;
@@ -2293,7 +2292,7 @@
   NSView *current_focus = [NSView focusView]; 
   // sometimes current_focus is set to a non-FLTK view: don't touch that
   if ( [current_focus isKindOfClass:[FLView class]] ) [current_focus 
unlockFocus];
-  [[(NSWindow*)i->xid contentView]  lockFocus];
+  [[i->xid contentView]  lockFocus];
   i->gc = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   fl_gc = i->gc;
   Fl_Region fl_window_region = XRectangleRegion(0,0,w(),h());
@@ -2310,7 +2309,7 @@
   // and escapes even clipping!!!
   // it gets activated when needed (e.g., draw text)
   CGContextSetShouldAntialias(fl_gc, false);  
-  CGFloat hgt = [[(NSWindow*)fl_window contentView] frame].size.height;
+  CGFloat hgt = [[fl_window contentView] frame].size.height;
   CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f);
   CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the 
window
   win = this;
@@ -2637,18 +2636,18 @@
 void Fl_X::destroy() {
   // subwindows share their xid with their parent window, so should not close 
it
   if (!subwindow && w && !w->parent() && xid) {
-    NSView *topview = [(NSWindow *)xid contentView]; 
+    NSView *topview = [xid contentView]; 
     if ( [NSView focusView] == topview ) {
       [topview unlockFocus];
     }
     [topview release];
-    [(NSWindow *)xid close];
+    [xid close];
   }
 }
 
 void Fl_X::map() {
   if (w && xid) {
-    [(NSWindow *)xid orderFront:nil];
+    [xid orderFront:nil];
   }
   //+ link to window list
   if (w && w->parent()) {
@@ -2659,7 +2658,7 @@
 
 void Fl_X::unmap() {
   if (w && !w->parent() && xid) {
-    [(NSWindow *)xid orderOut:nil];
+    [xid orderOut:nil];
   }
   if (w && Fl_X::i(w)) 
     Fl_X::i(w)->unlink();
@@ -2737,7 +2736,7 @@
 }
 
 void Fl_X::collapse() {
-  [(NSWindow *)xid miniaturize:nil];
+  [xid miniaturize:nil];
 }
 
 static NSImage *CGBitmapContextToNSImage(CGContextRef c)
@@ -3184,7 +3183,7 @@
 
 void Fl_X::set_key_window()
 {
-  [(NSWindow*)xid makeKeyWindow];
+  [xid makeKeyWindow];
 }
 
 static NSImage *imageFromText(const char *text, int *pwidth, int *pheight)
@@ -3268,7 +3267,7 @@
   } else { 
     while(win->window()) win = win->window();
   }
-  NSView *myview = [(NSWindow*)Fl_X::i(win)->xid contentView];
+  NSView *myview = [Fl_X::i(win)->xid contentView];
   NSEvent *theEvent = [NSApp currentEvent];
   
   int width, height;
@@ -3356,7 +3355,7 @@
 
 WindowRef Fl_X::window_ref()
 {
-  return (WindowRef)[(FLWindow*)xid windowRef];
+  return (WindowRef)[xid windowRef];
 }
 
 // so a CGRect matches exactly what is denoted x,y,w,h for clipping purposes

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to