Hi everyone, I want to do what is in the example picture.
Is just to add a triangle inside the cell of a column label in wxGrid.
I already know how to do it on a particular cell, but not in the column label.
THANKS
wxGrid changing label rendering Topic is solved
wxGrid changing label rendering
- Attachments
-
- this is the triangle example
- triangle.PNG (3.95 KiB) Viewed 1673 times
Simon
My class:
Code: Select all
/**********************************************************************************************/
/* vsBaseGrid.h */
/* */
/* All Rights Reserved. */
/**********************************************************************************************/
#ifndef __vsBaseGrid_H__
#define __vsBaseGrid_H__
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <wx/grid.h>
/**********************************************************************************************/
class vsBaseGrid: public wxGrid
{
public://///////////////////////////////////////////////////////////////////////////////////
vsBaseGrid( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxWANTS_CHARS );
~vsBaseGrid();
virtual wxGrid* Clone(wxWindowID id = wxID_ANY);
virtual int GetColLeft( int col ) { return wxGrid::GetColLeft( col ); }
virtual int GetRowBottom( int row ) { return wxGrid::GetRowBottom( row ); }
virtual int GetRowTop( int row ) { return wxGrid::GetRowTop( row ); }
private:////////////////////////////////////////////////////////////////////////////////////
virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
virtual void DrawRowLabel( wxDC& dc, int row );
virtual void DrawColLabel( wxDC& dc, int row );
DECLARE_EVENT_TABLE()
};
/**********************************************************************************************/
#endif // __vsBaseGrid_H__
/**********************************************************************************************/
/* vsBaseGrid.cpp */
/* */
/* All Rights Reserved. */
/**********************************************************************************************/
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "vsBaseGrid.h"
BEGIN_EVENT_TABLE(vsBaseGrid, wxGrid)
ND_EVENT_TABLE()
/**********************************************************************************************/
vsBaseGrid::vsBaseGrid( wxWindow *parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style )
: wxGrid( parent, id, pos, size, style )
{
EnableDragRowSize( false );
}
/**********************************************************************************************/
vsBaseGrid::~vsBaseGrid()
{
}
/**********************************************************************************************/
wxGrid* vsBaseGrid::Clone( wxWindowID id )
{
vsBaseGrid *t_pGrid;
t_pGrid = new vsBaseGrid(GetParent(), id);
//TODO
return t_pGrid;
}
/**********************************************************************************************/
// Hide wxGrid cursor
void vsBaseGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
{
//rewrite parent method for hide cursor
return;
}
/**********************************************************************************************/
// Drawing labels for each row
void vsBaseGrid::DrawRowLabel( wxDC& dc, int row )
{
wxGrid::DrawRowLabel( dc, row );
}
/**********************************************************************************************/
// Drawing labels for each row
void vsBaseGrid::DrawColLabel( wxDC& dc, int col )
{
int colLeft = GetColLeft(col);
int colCur = GetGridCursorCol();
wxColour cl1;
wxRect tRect( colLeft, 0, GetColWidth(col), m_colLabelHeight );
#ifdef __WXMSW__
cl1 = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
#else
cl1 = *wxWHITE;
#endif
wxColour cl2 = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
dc.GradientFillLinear( tRect, cl1/*wxColour( 250, 249, 245 )*/, cl2/*wxColour( 192, 192, 168 )*/, wxSOUTH );
#ifdef __WXMSW__
wxFont tFont = *wxNORMAL_FONT;
#else
wxFont tFont = *wxSMALL_FONT;
#endif
dc.SetFont( tFont );
dc.DrawLabel( GetColLabelValue( col ), tRect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL );
tRect.Offset( -1, 0 );
tRect.SetWidth( tRect.GetWidth() + 1 );
wxColour cl3 = GetGridLineColour();
dc.SetPen( cl3 );
dc.SetBrush( *wxTRANSPARENT_BRUSH );
dc.DrawRectangle( tRect );
}
http://www.wxwidgets.org/ --> at the right of the screen --> latest docsSimon wrote:THANKS A LOT. I was reading an old class reference. Where is the most up-to -date ???