Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Avishai
Thank you Mattias, every step is a help. :)



--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Centered-elements-in-autosize-enabled-panel-Possible-tp4034210p4034264.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Mattias Gaertner
On Mon, 11 Nov 2013 14:29:29 +0200
Avishai  wrote:

> I don't *think* that will work.  TBevel is TGraphicControl so it's not a
> "container".

You are right.

Then you must set Constraints.

Mattias


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Mattias Gaertner
On Mon, 11 Nov 2013 13:12:00 +0200
Avishai  wrote:

> Most of my applications are for RightToLeft (Hebrew) and TToolBar and

As a first step I implemented right aligning for
TToolBar.BidiMode=bdRightToLeft.

Switching the BidiMode does not alter the order of controls.


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Avishai
I don't *think* that will work.  TBevel is TGraphicControl so it's not a
"container".


On Mon, Nov 11, 2013 at 2:25 PM, Mattias Gaertner  wrote:

> On Mon, 11 Nov 2013 14:18:53 +0200
> Valdas Jankūnas  wrote:
>
> > 2013.11.11 13:14, Mattias Gaertner rašė:
> > > On Mon, 11 Nov 2013 12:51:14 +0200
> > > Valdas Jankūnas  wrote:
> > >
> > >> 2013.11.11 06:06, Avishai rašė:
> > >> [...]
> > >>I found why TBevel "doesn't want" shrink less than 50px: TBevel has
> > >> function "GetControlClassDefaultSize" where "Result.CY := 50;" is
> hardcoded.
> > >
> > > That's the default size of the control. The constraints are
> > > applied after.
> > >
> > > A TBevel can be shrinked to less than 50.
> >
> > It not shrinks when ChildSizing is being used (see screenshot).
>
> Your bevel has no content. Then the default size is used.
> Drop something into it.
>
> Mattias
>
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Mattias Gaertner
On Mon, 11 Nov 2013 14:18:53 +0200
Valdas Jankūnas  wrote:

> 2013.11.11 13:14, Mattias Gaertner rašė:
> > On Mon, 11 Nov 2013 12:51:14 +0200
> > Valdas Jankūnas  wrote:
> >
> >> 2013.11.11 06:06, Avishai rašė:
> >> [...]
> >>I found why TBevel "doesn't want" shrink less than 50px: TBevel has
> >> function "GetControlClassDefaultSize" where "Result.CY := 50;" is 
> >> hardcoded.
> >
> > That's the default size of the control. The constraints are
> > applied after.
> >
> > A TBevel can be shrinked to less than 50.
> 
> It not shrinks when ChildSizing is being used (see screenshot).

Your bevel has no content. Then the default size is used.
Drop something into it.

Mattias
 

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Mattias Gaertner
On Mon, 11 Nov 2013 12:51:14 +0200
Valdas Jankūnas  wrote:

> 2013.11.11 06:06, Avishai rašė:
>[...]
>   I found why TBevel "doesn't want" shrink less than 50px: TBevel has 
> function "GetControlClassDefaultSize" where "Result.CY := 50;" is hardcoded.

That's the default size of the control. The constraints are
applied after.

A TBevel can be shrinked to less than 50.


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Avishai
Most of my applications are for RightToLeft (Hebrew) and TToolBar and
TStatusBar don't support RightToLeft so I use this technique to make my
own.  I use the Align:= alLeft/alRight method though.  And I use TPanel for
dividers.


On Mon, Nov 11, 2013 at 12:51 PM, Valdas Jankūnas  wrote:

> 2013.11.11 06:06, Avishai rašė:
>
>  Could you use a TPanel in place of the TBevel?  I tried that and it  gives
>> the same visual effect without the size problems.  But I don't know what
>> you are doing with the TBevel.
>>
>
> Hello,
>
>  I use TBevel as separator (Shape=bsLeftLine) between components. I tried
> TPanel: looks good, also its Width  automatically adjusts to 2 when
> "CellAlighHorizontal" is set to other than "ccaFill".
>
>  Also I found how to rearrange Childs easily when "ChildSizing" is used:
> - Parent.ChildSizing set to "cclNone";
> - change "Z order" of Child;
> - revert back Parent.ChildSizing.
>
>  I found why TBevel "doesn't want" shrink less than 50px: TBevel has
> function "GetControlClassDefaultSize" where "Result.CY := 50;" is hardcoded.
>
>
> --
>   Valdas Jankūnas
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-11 Thread Valdas Jankūnas

