You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef CURSOR_STORE__H
  24. #define CURSOR_STORE__H
  25. #include <wx/cursor.h>
  26. #include <map>
  27. #include <vector>
  28. /**
  29. * Simple class to construct and store cursors against unique ID keys.
  30. *
  31. * This can be used to lazily construct cursors as needed for specific
  32. * applications.
  33. */
  34. class CURSOR_STORE
  35. {
  36. public:
  37. /**
  38. * Definition of a cursor
  39. */
  40. struct CURSOR_DEF
  41. {
  42. ///> The ID key used to uniquely identify a cursor in a given store
  43. int m_id_key;
  44. ///> The image data bitmap
  45. const unsigned char* m_image_data;
  46. ///> The mask data bitmap
  47. const unsigned char* m_mask_data;
  48. ///> The image size in pixels
  49. wxSize m_size;
  50. ///> The "hotspot" where the cursor "is" in the image
  51. wxPoint m_hotspot;
  52. };
  53. /**
  54. * Construct a store with a pre-set list of cursors.
  55. *
  56. * In future, an "Add()" function could be added if stores need to
  57. * dynamically add cursors.
  58. *
  59. * @param aDefs: the list of pre-set cursor definitions
  60. */
  61. CURSOR_STORE( const std::vector<CURSOR_DEF>& aDefs );
  62. /**
  63. * Get a given cursor by its ID
  64. * @param aIdKey the ID key to look up
  65. * @return the cursor, if found, else wxNullCursor
  66. */
  67. const wxCursor& Get( int aIdKey ) const;
  68. private:
  69. ///> Internal store of cursors by ID
  70. std::map<int, wxCursor> m_store;
  71. };
  72. #endif // CURSOR_STORE__H