]>
git.saurik.com Git - wxWidgets.git/blob - src/common/iconbndl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/iconbndl.cpp
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"
18 #include "wx/iconbndl.h"
21 #include "wx/settings.h"
25 #include "wx/bitmap.h"
28 #if wxUSE_IMAGE && !defined(_WX_IMAGE_H_)
32 #include "wx/arrimpl.cpp"
34 WX_DEFINE_OBJARRAY(wxIconArray
)
36 const wxIconBundle
& wxIconBundle::operator =( const wxIconBundle
& ic
)
38 if( this == &ic
) return *this;
40 size_t i
, max
= ic
.m_icons
.GetCount();
43 for( i
= 0; i
< max
; ++i
)
44 m_icons
.Add( ic
.m_icons
[i
] );
49 void wxIconBundle::DeleteIcons()
55 void wxIconBundle::AddIcon( const wxString
& file
, long type
)
57 void wxIconBundle::AddIcon( const wxString
& WXUNUSED(file
), long WXUNUSED(type
) )
60 #if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
61 size_t count
= wxImage::GetImageCount( file
, type
);
65 for( i
= 0; i
< count
; ++i
)
67 if( !image
.LoadFile( file
, type
, i
) )
69 wxLogError( _("Failed to load image %d from file '%s'."),
74 wxIcon
* tmp
= new wxIcon();
75 tmp
->CopyFromBitmap( wxBitmap( image
) );
82 const wxIcon
& wxIconBundle::GetIcon( const wxSize
& size
) const
84 size_t i
, max
= m_icons
.GetCount();
85 wxCoord sysX
= wxSystemSettings::GetMetric( wxSYS_ICON_X
),
86 sysY
= wxSystemSettings::GetMetric( wxSYS_ICON_Y
);
89 // temp. variable needed to fix Borland C++ 5.5.1 problem
90 // with passing a return value through two functions
93 for( i
= 0; i
< max
; i
++ )
95 if( !m_icons
[i
].Ok() )
97 wxCoord sx
= m_icons
[i
].GetWidth(), sy
= m_icons
[i
].GetHeight();
99 if( sx
== size
.x
&& sy
== size
.y
)
101 tmp
= &m_icons
[i
]; // fix for broken BCC
104 // keep track if there is a system-size icon
105 if( sx
== sysX
&& sy
== sysY
)
106 sysIcon
= &m_icons
[i
];
109 // return the system-sized icon if we've got one
110 if( sysIcon
) return *sysIcon
;
111 // return the first icon, if we have one
112 if( max
> 0 ) // fix for broken BCC
119 void wxIconBundle::AddIcon( const wxIcon
& icon
)
121 size_t i
, max
= m_icons
.GetCount();
123 for( i
= 0; i
< max
; ++i
)
125 wxIcon
& tmp
= m_icons
[i
];
126 if( tmp
.Ok() && tmp
.GetWidth() == icon
.GetWidth() &&
127 tmp
.GetHeight() == icon
.GetHeight() )