]> git.saurik.com Git - wxWidgets.git/blame - src/osx/artmac.cpp
better native types for carbon
[wxWidgets.git] / src / osx / artmac.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
96dabe43 2// Name: src/osx/artmac.cpp
489468fe
SC
3// Purpose: wxArtProvider instance with native Mac stock icons
4// Author: Alan Shouls
5// Created: 2006-10-30
6// RCS-ID: $Id$
7// Copyright: (c) wxWindows team
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// ---------------------------------------------------------------------------
12// headers
13// ---------------------------------------------------------------------------
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#if defined(__BORLANDC__)
19 #pragma hdrstop
20#endif
21
a158acac
VS
22#include "wx/artprov.h"
23
489468fe
SC
24#ifndef WX_PRECOMP
25 #include "wx/image.h"
26#endif
27
1d61c554 28#if wxOSX_USE_COCOA_OR_CARBON
489468fe
SC
29
30// ----------------------------------------------------------------------------
31// wxMacArtProvider
32// ----------------------------------------------------------------------------
33
34class wxMacArtProvider : public wxArtProvider
35{
36protected:
37 virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
38 const wxSize& size);
39 virtual wxIconBundle CreateIconBundle(const wxArtID& id,
40 const wxArtClient& client);
41};
42
43/* static */ void wxArtProvider::InitNativeProvider()
44{
45 wxArtProvider::Push(new wxMacArtProvider);
46}
47
48// ----------------------------------------------------------------------------
49// helper macros
50// ----------------------------------------------------------------------------
51
52#define CREATE_STD_ICON(iconId, xpmRc) \
53 { \
54 wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
55 return icon; \
56 }
57
58// Macro used in CreateBitmap to get wxICON_FOO icons:
59#define ART_MSGBOX(artId, iconId, xpmRc) \
60 if ( id == artId ) \
61 { \
62 CREATE_STD_ICON(#iconId, xpmRc) \
63 }
64
65static wxIconBundle wxMacArtProvider_CreateIconBundle(const wxArtID& id)
66{
67 ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error)
68 ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info)
69 ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning)
70 ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question)
71
72 ART_MSGBOX(wxART_FOLDER, wxICON_FOLDER, folder)
73 ART_MSGBOX(wxART_FOLDER_OPEN, wxICON_FOLDER_OPEN, folder_open)
74 ART_MSGBOX(wxART_NORMAL_FILE, wxICON_NORMAL_FILE, deffile)
9c4ae528 75 ART_MSGBOX(wxART_EXECUTABLE_FILE, wxICON_EXECUTABLE_FILE, exefile)
489468fe 76
c481e6cf
SC
77 ART_MSGBOX(wxART_CDROM, wxICON_CDROM, cdrom)
78 ART_MSGBOX(wxART_FLOPPY, wxICON_FLOPPY, floppy)
79 ART_MSGBOX(wxART_HARDDISK, wxICON_HARDDISK, harddisk)
80 ART_MSGBOX(wxART_REMOVABLE, wxICON_REMOVABLE, removable)
81
82 ART_MSGBOX(wxART_DELETE, wxICON_DELETE, delete)
83
84 ART_MSGBOX(wxART_GO_BACK, wxICON_GO_BACK, back)
85 ART_MSGBOX(wxART_GO_FORWARD, wxICON_GO_FORWARD, forward)
86 ART_MSGBOX(wxART_GO_HOME, wxICON_GO_HOME, home)
87
88 ART_MSGBOX(wxART_HELP_SETTINGS, wxICON_HELP_SETTINGS, htmoptns)
c481e6cf 89 ART_MSGBOX(wxART_HELP_PAGE, wxICON_HELP_PAGE, htmpage)
c481e6cf 90
489468fe
SC
91 return wxNullIconBundle;
92}
93
94// ----------------------------------------------------------------------------
95// CreateIconBundle
96// ----------------------------------------------------------------------------
97
98wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client)
99{
100 // On the Mac folders in lists are always drawn closed, so if an open
101 // folder icon is asked for we will ask for a closed one in its place
102 if ( client == wxART_LIST && id == wxART_FOLDER_OPEN )
103 return wxMacArtProvider_CreateIconBundle(wxART_FOLDER);
104
105 return wxMacArtProvider_CreateIconBundle(id);
106}
107
108// ----------------------------------------------------------------------------
109// CreateBitmap
110// ----------------------------------------------------------------------------
111
112wxBitmap wxMacArtProvider::CreateBitmap(const wxArtID& id,
113 const wxArtClient& client,
114 const wxSize& reqSize)
115{
116 wxIconBundle ic(CreateIconBundle(id, client));
117 if (ic.IsOk())
118 {
119 wxIcon theIcon(ic.GetIcon(reqSize));
120 return wxBitmap(theIcon);
121 }
122
123 return wxNullBitmap;
124}
b2680ced 125
b2680ced 126
a158acac
VS
127// ----------------------------------------------------------------------------
128// wxArtProvider::GetNativeSizeHint()
129// ----------------------------------------------------------------------------
130
131/*static*/
132wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client)
133{
134 if ( client == wxART_TOOLBAR )
135 {
136 // See http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIcons/chapter_15_section_9.html:
137 // "32 x 32 pixels is the recommended size"
138 return wxSize(32, 32);
139 }
140
141 return wxDefaultSize;
142}
b2680ced 143
1d61c554 144#endif // wxOSX_USE_COCOA_CARBON