]> git.saurik.com Git - wxWidgets.git/blame - src/common/bmpbase.cpp
i18n files are installed as part of wxBase (and should be ideally part of separate...
[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
WS
18#if defined(__WXMGL__) || \
19 defined(__WXMAC__) || \
20 defined(__WXGTK__) || \
21 defined(__WXMOTIF__) || \
22 defined(__WXX11__)
ee058011 23
e4db172a
WS
24#include "wx/bitmap.h"
25
26#ifndef WX_PRECOMP
27 #include "wx/log.h"
de6185e2 28 #include "wx/utils.h"
559a723c 29 #include "wx/palette.h"
923d28da 30 #include "wx/icon.h"
155ecd4c 31 #include "wx/image.h"
e4db172a
WS
32#endif // WX_PRECOMP
33
a04eec87
VS
34#include "wx/module.h"
35
36IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject)
37IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject)
38
39wxList wxBitmapBase::sm_handlers;
40
41void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler)
42{
43 sm_handlers.Append(handler);
44}
45
46void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler)
47{
48 sm_handlers.Insert(handler);
49}
50
51bool wxBitmapBase::RemoveHandler(const wxString& name)
52{
53 wxBitmapHandler *handler = FindHandler(name);
54 if ( handler )
55 {
56 sm_handlers.DeleteObject(handler);
c9d59ee7 57 return true;
a04eec87
VS
58 }
59 else
c9d59ee7 60 return false;
a04eec87
VS
61}
62
63wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& name)
64{
ac32ba44 65 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
66 while ( node )
67 {
1bc822df 68 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87
VS
69 if ( handler->GetName() == name )
70 return handler;
1bc822df 71 node = node->GetNext();
a04eec87
VS
72 }
73 return NULL;
74}
75
76wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType)
77{
ac32ba44 78 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
79 while ( node )
80 {
1bc822df 81 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87 82 if ( handler->GetExtension() == extension &&
4b232264 83 (bitmapType == wxBITMAP_TYPE_ANY || handler->GetType() == bitmapType) )
a04eec87 84 return handler;
1bc822df 85 node = node->GetNext();
a04eec87
VS
86 }
87 return NULL;
88}
89
90wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType)
91{
ac32ba44 92 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
93 while ( node )
94 {
1bc822df 95 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87
VS
96 if (handler->GetType() == bitmapType)
97 return handler;
1bc822df 98 node = node->GetNext();
a04eec87
VS
99 }
100 return NULL;
101}
102
103void wxBitmapBase::CleanUpHandlers()
104{
ac32ba44 105 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
106 while ( node )
107 {
1bc822df 108 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
ac32ba44 109 wxList::compatibility_iterator next = node->GetNext();
a04eec87 110 delete handler;
ac32ba44 111 sm_handlers.Erase(node);
a04eec87
VS
112 node = next;
113 }
114}
115
a04eec87
VS
116class wxBitmapBaseModule: public wxModule
117{
118DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule)
119public:
120 wxBitmapBaseModule() {}
c9d59ee7 121 bool OnInit() { wxBitmap::InitStandardHandlers(); return true; };
a04eec87
VS
122 void OnExit() { wxBitmap::CleanUpHandlers(); };
123};
124
125IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)
ee058011 126
7220e455 127#endif // __WXMGL__ || __WXMAC__ || __WXCOCOA__ || __WXMOTIF__ || __WXX11__