This update mainly improves support for X11, such as drag-and-drop events and dataexch (Clipboard), which means Nana C ++ library can work better on the Linux (X11) platform. In addition, this update includes other new features.
Class msgbox
Class msgbox is used to display a mode window and prompt a short message. A simple example:
NANA: Gui: msgbox M (STR ("msgbox example "));
M <STR ("This Is A msgbox example .");
M ();
Msgbox is a C ++ stream style, so we can easily display strings, numbers, and all types with the operator <operator for STD: ostream reloaded.
Sometimes, the application should ask the user whether to exit the program.
VoidWhen_exit (ConstNANA: Gui: eventinfo & EI)
{
NANA: Gui: msgbox M (Ei. Window, STR ("msgbox example"), Nana: Gui: msgbox: yes_no );
M. Icon (M. icon_question );
M <STR ("are you sure you want to exit the game? ");
EI. Unload. Cancel = (M ()! = M. pick_yes );
}
IntMain ()
{
Using namespaceNANA: Gui;
Form FM;
FM. make_event <events: Unload> (when_exit );
FM. Show ();
Exec ();
}
Window icon
The Nana library defines two interfaces used to set the icons of the root_widget window type, such as form and nested_form, which are defined in the nana: Gui: API namespace.
VoidWindow_icon_default (ConstNANA: paint: iamge &);
VoidWindow_icon (NANA: Gui: window,ConstNANA: paint: Image &);
Window_icon_default () sets a default icon. After the call, the default icons are automatically set when all windows are created.
Although Nana C ++ library is designed to be cross-platform, there are still some differences between Windows and Linux (X11). In Windows, the icon of a window can only be an icon file. If the program needs to be cross-platform, you need to treat it differently during encoding.
Using namespaceNANA: Gui;
# If defined (nana_windows)
API: window_icon (FM, Nana: paint: image (STR ("icon. ICO ")));
# Else
API: window_icon (FM, Nana: paint: image (STR ("icon.bmp ")));
# Endif
In Windows, the window icon is usually the icon of the EXE file, which is saved as a resource in the EXE file. If you set the icon file in the resource as a window icon, you only need to use the class image to open this EXE file.
API: window_icon_default (NANA: paint: image (STR ("program.exe ")));
Or
API: window_icon (a_form_object, Nana: paint: image (STR ("program.exe ")));