Border title and background

borderlayoutmanager.C creates two bordered elements. The one on the right has a title. A bordered widget with a title requires some additional space, to make room for the title text, so borderlayoutmanager.C aligns both elements on their bottom margins, for an even look.

x::w::new_borderlayoutmanager nblm;

nblm.title("Hello world");

x::w::new_borderlayoutmanager's title is an initially empty x::w::text_param. A non-empty title creates a title for the bordered widget.

borderlayoutmanager.C's left bordered widget does not have a title, unlike the the right bordered widget. Besides the title, the two bordered elements have a slightly different visual apperance. The title-less bordered widget has a slightly shaded, visually-highlighted background color.

Background colors and titles

The border layout manager uses a slightly non-standard approach to background colors when no title gets specified. Without a title the border layout manager automatically installs a theme-specified background color for the widget in the border. Setting the no_background flag in the x::w::new_borderlayoutmanager turn off this default behavior.

This behavior gets automatically turned off when creating a border with a title, which is why the right bordered widget has a plain background color. There's no explicit border drawn under the title, to serve as an explicit edge to the highlighted border. It would not look good, so the highlighted background does not get installed when the new border has a title.

blm->update_title("Lorem Ipsum");

The border layout manager's update_title() replaces the container's current title. It is recommended that the title should not be an empty string, and bordered containers that got created without a title should not use update_title to specify a title after their creation. Adding or removing a title requires resizing the container. This is because the title uses up. additional vertical real estate; and the border layout manager does not update the existing widget's background color either.

Note

An untitled border widget's default background color gets set when the bordered widget gets created by replace()'d factory. The border layout manager inherits from the utility singleton layout manager object, which implements methods for replacing the widget in the container. The border layout manager overrides the new widget's background color if there's no title, and explicitly removes the widget's background color if there is a non-empty title.

A preferred approach to modifying the contents of a bordered widget is to use x::w::new_borderlayoutmanager creator lambda to create a discrete container, with a stock grid layout manager, and use the grid layout manager to control the contents inside the border. The page, book, or event pane layout managers are other available options.