Nana development: Version 0.2.3

Source: Internet
Author: User

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 ")));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.