]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/settings.mm
compilation fix after r61232
[wxWidgets.git] / src / cocoa / settings.mm
index e35fc7ffec0ec5d23154033e4edde45abab38d81..0f6ffb05f02b908a2b9dc49b48717a2edb91b399 100644 (file)
@@ -1,21 +1,28 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        settings.cpp
+// Name:        src/cocoa/settings.mm
 // Purpose:     wxSettings
 // Purpose:     wxSettings
-// Author:      AUTHOR
+// Author:      David Elliott
 // Modified by:
 // Modified by:
-// Created:     ??/??/98
+// Created:     2005/01/11
 // RCS-ID:      $Id$
 // RCS-ID:      $Id$
-// Copyright:   (c) AUTHOR
+// Copyright:   (c) 2005 David Elliott
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "settings.h"
-#endif
+#include "wx/wxprec.h"
 
 #include "wx/settings.h"
 
 #include "wx/settings.h"
-#include "wx/gdicmn.h"
-#include "wx/utils.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/utils.h"
+    #include "wx/gdicmn.h"
+#endif
+
+#include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/private/fontfactory.h"
+
+#import <AppKit/NSColor.h>
+#import <AppKit/NSFont.h>
 
 // ----------------------------------------------------------------------------
 // wxSystemSettingsNative
 
 // ----------------------------------------------------------------------------
 // wxSystemSettingsNative
 
 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 {
 
 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 {
-    return wxColour();
-#if 0
-    int major,minor;
-    wxGetOsVersion( &major, &minor );
-    
+    wxAutoNSAutoreleasePool pool;
     switch( index )
     {
     case wxSYS_COLOUR_SCROLLBAR:
     switch( index )
     {
     case wxSYS_COLOUR_SCROLLBAR:
-    case wxSYS_COLOUR_BACKGROUND:
-    case wxSYS_COLOUR_ACTIVECAPTION:
-    case wxSYS_COLOUR_INACTIVECAPTION:
+        return wxColour([NSColor scrollBarColor]); // color of slot
+    case wxSYS_COLOUR_BACKGROUND: // No idea how to get desktop background
+        break; // break so we return an invalid colour.
+    case wxSYS_COLOUR_ACTIVECAPTION: // No idea how to get this
+        // fall through, window background is reasonable
+    case wxSYS_COLOUR_INACTIVECAPTION: // No idea how to get this
+        // fall through, window background is reasonable
     case wxSYS_COLOUR_MENU:
     case wxSYS_COLOUR_MENU:
+    case wxSYS_COLOUR_MENUBAR:
     case wxSYS_COLOUR_WINDOW:
     case wxSYS_COLOUR_WINDOWFRAME:
     case wxSYS_COLOUR_ACTIVEBORDER:
     case wxSYS_COLOUR_INACTIVEBORDER:
     case wxSYS_COLOUR_WINDOW:
     case wxSYS_COLOUR_WINDOWFRAME:
     case wxSYS_COLOUR_ACTIVEBORDER:
     case wxSYS_COLOUR_INACTIVEBORDER:
+        return wxColour([NSColor windowFrameColor]);
     case wxSYS_COLOUR_BTNFACE:
     case wxSYS_COLOUR_BTNFACE:
-    case wxSYS_COLOUR_MENUBAR:
-        return wxColor( 0xDD , 0xDD , 0xDD ) ;
-        break ;
-
+        return wxColour([NSColor knobColor]); // close enough?
     case wxSYS_COLOUR_LISTBOX:
     case wxSYS_COLOUR_LISTBOX:
-    {
-        if (major >= 10)
-            return *wxWHITE ;
-        else
-            return wxColor( 0xEE , 0xEE , 0xEE ) ;
-        break ;
-    }
+        return wxColour([NSColor controlBackgroundColor]);
     case wxSYS_COLOUR_BTNSHADOW:
     case wxSYS_COLOUR_BTNSHADOW:
-        return wxColor( 0x44 , 0x44 , 0x44 ) ;
-        break ;
-
+        return wxColour([NSColor controlShadowColor]);
     case wxSYS_COLOUR_BTNTEXT:
     case wxSYS_COLOUR_MENUTEXT:
     case wxSYS_COLOUR_WINDOWTEXT:
     case wxSYS_COLOUR_CAPTIONTEXT:
     case wxSYS_COLOUR_INFOTEXT:
     case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
     case wxSYS_COLOUR_BTNTEXT:
     case wxSYS_COLOUR_MENUTEXT:
     case wxSYS_COLOUR_WINDOWTEXT:
     case wxSYS_COLOUR_CAPTIONTEXT:
     case wxSYS_COLOUR_INFOTEXT:
     case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
-        return *wxBLACK;
-        break ;
+        return wxColour([NSColor controlTextColor]);
     case wxSYS_COLOUR_HIGHLIGHT:
     case wxSYS_COLOUR_HIGHLIGHT:
-        {
-            RGBColor hilite ;
-            LMGetHiliteRGB(&hilite) ;
-            return wxColor( hilite.red >> 8 , hilite.green >> 8  , hilite.blue >> 8  ) ;
-        }
-        break ;
+        return wxColour([NSColor selectedControlColor]);
     case wxSYS_COLOUR_BTNHIGHLIGHT:
     case wxSYS_COLOUR_BTNHIGHLIGHT:
+        return wxColour([NSColor controlHighlightColor]);
     case wxSYS_COLOUR_GRAYTEXT:
     case wxSYS_COLOUR_GRAYTEXT:
-        return wxColor( 0xCC , 0xCC , 0xCC ) ;
-        break ;
-
+        return wxColour([NSColor disabledControlTextColor]);
     case wxSYS_COLOUR_3DDKSHADOW:
     case wxSYS_COLOUR_3DDKSHADOW:
-        return wxColor( 0x44 , 0x44 , 0x44 ) ;
-        break ;
+        return wxColour([NSColor controlShadowColor]);
     case wxSYS_COLOUR_3DLIGHT:
     case wxSYS_COLOUR_3DLIGHT:
-        return wxColor( 0xCC , 0xCC , 0xCC ) ;
-        break ;
+        return wxColour([NSColor controlHighlightColor]);
     case wxSYS_COLOUR_HIGHLIGHTTEXT:
     case wxSYS_COLOUR_HIGHLIGHTTEXT:
-        {
-            RGBColor hilite ;
-            LMGetHiliteRGB(&hilite) ;
-            if ( ( hilite.red + hilite.green + hilite.blue ) == 0 )
-                    return *wxWHITE ;
-            else
-                    return *wxBLACK ;
-        }
-        break ;
+        return wxColour([NSColor selectedControlTextColor]);
     case wxSYS_COLOUR_INFOBK:
     case wxSYS_COLOUR_INFOBK:
+        // tooltip (bogus)
+        return wxColour([NSColor controlBackgroundColor]);
     case wxSYS_COLOUR_APPWORKSPACE:
     case wxSYS_COLOUR_APPWORKSPACE:
-        return *wxWHITE ;
-        break ;
-
+        // MDI window color (bogus)
+        return wxColour([NSColor windowBackgroundColor]);
     case wxSYS_COLOUR_HOTLIGHT:
     case wxSYS_COLOUR_HOTLIGHT:
+        break; // what is this?
     case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
     case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
     case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
     case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
+        break; // Doesn't really apply to Cocoa.
     case wxSYS_COLOUR_MENUHILIGHT:
     case wxSYS_COLOUR_MENUHILIGHT:
-        // TODO
-        return *wxBLACK;
-     
+        return wxColour([NSColor selectedMenuItemColor]);
     case wxSYS_COLOUR_MAX:
     case wxSYS_COLOUR_MAX:
-        wxFAIL_MSG( _T("unknown system colour index") );
-        break ;
+    default:
+        if(index>=wxSYS_COLOUR_MAX)
+        {
+            wxFAIL_MSG(wxT("Invalid system colour index"));
+            return wxColour();
+        }
     }
     }
-    return *wxWHITE;
-#endif
+    wxFAIL_MSG(wxT("Unimplemented system colour index"));
+    return wxColour();
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -122,8 +108,10 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 
 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
 {
 
 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
 {
-// return a nonworking font object, crash from wxInitializeStockObjects
-    return wxFont();
+    // Return the system font for now
+    {   wxAutoNSAutoreleasePool pool;
+        return wxCocoaFontFactory::InstanceForNSFont([NSFont systemFontOfSize:0.0], false);
+    }
     switch (index)
     {
         case wxSYS_ANSI_VAR_FONT :
     switch (index)
     {
         case wxSYS_ANSI_VAR_FONT :
@@ -142,7 +130,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
                 return *wxNORMAL_FONT ;
                     } ;
             break ;
                 return *wxNORMAL_FONT ;
                     } ;
             break ;
-                
+
     }
     return *wxNORMAL_FONT;
 }
     }
     return *wxNORMAL_FONT;
 }
