1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/artmac.cpp
3 // Purpose: wxArtProvider instance with native Mac stock icons
7 // Copyright: (c) wxWindows team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ---------------------------------------------------------------------------
13 // ---------------------------------------------------------------------------
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
18 #if defined(__BORLANDC__)
22 #include "wx/artprov.h"
28 #if wxOSX_USE_COCOA_OR_CARBON
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 class wxMacArtProvider
: public wxArtProvider
37 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
39 virtual wxIconBundle
CreateIconBundle(const wxArtID
& id
,
40 const wxArtClient
& client
);
43 /* static */ void wxArtProvider
::InitNativeProvider()
45 wxArtProvider
::Push(new wxMacArtProvider
);
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 #define CREATE_STD_ICON(iconId, xpmRc) \
54 wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
58 // Macro used in CreateBitmap to get wxICON_FOO icons:
59 #define ART_MSGBOX(artId, iconId, xpmRc) \
62 CREATE_STD_ICON(#iconId, xpmRc) \
65 static wxIconBundle
wxMacArtProvider_CreateIconBundle(const wxArtID
& id
)
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
)
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
)
76 ART_MSGBOX(wxART_CDROM
, wxICON_CDROM
, cdrom
)
77 ART_MSGBOX(wxART_FLOPPY
, wxICON_FLOPPY
, floppy
)
78 ART_MSGBOX(wxART_HARDDISK
, wxICON_HARDDISK
, harddisk
)
79 ART_MSGBOX(wxART_REMOVABLE
, wxICON_REMOVABLE
, removable
)
81 ART_MSGBOX(wxART_DELETE
, wxICON_DELETE
, delete)
83 ART_MSGBOX(wxART_GO_BACK
, wxICON_GO_BACK
, back
)
84 ART_MSGBOX(wxART_GO_FORWARD
, wxICON_GO_FORWARD
, forward
)
85 ART_MSGBOX(wxART_GO_HOME
, wxICON_GO_HOME
, home
)
87 ART_MSGBOX(wxART_HELP_SETTINGS
, wxICON_HELP_SETTINGS
, htmoptns
)
88 ART_MSGBOX(wxART_HELP_FOLDER
, wxICON_HELP_FOLDER
, htmfoldr
)
89 ART_MSGBOX(wxART_HELP_PAGE
, wxICON_HELP_PAGE
, htmpage
)
91 ART_MSGBOX(wxART_PRINT
, wxICON_PRINT
, print
)
93 return wxNullIconBundle
;
96 // ----------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
100 wxIconBundle wxMacArtProvider
::CreateIconBundle(const wxArtID
& id
, const wxArtClient
& client
)
102 // On the Mac folders in lists are always drawn closed, so if an open
103 // folder icon is asked for we will ask for a closed one in its place
104 if ( client
== wxART_LIST
&& id
== wxART_FOLDER_OPEN
)
105 return wxMacArtProvider_CreateIconBundle(wxART_FOLDER
);
107 return wxMacArtProvider_CreateIconBundle(id
);
110 // ----------------------------------------------------------------------------
112 // ----------------------------------------------------------------------------
114 wxBitmap wxMacArtProvider
::CreateBitmap(const wxArtID
& id
,
115 const wxArtClient
& client
,
116 const wxSize
& reqSize
)
118 wxIconBundle
ic(CreateIconBundle(id
, client
));
121 wxIcon
theIcon(ic
.GetIcon(reqSize
));
122 return wxBitmap(theIcon
);
129 // ----------------------------------------------------------------------------
130 // wxArtProvider::GetNativeSizeHint()
131 // ----------------------------------------------------------------------------
134 wxSize wxArtProvider
::GetNativeSizeHint(const wxArtClient
& client
)
136 if ( client
== wxART_TOOLBAR
)
138 // See http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIcons/chapter_15_section_9.html:
139 // "32 x 32 pixels is the recommended size"
140 return wxSize(32, 32);
143 return wxDefaultSize
;
146 #endif // wxOSX_USE_COCOA_CARBON