Graphical User Interfaces

Detailed Description

A Forms application constructs its visual hierarchy, shows its windows, and runs the event loop. The inherited event loop also supports I/O, timers, and asynchronous operations.

Application is the runtime root. Construct it before forms, windows, or controls. It is not a Widget. The application provides the primary Screen and its WindowManager, dispatches platform events, and owns the shared scaling, style, font, and input-method services.

The C++ class hierarchy and the visual hierarchy describe different relationships. The following diagram shows inheritance only. It does not describe which objects display or contain other objects. In particular, Window derives from Form; it is not a direct child of View.

Widget
Screen
WindowManager
View
Form
Window
Control

The visual hierarchy describes how Forms objects appear together. Each level follows the same non-owning host pattern: Application provides the Screen, a WindowManager attaches Window objects, a Form attaches one content Control, and a Control attaches child controls, including layouts. A Workspace applies the same pattern inside an ordinary control: its window manager presents several windows within the workspace bounds.

Application -> Screen -> WindowManager -> Window (Form) -> content Control -> child Controls

Attaching a window or control does not transfer ownership. The code that creates an object keeps it alive while the hierarchy uses it. A window or control removes itself from its parent when it is destroyed.

The following example creates a visual hierarchy with a window, its content layout, and a control displayed by that layout.

int main(int argc, char** argv)
{
Pt::Forms::Application application(argc, argv);
label.setText("Hello, Forms");
content.addItem(label);
window.setTitle("Example");
window.setContent(&content);
window.show();
application.run();
return 0;
}

Classes

class  Application
 Provides the runtime root of a Forms user interface. More...
 

Modules

 Widgets and Views
 Widget and view object model.
 
 Windows and Workspaces
 Windows and workspace management.
 
 Layouting and Painting
 Invalidate, layouting, and painting of visual content.
 
 Pointer and Keyboard Input
 Pointer, keyboard, and text-entry input.
 
 Layouts
 Arrangement of child controls.
 
 Buttons
 Commands and boolean choices.
 
 Displays
 Text, panels, and progress without editing.
 
 Editors and Selectors
 Text, numbers, lists, and ranges for entering or picking a value.
 
 Collections
 Lists, tabs, and scrollable content.
 
 Menus
 Menu bars and popup menus for commands and context actions.
 
 Icons and Text
 Icons and textual content for controls.
 
 Styles and Renderers
 Styles, options, and renderers for widget appearance.
 
Control that displays text or an icon.
Definition: Label.h:80
virtual void show(bool b=true)
Requests that the widget be shown or hidden.
Form presented by a window manager.
Definition: Window.h:99
void setText(const Pt::String &text)
Sets the caption to text and clears any icon.
Provides the runtime root of a Forms user interface.
Definition: Application.h:88
Arranges children in a single row or column.
Definition: FlowLayout.h:72
void setContent(Control *control)
Replaces the content root with control.
void addItem(Control &control)
Attaches control as a flow item.
void setTitle(const std::string &title)
Sets the window title to title.