-
-
Notifications
You must be signed in to change notification settings - Fork 5
page
#include <liblec/lecui/containers/page.h>
The page is the only container that can be added directly to the form. Other containers and widgets can then be added to a page. To add a page to a form we need to use the page manager. Since we typically use the page manager in various places in our code it is recommended to declare a page manager member variable in our form class. The page manager class constructor only takes on parameter, a reference to the form.
We add a page to the form by calling the .add() method of the page_manager class. The .add() method takes only one parameter, the page's alias. The alias uniquely identifies the page and has to be unique. After we add the page we can add widgets to it (and/or other containers). To make the page visible we have to call the .show() method of the page_manager class and pass the page's alias to it.
#include <liblec/lecui/containers/page.h>
using namespace liblec::lecui;
class sample_form : public form {
page_manager _page_man{ *this };
public:
sample_form() :
form("Sample Form") {
events().layout = [this](std::string& error) {
auto& home = _page_man.add("home");
// add widgets to "home" page here
_page_man.show("home");
return true;
};
}
};
int main() {
sample_form form;
std::string error;
if (!form.create(error))
form.message(error);
return 0;
}
The code above displays the following form:
Here are important facts about pages:
- Only one page can be displayed at a time using the .show() method in the page_manager class. Each time the .show() method is called the previously visible page is hidden and the new one is displayed.
- A page takes up the entire form except for the title-bar.
- When the form is resized the page is resized as well to match the form's new size.
- A page has neither a visible border nor a background.
- When widgets overlap the page's visible area scroll bars kick in automatically.
The screenshot below shows the actual position of the page on the form(red line):
Adding widgets to containers is discussed here.
lecui - rapidly develop modern, efficient and easy to maintain C++ GUI applications for Windows