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§
- ChDir
Dialog - A
Dialogthat 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. - Color
Picker - The reusable, embeddable truecolor color-picker view. A
Groupwrapping aTabBar+PageStack(four surface pages) + anInfoColumn, all sharing oneColorModel. Does NOT own OK/Cancel (dialog chrome). - Dialog
- A modal dialog window: a
Windowwith dialog-specific field overrides and the Esc/Enter/ok-cancel key handling. - DirEntry
- A (display-text, directory-path) pair for the directory tree pane.
- DirList
Box - A concrete
ListViewerover aVec<DirEntry>that renders the current working directory as a tree-indented listing of its ancestors and immediate subdirectories. - File
Collection - A name-sorted list of
SearchRecitems. - File
Dialog - A
Dialogthat 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. - File
Info Pane - A plain view that displays the focused file’s path on line 0 and its name + size + date on line 1.
- File
Input Line - A filename
InputLinethat mirrors theFileList’s focused entry. - File
List - The file-listing pane of the file dialog. A concrete
SortedSearch(henceListViewer) over a name-sortedVec<SearchRec>(== aFileCollection’s contents), with two columns and incremental type-to-search. - Message
BoxButtons - The set of buttons to show in a message box.
- Search
Rec - A directory-listing file-metadata record.
Enums§
- Button
Layout - How
Dialog::button_rowsizes the faces in a row. In every case the width is floored at the dialog’s configured minimum (seeset_button_min_width, defaultSTD_BUTTON). - Button
RowAlign - How
Dialog::button_rowplaces buttons. - Message
BoxKind - 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
DirEntryitems used byDirListBox.