besh81 / nana-extra Goto Github PK
View Code? Open in Web Editor NEWA collection of Nana custom controls
A collection of Nana custom controls
i want to write the property values, after the user has set them, to a database. But I do not get the new values set by the user.
This code ( based on demo with save button added )
#include <nana/gui.hpp>
#include <nana/gui/place.hpp>
#include <nana/gui/widgets/textbox.hpp>
#include "propertygrid.h"
#include "pgitems.h"
int main()
{
nana::form fm(0, nana::size{ 600, 500 });
nana::place pl{ fm };
pl.div("margin=50 gap=5 field");
nana::propertygrid propgrid{ fm };
pl["field"] << propgrid;
nana::textbox txt{ fm };
pl["field"] << txt;
txt.editable(false);
// append category
auto cat = propgrid.append("Standard properties");
// append string property
cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string("string", "ABC")));
// append int property
cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string_int("int", "-100")));
// append unsigned int property
cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string_uint("unsigned int", "100")));
// append string with button property
cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string_button("string + button", "Ciao")));
// append choice property
auto ip = cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_choice("choice")));
auto pgchoiche = static_cast<nana::pg_choice*>(ip._m_pgitem());
pgchoiche->push_back("One");
pgchoiche->push_back("Two");
pgchoiche->push_back("3");
// append check property
cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_check("check", true)));
// append color property
cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_color("color", "255,0,0")));
// append color+inherited property
ip = cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_color("color + inherited", "128,128,128", true)));
ip.value("0,255,0");
// connect the events
propgrid.events().property_changed([&txt](const nana::arg_propertygrid& arg)
{
auto ip = arg.item;
txt.append("[cat: " + std::to_string(ip.pos().cat) + ", pos: " + std::to_string(ip.pos().item) + "] ", true);
txt.append(" label: " + ip.label() + "\n", true);
});
// Save button will read the current value of the int properrty
nana::button save(fm,nana::rectangle{5,5,40,25},true);
save.caption("SAVE");
save.events().click([&propgrid]()
{
std::string t = propgrid.find("Standard properties","int").value();
nana::msgbox msg("Current Value of int property");
msg << t;
msg.show();
});
pl.collocate();
fm.show();
nana::exec();
}
Shows this result after user changes int property to 34
I want to start up my application with the categories collapsed.
( There are over 100 properties, so it is overwhelming to see all of them at once )
I tried:
cat = propgrid.append("Output Ports");
cat.expand( false );
but expand is not a method of the cat_proxy class returned by append.
It is an attribute of the structure category_t
cat_proxy does have a private attribute that is a pointer to a category_t structure, so maybe that is what I need?
I am requesting that categories should not only contain property items, but also child categories.
Something like this:
// append category to top level
auto parent_cat = propgrid.append("Parent");
// append category under parent
auto child_cat = propgrid.appendIn( parent_cat, "Child" );
Motivation
I was hoping to port my wxWidgets property grid application to nana. This has over 100 properties, so having just one level of category makes finding a particular property difficult for the user. Here is a screenshot of the wxWidgets app:
On startup, all categories are collapsed, hiding their children and so helping the user find what needs to be looked at in detail:
With categories expanded:
pgitem should have a virtual destructor, otherwise the derived class will not destruct and there will be memory leaks.
C:\Users\James\code\nana-extra\propertygrid\pgitems.cpp:12:10: fatal error: lock_guard.h: No such file or directory
There is a generous vertical gap between properties. Would it be possible to have an option to adjust the size of this gap, or even eliminate it entirely.
My application has over 100 properties, so there is a lot of scrolling when many categories are expanded.
Here is a screenshot of the app built with wxWidgets, which has no vertical gap between properties.
nana-extra/propertygrid/propertygrid.h
Line 259 in a032cdb
The comment on the declaration of this method suggests it is for internal use only.
Yet I seem to need to use it very often in my application code.
Creating a choice property ( this is from your demo code )
auto ip = cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_choice("choice")));
auto pgchoiche = static_cast<nana::pg_choice*>(ip._m_pgitem());
pgchoiche->push_back("One");
pgchoiche->push_back("Two");
pgchoiche->push_back("3");
and also when I need to select a choice
int selected;
... set selected...
(static_cast<nana::pg_choice*>(pg.find("Output Ports","A Format")._m_pgitem()))->option( selected ));
So, my questions:
nana-extra/propertygrid/propertygrid.cpp
Line 711 in a032cdb
My compiler ( g++ v8.3 ) does not like this, reporting an uninitialized variable.
Probably should add
pos_offset_end = 0;
nana-extra/propertygrid/pgitems.cpp
Lines 414 to 423 in 0beab38
The intention here ( I assume - there is no documentation ) is to select a new option. It fails. Instead the current value is set again.
At a minimum, line 418 should be changed to
option(std::stoul( value_ ));
I would also change the name of the parameter - it looks like a class member.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.