Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-09 Thread Bo Berglund via fpc-pascal
On Thu, 8 Jan 2026 11:51:15 +0100, Mattias Gaertner via fpc-pascal
 wrote:

>
>
>On 1/8/26 11:42, Bo Berglund via fpc-pascal wrote:
>>[...]
>> When I say autosize does not work I mean that the size changes but it does 
>> not
>> include the value part, which is what extends the text size...
>
>Have you checked the checkbox' Constraints?
>
>Or maybe there is another control overlapping?
>
>Mattias

I have never looked at the property "Constraints" before, but when I check (in
the Lazarus IDE) I see these:

Maxheight   0
MaxWidth0
MinHeight   0
MinWith 0

I assume that with these set to zero the entire group of properties is disabled?
Anyway, these are the defaults from when I added the component on the form.

And there is nothing close to the checkbox either.

Other properties of the checkbox:
Align = alNone
Alignment = taRightJustify
Anchors = [akTop, akLeft]
AutoSize = true

Parent_xxx are all True

And as I said it works as expected on Windows, fails on Linux (Ubuntu 24.04 With
MINT desktop)

Question:

Is there some "refresh" method available for the checkbox, which will re-draw it
on screen?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-08 Thread Mattias Gaertner via fpc-pascal




On 1/8/26 11:42, Bo Berglund via fpc-pascal wrote:

[...]
When I say autosize does not work I mean that the size changes but it does not
include the value part, which is what extends the text size...


Have you checked the checkbox' Constraints?

Or maybe there is another control overlapping?

Mattias

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-08 Thread Bo Berglund via fpc-pascal
On Wed, 7 Jan 2026 13:59:13 +0100, Mattias Gaertner via fpc-pascal
 wrote:

>
>
>On 1/6/26 21:52, Bo Berglund via fpc-pascal wrote:
>>[...]
>> On Windows the control expands in size to show the paramater added after the
>> function text (which is always shown).
>> But on Linux it does not expand enough to show the complete text, only the 
>> first
>> digit of the number is visible.
>> So it does try but fails to get it right (too small)...
>
>TCheckBox is used all over the the IDE and autosize works on all platforms.
>Do you have an example?
>
>Mattias

This is the actual event handler that activates the value and shows it on
screen:

procedure TfrmMain.ckbShiftAudioChange(Sender: TObject);
var
  bShowLipsync: boolean;
begin
  //Alternate function for audio delay handling with indication
  //of actual state on the control caption itself
  AudioShiftVal := 0; //Default value in global variable
  bShowLipsync := ckbShiftAudio.Checked;
  if bShowLipsync then
AudioShiftVal := speAudio.Value;
//Alternate placement of value in separate TStaticText container:  
//stxShiftAudio.Caption := IntToStr(AudioShiftVal);
  TCheckBox(Sender).Caption := 'Shift Audio: ' + IntToStr(AudioShiftVal);
  vlcPlayer.SetAudioDelay(AudioShiftVal *1000);
end;

The ckbShiftAudio checkbox is set to Autosize and it works fine on Windows but
not on Linux...
The altaernate way where the checkbox properties are not touched in this
OnChange event is to add a TStaticText item to the right of the checkbox and
write the value into that, but that has other problems:
- Where to place it so it sits adjacent to the checkbox in both environments
- How to get the same font size on the controls

When I have adjusted this on Windows it works fine too, but again fails on Linux
in a different way sice there are then control overlaps and also font size
differences

As you can see the actual working function is just to read another control
having the value to use and set the system up to use it. This works on both
Windows and Linux functionally.
But the display to the user is different on the platforms and essentially
unusable on Linux.

This is so strange, I have made several applications which use the same code via
SVN on both platforms and "just works" in both places.
But not so for this seemingly simple task...

Note:
When I say autosize does not work I mean that the size changes but it does not
include the value part, which is what extends the text size...
So typically I can see the first char of the value (often the sign) but then the
checkbox caption ends and no more is visible.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-07 Thread Mattias Gaertner via fpc-pascal




On 1/6/26 21:52, Bo Berglund via fpc-pascal wrote:

[...]
On Windows the control expands in size to show the paramater added after the
function text (which is always shown).
But on Linux it does not expand enough to show the complete text, only the first
digit of the number is visible.
So it does try but fails to get it right (too small)...


TCheckBox is used all over the the IDE and autosize works on all platforms.
Do you have an example?

Mattias

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-07 Thread Martin Wynne via fpc-pascal

On 07/01/2026 09:39, Bo Berglund via fpc-pascal wrote:

