FLTK logo

STR #2221

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.3 | SVN ⇄ GIT ]

STR #2221

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:1 - Request for Enhancement, e.g. asking for a feature
Scope:2 - Specific to an operating system
Subsystem:MacOS
Summary:Support for 64 bit Mac OS X
Version:1.3-feature
Created By:geuzaine.acm.caltech
Assigned To:matt
Fix Version:1.3.0 (SVN: v6951)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:


Name/Time/Date Filename/Size  
 
#1 manolo
01:05 Oct 25, 2009
fltk-1.3-cocoa.zip
6.3M
 
 
#2 geuzaine.acm.caltech
11:52 Oct 28, 2009
resize_bug.cpp
1k
 
 
#3 geuzaine.acm.caltech
09:36 Nov 02, 2009
tab.png
61k
 
 
#4 geuzaine.acm.caltech
09:36 Nov 02, 2009
tab2.png
54k
 
 
#5 manolo
10:11 Nov 21, 2009
branch-1.3-cocoa.zip
7.7M
 
 
#6 manolo
02:36 Dec 06, 2009
branch-1.3-cocoa-complete.zip
9.6M
 
 
#7 manolo
04:18 Dec 07, 2009
Fl_Preferences.cxx
36k
 
 
#8 manolo
07:44 Dec 07, 2009
Fl_cocoa.mm
95k
 
 
#9 manolo
02:29 Dec 11, 2009
recap.zip
45k
 
 
#10 manolo
11:31 Dec 12, 2009
recap2.zip
46k
 
 
#11 manolo
12:11 Dec 12, 2009
srcmakefile.patch
1k
 
 
#12 manolo
12:06 Dec 13, 2009
mach-sysmenuh-cocoa.patch
4k
 
 
#13 manolo
01:36 Dec 16, 2009
Fl_Native_File_Chooser-0.86-Cocoa.tar.gz
112k
 
 
#14 manolo
23:13 Dec 18, 2009
Fl_cocoa_v2.mm
100k
 
 
#15 manolo
07:05 Dec 21, 2009
cocoa-patch.zip
37k
 
 
#16 manolo
08:01 Jan 07, 2010
flfontmac-flcocoa.patch
4k
 
 
#17 manolo
15:17 Jan 15, 2010
cocoa.patch
1k
 
 
#18 manolo
14:01 Jan 19, 2010
cocoa-font.patch
6k
 
 
#19 manolo
13:36 Jan 22, 2010
bigpatch.patch
16k
 
     

Trouble Report Comments:


Name/Time/Date Text  
 
#1 geuzaine.acm.caltech
08:17 Jul 12, 2009
We need to remove the last Carbon leftovers in 1.3 in order to support 64 bit archs on Mac OS X.

Here's the error log when trying to build rev. 6829 with 64 bit support:

=== making src ===
echo Compiling Fl.cxx...
Compiling Fl.cxx...
g++ -m64 -I..  -I../png -I../jpeg  -Os -Wno-deprecated-declarations -Wall -Wunused -Wno-format-y2k  -fno-exceptions -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT   -c Fl.cxx -o Fl.o
../FL/mac.H: In function 'OpaqueRgnHandle* XRectangleRegion(int, int, int, int)':
../FL/mac.H:50: error: 'NewRgn' was not declared in this scope
../FL/mac.H:51: error: 'SetRectRgn' was not declared in this scope
../FL/mac.H: In function 'void XDestroyRegion(OpaqueRgnHandle*)':
../FL/mac.H:55: error: 'DisposeRgn' was not declared in this scope
Fl.cxx: In member function 'void Fl_Widget::damage(uchar, int, int, int, int)':
Fl.cxx:1456: error: 'NewRgn' was not declared in this scope
Fl.cxx:1457: error: 'SetRectRgn' was not declared in this scope
Fl.cxx:1458: error: 'UnionRgn' was not declared in this scope
Fl.cxx:1459: error: 'DisposeRgn' was not declared in this scope
Fl_mac.cxx: In function 'OSStatus HandleMenu(HICommand*)':
Fl_mac.cxx:495: error: 'GetMenuItemRefCon' was not declared in this scope
Fl_mac.cxx:503: error: 'SetItemMark' was not declared in this scope
Fl_mac.cxx:515: error: 'SetItemMark' was not declared in this scope
Fl_mac.cxx:522: error: 'SetItemMark' was not declared in this scope
Fl_mac.cxx:524: error: 'SetItemMark' was not declared in this scope
Fl_mac.cxx:528: error: 'HiliteMenu' was not declared in this scope
Fl_mac.cxx: In function 'OSStatus carbonDispatchHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*)':
Fl_mac.cxx:557: error: 'GetWindowEventTarget' was not declared in this scope
Fl_mac.cxx:559: error: 'GetWindowEventTarget' was not declared in this scope
Fl_mac.cxx: In function 'double do_queued_events(double)':
Fl_mac.cxx:698: error: 'NewRgn' was not declared in this scope
Fl_mac.cxx:700: error: 'GetMouse' was not declared in this scope
Fl_mac.cxx:701: error: 'SetRectRgn' was not declared in this scope
Fl_mac.cxx:702: error: 'SetEventMask' was not declared in this scope
Fl_mac.cxx:733: error: 'GetApplicationEventTarget' was not declared in this scope
Fl_mac.cxx:755: error: 'ConvertEventRefToEventRecord' was not declared in this scope
Fl_mac.cxx:766: error: 'MacFindWindow' was not declared in this scope
Fl_mac.cxx:767: error: 'MenuSelect' was not declared in this scope
Fl_mac.cxx: In function 'OSStatus carbonWindowHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*)':
Fl_mac.cxx:846: error: 'kEventWindowDrawContent' was not declared in this scope
Fl_mac.cxx:867: error: 'GetWindowClass' was not declared in this scope
Fl_mac.cxx:882: error: 'GetWindowClass' was not declared in this scope
Fl_mac.cxx: In function 'OSStatus carbonMousewheelHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*)':
Fl_mac.cxx:939: error: 'typeLongInteger' was not declared in this scope
Fl_mac.cxx: In function 'OSStatus carbonMouseHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*)':
Fl_mac.cxx:1008: error: 'FindWindow' was not declared in this scope
Fl_mac.cxx:1025: error: 'IsWindowActive' was not declared in this scope
Fl_mac.cxx:1063: error: 'GetPort' was not declared in this scope
Fl_mac.cxx:1064: error: 'GetWindowPort' was not declared in this scope
Fl_mac.cxx:1064: error: 'SetPort' was not declared in this scope
Fl_mac.cxx:1065: error: 'SetOrigin' was not declared in this scope
Fl_mac.cxx:1068: error: 'GlobalToLocal' was not declared in this scope
Fl_mac.cxx: In function 'short unsigned int keycode_to_sym(UInt32, UInt32, short unsigned int)':
Fl_mac.cxx:1104: error: 'KeyTranslate' was not declared in this scope
Fl_mac.cxx: In function 'int keycodeToUnicode(char*, int, EventKind, UInt32, UInt32, UInt32*, unsigned char, short unsigned int)':
Fl_mac.cxx:1134: error: 'KLGetCurrentKeyboardLayout' was not declared in this scope
Fl_mac.cxx:1136: error: 'KLGetKeyboardLayoutProperty' was not declared in this scope
Fl_mac.cxx: In function 'OSErr OpenAppleEventHandler(const AppleEvent*, AppleEvent*, UInt32)':
Fl_mac.cxx:1444: error: 'typeFSS' was not declared in this scope
Fl_mac.cxx: In function 'void fl_open_display()':
Fl_mac.cxx:1500: error: 'MoreMasters' was not declared in this scope
Fl_mac.cxx:1504: error: 'GetQDGlobalsArrow' was not declared in this scope
Fl_mac.cxx:1508: error: 'ClearMenuBar' was not declared in this scope
Fl_mac.cxx:1509: error: 'GetMenuHandle' was not declared in this scope
Fl_mac.cxx:1509: error: 'AppendResMenu' was not declared in this scope
Fl_mac.cxx:1510: error: 'DrawMenuBar' was not declared in this scope
Fl_mac.cxx: In static member function 'static int Fl::x()':
Fl_mac.cxx:1590: error: 'GetQDGlobalsScreenBits' was not declared in this scope
Fl_mac.cxx: In static member function 'static int Fl::y()':
Fl_mac.cxx:1600: error: 'GetQDGlobalsScreenBits' was not declared in this scope
Fl_mac.cxx: In static member function 'static int Fl::w()':
Fl_mac.cxx:1610: error: 'GetQDGlobalsScreenBits' was not declared in this scope
Fl_mac.cxx: In static member function 'static int Fl::h()':
Fl_mac.cxx:1620: error: 'GetQDGlobalsScreenBits' was not declared in this scope
Fl_mac.cxx: In static member function 'static void Fl::get_mouse(int&, int&)':
Fl_mac.cxx:1632: error: 'GetMouse' was not declared in this scope
Fl_mac.cxx:1633: error: 'LocalToGlobal' was not declared in this scope
Fl_mac.cxx: In member function 'void Fl_X::flush()':
Fl_mac.cxx:1658: error: 'SetOrigin' was not declared in this scope
Fl_mac.cxx: In function 'void handleUpdateEvent(OpaqueWindowPtr*)':
Fl_mac.cxx:1673: error: 'GetPort' was not declared in this scope
Fl_mac.cxx:1674: error: 'GetWindowPort' was not declared in this scope
Fl_mac.cxx:1674: error: 'SetPort' was not declared in this scope
Fl_mac.cxx:1679: error: 'InvalWindowRgn' was not declared in this scope
Fl_mac.cxx:1683: error: 'DisposeRgn' was not declared in this scope
Fl_mac.cxx: In static member function 'static int Fl_X::fake_X_wm(const Fl_Window*, int&, int&, int&, int&, int&)':
Fl_mac.cxx:1784: error: 'GetDeviceList' was not declared in this scope
Fl_mac.cxx:1784: error: 'GetNextDevice' was not declared in this scope
Fl_mac.cxx:1792: error: 'GetNextDevice' was not declared in this scope
Fl_mac.cxx:1801: error: 'GetNextDevice' was not declared in this scope
Fl_mac.cxx:1810: error: 'GetNextDevice' was not declared in this scope
Fl_mac.cxx:1819: error: 'GetNextDevice' was not declared in this scope
Fl_mac.cxx:1828: error: 'GetMainDevice' was not declared in this scope
Fl_mac.cxx:1830: error: 'GetAvailableWindowPositioningBounds' was not declared in this scope
Fl_mac.cxx: In function 'int FSSpec2UnixPath(FSSpec*, char*)':
Fl_mac.cxx:1850: error: 'FSpMakeFSRef' was not declared in this scope
Fl_mac.cxx: In function 'OSErr fillCurrentDragData(OpaqueDragRef*)':
Fl_mac.cxx:1891: error: 'CountDragItems' was not declared in this scope
Fl_mac.cxx:1895: error: 'GetDragItemReferenceNumber' was not declared in this scope
Fl_mac.cxx:1896: error: 'GetFlavorFlags' was not declared in this scope
Fl_mac.cxx:1899: error: 'GetFlavorDataSize' was not declared in this scope
Fl_mac.cxx:1906: error: 'GetFlavorDataSize' was not declared in this scope
Fl_mac.cxx:1913: error: 'GetFlavorDataSize' was not declared in this scope
Fl_mac.cxx:1936: error: 'GetDragItemReferenceNumber' was not declared in this scope
Fl_mac.cxx:1937: error: 'GetFlavorFlags' was not declared in this scope
Fl_mac.cxx:1940: error: 'GetFlavorDataSize' was not declared in this scope
Fl_mac.cxx:1941: error: 'GetFlavorData' was not declared in this scope
Fl_mac.cxx:1950: error: 'GetFlavorDataSize' was not declared in this scope
Fl_mac.cxx:1951: error: 'GetFlavorData' was not declared in this scope
Fl_mac.cxx:1959: error: 'GetFlavorDataSize' was not declared in this scope
Fl_mac.cxx:1960: error: 'GetFlavorData' was not declared in this scope
Fl_mac.cxx:1969: error: 'GetFlavorData' was not declared in this scope
Fl_mac.cxx: In function 'OSErr dndTrackingHandler(DragTrackingMessage, OpaqueWindowPtr*, void*, OpaqueDragRef*)':
Fl_mac.cxx:2003: error: 'GetDragMouse' was not declared in this scope
Fl_mac.cxx: In function 'OSErr dndReceiveHandler(OpaqueWindowPtr*, void*, OpaqueDragRef*)':
Fl_mac.cxx:2056: error: 'GetDragMouse' was not declared in this scope
Fl_mac.cxx: In function 'void q_set_window_title(OpaqueWindowPtr*, const char*)':
Fl_mac.cxx:2091: error: 'SetWindowTitleWithCFString' was not declared in this scope
Fl_mac.cxx: In static member function 'static void Fl_X::make(Fl_Window*)':
Fl_mac.cxx:2226: error: 'GetAvailableWindowAttributes' was not declared in this scope
Fl_mac.cxx:2227: error: 'CreateNewWindow' was not declared in this scope
Fl_mac.cxx:2229: error: 'MoveWindow' was not declared in this scope
Fl_mac.cxx:2232: error: 'SetWindowClass' was not declared in this scope
Fl_mac.cxx:2233: error: 'SetWindowActivationScope' was not declared in this scope
Fl_mac.cxx:2239: error: 'RepositionWindow' was not declared in this scope
Fl_mac.cxx:2241: error: 'RepositionWindow' was not declared in this scope
Fl_mac.cxx:2243: error: 'RepositionWindow' was not declared in this scope
Fl_mac.cxx:2255: error: 'GetWindowEventTarget' was not declared in this scope
Fl_mac.cxx:2281: error: 'kEventWindowDrawContent' was not declared in this scope
Fl_mac.cxx:2292: error: 'InstallTrackingHandler' was not declared in this scope
Fl_mac.cxx:2293: error: 'InstallReceiveHandler' was not declared in this scope
Fl_mac.cxx:2309: error: 'ShowWindow' was not declared in this scope
Fl_mac.cxx:2312: error: 'CollapseWindow' was not declared in this scope
Fl_mac.cxx:2318: error: 'GetWindowBounds' was not declared in this scope
Fl_mac.cxx: In member function 'void Fl_Window::size_range_()':
Fl_mac.cxx:2340: error: 'SetWindowResizeLimits' was not declared in this scope
Fl_mac.cxx: In member function 'virtual void Fl_Window::show()':
Fl_mac.cxx:2396: error: 'IsWindowCollapsed' was not declared in this scope
Fl_mac.cxx:2396: error: 'CollapseWindow' was not declared in this scope
Fl_mac.cxx:2398: error: 'BringToFront' was not declared in this scope
Fl_mac.cxx:2399: error: 'SelectWindow' was not declared in this scope
Fl_mac.cxx: In member function 'virtual void Fl_Window::resize(int, int, int, int)':
Fl_mac.cxx:2429: error: 'SetWindowBounds' was not declared in this scope
Fl_mac.cxx:2431: error: 'InvalWindowRect' was not declared in this scope
Fl_mac.cxx:2433: error: 'MoveWindow' was not declared in this scope
Fl_mac.cxx: In member function 'void Fl_Window::make_current()':
Fl_mac.cxx:2458: error: 'NewRgn' was not declared in this scope
Fl_mac.cxx:2462: error: 'GetWindowPort' was not declared in this scope
Fl_mac.cxx:2462: error: 'SetPort' was not declared in this scope
Fl_mac.cxx:2474: error: 'SetOrigin' was not declared in this scope
Fl_mac.cxx:2476: error: 'SetRectRgn' was not declared in this scope
Fl_mac.cxx:2483: error: 'NewRgn' was not declared in this scope
Fl_mac.cxx:2486: error: 'DiffRgn' was not declared in this scope
Fl_mac.cxx:2487: error: 'DisposeRgn' was not declared in this scope
Fl_mac.cxx:2491: error: 'QDBeginCGContext' was not declared in this scope
Fl_mac.cxx:2503: error: 'SetPortClipRegion' was not declared in this scope
Fl_mac.cxx: In static member function 'static void Fl_X::q_fill_context()':
Fl_mac.cxx:2525: error: 'GetWindowPort' was not declared in this scope
Fl_mac.cxx:2525: error: 'GetPortBounds' was not declared in this scope
Fl_mac.cxx: In static member function 'static void Fl_X::q_release_context(Fl_X*)':
Fl_mac.cxx:2551: error: 'GetWindowPort' was not declared in this scope
Fl_mac.cxx:2551: error: 'QDEndCGContext' was not declared in this scope
Fl_mac.cxx: In function 'void MacDestroyWindow(Fl_Window*, OpaqueWindowPtr*)':
Fl_mac.cxx:2862: error: 'DisposeWindow' was not declared in this scope
Fl_mac.cxx: In function 'void MacMapWindow(Fl_Window*, OpaqueWindowPtr*)':
Fl_mac.cxx:2867: error: 'ShowWindow' was not declared in this scope
Fl_mac.cxx: In function 'void MacUnmapWindow(Fl_Window*, OpaqueWindowPtr*)':
Fl_mac.cxx:2877: error: 'HideWindow' was not declared in this scope
make[1]: *** [Fl.o] Error 1
make: *** [all] Error 1
 
 
#2 manolo
14:48 Oct 19, 2009
Support for 64-bit applications on Mac OS X requires the use of Cocoa because much of Carbon is not available to 64-bit applications. This, in turn, requires the use of objective-c, or objective-c++. I present here a modified FLTK-1.3.x-r6858 that can be used to build Cocoa-based FLTK applications which can be compiled either in 32-bit or 64-bit modes.

