]> git.saurik.com Git - wxWidgets.git/blame - src/common/bmpbase.cpp
Remove all extensions before inport, not just .py
[wxWidgets.git] / src / common / bmpbase.cpp
CommitLineData
a04eec87
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: bitmap.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
14f355c2 11#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a04eec87
VS
12#pragma implementation "bitmapbase.h"
13#endif
14
9d4ca3aa
VS
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
d135b1a5 22#if defined(__WXMGL__) || defined(__WXMAC__) \
62ad3cb3 23 || defined(__WXMOTIF__) || defined(__WXX11__)
ee058011 24
a04eec87
VS
25#include "wx/setup.h"
26#include "wx/utils.h"
27#include "wx/palette.h"
28#include "wx/bitmap.h"
29#include "wx/icon.h"
30#include "wx/log.h"
31#include "wx/image.h"
32#include "wx/module.h"
33
34IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject)
35IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject)
36
37wxList wxBitmapBase::sm_handlers;
38
39void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler)
40{
41 sm_handlers.Append(handler);
42}
43
44void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler)
45{
46 sm_handlers.Insert(handler);
47}
48
49bool wxBitmapBase::RemoveHandler(const wxString& name)
50{
51 wxBitmapHandler *handler = FindHandler(name);
52 if ( handler )
53 {
54 sm_handlers.DeleteObject(handler);
55 return TRUE;
56 }
57 else
58 return FALSE;
59}
60
61wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& name)
62{
ac32ba44 63 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
64 while ( node )
65 {
1bc822df 66 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87
VS
67 if ( handler->GetName() == name )
68 return handler;
1bc822df 69 node = node->GetNext();
a04eec87
VS
70 }
71 return NULL;
72}
73
74wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType)
75{
ac32ba44 76 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
77 while ( node )
78 {
1bc822df 79 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87
VS
80 if ( handler->GetExtension() == extension &&
81 (bitmapType == -1 || handler->GetType() == bitmapType) )
82 return handler;
1bc822df 83 node = node->GetNext();
a04eec87
VS
84 }
85 return NULL;
86}
87
88wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType)
89{
ac32ba44 90 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
91 while ( node )
92 {
1bc822df 93 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
a04eec87
VS
94 if (handler->GetType() == bitmapType)
95 return handler;
1bc822df 96 node = node->GetNext();
a04eec87
VS
97 }
98 return NULL;
99}
100
101void wxBitmapBase::CleanUpHandlers()
102{
ac32ba44 103 wxList::compatibility_iterator node = sm_handlers.GetFirst();
a04eec87
VS
104 while ( node )
105 {
1bc822df 106 wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData();
ac32ba44 107 wxList::compatibility_iterator next = node->GetNext();
a04eec87 108 delete handler;
ac32ba44 109 sm_handlers.Erase(node);
a04eec87
VS
110 node = next;
111 }
112}
113
a04eec87
VS
114class wxBitmapBaseModule: public wxModule
115{
116DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule)
117public:
118 wxBitmapBaseModule() {}
119 bool OnInit() { wxBitmap::InitStandardHandlers(); return TRUE; };
120 void OnExit() { wxBitmap::CleanUpHandlers(); };
121};
122
123IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)
ee058011 124
62ad3cb3 125#endif // defined(__WXMGL__) || defined(__WXMAC__) || defined(__WXCOCOA__) || defined(__WXMOTIF__) || defined(__WXX11__)
ee058011 126