KiCad PCB EDA Suite
two_column_tree_list.h
Go to the documentation of this file.
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 
29 #include <wx/treelist.h>
30 #include <map>
31 
32 #ifndef __two_column_tree_list__
33 #define __two_column_tree_list__
34 
40 class TWO_COLUMN_TREE_LIST : public wxTreeListCtrl
41 {
42  public:
46  TWO_COLUMN_TREE_LIST( wxWindow* aParent, wxWindowID aID,
47  const wxPoint & aPos = wxDefaultPosition,
48  const wxSize & aSize = wxDefaultSize,
49  long aStyle = wxTL_DEFAULT_STYLE,
50  const wxString & aName = wxTreeListCtrlNameStr );
51 
52 
57  void SetRubberBandColumn( int aRubberBandColumn )
58  {
59  m_rubber_band_column = aRubberBandColumn;
60  }
61 
65  void SetClampedMinWidth( int aClampedMinWidth )
66  {
67  m_clamped_min_width = aClampedMinWidth;
68  }
69 
75  void AutosizeColumns();
76 
80  void OnSize( wxSizeEvent& aEvent );
81 
82  protected:
83 
88  int MemoWidthFor( const wxString& aStr );
89 
92 
93  static std::map<wxString, int> m_width_cache;
94 };
95 
96 #endif // __two_column_tree_list__
void AutosizeColumns()
Recompute column sizes.
TWO_COLUMN_TREE_LIST(wxWindow *aParent, wxWindowID aID, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxTL_DEFAULT_STYLE, const wxString &aName=wxTreeListCtrlNameStr)
Create a TWO_COLUMN_TREE_LIST.
Modified wxTreeListCtrl designed for use with two columns, with better column resizing.
void SetClampedMinWidth(int aClampedMinWidth)
Set the minimum width of the non-rubber-band column.
void SetRubberBandColumn(int aRubberBandColumn)
Set the column number that will "rubber-band" (expand with available space).
static std::map< wxString, int > m_width_cache
int MemoWidthFor(const wxString &aStr)
Memoized version of wx WidthFor(), which returns the width in pixels required to display a string...
void OnSize(wxSizeEvent &aEvent)
Override buggy wxTreeListCtrl size handler.