2013.11.11 06:06, Avishai rašė:

Could you use a TPanel in place of the TBevel?  I tried that and it  gives
the same visual effect without the size problems.  But I don't know what
you are doing with the TBevel.


Hello,

 I use TBevel as separator (Shape=bsLeftLine) between components. I 
tried TPanel: looks good, also its Width  automatically adjusts to 2 
when "CellAlighHorizontal" is set to other than "ccaFill".


 Also I found how to rearrange Childs easily when "ChildSizing" is used:
- Parent.ChildSizing set to "cclNone";
- change "Z order" of Child;
- revert back Parent.ChildSizing.

 I found why TBevel "doesn't want" shrink less than 50px: TBevel has 
function "GetControlClassDefaultSize" where "Result.CY := 50;" is hardcoded.


--
  Valdas Jankūnas

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread Avishai
Could you use a TPanel in place of the TBevel?  I tried that and it  gives
the same visual effect without the size problems.  But I don't know what
you are doing with the TBevel.


On Mon, Nov 11, 2013 at 12:20 AM, Avishai  wrote:

> Well?  I forgot that I had set Constraints.MaxHeight:= 24 before I set b
> orderSpacing.Around:= 4.  Then I changed MaxHeight:= 20 and it went back
> to Height:= 50.
>
> Then I reset MaxHeight:= 24 and borderSpacing.Around:= 0 and it jumped
> back to a height of 24.  I don't think that's an answer.  I'll keep looking.
>
>
> On Mon, Nov 11, 2013 at 12:09 AM, Avishai  wrote:
>
>> Hmmm.  I tried setting TBevel .borderSpacing.Around:= 4 and it suddenly
>> "corrected" itself.  I'm not too sure I trust that approach but you can
>> play with it and see.
>>
>>
>> On Mon, Nov 11, 2013 at 12:01 AM, Valdas Jankūnas wrote:
>>
>>> 2013.11.10 23:03, Avishai rašė:
>>>
>>>  You can also use Constraints to set height/width of children with
 ChildSizing.

>>>
>>>  Forgot about that, thanks.
>>>
>>>  One problem left: when you add TBevel as child and if you want it
>>> BorderSpacing.CellAlignVertical=ccaFill (to make separator), you get
>>> fixed height (always 50). To fix this I must use custom TBevel with
>>> overridden "CalculatePreferredSize" with "PreferredHeight := 1;" in it.
>>>
>>>  Is there more elegant way?
>>>
>>>
>>> --
>>>   Valdas Jankūnas
>>>
>>> --
>>> ___
>>> Lazarus mailing list
>>> Lazarus@lists.lazarus.freepascal.org
>>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>>>
>>
>>
>>
>> --
>> Shalom,
>> Avishai
>> avishai.g...@gmail.com
>> אבישי גוֹר
>>
>
>
>
> --
> Shalom,
> Avishai
> avishai.g...@gmail.com
> אבישי גוֹר
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread Avishai
Well?  I forgot that I had set Constraints.MaxHeight:= 24 before I set b
orderSpacing.Around:= 4.  Then I changed MaxHeight:= 20 and it went back to
Height:= 50.

Then I reset MaxHeight:= 24 and borderSpacing.Around:= 0 and it jumped back
to a height of 24.  I don't think that's an answer.  I'll keep looking.


On Mon, Nov 11, 2013 at 12:09 AM, Avishai  wrote:

