A great job !! treebox and listbox.

Nov 20, 2013 at 1:54 PM
Congratulation ! I love your work.
It was amazing to see that in only about one day of coding my "sequence explorer" is already working. It is a combination of a tree and a list. "Out of the box" I have check boxes in both (this was a serious problem in my project), and the user can with a simple click resize and reorganize the columns and order the data in it !! All of that for free for me, with no effort !!! It is also very fast. It is faster than C++/CLI using .NET 4.5.1 in Windows 7. It was no very hard to implement context-menus. And of course it is hundreds times faster than importing the data into Excel to reorder and format it.
But you know that. Here is my experience with these widgets:

OK, the documentation is not updated (yet). No problem: the MSVS2013 can navigate the code and offers auto-completion, etc., etc. and I hope other IDE can do too. Also, with doxygen I have a very good automatic and actualized variant of the documentation. Your "official" documentation is of course the best variant for a final user of Nana, but it can wait until you have a more stable interface to document.

By the way, a function to insert a new item in the list have disappeared and I need to use
list.at(0).append(new_value);
This may be good to remember me about the categories.. but some times I don´t care about they and I simple want to insert new items in the list.

I would like very much to have drag & drop capabilties for both, to let the user reorganize the sequences (my items) into different groups (my nodes). I realize this is far from simple and is something more general that these widgets, so, take it easy but keep in mind.

We have a problem once again with a 64b compilation. When you scroll the list with a mouse wheel, it work good "down", but "up" it sometimes make all the items disappear (they appear again when you move down again), and eventually it make the whole program crash. (see line 1869 in listbox.cpp).
I think this is not an issue specific to Nana, but a problem with a huge generality of the STL (or even a more general problem!). STL use a number of a "big" and "unspecified" type (size_t) to keep track of the number of elements (with a maximum of npos). Cling good. But then we use this type for the indexes. No problem. But what if you need to remember millions of these index? Maybe your "array" have a dozen of elements, but you are forced to keep track of it in an unsigned long long with a waste of 64b !! I dont think we will have more items in a menu than a "char" index can keep, or pixel coordenate in an int (not even unsigned!). Many standard functions will return a npos for "non-value" with you can compare for equality with your index only if they are of the same type. What we realy need is a "non-value" value, preferably universal. Inside nana (or any other particular library) we can not solve this general problem. So we need some work around and a lot of discipline. I dont have the solution. My idea is something like this. Let introduce some "universal" maximum we consider useful for each group of "use". A kind of:
using MIndex = unsigned char;

const MIndex  Invalid_Menu_idx = std::numeric_limits<MIndex>::max();   
            // global ?? Could be another "logical" value, for example, just 100.
 
MIndex  idx{Invalid_Menu_idx};

{ auto t_idx=std::find(some_menu_item....);
  if (t_idx == npos )
           t_idx = Invalid_Menu_idx ;

  idx = t_idx;     // use a cast to avoid false warning??
}                      // this could be a "graped" for some standard function

if (idx == Invalid_Menu_idx)
     ;   // not found
else
     ;    // found
or: (with do not depend on npos, and only assume that npos > Invalid_Menu_idx )
  auto t_idx=std::find(some_menu_item....);
  if ( t_idx >= Invalid_Menu_idx )
          idx = Invalid_Menu_idx ;  // not found
  else
          idx = t_idx;            // found, use a cast to avoid false warning??
