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.

86 lines
2.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
  5. * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
  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 3
  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 two_column_tree_list.h
  26. */
  27. #include <wx/treelist.h>
  28. #ifndef __two_column_tree_list__
  29. #define __two_column_tree_list__
  30. /**
  31. * Modified wxTreeListCtrl designed for use with two columns, with better
  32. * column resizing. wxTreeListCtrl accumulates error as columns resize,
  33. * leading to columns with a totally wrong size.
  34. */
  35. class TWO_COLUMN_TREE_LIST : public wxTreeListCtrl
  36. {
  37. public:
  38. /**
  39. * Create a TWO_COLUMN_TREE_LIST.
  40. */
  41. TWO_COLUMN_TREE_LIST( wxWindow* aParent, wxWindowID aID,
  42. const wxPoint & aPos = wxDefaultPosition,
  43. const wxSize & aSize = wxDefaultSize,
  44. long aStyle = wxTL_DEFAULT_STYLE,
  45. const wxString & aName = wxTreeListCtrlNameStr );
  46. /**
  47. * Set the column number that will "rubber-band" (expand with available space).
  48. * As this is a TWO column tree list, this must be zero or one.
  49. */
  50. void SetRubberBandColumn( int aRubberBandColumn )
  51. {
  52. m_rubber_band_column = aRubberBandColumn;
  53. }
  54. /**
  55. * Set the minimum width of the non-rubber-band column.
  56. */
  57. void SetClampedMinWidth( int aClampedMinWidth )
  58. {
  59. m_clamped_min_width = aClampedMinWidth;
  60. }
  61. /**
  62. * Recompute column sizes. This should be called after adding columns.
  63. * There is no need to call this in an OnSize handler - this CALLS the
  64. * OnSize handler.
  65. */
  66. void AutosizeColumns();
  67. /**
  68. * Override buggy wxTreeListCtrl size handler.
  69. */
  70. void OnSize( wxSizeEvent& aEvent );
  71. protected:
  72. int m_rubber_band_column;
  73. int m_clamped_min_width;
  74. };
  75. #endif // __two_column_tree_list__