lecui 1.0.0-alpha.20
lecui C++ user interface library
|
Form base class. The user must inherit from this class and call one of the two constructors from its own constructor. More...
#include <form.h>
Classes | |
struct | form_events |
Form events. More... | |
Public Member Functions | |
form (const std::string &caption) | |
Make a form with no parent. More... | |
form (const std::string &caption, form &parent) | |
Make a modal form. More... | |
void | move (const point &point) |
Move the form. More... | |
void | move (const form_position &form_position) |
Move the form. More... | |
void | force_instance () |
Force this instance to run even if an existing instance is found. More... | |
bool | create (std::string &error) |
Create the form. More... | |
void | close () |
Close the form. When this is called all activity is stopped and the form is closed. More... | |
bool | prompt (const std::string &question) |
Prompt the user for confirmation of an action. Displays a small modal message box with yes-no buttons. More... | |
void | message (const std::string &message) |
Display a message to the user in the form of a small modal message box with an ok button. More... | |
void | update () |
Update the form. A low resource refresh of the current page. Typically necessary only after adding a new widget at runtime to the currently displayed page to avoid a situation whereby the widget is only displayed the next time the mouse moves or the next time the tab key is pressed. | |
void | reload () |
Reload the form and all its widgets. A high resource reload of the entire form's graphic resources. The following things happen when this method is called: More... | |
float | get_dpi_scale () |
Get the current DPI scale. More... | |
void | allow_minimize () |
Minimize the form. More... | |
void | restore () |
Restore the form. More... | |
void | maximize () |
Maximize the form. More... | |
void | hide () |
Hide the form. Useful when using a system tray icon. More... | |
bool | visible () |
Check whether the form is visible. More... | |
void | show () |
Show the form. More... | |
bool | minimized () |
Check whether the form is minimized. More... | |
void | prevent_quit () |
Prevent the form from being closed. More... | |
void | allow_quit () |
Allow the form to be closed. More... | |
form_events & | events () |
Get or set form events. More... | |
Static Public Member Functions | |
static std::string | menu_form_caption () |
A special caption used to make a menu form. More... | |
static std::string | tooltip_form_caption () |
A special caption used to make a tooltip form. More... | |
static bool | keep_alive () |
Keep UI responsive during lengthy calls. More... | |
Form base class. The user must inherit from this class and call one of the two constructors from its own constructor.
Fully DPI aware, but needs to be recreated if the system DPI changes while already open to rescale properly.
liblec::lecui::form::form | ( | const std::string & | caption | ) |
Make a form with no parent.
caption | The form caption, displayed on the top left. Supports formatting like any other label widget. Care has to be taken that the formatting does not result in text of excessive height since the title bar's size is fixed. Default font size is 9px when none is specified in the formatting and it is not recommended to set a size greater than this for the above mentioned reason. |
liblec::lecui::form::form | ( | const std::string & | caption, |
form & | parent | ||
) |
Make a modal form.
caption | The form caption, displayed on the top left. Supports formatting like any other label widget. Care has to be taken that the formatting does not result in text of excessive height since the title bar's size is fixed. Default font size is 9px when none is specified in the formatting and it is not recommended to set a size greater than this for the above mentioned reason. |
parent | The parent form. The user cannot click the parent form until the child form is closed. Useful for making input forms. |
The parent form remains active in the background, with all timers running. If it so happens that the parent is closed from one of these timers, all it's children will be forcibly closed first. A child is not allowed to continue if the parent is closing.
void liblec::lecui::form::allow_minimize | ( | ) |
Minimize the form.
This method does nothing if the form is already minimized or if it doesn't have the minimize button.
void liblec::lecui::form::allow_quit | ( | ) |
Allow the form to be closed.
Required at some point after a call to prevent_quit else it will not be possible to close the form.
void liblec::lecui::form::close | ( | ) |
Close the form. When this is called all activity is stopped and the form is closed.
If called in the form_events::initialize event then the form_events::layout event never happens and the app is terminated gracefully.
bool liblec::lecui::form::create | ( | std::string & | error | ) |
Create the form.
error | Error information on fail. |
This is a blocking function and will only return when either the form is closed or in the event of an error during form creation.
form_events & liblec::lecui::form::events | ( | ) |
Get or set form events.
void liblec::lecui::form::force_instance | ( | ) |
Force this instance to run even if an existing instance is found.
This method causes the create method to continue execution regardless of whether an existing instance is present. You would typically do this if you need your app to reach the form_events::initialize event without the intention of allowing it to go as far as the form_events::layout event, in which case you would call the close method within the form_events::initialize event. A typical use-case is when the app is calling itself during an update process. Not calling this method would mean the spawning of the new instance is not guaranteed since the previous may still be running when the new one reaches the instance checking logic. The best place to call this method is in the constructor of the class that inherits from this base class.
float liblec::lecui::form::get_dpi_scale | ( | ) |
Get the current DPI scale.
void liblec::lecui::form::hide | ( | ) |
Hide the form. Useful when using a system tray icon.
Note that once called the form can only be restored through a call to the restore method. Besides that there will be no other means to make the form visible again. To manipulate a form's visibility at creation time use the controls::start_hidden method.
|
static |
Keep UI responsive during lengthy calls.
In lengthy operations it is useful to call this method between successive steps in order to keep the UI responsive.
void liblec::lecui::form::maximize | ( | ) |
Maximize the form.
This method does nothing if the form is already maximized or if it doesn't have the maximize button.
|
static |
A special caption used to make a menu form.
void liblec::lecui::form::message | ( | const std::string & | message | ) |
Display a message to the user in the form of a small modal message box with an ok button.
message | The message to display. |
Is centered to the form, and inherits the caption from the form.
bool liblec::lecui::form::minimized | ( | ) |
Check whether the form is minimized.
void liblec::lecui::form::move | ( | const form_position & | form_position | ) |
Move the form.
form_position | The predefined form position. |
void liblec::lecui::form::move | ( | const point & | point | ) |
Move the form.
point | The coordinates of the top left corner of the form, in pixels. |
void liblec::lecui::form::prevent_quit | ( | ) |
Prevent the form from being closed.
Typically useful when you need to perform a lengthy operation that should not or cannot be interrupted. To allow the form to be closed call the allow_quit method.
bool liblec::lecui::form::prompt | ( | const std::string & | question | ) |
Prompt the user for confirmation of an action. Displays a small modal message box with yes-no buttons.
question | The question to ask the user. |
Is centered to the form, and inherits the caption from the form.
void liblec::lecui::form::reload | ( | ) |
Reload the form and all its widgets. A high resource reload of the entire form's graphic resources. The following things happen when this method is called:
Depending on the computing platform, this can take a considerable amount of time in a large app, ranging from milliseconds to actual seconds. The better the app is designed the less time it will take, as such applications typically only create pages on-demand. However, even in a well designed app the difference with update() will be obvious if many pages are currently open. Note: this doesn't change the form's 'state', e.g. if a widget was closed it won't magically reappear. This reloads the current 'state'.
void liblec::lecui::form::restore | ( | ) |
Restore the form.
If the form is minimized it will be restored. If it is maximized it will also be restored to normal size. If the form is already in normal form nothing will be done (except bring it to the foreground if it isn't already). If the form was hidded it will be shown.
void liblec::lecui::form::show | ( | ) |
Show the form.
Neccessary to display a form that was hidden through a call to hide.
|
static |
A special caption used to make a tooltip form.
bool liblec::lecui::form::visible | ( | ) |
Check whether the form is visible.