Recent

Author Topic: bgracontrols TBCButton caption align on left side?  (Read 523 times)

Antek

  • New Member
  • *
  • Posts: 10
bgracontrols TBCButton caption align on left side?
« on: December 20, 2025, 07:10:17 pm »
Hello,

Is it possible or is there a property to set caption (and icon/glyph) to align on left side?

I checked all properties and examples. I used latest repo.

Attached picture shows that all captions are centered (except autosize and long captions)

Thank you

jamie

  • Hero Member
  • *****
  • Posts: 7519
Re: bgracontrols TBCButton caption align on left side?
« Reply #1 on: December 21, 2025, 12:36:03 am »
I looked at that control, and it does not look like there is a easy solution to perform a local hack without just about rewriting it which I for one am not doing! :o

 However, you could add spaces at the end of the Captions but if you don't use a fixed type of font, it may not be exact.

 There should be a Text alignment property but there is not.

 But, since you have the BGRABitmap already in place you could make your own buttons with some extra work that render at run-time.
   The idea is to use a standard platform control like a TPaintBox for example or a TPanel and direct all the OnPaint code to a single block of code that will draw a common surface for you.
  At design time this will look like blan looking but at runtime it will fill in. You can use the BGRABitmap and related items to do so.
  I suppose you could even pound out an example of such.


Jamie
 
The only true wisdom is knowing you know nothing

Josh

  • Hero Member
  • *****
  • Posts: 1454
Re: bgracontrols TBCButton caption align on left side?
« Reply #2 on: December 21, 2025, 02:14:37 am »
Hi

In the OI
Setting the following should get you close

GlyphAlignment=bcaLeftCenter
GlyphMargin=5
GlyphOldPlacement=False

StateNormal.Fontex.TextAlignment=bcaLeftCenter
StateNormal.Fontex.PaddingLeft=8
StateHover.Fontex.TextAlignment=bcaLeftCenter
StateHover.Fontex.PaddingLeft=8
StateClicked.Fontex.TextAlignment=bcaLeftCenter
StateClicked.Fontex.PaddingLeft=8
« Last Edit: December 21, 2025, 02:39:29 am by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

jamie

  • Hero Member
  • *****
  • Posts: 7519
Re: bgracontrols TBCButton caption align on left side?
« Reply #3 on: December 21, 2025, 02:51:23 am »
I didn't want to suck in large controls like that in a 32-biit app because I only needed one special type of shape.

if you drop a Tshape on the form and set its pen and bush to clear so they don't show
you can make a shinning button like this.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Shape1: TShape;
  16.     procedure Shape1Paint(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.  
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.Shape1Paint(Sender: TObject);
  33. var
  34.   B,C:TBitmap;
  35.   PC,PB:PDword;
  36.   I:Integer;
  37. begin
  38.   With Sender as TShape do
  39.   Begin
  40.     B:= TBitmap.Create;
  41.     B.PixelFormat := pf32bit;
  42.     B.SetSize(width,height);
  43.     B.Canvas.GradientFill(Rect(0,0,Width,Height shr 1),clgray,clwhite,gdVertical);
  44.     B.Canvas.GradientFill(Rect(0,Height shr 1,Width,Height),clWhite,clgray,gdVertical);
  45.     C:= TBitmap.create;
  46.     C.PixelFormat := pf32bit;
  47.     C.SetSize(width, height);
  48.     C.canvas.Brush.Color := clWhite;
  49.     C.canvas.RoundRect(0,0,width,height,10,10);
  50.     {First change all black to non black}
  51.     PC := PDWord(C.RawImage.Data);
  52.     PB := PDword(B.RawImage.Data);
  53.     C.BeginUpdate;
  54.     For I :=0 to (C.RawImage.DataSize div sizeOf(Dword))- 1 do
  55.      begin
  56.        If PC^ <> 0 Then PC^ := PB^+$FF000000;
  57.        Inc(PC);
  58.        Inc(PB);
  59.      end;
  60.     C.EndUpdate;
  61.     Canvas.Draw(0,0,C);
  62.     C.Free;
  63.     Canvas.Font.Color := clBlack;
  64.     canvas.Brush.style := bsClear;
  65.     Canvas.Font.Size := 15;
  66.     canvas.Textout(24,0,'Test');
  67.     Canvas.Font.Color := ClGray;
  68.     canvas.Textout(23,-1,'Test');
  69.     canvas.Draw(5,Height div 4,Application.Icon);
  70.     B.Free;
  71.   end;
  72. end;
  73.  
  74. end.
  75.  
  76.  

In my actual code i used a Tpaintbox and what i was going for was a flat circular gimbal where I could press with the mouse any area on the radius and draw it as an indention for direction control.

 I did code like above in the Paint Handler, I only needed one control like this.

 You can in fact have multiple TPainBoxes with their Paint handler directed to this, so you only need to repeat it once.

It's just an idea; it generates less bloat in the end. In my case I didn't a caption, this was just a test.

Jamie
The only true wisdom is knowing you know nothing

Antek

  • New Member
  • *
  • Posts: 10
Re: bgracontrols TBCButton caption align on left side?
« Reply #4 on: December 22, 2025, 02:33:47 pm »
Thank you for the answers!

I checked and tested the properties mentioned by Josh.
I 'll using this approach.  Thank you!

 

 

TinyPortal © 2005-2018