]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | #ifdef __GNUG__ | |
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 | ||
34 | IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject) | |
35 | IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject) | |
36 | ||
37 | wxList wxBitmapBase::sm_handlers; | |
38 | ||
39 | void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler) | |
40 | { | |
41 | sm_handlers.Append(handler); | |
42 | } | |
43 | ||
44 | void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler) | |
45 | { | |
46 | sm_handlers.Insert(handler); | |
47 | } | |
48 | ||
49 | bool 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 | ||
61 | wxBitmapHandler *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 | ||
74 | wxBitmapHandler *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 | ||
88 | wxBitmapHandler *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 | ||
101 | void 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 |
114 | class wxBitmapBaseModule: public wxModule |
115 | { | |
116 | DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule) | |
117 | public: | |
118 | wxBitmapBaseModule() {} | |
119 | bool OnInit() { wxBitmap::InitStandardHandlers(); return TRUE; }; | |
120 | void OnExit() { wxBitmap::CleanUpHandlers(); }; | |
121 | }; | |
122 | ||
123 | IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule) | |
ee058011 | 124 | |
62ad3cb3 | 125 | #endif // defined(__WXMGL__) || defined(__WXMAC__) || defined(__WXCOCOA__) || defined(__WXMOTIF__) || defined(__WXX11__) |
ee058011 | 126 |