Hi,
I know very little about wxGrid, but have used wxDC and related objects a fair 
bit.

Therefore something jumps out from the code.

Using $grid->SetCellOverflow( $row, $col,0) should be used outside your 
subroutine to set the extents of the $rect passed in and it is your job in a 
custom renderer to draw the text within the bounds described by $rect.

use

$dc->GetTextExtents

to decide how to draw your text and how much of it to output.


As I say, I'm not familiar with wxGrid, so maybe it has some special 
properties, but if using a custom renderer in wxGrid is like any other custom 
rendering, I think all the work is down to you.

Is there not an example in Wx::Demo that does something exactly like this?

Cheers

Mark






Doug Breshears wrote:
Hi everybody,

I have a grid with a custom cell combo editor/renderer.
The Editor works fine, the renderer however is allowing the text to overflow the cell boundaries even when the SetCellOverflow is set to False.
   $grid->SetCellOverflow( $row, $col,0);
The other cells w/o custom renderer's work fine and properly cut the text off when it is to big for the cell.

Below is the "Draw" method for my custom renderer. It is pretty much a copy of the examples with extra combo box functionality thrown in. If anyone has a clue as to what is going on I would appreciate some assistance. (I have also set SetDefaultCellOverflow(FALSE) in the creation of the grid.)

sub Draw {
debug "Renderer:Draw\n";
 my( $self, $grid, $attr, $dc, $rect, $row, $col, $sel ) = ( shift, @_ );
 $self->SUPER::Draw( @_ );
 $dc->SetPen( wxBLACK_PEN );
 $dc->SetBrush( wxWHITE_BRUSH );
 $dc->SetFont(Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT ));
 my $dbvalue = $grid->GetCellValue( $row, $col );
 $grid->SetCellOverflow( $row, $col,0);
 debug "Got Value of :$dbvalue:\n";
 my $textvalue = $self->get_text_from_id($dbvalue);
 debug "New Text is :$textvalue:\n";
 $dc->DrawText( $textvalue, $rect->x, $rect->y );
}



Reply via email to