1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmapBase
4 // Author: VaclavSlavik
7 // Copyright: (c) 2001, Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
12 #pragma implementation "bitmapbase.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #if defined(__WXMGL__) || defined(__WXMAC__) \
23 || defined(__WXMOTIF__) || defined(__WXX11__)
27 #include "wx/palette.h"
28 #include "wx/bitmap.h"
32 #include "wx/module.h"
34 IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase
, wxGDIObject
)
35 IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase
,wxObject
)
37 wxList
wxBitmapBase::sm_handlers
;
39 void wxBitmapBase::AddHandler(wxBitmapHandlerBase
*handler
)
41 sm_handlers
.Append(handler
);
44 void wxBitmapBase::InsertHandler(wxBitmapHandlerBase
*handler
)
46 sm_handlers
.Insert(handler
);
49 bool wxBitmapBase::RemoveHandler(const wxString
& name
)
51 wxBitmapHandler
*handler
= FindHandler(name
);
54 sm_handlers
.DeleteObject(handler
);
61 wxBitmapHandler
*wxBitmapBase::FindHandler(const wxString
& name
)
63 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
66 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
67 if ( handler
->GetName() == name
)
69 node
= node
->GetNext();
74 wxBitmapHandler
*wxBitmapBase::FindHandler(const wxString
& extension
, wxBitmapType bitmapType
)
76 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
79 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
80 if ( handler
->GetExtension() == extension
&&
81 (bitmapType
== -1 || handler
->GetType() == bitmapType
) )
83 node
= node
->GetNext();
88 wxBitmapHandler
*wxBitmapBase::FindHandler(wxBitmapType bitmapType
)
90 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
93 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
94 if (handler
->GetType() == bitmapType
)
96 node
= node
->GetNext();
101 void wxBitmapBase::CleanUpHandlers()
103 wxList::compatibility_iterator node
= sm_handlers
.GetFirst();
106 wxBitmapHandler
*handler
= (wxBitmapHandler
*)node
->GetData();
107 wxList::compatibility_iterator next
= node
->GetNext();
109 sm_handlers
.Erase(node
);
114 class wxBitmapBaseModule
: public wxModule
116 DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule
)
118 wxBitmapBaseModule() {}
119 bool OnInit() { wxBitmap::InitStandardHandlers(); return true; };
120 void OnExit() { wxBitmap::CleanUpHandlers(); };
123 IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule
, wxModule
)
125 #endif // defined(__WXMGL__) || defined(__WXMAC__) || defined(__WXCOCOA__) || defined(__WXMOTIF__) || defined(__WXX11__)