]>
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__) || \ | |
23 | defined(__WXMAC__) || \ | |
24 | defined(__WXGTK__) || \ | |
25 | defined(__WXMOTIF__) || \ | |
26 | defined(__WXX11__) | |
27 | ||
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 | ||
37 | IMPLEMENT_ABSTRACT_CLASS(wxBitmapBase, wxGDIObject) | |
38 | IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandlerBase,wxObject) | |
39 | ||
40 | wxList wxBitmapBase::sm_handlers; | |
41 | ||
42 | void wxBitmapBase::AddHandler(wxBitmapHandlerBase *handler) | |
43 | { | |
44 | sm_handlers.Append(handler); | |
45 | } | |
46 | ||
47 | void wxBitmapBase::InsertHandler(wxBitmapHandlerBase *handler) | |
48 | { | |
49 | sm_handlers.Insert(handler); | |
50 | } | |
51 | ||
52 | bool wxBitmapBase::RemoveHandler(const wxString& name) | |
53 | { | |
54 | wxBitmapHandler *handler = FindHandler(name); | |
55 | if ( handler ) | |
56 | { | |
57 | sm_handlers.DeleteObject(handler); | |
58 | return true; | |
59 | } | |
60 | else | |
61 | return false; | |
62 | } | |
63 | ||
64 | wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& name) | |
65 | { | |
66 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
67 | while ( node ) | |
68 | { | |
69 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
70 | if ( handler->GetName() == name ) | |
71 | return handler; | |
72 | node = node->GetNext(); | |
73 | } | |
74 | return NULL; | |
75 | } | |
76 | ||
77 | wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType) | |
78 | { | |
79 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
80 | while ( node ) | |
81 | { | |
82 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
83 | if ( handler->GetExtension() == extension && | |
84 | (bitmapType == -1 || handler->GetType() == bitmapType) ) | |
85 | return handler; | |
86 | node = node->GetNext(); | |
87 | } | |
88 | return NULL; | |
89 | } | |
90 | ||
91 | wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType) | |
92 | { | |
93 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
94 | while ( node ) | |
95 | { | |
96 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
97 | if (handler->GetType() == bitmapType) | |
98 | return handler; | |
99 | node = node->GetNext(); | |
100 | } | |
101 | return NULL; | |
102 | } | |
103 | ||
104 | void wxBitmapBase::CleanUpHandlers() | |
105 | { | |
106 | wxList::compatibility_iterator node = sm_handlers.GetFirst(); | |
107 | while ( node ) | |
108 | { | |
109 | wxBitmapHandler *handler = (wxBitmapHandler *)node->GetData(); | |
110 | wxList::compatibility_iterator next = node->GetNext(); | |
111 | delete handler; | |
112 | sm_handlers.Erase(node); | |
113 | node = next; | |
114 | } | |
115 | } | |
116 | ||
117 | class wxBitmapBaseModule: public wxModule | |
118 | { | |
119 | DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule) | |
120 | public: | |
121 | wxBitmapBaseModule() {} | |
122 | bool OnInit() { wxBitmap::InitStandardHandlers(); return true; }; | |
123 | void OnExit() { wxBitmap::CleanUpHandlers(); }; | |
124 | }; | |
125 | ||
126 | IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule) | |
127 | ||
128 | #endif // __WXMGL__ || __WXMAC__ || __WXCOCOA__ || __WXMOTIF__ || __WXX11__ |