/[pcsx2_0.9.7]/trunk/3rdparty/wxWidgets/src/common/artstd.cpp
ViewVC logotype

Contents of /trunk/3rdparty/wxWidgets/src/common/artstd.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (10 years, 2 months ago) by william
File size: 9773 byte(s)
committing r3113 initial commit again...
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: artstd.cpp 52561 2008-03-16 00:36:37Z VS $
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 // helper macros
42 // ----------------------------------------------------------------------------
43
44 // Standard macro for getting a resource from XPM file:
45 #define ART(artId, xpmRc) \
46 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
47
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 { \
68 CREATE_STD_ICON(#iconId, xpmRc) \
69 }
70
71 // ----------------------------------------------------------------------------
72 // wxArtProvider::InitStdProvider
73 // ----------------------------------------------------------------------------
74
75 /*static*/ void wxArtProvider::InitStdProvider()
76 {
77 wxArtProvider::Push(new wxDefaultArtProvider);
78 }
79
80 #if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__)
81 /*static*/ void wxArtProvider::InitNativeProvider()
82 {
83 }
84 #endif
85
86
87 // ----------------------------------------------------------------------------
88 // XPMs with the art
89 // ----------------------------------------------------------------------------
90
91
92 #if defined(__WXGTK__)
93 #include "../../art/gtk/info.xpm"
94 #include "../../art/gtk/error.xpm"
95 #include "../../art/gtk/warning.xpm"
96 #include "../../art/gtk/question.xpm"
97 #elif defined(__WXMOTIF__)
98 #include "../../art/motif/info.xpm"
99 #include "../../art/motif/error.xpm"
100 #include "../../art/motif/warning.xpm"
101 #include "../../art/motif/question.xpm"
102 #endif
103
104 #if wxUSE_HTML
105 #include "../../art/htmsidep.xpm"
106 #include "../../art/htmoptns.xpm"
107 #include "../../art/htmbook.xpm"
108 #include "../../art/htmfoldr.xpm"
109 #include "../../art/htmpage.xpm"
110 #endif // wxUSE_HTML
111
112 #include "../../art/missimg.xpm"
113 #include "../../art/addbookm.xpm"
114 #include "../../art/delbookm.xpm"
115 #include "../../art/back.xpm"
116 #include "../../art/forward.xpm"
117 #include "../../art/up.xpm"
118 #include "../../art/down.xpm"
119 #include "../../art/toparent.xpm"
120 #include "../../art/fileopen.xpm"
121 #include "../../art/print.xpm"
122 #include "../../art/helpicon.xpm"
123 #include "../../art/tipicon.xpm"
124 #include "../../art/home.xpm"
125 #include "../../art/repview.xpm"
126 #include "../../art/listview.xpm"
127 #include "../../art/new_dir.xpm"
128 #include "../../art/harddisk.xpm"
129 #include "../../art/cdrom.xpm"
130 #include "../../art/floppy.xpm"
131 #include "../../art/removable.xpm"
132 #include "../../art/folder.xpm"
133 #include "../../art/folder_open.xpm"
134 #include "../../art/dir_up.xpm"
135 #include "../../art/exefile.xpm"
136 #include "../../art/deffile.xpm"
137 #include "../../art/tick.xpm"
138 #include "../../art/cross.xpm"
139
140 #include "../../art/filesave.xpm"
141 #include "../../art/filesaveas.xpm"
142 #include "../../art/copy.xpm"
143 #include "../../art/cut.xpm"
144 #include "../../art/paste.xpm"
145 #include "../../art/delete.xpm"
146 #include "../../art/new.xpm"
147 #include "../../art/undo.xpm"
148 #include "../../art/redo.xpm"
149 #include "../../art/quit.xpm"
150 #include "../../art/find.xpm"
151 #include "../../art/findrepl.xpm"
152
153
154
155 wxBitmap wxDefaultArtProvider_CreateBitmap(const wxArtID& id)
156 {
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:
164 #if wxUSE_HTML
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)
170 #endif // wxUSE_HTML
171 ART(wxART_MISSING_IMAGE, missimg)
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)
179 ART(wxART_GO_HOME, home)
180 ART(wxART_FILE_OPEN, fileopen)
181 ART(wxART_PRINT, print)
182 ART(wxART_HELP, helpicon)
183 ART(wxART_TIP, tipicon)
184 ART(wxART_REPORT_VIEW, repview)
185 ART(wxART_LIST_VIEW, listview)
186 ART(wxART_NEW_DIR, new_dir)
187 ART(wxART_HARDDISK, harddisk)
188 ART(wxART_FLOPPY, floppy)
189 ART(wxART_CDROM, cdrom)
190 ART(wxART_REMOVABLE, removable)
191 ART(wxART_FOLDER, folder)
192 ART(wxART_FOLDER_OPEN, folder_open)
193 ART(wxART_GO_DIR_UP, dir_up)
194 ART(wxART_EXECUTABLE_FILE, exefile)
195 ART(wxART_NORMAL_FILE, deffile)
196 ART(wxART_TICK_MARK, tick)
197 ART(wxART_CROSS_MARK, cross)
198
199 ART(wxART_FILE_SAVE, filesave)
200 ART(wxART_FILE_SAVE_AS, filesaveas)
201 ART(wxART_COPY, copy)
202 ART(wxART_CUT, cut)
203 ART(wxART_PASTE, paste)
204 ART(wxART_DELETE, delete)
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)
210 ART(wxART_NEW, new)
211
212
213 return wxNullBitmap;
214 }
215
216 // ----------------------------------------------------------------------------
217 // CreateBitmap routine
218 // ----------------------------------------------------------------------------
219
220 wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id,
221 const wxArtClient& client,
222 const wxSize& reqSize)
223 {
224 wxBitmap bmp = wxDefaultArtProvider_CreateBitmap(id);
225
226 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
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
239 if ((bmp_h < bestSize.x) && (bmp_w < bestSize.y))
240 {
241 // the caller wants default size, which is larger than
242 // the image we have; to avoid degrading it visually by
243 // scaling it up, paste it into transparent image instead:
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);
248 }
249 else // scale (down or mixed, but not up)
250 {
251 wxImage img = bmp.ConvertToImage();
252 bmp = wxBitmap
253 (
254 img.Scale(bestSize.x, bestSize.y,
255 wxIMAGE_QUALITY_HIGH)
256 );
257 }
258 }
259 }
260 }
261 #else
262 wxUnusedVar(client);
263 wxUnusedVar(reqSize);
264 #endif // wxUSE_IMAGE
265
266 return bmp;
267 }

  ViewVC Help
Powered by ViewVC 1.1.22