]>
Commit | Line | Data |
---|---|---|
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 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
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 | #if defined(__WXMGL__) || defined(__WXMAC__) || defined(__WXGTK__) \ | |
23 | || defined(__WXMOTIF__) || defined(__WXX11__) | |
24 | ||
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 | { | |
63 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
64 | while ( node ) | |
65 | { | |
66 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
67 | if ( handler->GetName() == name ) | |
68 | return handler; | |
69 | node = node->GetNext(); | |
70 | } | |
71 | return NULL; | |
72 | } | |
73 | ||
74 | wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType) | |
75 | { | |
76 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
77 | while ( node ) | |
78 | { | |
79 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
80 | if ( handler->GetExtension() == extension && | |
81 | (bitmapType == -1 || handler->GetType() == bitmapType) ) | |
82 | return handler; | |
83 | node = node->GetNext(); | |
84 | } | |
85 | return NULL; | |
86 | } | |
87 | ||
88 | wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType) | |
89 | { | |
90 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
91 | while ( node ) | |
92 | { | |
93 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
94 | if (handler->GetType() == bitmapType) | |
95 | return handler; | |
96 | node = node->GetNext(); | |
97 | } | |
98 | return NULL; | |
99 | } | |
100 | ||
101 | void wxBitmapBase::CleanUpHandlers() | |
102 | { | |
103 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
104 | while ( node ) | |
105 | { | |
106 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
107 | wxList::compatibility_iterator next = node->GetNext(); | |
108 | delete handler; | |
109 | sm_handlers.Erase(node); | |
110 | node = next; | |
111 | } | |
112 | } | |
113 | ||
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) | |
124 | ||
125 | #endif // defined(__WXMGL__) || defined(__WXMAC__) || defined(__WXCOCOA__) || defined(__WXMOTIF__) || defined(__WXX11__) | |
126 |