Guide API
Skip to main content

Module dialog

Module dialog 

Source
Expand description

The modal dialog window.

Dialog is the view you run modally: hand it to exec_view and it returns the command that closed it (Command::OK, CANCEL, …). It embeds a Window exactly as Window embeds a Group, and forwards almost the whole View trait to that window. The dialog’s own behaviour is just three things it overrides:

  • handle_event — let the window handle the event first, then the dialog keys (Esc → post a Cancel command, Enter → broadcast Default) and the modal-result commands (OK / Cancel / Yes / No → end the modal loop while the dialog is modal).
  • valid — Cancel is always valid (cancelling a dialog can never be vetoed); every other command defers to the embedded group, so a control with a failing validator can keep the dialog open.
  • constructor field overrides — no grow-with-owner, decoration flags move | close (no grow, no zoom), and the gray dialog color scheme.

The modal loop is the program’s single pump_once driven in a bounded top-level loop by exec_view; ending the modal is a downward Deferred::EndModal request routed to the loop owner rather than an up-pointer call.

Data-bearing dialogs work today: child controls (input lines, clusters, …) carry typed values, optional Validators gate focus-release and close, and the group’s gather/scatter walk collects them — see FileDialog for a worked example.

The layout constants (STD_BUTTON, BUTTON_GAP, the margins and BUTTON_ROW_FROM_BOTTOM) name the classic Turbo Vision metrics, recovered from msgbox.cpp and tfildlg.cpp, so dialogs need not invent their own coordinates. Dialog::button_row lays out a row of buttons with them.

Guide: Dialogs & data.

§Turbo Vision heritage

Ports TDialog (tdialog.cpp/dialogs.h), which derived from the window class. That inheritance becomes embed-and-delegate composition (deviation D2) — the dialog holds a Window and forwards to it; the single modal loop and the downward end-modal request are deviation D9.

Structs§

ChDirDialog
A Dialog that lets the user change the process current directory, assembling a path input line, a directory-tree pane (DirListBox), a history icon, and the OK / Chdir / Revert (and optional Help) buttons.
ColorPicker
The reusable, embeddable truecolor color-picker view. A Group wrapping a TabBar + PageStack (four surface pages) + an InfoColumn, all sharing one ColorModel. Does NOT own OK/Cancel (dialog chrome).
Dialog
A modal dialog window: a Window with dialog-specific field overrides and the Esc/Enter/ok-cancel key handling.
DirEntry
A (display-text, directory-path) pair for the directory tree pane.
DirListBox
A concrete ListViewer over a Vec<DirEntry> that renders the current working directory as a tree-indented listing of its ancestors and immediate subdirectories.
FileCollection
A name-sorted list of SearchRec items.
FileDialog
A Dialog that assembles the file picker — the directory/file panes (FileList, FileInputLine, FileInfoPane) plus a filename label, a history icon, a scroll bar, and the action buttons — into a working file dialog.
FileInfoPane
A plain view that displays the focused file’s path on line 0 and its name + size + date on line 1.
FileInputLine
A filename InputLine that mirrors the FileList’s focused entry.
FileList
The file-listing pane of the file dialog. A concrete SortedSearch (hence ListViewer) over a name-sorted Vec<SearchRec> (== a FileCollection’s contents), with two columns and incremental type-to-search.
MessageBoxButtons
The set of buttons to show in a message box.
SearchRec
A directory-listing file-metadata record.

Enums§

ButtonLayout
How Dialog::button_row sizes the faces in a row. In every case the width is floored at the dialog’s configured minimum (see set_button_min_width, default STD_BUTTON).
ButtonRowAlign
How Dialog::button_row places buttons.
MessageBoxKind
The dialog title — which kind of alert this is.
Tab
The active surface tab.

Constants§

BUTTON_GAP
Cells between adjacent buttons in a button row.
BUTTON_ROW_FROM_BOTTOM
Button-row top edge = dialog_height - BUTTON_ROW_FROM_BOTTOM.
CD_HELP_BUTTON
Add a “Help” button to the ChDirDialog.
CD_NORMAL
Default options for ChDirDialog: no extra buttons, load the directory tree on open.
CD_NO_LOAD_DIR
Suppress the initial directory-tree read when the dialog opens.
FA_DIREC
The directory-attribute bit of SearchRec::attr (FA_DIREC = 0x10).
FD_CLEAR_BUTTON
Insert a “Clear” button that closes the dialog without a filename.
FD_HELP_BUTTON
Insert a “Help” button (posts Command::HELP; does not close the dialog).
FD_NO_LOAD_DIR
Skip the initial directory read when the dialog opens.
FD_OK_BUTTON
Insert an “OK” button that closes the dialog with the selected filename.
FD_OPEN_BUTTON
Insert an “Open” button that closes the dialog with the selected filename.
FD_REPLACE_BUTTON
Insert a “Replace” button that closes the dialog with the selected filename.
MARGIN_LEFT
Content inset from the left frame.
MARGIN_RIGHT
Content inset from the right frame.
MARGIN_TOP
Content inset from the top frame.
STD_BUTTON
Standard button: 10 columns × 2 rows (row 2 is the drop shadow).

Functions§

search_rec_compare
The sort order for a directory listing: ".." last, directories after plain files, then case-sensitive byte-order by name.

Type Aliases§

DirCollection
An ordered list of DirEntry items used by DirListBox.