View Issue Details

IDProjectCategoryView StatusLast Update
0012343LazarusLCLpublic2019-02-24 13:13
ReporterMarius Assigned ToBart Broersma  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version0.9.27 (SVN) 
Summary0012343: TCheckbox.Alignment is mising
DescriptionCheckbox Alignment (taLeftJustify, taRightJustify) is missing. We have a few projects where we need the check on the right instead of left
Tagspatch
Fixed in Revisionr47030
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0027106 closedJuha Manninen [New] TCheckBoxThemed 
related to 0019303 acknowledged BiDi meta issue 
related to 0023919 closedZeljan Rikalo Wrong TCheckBox.Caption on 2 lines 

Activities

2009-02-03 17:00

 

checkbox_alignment.patch (2,193 bytes)   
Index: include/customcheckbox.inc
===================================================================
--- include/customcheckbox.inc	(revision 18542)
+++ include/customcheckbox.inc	(working copy)
@@ -81,6 +81,13 @@
   end;
 end;
 
+procedure TCustomCheckBox.SetAlignment(const AValue: TLeftRight);
+begin
+  if FAlignment = AValue then exit;
+  FAlignment := AValue;
+  Perform(CM_BIDIMODECHANGED, 0, 0);
+end;
+
 {------------------------------------------------------------------------------
   Method: TCustomCheckBox.Create
   Params:  TheOwner: the owner of the class
@@ -172,6 +179,11 @@
   SetChecked(not GetChecked);
 end;
 
+function TCustomCheckBox.UseRightToLeftAlignment: Boolean;
+begin
+  Result := inherited UseRightToLeftAlignment xor (FAlignment = taRightJustify);
+end;
+
 {------------------------------------------------------------------------------
   Method: TCustomCheckBox.ApplyChanges
   Params: none
Index: stdctrls.pp
===================================================================
--- stdctrls.pp	(revision 18542)
+++ stdctrls.pp	(working copy)
@@ -1141,9 +1141,11 @@
 
   TCustomCheckBox = class(TButtonControl)
   private
+    FAlignment: TLeftRight;
     FAllowGrayed: Boolean;
     FState: TCheckBoxState;
     FShortCut: TShortcut;
+    procedure SetAlignment(const AValue: TLeftRight);
     procedure SetState(Value: TCheckBoxState);
     function GetState: TCheckBoxState;
     procedure DoChange(var Msg); message LM_CHANGED;
@@ -1163,8 +1165,10 @@
     procedure TextChanged; override;
   public
     constructor Create(TheOwner: TComponent); override;
+    function UseRightToLeftAlignment: Boolean; override;
   public
     property AutoSize default true;
+    property Alignment: TLeftRight read FAlignment write SetAlignment default taLeftJustify;
     property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed default false;
     property State: TCheckBoxState read GetState write SetState default cbUnchecked;
     property TabStop default true;
@@ -1176,6 +1180,7 @@
   published
     property Action;
     property Align;
+    property Alignment;
     property AllowGrayed;
     property Anchors;
     property AutoSize;
checkbox_alignment.patch (2,193 bytes)   

Alexander S. Klenin

2009-02-03 17:05

developer   ~0025062

Attached patch implements Alignment.
It requires to either add new type definition
  TLeftRight = taLeftJustify..taRightJustify;
to some place in Lazarus or
to uncomment corresponding line in FPC's classesh.inc.

I am not sure why it is commented there.

Paul Ishenin

2009-02-04 09:08

manager   ~0025091

1. I looked at gtk2 and qt. There is no way to set alignment except using the same approach as with changing of BidiMode
2. What you want to achieve can be done using BidiMode property

I see no reason to invent a new property even for delphi compatibility here.

Why do you need it?

Alexander S. Klenin

2009-02-04 10:36

developer   ~0025097

Last edited: 2009-02-04 10:39

Heh, it seems that today is not my day for Lazarus bugs acceptance ;-)
Anyway, reasons:
1) Delphi compatibility. As said by original reporter,
  it is a nuisance while migrating Delphi projects. I encountered it too,
  hence decided to fix it.
2) Semantic difference. Alignment is an item-specific, aesthetic/visual option,
  while BidiMode is project-wide, linguistic option.
  The fact that one is using another under the hood
  is an implementation detail -- if Alignment would be implemented first,
  it would be vice versa.
3) Conceptual simplicity.
  Alignment is a very simple concept immediately obvious to any developer.
  BidiMode is rather complicated: it currently has four options,
  at least two of them hard to understand both for me and, probably,
  for any non-Arabic-speaking developer.

Last but not least, why was original report acknowledged if
the feature is deemed useless?
You should have discussed the same with original reporter.

Vincent Snijders

2009-04-26 16:40

manager   ~0027106

> Last but not least, why was original report acknowledged if
the feature is deemed useless?

It was acknowledged, because I did not know why I should reject it immediately. Paul gave some good reasons. Should I reject it now, or shall we wait to if somebody finds a way to implement it on gtk2 and qt.

