Expand/Shrink

gDialog

Definition: include xpGUI.e

gdx id = gDialog(gdx child, [parent=NULL,] [string [title="",] attributes="", [dword_seq args={},]] bool bEsc=true)
Description: Creates a dialog element, also known as a window, which contains and manages user interaction with the interface elements. For any (other type of) interface element to be shown, it must ultimately be encapsulated in a dialog.

child: the identifier of an interface element. The dialog has only one child.
parent: must be specified at creation time, or NULL (/omitted) for top-level windows.
title: optional, can also be set via `TITLE="xxx"` in the attributes parameter, or even later.
For more information on the attributes and args parameters see gSetAttributes().
bEsc: when true (the default) the dialog is automatically closed when escape is keyed.
This is a paranormalised function (see technicalia)

Returns the identifier of the created element.
pwa/p2js: Supported.
See Also: gShow, gMainLoop, gHide
Example:
-- demo\xpGUI\gDialog.exw
include xpGUI.e
gdx dlg = gDialog(NULL,"gDialog","SIZE=240x80")
gShow(dlg)
gMainLoop()
gDialog
Notes: All elements (including menus) must be inside a dialog to interact with the user.
An interface element will only be visible if the containing dialog is also visible.

Technically the child can be NULL, as shown above, but that is only useful for test/incomplete applications, since (unlike pGUI) there is no way to insert or reparent controls, and besides it is pretty easy to show/hide elements.
Attributes:
CLOSE_ON_ESCAPE An alternative way to set the same thing as the bEsc parameter, or to check what it is (replaces IupCloseOnEscape).
DEFAULTENTER
DEFAULTESC
NULL, XPG_CLOSE, XPG_IGNORE, or the gdx of the button to be activated (more accurately the ACTION handler of said to be invoked) when the user presses (an otherwise unhandled) Enter/Esc when the keyboard focus is on any control within the dialog.
Alternatively (/when there is no suitable button) just use a KEY handler on the dialog.
Note that DEFAULTESC takes priority over bEsc/CLOSE_ON_ESCAPE.
? FULLSCREEN Makes the dialog occupy the whole screen over any system bars in the main monitor.
All dialog details, such as title bar, borders, maximize button, etc, are removed.
Possible values: YES, NO.
MARGIN,
PADDING,
EXPAND
There are no such things on a dialog itself, however like all containers a dialog is responsible for handling child margin[s], hence instead specify a MARGIN on the (sole) child for some space around the edges of a dialog, and of course should that be a gH/Vbox additional options GAP and SPACE are also available. EXPAND is meaningless on a gDialog: there is nothing for it to expand into (you may be thinking of RESIZE). A dialog is given a natural size sufficient for its contents, unless explicitly overidden by the SIZE, MINSIZE, and/or MAXSIZE attributes.
? MAXBOX,
? MINBOX,
? MENUBOX
DEV post-v1..
(creation only) Requires a maximize/minimize button/system menu box from the window manager. Default: YES.
If RESIZE=NO then MAXBOX will be set to NO.
If MENUBOX=NO will also remove the Close button.
In Windows MENUBOX=NO will also hide MAXBOX and MINBOX.
PL: removes the min|(max/restore)|close buttons (Windows). I need to test it on Linux/GTK
In Windows MAXBOX/MINBOX is hidden only if MINBOX/MAXBOX is hidden as well, otherwise it is just disabled.
? MAXIMIZED,
MINIMIZED
[Windows Only] (read-only) indicates if the dialog is maximized/minimized. Can be YES or NO.
? PLACEMENT+ Changes how the dialog will be shown. Values: "FULL", "MAXIMIZED", "MINIMIZED" and "NORMAL". Default: NORMAL.
After gShow the attribute is set back to "NORMAL".
?? FULL is similar to FULLSCREEN but only the dialog client area covers the screen area, menu and decorations will be there but out of the screen.
Under pwa/p2js MINIMIZED is not supported since that is more likely to be the job of the browser, rather than anything on a tab within the browser.
? RESIZE DEV post-v1, probably...
(creation only) Allows interactively changing the dialog’s size. Default: YES.
If RESIZE=NO then MAXBOX will be set to NO.
? SIZE Dialog’s size. Additionally the following values can also be defined for width and/or height:

"FULL": Makes the dialog width (or height) equal to the screen width (or height)
"HALF": Makes the dialog width (or height) equal to half the screen width (or height)
"THIRD": Makes the dialog width (or height) equal to 1/3 the screen width (or height)
"QUARTER": Makes the dialog width (or height) equal to 1/4 of the screen width (or height)
"EIGHTH": Makes the dialog width (or height) equal to 1/8 of the screen width (or height)
NOTE: the above SIZE values are for gDialog only, they will not work with other controls such as gButton, gBox, or gFrame.
The dialog natural size is only considered when the user size is not defined.

The setting of the SIZE attribute of a dialog is always accepted, regardless of the minimum size required by its children.
?? For a dialog to have the minimum necessary size to fit all elements contained in it, simply define SIZE to NULL.
? Also if you set SIZE to be used as the initial size of the dialog, its contents will be limited to this size as the minimum size,
if you do not want that, then after showing the dialog reset this size to NULL so the dialog can be resized to smaller values.

For more information see Layout Management.
TITLE Dialog’s title. Default: NULL. If you want to remove the title bar you must also set MENUBOX=NO, MAXBOX=NO and MINBOX=NO, before map.
? VISIBLE (read only) Returns true or false.
Calling gShow or gHide for the dialog fairly obviously implicitly updates this attribute.
Also accepted: ACTIVE, FONT, MAXSIZE, MINSIZE, TIP, Note that ACTIVE and FONT also affect all the controls inside the dialog.
? Drag & Drop attributes and handlers are supported.
Handlers:
? CLOSE_CB Called right before the dialog is closed.
NB: Will not be invoked when a handler returns XPG_CLOSE, instead the programmer should invoke any necessary routines explicitly.
? COPYDATA_CB [DEV use ipc instead...] [Windows Only] Called at the first instance, when a second instance is running.
Must set the global attribute SINGLEINSTANCE to be called.

function copydata_cb(Ihandle ih, atom pCmdLine, integer size)
ih: identifier of the element that activated the event.
pCmdLine: command line (char*) of the second instance.
size: size of the command line string including the null character.
? DROPFILES_CB [Windows and GTK Only] Event generated when one or more files are dropped in the dialog.
also KEY: All common handlers are supported.
? Drag & Drop attributes and handlers are supported.
Expand/Shrink