> Hmmm.  I tried setting TBevel .borderSpacing.Around:= 4 and it suddenly
> "corrected" itself.  I'm not too sure I trust that approach but you can
> play with it and see.
>
>
> On Mon, Nov 11, 2013 at 12:01 AM, Valdas Jankūnas wrote:
>
>> 2013.11.10 23:03, Avishai rašė:
>>
>>  You can also use Constraints to set height/width of children with
>>> ChildSizing.
>>>
>>
>>  Forgot about that, thanks.
>>
>>  One problem left: when you add TBevel as child and if you want it
>> BorderSpacing.CellAlignVertical=ccaFill (to make separator), you get
>> fixed height (always 50). To fix this I must use custom TBevel with
>> overridden "CalculatePreferredSize" with "PreferredHeight := 1;" in it.
>>
>>  Is there more elegant way?
>>
>>
>> --
>>   Valdas Jankūnas
>>
>> --
>> ___
>> Lazarus mailing list
>> Lazarus@lists.lazarus.freepascal.org
>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
>
>
>
> --
> Shalom,
> Avishai
> avishai.g...@gmail.com
> אבישי גוֹר
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread Avishai
Hmmm.  I tried setting TBevel .borderSpacing.Around:= 4 and it suddenly
"corrected" itself.  I'm not too sure I trust that approach but you can
play with it and see.


On Mon, Nov 11, 2013 at 12:01 AM, Valdas Jankūnas  wrote:

> 2013.11.10 23:03, Avishai rašė:
>
>  You can also use Constraints to set height/width of children with
>> ChildSizing.
>>
>
>  Forgot about that, thanks.
>
>  One problem left: when you add TBevel as child and if you want it
> BorderSpacing.CellAlignVertical=ccaFill (to make separator), you get
> fixed height (always 50). To fix this I must use custom TBevel with
> overridden "CalculatePreferredSize" with "PreferredHeight := 1;" in it.
>
>  Is there more elegant way?
>
>
> --
>   Valdas Jankūnas
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread Valdas Jankūnas

2013.11.10 23:03, Avishai rašė:

You can also use Constraints to set height/width of children with
ChildSizing.


 Forgot about that, thanks.

 One problem left: when you add TBevel as child and if you want it 
BorderSpacing.CellAlignVertical=ccaFill (to make separator), you get 
fixed height (always 50). To fix this I must use custom TBevel with 
overridden "CalculatePreferredSize" with "PreferredHeight := 1;" in it.


 Is there more elegant way?

--
  Valdas Jankūnas

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread Avishai
What I don't like about ChildSizing is if you need to change the order of
controls it can be difficult.  And here's something you should try.  Have a
TPanel as one of the Children - get everything set the way you want with
ChildSizing - now add a TLabel to the TPanel.

Using LeftAlign it's only a matter of dragging the control to the location
you want. BorderSpacing and Constraints gives me all the control I need (so
far - I'm still playing with it).


On Sun, Nov 10, 2013 at 11:03 PM, Avishai  wrote:

> You can also use Constraints to set height/width of children with
> ChildSizing.
>
>
> On Sun, Nov 10, 2013 at 10:43 PM, Valdas Jankūnas wrote:
>
>> 2013.11.10 18:24, William Oliveira Ferreira rašė:
>>
>>  I think you could also use anchors
>>>
>>
>> Anchors not helps if Parent.Autosize is True.
>>
>> I found better solution:
>> - Panel.AutoSize := True;
>> - Panel.ChildSizing.ControlsPerLine := MaxInt;
>> - Panel.ChildSizing.Layout := cclLeftToRightThenTopToBottom;
>> - Every Child.BorderSpacing.Left := 2;
>> - Every Child.BorderSpacing.CellAlignVertical := ccaCenter;
>> - Every Child.AutoSize := True;
>>
>>
>> If you want to adjust Child's Width (by default you cannot) then you must
>> use overridden procedure "CalculatePreferredSize" in class of that Child,
>> in which:
>>
>>inherited CalculatePreferredSize(PreferredWidth, PreferredHeight,
>> WithThemeSpace);
>>PreferredWidth := Width;
>>
>>
>>
>> --
>>   Valdas Jankūnas
>>
>> --
>> ___
>> Lazarus mailing list
>> Lazarus@lists.lazarus.freepascal.org
>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
>
>
>
> --
> Shalom,
> Avishai
> avishai.g...@gmail.com
> אבישי גוֹר
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread Avishai
You can also use Constraints to set height/width of children with
ChildSizing.


On Sun, Nov 10, 2013 at 10:43 PM, Valdas Jankūnas  wrote:

> 2013.11.10 18:24, William Oliveira Ferreira rašė:
>
>  I think you could also use anchors
>>
>
> Anchors not helps if Parent.Autosize is True.
>
> I found better solution:
> - Panel.AutoSize := True;
> - Panel.ChildSizing.ControlsPerLine := MaxInt;
> - Panel.ChildSizing.Layout := cclLeftToRightThenTopToBottom;
> - Every Child.BorderSpacing.Left := 2;
> - Every Child.BorderSpacing.CellAlignVertical := ccaCenter;
> - Every Child.AutoSize := True;
>
>
> If you want to adjust Child's Width (by default you cannot) then you must
> use overridden procedure "CalculatePreferredSize" in class of that Child,
> in which:
>
>inherited CalculatePreferredSize(PreferredWidth, PreferredHeight,
> WithThemeSpace);
>PreferredWidth := Width;
>
>
>
> --
>   Valdas Jankūnas
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread Valdas Jankūnas

2013.11.10 18:24, William Oliveira Ferreira rašė:

I think you could also use anchors


Anchors not helps if Parent.Autosize is True.

I found better solution:
- Panel.AutoSize := True;
- Panel.ChildSizing.ControlsPerLine := MaxInt;
- Panel.ChildSizing.Layout := cclLeftToRightThenTopToBottom;
- Every Child.BorderSpacing.Left := 2;
- Every Child.BorderSpacing.CellAlignVertical := ccaCenter;
- Every Child.AutoSize := True;


If you want to adjust Child's Width (by default you cannot) then you 
must use overridden procedure "CalculatePreferredSize" in class of that 
Child, in which:


   inherited CalculatePreferredSize(PreferredWidth, PreferredHeight, 
WithThemeSpace);

   PreferredWidth := Width;


--
  Valdas Jankūnas

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-10 Thread William Oliveira Ferreira
I think you could also use anchors
Em 09/11/2013 19:46, "Valdas Jankūnas"  escreveu:

> 2013.11.09 22:52, Avishai rašė:
>
>> OK.  I tried putting 2 Labels Align:= alLeft.  For both Labels I set
>> BorderSpacing Left and Right := 10 and Layout := tlCenter.  Then I set
>> Panel.AutoSize := True.  It looks like it does what you want.
>>
>
> It works! Even with autosized Buttons or Edits.
>
> Thanks!
>
>
> --
>   Valdas Jankūnas
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-09 Thread Avishai
Glad I could help :)


