]> git.saurik.com Git - wxWidgets.git/blob - src/common/artstd.cpp
Move SetDefaultTimeout to wxProtocol and set it to 60 seconds for both wxHTTP and...
[wxWidgets.git] / src / common / artstd.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ---------------------------------------------------------------------------
13 // headers
14 // ---------------------------------------------------------------------------
15
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 #ifndef WX_PRECOMP
24 #include "wx/image.h"
25 #endif
26
27 #include "wx/artprov.h"
28
29 // ----------------------------------------------------------------------------
30 // wxDefaultArtProvider
31 // ----------------------------------------------------------------------------
32
33 class wxDefaultArtProvider : public wxArtProvider
34 {
35 protected:
36 virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
37 const wxSize& size);
38 };
39
40 // ----------------------------------------------------------------------------
41 // wxArtProvider::InitStdProvider
42 // ----------------------------------------------------------------------------
43
44 /*static*/ void wxArtProvider::InitStdProvider()
45 {
46 wxArtProvider::Push(new wxDefaultArtProvider);
47 }
48
49 // ----------------------------------------------------------------------------
50 // helper macros
51 // ----------------------------------------------------------------------------
52
53 // Standard macro for getting a resource from XPM file:
54 #define ART(artId, xpmRc) \
55 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
56
57 // ----------------------------------------------------------------------------
58 // XPMs with the art
59 // ----------------------------------------------------------------------------
60
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__
74
75 #if wxUSE_HTML
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"
81 #endif // wxUSE_HTML
82
83 #include "../../art/missimg.xpm"
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"
95 #include "../../art/home.xpm"
96 #include "../../art/repview.xpm"
97 #include "../../art/listview.xpm"
98 #include "../../art/new_dir.xpm"
99 #include "../../art/harddisk.xpm"
100 #include "../../art/cdrom.xpm"
101 #include "../../art/floppy.xpm"
102 #include "../../art/removable.xpm"
103 #include "../../art/folder.xpm"
104 #include "../../art/folder_open.xpm"
105 #include "../../art/dir_up.xpm"
106 #include "../../art/exefile.xpm"
107 #include "../../art/deffile.xpm"
108 #include "../../art/tick.xpm"
109 #include "../../art/cross.xpm"
110
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"
116 #include "../../art/delete.xpm"
117 #include "../../art/new.xpm"
118 #include "../../art/undo.xpm"
119 #include "../../art/redo.xpm"
120 #include "../../art/quit.xpm"
121 #include "../../art/find.xpm"
122 #include "../../art/findrepl.xpm"
123
124 wxBitmap wxDefaultArtProvider_CreateBitmap(const wxArtID& id)
125 {
126 #if !defined(__WXUNIVERSAL__) && (defined(__WXGTK__) || defined(__WXMOTIF__))
127 // wxMessageBox icons:
128 ART(wxART_ERROR, error)
129 ART(wxART_INFORMATION, info)
130 ART(wxART_WARNING, warning)
131 ART(wxART_QUESTION, question)
132 #endif
133
134 // standard icons:
135 #if wxUSE_HTML
136 ART(wxART_HELP_SIDE_PANEL, htmsidep)
137 ART(wxART_HELP_SETTINGS, htmoptns)
138 ART(wxART_HELP_BOOK, htmbook)
139 ART(wxART_HELP_FOLDER, htmfoldr)
140 ART(wxART_HELP_PAGE, htmpage)
141 #endif // wxUSE_HTML
142 ART(wxART_MISSING_IMAGE, missimg)
143 ART(wxART_ADD_BOOKMARK, addbookm)
144 ART(wxART_DEL_BOOKMARK, delbookm)
145 ART(wxART_GO_BACK, back)
146 ART(wxART_GO_FORWARD, forward)
147 ART(wxART_GO_UP, up)
148 ART(wxART_GO_DOWN, down)
149 ART(wxART_GO_TO_PARENT, toparent)
150 ART(wxART_GO_HOME, home)
151 ART(wxART_FILE_OPEN, fileopen)
152 ART(wxART_PRINT, print)
153 ART(wxART_HELP, helpicon)
154 ART(wxART_TIP, tipicon)
155 ART(wxART_REPORT_VIEW, repview)
156 ART(wxART_LIST_VIEW, listview)
157 ART(wxART_NEW_DIR, new_dir)
158 ART(wxART_HARDDISK, harddisk)
159 ART(wxART_FLOPPY, floppy)
160 ART(wxART_CDROM, cdrom)
161 ART(wxART_REMOVABLE, removable)
162 ART(wxART_FOLDER, folder)
163 ART(wxART_FOLDER_OPEN, folder_open)
164 ART(wxART_GO_DIR_UP, dir_up)
165 ART(wxART_EXECUTABLE_FILE, exefile)
166 ART(wxART_NORMAL_FILE, deffile)
167 ART(wxART_TICK_MARK, tick)
168 ART(wxART_CROSS_MARK, cross)
169
170 ART(wxART_FILE_SAVE, filesave)
171 ART(wxART_FILE_SAVE_AS, filesaveas)
172 ART(wxART_COPY, copy)
173 ART(wxART_CUT, cut)
174 ART(wxART_PASTE, paste)
175 ART(wxART_DELETE, delete)
176 ART(wxART_UNDO, undo)
177 ART(wxART_REDO, redo)
178 ART(wxART_QUIT, quit)
179 ART(wxART_FIND, find)
180 ART(wxART_FIND_AND_REPLACE, findrepl)
181 ART(wxART_NEW, new)
182
183
184 return wxNullBitmap;
185 }
186
187 // ----------------------------------------------------------------------------
188 // CreateBitmap routine
189 // ----------------------------------------------------------------------------
190
191 wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id,
192 const wxArtClient& client,
193 const wxSize& reqSize)
194 {
195 wxBitmap bmp = wxDefaultArtProvider_CreateBitmap(id);
196
197 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
198 if (bmp.Ok())
199 {
200 // fit into transparent image with desired size hint from the client
201 if (reqSize == wxDefaultSize)
202 {
203 // find out if there is a desired size for this client
204 wxSize bestSize = GetSizeHint(client);
205 if (bestSize != wxDefaultSize)
206 {
207 int bmp_w = bmp.GetWidth();
208 int bmp_h = bmp.GetHeight();
209
210 if ((bmp_h < bestSize.x) && (bmp_w < bestSize.y))
211 {
212 // the caller wants default size, which is larger than
213 // the image we have; to avoid degrading it visually by
214 // scaling it up, paste it into transparent image instead:
215 wxPoint offset((bestSize.x - bmp_w)/2, (bestSize.y - bmp_h)/2);
216 wxImage img = bmp.ConvertToImage();
217 img.Resize(bestSize, offset);
218 bmp = wxBitmap(img);
219 }
220 else // scale (down or mixed, but not up)
221 {
222 wxImage img = bmp.ConvertToImage();
223 bmp = wxBitmap
224 (
225 img.Scale(bestSize.x, bestSize.y,
226 wxIMAGE_QUALITY_HIGH)
227 );
228 }
229 }
230 }
231 }
232 #else
233 wxUnusedVar(client);
234 wxUnusedVar(reqSize);
235 #endif // wxUSE_IMAGE
236
237 return bmp;
238 }