]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/artmac.cpp
Added extra width for controls to avoid edge being clipped
[wxWidgets.git] / src / mac / carbon / artmac.cpp
CommitLineData
52734360
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/mac/carbon/artmac.cpp
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
22#ifndef WX_PRECOMP
23 #include "wx/image.h"
24#endif
25
26#include "wx/artprov.h"
27#include "wx/image.h"
28
29// ----------------------------------------------------------------------------
30// wxMacArtProvider
31// ----------------------------------------------------------------------------
32
33class wxMacArtProvider : public wxArtProvider
34{
35protected:
36 virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
37 const wxSize& size);
38 virtual wxIconBundle CreateIconBundle(const wxArtID& id,
39 const wxArtClient& client);
40};
41
42/* static */ void wxArtProvider::InitNativeProvider()
43{
44 wxArtProvider::Push(new wxMacArtProvider);
45}
46
47// ----------------------------------------------------------------------------
48// helper macros
49// ----------------------------------------------------------------------------
50
51#define CREATE_STD_ICON(iconId, xpmRc) \
52 { \
53 wxIconBundle icon(_T(iconId), wxBITMAP_TYPE_ICON_RESOURCE); \
54 return icon; \
55 }
56
57// Macro used in CreateBitmap to get wxICON_FOO icons:
58#define ART_MSGBOX(artId, iconId, xpmRc) \
59 if ( id == artId ) \
60 { \
61 CREATE_STD_ICON(#iconId, xpmRc) \
62 }
63
64static wxIconBundle wxMacArtProvider_CreateIconBundle(const wxArtID& id)
65{
66 ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error)
67 ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info)
68 ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning)
69 ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question)
70
71 ART_MSGBOX(wxART_FOLDER, wxICON_FOLDER, folder)
72 ART_MSGBOX(wxART_FOLDER_OPEN, wxICON_FOLDER_OPEN, folder_open)
73 ART_MSGBOX(wxART_NORMAL_FILE, wxICON_NORMAL_FILE, deffile)
74
75 return wxNullIconBundle;
76}
77
78// ----------------------------------------------------------------------------
79// CreateIconBundle
80// ----------------------------------------------------------------------------
81
82wxIconBundle wxMacArtProvider::CreateIconBundle(const wxArtID& id, const wxArtClient& client)
83{
84 // On the Mac folders in lists are always drawn closed, so if an open
85 // folder icon is asked for we will ask for a closed one in its place
86 if ( client == wxART_LIST && id == wxART_FOLDER_OPEN )
87 return wxMacArtProvider_CreateIconBundle(wxART_FOLDER);
88
89 return wxMacArtProvider_CreateIconBundle(id);
90}
91
92// ----------------------------------------------------------------------------
93// CreateBitmap
94// ----------------------------------------------------------------------------
95
96wxBitmap wxMacArtProvider::CreateBitmap(const wxArtID& id,
97 const wxArtClient& client,
98 const wxSize& reqSize)
99{
100 wxIconBundle ic(CreateIconBundle(id, client));
101 if (ic.IsOk())
102 {
103 wxIcon theIcon(ic.GetIcon(reqSize));
104 return wxBitmap(theIcon);
105 }
106
107 return wxNullBitmap;
108}