iconloc.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_ICONLOC_H_
  11. #define _WX_ICONLOC_H_
  12. #include "wx/string.h"
  13. // ----------------------------------------------------------------------------
  14. // wxIconLocation: describes the location of an icon
  15. // ----------------------------------------------------------------------------
  16. class WXDLLIMPEXP_BASE wxIconLocationBase
  17. {
  18. public:
  19. // ctor takes the name of the file where the icon is
  20. wxEXPLICIT wxIconLocationBase(const wxString& filename = wxEmptyString)
  21. : m_filename(filename) { }
  22. // default copy ctor, assignment operator and dtor are ok
  23. // returns true if this object is valid/initialized
  24. bool IsOk() const { return !m_filename.empty(); }
  25. // set/get the icon file name
  26. void SetFileName(const wxString& filename) { m_filename = filename; }
  27. const wxString& GetFileName() const { return m_filename; }
  28. private:
  29. wxString m_filename;
  30. };
  31. // under Windows the same file may contain several icons so we also store the
  32. // index of the icon
  33. #if defined(__WINDOWS__)
  34. class WXDLLIMPEXP_BASE wxIconLocation : public wxIconLocationBase
  35. {
  36. public:
  37. // ctor takes the name of the file where the icon is and the icons index in
  38. // the file
  39. wxEXPLICIT wxIconLocation(const wxString& file = wxEmptyString, int num = 0);
  40. // set/get the icon index
  41. void SetIndex(int num) { m_index = num; }
  42. int GetIndex() const { return m_index; }
  43. private:
  44. int m_index;
  45. };
  46. inline
  47. wxIconLocation::wxIconLocation(const wxString& file, int num)
  48. : wxIconLocationBase(file)
  49. {
  50. SetIndex(num);
  51. }
  52. #else // !__WINDOWS__
  53. // must be a class because we forward declare it as class
  54. class WXDLLIMPEXP_BASE wxIconLocation : public wxIconLocationBase
  55. {
  56. public:
  57. wxEXPLICIT wxIconLocation(const wxString& filename = wxEmptyString)
  58. : wxIconLocationBase(filename) { }
  59. };
  60. #endif // platform
  61. #endif // _WX_ICONLOC_H_