]> git.saurik.com Git - wxWidgets.git/blob - include/wx/iconloc.h
added wxIconLocation; minor fixes to wxIcon on some platforms
[wxWidgets.git] / include / wx / iconloc.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/iconloc.h
3 // Purpose: declaration of wxIconLocation class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 21.06.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_ICONLOC_H_
13 #define _WX_ICONLOC_H_
14
15 #include "wx/string.h"
16
17 // ----------------------------------------------------------------------------
18 // wxIconLocation: describes the location of an icon
19 // ----------------------------------------------------------------------------
20
21 class WXDLLEXPORT wxIconLocationBase
22 {
23 public:
24 // ctor takes the name of the file where the icon is
25 wxEXPLICIT wxIconLocationBase(const wxString& file) : m_filename(file) { }
26
27 // default copy ctor, assignment operator and dtor are ok
28
29
30 // returns true if this object is valid/initialized
31 bool IsOk() const { return !m_filename.empty(); }
32
33 // set/get the icon file name
34 void SetFileName(const wxString& file) { m_filename = file; }
35 const wxString& GetFileName() const { return m_filename; }
36
37 private:
38 wxString m_filename;
39 };
40
41 // under MSW the same file may contain several icons so we also store the
42 // index of the icon
43 #if defined(__WXMSW__)
44
45 class WXDLLEXPORT wxIconLocation : public wxIconLocationBase
46 {
47 public:
48 // ctor takes the name of the file where the icon is and the icons index in
49 // the file
50 wxEXPLICIT wxIconLocation(const wxString& file, int num = 0);
51
52 // set/get the icon index
53 void SetIndex(int num) { m_index = num; }
54 int GetIndex() const { return m_index; }
55
56 private:
57 int m_index;
58 };
59
60 inline
61 wxIconLocation::wxIconLocation(const wxString& file, int num)
62 : wxIconLocationBase(file)
63 {
64 SetIndex(num);
65 }
66
67 #else // !MSW
68
69 typedef wxIconLocationBase wxIconLocation;
70
71 #endif // platform
72
73 #endif // _WX_ICONLOC_H_
74