]>
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 | #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 | #if defined(__WXMGL__) || defined(__WXMAC__) | |
23 | ||
24 | #include "wx/wx.h" | |
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 | wxNode *node = sm_handlers.First(); | |
64 | while ( node ) | |
65 | { | |
66 | wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); | |
67 | if ( handler->GetName() == name ) | |
68 | return handler; | |
69 | node = node->Next(); | |
70 | } | |
71 | return NULL; | |
72 | } | |
73 | ||
74 | wxBitmapHandler *wxBitmapBase::FindHandler(const wxString& extension, wxBitmapType bitmapType) | |
75 | { | |
76 | wxNode *node = sm_handlers.First(); | |
77 | while ( node ) | |
78 | { | |
79 | wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); | |
80 | if ( handler->GetExtension() == extension && | |
81 | (bitmapType == -1 || handler->GetType() == bitmapType) ) | |
82 | return handler; | |
83 | node = node->Next(); | |
84 | } | |
85 | return NULL; | |
86 | } | |
87 | ||
88 | wxBitmapHandler *wxBitmapBase::FindHandler(wxBitmapType bitmapType) | |
89 | { | |
90 | wxNode *node = sm_handlers.First(); | |
91 | while ( node ) | |
92 | { | |
93 | wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); | |
94 | if (handler->GetType() == bitmapType) | |
95 | return handler; | |
96 | node = node->Next(); | |
97 | } | |
98 | return NULL; | |
99 | } | |
100 | ||
101 | void wxBitmapBase::CleanUpHandlers() | |
102 | { | |
103 | wxNode *node = sm_handlers.First(); | |
104 | while ( node ) | |
105 | { | |
106 | wxBitmapHandler *handler = (wxBitmapHandler *)node->Data(); | |
107 | wxNode *next = node->Next(); | |
108 | delete handler; | |
109 | delete 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__) | |
126 |