]> git.saurik.com Git - wxWidgets.git/blame - src/msw/artmsw.cpp
Fix wxGrid compilation with MSVC7.
[wxWidgets.git] / src / msw / artmsw.cpp
CommitLineData
7abd9a03
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/artmsw.cpp
3// Purpose: stock wxArtProvider instance with native MSW stock icons
4// Author: Vaclav Slavik
5// Modified by:
6// Created: 2008-10-15
7// RCS-ID: $Id$
8// Copyright: (c) Vaclav Slavik, 2008
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ---------------------------------------------------------------------------
13// headers
14// ---------------------------------------------------------------------------
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#if defined(__BORLANDC__)
20 #pragma hdrstop
21#endif
22
23#include "wx/artprov.h"
24#include "wx/msw/wrapwin.h"
25
26
27// ----------------------------------------------------------------------------
28// wxWindowsArtProvider
29// ----------------------------------------------------------------------------
30
31class wxWindowsArtProvider : public wxArtProvider
32{
33protected:
34 virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
35 const wxSize& size);
36};
37
38static wxBitmap CreateFromStdIcon(const char *iconName)
39{
40 wxIcon icon(iconName);
41 wxBitmap bmp;
42 bmp.CopyFromIcon(icon);
43 return bmp;
44}
45
46wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id,
47 const wxArtClient& WXUNUSED(client),
48 const wxSize& WXUNUSED(size))
49{
50 // handle message box icons specially (wxIcon ctor treat these names
51 // as special cases via wxICOResourceHandler::LoadIcon):
52 if ( id == wxART_ERROR )
53 return CreateFromStdIcon("wxICON_ERROR");
54 else if ( id == wxART_INFORMATION )
55 return CreateFromStdIcon("wxICON_INFORMATION");
56 else if ( id == wxART_WARNING )
57 return CreateFromStdIcon("wxICON_WARNING");
58 else if ( id == wxART_QUESTION )
59 return CreateFromStdIcon("wxICON_QUESTION");
60
61 // for anything else, fall back to generic provider:
62 return wxNullBitmap;
63}
64
65// ----------------------------------------------------------------------------
66// wxArtProvider::InitNativeProvider()
67// ----------------------------------------------------------------------------
68
69/*static*/ void wxArtProvider::InitNativeProvider()
70{
71 Push(new wxWindowsArtProvider);
72}
73
74// ----------------------------------------------------------------------------
75// wxArtProvider::GetNativeSizeHint()
76// ----------------------------------------------------------------------------
77
78/*static*/
79wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client)
80{
81 if ( client == wxART_TOOLBAR )
82 {
83 return wxSize(24, 24);
84 }
85 else if ( client == wxART_MENU )
86 {
87 return wxSize(16, 16);
88 }
89 else if ( client == wxART_FRAME_ICON )
90 {
91 return wxSize(::GetSystemMetrics(SM_CXSMICON),
92 ::GetSystemMetrics(SM_CYSMICON));
93 }
94 else if ( client == wxART_CMN_DIALOG ||
95 client == wxART_MESSAGE_BOX )
96 {
97 return wxSize(::GetSystemMetrics(SM_CXICON),
98 ::GetSystemMetrics(SM_CYICON));
99 }
100 else if (client == wxART_BUTTON)
101 {
102 return wxSize(16, 16);
103 }
104
105 return wxDefaultSize;
106}