]> git.saurik.com Git - wxWidgets.git/blame_incremental - 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
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/bmpbase.cpp
3// Purpose: wxBitmapBase
4// Author: VaclavSlavik
5// Created: 2001/04/11
6// RCS-ID: $Id$
7// Copyright: (c) 2001, Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#if defined(__WXMGL__) || \
19 defined(__WXMAC__) || \
20 defined(__WXGTK__) || \
21 defined(__WXMOTIF__) || \
22 defined(__WXX11__)
23
24#include "wx/bitmap.h"
25
26#ifndef WX_PRECOMP
27 #include "wx/log.h"
28 #include "wx/utils.h"
29 #include "wx/palette.h"
30 #include "wx/icon.h"
31 #include "wx/image.h"
32#endif // WX_PRECOMP
33
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);
57 return true;
58 }
59 else
60 return false;
61}
62
63wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& name)
64{
65 wxList::compatibility_iterator node = sm_handlers.GetFirst();
66 while ( node )
67 {
68 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
69 if ( handler->GetName() == name )
70 return handler;
71 node = node->GetNext();
72 }
73 return NULL;
74}
75
76wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType)
77{
78 wxList::compatibility_iterator node = sm_handlers.GetFirst();
79 while ( node )
80 {
81 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
82 if ( handler->GetExtension() == extension &&
83 (bitmapType == wxBITMAP_TYPE_ANY || handler->GetType() == bitmapType) )
84 return handler;
85 node = node->GetNext();
86 }
87 return NULL;
88}
89
90wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType)
91{
92 wxList::compatibility_iterator node = sm_handlers.GetFirst();
93 while ( node )
94 {
95 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
96 if (handler->GetType() == bitmapType)
97 return handler;
98 node = node->GetNext();
99 }
100 return NULL;
101}
102
103void wxBitmapBase::CleanUpHandlers()
104{
105 wxList::compatibility_iterator node = sm_handlers.GetFirst();
106 while ( node )
107 {
108 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
109 wxList::compatibility_iterator next = node->GetNext();
110 delete handler;
111 sm_handlers.Erase(node);
112 node = next;
113 }
114}
115
116class wxBitmapBaseModule: public wxModule
117{
118DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule)
119public:
120 wxBitmapBaseModule() {}
121 bool OnInit() { wxBitmap::InitStandardHandlers(); return true; };
122 void OnExit() { wxBitmap::CleanUpHandlers(); };
123};
124
125IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)
126
127#endif // __WXMGL__ || __WXMAC__ || __WXCOCOA__ || __WXMOTIF__ || __WXX11__