Boost.UI
User Interface Boost library
|
Boost.UI is a C++ User Interface (GUI) Boost library that
It supports Graphics, various Widgets, Events, Layouts.
C++ programs should have a better way to interact with humans then std::cin / std::cout.
Boost.UI library master include file is <boost/ui.hpp>
and this library uses boost::ui namespace to hold all classes and functions.
Boost.UI requires GUI initialization and uninitialization, therefore you should use boost::ui::entry() function to do it.
Widget is a graphical control element and represents any visible object on screen. boost::ui::widget is a base class for all widgets. Widget should be created to be visible and use its functions, boost::ui::widget::native_valid() function returns true in this case.
Top level widgets (TLW) are widgets that are used to host other (child) widgets and they are controlled by OS window manager. Basic TLW is boost::ui::dialog. If you need boost::ui::menu_bar or boost::ui::status_bar support you should use boost::ui::frame TLW. boost::ui::window is a base class for all (two) TLW classes. boost::ui::window::show_modal() class function displays TLW and waits while end user close TLW manually or boost::ui::window::close() class function is called.
boost::ui::frame with boost::ui::menu_bar and boost::ui::status_bar support:
Child widget is a widget that is placed on parent widget (top level widget (TLW) or other child widget - boost::ui::panel). Parent widget should be specified for each child widget as a first argument in constructor. Child widget is automatically destroyed when parent widget is destroyed.
If you want to draw lines, circles, etc you should use boost::ui::canvas child widget and draw using drawing context - boost::ui::painter class. Other widgets not support drawing.
Boost.UI is NOT thread safe library, so you should use boost::ui::call_async() function to synchronize worker threads with main (GUI) thread. However you can use Logging in any thread, it is thread safe.
Boost.UI has own event loops and you can't create other your own event loops inside main (GUI) thread without freezing GUI. For example if you are using Boost.ASIO you should create other (worker) thread and synchronize it with main thread as described before. Note that main thread is used to interact with end user, not for long time calculations.
Widgets have various event subscription functions (for example boost::ui::button::on_press()). If you pass callback function to it, this function will be called when event occurs (button press in this case). Multiple subscription calls cause multiple event handlers calls, i. e. event handler callback function isn't overrided on next event subscription call.
Boost.UI catches exception inside boost::ui::entry() and event handlers if you didn't catch it before. After exception catch library shows exception dialog window to the end user.
Boost.UI has own boost::ui::uistring string class that simplifies conversion between native widget toolkit string classes and C++ Standard string classes. Native string format could be ANSI, UTF-8, wchar_t etc.
WinMain()
function is used under Windows as entry point for GUI applications, but Boost.UI requires main()
function. You can call main()
from WinMain()
by including into your cpp file:
Or make this call manually.
See source code (GitHub). Read README.md file for build instructions and library details.