Here is a list of statements that describe this contribution:
- Only MAC-specific code has been touched, so WIN32 and X11 FLTK platforms are unchanged and unconcerned.
- The FLTK API is unchanged, so existing applications can be recompiled without source-level change in 64-bit mode.
- All changes have been bracketted by #ifdef _APPLE_COCOA__ / #endif. This allows this codebase to produce a traditional carbon fltk using a traditional config.h file. The changes are visible if and only if
#define __APPLE_COCOA__
is added to config.h
- The code presented here is almost complete in the sense that all of FLTK works (see below for details) in both 32-bit and 64-bit modes, except for GL- and cairo-related stuff I did not consider at all. Because this stuff is unchanged, it will work as before under 32-bit but may not compile under 64-bit mode.
- FLTK's logic of where to clip and when to draw is unchanged; only how things are drawn change from Carbon to Cocoa. This statement is of course closely related to the fact that none of the non MAC-specific code was modified.
- All objective-c code has been put in a single file, FL_cocoa.m, that replaces Fl_mac.cxx when Fl.cxx is compiled and __APPLE_COCOA__ is defined. So a single file, Fl.cxx, must be compiled in objective-c++. This is achieved under Xcode by setting this file to the type sourcecode.cpp.objcpp. In a make context, the  same is achieved with the -x objective-c++ gcc option.
- A single .H file was touched, mac.H, where, as said above, changes are active only if __APPLE_COCOA__ is defined in config.h
- Modified files of the src directory are those dated October 3, 2009 or after; there are 17 such files. Older files have not been modified.
- Text/fonts: FLTK uses ATSUI which, for some reason I don't grasp, is not available to 64-bit applications. So the new code uses "Core Text" for UTF text, but core text is not available before MAC OS 10.5. So "Core Text" calls are bracketted by
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 / #endif. Consequently, the 64-bit mode of the new code is not available before 10.5, which is not a problem because GUI-based 64-bit applications did not start before 10.5. In 32-bit mode, ATSUI is used if an SDK older than 10.5 is used, and Core Text is used with SDK's 10.5 or above.
- UTF support is present with correct display of chinese, russian, greek, arabic and hebrew text.
- rotated text works.
- right-to-left text output should work but has not been tested.
- The new code compiles in ppc mode for SDKs 10.3, 10.4, 10.5, in i386 mode for 10.4 and above, in x86_64 for 10.5 and above.
- The new code has been tested in 10.5 and 10.6 (which presented some unexpected surprises) and runs correctly in both cases in 32-bit and 64-bit modes.
- text input: ASCII and non-ASCII keys (I use a French keyboard) are correctly input (better than with traditional FLTK-1.3). Character composition does not work, though.
- Fl::add_fd and Fl::add_timeout work, unchanged.
- fl_read_image, that reads a piece of a window, work and allow fl_overlay_rect to work.
- fl_open_callback works.
- drop of text and filenames and drag of text work.
- Fl_Scroll works using a Cocoa equivalent of CopyBits
- Fl_Open_display now creates a standard "Application menu" with the About, Hide, Quit commands.
- menu shortcuts work.
- I have added a function (MACsetAboutMenu) that accepts a callback called by the "About myprog" item of the Application menu.
- Fl_Sys_Menu_Bar.cxx allows to create FLTK menus in the menu bar of the top of the screen and to attach standard FLTK callbacks to them.
- Cursors: only predefined Cocoa cursors have been used. This allows to implement much of the FLTK-defined cursors, but one conspicuous absence is the watch cursor. Missing cursors are all replaced by the default arrow cursor.
- Modal and non_modal windows work.
- mouse wheel works.
- Carbon regions are not supported by 64-bit applications, so regions have been replaced by a custom structure:
typedef struct flrects {
        int count;
        CGRect *rects;
} *Fl_Region;
and two support functions were written:
Fl_Region MacRectRegionIntersect(Fl_Region current, int x,int y,int w, int h)
to intersect a region and a rectangle
and
Fl_Region MacRegionMinusRect(Fl_Region r, int x,int y,int w,int h)
to remove a rectangle from a region.

I contribute a ZIP archive available at
http://pbil.univ-lyon1.fr/members/mgouy/data/fltk-1.3-cocoa.zip
containing an Xcode project, fltkCOCOA.xcodeproj located in the fltk-xcode directory of the archive, with the modified code and several targets:
- fltkCOCOA: builds the 32-bit i386 libfltkCOCOA.a using the 10.4 SDK.
- fltCOCOA64: builds the 64-bit x86_64 libfltkCOCOA64.a using the 10.5 SDK.
- fluid: builds the fluid application (unbundled to allow for arguments) as an example of a 32-bit cocoa fltk application
- scroll64: builds the scroll.cxx demo application as an example of a 64-bit bundled fltk application.
- libjpeg and libpng: build support 32-bit libraries
- libjpeg64 and libpng64: build support 64-bit libraries

I imagine 64-bit support could be valuable today for example to image-processing FLTK applications. All of this results from much hard, but fun, work. I wish the FLTK team will agree to evaluate this contribution, and hopefully, integrate it in FLTK 1.3
 
 
#3 fabien
09:54 Oct 20, 2009
This looks truly interesting manolo,
unfortunately I have no 64bit OS X platform for testing that yet and I'm really too busy with my business right now to go into it.
Matt, do you have access to 64 bit Snow Leopard ?
What do you think of this new contribution ?
 
 
#4 ianmacarthur
12:30 Oct 20, 2009
I'm quite liking what Manolo has done - I only wish I had a 64-bit OSX box to test it on!  
 
#5 matt
12:37 Oct 20, 2009
Wow, I missed that! Very cool. I will try this on snow leopard as soon as I have a few minutes. Thanks!  
 
#6 manolo
00:21 Oct 21, 2009
I have not encountered a single difference between 32-bit and 64-bit compilations, in contrast to, for example, a couple of things changing between leopard and snow leopard. In other words, in no instance at all did I have to change anything, or even consider any issue raised by 32 vs. 64-bit compiles. Thus, if you don't have a 64-bit capable Mac, but compile the code in 32-bit with SDK 10.5 you'll be able to test exactly ALL of the modified code. With SDK 10.4 you'd miss a few changes, for example "Core Text" instead of ATSUI.  
 
#7 manolo
09:14 Oct 21, 2009
Following Christophe's remark "The only missing piece really is OpenGL support", I have added OpenGL support, at least support of FLTK's glpuzzle demo application. You'll find that at:
http://pbil.univ-lyon1.fr/members/mgouy/data/fltk-1.3-cocoa.zip
as before, with 2 new targets, glpuzzle and glpuzzle64.
Changes to OpenGL stuff are clean and simple, except in gl_font of gl_draw.cxx where I used a very quick and very dirty substitute of the 32-bit only GetFNum call.
 
 
#8 manolo
01:11 Oct 25, 2009
The flscroll demo did not work in 32-bit on 10.6 and SDK 10.4. I have corrected that. I have also completed all FLTK-predefined cursors, and added a user feedback when dragging text inspired by the one provided by the system. With this, the cocoa port of FLTK-1.3 is complete. All material is now in a file attached to this post.  
 
#9 geuzaine.acm.caltech
14:45 Oct 27, 2009
Hi Manolo - I spent some time playing with your new Cocoa version in 64 bit mode: it's amazing how much already works!

Here are a few problems I could detect with our code (Gmsh):

* I get many many messages like this in the terminal:

  2009-10-27 22:29:15.853 gmsh[47851:903] unlockFocus called too many time.

* There are some weird resizing and focus problems (maybe linked with Fl_Scroll, but I need to test more), as well as random crashes with multiple OpenGL contexts in Fl_Tiles.

* Some separators (after submenus) do not appear in Fl_Sys_Menu_Bar

* I could not manage to get any fonts (even the standard ones) working in OpenGL windows

* Alt-key shortcuts do not seem to be handled correctly

* including "Fl/x.H" (for fl_open_callback) seems to include old Carbon stuff

Not a bug, but Greg's native file chooser will not work with the Cocoa version (since it too needs to be ported to Cocoa)

Thanks again for your port: hopefully it will allow us to keep using FLTK on Mac going forward instead switching to Qt.

Christophe
 
 
#10 manolo
07:20 Oct 28, 2009
Christophe:
- I have repaired the missing menu separators in http://pbil.univ-lyon1.fr/members/mgouy/data/fltk-1.3-cocoa.zip.
- you should not get carbon stuff included when including Fl/x.H. May be the cause is that the config.h file included by your code (x.H includes mac.H which includes config.h) is not the new one that must contain
#define __APPLE_COCOA__
but the old one without this define.
- I use here Greg's native file chooser with the cocoa FLTK without any problem.
- I known alt-key shortcuts don't work, but in my hands they don't work either with carbon FLTK 1.3. So this may not result from a cocoa change.
- the font problem under OpenGL is unexpected because the only change in this respect is to emulate the 32-bit-only call GetFNum and I have checked that the new code emulates it exactly, at least for standard fonts. I don't know OpenGL, so can't progress on this issue.
- the resizing problems and unlockFocus messages you receive are probably linked. Could you give me a code as simple as possible that presents this problem?
 
 
#11 geuzaine.acm.caltech
11:51 Oct 28, 2009
Hi Manolo,

- I've attached a little example showing the resize bug (resize_bug.cpp), but I could not yet manage to isolate the unlockFocus problem.

- You were right about "config.h" problem: "fltk-xcode/COCOAconfig" was not in the include path and I was including an unrelated config.h file.

- The Alt+key shortcuts work fine over here with the Carbon version: try "Alt-O") in the small resize_bug.cpp example above.

I will try to find some time to have a look at the OpenGL font issues.
 
 
#12 manolo
10:54 Oct 29, 2009
Text input now accepts all left-to-right alphabetic scripts (e.g., roman, greek, russian) and two-stroke key compositions (e.g. Alt-N + n for ñ) where the first keystroke is a deadkey that modifies the next stroke.

