Recent

Author Topic: SCALE Form  (Read 2926 times)

seghele0

  • Full Member
  • ***
  • Posts: 173
SCALE Form
« on: December 30, 2021, 04:15:15 pm »
Scale '+' and '-' work, but there's a problem with the StringGrid.
When expanding the Form, extra blank space is added to the right and bottom of the StringGrid.
Can this be solved?
 :-[

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3.  
  4. interface
  5.  
  6. uses
  7.   Classes, SysUtils, FileUtil, Forms, Controls,
  8.   Graphics, Dialogs, StdCtrls, Grids, Buttons;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.   TForm1 = class(TForm)
  14.         ButtonPLUSscale: TButton;
  15.         ButtonMINdscale: TButton;
  16.         Label1: TLabel;
  17.         ButtonEXIT: TSpeedButton;
  18.         StringGrid1: TStringGrid;
  19.         procedure ButtonPLUSscaleClick(Sender: TObject);
  20.         procedure ButtonMINdscaleClick(Sender: TObject);
  21.         procedure ButtonEXITClick(Sender: TObject);
  22.  
  23.   private
  24.   public
  25.  
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.  
  31. implementation
  32.  
  33. {$R *.lfm}
  34.  
  35. procedure TForm1.ButtonPLUSscaleClick(Sender: TObject);
  36. begin
  37.     ScaleBy(125, 100);
  38. end;
  39.  
  40. procedure TForm1.ButtonMINdscaleClick(Sender: TObject);
  41. begin
  42.     ScaleBy(100, 125);
  43. end;
  44.  
  45. procedure TForm1.ButtonEXITClick(Sender: TObject);
  46. begin
  47.    Close;
  48. end;
  49.  
  50. end.
  51.  

dsiders

  • Hero Member
  • *****
  • Posts: 1078
Re: SCALE Form
« Reply #1 on: December 30, 2021, 05:20:57 pm »
Try setting TStringGrid.AutoFillColumns to True, tweaking properties for defined Columns, or setting ColWidths.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

seghele0

  • Full Member
  • ***
  • Posts: 173
Re: SCALE Form
« Reply #2 on: December 30, 2021, 05:39:29 pm »
Thank you for the info.
The Columns are fine now, but what about the rows, the space below the grid is still growing after '+' scaling.
 :(

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: SCALE Form
« Reply #3 on: December 30, 2021, 07:59:06 pm »
The problem with this kind of scaling is that it is not supported by the components internally, it does not scale internal dimensions at all, only those which are defined in a relative way or which depend on font size.

The attached demo is based on yours, it keeps the colwidths unchanged as designed. Note that when you click on "+25%" everything increases, except for the colwidths because the grid does not know that it should draw itself in a rescaled manner. The rowheights do increase, though, because the default rowheight depends on the font height which is scaled by your approach. But put in constant values for the row heights (by checking on the "fixed row heights" box) and you will see the row heights not changing any more.

Other controls have similar issues. Have a look at the toolbar. The size of the buttons is given by the ButtonHeight and ButtonWidth properties. But since these do not know that they should be scaled the size of the toolbuttons does not change.

Or the checkbox which does not scale the checkbox glyph and even disturbes the AutoSize calculation so that the text is truncated at large magnifications.

The only way to get around these issues is to touch every component at runtime whenever you call ScaleBy and adjust these "inner dimensions".

What do you want to achieve with this kind of scaling? Increase everything for impaired users? In this case, it is not only your application which has a too-small font, but also others. Why don't you use to tools that the OS has for this purpose? Simply change the pixel density settings of your monitor. This leads to LCLScaling well-supported by the LCL.

seghele0

  • Full Member
  • ***
  • Posts: 173
Re: SCALE Form
« Reply #4 on: December 31, 2021, 10:12:12 am »
dsiders , wp:
Thanks for the detailed information.
What I want to achieve is to create the possibility to increase the visibility of my application.
This is due to a disease of my eyes (macular degeneration).
My eyes don't have the same need for larger fonts every day, this varies.
Also my age of 72 plays a role.
 :-[
Will read and test everything ( your code) again next week.
 ;)
I wish you a happy new year with special thanks for your information and source code.

 

TinyPortal © 2005-2018