]> git.saurik.com Git - wxWidgets.git/blob - src/common/bmpbase.cpp
Replace deprecated wxNB_* flags with wxBK_* used in last commit.
[wxWidgets.git] / src / common / bmpbase.cpp
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/utils.h"
25 #include "wx/palette.h"
26 #include "wx/bitmap.h"
27 #include "wx/icon.h"
28 #include "wx/log.h"
29 #include "wx/image.h"
30 #include "wx/module.h"
31
32 IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject)
33 IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject)
34
35 wxList wxBitmapBase::sm_handlers;
36
37 void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler)
38 {
39 sm_handlers.Append(handler);
40 }
41
42 void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler)
43 {
44 sm_handlers.Insert(handler);
45 }
46
47 bool wxBitmapBase::RemoveHandler(const wxString& name)
48 {
49 wxBitmapHandler *handler = FindHandler(name);
50 if ( handler )
51 {
52 sm_handlers.DeleteObject(handler);
53 return true;
54 }
55 else
56 return false;
57 }
58
59 wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& name)
60 {
61 wxList::compatibility_iterator node = sm_handlers.GetFirst();
62 while ( node )
63 {
64 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
65 if ( handler->GetName() == name )
66 return handler;
67 node = node->GetNext();
68 }
69 return NULL;
70 }
71
72 wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType)
73 {
74 wxList::compatibility_iterator node = sm_handlers.GetFirst();
75 while ( node )
76 {
77 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
78 if ( handler->GetExtension() == extension &&
79 (bitmapType == wxBITMAP_TYPE_ANY || handler->GetType() == bitmapType) )
80 return handler;
81 node = node->GetNext();
82 }
83 return NULL;
84 }
85
86 wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType)
87 {
88 wxList::compatibility_iterator node = sm_handlers.GetFirst();
89 while ( node )
90 {
91 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
92 if (handler->GetType() == bitmapType)
93 return handler;
94 node = node->GetNext();
95 }
96 return NULL;
97 }
98
99 void wxBitmapBase::CleanUpHandlers()
100 {
101 wxList::compatibility_iterator node = sm_handlers.GetFirst();
102 while ( node )
103 {
104 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
105 wxList::compatibility_iterator next = node->GetNext();
106 delete handler;
107 sm_handlers.Erase(node);
108 node = next;
109 }
110 }
111
112 class wxBitmapBaseModule: public wxModule
113 {
114 DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule)
115 public:
116 wxBitmapBaseModule() {}
117 bool OnInit() { wxBitmap::InitStandardHandlers(); return true; };
118 void OnExit() { wxBitmap::CleanUpHandlers(); };
119 };
120
121 IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)
122
123 #endif // __WXMGL__ || __WXMAC__ || __WXCOCOA__ || __WXMOTIF__ || __WXX11__