]> git.saurik.com Git - wxWidgets.git/blame - src/common/artstd.cpp
Fix harmless gcc warning about uninitialized mask in PNG saving code.
[wxWidgets.git] / src / common / artstd.cpp
CommitLineData
2aca4a98 1/////////////////////////////////////////////////////////////////////////////
155ecd4c 2// Name: src/common/artstd.cpp
2aca4a98
VS
3// Purpose: stock wxArtProvider instance with default wxWin art
4// Author: Vaclav Slavik
5// Modified by:
6// Created: 18/03/2002
7// RCS-ID: $Id$
8// Copyright: (c) Vaclav Slavik
65571936 9// Licence: wxWindows licence
2aca4a98
VS
10/////////////////////////////////////////////////////////////////////////////
11
12// ---------------------------------------------------------------------------
13// headers
14// ---------------------------------------------------------------------------
15
2aca4a98
VS
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
2e9b5717
VZ
23#if wxUSE_ARTPROVIDER_STD
24
155ecd4c
WS
25#ifndef WX_PRECOMP
26 #include "wx/image.h"
27#endif
28
2aca4a98 29#include "wx/artprov.h"
2aca4a98
VS
30
31// ----------------------------------------------------------------------------
32// wxDefaultArtProvider
33// ----------------------------------------------------------------------------
34
35class wxDefaultArtProvider : public wxArtProvider
36{
37protected:
57b0987b
VS
38 virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
39 const wxSize& size);
2aca4a98
VS
40};
41
2aca4a98 42// ----------------------------------------------------------------------------
2b5f62a0 43// wxArtProvider::InitStdProvider
2aca4a98
VS
44// ----------------------------------------------------------------------------
45
2b5f62a0 46/*static*/ void wxArtProvider::InitStdProvider()
2aca4a98 47{
571d2e0f 48 wxArtProvider::Push(new wxDefaultArtProvider);
2b5f62a0 49}
2aca4a98 50
a158acac
VS
51// ----------------------------------------------------------------------------
52// helper macros
53// ----------------------------------------------------------------------------
ff44780b 54
a158acac
VS
55// Standard macro for getting a resource from XPM file:
56#define ART(artId, xpmRc) \
57 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
2aca4a98
VS
58
59// ----------------------------------------------------------------------------
60// XPMs with the art
61// ----------------------------------------------------------------------------
62
a158acac
VS
63#ifndef __WXUNIVERSAL__
64 #if defined(__WXGTK__)
65 #include "../../art/gtk/info.xpm"
66 #include "../../art/gtk/error.xpm"
67 #include "../../art/gtk/warning.xpm"
68 #include "../../art/gtk/question.xpm"
69 #elif defined(__WXMOTIF__)
70 #include "../../art/motif/info.xpm"
71 #include "../../art/motif/error.xpm"
72 #include "../../art/motif/warning.xpm"
73 #include "../../art/motif/question.xpm"
74 #endif
75#endif // !__WXUNIVERSAL__
66941e14 76
2aca4a98 77#if wxUSE_HTML
57b0987b
VS
78 #include "../../art/htmsidep.xpm"
79 #include "../../art/htmoptns.xpm"
80 #include "../../art/htmbook.xpm"
81 #include "../../art/htmfoldr.xpm"
82 #include "../../art/htmpage.xpm"
2aca4a98
VS
83#endif // wxUSE_HTML
84
0de41e82 85#include "../../art/missimg.xpm"
57b0987b
VS
86#include "../../art/addbookm.xpm"
87#include "../../art/delbookm.xpm"
88#include "../../art/back.xpm"
89#include "../../art/forward.xpm"
90#include "../../art/up.xpm"
91#include "../../art/down.xpm"
92#include "../../art/toparent.xpm"
93#include "../../art/fileopen.xpm"
94#include "../../art/print.xpm"
95#include "../../art/helpicon.xpm"
96#include "../../art/tipicon.xpm"
60d2cc25 97#include "../../art/home.xpm"
a7cfad3a
VZ
98#include "../../art/first.xpm"
99#include "../../art/last.xpm"
60d2cc25
VS
100#include "../../art/repview.xpm"
101#include "../../art/listview.xpm"
102#include "../../art/new_dir.xpm"
ddf6088b
RR
103#include "../../art/harddisk.xpm"
104#include "../../art/cdrom.xpm"
105#include "../../art/floppy.xpm"
106#include "../../art/removable.xpm"
60d2cc25 107#include "../../art/folder.xpm"
ddf6088b 108#include "../../art/folder_open.xpm"
60d2cc25
VS
109#include "../../art/dir_up.xpm"
110#include "../../art/exefile.xpm"
111#include "../../art/deffile.xpm"
00958db5
VS
112#include "../../art/tick.xpm"
113#include "../../art/cross.xpm"
2aca4a98 114
ec6803d9
RD
115#include "../../art/filesave.xpm"
116#include "../../art/filesaveas.xpm"
117#include "../../art/copy.xpm"
118#include "../../art/cut.xpm"
119#include "../../art/paste.xpm"
d00016f5 120#include "../../art/delete.xpm"
406011a8 121#include "../../art/new.xpm"
ec6803d9
RD
122#include "../../art/undo.xpm"
123#include "../../art/redo.xpm"
a7cfad3a
VZ
124#include "../../art/plus.xpm"
125#include "../../art/minus.xpm"
b9727751 126#include "../../art/close.xpm"
ec6803d9
RD
127#include "../../art/quit.xpm"
128#include "../../art/find.xpm"
129#include "../../art/findrepl.xpm"
130
e53a95bc 131wxBitmap wxDefaultArtProvider_CreateBitmap(const wxArtID& id)
2aca4a98 132{
a158acac 133#if !defined(__WXUNIVERSAL__) && (defined(__WXGTK__) || defined(__WXMOTIF__))
66941e14 134 // wxMessageBox icons:
a158acac
VS
135 ART(wxART_ERROR, error)
136 ART(wxART_INFORMATION, info)
137 ART(wxART_WARNING, warning)
138 ART(wxART_QUESTION, question)
139#endif
66941e14
VS
140
141 // standard icons:
2aca4a98 142#if wxUSE_HTML
57b0987b
VS
143 ART(wxART_HELP_SIDE_PANEL, htmsidep)
144 ART(wxART_HELP_SETTINGS, htmoptns)
145 ART(wxART_HELP_BOOK, htmbook)
146 ART(wxART_HELP_FOLDER, htmfoldr)
147 ART(wxART_HELP_PAGE, htmpage)
2aca4a98 148#endif // wxUSE_HTML
ff44780b 149 ART(wxART_MISSING_IMAGE, missimg)
57b0987b
VS
150 ART(wxART_ADD_BOOKMARK, addbookm)
151 ART(wxART_DEL_BOOKMARK, delbookm)
152 ART(wxART_GO_BACK, back)
153 ART(wxART_GO_FORWARD, forward)
154 ART(wxART_GO_UP, up)
155 ART(wxART_GO_DOWN, down)
156 ART(wxART_GO_TO_PARENT, toparent)
60d2cc25 157 ART(wxART_GO_HOME, home)
a7cfad3a
VZ
158 ART(wxART_GOTO_FIRST, first)
159 ART(wxART_GOTO_LAST, last)
57b0987b
VS
160 ART(wxART_FILE_OPEN, fileopen)
161 ART(wxART_PRINT, print)
162 ART(wxART_HELP, helpicon)
163 ART(wxART_TIP, tipicon)
60d2cc25
VS
164 ART(wxART_REPORT_VIEW, repview)
165 ART(wxART_LIST_VIEW, listview)
166 ART(wxART_NEW_DIR, new_dir)
ddf6088b
RR
167 ART(wxART_HARDDISK, harddisk)
168 ART(wxART_FLOPPY, floppy)
169 ART(wxART_CDROM, cdrom)
170 ART(wxART_REMOVABLE, removable)
60d2cc25 171 ART(wxART_FOLDER, folder)
ddf6088b 172 ART(wxART_FOLDER_OPEN, folder_open)
60d2cc25
VS
173 ART(wxART_GO_DIR_UP, dir_up)
174 ART(wxART_EXECUTABLE_FILE, exefile)
175 ART(wxART_NORMAL_FILE, deffile)
00958db5
VS
176 ART(wxART_TICK_MARK, tick)
177 ART(wxART_CROSS_MARK, cross)
2aca4a98 178
532d575b
WS
179 ART(wxART_FILE_SAVE, filesave)
180 ART(wxART_FILE_SAVE_AS, filesaveas)
ec6803d9
RD
181 ART(wxART_COPY, copy)
182 ART(wxART_CUT, cut)
183 ART(wxART_PASTE, paste)
d00016f5 184 ART(wxART_DELETE, delete)
ec6803d9
RD
185 ART(wxART_UNDO, undo)
186 ART(wxART_REDO, redo)
a7cfad3a
VZ
187 ART(wxART_PLUS, plus)
188 ART(wxART_MINUS, minus)
b9727751 189 ART(wxART_CLOSE, close)
ec6803d9
RD
190 ART(wxART_QUIT, quit)
191 ART(wxART_FIND, find)
192 ART(wxART_FIND_AND_REPLACE, findrepl)
406011a8 193 ART(wxART_NEW, new)
532d575b
WS
194
195
2aca4a98
VS
196 return wxNullBitmap;
197}
e53a95bc
RR
198
199// ----------------------------------------------------------------------------
200// CreateBitmap routine
201// ----------------------------------------------------------------------------
202
203wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id,
204 const wxArtClient& client,
205 const wxSize& reqSize)
206{
207 wxBitmap bmp = wxDefaultArtProvider_CreateBitmap(id);
208
64c288fa 209#if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
a1b806b9 210 if (bmp.IsOk())
e53a95bc
RR
211 {
212 // fit into transparent image with desired size hint from the client
213 if (reqSize == wxDefaultSize)
214 {
215 // find out if there is a desired size for this client
216 wxSize bestSize = GetSizeHint(client);
217 if (bestSize != wxDefaultSize)
218 {
219 int bmp_w = bmp.GetWidth();
220 int bmp_h = bmp.GetHeight();
e6e780ac 221
e53a95bc
RR
222 if ((bmp_h < bestSize.x) && (bmp_w < bestSize.y))
223 {
03647350 224 // the caller wants default size, which is larger than
e6e780ac
VS
225 // the image we have; to avoid degrading it visually by
226 // scaling it up, paste it into transparent image instead:
e53a95bc
RR
227 wxPoint offset((bestSize.x - bmp_w)/2, (bestSize.y - bmp_h)/2);
228 wxImage img = bmp.ConvertToImage();
229 img.Resize(bestSize, offset);
230 bmp = wxBitmap(img);
a376ab30 231 }
e6e780ac
VS
232 else // scale (down or mixed, but not up)
233 {
234 wxImage img = bmp.ConvertToImage();
235 bmp = wxBitmap
236 (
237 img.Scale(bestSize.x, bestSize.y,
238 wxIMAGE_QUALITY_HIGH)
239 );
240 }
e53a95bc 241 }
a376ab30 242 }
e53a95bc 243 }
532d575b
WS
244#else
245 wxUnusedVar(client);
246 wxUnusedVar(reqSize);
a376ab30
WS
247#endif // wxUSE_IMAGE
248
e53a95bc
RR
249 return bmp;
250}
2e9b5717
VZ
251
252#endif // wxUSE_ARTPROVIDER_STD