FLTK logo

[Library] r9037 - in branches/branch-3.0: include/fltk3 src/fltk3

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[Library] r9037 - in branches/branch-3.0: include/fltk3 src/fltk3 fltk-dev Sep 15, 2011  
 
Author: manolo
Date: 2011-09-15 05:25:11 -0700 (Thu, 15 Sep 2011)
New Revision: 9037
Log:
Transferred to branch-3.0 all changes in branch-1.3/src and branch-1.3/FL until r9035.

Modified:
   branches/branch-3.0/include/fltk3/PostScript.h
   branches/branch-3.0/include/fltk3/Printer.h
   branches/branch-3.0/include/fltk3/RoundButton.h
   branches/branch-3.0/include/fltk3/osx.h
   branches/branch-3.0/src/fltk3/cocoa.mm
   branches/branch-3.0/src/fltk3/cocoaNativeFileChooser.mm
   branches/branch-3.0/src/fltk3/cocoaQuartzPrinter.mm

Modified: branches/branch-3.0/include/fltk3/PostScript.h
===================================================================
--- branches/branch-3.0/include/fltk3/PostScript.h	2011-09-14 15:19:20 UTC (rev 9036)
+++ branches/branch-3.0/include/fltk3/PostScript.h	2011-09-15 12:25:11 UTC (rev 9037)
@@ -217,7 +217,7 @@
    */
   class FLTK3_EXPORT PostScriptFileDevice : public fltk3::PagedDevice {
 #ifdef __APPLE__
-    Fl_CGContextRef gc;
+    CGContextRef gc;
 #endif
   protected:
     fltk3::PostScriptGraphicsDriver *driver();

Modified: branches/branch-3.0/include/fltk3/Printer.h
===================================================================
--- branches/branch-3.0/include/fltk3/Printer.h	2011-09-14 15:19:20 UTC (rev 9036)
+++ branches/branch-3.0/include/fltk3/Printer.h	2011-09-15 12:25:11 UTC (rev 9037)
@@ -65,9 +65,9 @@
     float scale_x;
     float scale_y;
     float angle; // rotation angle in radians
-    Fl_PMPrintSession  printSession;
-    Fl_PMPageFormat    pageFormat;
-    Fl_PMPrintSettings printSettings;
+    PMPrintSession  printSession;
+    PMPageFormat    pageFormat;
+    PMPrintSettings printSettings;
 #elif defined(WIN32)
     int   abortPrint;
     PRINTDLG      pd;

Modified: branches/branch-3.0/include/fltk3/RoundButton.h
===================================================================
--- branches/branch-3.0/include/fltk3/RoundButton.h	2011-09-14 15:19:20 UTC (rev 9036)
+++ branches/branch-3.0/include/fltk3/RoundButton.h	2011-09-15 12:25:11 UTC (rev 9037)
@@ -45,7 +45,7 @@
    turning on a light, rather than drawing pushed in.  The shape of the
    "light" is initially set to fltk3::ROUND_DOWN_BOX.  The color of the light
    when on is controlled with selection_color(), which defaults to
-   fltk3::RED.
+   fltk3::FOREGROUND_COLOR.
    */
   class FLTK3_EXPORT RoundButton : public LightButton {
   public:

Modified: branches/branch-3.0/include/fltk3/osx.h
===================================================================
--- branches/branch-3.0/include/fltk3/osx.h	2011-09-14 15:19:20 UTC (rev 9036)
+++ branches/branch-3.0/include/fltk3/osx.h	2011-09-15 12:25:11 UTC (rev 9037)
@@ -33,38 +33,23 @@
 #if !defined(Fltk3_X_H)
 #  error "Never use <fltk3/osx.h> directly; include <fltk3/x.h> instead."
 #endif // !Fltk3_X_H
-#include <fltk3/Widget.h>
 
 typedef void* Window;	    // this is really a pointer to the subclass FLWindow of NSWindow
 
-namespace fltk3 {
-  typedef void* Offscreen; // this is really a CGContextRef
-  typedef void* Bitmask;   // this is really a CGImageRef
-}
-
-#include <AvailabilityMacros.h>
-#ifndef MAC_OS_X_VERSION_10_3
-#define MAC_OS_X_VERSION_10_3 1030
-#endif
-#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
-
 #if !(defined(FL_LIBRARY) || defined(FLTK3_INTERNALS)) // this part is used when compiling an application program
+#include <fltk3/Widget.h>
 
 namespace fltk3 {
-  typedef void* Region;
+  typedef struct flCocoaRegion* Region;
 }
-typedef void* Fl_CGContextRef;
-typedef void* Fl_PMPrintSettings;
-typedef void* Fl_PMPageFormat;
-typedef void* Fl_PMPrintSession;
+typedef struct CGContext* CGContextRef;
+typedef struct OpaquePMPrintSettings*   PMPrintSettings;
+typedef struct OpaquePMPageFormat*      PMPageFormat;
+typedef struct OpaquePMPrintSession*    PMPrintSession;
+typedef struct CGImage* CGImageRef;
+namespace fltk3 {
+  typedef CGContextRef Offscreen;
+  }
 
 #else // this part must be compiled when building the FLTK libraries
 
@@ -72,12 +57,8 @@
 #include <ApplicationServices/ApplicationServices.h>
 #undef check // because of fltk3::check()
 
-typedef CGContextRef	Fl_CGContextRef;
-typedef PMPrintSettings Fl_PMPrintSettings;
-typedef PMPageFormat	Fl_PMPageFormat;
-typedef PMPrintSession	Fl_PMPrintSession;
-
 namespace fltk3 {
+  typedef CGContextRef Offscreen;
   typedef struct flCocoaRegion {
     int count;
     CGRect *rects;
@@ -167,32 +148,48 @@
   RGBColor rgb;
   ulong pen;
 } *fl_current_xmap;
-extern FLTK3_EXPORT Window fl_window;
+extern Window fl_window;
 
 #endif // FL_LIBRARY || FLTK3_INTERNALS
 
-extern FLTK3_EXPORT Fl_CGContextRef fl_gc;
+#ifndef MAC_OS_X_VERSION_10_3
+#define MAC_OS_X_VERSION_10_3 1030
+#endif
+#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
 
 namespace fltk3 {
-  extern FLTK3_EXPORT class SysMenuBar *sys_menu_bar;
+  typedef CGImageRef Bitmask;
+  }
+
+extern CGContextRef fl_gc;
+namespace fltk3 {
+  extern class SysMenuBar *sys_menu_bar;
 }
 
 extern Window fl_xid(const fltk3::Window*);
-
+extern fltk3::Window* fl_find(Window xid);
 namespace fltk3 {
   void clip_region(fltk3::Region);
 }
 
-extern FLTK3_EXPORT fltk3::Bitmask fl_create_bitmask(int w, int h, const uchar *data);
-extern FLTK3_EXPORT fltk3::Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
-extern FLTK3_EXPORT void fl_delete_bitmask(fltk3::Bitmask bm);
+extern fltk3::Bitmask fl_create_bitmask(int w, int h, const uchar *data);
+extern fltk3::Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
+extern void fl_delete_bitmask(fltk3::Bitmask bm);
 extern fltk3::Offscreen fl_create_offscreen(int w, int h);
 extern void fl_copy_offscreen(int x,int y,int w,int h, fltk3::Offscreen gWorld, int srcx,int srcy);
 extern void fl_delete_offscreen(fltk3::Offscreen gWorld);
 extern void fl_begin_offscreen(fltk3::Offscreen gWorld);
 extern void fl_end_offscreen();
 
-extern FLTK3_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
+extern int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
 extern void fl_open_display();
 
 #endif // FLTK3_DOXYGEN

Modified: branches/branch-3.0/src/fltk3/cocoa.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoa.mm	2011-09-14 15:19:20 UTC (rev 9036)
+++ branches/branch-3.0/src/fltk3/cocoa.mm	2011-09-15 12:25:11 UTC (rev 9037)
@@ -5,21 +5,12 @@
 //
 // Copyright 1998-2011 by Bill Spitzak and others.
 //
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
+// 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:
 //
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Library General Public License for more details.
+//     http://www.fltk.org/COPYING.php
 //
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
 // Please report all bugs and problems on the following page:
 //
 //     http://www.fltk.org/str.php
@@ -904,61 +895,12 @@
 
 static void	(*open_cb)(const char *) = 0;
 
-
 /*
  * Install an open documents event handler...
  */
-@interface FLAppleEventHandler : NSObject
-{
-}
-- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
-@end
-@implementation FLAppleEventHandler
-- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent
-{
-  NSAppleEventDescriptor *single = [event descriptorAtIndex:1];
-  const AEDesc *document = [single aeDesc];
-  long i, n;
-  FSRef fileRef;
-  AEKeyword keyWd;
-  DescType typeCd;
-  Size actSz;
-  char filename[1024];
-  // Lock access to FLTK in this thread...
-  fl_lock_function();
-  
-  // Open the documents via the callback...
-  if (AECountItems(document, &n) == noErr) {
-    for (i = 1; i <= n; i ++) {
-      AEGetNthPtr(document, i, typeFSRef, &keyWd, &typeCd,
-                  (Ptr)&fileRef, sizeof(fileRef),
-                  (actSz = sizeof(fileRef), &actSz));
-      FSRefMakePath( &fileRef, (UInt8*)filename, sizeof(filename) );
-      
-      (*open_cb)(filename);
-    }
-  }
-  // Unlock access to FLTK for all threads...
-  fl_unlock_function();
-}
-@end
-
 void fl_open_callback(void (*cb)(const char *)) {
-  static NSAppleEventManager *aeventmgr = nil;
-  static FLAppleEventHandler *handler;
   fl_open_display();
-  if (!aeventmgr) {
-    aeventmgr = [NSAppleEventManager sharedAppleEventManager];
-    handler = [[FLAppleEventHandler alloc] init];
-  }
-  
   open_cb = cb;
-  if (cb) {
-    [aeventmgr setEventHandler:handler andSelector:@selector(handleAppleEvent:withReplyEvent:) 
-                 forEventClass:kCoreEventClass andEventID:kAEOpenDocuments];
-  } else {
-    [aeventmgr removeEventHandlerForEventClass:kCoreEventClass andEventID:kAEOpenDocuments];  
-  }
 }
 
 
@@ -993,6 +935,7 @@
 - (void)applicationWillHide:(NSNotification *)notify;
 - (void)applicationWillUnhide:(NSNotification *)notify;
 - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client;
+- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
 @end
 @implementation FLDelegate
 - (void)windowDidMove:(NSNotification *)notif
@@ -1128,7 +1071,7 @@
   for (x = Fl_X::first;x;x = x->next) {
     FLWindow *cw = (FLWindow*)x->xid;
     fltk3::Window *win = x->w;
-    if (win && cw) {
+    if (win && cw && [cw isVisible]) {
       if (win->modal()) {
         [cw setLevel:NSModalPanelWindowLevel];
         if (topModal) 
@@ -1172,7 +1115,7 @@
   for (x = Fl_X::first;x;x = x->next) {
     FLWindow *cw = (FLWindow*)x->xid;
     fltk3::Window *win = x->w;
-    if (win && cw) {
+    if (win && cw && [cw isVisible]) {
       if (win->modal()) {
         [cw setLevel:NSNormalWindowLevel];
         if (top) [cw orderWindow:NSWindowAbove relativeTo:[top windowNumber]];
@@ -1183,7 +1126,7 @@
   for (x = Fl_X::first;x;x = x->next) {
     FLWindow *cw = (FLWindow*)x->xid;
     fltk3::Window *win = x->w;
-    if (win && cw) {
+    if (win && cw && [cw isVisible]) {
       if (win->non_modal()) {
         [cw setLevel:NSNormalWindowLevel];
         if (top) [cw orderWindow:NSWindowAbove relativeTo:[top windowNumber]];
@@ -1209,7 +1152,6 @@
   for (x = Fl_X::first;x;x = x->next) {
     fltk3::Window *w = x->w;
     if ( !w->parent() ) {
-      if ( w->border() || (!w->modal() && !w->tooltip_window()) ) fltk3::handle( fltk3::FOCUS, w);
       fltk3::handle( fltk3::SHOW, w);
       }
   }
@@ -1227,6 +1169,16 @@
   }
   return nil;
 }
+- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
+{
+  if (open_cb) {
+    fl_lock_function();
+    (*open_cb)([filename UTF8String]);
+    fl_unlock_function();
+    return YES;
+  }
+  return NO;
+}
 @end
 
 @implementation FLApplication
@@ -2674,7 +2626,11 @@
 void Fl_X::destroy() {
   // subwindows share their xid with their parent window, so should not close it
   if (!subwindow && w && !w->parent() && xid) {
-    [[(NSWindow *)xid contentView] release];
+    NSView *topview = [(NSWindow *)xid contentView]; 
+    if ( [NSView focusView] == topview ) {
+      [topview unlockFocus];
+    }
+    [topview release];
     [(NSWindow *)xid close];
   }
 }
@@ -2893,6 +2849,7 @@
     scale = (float)w/win->w();
     if ((float)h/wh < scale) scale = (float)h/wh;
     printer.scale(scale);
+    printer.printable_rect(&w, &h);
   }
 //#define ROTATE 1
 #ifdef ROTATE
@@ -2900,10 +2857,10 @@
   printer.printable_rect(&w, &h);
   printer.origin(w/2, h/2 );
   printer.rotate(20.);
-  printer.print_window( win, - win->w()/2, - win->h()/2 );
 #else
-  printer.print_window(win);
+  printer.origin(w/2, h/2);
 #endif
+  printer.print_window( win, - ww/2, - wh/2 );
   printer.end_page();
   printer.end_job();
   fl_unlock_function();

Modified: branches/branch-3.0/src/fltk3/cocoaNativeFileChooser.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoaNativeFileChooser.mm	2011-09-14 15:19:20 UTC (rev 9036)
+++ branches/branch-3.0/src/fltk3/cocoaNativeFileChooser.mm	2011-09-15 12:25:11 UTC (rev 9037)
@@ -129,8 +129,6 @@
   // POST BROWSER
   int err = post();
 
-  _filt_total = 0;
-
   return(err);
 }
 
@@ -408,7 +406,7 @@
     }
     rank++;
     *(q++) = '\n'; 
-    if (*p) p = r + 1;
+    if (*r) p = r + 1; else p = r;
   } while(*p);
   *q = 0;
   return t;
@@ -609,6 +607,7 @@
     }
     if (_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory];
     if (_filt_total) {
+      if (_filt_value >= _filt_total) _filt_value = _filt_total - 1;
       char *t = prepareMacFilter(_filt_total, _filter, _filt_patt);
       popup = createPopupAccessory((NSSavePanel*)_panel, t, [[(NSSavePanel*)_panel nameFieldLabel] UTF8String], _filt_value);
       delete[] t;

Modified: branches/branch-3.0/src/fltk3/cocoaQuartzPrinter.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoaQuartzPrinter.mm	2011-09-14 15:19:20 UTC (rev 9036)
+++ branches/branch-3.0/src/fltk3/cocoaQuartzPrinter.mm	2011-09-15 12:25:11 UTC (rev 9037)
@@ -51,35 +51,30 @@
 //returns 0 iff OK
 {
   OSStatus status = 0;
+  fl_open_display();
   Fl_X::q_release_context();
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-  if( [NSPrintPanel instancesRespondToSelector:@selector(runModalWithPrintInfo:)] &&
-     [NSPrintInfo instancesRespondToSelector:@selector(PMPrintSession)] ) {
-    NSAutoreleasePool *localPool;
-    localPool = [[NSAutoreleasePool alloc] init]; 
+  if (fl_mac_os_version >= 100500) {
     NSPrintInfo *info = [NSPrintInfo sharedPrintInfo];
-    NSPageLayout *layout = [NSPageLayout pageLayout];
-    NSInteger retval = [layout runModal];
-    if(retval == NSOKButton) {
-      NSPrintPanel *panel = [NSPrintPanel printPanel];
-      retval = (NSInteger)[panel runModalWithPrintInfo:info];//from 10.5 only
-    }
+    NSPrintPanel *panel = [NSPrintPanel printPanel];
+    //from 10.5
+    [panel setOptions:NSPrintPanelShowsCopies | NSPrintPanelShowsPageRange | NSPrintPanelShowsPageSetupAccessory];
+    NSInteger retval = [panel runModalWithPrintInfo:info];//from 10.5
     if(retval != NSOKButton) {
-      fltk3::first_window()->show();
-      [localPool release];
+      fltk3::Window *w = fltk3::first_window();
+      if (w) w->show();
       return 1;
     }
-    printSession = (PMPrintSession)[info PMPrintSession];
-    pageFormat = (PMPageFormat)[info PMPageFormat];
-    printSettings = (PMPrintSettings)[info PMPrintSettings];
+    printSession = (PMPrintSession)[info PMPrintSession];//from 10.5
+    pageFormat = (PMPageFormat)[info PMPageFormat];//from 10.5
+    printSettings = (PMPrintSettings)[info PMPrintSettings];//from 10.5
     UInt32 from32, to32;
     PMGetFirstPage(printSettings, &from32); 
     if (frompage) *frompage = (int)from32;
     PMGetLastPage(printSettings, &to32); 
     if (topage) *topage = (int)to32;
     if(topage && *topage > pagecount) *topage = pagecount;
-    status = PMSessionBeginCGDocumentNoDialog(printSession, printSettings, pageFormat);
-    [localPool release];
+    status = PMSessionBeginCGDocumentNoDialog(printSession, printSettings, pageFormat);//from 10.4
   }
   else {
 #endif
@@ -298,7 +293,8 @@
   PMSessionEndDocumentNoDialog(printSession);
   fltk3::DisplayDevice::display_device()->set_current();
   fl_gc = 0;
-  fltk3::first_window()->show();
+  fltk3::Window *w = fltk3::first_window();
+  if (w) w->show();
 }
 
 #endif // __APPLE__

Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.