8

Today i tried to implement the owner drawn menu item support in Cocoa and MacOSX 10.5

And what i found was pretty scary when i think about QT which i intended to use for some other projects.

If i see it right there is no future for QT on MacOSX because the whole Appearance Manager with the exeception of a few trivial functions is completely deprecated in 10.5 (i can't even find a public URL anymore) and even the "Developer" color list and the color "constants" in NSColor are marked as not stable and do not use.

With this policy a Toolkit like QT would have no option then dropping MacOSX support which makes sense for Apple in more then one way (remember Nokia is a competitor). And Apple didn't care about dropping Carbon and Java too.

So do i miss something. Is there any kind of Cocoa Appearance manager or any technique which the QT team could use a reasonable fallback? I'm scared that in 10.7 or 10.8 the apperance might be very different.

And please all people who want to close this question as subjective please consider that i'm asking for a technical work around solution to this problem. Its not a discussion about good or bad but if there is a way to get around this limitation.

It is a serious business decision for me which can easily cost tens of thousands of dollars if done wrong and trusting QT turns out to be a failure.

EDIT: This is a link telling me that even the system colors are not supported anymore Accessing System Colors. And it's correct a theme change to graphite does not result in a color list changed notification.

Lothar
  • 12,537
  • 6
  • 72
  • 121
  • What exactly is the problem? There is a Cocoa version of Qt that runs on 10.6. – andref Aug 07 '10 at 15:26
  • What do you mean with Cocoa version? A QT which only uses NSView and a the NSOpenPanel dialog? This will be no help at all. A Cocoa version has to use all Cocoa widgets and this is not the concept behind QT. NSView is just the same as using HWND on windows or a Window on X11. – Lothar Aug 07 '10 at 15:36
  • Ah, I see what you mean. What you want to know is if there is a Cocoa alternative to HITheme (which is what Qt uses to do the drawing atop bare NSViews) in case Apple drops Carbon for good (which it hasn’t yet, see iTunes). Rephrasing the question to sound more Cocoa and less Qt might attract the interest of the right kind of people. – andref Aug 07 '10 at 17:23
  • NSView is not an analogue to window handles on any platform. NSWindow is. Also, that link doesn't say anything about the system colors not being supported anymore; it says only that *some* system colors (those dating back to the Rhapsody days) are no longer useful. – Peter Hosey Aug 08 '10 at 04:04
  • NSView is an analogue of an WS_CHILD styled HWND. NSWindow is a top level or overlapped HWND. – Chris Becke Aug 08 '10 at 06:33
  • Chris Becke: Are you sure an NSWindow added as a child of another NSWindow wouldn't be more accurate? – Peter Hosey Aug 08 '10 at 10:25
  • Can you do that? My understanding of NSWindow and NSView comes not from a deep understanding of the OS-X windowing system, but a mapping of what I know of MS-Windows windows to what I find in XCode and Interface Builder. NSWindow is the base class of the thing that you create when you want a "window" a thing with a title bar, and minimize and maximize buttons. NSView is the base class of buttons, and text boxes and controls in general. – Chris Becke Aug 08 '10 at 11:05
  • @Chris: you can't add NSWindows to other NSWindows. NSWindows are the them resource (remember they have a window number). AFAIK NSView stuff is completely process/user space without any system call. But this doesn't matter here. The question is if QT is able to emulate the native MacOSX GUI in the future. They are already not perfect in this but with 10.5 i see that the complete foundations for them is removed. – Lothar Aug 08 '10 at 16:02
  • Chris Becke, Lothar: Yes, you can add an NSWindow as a child window of another NSWindow. http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/addChildWindow:ordered: Chris Becke: You are correct in your last two sentences. – Peter Hosey Aug 09 '10 at 03:20

2 Answers2

3

I gave up trying to make QT look native. It won't ever work because there are too many subtle behaviors that no cross-platform toolkit can ever mimic well enough to fool users. If a native application is the goal, it's going to be much easier to just spend a little extra time making native interfaces for the platforms that you want to support.

The thing that was keeping me from dumping QT was unfamiliarity with Xcode and Objective-C. You probably already know this, but you can rename any Objective-C (.m) file in Xcode to compile as Objective-C++ (.mm). This lets you link all the C++ code that you want, right where you need it in your project.

Tara Harris
  • 85
  • 10
  • I would still use Qt for Windows work, I think. It's close enough there, and standards are lower, and it's less frustrating to work with. – Steven Fisher Aug 17 '10 at 20:31
  • can you drop a line about what where the most annoying subtle behaviors. – Lothar Aug 18 '10 at 01:14
  • @tewha: Yes i thought the same and then came Windows Vista, Ribbons, the new docking tool, Word 2007 colors and all the other stuff in MFC Feature Pack. I hate MFC but i'm afraid that QT is not very native anymore - depending off course on the kind of application you are writing. – Lothar Aug 18 '10 at 01:17
  • Yeah, I don't need to worry about ribbons and the like. – Steven Fisher Aug 20 '10 at 19:04
0

Firefox is somewhat in the same boat as they are largely cocoa based. Their OS X theme engine implementation can be seen here.

  1. http://mxr.mozilla.org/mozilla2.0/source/widget/src/cocoa/nsNativeThemeCocoa.mm
  2. http://mxr.mozilla.org/mozilla2.0/source/widget/src/cocoa/nsNativeThemeCocoa.h
  3. http://mxr.mozilla.org/mozilla2.0/source/gfx/cairo/cairo/src/cairo-quartz-surface.c

They are relying on Cairo (a platform neutral drawing API) sitting over Quartz to do their rendering.

locka
  • 5,809
  • 3
  • 33
  • 38