[Lazarus] Does using GtkFrame in LCL make sense?

zeljko zeljko at holobit.net
Fri Jul 1 15:04:52 CEST 2011


On Friday 01 of July 2011 14:17:15 Max Vlasov wrote:
> Hi,
> 
> I recently created report http://bugs.freepascal.org/view.php?id=19658
> 
> This was about panels that behave a little differently to panels in Lazarus
> Windows and Delphi. There were no comments or feedback request there so I
> decided to take a look
> 
> After some investigation it appeared that the problem was because GtkFrame
> was used. The problem with this widget is that one can't control the
> postion and painting in a small area two pixels around it. So every nested
> TPanel in GTK2 Lazarus smaller by 4 pixels that the parent no matter what
> (the consequences can be seen in the screenshots from Panel.zip). Looking
> at the code I also noticed that no special features of GtkFrame were used,
> all panel drawings take place inside paltform-independent part of LCL.
> 
> Trying to solve the problem, I ended up with the following replacement in
> the TGtk2WSCustomPanel.CreateHandle
> 
> { -------- Before }
> 
>   Frame := gtk_frame_new(nil);
>   gtk_frame_set_shadow_type(PGtkFrame(Frame),
>     BorderStyleShadowMap[TCustomControl(AWinControl).BorderStyle]);
> 
> { -------- After }
> 
>   Frame:=gtk_scrolled_window_new(nil, nil);
>   gtk_scrolled_window_set_shadow_type(PGtkScrolledWindow(Frame),
>     BorderStyleShadowMap[TCustomControl(AWinControl).BorderStyle]);
>   gtk_scrolled_window_set_policy(PGtkScrolledWindow(Frame),
> GTK_POLICY_NEVER, GTK_POLICY_NEVER);
> 
> After this change the problem project that looked identically (good) in
> Delphi and Win32 Lazarus and differently in GTK2 Lazarus (labels and panels
> at wrong positions) began to look consistent in linux.
> 
> So there are questions:
> - Can this patch be applied? Apart from obvious testing and checking, there
> is also a compatibility problem. After this change, the forms people
> designed in linux can start to look a little different (or even greatly if
> the nesting level of panels is deep). But as I noted in the report, without
> this change it's difficult to synchronize forms "visually".
> - Does using GtkFrame in LCL make sense at all? I did not look deeper, but
> at least quick search showed it was used several times.

1.It's changed to GtkFrame with r31280
LCL GTK2: Make Panel.OnPaint work. Patch from August Klein, issue #19488

I don't like to use GtkScrolledWin in place of simple widget. Can it be 
changed to something else (like pure GtkWindow and then draw border if needed) 
?



zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110701/fb2ee1ad/attachment-0003.html>


More information about the Lazarus mailing list