Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / gtk2 / 2009-12

autosize question

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Henry Vermaak

Hi gtk2 list

I realised today that the lcl doesn't react very well if you change the size of the system font. Autosized controls should react by invalidating and re-computing their size. I thought the best place to do this is GTKStyleChanged (using the style-set signal). It should be really simple, like calling InvalidatePreferredSize or something, but I can't get it to work (except if I call
gtk_widget_set_size_request(widget, -1, -1), but I doubt if that's the best thing to do). Can someone give me any hints, please?

Henry

Reply by email

Mattias Gaertner
to Henry Vermaak
Show quoted text 10 lines
Hi gtk2 list I realised today that the lcl doesn't react very well if you change the size of the system font. Autosized controls should react by invalidating and re-computing their size. I thought the best place to do this is GTKStyleChanged (using the style-set signal). It should be really simple, like calling InvalidatePreferredSize or something, but I can't get it to work (except if I call gtk_widget_set_size_request(widget, -1, -1), but I doubt if that's the best thing to do). Can someone give me any hints, please?
AControl.InvalidateClientRectCache(false);

Then send a WMSize message to the control.

Mattias

Reply by email

Henry Vermaak
to Mattias Gaertner

2009/12/8 Mattias Gaertner :

Show quoted text 17 lines
On Tue, 8 Dec 2009 17:15:22 +0000 Henry Vermaak wrote: > Hi gtk2 list > > I realised today that the lcl doesn't react very well if you change > the size of the system font. ?Autosized controls should react by > invalidating and re-computing their size. ?I thought the best place to > do this is GTKStyleChanged (using the style-set signal). ?It should be > really simple, like calling InvalidatePreferredSize or something, but > I can't get it to work (except if I call > gtk_widget_set_size_request(widget, -1, -1), but I doubt if that's the > best thing to do). ?Can someone give me any hints, please? AControl.InvalidateClientRectCache(false); Then send a WMSize message to the control.

Hmm, this works, but the resize seems to be one event behind. So the first resize does nothing, then the next one resizes to where the previous one should have been. I used ConnectSenderSignalAfter, but that didn't help.

Also, the labels don't obey the system font resize at all, any reason for that?

Henry

Reply by email

Mattias Gaertner
to Henry Vermaak
Show quoted text 23 lines
2009/12/8 Mattias Gaertner : > On Tue, 8 Dec 2009 17:15:22 +0000 > Henry Vermaak wrote: > >> Hi gtk2 list >> >> I realised today that the lcl doesn't react very well if you change >> the size of the system font. ?Autosized controls should react by >> invalidating and re-computing their size. ?I thought the best place to >> do this is GTKStyleChanged (using the style-set signal). ?It should be >> really simple, like calling InvalidatePreferredSize or something, but >> I can't get it to work (except if I call >> gtk_widget_set_size_request(widget, -1, -1), but I doubt if that's the >> best thing to do). ?Can someone give me any hints, please? > > AControl.InvalidateClientRectCache(false); > > Then send a WMSize message to the control. Hmm, this works, but the resize seems to be one event behind. So the first resize does nothing, then the next one resizes to where the previous one should have been. I used ConnectSenderSignalAfter, but that didn't help.

I don't know. Maybe you can create an example.

Also, the labels don't obey the system font resize at all, any reason for that?

Probably the font handles must be recreated.

Mattias

Reply by email

Henry Vermaak
to Mattias Gaertner

2009/12/8 Mattias Gaertner :

I don't know. Maybe you can create an example.

I've attached a simple diff.

Show quoted text 5 lines
> Also, the labels don't obey the system font resize at all, any reason for that? Probably the font handles must be recreated.

OK, I may need some more pointers for that, but I'll dig first.

Henry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: autosize.diff
Type: text/x-diff
Size: 1813 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/gtk2/attachments/20091208/61b51d08/attachment.bin>

Reply by email

Henry Vermaak
to Henry Vermaak

2009/12/8 Henry Vermaak :

Show quoted text 5 lines
2009/12/8 Mattias Gaertner : > > I don't know. Maybe you can create an example. I've attached a simple diff.

No luck with this, but I got it to work if I set a flag in the style-set and then check that flag in an event-after handler, invalidating and sending a size message as necessary. I just tested this with buttons, but it should be possible for a generic case. I'm just not sure what the best way is to integrate this into the lcl. Is this something you're interested in for the lcl?

Henry

Reply by email

Henry Vermaak
to Henry Vermaak

2009/12/9 Henry Vermaak :

Show quoted text 13 lines
2009/12/8 Henry Vermaak : > 2009/12/8 Mattias Gaertner : >> >> I don't know. Maybe you can create an example. > > I've attached a simple diff. No luck with this, but I got it to work if I set a flag in the style-set and then check that flag in an event-after handler, invalidating and sending a size message as necessary. ?I just tested this with buttons, but it should be possible for a generic case. ?I'm just not sure what the best way is to integrate this into the lcl. ?Is this something you're interested in for the lcl?

Any thoughts?

Reply by email

Mattias Gaertner
to Henry Vermaak
Show quoted text 16 lines
2009/12/9 Henry Vermaak : > 2009/12/8 Henry Vermaak : >> 2009/12/8 Mattias Gaertner : >>> >>> I don't know. Maybe you can create an example. >> >> I've attached a simple diff. > > No luck with this, but I got it to work if I set a flag in the > style-set and then check that flag in an event-after handler, > invalidating and sending a size message as necessary. ?I just tested > this with buttons, but it should be possible for a generic case. ?I'm > just not sure what the best way is to integrate this into the lcl. ?Is > this something you're interested in for the lcl? Any thoughts?

I added the event and some notes:

This event is called for many widgets but not for all. It is called on creation and called when the theme changes. The resizing should occur when all styles were updated by the gtk. The gtk itself uses size messages via queue.
Maybe the solution is to use g_idle_add for the top level form and resize.

Mattias

Reply by email