Scaling TRzToolButton for high DPI

Components on the Raize Buttons palette: buttons, menu buttons, spin buttons, tool buttons, check boxes, radio buttons, shape buttons, etc.

Scaling TRzToolButton for high DPI

Postby Marek » Mon Dec 12, 2016 3:39 pm

Hello Ray,

I use in my manifest file "<dpiAware>True/PM</dpiAware>", it means I make the scaling self.
Unfortunatelly it is not possible to right scale the TRzToolButton. The arrow region has fixed width.
It would be nice for the next release to make it defineable.
I have for me the following solution:

1. Add const:
Code: Select all
ArrowWidth = 4;

2. Add protected functions:
Code: Select all
function GetArrowRegionWidth: integer; virtual;   
    function GetArrowWidth: integer; virtual;

Code: Select all
function TRzToolButton.GetArrowRegionWidth: integer; 
begin
   result := ArrowRegionWidth;
end;

function TRzToolButton.GetArrowWidth: integer;   
begin
  result := ArrowWidth;
end;

3. Change all occurrences of the const ArrowRegionWidth to GetArrowRegionWidth()
4. Change the DrawTriangle procedure
Code: Select all
halfArrowWidth := Min( GetArrowWidth, GetArrowRegionWidth) div 2;
    if UseRightToLeftAlignment then
      X := (GetArrowRegionWidth div 2) - 1
    else
      X := ClientRect.Right - ((GetArrowRegionWidth div 2) - 1);
    Y := ClientRect.Top + ( ClientRect.Bottom - ClientRect.Top ) div 2 + 2;
    if ( FVisualStyle <> vsGradient ) and ( FState in [ tbsDown, tbsDropDown ] ) then
    begin
      Inc( X );
      Inc( Y );
    end;
    Canvas.Polygon( [ Point( X, Y ), Point( X - halfArrowWidth, Y - halfArrowWidth ), Point( X + halfArrowWidth, Y - halfArrowWidth ) ] );

//    if UseRightToLeftAlignment then
//      X := 6
//    else
//      X := ClientRect.Right - 8;
//    Y := ClientRect.Top + ( ClientRect.Bottom - ClientRect.Top ) div 2 + 2;
//    if ( FVisualStyle <> vsGradient ) and ( FState in [ tbsDown, tbsDropDown ] ) then
//    begin
//      Inc( X );
//      Inc( Y );
//    end;
//    Canvas.Polygon( [ Point( X, Y ), Point( X - 2, Y - 2 ), Point( X + 2, Y - 2 ) ] );
Thanks,
Marek
Marek
 
Posts: 44
Joined:
Wed Apr 13, 2011 7:09 am

Re: Scaling TRzToolButton for high DPI

Postby Raize Support » Mon Dec 12, 2016 3:45 pm

Thanks for the report and suggestion. I'll be sure to pass this information along to Embarcadero.

Ray
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 603
Joined:
Fri Mar 25, 2011 9:04 pm


Return to Buttons

Who is online

Users browsing this forum: No registered users and 1 guest

cron