[Gtk-sharp-list] Tips for drawing quickly

Aaron Oxford aaron at hardwarehookups.com.au
Sat May 19 01:34:38 EDT 2007

Hi all,

I have a very large, very important custom control in my application 
that is basically a big grid of numbers and words. The best way you 
could think of it is as a big spreadsheet. It has the usual things 
like selecting regions and what-not going on. The problem is it has 
to draw a lot of text (character by character, no less) and it's too 
slow to update.

I have little experience with these sorts of things except in just 
making them go. This control is *really* sluggish though. I'm hoping 
this isn't just a side-effect of GTK, but in any case I'd really 
appreciate any tips on making things go faster. My other control 
(which is more like dragging boxes around on a canvas) is a bit jerky 
at 1280x960, but not unbearable. It seems that without double 
buffering, the updates are far faster. Is there a framerate setting 
somewhere? :-)

I'm using the Gtk 'native' libraries under Windows, not the Gtk# 
implementation of System.Drawing. Is this inherently slower/faster? 
What about under Linux?

Is there a way to make Pango do monospaced layouts (without 
restricting me to monospaced fonts)? I've done some experimentation, 
and I can increase the speed significantly by avoiding this excessive 
use of DrawLayout and using a cache of images to draw text. Is this 
the sort of lengths I should be going to or are there better ways to 
accelerate updating custom controls and/or draw a spreadsheet-like control?

Could I for instance compose the appearance in a buffer, perhaps 
saving some time using image manipulation rather than completely 
recomposing the image on every update? That would be a lot of work 
and I could only attempt it if I knew it would pay off.

Thanks in advance for any advice,

Aaron Oxford   -   aaron+hardwarehookups .com .au
Director, Innovative Computer Solutions (Aust) Pty. Ltd.
49 Maitland Rd, Mayfield, NSW 2304 Australia
Developer, SourceForge project VioLet Composer

More information about the Gtk-sharp-list mailing list