Creating the standard input focus frame widget

customkeyfocus.C's custom widget's default appearance is plain and unadorned. LibCXXW's standard widgets visually indicate which one has keyboard input focus frame by drawing a border around that widget. This is not something that happens automatically. Each widget has full control over its appearance.

customkeyfocus.C custom widget changes its background color when it has input focus. Running customkeyfocus with the -f option also draws the standard input focus frame.

An input focus frame is a container. LibCXXW's widgets are arranged in a logical hierarchy of containers, and a container itself is a widget; namely a widget that contains other widgets. An input focus frame is a container that draws a input focus border around the widget inside the container.

A brief overview of a process for creating a custom widget:

  1. Use a factory's get_container_impl() to obtain the new custom widget's parent container implementation object.

  2. Create the custom widget's implementation object instance, passing to it the parent container's implementation object.

  3. Create the public object for the custom widget's implementation object.

  4. Pass the new public object to the factory's created_internally() method.

Use the following process for creating a custom focusable widget with an input focus frame.

  1. Use a factory's get_container_impl() to obtain the new custom widget's parent container implementation object.

  2. Create an implementation object for the input focus frame's container.

  3. Create the custom widget's implementation object instance, passing to it the input focus frame container's implementation object.

  4. Create the public object for the custom widget's implementation object.

  5. Create the public object for the input focus frame, using x::w::create_focusframe_container(), which takes care of logically using created_internally() with the custom widget's public object.

  6. Pass the input focus frame's public object to the factory's created_internally() method.

This logically translates to a minor sleight of hand. Instead of creating a custom widget for the factory in question, the input focus frame widget gets created. That becomes the new widget. But the real custom widget goes into the input focus frame, which is a container.