Set the grid rfenderer Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Set the grid rfenderer

Post by ONEEYEMAN »

Hi, ALL,

Code: Select all

#pragma once

#ifndef _IMAGECELLRENDERER
#define _IMAGECELLRENDERER

class ImageCellRenderer : wxGridCellStringRenderer
{
public:
    ImageCellRenderer(wxImage image);
    virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) wxOVERRIDE;
private:
    wxImage m_image;
    wxDECLARE_NO_COPY_CLASS(ImageCellRenderer);
};

#endif

#ifdef __GNUC__
#pragma implementation "dialogs.h"
#endif

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/grid.h"
#include "imagecellrenderer.h"

ImageCellRenderer::ImageCellRenderer(wxImage image)
{
    m_image = image;
}

void ImageCellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected)
{
    wxGridCellStringRenderer::Draw( grid, attr, dc, rect, row, col, isSelected );
    wxBitmap bitmap( m_image );
    dc.DrawBitmap( bitmap, rect.x, rect.y );
}
Trying to use this class I am getting:

Code: Select all

                    m_grid->SetCellRenderer( m_processed, i++, new ImageCellRenderer( image ) );

error C2243: 'type cast': conversion from 'ImageCellRenderer *' to 'wxGridCellRenderer *' exists, but is inaccessible
What am I missing?

Thank you.

P..S..: This is with wx-3.1.4 on Windows with MSVC 2017.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Set the grid rfenderer

Post by doublemax »

Missing 'public' before wxGridCellStringRenderer

Code: Select all

class ImageCellRenderer : public wxGridCellStringRenderer
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Set the grid rfenderer

Post by ONEEYEMAN »

doublemax,
You have a Hawk Eye. :D

Thank you..
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Set the grid rfenderer

Post by doublemax »

ONEEYEMAN wrote: Mon Apr 05, 2021 4:00 am doublemax,
You have a Hawk Eye. :D
Well, the error message kind of gave it away ;)
Use the source, Luke!
Post Reply