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 » Can't add/remove +/- sign [CanOpen()]
Can't add/remove +/- sign [CanOpen()] [message #24259] Thu, 07 January 2010 19:38 Go to previous message
galious is currently offline  galious
Messages: 28
Registered: March 2008
Promising Member
Hi,

I'm having problems removing the +/- sign of a tree node. The use case is as follow:

I want to create a tree, where some nodes potentially are slow to add their child-nodes. Therefore for thee slow nodes I set CanOpen() on this node to display the +/- sign. Once a users tries to open the node and during the open action we identify no children are available I want to remove the +/- sign.

An example is added below. Once you navigate to a node without folders in it I expect the +/- sign to disappear, however this doesn't happen. How should I solve this?

BR,

Martin


#include "CtrlLib/CtrlLib.h"

using namespace Upp;

struct App : TopWindow {
    TreeCtrl   tree;

    typedef App CLASSNAME;

    void OpenDir(int id) {
        String path = tree[id];

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

            if(n != "." && n != ".." && ff.IsFolder()) {
                tree.Add(id, CtrlImg::Dir(),
                          AppendFileName(path, n), n, true);
            }
        }
        
        // I expect to get the +/- sign removed if a folder does not contain other folders
        // using the following code:
        if (tree.GetChildCount(id) == 0)
        {
            tree.GetNode(id).CanOpen(false);
            tree.Close(id);
	        tree.RefreshItem(id);     
        }
    }

    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(CtrlImg::Dir(), dir);

        Sizeable();
    }
};

GUI_APP_MAIN
{
    App().Run();
}
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Blinking tree when opening or closing nodes
Next Topic: OptionTree loses check state
Goto Forum:
  


Current Time: Tue Nov 12 14:23:59 CET 2019

Total time taken to generate the page: 0.00980 seconds