@@ -152,13 +140,13 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
 // ----------------------------------------------------------------------------
 
 // Get a system metric, e.g. scrollbar size
 // ----------------------------------------------------------------------------
 
 // Get a system metric, e.g. scrollbar size
-int wxSystemSettingsNative::GetMetric(wxSystemMetric index)
+int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow *WXUNUSED(win))
 {
     switch ( index)
     {
         case wxSYS_MOUSE_BUTTONS:
                     return 2; // we emulate a two button mouse (ctrl + click = right button )
 {
     switch ( index)
     {
         case wxSYS_MOUSE_BUTTONS:
                     return 2; // we emulate a two button mouse (ctrl + click = right button )
-                    
+
         // TODO case wxSYS_BORDER_X:
         // TODO case wxSYS_BORDER_Y:
         // TODO case wxSYS_CURSOR_X:
         // TODO case wxSYS_BORDER_X:
         // TODO case wxSYS_BORDER_Y:
         // TODO case wxSYS_CURSOR_X:
@@ -176,7 +164,7 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index)
             return 16;
         case wxSYS_HTHUMB_X:
             return 16;
             return 16;
         case wxSYS_HTHUMB_X:
             return 16;
-            
+
         // TODO case wxSYS_ICON_X:
         // TODO case wxSYS_ICON_Y:
         // TODO case wxSYS_ICONSPACING_X:
         // TODO case wxSYS_ICON_X:
         // TODO case wxSYS_ICON_Y:
         // TODO case wxSYS_ICONSPACING_X:
@@ -189,7 +177,7 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index)
         // TODO case wxSYS_FRAMESIZE_Y:
         // TODO case wxSYS_SMALLICON_X:
         // TODO case wxSYS_SMALLICON_Y:
         // TODO case wxSYS_FRAMESIZE_Y:
         // TODO case wxSYS_SMALLICON_X:
         // TODO case wxSYS_SMALLICON_Y:
-            
+
         case wxSYS_HSCROLL_Y:
             return 16;
         case wxSYS_VSCROLL_X:
         case wxSYS_HSCROLL_Y:
             return 16;
         case wxSYS_VSCROLL_X:
@@ -200,19 +188,19 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index)
             return 16;
         case wxSYS_VTHUMB_Y:
             return 16;
             return 16;
         case wxSYS_VTHUMB_Y:
             return 16;
-            
+
         // TODO case wxSYS_CAPTION_Y:
         // TODO case wxSYS_MENU_Y:
         // TODO case wxSYS_NETWORK_PRESENT:
         // TODO case wxSYS_CAPTION_Y:
         // TODO case wxSYS_MENU_Y:
         // TODO case wxSYS_NETWORK_PRESENT:
-            
+
         case wxSYS_PENWINDOWS_PRESENT:
             return 0;
         case wxSYS_PENWINDOWS_PRESENT:
             return 0;
-            
+
         // TODO case wxSYS_SHOW_SOUNDS:
 
         case wxSYS_SWAP_BUTTONS:
             return 0;
         // TODO case wxSYS_SHOW_SOUNDS:
 
         case wxSYS_SWAP_BUTTONS:
             return 0;
-            
+
         default:
             return -1;  // unsupported metric
     }
         default:
             return -1;  // unsupported metric
     }
@@ -223,11 +211,11 @@ bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
 {
     switch (index)
     {
 {
     switch (index)
     {
-        case wxSYS_CAN_ICONIZE_FRAME: 
+        case wxSYS_CAN_ICONIZE_FRAME:
         case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
         case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
-            return TRUE;
-            
+            return true;
+
         default:
         default:
-            return FALSE;
+            return false;
     }
 }
     }
 }