to Christophe:
- I have arranged for Alt+key to work as menu shortcut (although
it's not very mac-like)
- I have corrected the resize bug
 
 
#13 geuzaine.acm.caltech
12:11 Nov 01, 2009
Manolo - I confirm that the Alt+key shortcuts now work as expected, and that the resize bug is fixed.  
 
#14 manolo
01:48 Nov 02, 2009
Christophe: The "unlockFocus called too many time" bug is repaired in http://pbil.univ-lyon1.fr/members/mgouy/data/fltk-1.3-cocoa.zip

Matt: I have applied for developer status and have prepared what could become a new branch-1.3-cocoa with an updated ide/Xcode3.1/FLTK.xcodeproj in which all demos (except checkers) seem to work correctly.
 
 
#15 geuzaine.acm.caltech
09:35 Nov 02, 2009
Manolo - Just to confirm that the "UnlockFocus called too many time" message does not appear anymore.

Your new version also fixes the crashes experienced when programmatically resizing windows (by calling resize() while the window is shown), as well as the crash with resizing tiles!

The only major problem remaining is the OpenGL font issue. I had a quick look but did not figure out why they don't work. Does test/cube.cxx work on your machine (do you see the text in the OpenGL windows)?

There is one other (very) minor glitch when drawing tabs. When tags are draw for the first time (cf. tab.png) the small line separator is missing. When selecting the tab it shows up (cf. tab2.png). This looks like a little off-by-one pixel problem.
 
 
#16 manolo
10:59 Nov 21, 2009
Following Greg's suggestion, I have uploaded a file branch-1.3-cocoa.zip that could become a cocoa-based FLTK 1.3 branch. The data therein can be fully compiled by make and/or using the FLTK.xcodeproj Xcode project therein. All test programs work in both 32- and 64-bit modes under either Mac OS 10.5 or 10.6, including those obtained by make but not by the Xcode project (e.g., unittest). One thing does not work though in 64-bits, text drawing in OpenGL windows, that would require a complete rewrite. I have added to the Xcode project a new build configuration, Debug64, that builds 64-bit versions of all targets. The release build configuration itself builds universal programs with 4 architectures (i386, x86_64, ppc, ppc64).
Text input is complete with support of international keyboards, of two-keystroke character composition, and of character palette input.
As said before, all changes are surrounded by #ifdef __APPLE_COCOA__ / #endif, so the modified code is exactly FLTK 1.3 unless #define __APPLE_COCOA__ is added to config.h. The FLTK API is unchanged.

Could any FLTK developer evaluate this contribution proposal?
 
 
#17 hugues
17:16 Dec 02, 2009
Thanks Manolo, this is tremendously exciting.

Question: is it possible to compile fltk 64-bit from the command line (using the makefile) ? I could not figure that out, it's late.
 
 
#18 manolo
03:02 Dec 06, 2009
- I have posted file branch-1.3-cocoa-complete.zip that completes the Cocoa port of FLTK 1.3 with an implementation of function gl_draw for text drawing in OpenGL windows. This also brings the benefit of allowing to draw any UTF character rather than just a set of 256 characters. The FLTK.xcodeproj can now be compiled in 32-bit mode (i386 or ppc) from SDK 10.3.9 and in 64-bit from SDK 10.5. I have also corrected a one-pixel offset that occurred in the scroll demo under Mac OS 10.6, and simplified a few things in the code.
- The code can also be compiled in 64-bit without using Xcode by:
make CC="gcc -arch x86_64" CXX="g++ -arch x86_64"
- Matt, Ian: did you find time to try this Cocoa port?
 
 
#19 matt
14:23 Dec 06, 2009
OK, so I merged the zip archive into the current SVN tree. Please guys, check if this all went right! I still have to do a bunch of tests, but the basic code seems to work very well! (to the point where I sometimes wonder if I set the flags right and I am not still using Carbon ;-)  
 
#20 manolo
07:49 Dec 07, 2009
I have uploaded a slightly modified Fl_cocoa.mm file
that should solve all compilation errors reported by Ian.

It contains this addition:
#include <AvailabilityMacros.h>
#if defined(__LP64__) && __LP64__
typedef double CGFloat;
#else
typedef float CGFloat;
#endif

plus a default clause in each of the two switch statements that caused warnings.
 
 
#21 manolo
08:19 Dec 07, 2009
File branch-1.3/makeinclude.in has also been modified in the process
to ensure compilation of file Fl.cxx in objective-c++ instead of c++.
I suddenly realize that this modification would also act on non-Mac OS
builds, which are definitely unconcerned.
I suggest to change line 155 of this file from the present:
        @if [ $< = Fl.cxx ]; then \
to:
        @if [ `uname` = Darwin -a $< = Fl.cxx ]; then \
to make sure that only Mac OS make runs do objective-c++ compilations.

You may also find a better way to obtain the same effect.
 
 
#22 matt
11:16 Dec 07, 2009
Hmm. I had two errors umping a case label, and a warning:

Fl_cocoa.mm:2015: warning: class 'FLDelegate' does not implement the 'NSWindowDelegate' protocol

How do I get rid of the warning? I do not speak Objective-C.
 
 
#23 matt
11:56 Dec 07, 2009
Manolo, would you please check the Xcode setup. It seems that the Release version does not compile. Thanks.  
 
#24 manolo
15:08 Dec 07, 2009
In file FL/mac.H, add this just after the #include <Carbon/Carbon.h>:

#ifdef __APPLE_COCOA__

#ifndef __AVAILABILITYMACROS__
#include <AvailabilityMacros.h>
#endif
#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
#ifndef MAC_OS_X_VERSION_MAX_ALLOWED
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
#endif

#endif

this should solve all of Ian's errors.

In src/Fl_cocoa.mm, remove
#include <AvailabilityMacros.h>
that we just recently added (sorry for this back and forth)
because we have now this included by mac.H so it applies also
to, e.g.,  fl_fonts_mac.cxx

and at line 1257 change the 2 lines:
@interface FLDelegate : NSObject {
}
into the 6 lines:
@interface FLDelegate : NSObject
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
<NSWindowDelegate>
#endif
{
}
this should solve the warning you Matt mentionned
(this warning is a gift from SDK 10.6 I had not tried yet,
I had just run the programs on 10.6).


For the Release configuration, Matt, please, remove the ppc64
architecture from it (leaving 3: ppc, i386, x86_64). To do that,
open the Info window of the FLTK project itself, go to the
Build tab, select the Release configuration,
select Show all settings, and go to the
Architectures line, delete its current value and replace it by
ppc i386 x86_64
This change will propagate to all targets of the FLTK project.
The 4-architecture build works well with 10.5 but apparently not with 10.6 builds. I don't think the ppc64 architecture has much interest.

Hopefully, we'll have progressed with that.

About the change in file makeinclude.in: sorry, I don't see
exactly what syntax you suggest that would be more portable.
May be you can do the change yourself? The goal is to add
-x objective-c++ only to compile file Fl.cxx and only if on a Mac.
 
 
#25 manolo
22:59 Dec 07, 2009
File Makefile was also modified in the process: its lines 30-31
have become:
#DIRS = $(IMAGEDIRS) src $(CAIRODIR) fluid test documentation
DIRS = $(IMAGEDIRS) src $(CAIRODIR) fluid test
and should go back to the single line:
DIRS = $(IMAGEDIRS) src $(CAIRODIR) fluid test documentation

This is because I had to remove the documentation subdirectory
from the zip file to keep it below 10 MB so I could upload
it on your server. Thus, I removed the documentation step from
the Makefile not to have make finish with error messages.

Having slept over it, I think useless to put
#ifndef __AVAILABILITYMACROS__
#include <AvailabilityMacros.h>
#endif
in file FL/mac.H, because Carbon.h will have included this header file.
The rest, though, defining MAC_OS_X_VERSION_10_3 and friends
if not yet defined, is useful as Ian's experience told us.
 
 
#26 manolo
23:41 Dec 07, 2009
>the basic code seems to work very well! (to the point where I sometimes >wonder if I set the flags right and I am not still using Carbon ;-)
To make sure you are running a Cocoa demo program, run its About ...
menu item from the Apple menu bar application menu: all Cocoa programs have one, and none of the Carbon programs do.
 
 
#27 greg.ercolano
01:07 Dec 08, 2009
Are any of these fixes checked in?

I'm trying to test changes to Fl_Tree on OSX and can't compile fltk 1.3.x svn current on OSX 10.4.11 at the moment because of errors that appear to be related to this STR.

I tried applying some of the recent mods, and got past Fl_Cocoa.mm errors, but now getting failures in fl_line_style.cxx:

Compiling fl_line_style.cxx...
fl_line_style.cxx:43: error: expected initializer before '*' token
fl_line_style.cxx: In function 'void fl_quartz_restore_line_style_()':
fl_line_style.cxx:49: error: 'fl_quartz_line_pattern' was not declared in this scope
fl_line_style.cxx: In function 'void fl_line_style(int, int, char*)':
fl_line_style.cxx:148: error: 'CGFloat' does not name a type
[..]

Is there something I can configure(1) off to bypass?
 
 
#28 manolo
02:41 Dec 08, 2009
Last call (I hope) for this CGFloat/NSInteger/MAC_OS_X_VERSION_MAX_ALLOWED
business.

1) In FL/mac.h, put:
// Standard MacOS Carbon API includes...
#include <Carbon/Carbon.h>
#include <config.h>

#ifdef __APPLE_COCOA__

#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
#ifndef MAC_OS_X_VERSION_MAX_ALLOWED
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
#endif

#ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h
#if defined(__LP64__) && __LP64__
typedef double CGFloat;
#else
typedef float CGFloat;
#endif
#endif

#endif

// Now make some fixes to the headers...

The starting and ending comments indicate where to place that.


2) In src/Fl_cocoa.mm, we want to obtain:

#import <Cocoa/Cocoa.h>

#ifndef NSINTEGER_DEFINED //appears with 10.5 in NSObjCRuntime.h
#if defined(__LP64__) && __LP64__
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
#endif

// #define DEBUG_SELECT // UNCOMMENT FOR SELECT()/THREAD DEBUGGING

The first and last lines indicate where to place that.
 
 
#29 manolo
05:17 Dec 08, 2009
A small change, as an svn diff output, to Fl_cocoa.mm so the
"About myprog" menu item displays the FLTK version being used.
This diff also reflects my previous suggestion for Fl_cocoa.mm changes.

===================================================================
--- Fl_cocoa.mm (revision 6958)
+++ Fl_cocoa.mm (working copy)
@@ -61,19 +61,17 @@
 #include <stdarg.h>
 
 #import <Cocoa/Cocoa.h>
-#include <AvailabilityMacros.h>
+
+#ifndef NSINTEGER_DEFINED //appears with 10.5 in NSObjCRuntime.h
 #if defined(__LP64__) && __LP64__
-typedef double CGFloat;
-#else
-typedef float CGFloat;
-#endif
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
 typedef long NSInteger;
 typedef unsigned long NSUInteger;
+#else
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
 #endif
+#endif
 
-
 // #define DEBUG_SELECT // UNCOMMENT FOR SELECT()/THREAD DEBUGGING
 #ifdef DEBUG_SELECT
 #include <stdio.h> // testing
@@ -1255,7 +1253,11 @@
                                             UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
 }
 
-@interface FLDelegate : NSObject {
+@interface FLDelegate : NSObject
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+<NSWindowDelegate, NSApplicationDelegate>
+#endif
+{
 }
 - (void)windowDidMove:(NSNotification *)notif;
 - (void)windowDidResize:(NSNotification *)notif;
@@ -2746,6 +2748,22 @@
   return num_screens;
 }
 
+@interface FLaboutItemTarget : NSObject
+{
+}
+- (void)showPanel;
+@end
+@implementation FLaboutItemTarget
+- (void)showPanel
+{
+  NSDictionary *options;
+  options = [NSDictionary dictionaryWithObjectsAndKeys:
+      [NSString stringWithFormat:@" FLTK %d.%d Cocoa", FL_MAJOR_VERSION, FL_MINOR_VERSION ], @"Copyright",
+      nil];
+  [NSApp  orderFrontStandardAboutPanelWithOptions:options];
+}
+@end
+
 static NSMenu *appleMenu;
 static void createAppleMenu(void)
 {
@@ -2763,7 +2781,9 @@
   appleMenu = [[NSMenu alloc] initWithTitle:@""];
   /* Add menu items */
   title = [@"About " stringByAppendingString:(NSString*)nsappname];
-  [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
+  [appleMenu addItemWithTitle:title action:@selector(showPanel) keyEquivalent:@""];
+  FLaboutItemTarget *about = [[FLaboutItemTarget alloc] init];
+  [[appleMenu itemAtIndex:0] setTarget:about];
   [appleMenu addItem:[NSMenuItem separatorItem]];
   // Services Menu
   services = [[[NSMenu alloc] init] autorelease];
 
 
#30 matt
05:44 Dec 08, 2009
One observation: when usung Fl_Sys_Menu, the '&' character that is used to create menu item accelerators with an underline, the '&' is visible in the top-menubar menus.  
 
#31 manolo
06:40 Dec 08, 2009
Correct, this & character is displayed. I attach an svn diff Fl_cocoa.mm
that repairs that. I want to stress that, as written in the file,
Fl_Sys_Menu_Bar.cxx is not a complete implementation of the Fl_Menu
class. Some of the things that do work are shortcuts and FL_MENU_TOGGLE.

Last login: Tue Dec  8 15:30:07 on ttys000
[biomp2:~] mgouy% cd /Users/mgouy/Documents/fltk/COCOA/branch-1.3/src
[biomp2:COCOA/branch-1.3/src] mgouy% svn diff Fl_cocoa.mm
Index: Fl_cocoa.mm
===================================================================
--- Fl_cocoa.mm (revision 6958)
+++ Fl_cocoa.mm (working copy)
@@ -61,19 +61,17 @@
 #include <stdarg.h>
 
 #import <Cocoa/Cocoa.h>
-#include <AvailabilityMacros.h>
+
+#ifndef NSINTEGER_DEFINED //appears with 10.5 in NSObjCRuntime.h
 #if defined(__LP64__) && __LP64__
-typedef double CGFloat;
-#else
-typedef float CGFloat;
-#endif
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
 typedef long NSInteger;
 typedef unsigned long NSUInteger;
+#else
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
 #endif
+#endif
 
-
 // #define DEBUG_SELECT // UNCOMMENT FOR SELECT()/THREAD DEBUGGING
 #ifdef DEBUG_SELECT
 #include <stdio.h> // testing
@@ -1255,7 +1253,11 @@
                                             UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
 }
 
-@interface FLDelegate : NSObject {
+@interface FLDelegate : NSObject
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+<NSWindowDelegate, NSApplicationDelegate>
+#endif
+{
 }
 - (void)windowDidMove:(NSNotification *)notif;
 - (void)windowDidResize:(NSNotification *)notif;
@@ -2746,6 +2748,22 @@
   return num_screens;
 }
 
+@interface FLaboutItemTarget : NSObject
+{
+}
+- (void)showPanel;
+@end
+@implementation FLaboutItemTarget
+- (void)showPanel
+{
+  NSDictionary *options;
+  options = [NSDictionary dictionaryWithObjectsAndKeys:
+      [NSString stringWithFormat:@" FLTK %d.%d Cocoa", FL_MAJOR_VERSION, FL_MINOR_VERSION ], @"Copyright",
+      nil];
+  [NSApp  orderFrontStandardAboutPanelWithOptions:options];
+}
+@end
+
 static NSMenu *appleMenu;
 static void createAppleMenu(void)
 {
@@ -2763,7 +2781,9 @@
   appleMenu = [[NSMenu alloc] initWithTitle:@""];
   /* Add menu items */
   title = [@"About " stringByAppendingString:(NSString*)nsappname];
-  [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
+  [appleMenu addItemWithTitle:title action:@selector(showPanel) keyEquivalent:@""];
+  FLaboutItemTarget *about = [[FLaboutItemTarget alloc] init];
+  [[appleMenu itemAtIndex:0] setTarget:about];
   [appleMenu addItem:[NSMenuItem separatorItem]];
   // Services Menu
   services = [[[NSMenu alloc] init] autorelease];
@@ -2818,7 +2838,7 @@
 }
 - (void) doCallback:(id)obj
 {
-  cb((Fl_Widget*)obj, data);
+  if(cb) cb((Fl_Widget*)obj, data);
 }
 - (void*)getItemData
 {
@@ -2960,10 +2980,21 @@
     //upon return, puts the rank of the new item in *prank unless prank is NULL
     menu = va_arg(ap, NSMenu*);
     const char *name = va_arg(ap, const char*);
+    char *name2 = strdup(name);
+    const char *p;
+    char *q;
+    p = name;
+    q = name2;
+    while(*p != 0) {
+      if(*p != '&') *q++ = *p;
+      p++;
+      }
+    *q = 0;
     Fl_Callback *cb = va_arg(ap, Fl_Callback*);
     pter = va_arg(ap, void *);
     int *prank = va_arg(ap, int*);
-    CFStringRef cfname = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8);
+    CFStringRef cfname = CFStringCreateWithCString(NULL, name2, kCFStringEncodingUTF8);
+    free(name2);
     FLMenuItem *item = [FLMenuItem alloc];
     [item initWithTitle:(NSString*)cfname action:@selector(doCallback:) keyEquivalent:@""];
     [item putData:cb pter:pter];
 
 
#32 matt
15:22 Dec 08, 2009
OK, I patched some more. Please verify the SVN.

Could you please repost the instructions on how to remove the PPC64 build from the Release settings? I must have deleted that mail :-(

Fl_Sys_Menu now has the problem that we do not get a pointer to a widget anymore. Launch Sudoku and hit Apple-N -> Crash.
 
 
#33 greg.ercolano
20:51 Dec 08, 2009
Matt, your latest svn fixed my build problem -- thanks!  
 
#34 manolo
01:05 Dec 09, 2009
Yes, what works now is assigning a callback and a data pointer to
a menu bar item with, e.g.,   items[x].callback(mycb, data);
and when this callback gets called, it receives an Fl_Widget* and
a void* arguments, but only the void* has meaning, because a
system menu bar item is not an FLTK widget.
I realize with your post that Sudoku needs a widget. Since Carbon
Fl_Sys_Menu_Bar was in the same situation, there is hope to find a
solution.

It's good that you tell me the crashes you detect, but do you also
see many things working well as I do?

Did you try dragging text out of a text field, using the input
demo for instance?
 
 
#35 manolo
08:58 Dec 09, 2009
OK I have better grasped the Fl_Sys_Menu_Bar logic, and have corrected
Fl_Sys_Menu_Bar.cxx and Fl_Cocoa.mm accordingly. I put here and in a
next post the svn diff outputs. Sudoku menus now work nicely,
and shortcuts + Toggle work around menu items.


Index: Fl_Sys_Menu_Bar.cxx
===================================================================
--- Fl_Sys_Menu_Bar.cxx (revision 6958)
+++ Fl_Sys_Menu_Bar.cxx (working copy)
@@ -228,7 +228,7 @@
   
   while ( mm->text )
   {
- MACMenuOrItemOperation("addNewItem", submenu, mm->text, mm->callback_, mm->user_data_, &miCnt);
+ MACMenuOrItemOperation("addNewItem", submenu, mm, &miCnt);
     setMenuFlags( submenu, miCnt, mm );
     setMenuShortcut( submenu, miCnt, mm );
         if ( mm->flags & FL_MENU_INACTIVE ) {
@@ -274,7 +274,7 @@
     if ( !mm || !mm->text )
       break;
     char visible = mm->visible() ? 1 : 0;
- MACMenuOrItemOperation("addNewItem", MACmainMenu(), mm->text, NULL, NULL, NULL);
+ MACMenuOrItemOperation("addNewItem", MACmainMenu(), mm, NULL);
 
     if ( mm->flags & FL_SUBMENU )
       createSubMenu( MACmainMenu(), mm );
 
 
#36 manolo
09:06 Dec 09, 2009
Here is the Fl_cocoa.mm svn diff output.
I also propose an addition to the public API:
    fl_mac_set_about(Fl_Menu_Item *item)
connects item to the "About myprog" item of the system application menu.
This allows to program in FLTK a window to be displayed as "About myprog". I have tried to comment it a-la-Doxygen so it appears in the
doc.


Index: Fl_cocoa.mm
===================================================================
--- Fl_cocoa.mm (revision 6960)
+++ Fl_cocoa.mm (working copy)
@@ -123,6 +123,7 @@
 static Fl_Window* resize_from_system;
 static NSView *viewWithLockedFocus = nil;
 static SInt32 MACsystemVersion;
+void *MACMenuOrItemOperation(const char *operation, ...);
 
 #if CONSOLIDATE_MOTION
 static Fl_Window* send_motion;
@@ -2824,28 +2825,35 @@
 }
 
 @interface FLMenuItem : NSMenuItem {
-  Fl_Callback *cb;
-  void *data;
+  const Fl_Menu_Item *item;
 }
-- (FLMenuItem*) putData:(Fl_Callback*)callback pter:(void*)d;
-- (void) doCallback:(id)obj;
-- (void*)getItemData;
+- (void) setFlMenuItem:(const Fl_Menu_Item*)flItem;
+- (void) doCallback:(id)unused;
+- (void) directCallback:(id)unused;
+- (Fl_Menu_Item*)getFlMenuItem;
 @end
 @implementation FLMenuItem
-- (FLMenuItem*) putData:(Fl_Callback*)callback pter:(void*)d
+- (void) setFlMenuItem:(const Fl_Menu_Item*)flItem
 {
-  cb = callback;
-  data = d;
-  return self;
+  item = flItem;
 }
-- (void) doCallback:(id)obj
+- (void) doCallback:(id)unused
 {
-  if (cb) cb((Fl_Widget*)obj, data);
+  if(item) {
+    fl_sys_menu_bar->picked(item);
+    if ( item->flags & FL_MENU_TOGGLE ) {// update the menu toggle symbol
+      [(NSMenuItem*)unused setState:(item->value() ? NSOnState : NSOffState)];
+      }
+  }
 }
-- (void*)getItemData
+- (void) directCallback:(id)unused
 {
-  return data;
+  if( item && item->callback() ) item->do_callback(NULL);
 }
+- (const Fl_Menu_Item*)getFlMenuItem
+{
+  return item;
+}
 @end
 
 void *MACmainMenu(void)
@@ -2873,15 +2881,26 @@
   return (void *)mymenu;
 }
 
-void MACsetAboutMenu( Fl_Callback *cb, void *data )
-// attaches a callback to the "About myprog" item of the application menu
+void fl_mac_set_about(  Fl_Menu_Item *flItem )
+/**
+ * Mac OS: attaches an Fl_Menu_Item to the "About myprog" item of the system application menu.
+ * \note Only the shortcut_, callback_ and user_data_ fields of the Fl_Menu_Item* \p flItem are used.
+ *
+ * \author Manolo Gouy
+ *
+ * \param[in] flItem is a const Fl_Menu_Item*
+ */
 {
   fl_open_display();
   CFStringRef cfname = CFStringCreateCopy(NULL, (CFStringRef)[[appleMenu itemAtIndex:0] title]);
   [appleMenu removeItemAtIndex:0];
   FLMenuItem *item = [[FLMenuItem alloc] autorelease];
-  [item initWithTitle:(NSString*)cfname action:@selector(doCallback:) keyEquivalent:@""];
-  [item putData:cb pter:data];
+  [item initWithTitle:(NSString*)cfname action:@selector(directCallback:) keyEquivalent:@""];
+  if(flItem->shortcut()) {
+    MACMenuOrItemOperation("setKeyEquivalent", item, flItem->shortcut() & 0xff);
+    MACMenuOrItemOperation("setKeyEquivalentModifierMask", item, flItem->shortcut() );
+    }
+  [item setFlMenuItem:flItem];
   [appleMenu insertItem:item atIndex:0];
   CFRelease(cfname);
   [item setTarget:item];
@@ -2991,27 +3010,25 @@
     value = va_arg(ap, int);
     [menu removeItem:[menu itemAtIndex:value]];
   }
-  else if(strcmp(operation, "getItemData") == 0) {//arguments: NSMenu*, int. Returns the item's data
-                                                  //items can have a callback and a data pointer attached to them. This returns the data pointer
+  else if(strcmp(operation, "getFlMenuItem") == 0) {//arguments: NSMenu*, int. Returns the item's Fl_Menu_Item*
     menu = va_arg(ap, NSMenu*);
     value = va_arg(ap, int);
-    retval = [(FLMenuItem *)[menu itemAtIndex:value] getItemData];
+    retval = [(FLMenuItem *)[menu itemAtIndex:value] getFlMenuItem];
   }
   else if(strcmp(operation, "addNewItem") == 0) {
-    //arguments: NSMenu *menu, const char *name, Fl_Callback *cb, void *data, int *prank
-    //creates a new menu item named 'name' at the end of 'menu'
-    //attaches callback 'cb' and data pointer 'data' to it
+    //arguments: NSMenu *menu, const Fl_Menu_Item* flItem, int *prank
+    //creates a new menu item at the end of 'menu'
+    //attaches the Fl_Menu_Item *flItem to it
     //upon return, puts the rank of the new item in *prank unless prank is NULL
     menu = va_arg(ap, NSMenu*);
-    char *name = remove_ampersand(va_arg(ap, const char*));
-    Fl_Callback *cb = va_arg(ap, Fl_Callback*);
-    pter = va_arg(ap, void *);
+    const Fl_Menu_Item *flItem = va_arg(ap, const Fl_Menu_Item*);
+    char *name = remove_ampersand(flItem->label());
     int *prank = va_arg(ap, int*);
     CFStringRef cfname = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8);
     free(name);
     FLMenuItem *item = [FLMenuItem alloc];
     [item initWithTitle:(NSString*)cfname action:@selector(doCallback:) keyEquivalent:@""];
-    [item putData:cb pter:pter];
+    [item setFlMenuItem:flItem];
     [menu addItem:item];
     CFRelease(cfname);
     [item setTarget:item];
 
 
#37 manolo
15:36 Dec 09, 2009
Ian: you are right, you get non-antialiased text on 10.4. This is
something I overlooked because it does not happen on >= 10.5.
But it's easy to repair, apply this patch (as an svn diff)
to fl_font_mac.cxx.
(This is a patch to put in the svn, not something only for Ian)

svn diff fl_font_mac.cxx
Index: fl_font_mac.cxx
===================================================================
--- fl_font_mac.cxx (revision 6958)
+++ fl_font_mac.cxx (working copy)
@@ -485,8 +485,14 @@
   ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr);
 
   err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n);
+#if defined(__APPLE_COCOA__)
+  CGContextSetShouldAntialias(fl_gc, true);
+#endif
   err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y));
+#if defined(__APPLE_COCOA__)
+  CGContextSetShouldAntialias(fl_gc, false);
 #endif
+#endif
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
   }
 #endif
@@ -520,7 +526,13 @@
   ATSUSetLayoutControls(layout, 2, iTag, iSize, aAttr);
 
   err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n);
+#if defined(__APPLE_COCOA__)
+  CGContextSetShouldAntialias(fl_gc, true);
+#endif
   err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y));
+#if defined(__APPLE_COCOA__)
+  CGContextSetShouldAntialias(fl_gc, false);
+#endif
   //restore layout baseline
   ang = IntToFixed(0);
   ATSUSetLayoutControls(layout, 2, iTag, iSize, aAttr);
@@ -553,8 +565,14 @@
   ATSUSetLayoutControls (layout, 2, iTag, iSize, aAttr );
 
   err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n);
+#if defined(__APPLE_COCOA__)
+  CGContextSetShouldAntialias(fl_gc, true);
+#endif
   err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x-offs), FloatToFixed(y));
+#if defined(__APPLE_COCOA__)
+  CGContextSetShouldAntialias(fl_gc, false);
 #endif
+#endif
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
   }
 #endif
 
 
#38 manolo
08:16 Dec 10, 2009
Here is a correction of the vanishing "About myprog" window bug.
In function do_queued_events of file src/Fl_cocoa.mm, put:

  //necessary so that after closing a non-FLTK window (e.g., Fl_Native_File_Chooser)
  //the front window turns key again
  if([NSApp keyWindow] == nil) {
    Fl_Window *w = Fl::first_window();
    if (w) {
      NSWindow *cw = (NSWindow*)Fl_X::i(w)->xid;
      if([cw isVisible] && ![cw isMiniaturized] && ([cw styleMask] & NSTitledWindowMask) ) {
        if(![cw isKeyWindow]) {//always make Fl::first_window() the key window
          [cw makeKeyWindow];
        }
      }
    }
  }
  NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask

where the first and last lines indicate where this goes.
 
 
#39 manolo
02:29 Dec 11, 2009
Let's do a recap of where we are now.
I upload file recap.zip containing all modified source code (and .h)
to avoid svn diff problems, and will follow Greg's advice thereafter.

Solved issues:
- non-antialiased fonts under 10.4
- Sudoku crash
- vanishing "About myprog" window

New API proposal:
- fl_mac_set_about(const Fl_Menu_Item *item)
to connect an FLTK menu item to the "About myprog" application menu item

Extending Fl_Sys_Menu_Bar towards more complete FLTK behavior:
I have added these two member functions (that's new):
int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0);
void remove(int n);
so system menus can now also be modified programmatically. This
is done in a very brutal way (delete the whole menu bar and recreate
it fully after any add or remove) but it requires very, very little
code (so hopefully no bug).

Pending issues:
- white footprint behind Fl_Native_file_Chooser wwindow in Ian's app
- drag crash in Ian's app
- nonfunctional keyboard accelerators in Ian's app
 
 
#40 AlbrechtS
03:26 Dec 11, 2009
Regarding
> New API proposal:
> - fl_mac_set_about(const Fl_Menu_Item *item)
> to connect an FLTK menu item to the "About myprog" application menu item

Maybe it would be better to remove "_mac" from the name, just in case we add similar functions for other platforms, i.e. call it fl_set_about() or fl_about_menu() or similar.

This could be documented as (currently) only for the Mac system menu, and thus do nothing for other platforms.
 
 
#41 manolo
11:36 Dec 12, 2009
Hi all,

I have uploaded file recap2.zip that contains several patched files
and .h to solve, in addition to what has already been mentionned:
- missing shortcuts in Sudoku system menu on PPC
- drag with square image when not dragging from an Fl_Input_ object
- compilation without __APPLE_COCOA__

This also contains a well verified Fl_Sys_Menu_Bar API extended with
add(), remove(), and replace() functions that are enough to
programmatically control the system menu bar.
 
 
#42 manolo
11:43 Dec 12, 2009
and recap2.zip also contains my final proposal for
   fl_mac_set_about(Fl_Callback *cb, void *user_data, int shortcut = 0);
 
 
#43 manolo
12:05 Dec 13, 2009
So, you begin to write objective-c code! Beautiful!
I have seen the nice improvement in the drag text effect. Great.

I upload in mach-sysmenuh-cocoa.patch 3 patches as follows:
- in mac.H, add the fl_mac_set_about prototype as discussed

- in Fl_Sys_Menu_Bar.H, add missing #ifdef __APPLE_COCOA__
because the new functions (add, remove, replace) don't apply to Carbon
(sorry, my fault).

- in Fl_cocoa.mm, I don't think the code you added in handleUpdateEvent
is necessary and explain why in comments. But I may be wrong. Let me know.
The patch also introduces some check code that makes sure function
carbonTextHandler is applied only to a genuine FLTK window,
which does no harm for sure, and might even help with Ian's bug.
The fl_mac_set_about first line is corrected (necessary because =0
is in prototype now), and better commented.

About the dynamic_type question: I will see if I can do otherwise
with w->type() call. If not, I don't see how to do otherwise.
 
 
#44 matt
12:42 Dec 13, 2009
Yes, the dnd effect is nice, but for whatever reason, it does not work if data is dragged from the same program. In general, I have a hard time figuring out how a "damage" situation is communicated to Cocoa. The code I added seem to have the ability to invalidate graphics regions, but somehow it is never called. My last prot has been such a long time ago that I don't know anymore where to hook in :-(  
 
#45 AlbrechtS
14:21 Dec 13, 2009
manolo gouy wrote:

> About the dynamic_type question: I will see if I can do otherwise
> with w->type() call. If not, I don't see how to do otherwise.

You wanted to say "dynamic_cast". I'd appreciate if we don't use type() for anything else than widget-specific types, and there is no general way to use type() to decide if the widget is an Fl_Input_* class.

I also don't think that it's worth the effort to display the dragged text, because this would be Mac-specific, and I'm sure that other users wouldn't like it. Thus my proposal: use a generic image (or cursor symbol or ...), just as it was before and as it is on other platforms.

Just my 2 ct.
 
 
#46 manolo
09:57 Dec 15, 2009
Matt: 64-bit building using the make system is doable with:
make CC="gcc -arch x86_64" CXX="g++ -arch x86_64"

Presently, it fails on file fl_draw_pixmap.cxx.
Please, correct line 339 of this file into:
        U32* colors = (U32*)d.byte1[*p++];
that is, make explicit the implicit cast therein.

I know you can run the build on any intel mac, even if you can't run the
64-bit executables it will make.

Did you find any remaining bug in the demo programs (or others)
you could have tested ?

Thanks.
 
 
#47 manolo
01:38 Dec 16, 2009
I uploaded file Fl_Native_File_Chooser-0.86-Cocoa.tar.gz that
slightly expands the latest version (0.86) of Greg's highly useful
file chooser in 3 ways:

1) Its FLTK1 version is Cocoa-ized (with changes bracketted by
#ifdef __APPLE_COCOA__ / #endif, as for the rest of FLTK).
I have the impression that it's not possible with Cocoa to build
a save browser with Fl_Native_File_Chooser::SAVEAS_CONFIRM off.
A telling observation is that the Carbon
subframework that implements the file chooser dialogs used by
Fl_Native_File_Chooser, NavigationServices.framework,
is present in 64-bit architecture in Mac OS 10.5, but absent from 10.6.
This is the only case I have noticed of a 64-bit Carbon API that
disappeared after having existed, but it clearly suggests to me
that replacing Carbon APIs by Cocoa ones is good for the future of
FLTK on the Mac platform.

2) I have modified its WIN32 part so that Unicode file- and path-names,
rather than ASCII-only, are properly handled and interfaced wih FLTK
UTF8 strings.

3) Upon request of some of my users, I have set the X11 dialogs
so hidden files (.xxx) don't appear by default in the chooser,
and added a "show hidden" button to have hidden files appear if needed.
This improves the chooser's usability, especially when browsing
the user's home directory that is often full of hidden files and
directories in the unix context. This feature requires access to the
underlying Fl_File_Browser object which is the private variable fileList
of the Fl_File_Chooser object. I used a little hack to steal a pointer
to that object, but believe it would be cleaner to set, in file
FL/Fl_File_Chooser.H, variable fileList public instead of private,
or to set it protected and make Fl_Native_File_Chooser a friend of class
Fl_File_Chooser.
Is that possible ?
 
 
#48 matt
12:45 Dec 18, 2009
Allright, applied the next patch.

I suggest that we close this STR because it gets crowded. We can then open new STRs for new issues that come up with the Cocoa option.

About the Native File Chooser: I tried to figure out what's going on but couldn't. It's just a huge bunch of files. Would it be possible to

- make this a new STR
- just publish a patch, not a whole tree of files.

Thanks.
 
 
#49 manolo
23:15 Dec 18, 2009
Thanks Matt.
With the uploaded Fl_cocoa_V2.mm file that solves the "white
rectangle after FNFC" bug in Ian's app, plus some misc cleaning,
I agree you could close this STR.
I'll try to simplify the FNFC patch that boils down to not that
many files.
 
 
#50 manolo
23:21 Dec 18, 2009
... and there is also the compilation error in fl_draw_pixmap.cxx
that stops 64-bit make builds. See my post Dec 15 09:57
to correct that.
 
 
#51 manolo
07:14 Dec 21, 2009
Matt: a last patch before closing this STR. :=)
Please, update the svn with the 3 files in uploaded file cocoa-patch.zip
(you can ignore file Fl_cocoa_v2.mm that is included in this last one).
This will solve all remaining Cocoa-FLTK-1.3 bugs I'm aware of:
- white rectangle in Ian's app after Fl_Native_File_Chooser use
- bug in FL_ALT shortcuts
- bug in FL_META shortcuts in Fl_Sys_Menu_Bar
- FL_MENU_RADIO is now working in Fl_Sys_Menu_Bar

By the way, there's a minor bug in demo file sudoku.cxx, the number 8
at line 670 should be replaced by 10.

Greg: do you think you could take care of STR #2298 that aims at
including your Fl_Native_File_Chooser in the FLTK-1.3 svn ?
 
 
#52 AlbrechtS
08:30 Dec 21, 2009
manolo gouy wrote:
> By the way, there's a minor bug in demo file sudoku.cxx, the number 8
> at line 670 should be replaced by 10.

This is now fixed in subversion repository (-r 6972), thanks.
 
 
#53 AlbrechtS
08:38 Dec 21, 2009
... fixed in 1.1.10 as well (svn -r 6973).  
 
#54 manolo
13:38 Dec 22, 2009
Thanks Matt for this last svn update.
Remaining things:
1) one correction in function doCallback of file Fl_cocoa.mm
that fixes the radio menu item bug Ian reported (see my post
Tue Dec 21, 06:27).
2) I think the fl_draw_pixmap.cxx correction is necessary if
we want our users to be able to build 64-bit libraries using make
(with the present svn, the build stops). See my post Dec 15, 09:57.

