]> git.saurik.com Git - wxWidgets.git/blame - src/common/artstd.cpp
fix warnings (double to int conversions and unused variables); removed hard TABs...
[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
155ecd4c
WS
23#ifndef WX_PRECOMP
24 #include "wx/image.h"
25#endif
26
2aca4a98 27#include "wx/artprov.h"
2aca4a98
VS
28
29// ----------------------------------------------------------------------------
30// wxDefaultArtProvider
31// ----------------------------------------------------------------------------
32
33class wxDefaultArtProvider : public wxArtProvider
34{
35protected:
57b0987b
VS
36 virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
37 const wxSize& size);
2aca4a98
VS
38};
39
66941e14
VS
40// ----------------------------------------------------------------------------
41// helper macros
42// ----------------------------------------------------------------------------
43
44// Standard macro for getting a resource from XPM file:
57b0987b
VS
45#define ART(artId, xpmRc) \
46 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
66941e14 47
66941e14
VS
48// There are two ways of getting the standard icon: either via XPMs or via
49// wxIcon ctor. This depends on the platform:
50#if defined(__WXUNIVERSAL__)
51 #define CREATE_STD_ICON(iconId, xpmRc) return wxNullBitmap;
52#elif defined(__WXGTK__) || defined(__WXMOTIF__)
53 #define CREATE_STD_ICON(iconId, xpmRc) return wxBitmap(xpmRc##_xpm);
54#else
55 #define CREATE_STD_ICON(iconId, xpmRc) \
56 { \
57 wxIcon icon(_T(iconId)); \
58 wxBitmap bmp; \
59 bmp.CopyFromIcon(icon); \
60 return bmp; \
61 }
62#endif
63
64// Macro used in CreateBitmap to get wxICON_FOO icons:
65#define ART_MSGBOX(artId, iconId, xpmRc) \
66 if ( id == artId ) \
67 { \
66941e14
VS
68 CREATE_STD_ICON(#iconId, xpmRc) \
69 }
2aca4a98
VS
70
71// ----------------------------------------------------------------------------
2b5f62a0 72// wxArtProvider::InitStdProvider
2aca4a98
VS
73// ----------------------------------------------------------------------------
74
2b5f62a0 75/*static*/ void wxArtProvider::InitStdProvider()
2aca4a98 76{
571d2e0f 77 wxArtProvider::Push(new wxDefaultArtProvider);
2b5f62a0 78}
2aca4a98 79
ff44780b
VS
80#if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__)
81/*static*/ void wxArtProvider::InitNativeProvider()
82{
83}
84#endif
85
2aca4a98
VS
86
87// ----------------------------------------------------------------------------
88// XPMs with the art
89// ----------------------------------------------------------------------------
90
91// XPM hack: make the arrays const
92#define static static const
93
66941e14
VS
94#if defined(__WXGTK__)
95 #include "../../art/gtk/info.xpm"
96 #include "../../art/gtk/error.xpm"
97 #include "../../art/gtk/warning.xpm"
98 #include "../../art/gtk/question.xpm"
99#elif defined(__WXMOTIF__)
100 #include "../../art/motif/info.xpm"
101 #include "../../art/motif/error.xpm"
102 #include "../../art/motif/warning.xpm"
103 #include "../../art/motif/question.xpm"
104#endif
105
2aca4a98 106#if wxUSE_HTML
57b0987b
VS
107 #include "../../art/htmsidep.xpm"
108 #include "../../art/htmoptns.xpm"
109 #include "../../art/htmbook.xpm"
110 #include "../../art/htmfoldr.xpm"
111 #include "../../art/htmpage.xpm"
2aca4a98
VS
112#endif // wxUSE_HTML
113
0de41e82 114#include "../../art/missimg.xpm"
57b0987b
VS
115#include "../../art/addbookm.xpm"
116#include "../../art/delbookm.xpm"
117#include "../../art/back.xpm"
118#include "../../art/forward.xpm"
119#include "../../art/up.xpm"
120#include "../../art/down.xpm"
121#include "../../art/toparent.xpm"
122#include "../../art/fileopen.xpm"
123#include "../../art/print.xpm"
124#include "../../art/helpicon.xpm"
125#include "../../art/tipicon.xpm"
60d2cc25
VS
126#include "../../art/home.xpm"
127#include "../../art/repview.xpm"
128#include "../../art/listview.xpm"
129#include "../../art/new_dir.xpm"
ddf6088b
RR
130#include "../../art/harddisk.xpm"
131#include "../../art/cdrom.xpm"
132#include "../../art/floppy.xpm"
133#include "../../art/removable.xpm"
60d2cc25 134#include "../../art/folder.xpm"
ddf6088b 135#include "../../art/folder_open.xpm"
60d2cc25
VS
136#include "../../art/dir_up.xpm"
137#include "../../art/exefile.xpm"
138#include "../../art/deffile.xpm"
00958db5
VS
139#include "../../art/tick.xpm"
140#include "../../art/cross.xpm"
2aca4a98 141
ec6803d9
RD
142#include "../../art/filesave.xpm"
143#include "../../art/filesaveas.xpm"
144#include "../../art/copy.xpm"
145#include "../../art/cut.xpm"
146#include "../../art/paste.xpm"
d00016f5 147#include "../../art/delete.xpm"
406011a8 148#include "../../art/new.xpm"
ec6803d9
RD
149#include "../../art/undo.xpm"
150#include "../../art/redo.xpm"
151#include "../../art/quit.xpm"
152#include "../../art/find.xpm"
153#include "../../art/findrepl.xpm"
154
155
2aca4a98
VS
156#undef static
157
e53a95bc 158wxBitmap wxDefaultArtProvider_CreateBitmap(const wxArtID& id)
2aca4a98 159{
66941e14
VS
160 // wxMessageBox icons:
161 ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error)
162 ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info)
163 ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning)
164 ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question)
165
166 // standard icons:
2aca4a98 167#if wxUSE_HTML
57b0987b
VS
168 ART(wxART_HELP_SIDE_PANEL, htmsidep)
169 ART(wxART_HELP_SETTINGS, htmoptns)
170 ART(wxART_HELP_BOOK, htmbook)
171 ART(wxART_HELP_FOLDER, htmfoldr)
172 ART(wxART_HELP_PAGE, htmpage)
2aca4a98 173#endif // wxUSE_HTML
ff44780b 174 ART(wxART_MISSING_IMAGE, missimg)
57b0987b
VS
175 ART(wxART_ADD_BOOKMARK, addbookm)
176 ART(wxART_DEL_BOOKMARK, delbookm)
177 ART(wxART_GO_BACK, back)
178 ART(wxART_GO_FORWARD, forward)
179 ART(wxART_GO_UP, up)
180 ART(wxART_GO_DOWN, down)
181 ART(wxART_GO_TO_PARENT, toparent)
60d2cc25 182 ART(wxART_GO_HOME, home)
57b0987b
VS
183 ART(wxART_FILE_OPEN, fileopen)
184 ART(wxART_PRINT, print)
185 ART(wxART_HELP, helpicon)
186 ART(wxART_TIP, tipicon)
60d2cc25
VS
187 ART(wxART_REPORT_VIEW, repview)
188 ART(wxART_LIST_VIEW, listview)
189 ART(wxART_NEW_DIR, new_dir)
ddf6088b
RR
190 ART(wxART_HARDDISK, harddisk)
191 ART(wxART_FLOPPY, floppy)
192 ART(wxART_CDROM, cdrom)
193 ART(wxART_REMOVABLE, removable)
60d2cc25 194 ART(wxART_FOLDER, folder)
ddf6088b 195 ART(wxART_FOLDER_OPEN, folder_open)
60d2cc25
VS
196 ART(wxART_GO_DIR_UP, dir_up)
197 ART(wxART_EXECUTABLE_FILE, exefile)
198 ART(wxART_NORMAL_FILE, deffile)
00958db5
VS
199 ART(wxART_TICK_MARK, tick)
200 ART(wxART_CROSS_MARK, cross)
2aca4a98 201
532d575b
WS
202 ART(wxART_FILE_SAVE, filesave)
203 ART(wxART_FILE_SAVE_AS, filesaveas)
ec6803d9
RD
204 ART(wxART_COPY, copy)
205 ART(wxART_CUT, cut)
206 ART(wxART_PASTE, paste)
d00016f5 207 ART(wxART_DELETE, delete)
ec6803d9
RD
208 ART(wxART_UNDO, undo)
209 ART(wxART_REDO, redo)
210 ART(wxART_QUIT, quit)
211 ART(wxART_FIND, find)
212 ART(wxART_FIND_AND_REPLACE, findrepl)
406011a8 213 ART(wxART_NEW, new)
532d575b
WS
214
215
2aca4a98
VS
216 return wxNullBitmap;
217}
e53a95bc
RR
218
219// ----------------------------------------------------------------------------
220// CreateBitmap routine
221// ----------------------------------------------------------------------------
222
223wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id,
224 const wxArtClient& client,
225 const wxSize& reqSize)
226{
227 wxBitmap bmp = wxDefaultArtProvider_CreateBitmap(id);
228
64c288fa 229#if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
e53a95bc
RR
230 if (bmp.Ok())
231 {
232 // fit into transparent image with desired size hint from the client
233 if (reqSize == wxDefaultSize)
234 {
235 // find out if there is a desired size for this client
236 wxSize bestSize = GetSizeHint(client);
237 if (bestSize != wxDefaultSize)
238 {
239 int bmp_w = bmp.GetWidth();
240 int bmp_h = bmp.GetHeight();
241 // want default size but it's smaller, paste into transparent image
242 if ((bmp_h < bestSize.x) && (bmp_w < bestSize.y))
243 {
244 wxPoint offset((bestSize.x - bmp_w)/2, (bestSize.y - bmp_h)/2);
245 wxImage img = bmp.ConvertToImage();
246 img.Resize(bestSize, offset);
247 bmp = wxBitmap(img);
a376ab30 248 }
e53a95bc 249 }
a376ab30 250 }
e53a95bc 251 }
532d575b
WS
252#else
253 wxUnusedVar(client);
254 wxUnusedVar(reqSize);
a376ab30
WS
255#endif // wxUSE_IMAGE
256
e53a95bc
RR
257 return bmp;
258}