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.

123 lines
3.0 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. enum class KICURSOR
  29. {
  30. DEFAULT,
  31. ARROW,
  32. MOVING,
  33. PENCIL,
  34. REMOVE,
  35. HAND,
  36. BULLSEYE,
  37. VOLTAGE_PROBE,
  38. CURRENT_PROBE,
  39. TUNE,
  40. TEXT,
  41. MEASURE,
  42. ADD,
  43. SUBTRACT,
  44. XOR,
  45. ZOOM_IN,
  46. ZOOM_OUT,
  47. LABEL_NET,
  48. LABEL_GLOBAL,
  49. COMPONENT,
  50. SELECT_WINDOW,
  51. SELECT_LASSO,
  52. LINE_BUS,
  53. LINE_GRAPHIC,
  54. LINE_WIRE,
  55. LINE_WIRE_ADD,
  56. LABEL_HIER,
  57. PLACE
  58. };
  59. /**
  60. * Simple class to construct and store cursors against unique ID keys.
  61. *
  62. * This can be used to lazily construct cursors as needed for specific
  63. * applications.
  64. */
  65. class CURSOR_STORE
  66. {
  67. public:
  68. /**
  69. * Definition of a cursor
  70. */
  71. struct CURSOR_DEF
  72. {
  73. ///> The ID key used to uniquely identify a cursor in a given store
  74. KICURSOR m_id_key;
  75. ///> The image data bitmap
  76. const unsigned char* m_image_data;
  77. ///> The mask data bitmap
  78. const unsigned char* m_mask_data;
  79. const char** m_xpm;
  80. ///> The image size in pixels
  81. wxSize m_size;
  82. ///> The "hotspot" where the cursor "is" in the image
  83. wxPoint m_hotspot;
  84. };
  85. /**
  86. * Construct a store with a pre-set list of cursors.
  87. *
  88. * In future, an "Add()" function could be added if stores need to
  89. * dynamically add cursors.
  90. *
  91. * @param aDefs: the list of pre-set cursor definitions
  92. */
  93. CURSOR_STORE( const std::vector<CURSOR_DEF>& aDefs );
  94. /**
  95. * Get a given cursor by its ID
  96. * @param aIdKey the ID key to look up
  97. * @return the cursor, if found, else wxNullCursor
  98. */
  99. const wxCursor& Get( KICURSOR aIdKey ) const;
  100. static const wxCursor GetCursor( KICURSOR aCursorType );
  101. static const wxStockCursor GetStockCursor( KICURSOR aCursorType );
  102. private:
  103. ///> Internal store of cursors by ID
  104. std::map<KICURSOR, wxCursor> m_store;
  105. };
  106. #endif // CURSOR_STORE__H