Zeljan Rikalo

2009-04-26 18:29

developer   ~0027107

It cannot be implemented under qt, I've already asked ppl from trolltech.
They point me to change bidi mode.

Marius

2010-11-01 10:10

reporter   ~0042534

Bugger. If it really cannot be done under all platforms with the standard component the tcheckbox should be replaced with one that is a compound using a seperate label and a checkbox (without caption). I don't like this solution much but its the only solution that is really platform independent..

Zeljan Rikalo

2010-11-01 10:17

developer   ~0042538

No it cannot, maybe only win32 supports this, others should be heavy hacked to have such behaviour.
So solution is to invent new component, or to implement it for win32 only and mark other ws as mission impossible.

Avishai

2011-06-07 07:36

reporter   ~0048906

I realize this is an old post and it sounds as though it was decided to rewrite the TCheckBox component. But the suggestion of using BiDiMode is not a good one. Please keep in mind that if BiDiMode:= bdRightToLeft and the caption is not a RightToLeft language, it effects punctuation placement. If the last char is punctuation, it will be displayed incorrectly. The same is true when BiDiMode:= bdLeftToRight and a RightToLeft language is used.

Zeljan Rikalo

2014-09-27 20:08

developer   ~0077751

If all widgetsets implement drawing of themed checkbox then some can create TCheckBoxEx (like we have TComboBoxEx in trunk), based on TCustomControl and our own painting.

Bart Broersma

2014-11-05 18:43

developer   ~0078923

Yes, maybe a good idea to implement TCheckBoxEx, but maybe it is not a bad idea to implement Alignement (not using bidi-mode), for Windows WS _and_ mark it a restricted property.
This way converting Delphi apps for Windows won't suffer.

Zeljan Rikalo

2014-11-05 20:53

developer   ~0078926

I'm not against such solution.

Bart Broersma

2014-11-22 15:41

developer   ~0079285

Implemented TCustomCheckBox.Alignment for win32/wince in r46963.
Please test.
Not resolving yet, since we may want to have TCustomCheckBoxEx to handle this for every widgetset.

Bart Broersma

2014-12-03 17:43

developer   ~0079602

In r47030 the new TCheckBoxThemed implements Alignment for all WidgetSets.
(As discussed before, this cannot be done natively for all WS for TCustomCheckBox)

Juha Manninen

2014-12-03 18:48

developer   ~0079606

Ok, it was a happy coincidence the. I did not think of this issue when committing the new component.
I guess the name doesn't matter because there is no Delphi compatibility involved now.

Issue History

Date Modified Username Field Change
2008-10-11 12:09 Marius New Issue
2008-10-11 12:09 Marius Widgetset => Win32
2008-10-17 21:36 Vincent Snijders LazTarget => post 1.2
2008-10-17 21:36 Vincent Snijders Status new => acknowledged
2009-02-03 17:00 Alexander S. Klenin File Added: checkbox_alignment.patch
2009-02-03 17:05 Alexander S. Klenin Note Added: 0025062
2009-02-04 09:08 Paul Ishenin Note Added: 0025091
2009-02-04 10:36 Alexander S. Klenin Note Added: 0025097
2009-02-04 10:39 Alexander S. Klenin Note Edited: 0025097
2009-04-26 16:40 Vincent Snijders Note Added: 0027106
2009-04-26 18:29 Zeljan Rikalo Note Added: 0027107
2010-11-01 10:10 Marius Note Added: 0042534
2010-11-01 10:17 Zeljan Rikalo Note Added: 0042538
2011-05-06 22:35 Juha Manninen Relationship added related to 0019303
2011-06-07 07:36 Avishai Note Added: 0048906
2013-09-03 12:07 Martin Friebe LazTarget post 1.2 => 1.4
2014-09-10 17:59 Juha Manninen LazTarget 1.4 => -
2014-09-13 13:32 Juha Manninen Tag Attached: patch
2014-09-27 20:08 Zeljan Rikalo Note Added: 0077751
2014-09-28 12:47 Zeljan Rikalo Relationship added related to 0023919
2014-11-05 18:43 Bart Broersma Note Added: 0078923
2014-11-05 20:53 Zeljan Rikalo Note Added: 0078926
2014-11-22 15:41 Bart Broersma Note Added: 0079285
2014-12-03 17:43 Bart Broersma Fixed in Revision => r47030
2014-12-03 17:43 Bart Broersma Note Added: 0079602
2014-12-03 17:43 Bart Broersma Status acknowledged => resolved
2014-12-03 17:43 Bart Broersma Resolution open => fixed
2014-12-03 17:43 Bart Broersma Assigned To => Bart Broersma
2014-12-03 17:43 Bart Broersma Assigned To Bart Broersma =>
2014-12-03 18:45 Juha Manninen Relationship added related to 0027106
2014-12-03 18:48 Juha Manninen Note Added: 0079606
2014-12-04 15:15 Maxim Ganetsky Assigned To => Bart Broersma