KiCad PCB EDA Suite
GRID_CELL_ICON_RENDERER Class Reference

#include <grid_icon_text_helpers.h>

Inheritance diagram for GRID_CELL_ICON_RENDERER:

Public Member Functions

 GRID_CELL_ICON_RENDERER (const wxBitmap &icon)
 
void Draw (wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
 
wxSize GetBestSize (wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
 
wxGridCellRenderer * Clone () const override
 

Private Attributes

const wxBitmap & m_icon
 

Detailed Description

Definition at line 56 of file grid_icon_text_helpers.h.

Constructor & Destructor Documentation

GRID_CELL_ICON_RENDERER::GRID_CELL_ICON_RENDERER ( const wxBitmap &  icon)

Definition at line 75 of file grid_icon_text_helpers.cpp.

Referenced by Clone().

75  : m_icon( icon )
76 {
77 }

Member Function Documentation

wxGridCellRenderer * GRID_CELL_ICON_RENDERER::Clone ( ) const
override

Definition at line 106 of file grid_icon_text_helpers.cpp.

References GRID_CELL_ICON_RENDERER(), and m_icon.

107 {
108  return new GRID_CELL_ICON_RENDERER( m_icon );
109 }
GRID_CELL_ICON_RENDERER(const wxBitmap &icon)
void GRID_CELL_ICON_RENDERER::Draw ( wxGrid &  aGrid,
wxGridCellAttr &  aAttr,
wxDC &  aDC,
const wxRect &  aRect,
int  aRow,
int  aCol,
bool  isSelected 
)
override

Definition at line 80 of file grid_icon_text_helpers.cpp.

References m_icon.

82 {
83  wxRect rect = aRect;
84  rect.Inflate( -1 );
85 
86  // erase background
87  wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
88 
89  // Draw icon
90  if( m_icon.IsOk() )
91  {
92  aDC.DrawBitmap( m_icon,
93  rect.GetLeft() + ( rect.GetWidth() - m_icon.GetWidth() ) / 2,
94  rect.GetTop() + ( rect.GetHeight() - m_icon.GetHeight() ) / 2,
95  true );
96  }
97 }
wxSize GRID_CELL_ICON_RENDERER::GetBestSize ( wxGrid &  grid,
wxGridCellAttr &  attr,
wxDC &  dc,
int  row,
int  col 
)
override

Definition at line 100 of file grid_icon_text_helpers.cpp.

References m_icon.

101 {
102  return wxSize( m_icon.GetWidth() + 6, m_icon.GetHeight() + 4 );
103 }

Member Data Documentation

const wxBitmap& GRID_CELL_ICON_RENDERER::m_icon
private

Definition at line 67 of file grid_icon_text_helpers.h.

Referenced by Clone(), Draw(), and GetBestSize().


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