ultimatepp/uppdev/TreeCtrlCanOpen/main.cpp
cxl 3cd394812c Merge continued
git-svn-id: svn://ultimatepp.org/upp/trunk@10263 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2016-10-04 08:34:39 +00:00

53 lines
1.2 KiB
C++

#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)
{
TreeCtrl::Node node = tree.GetNode(id);
node.CanOpen(false);
tree.SetNode(id, node);
}
}
void CloseDir(int id) {
tree.RemoveChildren(id);
}
App() {
Add(tree.SizePos());
tree.WhenOpen = THISBACK(OpenDir);
tree.WhenClose = THISBACK(CloseDir);
String dir = "u:/upp.src";
tree.SetRoot(CtrlImg::Dir(), dir);
Sizeable();
}
};
GUI_APP_MAIN
{
App().Run();
}