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