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