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