227 views
in GUI Development by
Hello,
I have a question, i would like to show the Content of the OutlineBox horizontaly Cnetred . Is this possible ?

Thanks for the answere

Cheers

Simon

1 Answer

0 votes
by

Hello Simon,

an automatic horizontal alignment in the Outline Box is possibly only when you set its property Formation to value e.g. Core::Formation.TopToBottom. Then you can configure the property Layout of all affected views to the value Core::Layout[AlignToLeft, AlignToRight]. Thereupon the Outline Box arranges the views automatically one below the other (according to the Formation property) and the views are centered horizontally (they are simultaneously aligned to the left and right edge of the outline box). For more details see:

Use Outline Box to arrange the views in rows and columns

Align and resize the automatically arranged views

If this approach is not sufficient for you, you will need to adjust the views manually. This means you calculate the position of each view so that it appears centered within the area of the Outline Box. For example:

someView.Bounds.x = Outline.Bounds.x + ( Outline.Bounds.w - someView.Bounds.w ) / 2;

or more sophisticated by using the instant property center and the compound assignment operator +=:

someView.Bounds.x += Outline.Bounds.center.x - someView.Bounds.center.x;

Does it help you further?

Best regards

Paul Banach

by

Hello Paul 

Thanks for your reply, unfortunately this is not what I am looking for, 
I think I have expressed myself wrong 

I would like to align the OutlineBox horizontally , not vertically 

I have created a short drawing for you. 

I would like to have if there is only one object centered in the outline box, if there are more objects the outline box should sort them automatically. OneObjekt in the Outline Box

If there is only one Objekt in the Outline Box 

 

If there are more objekts in the outline box 

 

i hope you can help me 

 

Thanks

Cheers

Simon 

 

by

Hello Simon,

now it's clear. In such case:

Step 1: You want the views to be automatically arranged horizontally side by side. For this purpose configure the property Formation of the Outline Box to e.g. Core::Formation.LeftToRight.

Step 2: From  the above drawings I suppose you want the view row to be centered vertically within the Outline Box. If this is the case configure for each view its property Layout to the value Core::Layout[AlignToBottom, AlignToTop].

Step 3: The exciting part: you want all views, as a group to appear arranged in the center of the Outline Box. This is achieved by adjusting the property ScrollOffset of the Outline Box. Following code calculates from the actual position of the Outline Box content and the Outline Box boundary area the necessary displacement:

Outline.ScrollOffset.x += ( Outline.Bounds.center.x - Outline.GetContentArea( Core::ViewState[]).center.x );

Step 4: If you want the above position adjustment to be executed automatically each time the content of the Outline Box is changed, then:

Step 4.A: Put the above code line within a new slot method named e.g. centerOutlineBox. The slot method centerOutlineBox contains thus following code only:

Outline.ScrollOffset.x += ( Outline.Bounds.center.x - Outline.GetContentArea( Core::ViewState[]).center.x );

Step 4.B: Add a further new slot method and name it e.g. onUpdateOutlineBox and implement it with following code:

postsignal centerOutlineBox;

Step 4.C: Assign the method onUpdateOutlineBox to the property OnUpdate of the Outline Box.

This will have the effect that each time the Outline Box updates its content, the method onUpdateOutlineBox is invoked. This thereupon invokes the method centerOutlineBox which adjusts the scroll position in the Outline Box. See also: 

Use Outline Box to scroll the embedded views

Enumerate and search views controlled by the Outline Box

Does t help you further?

Best regards

Paul Banach

 

by
Hi Paul

Great , thanks very mutch it works very well !

Cheers Simon

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...