[gtkada] Help needed creating custom gtkada widget

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Mon Jan 11 19:58:07 CET 2016



On 2016-01-11 19:15, Brent Seidel wrote:
> I have tried basing my widget on Gtk_Widget_Record and Gtk_Drawing_Area_Record and got the same results.
Gtk_Misc is deprecated anyway, it should not be used.

If you want it in a hard way, read this through, to start with:

https://developer.gnome.org/gtk3/stable/GtkDrawingArea.html
>
>> On Jan 11, 2016, at 10:45 AM, Dmitry A. Kazakov <mailbox at dmitry-kazakov.de> wrote:
>>
>>
>> There is Gtk_Drawing_Area_Record for that. Then you do widget and widget class initialization wrong.
>>
>> The error reported tells that the widget does not have a window where you could draw. This is due to improper initialization.
> I’ve guessed that there was a problem with my initialization.  Unfortunately, I haven’t been able to find anything that says what needs to be done.  I’ve tried to combine some hints that I’ve found here and there.

You must call Initialize of the base widget. From the handler of 'draw' 
you must draw onto the context (the second parameter), not queuing 
another draw. You must handle some other signals as well, 
'size-allocate', likely 'style-update' and 'destroy'. There also is a 
lot of quite boring stuff about how widgets are resized, realized, catch 
focus etc.
>
>> You can take a look how dial widgets are implemented in cairo here:
>>
>> http://www.dmitry-kazakov.de/ada/aicwl.htm
>>
>> Or you could simply assemble your dial from existing elements (layers) provided there.
> That is quite an impressive set of dials that you have there.  However using them won’t help me learn how to do it myself.

You can study the source code. I don't think it is exciting. GTK is 
quite obscure. Cairo does not well fit into GTK. There is a lot of ugly 
stuff, for example, in using different types fonts for drawing texts in 
Cairo. Starting with corrections of poorly implemented size estimation 
in order to get the text scaled with the widget... Why do you want to 
learn all this dull mess instead of using an existing implementation?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



More information about the gtkada mailing list