]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/artmsw.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/artmsw.cpp
3 // Purpose: stock wxArtProvider instance with native MSW stock icons
4 // Author: Vaclav Slavik
8 // Copyright: (c) Vaclav Slavik, 2008
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ---------------------------------------------------------------------------
14 // ---------------------------------------------------------------------------
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #if defined(__BORLANDC__)
23 #include "wx/artprov.h"
25 #include "wx/msw/wrapwin.h"
28 // ----------------------------------------------------------------------------
29 // wxWindowsArtProvider
30 // ----------------------------------------------------------------------------
32 class wxWindowsArtProvider
: public wxArtProvider
35 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
39 static wxBitmap
CreateFromStdIcon(const char *iconName
,
40 const wxArtClient
& client
)
42 wxIcon
icon(iconName
);
44 bmp
.CopyFromIcon(icon
);
47 // The standard native message box icons are in message box size (32x32).
48 // If they are requested in any size other than the default or message
49 // box size, they must be rescaled first.
50 if ( client
!= wxART_MESSAGE_BOX
&& client
!= wxART_OTHER
)
52 const wxSize size
= wxArtProvider::GetNativeSizeHint(client
);
53 if ( size
!= wxDefaultSize
)
55 wxImage img
= bmp
.ConvertToImage();
56 img
.Rescale(size
.x
, size
.y
);
65 wxBitmap
wxWindowsArtProvider::CreateBitmap(const wxArtID
& id
,
66 const wxArtClient
& client
,
67 const wxSize
& WXUNUSED(size
))
69 // handle message box icons specially (wxIcon ctor treat these names
70 // as special cases via wxICOResourceHandler::LoadIcon):
71 const char *name
= NULL
;
72 if ( id
== wxART_ERROR
)
73 name
= "wxICON_ERROR";
74 else if ( id
== wxART_INFORMATION
)
75 name
= "wxICON_INFORMATION";
76 else if ( id
== wxART_WARNING
)
77 name
= "wxICON_WARNING";
78 else if ( id
== wxART_QUESTION
)
79 name
= "wxICON_QUESTION";
82 return CreateFromStdIcon(name
, client
);
84 // for anything else, fall back to generic provider:
88 // ----------------------------------------------------------------------------
89 // wxArtProvider::InitNativeProvider()
90 // ----------------------------------------------------------------------------
92 /*static*/ void wxArtProvider::InitNativeProvider()
94 PushBack(new wxWindowsArtProvider
);
97 // ----------------------------------------------------------------------------
98 // wxArtProvider::GetNativeSizeHint()
99 // ----------------------------------------------------------------------------
102 wxSize
wxArtProvider::GetNativeSizeHint(const wxArtClient
& client
)
104 if ( client
== wxART_TOOLBAR
)
106 return wxSize(24, 24);
108 else if ( client
== wxART_MENU
)
110 return wxSize(16, 16);
112 else if ( client
== wxART_FRAME_ICON
)
114 return wxSize(::GetSystemMetrics(SM_CXSMICON
),
115 ::GetSystemMetrics(SM_CYSMICON
));
117 else if ( client
== wxART_CMN_DIALOG
||
118 client
== wxART_MESSAGE_BOX
)
120 return wxSize(::GetSystemMetrics(SM_CXICON
),
121 ::GetSystemMetrics(SM_CYICON
));
123 else if (client
== wxART_BUTTON
)
125 return wxSize(16, 16);
127 else if (client
== wxART_LIST
)
129 return wxSize(16, 16);
132 return wxDefaultSize
;