KiCad PCB EDA Suite
DESIGN_TREE_FRAME Class Reference

Class DESIGN_TREE_FRAME is the left window showing the list of items. More...

#include <design_tree_frame.h>

Inheritance diagram for DESIGN_TREE_FRAME:

Public Member Functions

 DESIGN_TREE_FRAME (PL_EDITOR_FRAME *aParent)
 
 ~DESIGN_TREE_FRAME ()
 
void ReCreateDesignTree ()
 
wxSize GetMinSize () const override
 
WORKSHEET_DATAITEMGetPageLayoutItem (wxTreeItemId aCell) const
 
WORKSHEET_DATAITEMGetPageLayoutSelectedItem () const
 
int GetSelectedItemIndex ()
 
void SelectCell (WORKSHEET_DATAITEM *aItem)
 
void SelectCell (const wxTreeItemId &aTreeItem, bool aSelect=true)
 

Private Attributes

wxImageList * m_imageList
 

Friends

class PL_EDITOR_FRAME
 

Detailed Description

Class DESIGN_TREE_FRAME is the left window showing the list of items.

Definition at line 73 of file design_tree_frame.h.

Constructor & Destructor Documentation

DESIGN_TREE_FRAME::DESIGN_TREE_FRAME ( PL_EDITOR_FRAME aParent)

Definition at line 157 of file design_tree_frame.cpp.

References img_xpm, line_xpm, m_imageList, poly_xpm, rect_xpm, root_xpm, and text_xpm.

157  :
158  wxTreeCtrl( aParent, ID_DESIGN_TREE_FRAME )
159 {
160  // icons size is not know (depending on they are built)
161  // so get it:
162  wxSize iconsize;
163  wxBitmap root_bm( root_xpm );
164 
165  iconsize.x = root_bm.GetWidth();
166  iconsize.y = root_bm.GetHeight();
167 
168  // Make an image list containing small icons
169  m_imageList = new wxImageList( iconsize.x, iconsize.y, true, 6 );
170 
171  m_imageList->Add( root_bm ); // root symbol
172  m_imageList->Add( wxBitmap( line_xpm ) ); // line item
173  m_imageList->Add( wxBitmap( rect_xpm ) ); // rect item
174  m_imageList->Add( wxBitmap( text_xpm ) ); // text item
175  m_imageList->Add( wxBitmap( poly_xpm ) ); // poly item
176  m_imageList->Add( wxBitmap( img_xpm ) ); // bitmap item
177 
178  SetImageList( m_imageList );
179 }
static const char * line_xpm[]
static const char * rect_xpm[]
wxImageList * m_imageList
static const char * poly_xpm[]
static const char * root_xpm[]
static const char * text_xpm[]
static const char * img_xpm[]
DESIGN_TREE_FRAME::~DESIGN_TREE_FRAME ( )

Definition at line 182 of file design_tree_frame.cpp.

References m_imageList.

183 {
184  delete m_imageList;
185 }
wxImageList * m_imageList

Member Function Documentation

wxSize DESIGN_TREE_FRAME::GetMinSize ( ) const
override

Definition at line 188 of file design_tree_frame.cpp.

Referenced by PL_EDITOR_FRAME::PL_EDITOR_FRAME().

189 {
190  return wxSize( 100, -1 );
191 }
WORKSHEET_DATAITEM * DESIGN_TREE_FRAME::GetPageLayoutItem ( wxTreeItemId  aCell) const
Returns
the page layout item managed by the cell

Definition at line 258 of file design_tree_frame.cpp.

References DESIGN_TREE_ITEM_DATA::GetItem().

Referenced by GetPageLayoutSelectedItem().

259 {
260  DESIGN_TREE_ITEM_DATA* data = (DESIGN_TREE_ITEM_DATA*) GetItemData( aCell );
261  if( data )
262  return data->GetItem();
263  else
264  return NULL;
265 }
class DESIGN_TREE_ITEM Handle one item for the page layoiut design
WORKSHEET_DATAITEM * GetItem() const
WORKSHEET_DATAITEM * DESIGN_TREE_FRAME::GetPageLayoutSelectedItem ( ) const
Returns
the page layout item managed by the selected cell (or NULL)

Definition at line 269 of file design_tree_frame.cpp.

References GetPageLayoutItem().

Referenced by PL_EDITOR_FRAME::GetSelectedItem(), GetSelectedItemIndex(), PL_EDITOR_FRAME::OnHotKey(), PL_EDITOR_FRAME::OnLeftClick(), and PL_EDITOR_FRAME::OnRightClick().

270 {
271  wxTreeItemId cell;
272  cell = GetSelection();
273 
274  if( cell.IsOk() )
275  return GetPageLayoutItem( cell );
276 
277  return NULL;
278 }
WORKSHEET_DATAITEM * GetPageLayoutItem(wxTreeItemId aCell) const
int DESIGN_TREE_FRAME::GetSelectedItemIndex ( )
Returns
the page layout item index managed by the selected cell (or -1)

Definition at line 282 of file design_tree_frame.cpp.

References WORKSHEET_LAYOUT::GetItemIndex(), GetPageLayoutSelectedItem(), and WORKSHEET_LAYOUT::GetTheInstance().

