]> git.saurik.com Git - wxWidgets.git/commitdiff
cleanup OSX native font dialog stuff a bit (it should prob. be an option in configure
authorRyan Norton <wxprojects@comcast.net>
Tue, 16 Nov 2004 14:36:10 +0000 (14:36 +0000)
committerRyan Norton <wxprojects@comcast.net>
Tue, 16 Nov 2004 14:36:10 +0000 (14:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/bakefiles/files.bkl
include/wx/fontdlg.h
src/mac/carbon/colordlg.cpp
src/mac/carbon/colordlg.mm
src/mac/carbon/fontdlg.cpp
src/mac/carbon/fontdlg.mm

index 2f3e081654a4e3ba1901379f1a03967c3432e01a..a315dd91b5160363b15830a9ade1f0981c588e61 100644 (file)
@@ -1668,6 +1668,9 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/unix/snglinst.cpp
     <!-- wxWebKit files -->
     src/html/htmlctrl/webkit/webkit.mm
+    <!-- Native color/font dialogs -->
+    src/mac/carbon/fontdlg.mm
+    src/mac/carbon/colordlg.mm
 </if>
 </set>
 
index 060ab4c16159f37679002a07c671f2a2edd1ace7..e0d5c8209ff74dc88aa7682a15474f833a3c341b 100644 (file)
@@ -65,7 +65,13 @@ protected:
 // platform-specific wxFontDialog implementation
 // ----------------------------------------------------------------------------
 
+#if defined( __WXMAC_OSX__ ) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
+//set to 1 to use native mac font and color dialogs
 #define USE_NATIVE_FONT_DIALOG_FOR_MACOSX 0
+#else
+//not supported on these platforms, leave 0
+#define USE_NATIVE_FONT_DIALOG_FOR_MACOSX 0
+#endif
 
 #if defined(__WXUNIVERSAL__) || \
     defined(__WXMOTIF__)     || \
index 3c8411319b333758f23b5b26de4f970a09fa6c64..6ca035476126cca94163014c5e3ecfdb283b56d6 100644 (file)
 #endif
 
 #include "wx/mac/colordlg.h"
+#include "wx/fontdlg.h"
+
+
+#if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
@@ -68,3 +72,4 @@ int wxColourDialog::ShowModal()
     return wxID_CANCEL;
 }
 
+#endif
index a04f85fe39fd9bd473c9954be8367edc6c867bbb..790785c4dcdd8f0f8767a3965854df5c9304660d 100644 (file)
@@ -34,7 +34,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
 // ============================================================================
 
 //Mac OSX 10.2+ only
-#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX && defined( __WXMAC_OSX__ ) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
+#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX
 
 // Cocoa headers
 #include "wx/cocoa/autorelease.h"
@@ -191,55 +191,5 @@ int wxColourDialog::ShowModal()
     return wxID_OK;
 }
 
-#else
-#include "wx/mac/private.h"
-#ifndef __DARWIN__
-#include <ColorPicker.h>
-#endif
-
-/*
- * 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;
-    return TRUE;
-}
-
-
-int wxColourDialog::ShowModal()
-{
-    Point where ;
-    RGBColor currentColor = *((RGBColor*)m_colourData.m_dataColour.GetPixel()) , newColor ;
-    
-    where.h = where.v = -1;
-
-    if (GetColor( where, "\pSelect a new palette color.", &currentColor, &newColor ))
-    {
-        m_colourData.m_dataColour.Set( (WXCOLORREF*) &newColor ) ;
-        return wxID_OK;
-    }
-    else
-    {
-        return wxID_CANCEL;
-    }
-
-    return wxID_CANCEL;
-}
-
 #endif //use native font dialog
 
index 410e8f08b547532f0cb019aaf10a02ea838b8916..e2f20113dc796e67b14895db3b9da0a82c642311 100644 (file)
     #include "wx/cmndata.h"
 #endif
 
-#include "wx/mac/fontdlg.h"
+#include "wx/fontdlg.h"
     
+
+#if !USE_NATIVE_FONT_DIALOG_FOR_MACOSX
+
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
 #endif
 
 #include "wx/mac/private.h"
 
-//Mac OSX 10.2+ only
-#if defined( __WXMAC__ ) && TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
-
-#include <ATSUnicode.h>
-
-#include "wx/msgdlg.h"
-
-//color isn't working in carbon impl
-#define ISCOLORWORKING 0
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ---------------------------------------------------------------------------
-// Carbon event callback(s)
-// ---------------------------------------------------------------------------
-
-pascal OSStatus wxFontDialogEventHandler(      EventHandlerCallRef inHandlerCallRef,
-                                                                       EventRef event, void* pData)
-{
-    wxASSERT(GetEventClass(event) == kEventClassFont && 
-             GetEventKind(event) == kEventFontSelection);
-   
-    OSStatus status = noErr;
-    
-    FMFontFamily fontfamily;
-    FMFontStyle fontstyle;
-    FMFontSize fontsize;
-#if ISCOLORWORKING
-    RGBColor fontcolor;
-#endif
-        
-    status = GetEventParameter (event, kEventParamFMFontFamily,
-                                    typeFMFontFamily, NULL,
-                                    sizeof (FMFontFamily), 
-                                    NULL, &(fontfamily)); 
-    check_noerr (status); 
-
-    status = GetEventParameter (event, kEventParamFMFontStyle,
-                                    typeFMFontStyle, NULL,
-                                    sizeof (FMFontStyle), 
-                                    NULL, &(fontstyle)); 
-    check_noerr (status); 
-
-    status = GetEventParameter (event, kEventParamFMFontSize,
-                                    typeFMFontSize, NULL,
-                                    sizeof (FMFontSize), 
-                                    NULL, &(fontsize)); 
-
-    check_noerr (status);
-
-#if ISCOLORWORKING
-    status = GetEventParameter (event, kEventParamFontColor,
-                                    typeRGBColor, NULL,
-                                    sizeof( RGBColor ), NULL, &fontcolor); 
-    check_noerr (status);
-#endif
-    
-    //now do the conversion to the wx font data
-    wxFontData theFontData;
-    wxFont        theFont;
-
-#if ISCOLORWORKING 
-    //set color
-    wxColour theColor;
-    theColor.Set(&(WXCOLORREF&)fontcolor);
-    theFontData.SetColour(theColor);
-#endif
-        
-    //set size
-    theFont.SetPointSize(fontsize);
-    
-    //set name
-    Str255 theFontName;
-    GetFontName(fontfamily, theFontName);
-    theFont.SetFaceName(wxMacMakeStringFromPascal(theFontName));
-      
-    //TODOTODO: Get font family - mayby by the script code?
-    theFont.SetFamily(wxDEFAULT);  
-
-    //TODOTODO: Get other styles?
-    theFont.SetStyle(((fontstyle & italic) ? wxFONTSTYLE_ITALIC : 0));
-    theFont.SetWeight((fontstyle & bold) ? wxBOLD : wxNORMAL);   
-    theFont.SetUnderlined(((fontstyle & underline) ? true : false));
-        
-    //phew!!  We're done - set the chosen font
-    theFontData.SetChosenFont(theFont);
-    ((wxFontDialog*)pData)->SetData(theFontData);
-    
-    return status;
-}
-
-DEFINE_ONE_SHOT_HANDLER_GETTER( wxFontDialogEventHandler );
-
-// ---------------------------------------------------------------------------
-// wxFontDialog
-// ---------------------------------------------------------------------------
-
-wxFontDialog::wxFontDialog() :
-    m_dialogParent(NULL), m_pEventHandlerRef(NULL)
-{
-}
-
-wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData&  data)
-{
-    Create(parent, data);
-}
-
-wxFontDialog::~wxFontDialog()
-{
-    if (m_pEventHandlerRef)
-        ::RemoveEventHandler((EventHandlerRef&)m_pEventHandlerRef);
-}
-
-void wxFontDialog::SetData(wxFontData& fontdata)
-{
-    m_fontData = fontdata;
-}
-
-bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
-{
-    m_dialogParent = parent;
-    m_fontData = data;
-
-    //Register the events that will return this dialog
-       EventTypeSpec ftEventList[] = { { kEventClassFont, kEventFontSelection } };
-
-    OSStatus err = noErr;
-  
-//FIXMEFIXME: Why doesn't it recieve events if there's a parent?
-//    if (parent)
-//    {
-//       err = InstallWindowEventHandler(
-//            MAC_WXHWND(parent->GetHandle()),
-//            GetwxFontDialogEventHandlerUPP(),
-//            GetEventTypeCount(ftEventList), ftEventList, 
-//                     this, (&(EventHandlerRef&)m_pEventHandlerRef));
-//            
-//    }
-//    else //no parent - send to app
-//    {
-        err = InstallApplicationEventHandler(
-            GetwxFontDialogEventHandlerUPP(),
-            GetEventTypeCount(ftEventList), ftEventList, 
-                       this, (&(EventHandlerRef&)m_pEventHandlerRef));
-//       }
-               
-    return err == noErr;
-}
-
-bool wxFontDialog::IsShown() const
-{
-    return FPIsFontPanelVisible();
-}
-
-int wxFontDialog::ShowModal()
-{
-    wxASSERT(!FPIsFontPanelVisible());
-    
-    //set up initial font
-    wxFont theInitialFont = m_fontData.GetInitialFont();
-
-    //create ATSU style
-    ATSUStyle theStyle;
-    OSStatus status = ATSUCreateStyle(&theStyle);
-    check_noerr(status);
-
-    //put stuff into the style - we don't need kATSUColorTag    
-    ATSUFontID                                 fontid = theInitialFont.MacGetATSUFontID();
-    Fixed                                      fontsize = theInitialFont.MacGetFontSize() << 16;
-    ATSUAttributeTag           theTags[2] = { kATSUFontTag, kATSUSizeTag };
-    ByteCount                  theSizes[2] = { sizeof(ATSUFontID), sizeof(Fixed) };
-    ATSUAttributeValuePtr   theValues[2] = { &fontid, 
-                                             &fontsize };
-    
-    //set the stuff for the ATSU style
-    verify_noerr (ATSUSetAttributes (theStyle, 2, theTags, theSizes, theValues) ); 
-    
-    //they set us up the bomb!  Set the initial font of the dialog
-    SetFontInfoForSelection(kFontSelectionATSUIType,
-                            1, 
-                            &theStyle,
-                            (HIObjectRef) 
-                                (m_dialogParent ? 
-                                 GetWindowEventTarget(MAC_WXHWND(m_dialogParent->GetHandle())) :
-                                 GetApplicationEventTarget())
-                            );
-    
-    //dispose of the style
-    status = ATSUDisposeStyle(theStyle);
-    check_noerr(status);
-    
-    //in case the user doesn't choose anything -
-    //if he doesn't we'll get a bad font with red text
-    m_fontData.SetChosenFont(m_fontData.GetInitialFont());
-    m_fontData.SetColour(wxColour(0,0,0));
-    
-    //finally, show the font dialog
-    if( (status = FPShowHideFontPanel()) == noErr)
-    {
-        while(FPIsFontPanelVisible()) 
-        {
-            //yeild so we can get events
-            wxTheApp->Yield(false);
-        }
-    }
-    else
-        return wxID_CANCEL;
-    
-    return wxID_OK;
-}
-
-
-#else
-   //10.2+ only
-   
 // ---------------------------------------------------------------------------
 // wxFontDialog stub for mac OS's without a native font dialog
 // ---------------------------------------------------------------------------
index b0803c3d80651b267507eb39c6e0ce0267a8039c..be1a6e1b05a4a42a4fdac40ba946158bd3009eed 100644 (file)
@@ -44,7 +44,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
 // ============================================================================
 
 //Mac OSX 10.2+ only
-#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX && defined( __WXMAC_OSX__ ) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
+#if USE_NATIVE_FONT_DIALOG_FOR_MACOSX
 
 // Cocoa headers
 #include "wx/cocoa/autorelease.h"
@@ -380,48 +380,4 @@ bool wxFontDialog::IsShown() const
     return false;
 }
 
-#else
-   //10.2+ only
-   
-// ---------------------------------------------------------------------------
-// wxFontDialog stub for mac OS's without a native font dialog
-// ---------------------------------------------------------------------------
-
-wxFontDialog::wxFontDialog()
-{
-    m_dialogParent = NULL;
-}
-
-wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData&  data)
-{
-    Create(parent, data);
-}
-
-void wxFontDialog::SetData(wxFontData& fontdata)
-{
-    m_fontData = fontdata;
-}
-
-bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
-{
-    m_dialogParent = parent;
-
-    m_fontData = data;
-
-    // TODO: you may need to do dialog creation here, unless it's
-    // done in ShowModal.
-    return TRUE;
-}
-
-bool wxFontDialog::IsShown() const
-{
-    return false;
-}
-
-int wxFontDialog::ShowModal()
-{
-    // TODO: show (maybe create) the dialog
-    return wxID_CANCEL;
-}
-
 #endif // 10.2+