]>
git.saurik.com Git - wxWidgets.git/blob - src/common/iconbndl.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIconBundle
4 // Author: Mattia Barbon
7 // Copyright: (c) Mattia barbon
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
19 #include "wx/settings.h"
23 #include "wx/bitmap.h"
26 #if wxUSE_IMAGE && !defined(_WX_IMAGE_H_)
30 #include "wx/iconbndl.h"
31 #include "wx/arrimpl.cpp"
33 WX_DEFINE_OBJARRAY(wxIconArray
)
35 const wxIconBundle
& wxIconBundle::operator =( const wxIconBundle
& ic
)
37 if( this == &ic
) return *this;
39 size_t i
, max
= ic
.m_icons
.GetCount();
42 for( i
= 0; i
< max
; ++i
)
43 m_icons
.Add( ic
.m_icons
[i
] );
48 void wxIconBundle::DeleteIcons()
54 void wxIconBundle::AddIcon( const wxString
& file
, long type
)
56 void wxIconBundle::AddIcon( const wxString
& WXUNUSED(file
), long WXUNUSED(type
) )
59 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
60 size_t count
= wxImage::GetImageCount( file
, type
);
64 for( i
= 0; i
< count
; ++i
)
66 if( !image
.LoadFile( file
, type
, i
) )
68 wxLogError( _("Failed to load image %d from file '%s'."),
73 wxIcon
* tmp
= new wxIcon();
74 tmp
->CopyFromBitmap( wxBitmap( image
) );
81 const wxIcon
& wxIconBundle::GetIcon( const wxSize
& size
) const
83 size_t i
, max
= m_icons
.GetCount();
84 wxCoord sysX
= wxSystemSettings::GetMetric( wxSYS_ICON_X
),
85 sysY
= wxSystemSettings::GetMetric( wxSYS_ICON_Y
);
88 // temp. variable needed to fix Borland C++ 5.5.1 problem
89 // with passing a return value through two functions
92 for( i
= 0; i
< max
; i
++ )
94 if( !m_icons
[i
].Ok() )
96 wxCoord sx
= m_icons
[i
].GetWidth(), sy
= m_icons
[i
].GetHeight();
98 if( sx
== size
.x
&& sy
== size
.y
)
100 tmp
= &m_icons
[i
]; // fix for broken BCC
103 // keep track if there is a system-size icon
104 if( sx
== sysX
&& sy
== sysY
)
105 sysIcon
= &m_icons
[i
];
108 // return the system-sized icon if we've got one
109 if( sysIcon
) return *sysIcon
;
110 // return the first icon, if we have one
111 if( max
> 0 ) // fix for broken BCC
118 void wxIconBundle::AddIcon( const wxIcon
& icon
)
120 size_t i
, max
= m_icons
.GetCount();
122 for( i
= 0; i
< max
; ++i
)
124 wxIcon
& tmp
= m_icons
[i
];
125 if( tmp
.Ok() && tmp
.GetWidth() == icon
.GetWidth() &&
126 tmp
.GetHeight() == icon
.GetHeight() )