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