283 {
285 
286  if( item == NULL )
287  return -1;
288 
290  return pglayout.GetItemIndex( item );
291 }
int GetItemIndex(WORKSHEET_DATAITEM *aItem) const
static WORKSHEET_LAYOUT & GetTheInstance()
static function: returns the instance of WORKSHEET_LAYOUT used in the application ...
WORKSHEET_LAYOUT handles the graphic items list to draw/plot the title block and other items (page re...
WORKSHEET_DATAITEM * GetPageLayoutSelectedItem() const
void DESIGN_TREE_FRAME::ReCreateDesignTree ( )

Definition at line 194 of file design_tree_frame.cpp.

References dummy(), WORKSHEET_LAYOUT::GetCount(), WORKSHEET_LAYOUT::GetItem(), WORKSHEET_LAYOUT::GetTheInstance(), WORKSHEET_DATAITEM::GetType(), WORKSHEET_DATAITEM::m_Name, WORKSHEET_DATAITEM::WS_BITMAP, WORKSHEET_DATAITEM::WS_POLYPOLYGON, WORKSHEET_DATAITEM::WS_RECT, WORKSHEET_DATAITEM::WS_SEGMENT, and WORKSHEET_DATAITEM::WS_TEXT.

Referenced by PL_EDITOR_FRAME::RebuildDesignTree().

195 {
196  wxWindowUpdateLocker dummy(this); // Avoid flicker when rebuilding the tree
197 
198  DeleteAllItems();
199 
201 
202  // root tree:
203  wxFileName fn( ((PL_EDITOR_FRAME*) GetParent())->GetCurrFileName() );
204  wxTreeItemId rootitem;
205 
206  if( fn.GetName().IsEmpty() )
207  rootitem = AddRoot( wxT( "<default>" ), 0, 0 );
208  else
209  rootitem = AddRoot( fn.GetName(), 0, 0 );
210 
211  SetItemBold( rootitem, true );
212 
213  // Now adding all current items
214  for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
215  {
216  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
217  int img = 0;
218  switch( item->GetType() )
219  {
220  case WORKSHEET_DATAITEM::WS_SEGMENT: img = 1; break;
221  case WORKSHEET_DATAITEM::WS_RECT: img = 2; break;
222  case WORKSHEET_DATAITEM::WS_TEXT: img = 3; break;
223  case WORKSHEET_DATAITEM::WS_POLYPOLYGON: img = 4; break;
224  case WORKSHEET_DATAITEM::WS_BITMAP: img = 5; break;
225  }
226  wxTreeItemId cell= AppendItem( rootitem, item->m_Name, img, img );
227  DESIGN_TREE_ITEM_DATA* data = new DESIGN_TREE_ITEM_DATA( item );
228  SetItemData( cell, data );
229  }
230 
231  Expand( rootitem );
232 }
static WORKSHEET_LAYOUT & GetTheInstance()
static function: returns the instance of WORKSHEET_LAYOUT used in the application ...
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
class DESIGN_TREE_ITEM Handle one item for the page layoiut design
WORKSHEET_LAYOUT handles the graphic items list to draw/plot the title block and other items (page re...
unsigned GetCount() const
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
WS_ItemType GetType() const
void DESIGN_TREE_FRAME::SelectCell ( WORKSHEET_DATAITEM aItem)

Definition at line 236 of file design_tree_frame.cpp.

References DESIGN_TREE_ITEM_DATA::GetItem().

Referenced by PL_EDITOR_FRAME::OnHotKey(), PL_EDITOR_FRAME::OnLeftClick(), PL_EDITOR_FRAME::OnRightClick(), and PL_EDITOR_FRAME::OnTreeRightClick().

237 {
238  wxTreeItemId rootcell = GetRootItem();
239  wxTreeItemIdValue cookie;
240 
241  wxTreeItemId cell = GetFirstChild( rootcell, cookie );
242 
243  while( cell.IsOk() )
244  {
245  DESIGN_TREE_ITEM_DATA* data = (DESIGN_TREE_ITEM_DATA*) GetItemData( cell );
246 
247  if( data->GetItem() == aItem )
248  {
249  SelectItem( cell );
250  return;
251  }
252 
253  cell = GetNextChild( rootcell, cookie );
254  }
255 }
class DESIGN_TREE_ITEM Handle one item for the page layoiut design
WORKSHEET_DATAITEM * GetItem() const
void DESIGN_TREE_FRAME::SelectCell ( const wxTreeItemId &  aTreeItem,
bool  aSelect = true 
)
inline

Definition at line 102 of file design_tree_frame.h.

103  {
104  SelectItem( aTreeItem, aSelect );
105  }

Friends And Related Function Documentation

friend class PL_EDITOR_FRAME
friend

Definition at line 75 of file design_tree_frame.h.

Member Data Documentation

wxImageList* DESIGN_TREE_FRAME::m_imageList
private

Definition at line 78 of file design_tree_frame.h.

Referenced by DESIGN_TREE_FRAME(), and ~DESIGN_TREE_FRAME().


The documentation for this class was generated from the following files: