This example illustrates how to show the line numbers of textbox.
In Nana 1.2, textbox has added some new member functions and a new event for line number operations.
textbox::text_position() returns the position of text that each line currently displays on screen.
event text_exposed occurs when line numbers of text that are displayed on screen are changed(for example, adding a new line of text, scrolling vertical scrollbar).... read more
The listbox model is a new feature which will be introduced into Nana 1.4. The listbox model is to use an existing STL container and adopt the container as the storage for a listbox category.
~~~~
//Definition of a person
struct person
{
std::string name;
unsigned age;
};
//A container stores persons
std::vector<person> persons;
//Insert 3 persons.
persons.push_back(person{"Steve", 20});
persons.push_back(person{"Nolan", 25});
persons.push_back(person{"Susan", 21});... read more
This example illustrates how to scroll a picture by using scrollbars.
~~~~
int main()
{
using namespace nana;
form fm; scroll<true> vert_s(fm, true); scroll<false> horz_s(fm, true); //layout management for scrollbars place plc(fm); plc.div("vert<<><weight=16 vert_scroll>><weight=16 horz_bottom <horz_scroll><weight=16 corner>>"); plc["vert_scroll"] << vert_s; plc["horz_scroll"] << horz_s;... [read more](/p/nanapro/blog/2016/03/nana-example---using-scrollbar/)
1.0 is the first version of beta phase. Thanks to guys who supported this library, especially qPCR4vir, who has made source contributions for the project over the past year.
BREAKING CHANGES
1, ::nana::color_t is now deprecated in favor of class nana::color.
The main problem of color_t is impossible to represent an invalid color, because color_t is just a typedef name of unsigned. The class color provides some useful interfaces, from_rgb()/from_hsl() to assign a color, and blend() to mix 2 colors. Here also defines some helper types to initialize a color.... read more
(This page may be deprecated for releases from Nana 1.2. Instead, refer to for details)
In the release of 0.2, Nana provides the support for PNG, but defaultly Nana disables the feature of PNG for easy and fast configuration.
The support for PNG is introduced to Nana C++ Library by employing libpng(), there are two strategies for the support:
1, use the libpng bundled with Nana;
2, use the libpng from operating system, it means that we have to install the libpng by ourselves.... read more
This is a new feature, it will be shown up in next release(0.9)
A new class cell represents the format of a sub item of listbox, including text, background and foreground color.
Thank qPCR4vir for creating this feature.
Another modification is to introduce two class iresolver/oresolver into for displacing resolver_interface.... read more
This is a new feature, it will be shown up in next release(0.9)
A new i18n method was introduced into class widget.
~~~~~~
:::C++
int main()
{
using namespace nana;
form fm(API::make_center(300, 44)); button btn(fm, rectangle{10, 10, 280, 24}); nana::internationalization i18n; i18n.load("en.txt"); //Load the language file. auto reset_caption = [&]{ btn.i18n("Greetings", i18n("Chongqing"), i18n("China")); //is equal to //btn.caption(i18n("Greetings", i18n("Chongqing"), i18n("China"))); };... [read more](/p/nanapro/blog/2014/11/nana-i18n-overview/)
Let's start a tutorial to create a simple notepad, the simple notepad is a text editor allows the user to select and browse existing text files. This example also shows how you can use place, menubar, menu, textbox, msgbox, and filebox and their various options.
This example requires Nana 0.8 for C++11 and a C++11 compiler.
First of all, the whole program code is ready, and then we will go through each function.... read more
In version 0.6.3, Nana made a little improvement for 2 new features which can bring convenience for programming.
The Margin Property for Class Place
The margin specifies the empty space at side of the place field.
The div-text might look like this.Full example is here... read more
Hi, guys, Nana now faces insuperable difficulties with too little documentation. It wants your help when you get any thoughts or experience, please write it down, then create demos and articles to help people understand how to use this library.
Send your article to cnjinhao@hotmail.com, I am looking forward to it.
By the way, a new domain for the project is working now.
Regards!
Jinhae
1, The Elements
2, Compset and Item Renderer
3, Item Proxy
The item proxy is a basic type that can be used for accessing all items in a container
widget, such as listbox, treebox. Meanwhile, the item proxy is an iterator of the widget,
unlike the STL iterator, the value_type of the item_proxy is itself.
The iterators are a powerful technique and one of the fundamental design patterns. For ... read more
Nana provides a mechanism which can flexibly configure the image processing algorithms. For an abstract algorithm, there would be many implementations. For example, Nana C++ Library provides two stretch algorithms, they are bilinear interoplation and proximal interoplation, you can switch the algorithms under your requirement.
See the example at:... read more
In C++, objects often provide copy ability and moveability to duplicate or move from an existing object. But it was by making a widget copyable or movable caused more problems than it solves.
Dilemma
Suppose the button widget is copyable, E.g.
form fm1; button btn1(fm1); form fm2; button btn2(fm2); btn1 = btn2; //Assume that copy is allowed.
We can say that after copying, the caption, position and size of btn1 is same to btn2′s. But, which should be the parent of btn1? fm1 or fm2? and another important question is that the event handlers of btn2 should be copied to btn1?... read more
Requires: C++11, Nana 0.8
In this tutorial, we will make a GUI calculator with Nana C++ Library. The calculator that we build will look like:
Using nana::place which is introduced into Nana in the version of 0.5, we can create a such GUI easily.
Let's start the code.
~~~~~~
:::C++
This article is update for Nana 0.8, based on C++11.
Although C++ is a powerful and sytnax-agile language, in fact, many programmers don’t like to do GUI in C++, because it is so difficault to make GUI in C++. Some exsiting C++ GUI frameworks define their own rule that makes you write some stiff code for running, it always causes some problems, such as leaving your code in a deep inheritance hierarchy, making maintenance painful. Now, there is an alternative, Nana C++ Library, a pure C++ library that will guide you in doing GUI with your immense and extensive C++ knowledge/skill/idioms, it makes a great progress in doing GUI in C++.... read more