]> git.saurik.com Git - wxWidgets.git/blame - src/osx/artmac.cpp
Fix install_name_tool calls in OS X "make install".
[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
489468fe
SC
6// Copyright: (c) wxWindows team
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// ---------------------------------------------------------------------------
11// headers
12// ---------------------------------------------------------------------------
13
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
17#if defined(__BORLANDC__)
18 #pragma hdrstop
19#endif
20
a158acac
VS
21#include "wx/artprov.h"
22
489468fe
SC
23#ifndef WX_PRECOMP
24 #include "wx/image.h"
25#endif
26
ca9eebc3 27#include "wx/osx/private.h"
489468fe
SC
28
29// ----------------------------------------------------------------------------
30// wxMacArtProvider
31// ----------------------------------------------------------------------------
32
33class wxMacArtProvider : public wxArtProvider
34{
35protected:
ca9eebc3 36#if wxOSX_USE_COCOA_OR_CARBON
489468fe
SC
37 virtual wxIconBundle CreateIconBundle(const wxArtID& id,
38 const wxArtClient& client);
ca9eebc3
SC
39#endif
40#if wxOSX_USE_COCOA_OR_IPHONE
41 virtual wxBitmap CreateBitmap(const wxArtID& id,
42 const wxArtClient& client,
43 const wxSize& size)
44 {
45 return wxOSXCreateSystemBitmap(id, client, size);
46 }
47#endif
489468fe
SC
48};
49
50/* static */ void wxArtProvider::InitNativeProvider()
51{
0d68cd13 52 PushBack(new wxMacArtProvider);
489468fe
SC
53}
54
ca9eebc3
SC
55#if wxOSX_USE_COCOA_OR_CARBON
56
489468fe
SC
57// ----------------------------------------------------------------------------
58// helper macros
59// ----------------------------------------------------------------------------
60
61#define CREATE_STD_ICON(iconId, xpmRc) \
62 { \
9a83f860 63 wxIconBundle icon(wxT(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
489468fe
SC
64 return icon; \
65 }
66
67// Macro used in CreateBitmap to get wxICON_FOO icons:
68#define ART_MSGBOX(artId, iconId, xpmRc) \
69 if ( id == artId ) \
70 { \
71 CREATE_STD_ICON(#iconId, xpmRc) \
72 }
73
74static wxIconBundle wxMacArtProvider_CreateIconBundle(const wxArtID& id)
75{
76 ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error)
77 ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info)
78 ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning)
79 ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question)
80
81 ART_MSGBOX(wxART_FOLDER, wxICON_FOLDER, folder)
82 ART_MSGBOX(wxART_FOLDER_OPEN, wxICON_FOLDER_OPEN, folder_open)
83 ART_MSGBOX(wxART_NORMAL_FILE, wxICON_NORMAL_FILE, deffile)
9c4ae528 84 ART_MSGBOX(wxART_EXECUTABLE_FILE, wxICON_EXECUTABLE_FILE, exefile)
489468fe 85
03647350
VZ
86 ART_MSGBOX(wxART_CDROM, wxICON_CDROM, cdrom)
87 ART_MSGBOX(wxART_FLOPPY, wxICON_FLOPPY, floppy)
88 ART_MSGBOX(wxART_HARDDISK, wxICON_HARDDISK, harddisk)
89 ART_MSGBOX(wxART_REMOVABLE, wxICON_REMOVABLE, removable)
90
91 ART_MSGBOX(wxART_DELETE, wxICON_DELETE, delete)
92
93 ART_MSGBOX(wxART_GO_BACK, wxICON_GO_BACK, back)
94 ART_MSGBOX(wxART_GO_FORWARD, wxICON_GO_FORWARD, forward)
95 ART_MSGBOX(wxART_GO_HOME, wxICON_GO_HOME, home)
96
97 ART_MSGBOX(wxART_HELP_SETTINGS, wxICON_HELP_SETTINGS, htmoptns)
98 ART_MSGBOX(wxART_HELP_PAGE, wxICON_HELP_PAGE, htmpage)
99
489468fe
SC
100 return wxNullIconBundle;
101}
102
103// ----------------------------------------------------------------------------
104// CreateIconBundle
105// ----------------------------------------------------------------------------
106
107wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client)
108{
109 // On the Mac folders in lists are always drawn closed, so if an open
110 // folder icon is asked for we will ask for a closed one in its place
111 if ( client == wxART_LIST && id == wxART_FOLDER_OPEN )
112 return wxMacArtProvider_CreateIconBundle(wxART_FOLDER);
113
114 return wxMacArtProvider_CreateIconBundle(id);
115}
116
ca9eebc3 117#endif
b2680ced 118
a158acac
VS
119// ----------------------------------------------------------------------------
120// wxArtProvider::GetNativeSizeHint()
121// ----------------------------------------------------------------------------
122
123/*static*/
124wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client)
125{
126 if ( client == wxART_TOOLBAR )
127 {
128 // See http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIcons/chapter_15_section_9.html:
129 // "32 x 32 pixels is the recommended size"
130 return wxSize(32, 32);
131 }
1d3dfc57
VZ
132 else if ( client == wxART_BUTTON || client == wxART_MENU )
133 {
134 // Mac UI doesn't use any images in neither buttons nor menus in
135 // general but the code using wxArtProvider can use wxART_BUTTON to
136 // find the icons of a roughly appropriate size for the buttons and
137 // 16x16 seems to be the best choice for this kind of use
138 return wxSize(16, 16);
139 }
a158acac
VS
140
141 return wxDefaultSize;
142}
b2680ced 143