]> git.saurik.com Git - wxWidgets.git/blame - src/osx/artmac.cpp
Make the gui test still run on the buildbot when the non-gui tests fail.
[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:
489468fe
SC
37 virtual wxIconBundle CreateIconBundle(const wxArtID& id,
38 const wxArtClient& client);
39};
40
41/* static */ void wxArtProvider::InitNativeProvider()
42{
43 wxArtProvider::Push(new wxMacArtProvider);
44}
45
46// ----------------------------------------------------------------------------
47// helper macros
48// ----------------------------------------------------------------------------
49
50#define CREATE_STD_ICON(iconId, xpmRc) \
51 { \
9a83f860 52 wxIconBundle icon(wxT(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
489468fe
SC
53 return icon; \
54 }
55
56// Macro used in CreateBitmap to get wxICON_FOO icons:
57#define ART_MSGBOX(artId, iconId, xpmRc) \
58 if ( id == artId ) \
59 { \
60 CREATE_STD_ICON(#iconId, xpmRc) \
61 }
62
63static wxIconBundle wxMacArtProvider_CreateIconBundle(const wxArtID& id)
64{
65 ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error)
66 ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info)
67 ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning)
68 ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question)
69
70 ART_MSGBOX(wxART_FOLDER, wxICON_FOLDER, folder)
71 ART_MSGBOX(wxART_FOLDER_OPEN, wxICON_FOLDER_OPEN, folder_open)
72 ART_MSGBOX(wxART_NORMAL_FILE, wxICON_NORMAL_FILE, deffile)
9c4ae528 73 ART_MSGBOX(wxART_EXECUTABLE_FILE, wxICON_EXECUTABLE_FILE, exefile)
489468fe 74
03647350
VZ
75 ART_MSGBOX(wxART_CDROM, wxICON_CDROM, cdrom)
76 ART_MSGBOX(wxART_FLOPPY, wxICON_FLOPPY, floppy)
77 ART_MSGBOX(wxART_HARDDISK, wxICON_HARDDISK, harddisk)
78 ART_MSGBOX(wxART_REMOVABLE, wxICON_REMOVABLE, removable)
79
80 ART_MSGBOX(wxART_DELETE, wxICON_DELETE, delete)
81
82 ART_MSGBOX(wxART_GO_BACK, wxICON_GO_BACK, back)
83 ART_MSGBOX(wxART_GO_FORWARD, wxICON_GO_FORWARD, forward)
84 ART_MSGBOX(wxART_GO_HOME, wxICON_GO_HOME, home)
85
86 ART_MSGBOX(wxART_HELP_SETTINGS, wxICON_HELP_SETTINGS, htmoptns)
87 ART_MSGBOX(wxART_HELP_PAGE, wxICON_HELP_PAGE, htmpage)
88
489468fe
SC
89 return wxNullIconBundle;
90}
91
92// ----------------------------------------------------------------------------
93// CreateIconBundle
94// ----------------------------------------------------------------------------
95
96wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client)
97{
98 // On the Mac folders in lists are always drawn closed, so if an open
99 // folder icon is asked for we will ask for a closed one in its place
100 if ( client == wxART_LIST && id == wxART_FOLDER_OPEN )
101 return wxMacArtProvider_CreateIconBundle(wxART_FOLDER);
102
103 return wxMacArtProvider_CreateIconBundle(id);
104}
105
b2680ced 106
a158acac
VS
107// ----------------------------------------------------------------------------
108// wxArtProvider::GetNativeSizeHint()
109// ----------------------------------------------------------------------------
110
111/*static*/
112wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client)
113{
114 if ( client == wxART_TOOLBAR )
115 {
116 // See http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIcons/chapter_15_section_9.html:
117 // "32 x 32 pixels is the recommended size"
118 return wxSize(32, 32);
119 }
1d3dfc57
VZ
120 else if ( client == wxART_BUTTON || client == wxART_MENU )
121 {
122 // Mac UI doesn't use any images in neither buttons nor menus in
123 // general but the code using wxArtProvider can use wxART_BUTTON to
124 // find the icons of a roughly appropriate size for the buttons and
125 // 16x16 seems to be the best choice for this kind of use
126 return wxSize(16, 16);
127 }
a158acac
VS
128
129 return wxDefaultSize;
130}
b2680ced 131
1d61c554 132#endif // wxOSX_USE_COCOA_CARBON