]>
git.saurik.com Git - wxWidgets.git/blob - src/common/artstd.cpp
1 /////////////////////////////////////////////////////////////////////////////
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__)
24 #if WXWIN_COMPATIBILITY_2_2
29 #include "wx/artprov.h"
32 // ----------------------------------------------------------------------------
33 // wxDefaultArtProvider
34 // ----------------------------------------------------------------------------
36 class wxDefaultArtProvider
: public wxArtProvider
39 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 // Standard macro for getting a resource from XPM file:
48 #define ART(artId, xpmRc) \
49 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
51 // There are two ways of getting the standard icon: either via XPMs or via
52 // wxIcon ctor. This depends on the platform:
53 #if defined(__WXUNIVERSAL__)
54 #define CREATE_STD_ICON(iconId, xpmRc) return wxNullBitmap;
55 #elif defined(__WXGTK__) || defined(__WXMOTIF__)
56 #define CREATE_STD_ICON(iconId, xpmRc) return wxBitmap(xpmRc##_xpm);
58 #define CREATE_STD_ICON(iconId, xpmRc) \
60 wxIcon icon(_T(iconId)); \
62 bmp.CopyFromIcon(icon); \
67 // Macro used in CreateBitmap to get wxICON_FOO icons:
68 #define ART_MSGBOX(artId, iconId, xpmRc) \
71 CREATE_STD_ICON(#iconId, xpmRc) \
74 // ----------------------------------------------------------------------------
75 // wxArtProvider::InitStdProvider
76 // ----------------------------------------------------------------------------
78 /*static*/ void wxArtProvider::InitStdProvider()
80 wxArtProvider::PushProvider(new wxDefaultArtProvider
);
83 #if !defined(__WXGTK20__) || defined(__WXUNIVERSAL__)
84 /*static*/ void wxArtProvider::InitNativeProvider()
90 // ----------------------------------------------------------------------------
92 // ----------------------------------------------------------------------------
94 // XPM hack: make the arrays const
95 #define static static const
97 #if defined(__WXGTK__)
98 #include "../../art/gtk/info.xpm"
99 #include "../../art/gtk/error.xpm"
100 #include "../../art/gtk/warning.xpm"
101 #include "../../art/gtk/question.xpm"
102 #elif defined(__WXMOTIF__)
103 #include "../../art/motif/info.xpm"
104 #include "../../art/motif/error.xpm"
105 #include "../../art/motif/warning.xpm"
106 #include "../../art/motif/question.xpm"
110 #include "../../art/htmsidep.xpm"
111 #include "../../art/htmoptns.xpm"
112 #include "../../art/htmbook.xpm"
113 #include "../../art/htmfoldr.xpm"
114 #include "../../art/htmpage.xpm"
117 #include "../../art/missimg.xpm"
118 #include "../../art/addbookm.xpm"
119 #include "../../art/delbookm.xpm"
120 #include "../../art/back.xpm"
121 #include "../../art/forward.xpm"
122 #include "../../art/up.xpm"
123 #include "../../art/down.xpm"
124 #include "../../art/toparent.xpm"
125 #include "../../art/fileopen.xpm"
126 #include "../../art/print.xpm"
127 #include "../../art/helpicon.xpm"
128 #include "../../art/tipicon.xpm"
129 #include "../../art/home.xpm"
130 #include "../../art/repview.xpm"
131 #include "../../art/listview.xpm"
132 #include "../../art/new_dir.xpm"
133 #include "../../art/harddisk.xpm"
134 #include "../../art/cdrom.xpm"
135 #include "../../art/floppy.xpm"
136 #include "../../art/removable.xpm"
137 #include "../../art/folder.xpm"
138 #include "../../art/folder_open.xpm"
139 #include "../../art/dir_up.xpm"
140 #include "../../art/exefile.xpm"
141 #include "../../art/deffile.xpm"
142 #include "../../art/tick.xpm"
143 #include "../../art/cross.xpm"
145 #include "../../art/filesave.xpm"
146 #include "../../art/filesaveas.xpm"
147 #include "../../art/copy.xpm"
148 #include "../../art/cut.xpm"
149 #include "../../art/paste.xpm"
150 #include "../../art/delete.xpm"
151 #include "../../art/new.xpm"
152 #include "../../art/undo.xpm"
153 #include "../../art/redo.xpm"
154 #include "../../art/quit.xpm"
155 #include "../../art/find.xpm"
156 #include "../../art/findrepl.xpm"
161 wxBitmap
wxDefaultArtProvider_CreateBitmap(const wxArtID
& id
)
163 // wxMessageBox icons:
164 ART_MSGBOX(wxART_ERROR
, wxICON_ERROR
, error
)
165 ART_MSGBOX(wxART_INFORMATION
, wxICON_INFORMATION
, info
)
166 ART_MSGBOX(wxART_WARNING
, wxICON_WARNING
, warning
)
167 ART_MSGBOX(wxART_QUESTION
, wxICON_QUESTION
, question
)
171 ART(wxART_HELP_SIDE_PANEL
, htmsidep
)
172 ART(wxART_HELP_SETTINGS
, htmoptns
)
173 ART(wxART_HELP_BOOK
, htmbook
)
174 ART(wxART_HELP_FOLDER
, htmfoldr
)
175 ART(wxART_HELP_PAGE
, htmpage
)
177 ART(wxART_MISSING_IMAGE
, missimg
)
178 ART(wxART_ADD_BOOKMARK
, addbookm
)
179 ART(wxART_DEL_BOOKMARK
, delbookm
)
180 ART(wxART_GO_BACK
, back
)
181 ART(wxART_GO_FORWARD
, forward
)
183 ART(wxART_GO_DOWN
, down
)
184 ART(wxART_GO_TO_PARENT
, toparent
)
185 ART(wxART_GO_HOME
, home
)
186 ART(wxART_FILE_OPEN
, fileopen
)
187 ART(wxART_PRINT
, print
)
188 ART(wxART_HELP
, helpicon
)
189 ART(wxART_TIP
, tipicon
)
190 ART(wxART_REPORT_VIEW
, repview
)
191 ART(wxART_LIST_VIEW
, listview
)
192 ART(wxART_NEW_DIR
, new_dir
)
193 ART(wxART_HARDDISK
, harddisk
)
194 ART(wxART_FLOPPY
, floppy
)
195 ART(wxART_CDROM
, cdrom
)
196 ART(wxART_REMOVABLE
, removable
)
197 ART(wxART_FOLDER
, folder
)
198 ART(wxART_FOLDER_OPEN
, folder_open
)
199 ART(wxART_GO_DIR_UP
, dir_up
)
200 ART(wxART_EXECUTABLE_FILE
, exefile
)
201 ART(wxART_NORMAL_FILE
, deffile
)
202 ART(wxART_TICK_MARK
, tick
)
203 ART(wxART_CROSS_MARK
, cross
)
205 ART(wxART_FILE_SAVE
, filesave
)
206 ART(wxART_FILE_SAVE_AS
, filesaveas
)
207 ART(wxART_COPY
, copy
)
209 ART(wxART_PASTE
, paste
)
210 ART(wxART_DELETE
, delete)
211 ART(wxART_UNDO
, undo
)
212 ART(wxART_REDO
, redo
)
213 ART(wxART_QUIT
, quit
)
214 ART(wxART_FIND
, find
)
215 ART(wxART_FIND_AND_REPLACE
, findrepl
)
222 // ----------------------------------------------------------------------------
223 // CreateBitmap routine
224 // ----------------------------------------------------------------------------
226 wxBitmap
wxDefaultArtProvider::CreateBitmap(const wxArtID
& id
,
227 const wxArtClient
& client
,
228 const wxSize
& reqSize
)
230 wxBitmap bmp
= wxDefaultArtProvider_CreateBitmap(id
);
235 // fit into transparent image with desired size hint from the client
236 if (reqSize
== wxDefaultSize
)
238 // find out if there is a desired size for this client
239 wxSize bestSize
= GetSizeHint(client
);
240 if (bestSize
!= wxDefaultSize
)
242 int bmp_w
= bmp
.GetWidth();
243 int bmp_h
= bmp
.GetHeight();
244 // want default size but it's smaller, paste into transparent image
245 if ((bmp_h
< bestSize
.x
) && (bmp_w
< bestSize
.y
))
247 wxPoint
offset((bestSize
.x
- bmp_w
)/2, (bestSize
.y
- bmp_h
)/2);
248 wxImage img
= bmp
.ConvertToImage();
249 img
.Resize(bestSize
, offset
);
257 wxUnusedVar(reqSize
);
258 #endif // wxUSE_IMAGE