On Sat, Nov 9, 2013 at 11:13 PM, Valdas Jankūnas  wrote:

> 2013.11.09 22:52, Avishai rašė:
>
>> OK.  I tried putting 2 Labels Align:= alLeft.  For both Labels I set
>> BorderSpacing Left and Right := 10 and Layout := tlCenter.  Then I set
>> Panel.AutoSize := True.  It looks like it does what you want.
>>
>
> It works! Even with autosized Buttons or Edits.
>
> Thanks!
>
>
> --
>   Valdas Jankūnas
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-09 Thread Valdas Jankūnas

2013.11.09 22:52, Avishai rašė:

OK.  I tried putting 2 Labels Align:= alLeft.  For both Labels I set
BorderSpacing Left and Right := 10 and Layout := tlCenter.  Then I set
Panel.AutoSize := True.  It looks like it does what you want.


It works! Even with autosized Buttons or Edits.

Thanks!


--
  Valdas Jankūnas

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-09 Thread Avishai
OK.  I tried putting 2 Labels Align:= alLeft.  For both Labels I set
BorderSpacing Left and Right := 10 and Layout := tlCenter.  Then I set
Panel.AutoSize := True.  It looks like it does what you want.



--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Centered-elements-in-autosize-enabled-panel-Possible-tp4034210p4034212.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-09 Thread Avishai
Have you tried using BorderSpacing?  I think you can get what you want using
Left and Right BorderScaping.  I'll give it a try.



--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Centered-elements-in-autosize-enabled-panel-Possible-tp4034210p4034211.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Centered elements in autosize enabled panel. Possible?

2013-11-09 Thread Valdas Jankūnas

Hello,

I want to create this layout:
- form has a Panel;
- "Autosize" of Panel is True;
- Panel has Controls with various heights;
- every Control in Panel must be centered vertically.

I tried this (trough Anchor editor):
- Control2 centered to Control1;
- Control1 centered to Panel.
But then Panel shrinks to Height=2 (circular align happens?).

Is it possible to create mentioned layout (preferably not through code)?


Sorry for bad English.

--
  Valdas Jankūnas

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus