The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
Namespaces | Classes
Base for all dialogs in the GUI

Description

This module provides the base definitions for the dialogs.

http://jafma.net

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Collaboration diagram for Base for all dialogs in the GUI:

Namespaces

namespace  zxeco
 The main namespace of the library, that spans across all the zx modules.
 
namespace  zxeco::gui
 The namespace of the GUI companion sub-library.
 

Classes

class  zxeco::gui::Dialog
 Base class for all dialogs. More...
 
struct  zxeco::gui::Dialog::Result
 Possible results of a dialog after interacting with the user. More...
 

Class Documentation

◆ zxeco::gui::Dialog

class zxeco::gui::Dialog

Base class for all dialogs.

Definition at line 41 of file ZXDialogsBase.h.

Inheritance diagram for zxeco::gui::Dialog:
Collaboration diagram for zxeco::gui::Dialog:

Static Public Member Functions

static const WinColorswinColorsForDialogs (void)
 Return the window colors used in all dialogs.
 

Public Member Functions

 Dialog (ZXEco &zxe, const std::string &title)
 Create a dialog with that ecosystem and title. More...
 
virtual ~Dialog (void)=default
 Just to activate polymorphism in delete.
 
virtual int show (bool center, const CharCursor &corner, const CharArea &dims)=0
 Must show the dialog, interact with the user, and close it. More...
 

Protected Member Functions

Window::MngResult openAndInteract (bool closeifout=false, bool center=true, const CharCursor &corner={0, 0}, const CharArea &dims={0, 0})
 Open the dialog and interact with the user. More...
 

Protected Attributes

const std::string title_
 
ZXEcozxe_
 
Window::DepthFirstInserter wins_
 Note that is not in auto-ID mode. More...
 

Constructor & Destructor Documentation

◆ Dialog()

zxeco::gui::Dialog::Dialog ( ZXEco zxe,
const std::string &  title 
)
inline

Create a dialog with that ecosystem and title.

The dialog is created but not populated with widgets, nor opened. The title can be empty to not showing title bar.

Definition at line 70 of file ZXDialogsBase.h.

Member Function Documentation

◆ show()

virtual int zxeco::gui::Dialog::show ( bool  center,
const CharCursor corner,
const CharArea dims 
)
pure virtual

Must show the dialog, interact with the user, and close it.

Must return an INT that static-cast to Result or to the derived class own result codes. It creates a new window for the dialog that is destroyed after interacting, but the widgets created by the derived class are kept in the private member wins_ and therefore can be opened again in another window (another call to show()).

Parameters
centercenter the dialog on the screen if TRUE, or use as its top-left corner the one given in corner if FALSE.
corneris ignored if center == TRUE.
dimsare forced dimensions for the dialog, instead of using the automatically calculated ones in this class.

Implemented in zxeco::gui::MessageDialog, zxeco::gui::ExplanationDialog, zxeco::gui::FileDialog, and zxeco::gui::MenuDialog.

◆ openAndInteract()

Window::MngResult zxeco::gui::Dialog::openAndInteract ( bool  closeifout = false,
bool  center = true,
const CharCursor corner = {0, 0},
const CharArea dims = {0, 0} 
)
protected

Open the dialog and interact with the user.

The WINS_ protected member must be filled with the widgets of the dialog previously; the interaction ends only if the user closes the desktop (Window::MngResult::DESKCLOSE_EVENT) or if some callback attached to the widgets return false (Window::MngResult::FINISHING_CALLBACK).

If CLOSEIFOUT is true, any click out of the dialog window will close it (returning OUT_CLICK).

If CENTER is true, centers the dialog on the screen.

If DIMS is not empty, use them for the window size; otherwise, auto fit the widgets of WINS_ to a suitable size (this does not work well if the widgets contain elements, such as lists, that might occupy more space in smaller areas than in larger areas -due to the appearance of scroll bars-)

Member Data Documentation

◆ title_

const std::string zxeco::gui::Dialog::title_
protected

Definition at line 99 of file ZXDialogsBase.h.

◆ zxe_

ZXEco& zxeco::gui::Dialog::zxe_
protected

Definition at line 100 of file ZXDialogsBase.h.

◆ wins_

Window::DepthFirstInserter zxeco::gui::Dialog::wins_
protected

Note that is not in auto-ID mode.

Definition at line 101 of file ZXDialogsBase.h.

◆ zxeco::gui::Dialog::Result

struct zxeco::gui::Dialog::Result

Possible results of a dialog after interacting with the user.

These are the most common buttons to end the interaction with a dialog; the derived class must populate itself with those buttons. For adding new buttons, use your own enumerations that map into int.

Definition at line 53 of file ZXDialogsBase.h.

Public Types

enum  : int {
  kDesktopClosed = 0 , kOk , kYes , kNo ,
  kCancel , kClose , kSelected , kError ,
  kClickedOutside , kNumBaseResults
}
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : int
Enumerator
kDesktopClosed 

Desktop closed.

kOk 

The user clicked on OK.

kYes 

The user clicked on YES.

kNo 

The user clicked on NO.

kCancel 

The user clicked on CANCEL.

kClose 

The user clicked on CLOSE.

kSelected 

The user clicked to select.

kError 

Error processing user's req.

kClickedOutside 

The user clicked outside the dialg.

Definition at line 55 of file ZXDialogsBase.h.