[Lazarus] Issue 15351 - Screen.Cursor from a TGroupBox fails (GTK2)

Paul Ishenin ip at kmiac.ru
Thu Dec 17 05:23:44 CET 2009


16.12.2009 22:07, Alexsander Rosa wrote:
> Let me know if you want me to take a look on that, just point me what
> has to be done and where.
> I have some rusty GTK knowledge, mostly from Griffith's "GNOME/GTK+
> Programming Bible".

Look at r23153. I don't know another solution now although I don't like 
the fix (due to recursion it needs).

The problem with cursors is that they can't assigned to widgets - they 
needs to be assigned to windows. Not every widget has its own window and 
some widgets don't give an access for their internal windows.

In the example TGroupBox consists of 3 widgets:

1. GtkFrame - for drawing frame around
2. GtkEventWindow - to handle events (clicks, focus, ...)
3. GtkFixed - to allow setting custom children positions

Only GtkEventWindow has a window but it does not provide any API to 
access it. Therefore we can only access the parent window of TGroupBox - 
TForm in this case. And we need to start traversing all the windows 
starting from the one TForm has. I wrote a new method of cursor changing 
now - it gets a widget from the window (every widget stores itself in 
the window it has using gdk_window_set_user_data) and gets WidgetInfo we 
stores for every widget we create. So if a window has a widget and the 
widget has a WidgetInfo wich equals to WidgetInfo of our control (of 
TGroupBox for example) then we can change the cursor for the window.

Probably we can simplify ResetGlobalCursor to call:

       if GtkWidgetIsA(Widget, gtk_widget_get_type)
       then begin
         WidgetInfo := GetWidgetInfo(Widget);
         SetWindowCursor(AWindow, WidgetInfo^.ControlCursor, False);
       end;

But I have not tested this idea yet.

Best regards,
Paul Ishenin.





More information about the Lazarus mailing list