]>
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 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "iconbndl.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
23 #include "wx/settings.h"
33 #include "wx/iconbndl.h"
34 #include "wx/arrimpl.cpp"
36 WX_DEFINE_OBJARRAY(wxIconArray
)
38 const wxIconBundle
& wxIconBundle::operator =( const wxIconBundle
& ic
)
40 if( this == &ic
) return *this;
42 size_t i
, max
= ic
.m_icons
.GetCount();
45 for( i
= 0; i
< max
; ++i
)
46 m_icons
.Add( ic
.m_icons
[i
] );
51 void wxIconBundle::DeleteIcons()
56 void wxIconBundle::AddIcon( const wxString
& file
, long type
)
58 size_t count
= wxImage::GetImageCount( file
, type
);
62 for( i
= 0; i
< count
; ++i
)
64 if( !image
.LoadFile( file
, type
, i
) )
66 wxLogError( _("Failed to load image %d from file '%s'."),
71 wxIcon
* tmp
= new wxIcon();
72 tmp
->CopyFromBitmap( wxBitmap( image
) );
78 const wxIcon
& wxIconBundle::GetIcon( const wxSize
& size
) const
80 size_t i
, max
= m_icons
.GetCount();
81 wxCoord sysX
= wxSystemSettings::GetMetric( wxSYS_ICON_X
),
82 sysY
= wxSystemSettings::GetMetric( wxSYS_ICON_Y
);
85 // temp. variable needed to fix Borland C++ 5.5.1 problem
86 // with passing a return value through two functions
89 for( i
= 0; i
< max
; i
++ )
91 if( !m_icons
[i
].Ok() )
93 wxCoord sx
= m_icons
[i
].GetWidth(), sy
= m_icons
[i
].GetHeight();
95 if( sx
== size
.x
&& sy
== size
.y
)
97 tmp
= &m_icons
[i
]; // fix for broken BCC
100 // keep track if there is a system-size icon
101 if( sx
== sysX
&& sy
== sysY
)
102 sysIcon
= &m_icons
[i
];
105 // return the system-sized icon if we've got one
106 if( sysIcon
) return *sysIcon
;
107 // return the first icon, if we have one
108 if( max
> 0 ) // fix for broken BCC
115 void wxIconBundle::AddIcon( const wxIcon
& icon
)
117 size_t i
, max
= m_icons
.GetCount();
119 for( i
= 0; i
< max
; ++i
)
121 wxIcon
& tmp
= m_icons
[i
];
122 if( tmp
.Ok() && tmp
.GetWidth() == icon
.GetWidth() &&
123 tmp
.GetHeight() == icon
.GetHeight() )