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