]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/bmpbase.cpp
iconv-based conversion works again, after being broken for a while
[wxWidgets.git] / src / common / bmpbase.cpp
... / ...
CommitLineData
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
11#ifdef __GNUG__
12#pragma implementation "bitmapbase.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
22#include "wx/wx.h"
23#include "wx/setup.h"
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
32IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject)
33IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject)
34
35wxList wxBitmapBase::sm_handlers;
36
37void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler)
38{
39 sm_handlers.Append(handler);
40}
41
42void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler)
43{
44 sm_handlers.Insert(handler);
45}
46
47bool 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
59wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& name)
60{
61 wxNode *node = sm_handlers.First();
62 while ( node )
63 {
64 wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
65 if ( handler->GetName() == name )
66 return handler;
67 node = node->Next();
68 }
69 return NULL;
70}
71
72wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType)
73{
74 wxNode *node = sm_handlers.First();
75 while ( node )
76 {
77 wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
78 if ( handler->GetExtension() == extension &&
79 (bitmapType == -1 || handler->GetType() == bitmapType) )
80 return handler;
81 node = node->Next();
82 }
83 return NULL;
84}
85
86wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType)
87{
88 wxNode *node = sm_handlers.First();
89 while ( node )
90 {
91 wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
92 if (handler->GetType() == bitmapType)
93 return handler;
94 node = node->Next();
95 }
96 return NULL;
97}
98
99void wxBitmapBase::CleanUpHandlers()
100{
101 wxNode *node = sm_handlers.First();
102 while ( node )
103 {
104 wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
105 wxNode *next = node->Next();
106 delete handler;
107 delete node;
108 node = next;
109 }
110}
111
112class wxBitmapBaseModule: public wxModule
113{
114DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule)
115public:
116 wxBitmapBaseModule() {}
117 bool OnInit() { wxBitmap::InitStandardHandlers(); return TRUE; };
118 void OnExit() { wxBitmap::CleanUpHandlers(); };
119};
120
121IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)