]>
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__)
23 #if wxUSE_ARTPROVIDER_STD
29 #include "wx/artprov.h"
31 // ----------------------------------------------------------------------------
32 // wxDefaultArtProvider
33 // ----------------------------------------------------------------------------
35 class wxDefaultArtProvider
: public wxArtProvider
38 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
42 // ----------------------------------------------------------------------------
43 // wxArtProvider::InitStdProvider
44 // ----------------------------------------------------------------------------
46 /*static*/ void wxArtProvider::InitStdProvider()
48 wxArtProvider::PushBack(new wxDefaultArtProvider
);
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 // Standard macro for getting a resource from XPM file:
56 #define ART(artId, xpmRc) \
57 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
63 #ifndef __WXUNIVERSAL__
64 #if defined(__WXGTK__)
65 #include "../../art/gtk/info.xpm"
66 #include "../../art/gtk/error.xpm"
67 #include "../../art/gtk/warning.xpm"
68 #include "../../art/gtk/question.xpm"
69 #elif defined(__WXMOTIF__)
70 #include "../../art/motif/info.xpm"
71 #include "../../art/motif/error.xpm"
72 #include "../../art/motif/warning.xpm"
73 #include "../../art/motif/question.xpm"
75 #endif // !__WXUNIVERSAL__
78 #include "../../art/htmsidep.xpm"
79 #include "../../art/htmoptns.xpm"
80 #include "../../art/htmbook.xpm"
81 #include "../../art/htmfoldr.xpm"
82 #include "../../art/htmpage.xpm"
85 #include "../../art/missimg.xpm"
86 #include "../../art/addbookm.xpm"
87 #include "../../art/delbookm.xpm"
88 #include "../../art/back.xpm"
89 #include "../../art/forward.xpm"
90 #include "../../art/up.xpm"
91 #include "../../art/down.xpm"
92 #include "../../art/toparent.xpm"
93 #include "../../art/fileopen.xpm"
94 #include "../../art/print.xpm"
95 #include "../../art/helpicon.xpm"
96 #include "../../art/tipicon.xpm"
97 #include "../../art/home.xpm"
98 #include "../../art/first.xpm"
99 #include "../../art/last.xpm"
100 #include "../../art/repview.xpm"
101 #include "../../art/listview.xpm"
102 #include "../../art/new_dir.xpm"
103 #include "../../art/harddisk.xpm"
104 #include "../../art/cdrom.xpm"
105 #include "../../art/floppy.xpm"
106 #include "../../art/removable.xpm"
107 #include "../../art/folder.xpm"
108 #include "../../art/folder_open.xpm"
109 #include "../../art/dir_up.xpm"
110 #include "../../art/exefile.xpm"
111 #include "../../art/deffile.xpm"
112 #include "../../art/tick.xpm"
113 #include "../../art/cross.xpm"
115 #include "../../art/filesave.xpm"
116 #include "../../art/filesaveas.xpm"
117 #include "../../art/copy.xpm"
118 #include "../../art/cut.xpm"
119 #include "../../art/paste.xpm"
120 #include "../../art/delete.xpm"
121 #include "../../art/new.xpm"
122 #include "../../art/undo.xpm"
123 #include "../../art/redo.xpm"
124 #include "../../art/plus.xpm"
125 #include "../../art/minus.xpm"
126 #include "../../art/close.xpm"
127 #include "../../art/quit.xpm"
128 #include "../../art/find.xpm"
129 #include "../../art/findrepl.xpm"
131 wxBitmap
wxDefaultArtProvider_CreateBitmap(const wxArtID
& id
)
133 #if !defined(__WXUNIVERSAL__) && (defined(__WXGTK__) || defined(__WXMOTIF__))
134 // wxMessageBox icons:
135 ART(wxART_ERROR
, error
)
136 ART(wxART_INFORMATION
, info
)
137 ART(wxART_WARNING
, warning
)
138 ART(wxART_QUESTION
, question
)
143 ART(wxART_HELP_SIDE_PANEL
, htmsidep
)
144 ART(wxART_HELP_SETTINGS
, htmoptns
)
145 ART(wxART_HELP_BOOK
, htmbook
)
146 ART(wxART_HELP_FOLDER
, htmfoldr
)
147 ART(wxART_HELP_PAGE
, htmpage
)
149 ART(wxART_MISSING_IMAGE
, missimg
)
150 ART(wxART_ADD_BOOKMARK
, addbookm
)
151 ART(wxART_DEL_BOOKMARK
, delbookm
)
152 ART(wxART_GO_BACK
, back
)
153 ART(wxART_GO_FORWARD
, forward
)
155 ART(wxART_GO_DOWN
, down
)
156 ART(wxART_GO_TO_PARENT
, toparent
)
157 ART(wxART_GO_HOME
, home
)
158 ART(wxART_GOTO_FIRST
, first
)
159 ART(wxART_GOTO_LAST
, last
)
160 ART(wxART_FILE_OPEN
, fileopen
)
161 ART(wxART_PRINT
, print
)
162 ART(wxART_HELP
, helpicon
)
163 ART(wxART_TIP
, tipicon
)
164 ART(wxART_REPORT_VIEW
, repview
)
165 ART(wxART_LIST_VIEW
, listview
)
166 ART(wxART_NEW_DIR
, new_dir
)
167 ART(wxART_HARDDISK
, harddisk
)
168 ART(wxART_FLOPPY
, floppy
)
169 ART(wxART_CDROM
, cdrom
)
170 ART(wxART_REMOVABLE
, removable
)
171 ART(wxART_FOLDER
, folder
)
172 ART(wxART_FOLDER_OPEN
, folder_open
)
173 ART(wxART_GO_DIR_UP
, dir_up
)
174 ART(wxART_EXECUTABLE_FILE
, exefile
)
175 ART(wxART_NORMAL_FILE
, deffile
)
176 ART(wxART_TICK_MARK
, tick
)
177 ART(wxART_CROSS_MARK
, cross
)
179 ART(wxART_FILE_SAVE
, filesave
)
180 ART(wxART_FILE_SAVE_AS
, filesaveas
)
181 ART(wxART_COPY
, copy
)
183 ART(wxART_PASTE
, paste
)
184 ART(wxART_DELETE
, delete)
185 ART(wxART_UNDO
, undo
)
186 ART(wxART_REDO
, redo
)
187 ART(wxART_PLUS
, plus
)
188 ART(wxART_MINUS
, minus
)
189 ART(wxART_CLOSE
, close
)
190 ART(wxART_QUIT
, quit
)
191 ART(wxART_FIND
, find
)
192 ART(wxART_FIND_AND_REPLACE
, findrepl
)
199 // ----------------------------------------------------------------------------
200 // CreateBitmap routine
201 // ----------------------------------------------------------------------------
203 wxBitmap
wxDefaultArtProvider::CreateBitmap(const wxArtID
& id
,
204 const wxArtClient
& client
,
205 const wxSize
& reqSize
)
207 wxBitmap bmp
= wxDefaultArtProvider_CreateBitmap(id
);
209 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
212 // fit into transparent image with desired size hint from the client
213 if (reqSize
== wxDefaultSize
)
215 // find out if there is a desired size for this client
216 wxSize bestSize
= GetSizeHint(client
);
217 if (bestSize
!= wxDefaultSize
)
219 int bmp_w
= bmp
.GetWidth();
220 int bmp_h
= bmp
.GetHeight();
222 if ((bmp_h
< bestSize
.x
) && (bmp_w
< bestSize
.y
))
224 // the caller wants default size, which is larger than
225 // the image we have; to avoid degrading it visually by
226 // scaling it up, paste it into transparent image instead:
227 wxPoint
offset((bestSize
.x
- bmp_w
)/2, (bestSize
.y
- bmp_h
)/2);
228 wxImage img
= bmp
.ConvertToImage();
229 img
.Resize(bestSize
, offset
);
232 else // scale (down or mixed, but not up)
234 wxImage img
= bmp
.ConvertToImage();
237 img
.Scale(bestSize
.x
, bestSize
.y
,
238 wxIMAGE_QUALITY_HIGH
)
246 wxUnusedVar(reqSize
);
247 #endif // wxUSE_IMAGE
252 #endif // wxUSE_ARTPROVIDER_STD