Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TreeCtrl » OptionTree loses check state
OptionTree loses check state [message #24445] Mon, 18 January 2010 00:53 Go to next message
galious is currently offline  galious
Messages: 28
Registered: March 2008
Promising Member
Hi,

when dynamically adding childs to a node in a OptionTree the check state of the both the childs and the parent is lost. E.G. using the code provided below try to tick on the root node (while it is still collapsed) and after expanding no checkbox will be ticked on.

I didn't expect this behaviour and so changed it in the UPP code:

in TreeCtrl.cpp

int OptionTree::Insert(int parentid, int i, const Image& img, const char *text)
{
	return Insert(parentid, i, img, aux.Add().Set(option[parentid]->Get()).NoNotNull(), text);
}

int OptionTree::Insert(int parentid, int i, const char *text)
{
	return Insert(parentid, i, aux.Add().Set(option[parentid]->Get()).NoNotNull(), text);
}


and to provide the chaining behaviour in Button.cpp (and of course I changed the declaration to):

Option&  Option::Set(int b) {
	if(b != option) {
		option = b;
		Update();
		RefreshPush();
	}
	
	return *this;
}



Finally the code I tested with:

#include "CtrlLib/CtrlLib.h"

using namespace Upp;

struct App : TopWindow {
    OptionTree   tree;

    typedef App CLASSNAME;

    void OpenDir(int id) {
        String path = tree.GetLabel(id);

        for(FindFile ff(AppendFileName(path, "*.*")); ff; ff.Next()) {
            String n = ff.GetName();

            if(n != "." && n != ".." && ff.IsFolder()) {
                int childId = tree.Add(id, AppendFileName(path, n));
                tree.SetNode(childId, tree.GetNode(childId).CanOpen(true));
            }
        }
    }

    void CloseDir(int id) {
        tree.RemoveChildren(id);
    }

    App() {
        Add(tree.SizePos());

        tree.WhenOpen = THISBACK(OpenDir);
        tree.WhenClose = THISBACK(CloseDir);

    #ifdef PLATFORM_WIN32
        String dir = String(GetExeFilePath()[0], 1) + ":\\";
    #else
        String dir = "/usr";
    #endif

        tree.SetRoot(dir);
        tree.Set(0, dir);

        Sizeable();
    }
};

GUI_APP_MAIN
{
    App().Run();
}


Is it possible to include this change (at the least changed behaviour) in UPP?

Best regards,

Martin Schut
Re: OptionTree loses check state [message #24562 is a reply to message #24445] Sun, 24 January 2010 15:05 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks, patch applied.
Previous Topic: Can't add/remove +/- sign [CanOpen()]
Next Topic: Distorted GUI / memory leak
Goto Forum:
  


Current Time: Thu Mar 28 12:09:03 CET 2024

Total time taken to generate the page: 0.01342 seconds