]> git.saurik.com Git - wxWidgets.git/blob - src/common/artstd.cpp
finding papersizes allows for 1 mm tolerance
[wxWidgets.git] / src / common / artstd.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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$
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 #if WXWIN_COMPATIBILITY_2_2
25 #include "wx/app.h"
26 #endif
27 #endif
28
29 #include "wx/artprov.h"
30
31 // For the purposes of forcing this module to link
32 char g_ArtProviderModule = 0;
33
34 // ----------------------------------------------------------------------------
35 // wxDefaultArtProvider
36 // ----------------------------------------------------------------------------
37
38 class wxDefaultArtProvider : public wxArtProvider
39 {
40 protected:
41 virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
42 const wxSize& size);
43 };
44
45 // ----------------------------------------------------------------------------
46 // helper macros
47 // ----------------------------------------------------------------------------
48
49 // Standard macro for getting a resource from XPM file:
50 #define ART(artId, xpmRc) \
51 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
52
53 // Compatibility hack to use wxApp::GetStdIcon of overriden by the user
54 #if WXWIN_COMPATIBILITY_2_2
55 #define GET_STD_ICON_FROM_APP(iconId) \
56 if ( client == wxART_MESSAGE_BOX ) \
57 { \
58 wxIcon icon = wxTheApp->GetStdIcon(iconId); \
59 if ( icon.Ok() ) \
60 { \
61 wxBitmap bmp; \
62 bmp.CopyFromIcon(icon); \
63 return bmp; \
64 } \
65 }
66 #else
67 #define GET_STD_ICON_FROM_APP(iconId)
68 #endif
69
70 // There are two ways of getting the standard icon: either via XPMs or via
71 // wxIcon ctor. This depends on the platform:
72 #if defined(__WXUNIVERSAL__)
73 #define CREATE_STD_ICON(iconId, xpmRc) return wxNullBitmap;
74 #elif defined(__WXGTK__) || defined(__WXMOTIF__)
75 #define CREATE_STD_ICON(iconId, xpmRc) return wxBitmap(xpmRc##_xpm);
76 #else
77 #define CREATE_STD_ICON(iconId, xpmRc) \
78 { \
79 wxIcon icon(_T(iconId)); \
80 wxBitmap bmp; \
81 bmp.CopyFromIcon(icon); \
82 return bmp; \
83 }
84 #endif
85
86 // Macro used in CreateBitmap to get wxICON_FOO icons:
87 #define ART_MSGBOX(artId, iconId, xpmRc) \
88 if ( id == artId ) \
89 { \
90 GET_STD_ICON_FROM_APP(iconId) \
91 CREATE_STD_ICON(#iconId, xpmRc) \
92 }
93
94 // ----------------------------------------------------------------------------
95 // wxArtProvider::InitStdProvider
96 // ----------------------------------------------------------------------------
97
98 /*static*/ void wxArtProvider::InitStdProvider()
99 {
100 // NB: A few notes about this function:
101 // (1) it is in artstd.cpp and not in artprov.cpp on purpose. I wanted
102 // to avoid declaring wxDefaultArtProvider in any public header as
103 // it is only an implementation detail
104 // (2) other default art providers (e.g. GTK one) should NOT be added
105 // here. Instead, add them in port-specific initialialization code
106
107 wxArtProvider::PushProvider(new wxDefaultArtProvider);
108 }
109
110
111 // ----------------------------------------------------------------------------
112 // XPMs with the art
113 // ----------------------------------------------------------------------------
114
115 // XPM hack: make the arrays const
116 #define static static const
117
118 #if defined(__WXGTK__)
119 #include "../../art/gtk/info.xpm"
120 #include "../../art/gtk/error.xpm"
121 #include "../../art/gtk/warning.xpm"
122 #include "../../art/gtk/question.xpm"
123 #elif defined(__WXMOTIF__)
124 #include "../../art/motif/info.xpm"
125 #include "../../art/motif/error.xpm"
126 #include "../../art/motif/warning.xpm"
127 #include "../../art/motif/question.xpm"
128 #endif
129
130 #if wxUSE_HTML
131 #include "../../art/htmsidep.xpm"
132 #include "../../art/htmoptns.xpm"
133 #include "../../art/htmbook.xpm"
134 #include "../../art/htmfoldr.xpm"
135 #include "../../art/htmpage.xpm"
136 #include "../../art/missimg.xpm"
137 #endif // wxUSE_HTML
138
139 #include "../../art/addbookm.xpm"
140 #include "../../art/delbookm.xpm"
141 #include "../../art/back.xpm"
142 #include "../../art/forward.xpm"
143 #include "../../art/up.xpm"
144 #include "../../art/down.xpm"
145 #include "../../art/toparent.xpm"
146 #include "../../art/fileopen.xpm"
147 #include "../../art/print.xpm"
148 #include "../../art/helpicon.xpm"
149 #include "../../art/tipicon.xpm"
150 #include "../../art/home.xpm"
151 #include "../../art/repview.xpm"
152 #include "../../art/listview.xpm"
153 #include "../../art/new_dir.xpm"
154 #include "../../art/folder.xpm"
155 #include "../../art/dir_up.xpm"
156 #include "../../art/exefile.xpm"
157 #include "../../art/deffile.xpm"
158 #include "../../art/tick.xpm"
159 #include "../../art/cross.xpm"
160
161 #undef static
162
163 // ----------------------------------------------------------------------------
164 // CreateBitmap routine
165 // ----------------------------------------------------------------------------
166
167 wxBitmap wxDefaultArtProvider::CreateBitmap(const wxArtID& id,
168 const wxArtClient& client,
169 const wxSize& WXUNUSED(size))
170 {
171 // wxMessageBox icons:
172 ART_MSGBOX(wxART_ERROR, wxICON_ERROR, error)
173 ART_MSGBOX(wxART_INFORMATION, wxICON_INFORMATION, info)
174 ART_MSGBOX(wxART_WARNING, wxICON_WARNING, warning)
175 ART_MSGBOX(wxART_QUESTION, wxICON_QUESTION, question)
176
177 // standard icons:
178 #if wxUSE_HTML
179 ART(wxART_HELP_SIDE_PANEL, htmsidep)
180 ART(wxART_HELP_SETTINGS, htmoptns)
181 ART(wxART_HELP_BOOK, htmbook)
182 ART(wxART_HELP_FOLDER, htmfoldr)
183 ART(wxART_HELP_PAGE, htmpage)
184 ART(wxART_MISSING_IMAGE, missimg)
185 #endif // wxUSE_HTML
186 ART(wxART_ADD_BOOKMARK, addbookm)
187 ART(wxART_DEL_BOOKMARK, delbookm)
188 ART(wxART_GO_BACK, back)
189 ART(wxART_GO_FORWARD, forward)
190 ART(wxART_GO_UP, up)
191 ART(wxART_GO_DOWN, down)
192 ART(wxART_GO_TO_PARENT, toparent)
193 ART(wxART_GO_HOME, home)
194 ART(wxART_FILE_OPEN, fileopen)
195 ART(wxART_PRINT, print)
196 ART(wxART_HELP, helpicon)
197 ART(wxART_TIP, tipicon)
198 ART(wxART_REPORT_VIEW, repview)
199 ART(wxART_LIST_VIEW, listview)
200 ART(wxART_NEW_DIR, new_dir)
201 ART(wxART_FOLDER, folder)
202 ART(wxART_GO_DIR_UP, dir_up)
203 ART(wxART_EXECUTABLE_FILE, exefile)
204 ART(wxART_NORMAL_FILE, deffile)
205 ART(wxART_TICK_MARK, tick)
206 ART(wxART_CROSS_MARK, cross)
207
208 return wxNullBitmap;
209 }