]> git.saurik.com Git - wxWidgets.git/blame - src/common/bmpbase.cpp
return false from OnInit() in console build if we failed
[wxWidgets.git] / src / common / bmpbase.cpp
CommitLineData
a04eec87 1/////////////////////////////////////////////////////////////////////////////
f03e8f9b 2// Name: src/common/bmpbase.cpp
a04eec87
VS
3// Purpose: wxBitmapBase
4// Author: VaclavSlavik
5// Created: 2001/04/11
6// RCS-ID: $Id$
7// Copyright: (c) 2001, Vaclav Slavik
65571936 8// Licence: wxWindows licence
a04eec87
VS
9/////////////////////////////////////////////////////////////////////////////
10
9d4ca3aa
VS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
7220e455 18#if defined(__WXMGL__) || \
b3c86150 19 defined(__WXDFB__) || \
7220e455
WS
20 defined(__WXMAC__) || \
21 defined(__WXGTK__) || \
22 defined(__WXMOTIF__) || \
23 defined(__WXX11__)
ee058011 24
e4db172a
WS
25#include "wx/bitmap.h"
26
27#ifndef WX_PRECOMP
28 #include "wx/log.h"
de6185e2 29 #include "wx/utils.h"
559a723c 30 #include "wx/palette.h"
923d28da 31 #include "wx/icon.h"
155ecd4c 32 #include "wx/image.h"
e4db172a
WS
33#endif // WX_PRECOMP
34
a04eec87
VS
35#include "wx/module.h"
36
37IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject)
38IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject)
39
40wxList wxBitmapBase::sm_handlers;
41
42void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler)
43{
44 sm_handlers.Append(handler);
45}
46
47void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler)
48{
49 sm_handlers.Insert(handler);
50}
51
52bool wxBitmapBase::RemoveHandler(const wxString& name)
53{
54 wxBitmapHandler *handler = FindHandler(name);
55 if ( handler )
56 {
57 sm_handlers.DeleteObject(handler);
c9d59ee7 58 return true;
a04eec87
VS
59 }
60 else
c9d59ee7 61 return false;
a04eec87
VS
62}
63
64wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& name)
65{
ac32ba44 66 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
67 while ( node )
68 {
1bc822df 69 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87
VS
70 if ( handler->GetName() == name )
71 return handler;
1bc822df 72 node = node->GetNext();
a04eec87
VS
73 }
74 return NULL;
75}
76
77wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType)
78{
ac32ba44 79 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
80 while ( node )
81 {
1bc822df 82 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87 83 if ( handler->GetExtension() == extension &&
4b232264 84 (bitmapType == wxBITMAP_TYPE_ANY || handler->GetType() == bitmapType) )
a04eec87 85 return handler;
1bc822df 86 node = node->GetNext();
a04eec87
VS
87 }
88 return NULL;
89}
90
91wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType)
92{
ac32ba44 93 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
94 while ( node )
95 {
1bc822df 96 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87
VS
97 if (handler->GetType() == bitmapType)
98 return handler;
1bc822df 99 node = node->GetNext();
a04eec87
VS
100 }
101 return NULL;
102}
103
104void wxBitmapBase::CleanUpHandlers()
105{
ac32ba44 106 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
107 while ( node )
108 {
1bc822df 109 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
ac32ba44 110 wxList::compatibility_iterator next = node->GetNext();
a04eec87 111 delete handler;
ac32ba44 112 sm_handlers.Erase(node);
a04eec87
VS
113 node = next;
114 }
115}
116
a04eec87
VS
117class wxBitmapBaseModule: public wxModule
118{
119DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule)
120public:
121 wxBitmapBaseModule() {}
c9d59ee7 122 bool OnInit() { wxBitmap::InitStandardHandlers(); return true; };
a04eec87
VS
123 void OnExit() { wxBitmap::CleanUpHandlers(); };
124};
125
126IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)
ee058011 127
7220e455 128#endif // __WXMGL__ || __WXMAC__ || __WXCOCOA__ || __WXMOTIF__ || __WXX11__