I guess we can do some "clever" automation of this.
Nov 21, 2013 at 11:18 PM
Edited Nov 21, 2013 at 11:18 PM
Some warnings:
1>  listbox.cpp
1>..\..\source\gui\widgets\listbox.cpp(1286): warning C4309: '=' : truncation of constant value
1>..\..\source\gui\widgets\listbox.cpp(2890): warning C4309: '=' : truncation of constant value
1>  float_listbox.cpp
1>..\..\source\gui\widgets\float_listbox.cpp(303): warning C4267: 'initializing' : conversion from 'size_t' to 'const unsigned int', possible loss of data
Nov 24, 2013 at 1:12 AM
Edited Nov 24, 2013 at 1:15 AM
Hallo!!
I have the following problem: trying to process a check message in a treebox I have a crash accesing the value. There is some "super" node, not accesible for me with have no value and an emtpy key and text, that cause the crash when all the child nodes have been allready cheked. In treebox.cpp, in function:
void trigger::check(node_type* node, checkstate cs)
there is a
        node_type * owner = node->owner;
        while(owner){
 ....
         
                 impl_->set_checked(owner, cs);
         owner = owner->owner;
}
For me this FIX two time in this function works: if (node->owner ) /// SUPER NODE, have no value
But maybe you want to use te verify function...
                void trigger::check(node_type* node, checkstate cs)
                {
                    if(checkstate::unchecked != cs)
                        cs = checkstate::checked;

                    if(node->value.second.checked != cs)
                    {
                        if (node->owner  )   /// SUPER NODE, have no value
                          impl_->set_checked(node, cs);
                        //First, check the children of node
                        node_type * child = node->child;
                        while(child)
                        {
                            impl_->check_child(child, cs != checkstate::unchecked);
                            child = child->next;
                        }

                        //Then, change the parent node check state
                        node_type * owner = node->owner;
                        while(owner)
                        {
                            std::size_t len_checked = 0;
                            std::size_t size = 0;
                            checkstate cs = checkstate::unchecked;
                            child = owner->child;
                            while(child)
                            {
                                ++size;
                                if(checkstate::checked == child->value.second.checked)
                                {
                                    ++len_checked;
                                    if(size != len_checked)
                                    {
                                        cs = checkstate::partial;
                                        break;
                                    }
                                }
                                else if((checkstate::partial == child->value.second.checked) || (len_checked && (len_checked < size)))
                                {
                                    cs = checkstate::partial;
                                    break;
                                }
                                child = child->next;
                            }

                            if(size && (size == len_checked))
                                cs = checkstate::checked;

                            if(cs == owner->value.second.checked)
                                break;
                            if (owner->owner   )   /// SUPER NODE, have no value
                              impl_->set_checked(owner, cs);
                            owner = owner->owner;
                        }
                    }
                }
Nov 25, 2013 at 12:55 PM
Edited Nov 25, 2013 at 12:57 PM
Hi !
With this Fix I can now color the list item (listbox.cpp:2462)
item_proxy& item_proxy::fgcolor(nana::color_t col)
{
    ess_->lister.at_abs(cat_, pos_).fgcolor = col;   // why = 0 ; ???? 
    ess_->update();
    return *this;
}
Coordinator
Nov 26, 2013 at 6:15 AM
Hi,
I'm sorry for the late reply, and hope that the library keeps your "sequence explorer" working fine :-), of curose, i know there might be some potential library bugs would make your program crash.
list.at(0).append(new_value);
I noticed that, in many situations, we do not need to take care about the categories, those old methods which are operations for the default "category 0" should be kept. The drag&drop is a general feature for some widgets, such as, listbox and treebox, it should also be supported.

The mouse wheel error is fixed, the listbox did not check the scrollbar when it reached the "bottom". For the npos issue, it should keep on conforming with the concept like std::basic_string's, this might make it simpler. The only problem is a waste of memory in x64, should we ignore this problem?
ess_->lister.at_abs(cat_, pos_).fgcolor = col;   // why = 0 ; ???? 
No reason, just a mistake, you have fixed it up.

Here I missed a basic point, that is a item_proxy which is returned by treebox.find(STR("")) refers to the ROOT node, operating the ROOT node may cause many errors, because the ROOT node is the top of the node of the tree, and also is an internal data which should not be operated. I think the find(STR("")) method should return an "end" item_proxy to avoid these diffcult problems.