Still not working:
Error: Identifier not found: GetTextSize


Hi,

It relates to the widget set and destination platform.

Try this instead:

  with checkbox do begin
   AutoSize:=False;
   Caption:='new text';
   Width:=Canvas.TextWidth(Caption)+30;
  end;

Which is working fine here.

cheers,

Martin.
___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-07 Thread Bo Berglund via fpc-pascal
On Tue, 6 Jan 2026 23:50:43 +, Martin Wynne via fpc-pascal
 wrote:

>On 06/01/2026 23:15, Bo Berglund via fpc-pascal wrote:
>> Did not work:
>> 
>> Error: Identifier not found "ControlCanvas"
>> 
>> Where is this item declared?
>
>Sorry, that was Delphi code for Windows. In Lazarus for cross-platform 
>do this:
>
>uses
>   LCLIntf;
>
>var
>   w,h:integer;
>
>begin
>   with checkbox do begin
>AutoSize:=False;
>Caption:='new text';
>GetTextSize(Font,Caption,w,h);
>Width:=w+30;
>   end;
>
>
Tested but:

Still not working:
Error: Identifier not found: GetTextSize

Does this depend on something outside of Lazarus?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-06 Thread Martin Wynne via fpc-pascal



This is better:

  with checkbox do begin
   AutoSize:=False;
   Caption:='new text';
   Width:=Canvas.TextWidth(Caption)+30;
  end;

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-06 Thread Martin Wynne via fpc-pascal

On 06/01/2026 23:15, Bo Berglund via fpc-pascal wrote:

Did not work:

Error: Identifier not found "ControlCanvas"

Where is this item declared?


Sorry, that was Delphi code for Windows. In Lazarus for cross-platform 
do this:


uses
  LCLIntf;

var
  w,h:integer;

begin
  with checkbox do begin
   AutoSize:=False;
   Caption:='new text';
   GetTextSize(Font,Caption,w,h);
   Width:=w+30;
  end;


Martin.
___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-06 Thread Bo Berglund via fpc-pascal
On Tue, 6 Jan 2026 21:33:27 +, Martin Wynne via fpc-pascal
 wrote:

>Hi,
>
>Suggest:
>
>with checkbox do begin
>
>Autosize:=False;
>Caption:='new text';
>Width:=ControlCanvas.TextWidth(Caption);
>
>end;
>
>Martin.

Did not work:

Error: Identifier not found "ControlCanvas"

Where is this item declared?

-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-06 Thread Martin Wynne via fpc-pascal

Hi,

Suggest:

with checkbox do begin

Autosize:=False;
Caption:='new text';
Width:=ControlCanvas.TextWidth(Caption);

end;

Martin.

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] How to make TCheckBox autosize work correctly on Linux?

2026-01-06 Thread Bo Berglund via fpc-pascal
I have an application for video editing/viewing which I started back around
2019.
I use it daily and have improved it over time to streamline its use.

Now I have run into a problem concerning the display of TCheckbox objects:

I have used regular buttons in the past for two parameter setting/activation
functions but changed to use TCheckBox because then I can then show the state of
the parameter (active/inactive) as well as its value.

So when I click the checkbox active there is a checkmark shown so I see its
active state.
When activating the parameter I write the new value (integer) to the end of the
caption so the value is shown.
I have set the Autosize property to True so the control resizes to fit the new
longer text.

This works fine on Windows but when I build the project on Linux (Ubuntu Server
24.04 with the MATE desktop added) it worked fine before I did the switch to use
TCheckBox rather than TButton controls.

On Windows the control expands in size to show the paramater added after the
function text (which is always shown).
But on Linux it does not expand enough to show the complete text, only the first
digit of the number is visible.
So it does try but fails to get it right (too small)...


It seems like Lazarus/FPC is unable to figure out the correct size to use for
the control in the Autosize operation

How can I correct this such that it expands fully to show the added text like it
does on Windows? Is there a command I can use at the end of the code that runs
when the checkbox is clicked and the caption is modified to force it to show the
full text?

My devtool versions are :
FPC: 3.2.2
Lazarus: 4.2
OS: Windows 11 / Ubuntu 24.04 Server + MATE desktop

The project is the same on both Linux and Windows, I use Subversion to keep the
versions on both platforms the same.

I have a function that runs on startup if on UNIX (ifdef-ed) which modifies some
parameters which differ between the operating systems.

I could add something there if needed but I don't know what to use in order to
make these controls behave.

TIA

-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal