1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/bmpbase.cpp
3 // Purpose: wxBitmapBase
4 // Author: VaclavSlavik
7 // Copyright: (c) 2001, Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if defined(__WXMGL__) || \
19 defined(__WXDFB__) || \
20 defined(__WXMAC__) || \
21 defined(__WXGTK__) || \
22 defined(__WXMOTIF__) || \
25 #include "wx/bitmap.h"
30 #include "wx/palette.h"
33 #include "wx/module.h"
36 IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase
, wxGDIObject
)
37 IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase
,wxObject
)
39 wxList
wxBitmapBase::sm_handlers
;
41 void wxBitmapBase::AddHandler(wxBitmapHandlerBase
*handler
)
43 sm_handlers
.Append(handler
);
46 void wxBitmapBase::InsertHandler(wxBitmapHandlerBase
*handler
)
48 sm_handlers
.Insert(handler
);
51 bool wxBitmapBase::RemoveHandler(const wxString
& name
)
53 wxBitmapHandler
*handler
= FindHandler(name
);
56 sm_handlers
.DeleteObject(handler
);
63 wxBitmapHandler
*wxBitmapBase::FindHandler(const wxString
& name
)
65 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
68 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
69 if ( handler
->GetName() == name
)
71 node
= node
->GetNext();
76 wxBitmapHandler
*wxBitmapBase::FindHandler(const wxString
& extension
, wxBitmapType bitmapType
)
78 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
81 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
82 if ( handler
->GetExtension() == extension
&&
83 (bitmapType
== wxBITMAP_TYPE_ANY
|| handler
->GetType() == bitmapType
) )
85 node
= node
->GetNext();
90 wxBitmapHandler
*wxBitmapBase::FindHandler(wxBitmapType bitmapType
)
92 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
95 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
96 if (handler
->GetType() == bitmapType
)
98 node
= node
->GetNext();
103 void wxBitmapBase::CleanUpHandlers()
105 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
108 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
109 wxList::compatibility_iterator next
= node
->GetNext();
111 sm_handlers
.Erase(node
);
116 class wxBitmapBaseModule
: public wxModule
118 DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule
)
120 wxBitmapBaseModule() {}
121 bool OnInit() { wxBitmap::InitStandardHandlers(); return true; };
122 void OnExit() { wxBitmap::CleanUpHandlers(); };
125 IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule
, wxModule
)
127 #endif // __WXMGL__ || __WXMAC__ || __WXCOCOA__ || __WXMOTIF__ || __WXX11__