]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/artmac.cpp
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 #include "wx/osx/private.h"
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 class wxMacArtProvider
: public wxArtProvider
37 #if wxOSX_USE_COCOA_OR_CARBON
38 virtual wxIconBundle
CreateIconBundle(const wxArtID
& id
,
39 const wxArtClient
& client
);
41 #if wxOSX_USE_COCOA_OR_IPHONE
42 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
43 const wxArtClient
& client
,
46 return wxOSXCreateSystemBitmap(id
, client
, size
);
51 /* static */ void wxArtProvider::InitNativeProvider()
53 wxArtProvider::Push(new wxMacArtProvider
);
56 #if wxOSX_USE_COCOA_OR_CARBON
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 #define CREATE_STD_ICON(iconId, xpmRc) \
64 wxIconBundle icon(wxT(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
68 // Macro used in CreateBitmap to get wxICON_FOO icons:
69 #define ART_MSGBOX(artId, iconId, xpmRc) \
72 CREATE_STD_ICON(#iconId, xpmRc) \
75 static wxIconBundle
wxMacArtProvider_CreateIconBundle(const wxArtID
& id
)
77 ART_MSGBOX(wxART_ERROR
, wxICON_ERROR
, error
)
78 ART_MSGBOX(wxART_INFORMATION
, wxICON_INFORMATION
, info
)
79 ART_MSGBOX(wxART_WARNING
, wxICON_WARNING
, warning
)
80 ART_MSGBOX(wxART_QUESTION
, wxICON_QUESTION
, question
)
82 ART_MSGBOX(wxART_FOLDER
, wxICON_FOLDER
, folder
)
83 ART_MSGBOX(wxART_FOLDER_OPEN
, wxICON_FOLDER_OPEN
, folder_open
)
84 ART_MSGBOX(wxART_NORMAL_FILE
, wxICON_NORMAL_FILE
, deffile
)
85 ART_MSGBOX(wxART_EXECUTABLE_FILE
, wxICON_EXECUTABLE_FILE
, exefile
)
87 ART_MSGBOX(wxART_CDROM
, wxICON_CDROM
, cdrom
)
88 ART_MSGBOX(wxART_FLOPPY
, wxICON_FLOPPY
, floppy
)
89 ART_MSGBOX(wxART_HARDDISK
, wxICON_HARDDISK
, harddisk
)
90 ART_MSGBOX(wxART_REMOVABLE
, wxICON_REMOVABLE
, removable
)
92 ART_MSGBOX(wxART_DELETE
, wxICON_DELETE
, delete)
94 ART_MSGBOX(wxART_GO_BACK
, wxICON_GO_BACK
, back
)
95 ART_MSGBOX(wxART_GO_FORWARD
, wxICON_GO_FORWARD
, forward
)
96 ART_MSGBOX(wxART_GO_HOME
, wxICON_GO_HOME
, home
)
98 ART_MSGBOX(wxART_HELP_SETTINGS
, wxICON_HELP_SETTINGS
, htmoptns
)
99 ART_MSGBOX(wxART_HELP_PAGE
, wxICON_HELP_PAGE
, htmpage
)
101 return wxNullIconBundle
;
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
108 wxIconBundle
wxMacArtProvider::CreateIconBundle(const wxArtID
& id
, const wxArtClient
& client
)
110 // On the Mac folders in lists are always drawn closed, so if an open
111 // folder icon is asked for we will ask for a closed one in its place
112 if ( client
== wxART_LIST
&& id
== wxART_FOLDER_OPEN
)
113 return wxMacArtProvider_CreateIconBundle(wxART_FOLDER
);
115 return wxMacArtProvider_CreateIconBundle(id
);
120 // ----------------------------------------------------------------------------
121 // wxArtProvider::GetNativeSizeHint()
122 // ----------------------------------------------------------------------------
125 wxSize
wxArtProvider::GetNativeSizeHint(const wxArtClient
& client
)
127 if ( client
== wxART_TOOLBAR
)
129 // See http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIcons/chapter_15_section_9.html:
130 // "32 x 32 pixels is the recommended size"
131 return wxSize(32, 32);
133 else if ( client
== wxART_BUTTON
|| client
== wxART_MENU
)
135 // Mac UI doesn't use any images in neither buttons nor menus in
136 // general but the code using wxArtProvider can use wxART_BUTTON to
137 // find the icons of a roughly appropriate size for the buttons and
138 // 16x16 seems to be the best choice for this kind of use
139 return wxSize(16, 16);
142 return wxDefaultSize
;