cancel
Showing results for 
Search instead for 
Did you mean: 

Same spacing in different TransparentContainer

matteo_montalto
Contributor
0 Kudos

Hi everybody,

I'd like to understand if there's a solution regarding an "issue" I faced many times working on WD Abap development.

Consider the following layout: 2 different TransparentContainer elements, Matrixlayout, the second one has Layout data property set as MatrixHeadData.

Now, suppose that each TransparentContainer is itself split (50% and 50%) in two different TC; in this way we're trying to create two different columns inside the root TransparentContainer.


So far the schema is:

TRANSPARENTCONTAINER_1 (MatrixLayout)
TC_1_LEFT TC_1_RIGHT (MatrixData)
TRANSPARENTCONTAINER_2 (MatrixLayout, MatrixHeadData)
TC_2_LEFTTC_2_RIGHT (MatrixData)

Now, suppose that in each "sub"transparentContainer we add some couples label - inputfield.

What we have is basically shown in the attached screenshot.

Notice that all the couples in a single "subTC" share the same alignment, so that the inputField are all correctly aligned.

The "issue" is that obviously, TC_2_LEFT doesn't have the same alignment shown in TC_1_LEFT, neither TC_2_RIGHT has the same spacing visible in the overlying subTC, TC_1_RIGHT.

It's fine, I understood that the spacing is evaluated with respect to the elements which are part on the same TransparentContainer.

Therefore, spacings will vary between TC_1_LEFT and TC_2_LEFT since the contained elements are different and in particular, the labels have different length.

My question is: is it possible to maintain the same spacing/alignment in TrasparentContainer_1 and TransparentContainer_2?

I'm looking specifically on a workaround to get different TC contents aligned, something like fetch layout spacing from TC_1_LEFT and apply them to TC_2_LEFT.

Any idea will be appreciated.

Regards,

M.

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Matteo,

The alignment of elements is heavily depends on width of label elements and it is valid within a container. You would notice that, the space of alignment is set based on the largest label.

To make elements of different containers come in line, you need to set the width of labels appropriately

i.e. calculate the optimum width required across all containers and set to the every first label inside every container.

To make your scenario work, try to set the width viz 10EX for first label inside affected containers and check.

Hope this helps you.

Regards,

Rama

matteo_montalto
Contributor
0 Kudos

Hi Rama and thanks for your useful support,

Suppose I'm dealing with a bit of dynamic programming here; how to fetch what's the largest label in a transparent container?
I was thinking to the following algorithm:


get_children( ) of the transparent_container

LOOP over the children (which are typed as Type reF to cl_wd_uielement).

  IF child is a label.

    label_width = child->get_width( ).

    IF label_width GT max_width.

       max_width = label_width.

    ENDIF.

  ENDIF.

ENDLOOP.

The problem here is that the get_width( ) call return always <blank>.

So basically the question is: how to gather the real width information from a label at runtime?

Thanks again,

M.

Answers (0)