From: Ryan Norton Date: Tue, 16 Nov 2004 15:53:38 +0000 (+0000) Subject: makefile regen, include fix, duplicate file fix X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4e69ff22681b5625f52c2b4c7e47c1815df7c306 makefile regen, include fix, duplicate file fix git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/Makefile.in b/Makefile.in index 997146b144..3874841940 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3583,8 +3583,12 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS = \ monodll_tbarwce.o \ monodll_textctrlce.o @COND_TOOLKIT_WINCE@__GUI_SRC_OBJECTS = $(COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS) -@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS = \ -@COND_PLATFORM_MACOSX_1@ monodll_snglinst.o monodll_webkit.o +COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS = \ + monodll_snglinst.o \ + monodll_webkit.o \ + monodll_fontdlgosx.o \ + monodll_colordlgosx.o +@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS = $(COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS) @COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_1 = \ @COND_TOOLKIT_COCOA@ monodll_gsockosx.o monodll_utilsexc_cf.o COND_TOOLKIT_GTK___LOWLEVEL_SRC_OBJECTS_1 = \ @@ -5019,8 +5023,12 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_1 = \ monolib_tbarwce.o \ monolib_textctrlce.o @COND_TOOLKIT_WINCE@__GUI_SRC_OBJECTS_1 = $(COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_1) -@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS_1 = \ -@COND_PLATFORM_MACOSX_1@ monolib_snglinst.o monolib_webkit.o +COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_1 = \ + monolib_snglinst.o \ + monolib_webkit.o \ + monolib_fontdlgosx.o \ + monolib_colordlgosx.o +@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS_1 = $(COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_1) @COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_3 = \ @COND_TOOLKIT_COCOA@ monolib_gsockosx.o monolib_utilsexc_cf.o COND_TOOLKIT_GTK___LOWLEVEL_SRC_OBJECTS_3 = \ @@ -6649,8 +6657,12 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_2 = \ coredll_tbarwce.o \ coredll_textctrlce.o @COND_TOOLKIT_WINCE@__GUI_SRC_OBJECTS_2 = $(COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_2) -@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS_2 = \ -@COND_PLATFORM_MACOSX_1@ coredll_snglinst.o coredll_webkit.o +COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_2 = \ + coredll_snglinst.o \ + coredll_webkit.o \ + coredll_fontdlgosx.o \ + coredll_colordlgosx.o +@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS_2 = $(COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_2) @COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_5 = \ @COND_TOOLKIT_COCOA@ coredll_gsockosx.o coredll_utilsexc_cf.o COND_TOOLKIT_GTK___LOWLEVEL_SRC_OBJECTS_5 = \ @@ -7835,8 +7847,12 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_3 = \ corelib_tbarwce.o \ corelib_textctrlce.o @COND_TOOLKIT_WINCE@__GUI_SRC_OBJECTS_3 = $(COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_3) -@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS_3 = \ -@COND_PLATFORM_MACOSX_1@ corelib_snglinst.o corelib_webkit.o +COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_3 = \ + corelib_snglinst.o \ + corelib_webkit.o \ + corelib_fontdlgosx.o \ + corelib_colordlgosx.o +@COND_PLATFORM_MACOSX_1@__MAC_OSX_SRC_OBJECTS_3 = $(COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_3) @COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_7 = \ @COND_TOOLKIT_COCOA@ corelib_gsockosx.o corelib_utilsexc_cf.o COND_TOOLKIT_GTK___LOWLEVEL_SRC_OBJECTS_7 = \ @@ -9927,6 +9943,12 @@ monodll_statlmac.o: $(srcdir)/src/mac/carbon/statlmac.cpp $(MONODLL_ODEP) monodll_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< +monodll_fontdlgosx.o: $(srcdir)/src/mac/carbon/fontdlgosx.mm $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + +monodll_colordlgosx.o: $(srcdir)/src/mac/carbon/colordlgosx.mm $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + monodll_NSBox.o: $(srcdir)/src/cocoa/NSBox.mm $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< @@ -13245,6 +13267,12 @@ monolib_statlmac.o: $(srcdir)/src/mac/carbon/statlmac.cpp $(MONOLIB_ODEP) monolib_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< +monolib_fontdlgosx.o: $(srcdir)/src/mac/carbon/fontdlgosx.mm $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + +monolib_colordlgosx.o: $(srcdir)/src/mac/carbon/colordlgosx.mm $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + monolib_NSBox.o: $(srcdir)/src/cocoa/NSBox.mm $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< @@ -17370,6 +17398,12 @@ coredll_snglinst.o: $(srcdir)/src/unix/snglinst.cpp $(COREDLL_ODEP) coredll_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< +coredll_fontdlgosx.o: $(srcdir)/src/mac/carbon/fontdlgosx.mm $(COREDLL_ODEP) + $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + +coredll_colordlgosx.o: $(srcdir)/src/mac/carbon/colordlgosx.mm $(COREDLL_ODEP) + $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + coredll_NSBox.o: $(srcdir)/src/cocoa/NSBox.mm $(COREDLL_ODEP) $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< @@ -19854,6 +19888,12 @@ corelib_snglinst.o: $(srcdir)/src/unix/snglinst.cpp $(CORELIB_ODEP) corelib_webkit.o: $(srcdir)/src/html/htmlctrl/webkit/webkit.mm $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< +corelib_fontdlgosx.o: $(srcdir)/src/mac/carbon/fontdlgosx.mm $(CORELIB_ODEP) + $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + +corelib_colordlgosx.o: $(srcdir)/src/mac/carbon/colordlgosx.mm $(CORELIB_ODEP) + $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + corelib_NSBox.o: $(srcdir)/src/cocoa/NSBox.mm $(CORELIB_ODEP) $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< @@ -23665,12 +23705,6 @@ SAMPLES_DIST: ALL_GUI_DIST cp $(SAMPDIR)/mdi/*.xpm $(DISTDIR)/samples/mdi cp $(SAMPDIR)/mdi/bitmaps/*.xpm $(DISTDIR)/samples/mdi/bitmaps - mkdir $(DISTDIR)/samples/mediaplayer - cp $(SAMPDIR)/mediaplayer/Makefile.in $(DISTDIR)/samples/mediaplayer - cp $(SAMPDIR)/mediaplayer/makefile.unx $(DISTDIR)/samples/mediaplayer - cp $(SAMPDIR)/mediaplayer/*.cpp $(DISTDIR)/samples/mediaplayer - cp $(SAMPDIR)/mediaplayer/*.xpm $(DISTDIR)/samples/mediaplayer - mkdir $(DISTDIR)/samples/memcheck cp $(SAMPDIR)/memcheck/Makefile.in $(DISTDIR)/samples/memcheck cp $(SAMPDIR)/memcheck/makefile.unx $(DISTDIR)/samples/memcheck diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index a315dd91b5..a04986cf00 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1669,8 +1669,8 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/html/htmlctrl/webkit/webkit.mm - src/mac/carbon/fontdlg.mm - src/mac/carbon/colordlg.mm + src/mac/carbon/fontdlgosx.mm + src/mac/carbon/colordlgosx.mm diff --git a/src/mac/carbon/colordlg.mm b/src/mac/carbon/colordlg.mm deleted file mode 100644 index 790785c4dc..0000000000 --- a/src/mac/carbon/colordlg.mm +++ /dev/null @@ -1,195 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: colordlg.cpp -// Purpose: wxColourDialog class. NOTE: you can use the generic class -// if you wish, instead of implementing this. -// Author: Stefan Csomor -// Modified by: -// Created: 1998-01-01 -// RCS-ID: $Id$ -// Copyright: (c) Stefan Csomor -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// declarations -// =========================================================================== - -// --------------------------------------------------------------------------- -// headers -// --------------------------------------------------------------------------- - -#ifdef __GNUG__ -#pragma implementation "colordlg.h" -#endif - -#include "wx/mac/colordlg.h" -#include "wx/fontdlg.h" - -#if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) -#endif - -// ============================================================================ -// implementation -// ============================================================================ - -//Mac OSX 10.2+ only -#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX - -// Cocoa headers -#include "wx/cocoa/autorelease.h" -#include "wx/cocoa/string.h" - -#import -#import -#import -#import -#import - -// --------------------------------------------------------------------------- -// wxCPWCDelegate - Window Closed delegate -// --------------------------------------------------------------------------- - -@interface wxCPWCDelegate : NSObject -{ - bool m_bIsClosed; -} - -// Delegate methods -- (id)init; -- (BOOL)windowShouldClose:(id)sender; -- (BOOL)isClosed; -@end // interface wxNSFontPanelDelegate : NSObject - -@implementation wxCPWCDelegate : NSObject - -- (id)init -{ - [super init]; - m_bIsClosed = false; - - return self; -} - -- (BOOL)windowShouldClose:(id)sender -{ - m_bIsClosed = true; - - [NSApp abortModal]; - [NSApp stopModal]; - return YES; -} - -- (BOOL)isClosed -{ - return m_bIsClosed; -} - -@end // wxNSFontPanelDelegate - -/* - * wxColourDialog - */ - -wxColourDialog::wxColourDialog() -{ - m_dialogParent = NULL; -} - -wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data) -{ - Create(parent, data); -} - -bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) -{ - m_dialogParent = parent; - - if (data) - m_colourData = *data; - - // - // This is the key call - this initializes - // events and window stuff for cocoa for carbon - // applications. - // - // This is also the only call here that is - // 10.2+ specific (the rest is OSX only), - // which, ironically, the carbon font - // panel requires. - // - bool bOK = NSApplicationLoad(); - - //autorelease pool - req'd for carbon - NSAutoreleasePool *thePool; - thePool = [[NSAutoreleasePool alloc] init]; - - if(m_colourData.m_dataColour.Ok()) - [[NSColorPanel sharedColorPanel] setColor: - [NSColor colorWithCalibratedRed:m_colourData.m_dataColour.Red() / 255.0 - green:m_colourData.m_dataColour.Red() / 255.0 - blue:m_colourData.m_dataColour.Red() / 255.0 - alpha:1.0] - ]; - else - [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]]; - - //We're done - free up the pool - [thePool release]; - - return bOK; -} -int wxColourDialog::ShowModal() -{ - //Start the pool. Required for carbon interaction - //(For those curious, the only thing that happens - //if you don't do this is a bunch of error - //messages about leaks on the console, - //with no windows shown or anything). - NSAutoreleasePool *thePool; - thePool = [[NSAutoreleasePool alloc] init]; - - //Get the shared color and font panel - NSColorPanel* theColorPanel = [NSColorPanel sharedColorPanel]; - - //Create and assign the delegates (cocoa event handlers) so - //we can tell if a window has closed/open or not - wxCPWCDelegate* theCPDelegate = [[wxCPWCDelegate alloc] init]; - [theColorPanel setDelegate:theCPDelegate]; - - // - // Start the color panel modal loop - // - NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel]; - for (;;) - { - [NSApp runModalSession:session]; - - //If the color panel is closed, return the font panel modal loop - if ([theCPDelegate isClosed]) - break; - } - [NSApp endModalSession:session]; - - //free up the memory for the delegates - we don't need them anymore - [theCPDelegate release]; - - //Get the shared color panel along with the chosen color and set the chosen color - NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; - - m_colourData.m_dataColour.Set( - (unsigned char) ([theColor redComponent] * 255.0), - (unsigned char) ([theColor greenComponent] * 255.0), - (unsigned char) ([theColor blueComponent] * 255.0) - ); - - //Release the pool, we're done :) - [thePool release]; - - //Return ID_OK - there are no "apply" buttons or the like - //on either the font or color panel - return wxID_OK; -} - -#endif //use native font dialog - diff --git a/src/mac/carbon/colordlgosx.mm b/src/mac/carbon/colordlgosx.mm new file mode 100644 index 0000000000..f1246b418a --- /dev/null +++ b/src/mac/carbon/colordlgosx.mm @@ -0,0 +1,195 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: colordlg.cpp +// Purpose: wxColourDialog class. NOTE: you can use the generic class +// if you wish, instead of implementing this. +// Author: Stefan Csomor +// Modified by: +// Created: 1998-01-01 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// =========================================================================== +// declarations +// =========================================================================== + +// --------------------------------------------------------------------------- +// headers +// --------------------------------------------------------------------------- + +#ifdef __GNUG__ +#pragma implementation "colordlg.h" +#endif + +#include "wx/mac/colordlg.h" +#include "wx/fontdlg.h" + +// ============================================================================ +// implementation +// ============================================================================ + +//Mac OSX 10.2+ only +#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX + +#if !USE_SHARED_LIBRARY +IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) +#endif + +// Cocoa headers +#include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" + +#import +#import +#import +#import +#import + +// --------------------------------------------------------------------------- +// wxCPWCDelegate - Window Closed delegate +// --------------------------------------------------------------------------- + +@interface wxCPWCDelegate : NSObject +{ + bool m_bIsClosed; +} + +// Delegate methods +- (id)init; +- (BOOL)windowShouldClose:(id)sender; +- (BOOL)isClosed; +@end // interface wxNSFontPanelDelegate : NSObject + +@implementation wxCPWCDelegate : NSObject + +- (id)init +{ + [super init]; + m_bIsClosed = false; + + return self; +} + +- (BOOL)windowShouldClose:(id)sender +{ + m_bIsClosed = true; + + [NSApp abortModal]; + [NSApp stopModal]; + return YES; +} + +- (BOOL)isClosed +{ + return m_bIsClosed; +} + +@end // wxNSFontPanelDelegate + +/* + * wxColourDialog + */ + +wxColourDialog::wxColourDialog() +{ + m_dialogParent = NULL; +} + +wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data) +{ + Create(parent, data); +} + +bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) +{ + m_dialogParent = parent; + + if (data) + m_colourData = *data; + + // + // This is the key call - this initializes + // events and window stuff for cocoa for carbon + // applications. + // + // This is also the only call here that is + // 10.2+ specific (the rest is OSX only), + // which, ironically, the carbon font + // panel requires. + // + bool bOK = NSApplicationLoad(); + + //autorelease pool - req'd for carbon + NSAutoreleasePool *thePool; + thePool = [[NSAutoreleasePool alloc] init]; + + if(m_colourData.m_dataColour.Ok()) + [[NSColorPanel sharedColorPanel] setColor: + [NSColor colorWithCalibratedRed:m_colourData.m_dataColour.Red() / 255.0 + green:m_colourData.m_dataColour.Red() / 255.0 + blue:m_colourData.m_dataColour.Red() / 255.0 + alpha:1.0] + ]; + else + [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]]; + + //We're done - free up the pool + [thePool release]; + + return bOK; +} +int wxColourDialog::ShowModal() +{ + //Start the pool. Required for carbon interaction + //(For those curious, the only thing that happens + //if you don't do this is a bunch of error + //messages about leaks on the console, + //with no windows shown or anything). + NSAutoreleasePool *thePool; + thePool = [[NSAutoreleasePool alloc] init]; + + //Get the shared color and font panel + NSColorPanel* theColorPanel = [NSColorPanel sharedColorPanel]; + + //Create and assign the delegates (cocoa event handlers) so + //we can tell if a window has closed/open or not + wxCPWCDelegate* theCPDelegate = [[wxCPWCDelegate alloc] init]; + [theColorPanel setDelegate:theCPDelegate]; + + // + // Start the color panel modal loop + // + NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel]; + for (;;) + { + [NSApp runModalSession:session]; + + //If the color panel is closed, return the font panel modal loop + if ([theCPDelegate isClosed]) + break; + } + [NSApp endModalSession:session]; + + //free up the memory for the delegates - we don't need them anymore + [theCPDelegate release]; + + //Get the shared color panel along with the chosen color and set the chosen color + NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + + m_colourData.m_dataColour.Set( + (unsigned char) ([theColor redComponent] * 255.0), + (unsigned char) ([theColor greenComponent] * 255.0), + (unsigned char) ([theColor blueComponent] * 255.0) + ); + + //Release the pool, we're done :) + [thePool release]; + + //Return ID_OK - there are no "apply" buttons or the like + //on either the font or color panel + return wxID_OK; +} + +#endif //use native font dialog + diff --git a/src/mac/carbon/fontdlg.mm b/src/mac/carbon/fontdlg.mm deleted file mode 100644 index be1a6e1b05..0000000000 --- a/src/mac/carbon/fontdlg.mm +++ /dev/null @@ -1,383 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: fontdlg.cpp -// Purpose: wxFontDialog class. -// Author: Ryan Norton -// Modified by: -// Created: 2004-10-03 -// RCS-ID: $Id$ -// Copyright: (c) Ryan Norton -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// =========================================================================== -// declarations -// =========================================================================== - -// --------------------------------------------------------------------------- -// headers -// --------------------------------------------------------------------------- - -#ifdef __GNUG__ -#pragma implementation "fontdlg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/cmndata.h" - #include "wx/fontdlg.h" - #include "wx/fontutil.h" - #include "wx/log.h" -#endif - -#if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) -#endif - -// ============================================================================ -// implementation -// ============================================================================ - -//Mac OSX 10.2+ only -#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX - -// Cocoa headers -#include "wx/cocoa/autorelease.h" -#include "wx/cocoa/string.h" - -#import -#import -#import -#import -#import - -// --------------------------------------------------------------------------- -// wxWCDelegate - Window Closed delegate -// --------------------------------------------------------------------------- - -@interface wxWCDelegate : NSObject -{ - bool m_bIsClosed; -} - -// Delegate methods -- (id)init; -- (BOOL)windowShouldClose:(id)sender; -- (BOOL)isClosed; -@end // interface wxNSFontPanelDelegate : NSObject - -@implementation wxWCDelegate : NSObject - -- (id)init -{ - [super init]; - m_bIsClosed = false; - - return self; -} - -- (BOOL)windowShouldClose:(id)sender -{ - m_bIsClosed = true; - - [NSApp abortModal]; - [NSApp stopModal]; - return YES; -} - -- (BOOL)isClosed -{ - return m_bIsClosed; -} - -@end // wxNSFontPanelDelegate - -// --------------------------------------------------------------------------- -// wxWCODelegate - Window Closed or Open delegate -// --------------------------------------------------------------------------- - -@interface wxWCODelegate : NSObject -{ - bool m_bIsClosed; - bool m_bIsOpen; -} - -// Delegate methods -- (id)init; -- (BOOL)windowShouldClose:(id)sender; -- (void)windowDidUpdate:(NSNotification *)aNotification; -- (BOOL)isClosed; -- (BOOL)isOpen; -@end // interface wxNSFontPanelDelegate : NSObject - -@implementation wxWCODelegate : NSObject - -- (id)init -{ - [super init]; - m_bIsClosed = false; - m_bIsOpen = false; - - return self; -} - -- (BOOL)windowShouldClose:(id)sender -{ - m_bIsClosed = true; - m_bIsOpen = false; - - [NSApp abortModal]; - [NSApp stopModal]; - return YES; -} - -- (void)windowDidUpdate:(NSNotification *)aNotification -{ - if (m_bIsOpen == NO) - { - m_bIsClosed = false; - m_bIsOpen = true; - - [NSApp abortModal]; - [NSApp stopModal]; - } -} - -- (BOOL)isClosed -{ - return m_bIsClosed; -} - -- (BOOL)isOpen -{ - return m_bIsOpen; -} - -@end // wxNSFontPanelDelegate - -// --------------------------------------------------------------------------- -// wxFontDialog -// --------------------------------------------------------------------------- - -wxFontDialog::wxFontDialog() -{ -} - -wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& data) -{ - Create(parent, data); -} - -wxFontDialog::~wxFontDialog() -{ -} - -bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data) -{ - m_fontData = data; - - // - // This is the key call - this initializes - // events and window stuff for cocoa for carbon - // applications. - // - // This is also the only call here that is - // 10.2+ specific (the rest is OSX only), - // which, ironically, the carbon font - // panel requires. - // - bool bOK = NSApplicationLoad(); - - //autorelease pool - req'd for carbon - NSAutoreleasePool *thePool; - thePool = [[NSAutoreleasePool alloc] init]; - - //Get the initial wx font - wxFont& thewxfont = m_fontData.m_initialFont; - - //if the font is valid set the default (selected) font of the - //NSFontDialog to that font - if (thewxfont.Ok()) - { - NSFontTraitMask theMask = 0; - - if(thewxfont.GetStyle() == wxFONTSTYLE_ITALIC) - theMask |= NSItalicFontMask; - - if(thewxfont.IsFixedWidth()) - theMask |= NSFixedPitchFontMask; - - NSFont* theDefaultFont = - [[NSFontManager sharedFontManager] fontWithFamily: - wxNSStringWithWxString(thewxfont.GetFaceName()) - traits:theMask - weight:thewxfont.GetWeight() == wxBOLD ? 9 : - thewxfont.GetWeight() == wxLIGHT ? 0 : 5 - size: (float)(thewxfont.GetPointSize()) - ]; - - wxASSERT_MSG(theDefaultFont, wxT("Invalid default font for wxCocoaFontDialog!")); - - //set the initial font of the NSFontPanel - //(the font manager calls the appropriate NSFontPanel method) - [[NSFontManager sharedFontManager] setSelectedFont:theDefaultFont isMultiple:NO]; - - } - - if(m_fontData.m_fontColour.Ok()) - [[NSColorPanel sharedColorPanel] setColor: - [NSColor colorWithCalibratedRed:m_fontData.m_fontColour.Red() / 255.0 - green:m_fontData.m_fontColour.Red() / 255.0 - blue:m_fontData.m_fontColour.Red() / 255.0 - alpha:1.0] - ]; - else - [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]]; - - //We're done - free up the pool - [thePool release]; - - return bOK; -} - -int wxFontDialog::ShowModal() -{ - //Start the pool. Required for carbon interaction - //(For those curious, the only thing that happens - //if you don't do this is a bunch of error - //messages about leaks on the console, - //with no windows shown or anything). - NSAutoreleasePool *thePool; - thePool = [[NSAutoreleasePool alloc] init]; - - //Get the shared color and font panel - NSFontPanel* theFontPanel = [NSFontPanel sharedFontPanel]; - NSColorPanel* theColorPanel = [NSColorPanel sharedColorPanel]; - - //Create and assign the delegates (cocoa event handlers) so - //we can tell if a window has closed/open or not - wxWCDelegate* theFPDelegate = [[wxWCDelegate alloc] init]; - [theFontPanel setDelegate:theFPDelegate]; - - wxWCODelegate* theCPDelegate = [[wxWCODelegate alloc] init]; - [theColorPanel setDelegate:theCPDelegate]; - - // - // Begin the modal loop for the font and color panels - // - // The idea is that we first make the font panel modal, - // but if the color panel is opened, unless we stop the - // modal loop the color panel opens behind the font panel - // with no input acceptable to it - which makes it useless. - // - // So we set up delegates for both the color and font panels, - // and the if the font panel opens the color panel, we - // stop the modal loop, and start a seperate modal loop for - // the color panel until the color panel closes, switching - // back to the font panel modal loop once it does close. - // - do - { - // - // Start the font panel modal loop - // - NSModalSession session = [NSApp beginModalSessionForWindow:theFontPanel]; - for (;;) - { - [NSApp runModalSession:session]; - - //If the font panel is closed or the font panel - //opened the color panel, break - if ([theFPDelegate isClosed] || [theCPDelegate isOpen]) - break; - } - [NSApp endModalSession:session]; - - //is the color panel open? - if ([theCPDelegate isOpen]) - { - // - // Start the color panel modal loop - // - NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel]; - for (;;) - { - [NSApp runModalSession:session]; - - //If the color panel is closed, return the font panel modal loop - if ([theCPDelegate isClosed]) - break; - } - [NSApp endModalSession:session]; - } - //If the font panel is still alive (I.E. we broke - //out of its modal loop because the color panel was - //opened) return the font panel modal loop - }while([theFPDelegate isClosed] == NO); - - //free up the memory for the delegates - we don't need them anymore - [theFPDelegate release]; - [theCPDelegate release]; - - //Get the font the user selected - NSFont* theFont = [theFontPanel panelConvertFont:[NSFont userFontOfSize:0]]; - - //Get more information about the user's chosen font - NSFontTraitMask theTraits = [[NSFontManager sharedFontManager] traitsOfFont:theFont]; - int theFontWeight = [[NSFontManager sharedFontManager] weightOfFont:theFont]; - int theFontSize = (int) [theFont pointSize]; - - //Set the wx font to the appropriate data - if(theTraits & NSFixedPitchFontMask) - m_fontData.m_chosenFont.SetFamily(wxTELETYPE); - - m_fontData.m_chosenFont.SetFaceName(wxStringWithNSString([theFont familyName])); - m_fontData.m_chosenFont.SetPointSize(theFontSize); - m_fontData.m_chosenFont.SetStyle(theTraits & NSItalicFontMask ? wxFONTSTYLE_ITALIC : 0); - m_fontData.m_chosenFont.SetWeight(theFontWeight < 5 ? wxLIGHT : - theFontWeight >= 9 ? wxBOLD : wxNORMAL); - - //Get the shared color panel along with the chosen color and set the chosen color - NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; - - m_fontData.m_fontColour.Set((unsigned char) ([theColor redComponent] * 255.0), - (unsigned char) ([theColor greenComponent] * 255.0), - (unsigned char) ([theColor blueComponent] * 255.0)); - - //Friendly debug stuff -#ifdef FONTDLGDEBUG - wxPrintf(wxT("---Font Panel---\n--NS--\nSize:%f\nWeight:%i\nTraits:%i\n--WX--\nFaceName:%s\nPointSize:%i\nStyle:%i\nWeight:%i\nColor:%i,%i,%i\n---END Font Panel---\n"), - - (float) theFontSize, - theFontWeight, - theTraits, - - m_fontData.m_chosenFont.GetFaceName().c_str(), - m_fontData.m_chosenFont.GetPointSize(), - m_fontData.m_chosenFont.GetStyle(), - m_fontData.m_chosenFont.GetWeight(), - m_fontData.m_fontColour.Red(), - m_fontData.m_fontColour.Green(), - m_fontData.m_fontColour.Blue() ); -#endif - - //Release the pool, we're done :) - [thePool release]; - - //Return ID_OK - there are no "apply" buttons or the like - //on either the font or color panel - return wxID_OK; -} - -//old api stuff (REMOVE ME) -bool wxFontDialog::IsShown() const -{ - return false; -} - -#endif // 10.2+ diff --git a/src/mac/carbon/fontdlgosx.mm b/src/mac/carbon/fontdlgosx.mm new file mode 100644 index 0000000000..7bc885bd3c --- /dev/null +++ b/src/mac/carbon/fontdlgosx.mm @@ -0,0 +1,383 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: fontdlg.cpp +// Purpose: wxFontDialog class. +// Author: Ryan Norton +// Modified by: +// Created: 2004-10-03 +// RCS-ID: $Id$ +// Copyright: (c) Ryan Norton +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// =========================================================================== +// declarations +// =========================================================================== + +// --------------------------------------------------------------------------- +// headers +// --------------------------------------------------------------------------- + +#ifdef __GNUG__ +#pragma implementation "fontdlg.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/cmndata.h" + #include "wx/fontdlg.h" + #include "wx/fontutil.h" + #include "wx/log.h" +#endif + +// ============================================================================ +// implementation +// ============================================================================ + +//Mac OSX 10.2+ only +#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX + +#if !USE_SHARED_LIBRARY +IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) +#endif + +// Cocoa headers +#include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" + +#import +#import +#import +#import +#import + +// --------------------------------------------------------------------------- +// wxWCDelegate - Window Closed delegate +// --------------------------------------------------------------------------- + +@interface wxWCDelegate : NSObject +{ + bool m_bIsClosed; +} + +// Delegate methods +- (id)init; +- (BOOL)windowShouldClose:(id)sender; +- (BOOL)isClosed; +@end // interface wxNSFontPanelDelegate : NSObject + +@implementation wxWCDelegate : NSObject + +- (id)init +{ + [super init]; + m_bIsClosed = false; + + return self; +} + +- (BOOL)windowShouldClose:(id)sender +{ + m_bIsClosed = true; + + [NSApp abortModal]; + [NSApp stopModal]; + return YES; +} + +- (BOOL)isClosed +{ + return m_bIsClosed; +} + +@end // wxNSFontPanelDelegate + +// --------------------------------------------------------------------------- +// wxWCODelegate - Window Closed or Open delegate +// --------------------------------------------------------------------------- + +@interface wxWCODelegate : NSObject +{ + bool m_bIsClosed; + bool m_bIsOpen; +} + +// Delegate methods +- (id)init; +- (BOOL)windowShouldClose:(id)sender; +- (void)windowDidUpdate:(NSNotification *)aNotification; +- (BOOL)isClosed; +- (BOOL)isOpen; +@end // interface wxNSFontPanelDelegate : NSObject + +@implementation wxWCODelegate : NSObject + +- (id)init +{ + [super init]; + m_bIsClosed = false; + m_bIsOpen = false; + + return self; +} + +- (BOOL)windowShouldClose:(id)sender +{ + m_bIsClosed = true; + m_bIsOpen = false; + + [NSApp abortModal]; + [NSApp stopModal]; + return YES; +} + +- (void)windowDidUpdate:(NSNotification *)aNotification +{ + if (m_bIsOpen == NO) + { + m_bIsClosed = false; + m_bIsOpen = true; + + [NSApp abortModal]; + [NSApp stopModal]; + } +} + +- (BOOL)isClosed +{ + return m_bIsClosed; +} + +- (BOOL)isOpen +{ + return m_bIsOpen; +} + +@end // wxNSFontPanelDelegate + +// --------------------------------------------------------------------------- +// wxFontDialog +// --------------------------------------------------------------------------- + +wxFontDialog::wxFontDialog() +{ +} + +wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& data) +{ + Create(parent, data); +} + +wxFontDialog::~wxFontDialog() +{ +} + +bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data) +{ + m_fontData = data; + + // + // This is the key call - this initializes + // events and window stuff for cocoa for carbon + // applications. + // + // This is also the only call here that is + // 10.2+ specific (the rest is OSX only), + // which, ironically, the carbon font + // panel requires. + // + bool bOK = NSApplicationLoad(); + + //autorelease pool - req'd for carbon + NSAutoreleasePool *thePool; + thePool = [[NSAutoreleasePool alloc] init]; + + //Get the initial wx font + wxFont& thewxfont = m_fontData.m_initialFont; + + //if the font is valid set the default (selected) font of the + //NSFontDialog to that font + if (thewxfont.Ok()) + { + NSFontTraitMask theMask = 0; + + if(thewxfont.GetStyle() == wxFONTSTYLE_ITALIC) + theMask |= NSItalicFontMask; + + if(thewxfont.IsFixedWidth()) + theMask |= NSFixedPitchFontMask; + + NSFont* theDefaultFont = + [[NSFontManager sharedFontManager] fontWithFamily: + wxNSStringWithWxString(thewxfont.GetFaceName()) + traits:theMask + weight:thewxfont.GetWeight() == wxBOLD ? 9 : + thewxfont.GetWeight() == wxLIGHT ? 0 : 5 + size: (float)(thewxfont.GetPointSize()) + ]; + + wxASSERT_MSG(theDefaultFont, wxT("Invalid default font for wxCocoaFontDialog!")); + + //set the initial font of the NSFontPanel + //(the font manager calls the appropriate NSFontPanel method) + [[NSFontManager sharedFontManager] setSelectedFont:theDefaultFont isMultiple:NO]; + + } + + if(m_fontData.m_fontColour.Ok()) + [[NSColorPanel sharedColorPanel] setColor: + [NSColor colorWithCalibratedRed:m_fontData.m_fontColour.Red() / 255.0 + green:m_fontData.m_fontColour.Red() / 255.0 + blue:m_fontData.m_fontColour.Red() / 255.0 + alpha:1.0] + ]; + else + [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]]; + + //We're done - free up the pool + [thePool release]; + + return bOK; +} + +int wxFontDialog::ShowModal() +{ + //Start the pool. Required for carbon interaction + //(For those curious, the only thing that happens + //if you don't do this is a bunch of error + //messages about leaks on the console, + //with no windows shown or anything). + NSAutoreleasePool *thePool; + thePool = [[NSAutoreleasePool alloc] init]; + + //Get the shared color and font panel + NSFontPanel* theFontPanel = [NSFontPanel sharedFontPanel]; + NSColorPanel* theColorPanel = [NSColorPanel sharedColorPanel]; + + //Create and assign the delegates (cocoa event handlers) so + //we can tell if a window has closed/open or not + wxWCDelegate* theFPDelegate = [[wxWCDelegate alloc] init]; + [theFontPanel setDelegate:theFPDelegate]; + + wxWCODelegate* theCPDelegate = [[wxWCODelegate alloc] init]; + [theColorPanel setDelegate:theCPDelegate]; + + // + // Begin the modal loop for the font and color panels + // + // The idea is that we first make the font panel modal, + // but if the color panel is opened, unless we stop the + // modal loop the color panel opens behind the font panel + // with no input acceptable to it - which makes it useless. + // + // So we set up delegates for both the color and font panels, + // and the if the font panel opens the color panel, we + // stop the modal loop, and start a seperate modal loop for + // the color panel until the color panel closes, switching + // back to the font panel modal loop once it does close. + // + do + { + // + // Start the font panel modal loop + // + NSModalSession session = [NSApp beginModalSessionForWindow:theFontPanel]; + for (;;) + { + [NSApp runModalSession:session]; + + //If the font panel is closed or the font panel + //opened the color panel, break + if ([theFPDelegate isClosed] || [theCPDelegate isOpen]) + break; + } + [NSApp endModalSession:session]; + + //is the color panel open? + if ([theCPDelegate isOpen]) + { + // + // Start the color panel modal loop + // + NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel]; + for (;;) + { + [NSApp runModalSession:session]; + + //If the color panel is closed, return the font panel modal loop + if ([theCPDelegate isClosed]) + break; + } + [NSApp endModalSession:session]; + } + //If the font panel is still alive (I.E. we broke + //out of its modal loop because the color panel was + //opened) return the font panel modal loop + }while([theFPDelegate isClosed] == NO); + + //free up the memory for the delegates - we don't need them anymore + [theFPDelegate release]; + [theCPDelegate release]; + + //Get the font the user selected + NSFont* theFont = [theFontPanel panelConvertFont:[NSFont userFontOfSize:0]]; + + //Get more information about the user's chosen font + NSFontTraitMask theTraits = [[NSFontManager sharedFontManager] traitsOfFont:theFont]; + int theFontWeight = [[NSFontManager sharedFontManager] weightOfFont:theFont]; + int theFontSize = (int) [theFont pointSize]; + + //Set the wx font to the appropriate data + if(theTraits & NSFixedPitchFontMask) + m_fontData.m_chosenFont.SetFamily(wxTELETYPE); + + m_fontData.m_chosenFont.SetFaceName(wxStringWithNSString([theFont familyName])); + m_fontData.m_chosenFont.SetPointSize(theFontSize); + m_fontData.m_chosenFont.SetStyle(theTraits & NSItalicFontMask ? wxFONTSTYLE_ITALIC : 0); + m_fontData.m_chosenFont.SetWeight(theFontWeight < 5 ? wxLIGHT : + theFontWeight >= 9 ? wxBOLD : wxNORMAL); + + //Get the shared color panel along with the chosen color and set the chosen color + NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + + m_fontData.m_fontColour.Set((unsigned char) ([theColor redComponent] * 255.0), + (unsigned char) ([theColor greenComponent] * 255.0), + (unsigned char) ([theColor blueComponent] * 255.0)); + + //Friendly debug stuff +#ifdef FONTDLGDEBUG + wxPrintf(wxT("---Font Panel---\n--NS--\nSize:%f\nWeight:%i\nTraits:%i\n--WX--\nFaceName:%s\nPointSize:%i\nStyle:%i\nWeight:%i\nColor:%i,%i,%i\n---END Font Panel---\n"), + + (float) theFontSize, + theFontWeight, + theTraits, + + m_fontData.m_chosenFont.GetFaceName().c_str(), + m_fontData.m_chosenFont.GetPointSize(), + m_fontData.m_chosenFont.GetStyle(), + m_fontData.m_chosenFont.GetWeight(), + m_fontData.m_fontColour.Red(), + m_fontData.m_fontColour.Green(), + m_fontData.m_fontColour.Blue() ); +#endif + + //Release the pool, we're done :) + [thePool release]; + + //Return ID_OK - there are no "apply" buttons or the like + //on either the font or color panel + return wxID_OK; +} + +//old api stuff (REMOVE ME) +bool wxFontDialog::IsShown() const +{ + return false; +} + +#endif // 10.2+