I leave to Italy for holidays.
Merry Christmas to you all. I hope our chat will resume next year.
 
 
#55 manolo
02:36 Jan 01, 2010
Hi Matt: could you, please, enter this last patch to file
Fl_cocoa.mm (in its doCallback function) that makes
radio items of fl_sys_menu_bar work correctly when
series of items are separated by a divider line.
Thanks. Manolo.


svn diff Fl_cocoa.mm
Index: Fl_cocoa.mm
===================================================================
--- Fl_cocoa.mm (revision 6985)
+++ Fl_cocoa.mm (working copy)
@@ -2899,15 +2899,22 @@
       }
     else if ( item->flags & FL_MENU_RADIO ) {// update the menu radio symbols
       int from = flRank;
-      while(from > 0 && items[from - 1].flags & FL_MENU_RADIO) from--;
+      while( from > 0 && items[from - 1].label() && (items[from - 1].flags & FL_MENU_RADIO) &&
+     !(items[from - 1].flags & FL_MENU_DIVIDER) ) {
+ from--;
+ }
       int to = flRank;
-      while(items[to + 1].flags & FL_MENU_RADIO) to++;
+      while( !(items[to].flags & FL_MENU_DIVIDER) && items[to + 1].label() &&
+     (items[to + 1].flags & FL_MENU_RADIO) ) {
+ to++;
+ }
       NSMenu *nsmenu = [self menu];
       int nsrank = (int)[nsmenu indexOfItem:self];
       for(int i =  from - flRank + nsrank ; i <= to - flRank + nsrank; i++) {
- [[nsmenu itemAtIndex:i] setState:NSOffState];
+ NSMenuItem *nsitem = [nsmenu itemAtIndex:i];
+ if(nsitem != self) [nsitem setState:NSOffState];
+ else [nsitem setState:(item->value() ? NSOnState : NSOffState) ];
         }
-      if(item->value()) [self setState:NSOnState];   
       }
   }
 }
 
 
#56 manolo
09:40 Jan 07, 2010
Matt: could you please enter the patch I have uploaded as
flfontmac-flcocoa.patch that concerns files fl_font_mac.cxx
and Fl_cocoa.mm

The issue with fl_font_mac.cxx is to allow executables built
on recent OS X versions to run on older versions.
I have found that the standard test that was used till now:
if(CTFontCreateWithName != NULL)
does not work because CTFontCreateWithName is known in OS X 10.4.11
even though the doc says it appears in 10.5. So I have replaced
this test by a direct test of the running OS version.

About file Fl_cocoa.mm, after further tests, I conclude that
function performKeyEquivalent of class FLView is indeed necessary.
So the patch removes the commenting out of this function.

Thanks.
 
 
#57 manolo
11:43 Jan 10, 2010
Matt: the same issue applies with file fl_set_fonts_mac.cxx
as with fl_font_mac.cxx. Thus, please, enter also this patch
for this file. Thanks, Manolo

Index: fl_set_fonts_mac.cxx
===================================================================
--- fl_set_fonts_mac.cxx (revision 6991)
+++ fl_set_fonts_mac.cxx (working copy)
@@ -61,10 +61,14 @@
 Fl_Font Fl::set_fonts(const char* xstarname) {
 #pragma unused ( xstarname )
 #if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-if(CTFontCreateWithFontDescriptor != NULL) {
+static SInt32 MACsystemVersion = 0;
+if(MACsystemVersion == 0) Gestalt(gestaltSystemVersion, &MACsystemVersion);
+if(MACsystemVersion >= 0x1050) {
+//if(CTFontCreateWithFontDescriptor != NULL) {// CTFontCreateWithFontDescriptor != NULL on 10.4 also!
   int value[1] = {1};
-  CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)kCTFontCollectionRemoveDuplicatesOption,
- (const void **)&value, 1, NULL, NULL);
+  CFDictionaryRef dict = CFDictionaryCreate(NULL,
+     (const void **)kCTFontCollectionRemoveDuplicatesOption,
+     (const void **)&value, 1, NULL, NULL);
   CTFontCollectionRef fcref = CTFontCollectionCreateFromAvailableFonts(dict);
   CFRelease(dict);
   CFArrayRef arrayref = CTFontCollectionCreateMatchingFontDescriptors(fcref);
 
 
#58 manolo
07:28 Jan 12, 2010
Matt: please apply this important patch to file src/Fl_cocoa.mm .
It corrects a memory allocation bug where any FLTK application
calling Fl::ready() may crash !
It also reiterates the previously suggested changes.

Thanks,
Manolo


Index: Fl_cocoa.mm
===================================================================
--- Fl_cocoa.mm (revision 6989)
+++ Fl_cocoa.mm (working copy)
@@ -491,7 +491,6 @@
 {
         NSEvent *retval = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0]
                                           inMode:NSDefaultRunLoopMode dequeue:NO];
- if(retval != nil) [retval release];
         return retval != nil;
 }
 
@@ -1725,7 +1724,7 @@
 - (void)drawRect:(NSRect)rect;
 - (BOOL)acceptsFirstResponder;
 - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent;
-//- (BOOL)performKeyEquivalent:(NSEvent*)theEvent;
+- (BOOL)performKeyEquivalent:(NSEvent*)theEvent;
 - (void)mouseUp:(NSEvent *)theEvent;
 - (void)rightMouseUp:(NSEvent *)theEvent;
 - (void)otherMouseUp:(NSEvent *)theEvent;
@@ -1755,12 +1754,11 @@
 {  
   return YES;
 }
-/*
 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent
 {  
   OSStatus err = cocoaKeyboardHandler(theEvent);
   return (err ? NO : YES);
-}*/
+}
 - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent
 {  
   Fl_Window *w = [(FLWindow*)[theEvent window] getFl_Window];
@@ -2845,7 +2843,7 @@
   [[appleMenu itemAtIndex:0] setTarget:about];
   [appleMenu addItem:[NSMenuItem separatorItem]];
   // Services Menu
-  services = [[[NSMenu alloc] init] autorelease];
+  services = [[NSMenu alloc] init];
   [appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
   [appleMenu setSubmenu: services forItem: [appleMenu itemWithTitle: @"Services"]];
   // Hide AppName
 
 
#59 manolo
15:25 Jan 15, 2010
Matt: there is a remaining problem with FLTK-1.3-cocoa:
demo mandelbrot does not resize correctly (to see that,
set it to full window size). There are also resize
crashes in other cases.

Please, check-in the uploaded patch cocoa.patch that repairs
that in file Fl_cocoa.mm.

And, it would also be good to check-in the patches for
the font files as well (see my posts Jan 10 and Jan 7
- its part dealing with fl_font_mac.cxx only - on this
forum).

Thanks.
 
 
#60 manolo
14:07 Jan 19, 2010
Matt: if you have some time, could you, please, check-in
the uploaded patch named cocoa-font.patch that pools all remaining
changes related to cocoa-ization of FLTK.

This closes a bug where demo program mandelbrot does not resize
correctly and that may concern more generally apps doing
progressive window update.

It also includes the changes in files fl_font_mac.cxx,
fl_set_fonts_mac.cxx, and fl_draw_pixmap.cxx I mentionned previously.

Many thanks.
 
 
#61 matt
03:07 Jan 26, 2010
Hmmm. Resizing a window interactively does not seem to work half of the time. When I start "file_chooser" from the test suite, I can't pull the window smaller or larger at all. It *does* however work in some of the Fluid dialogs - but not all of them.  
 
#62 greg.ercolano
09:49 Jan 26, 2010
I just updated to svn r7031, and after a 'make distclean; make', file_chooser seems to resize OK under Snow Leopard (10.6.x).

I guess if a 'make clean; make' doesn't help, try a new checkout; since you're a dev and probably hacking away on files, maybe one of the svn merges gave up, leaving you with some mixed files.
 
 
#63 mjbmon
14:09 Feb 09, 2010
Today upgraded my mac to leopard -- tried compiling fltk-1.3.x-r7037

Although the compile worked, my links failed as this builds the 32 bit version. After reading this thread I tried to disable the -arch flag in the configure.in script and did a clean rebuild. Now it works!

Apparently everything has been done but updating the configure.in file in the current release. Good job, folks.
 
 
#64 manolo
01:49 Feb 11, 2010
Hi Christophe: could you, please, tell us whether your large app
is fully supported, in 64-bit mode, by the present FLTK-1.3-cocoa.
If so, we could close this (huge) STR. Thanks.
 
 
#65 mjbmon
18:37 Feb 16, 2010
After some testing with r7037 and r7063 I find that the mouse and wheel handling is buggy. Apparently mouse drag events with button other than 1 are not reported to the application, and wheel events are really bad.

I put some debug statements in the cocoaMouseHandler, and apparently after a push with mouse button 3 no further drag events are reported. So something further up the line in the apple code is probably at fault.
 
 
#66 manolo
22:33 Feb 16, 2010
Mark: could you put up a simple example showing the bug you report ?
That would be very helpful. Alternatively, please, describe the
problem as precisely as possible. You mention two things:
- mouse drag with != 1 button pushed not reported
- wheel events. I use vertical and horizontal wheel in my app
without error, so don't see the problem.
Thanks.
 
 
#67 matt
13:38 Feb 26, 2010
I am closing this because the STR has become much too complex. I would like to ask the users that have still issues to post them as individual new STRs, so we have a better handle on the bugs.

Thanks,

 - Matthias
 
     

Return to Bugs & Features ]

 
 

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