]>
git.saurik.com Git - wxWidgets.git/blob - src/common/artstd.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/artstd.cpp
3 // Purpose: stock wxArtProvider instance with default wxWin art
4 // Author: Vaclav Slavik
8 // Copyright: (c) Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ---------------------------------------------------------------------------
14 // ---------------------------------------------------------------------------
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #if defined(__BORLANDC__)
27 #include "wx/artprov.h"
29 // ----------------------------------------------------------------------------
30 // wxDefaultArtProvider
31 // ----------------------------------------------------------------------------
33 class wxDefaultArtProvider
: public wxArtProvider
36 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 // Standard macro for getting a resource from XPM file:
45 #define ART(artId, xpmRc) \
46 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
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__) || ( defined(__WXMAC__) && wxOSX_USE_IPHONE )
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);
55 #define CREATE_STD_ICON(iconId, xpmRc) \
57 wxIcon icon(_T(iconId)); \
59 bmp.CopyFromIcon(icon); \
64 // Macro used in CreateBitmap to get wxICON_FOO icons:
65 #define ART_MSGBOX(artId, iconId, xpmRc) \
68 CREATE_STD_ICON(#iconId, xpmRc) \
71 // ----------------------------------------------------------------------------
72 // wxArtProvider::InitStdProvider
73 // ----------------------------------------------------------------------------
75 /*static*/ void wxArtProvider::InitStdProvider()
77 wxArtProvider::Push(new wxDefaultArtProvider
);
80 #if !(defined(__WXGTK20__) || (defined(__WXMAC__) && wxOSX_USE_CARBON)) || defined(__WXUNIVERSAL__)
81 /*static*/ void wxArtProvider::InitNativeProvider()
87 // ----------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
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"
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"
111 #include "../../art/missimg.xpm"
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"
123 #include "../../art/home.xpm"
124 #include "../../art/repview.xpm"
125 #include "../../art/listview.xpm"
126 #include "../../art/new_dir.xpm"
127 #include "../../art/harddisk.xpm"
128 #include "../../art/cdrom.xpm"
129 #include "../../art/floppy.xpm"
130 #include "../../art/removable.xpm"
131 #include "../../art/folder.xpm"
132 #include "../../art/folder_open.xpm"
133 #include "../../art/dir_up.xpm"
134 #include "../../art/exefile.xpm"
135 #include "../../art/deffile.xpm"
136 #include "../../art/tick.xpm"
137 #include "../../art/cross.xpm"
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"
144 #include "../../art/delete.xpm"
145 #include "../../art/new.xpm"
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"
152 wxBitmap
wxDefaultArtProvider_CreateBitmap(const wxArtID
& id
)
154 // wxMessageBox icons:
155 ART_MSGBOX(wxART_ERROR
, wxICON_ERROR
, error
)
156 ART_MSGBOX(wxART_INFORMATION
, wxICON_INFORMATION
, info
)
157 ART_MSGBOX(wxART_WARNING
, wxICON_WARNING
, warning
)
158 ART_MSGBOX(wxART_QUESTION
, wxICON_QUESTION
, question
)
162 ART(wxART_HELP_SIDE_PANEL
, htmsidep
)
163 ART(wxART_HELP_SETTINGS
, htmoptns
)
164 ART(wxART_HELP_BOOK
, htmbook
)
165 ART(wxART_HELP_FOLDER
, htmfoldr
)
166 ART(wxART_HELP_PAGE
, htmpage
)
168 ART(wxART_MISSING_IMAGE
, missimg
)
169 ART(wxART_ADD_BOOKMARK
, addbookm
)
170 ART(wxART_DEL_BOOKMARK
, delbookm
)
171 ART(wxART_GO_BACK
, back
)
172 ART(wxART_GO_FORWARD
, forward
)
174 ART(wxART_GO_DOWN
, down
)
175 ART(wxART_GO_TO_PARENT
, toparent
)
176 ART(wxART_GO_HOME
, home
)
177 ART(wxART_FILE_OPEN
, fileopen
)
178 ART(wxART_PRINT
, print
)
179 ART(wxART_HELP
, helpicon
)
180 ART(wxART_TIP
, tipicon
)
181 ART(wxART_REPORT_VIEW
, repview
)
182 ART(wxART_LIST_VIEW
, listview
)
183 ART(wxART_NEW_DIR
, new_dir
)
184 ART(wxART_HARDDISK
, harddisk
)
185 ART(wxART_FLOPPY
, floppy
)
186 ART(wxART_CDROM
, cdrom
)
187 ART(wxART_REMOVABLE
, removable
)
188 ART(wxART_FOLDER
, folder
)
189 ART(wxART_FOLDER_OPEN
, folder_open
)
190 ART(wxART_GO_DIR_UP
, dir_up
)
191 ART(wxART_EXECUTABLE_FILE
, exefile
)
192 ART(wxART_NORMAL_FILE
, deffile
)
193 ART(wxART_TICK_MARK
, tick
)
194 ART(wxART_CROSS_MARK
, cross
)
196 ART(wxART_FILE_SAVE
, filesave
)
197 ART(wxART_FILE_SAVE_AS
, filesaveas
)
198 ART(wxART_COPY
, copy
)
200 ART(wxART_PASTE
, paste
)
201 ART(wxART_DELETE
, delete)
202 ART(wxART_UNDO
, undo
)
203 ART(wxART_REDO
, redo
)
204 ART(wxART_QUIT
, quit
)
205 ART(wxART_FIND
, find
)
206 ART(wxART_FIND_AND_REPLACE
, findrepl
)
213 // ----------------------------------------------------------------------------
214 // CreateBitmap routine
215 // ----------------------------------------------------------------------------
217 wxBitmap
wxDefaultArtProvider::CreateBitmap(const wxArtID
& id
,
218 const wxArtClient
& client
,
219 const wxSize
& reqSize
)
221 wxBitmap bmp
= wxDefaultArtProvider_CreateBitmap(id
);
223 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
226 // fit into transparent image with desired size hint from the client
227 if (reqSize
== wxDefaultSize
)
229 // find out if there is a desired size for this client
230 wxSize bestSize
= GetSizeHint(client
);
231 if (bestSize
!= wxDefaultSize
)
233 int bmp_w
= bmp
.GetWidth();
234 int bmp_h
= bmp
.GetHeight();
236 if ((bmp_h
< bestSize
.x
) && (bmp_w
< bestSize
.y
))
238 // the caller wants default size, which is larger than
239 // the image we have; to avoid degrading it visually by
240 // scaling it up, paste it into transparent image instead:
241 wxPoint
offset((bestSize
.x
- bmp_w
)/2, (bestSize
.y
- bmp_h
)/2);
242 wxImage img
= bmp
.ConvertToImage();
243 img
.Resize(bestSize
, offset
);
246 else // scale (down or mixed, but not up)
248 wxImage img
= bmp
.ConvertToImage();
251 img
.Scale(bestSize
.x
, bestSize
.y
,
252 wxIMAGE_QUALITY_HIGH
)
260 wxUnusedVar(reqSize
);
261 #endif // wxUSE_IMAGE