]>
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__)
26 #if !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON
28 #include "wx/artprov.h"
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class wxMacArtProvider
: public wxArtProvider
38 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
40 virtual wxIconBundle
CreateIconBundle(const wxArtID
& id
,
41 const wxArtClient
& client
);
44 /* static */ void wxArtProvider::InitNativeProvider()
46 wxArtProvider::Push(new wxMacArtProvider
);
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 #define CREATE_STD_ICON(iconId, xpmRc) \
55 wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
59 // Macro used in CreateBitmap to get wxICON_FOO icons:
60 #define ART_MSGBOX(artId, iconId, xpmRc) \
63 CREATE_STD_ICON(#iconId, xpmRc) \
66 static wxIconBundle
wxMacArtProvider_CreateIconBundle(const wxArtID
& id
)
68 ART_MSGBOX(wxART_ERROR
, wxICON_ERROR
, error
)
69 ART_MSGBOX(wxART_INFORMATION
, wxICON_INFORMATION
, info
)
70 ART_MSGBOX(wxART_WARNING
, wxICON_WARNING
, warning
)
71 ART_MSGBOX(wxART_QUESTION
, wxICON_QUESTION
, question
)
73 ART_MSGBOX(wxART_FOLDER
, wxICON_FOLDER
, folder
)
74 ART_MSGBOX(wxART_FOLDER_OPEN
, wxICON_FOLDER_OPEN
, folder_open
)
75 ART_MSGBOX(wxART_NORMAL_FILE
, wxICON_NORMAL_FILE
, deffile
)
77 return wxNullIconBundle
;
80 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
84 wxIconBundle
wxMacArtProvider::CreateIconBundle(const wxArtID
& id
, const wxArtClient
& client
)
86 // On the Mac folders in lists are always drawn closed, so if an open
87 // folder icon is asked for we will ask for a closed one in its place
88 if ( client
== wxART_LIST
&& id
== wxART_FOLDER_OPEN
)
89 return wxMacArtProvider_CreateIconBundle(wxART_FOLDER
);
91 return wxMacArtProvider_CreateIconBundle(id
);
94 // ----------------------------------------------------------------------------
96 // ----------------------------------------------------------------------------
98 wxBitmap
wxMacArtProvider::CreateBitmap(const wxArtID
& id
,
99 const wxArtClient
& client
,
100 const wxSize
& reqSize
)
102 wxIconBundle
ic(CreateIconBundle(id
, client
));
105 wxIcon
theIcon(ic
.GetIcon(reqSize
));
106 return wxBitmap(theIcon
);
112 #endif // !defined(__WXUNIVERSAL__)