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.

108 lines
2.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 CERN
  5. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file design_tree_frame.h
  26. */
  27. #ifndef _DESIGN_TREE_FRAME_H
  28. #define _DESIGN_TREE_FRAME_H
  29. #include <wx/treectrl.h>
  30. #include <pl_editor_frame.h>
  31. class WORKSHEET_DATAITEM;
  32. /** class DESIGN_TREE_ITEM
  33. * Handle one item for the page layoiut design
  34. */
  35. class DESIGN_TREE_ITEM_DATA : public wxTreeItemData
  36. {
  37. private:
  38. WORKSHEET_DATAITEM* m_wsItem; // the page layout item owned by me
  39. public:
  40. DESIGN_TREE_ITEM_DATA( WORKSHEET_DATAITEM* aItem = NULL )
  41. {
  42. m_wsItem = aItem;
  43. }
  44. /** @return the item managed by the cell
  45. */
  46. WORKSHEET_DATAITEM* GetItem() const
  47. {
  48. return m_wsItem;
  49. }
  50. /** Set the link to the item managed by the cell
  51. */
  52. void SetItem( WORKSHEET_DATAITEM* aItem )
  53. {
  54. m_wsItem = aItem;
  55. }
  56. };
  57. /**
  58. * Class DESIGN_TREE_FRAME is the left window showing the list of items
  59. */
  60. class DESIGN_TREE_FRAME : protected wxTreeCtrl
  61. {
  62. friend class PL_EDITOR_FRAME;
  63. private:
  64. wxImageList* m_imageList;
  65. public:
  66. DESIGN_TREE_FRAME( PL_EDITOR_FRAME* aParent );
  67. ~DESIGN_TREE_FRAME();
  68. void ReCreateDesignTree();
  69. wxSize GetMinSize() const override;
  70. /** @return the page layout item managed by the cell
  71. */
  72. WORKSHEET_DATAITEM* GetPageLayoutItem(wxTreeItemId aCell) const;
  73. /** @return the page layout item managed by the selected cell (or NULL)
  74. */
  75. WORKSHEET_DATAITEM* GetPageLayoutSelectedItem() const;
  76. /** @return the page layout item index managed by the selected cell (or -1)
  77. */
  78. int GetSelectedItemIndex();
  79. // Select the tree item corresponding to the WORKSHEET_DATAITEM aItem
  80. void SelectCell( WORKSHEET_DATAITEM* aItem );
  81. void SelectCell( const wxTreeItemId &aTreeItem, bool aSelect=true )
  82. {
  83. SelectItem( aTreeItem, aSelect );
  84. }
  85. };
  86. #endif /* _DESIGN_TREE_FRAME_H */