]>
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
7 // Copyright: (c) Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ---------------------------------------------------------------------------
13 // ---------------------------------------------------------------------------
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
18 #if defined(__BORLANDC__)
22 #if wxUSE_ARTPROVIDER_STD
28 #include "wx/artprov.h"
30 // ----------------------------------------------------------------------------
31 // wxDefaultArtProvider
32 // ----------------------------------------------------------------------------
34 class wxDefaultArtProvider
: public wxArtProvider
37 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
41 // ----------------------------------------------------------------------------
42 // wxArtProvider::InitStdProvider
43 // ----------------------------------------------------------------------------
45 /*static*/ void wxArtProvider::InitStdProvider()
47 wxArtProvider::PushBack(new wxDefaultArtProvider
);
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 // Standard macro for getting a resource from XPM file:
55 #define ART(artId, xpmRc) \
56 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 #ifndef __WXUNIVERSAL__
63 #if defined(__WXGTK__)
64 #include "../../art/gtk/info.xpm"
65 #include "../../art/gtk/error.xpm"
66 #include "../../art/gtk/warning.xpm"
67 #include "../../art/gtk/question.xpm"
68 #elif defined(__WXMOTIF__)
69 #include "../../art/motif/info.xpm"
70 #include "../../art/motif/error.xpm"
71 #include "../../art/motif/warning.xpm"
72 #include "../../art/motif/question.xpm"
74 #endif // !__WXUNIVERSAL__
77 #include "../../art/htmsidep.xpm"
78 #include "../../art/htmoptns.xpm"
79 #include "../../art/htmbook.xpm"
80 #include "../../art/htmfoldr.xpm"
81 #include "../../art/htmpage.xpm"
84 #include "../../art/missimg.xpm"
85 #include "../../art/addbookm.xpm"
86 #include "../../art/delbookm.xpm"
87 #include "../../art/back.xpm"
88 #include "../../art/forward.xpm"
89 #include "../../art/up.xpm"
90 #include "../../art/down.xpm"
91 #include "../../art/toparent.xpm"
92 #include "../../art/fileopen.xpm"
93 #include "../../art/print.xpm"
94 #include "../../art/helpicon.xpm"
95 #include "../../art/tipicon.xpm"
96 #include "../../art/home.xpm"
97 #include "../../art/first.xpm"
98 #include "../../art/last.xpm"
99 #include "../../art/repview.xpm"
100 #include "../../art/listview.xpm"
101 #include "../../art/new_dir.xpm"
102 #include "../../art/harddisk.xpm"
103 #include "../../art/cdrom.xpm"
104 #include "../../art/floppy.xpm"
105 #include "../../art/removable.xpm"
106 #include "../../art/folder.xpm"
107 #include "../../art/folder_open.xpm"
108 #include "../../art/dir_up.xpm"
109 #include "../../art/exefile.xpm"
110 #include "../../art/deffile.xpm"
111 #include "../../art/tick.xpm"
112 #include "../../art/cross.xpm"
114 #include "../../art/filesave.xpm"
115 #include "../../art/filesaveas.xpm"
116 #include "../../art/copy.xpm"
117 #include "../../art/cut.xpm"
118 #include "../../art/paste.xpm"
119 #include "../../art/delete.xpm"
120 #include "../../art/new.xpm"
121 #include "../../art/undo.xpm"
122 #include "../../art/redo.xpm"
123 #include "../../art/plus.xpm"
124 #include "../../art/minus.xpm"
125 #include "../../art/close.xpm"
126 #include "../../art/quit.xpm"
127 #include "../../art/find.xpm"
128 #include "../../art/findrepl.xpm"
130 wxBitmap
wxDefaultArtProvider_CreateBitmap(const wxArtID
& id
)
132 #if !defined(__WXUNIVERSAL__) && (defined(__WXGTK__) || defined(__WXMOTIF__))
133 // wxMessageBox icons:
134 ART(wxART_ERROR
, error
)
135 ART(wxART_INFORMATION
, info
)
136 ART(wxART_WARNING
, warning
)
137 ART(wxART_QUESTION
, question
)
142 ART(wxART_HELP_SIDE_PANEL
, htmsidep
)
143 ART(wxART_HELP_SETTINGS
, htmoptns
)
144 ART(wxART_HELP_BOOK
, htmbook
)
145 ART(wxART_HELP_FOLDER
, htmfoldr
)
146 ART(wxART_HELP_PAGE
, htmpage
)
148 ART(wxART_MISSING_IMAGE
, missimg
)
149 ART(wxART_ADD_BOOKMARK
, addbookm
)
150 ART(wxART_DEL_BOOKMARK
, delbookm
)
151 ART(wxART_GO_BACK
, back
)
152 ART(wxART_GO_FORWARD
, forward
)
154 ART(wxART_GO_DOWN
, down
)
155 ART(wxART_GO_TO_PARENT
, toparent
)
156 ART(wxART_GO_HOME
, home
)
157 ART(wxART_GOTO_FIRST
, first
)
158 ART(wxART_GOTO_LAST
, last
)
159 ART(wxART_FILE_OPEN
, fileopen
)
160 ART(wxART_PRINT
, print
)
161 ART(wxART_HELP
, helpicon
)
162 ART(wxART_TIP
, tipicon
)
163 ART(wxART_REPORT_VIEW
, repview
)
164 ART(wxART_LIST_VIEW
, listview
)
165 ART(wxART_NEW_DIR
, new_dir
)
166 ART(wxART_HARDDISK
, harddisk
)
167 ART(wxART_FLOPPY
, floppy
)
168 ART(wxART_CDROM
, cdrom
)
169 ART(wxART_REMOVABLE
, removable
)
170 ART(wxART_FOLDER
, folder
)
171 ART(wxART_FOLDER_OPEN
, folder_open
)
172 ART(wxART_GO_DIR_UP
, dir_up
)
173 ART(wxART_EXECUTABLE_FILE
, exefile
)
174 ART(wxART_NORMAL_FILE
, deffile
)
175 ART(wxART_TICK_MARK
, tick
)
176 ART(wxART_CROSS_MARK
, cross
)
178 ART(wxART_FILE_SAVE
, filesave
)
179 ART(wxART_FILE_SAVE_AS
, filesaveas
)
180 ART(wxART_COPY
, copy
)
182 ART(wxART_PASTE
, paste
)
183 ART(wxART_DELETE
, delete)
184 ART(wxART_UNDO
, undo
)
185 ART(wxART_REDO
, redo
)
186 ART(wxART_PLUS
, plus
)
187 ART(wxART_MINUS
, minus
)
188 ART(wxART_CLOSE
, close
)
189 ART(wxART_QUIT
, quit
)
190 ART(wxART_FIND
, find
)
191 ART(wxART_FIND_AND_REPLACE
, findrepl
)
198 // ----------------------------------------------------------------------------
199 // CreateBitmap routine
200 // ----------------------------------------------------------------------------
202 wxBitmap
wxDefaultArtProvider::CreateBitmap(const wxArtID
& id
,
203 const wxArtClient
& client
,
204 const wxSize
& reqSize
)
206 wxBitmap bmp
= wxDefaultArtProvider_CreateBitmap(id
);
208 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
211 // fit into transparent image with desired size hint from the client
212 if (reqSize
== wxDefaultSize
)
214 // find out if there is a desired size for this client
215 wxSize bestSize
= GetSizeHint(client
);
216 if (bestSize
!= wxDefaultSize
)
218 int bmp_w
= bmp
.GetWidth();
219 int bmp_h
= bmp
.GetHeight();
221 if (bmp_w
== 16 && bmp_h
== 15 && bestSize
== wxSize(16, 16))
223 // Do nothing in this special but quite common case, because scaling
224 // with only a pixel difference will look horrible.
226 else if ((bmp_h
< bestSize
.x
) && (bmp_w
< bestSize
.y
))
228 // the caller wants default size, which is larger than
229 // the image we have; to avoid degrading it visually by
230 // scaling it up, paste it into transparent image instead:
231 wxPoint
offset((bestSize
.x
- bmp_w
)/2, (bestSize
.y
- bmp_h
)/2);
232 wxImage img
= bmp
.ConvertToImage();
233 img
.Resize(bestSize
, offset
);
236 else // scale (down or mixed, but not up)
238 wxImage img
= bmp
.ConvertToImage();
241 img
.Scale(bestSize
.x
, bestSize
.y
,
242 wxIMAGE_QUALITY_HIGH
)
250 wxUnusedVar(reqSize
);
251 #endif // wxUSE_IMAGE
256 #endif // wxUSE_ARTPROVIDER_STD