mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
syncing uppdev
git-svn-id: svn://ultimatepp.org/upp/trunk@1929 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
e26d52b8d8
commit
03de5f35f6
17 changed files with 294 additions and 4 deletions
9
uppdev/TreeCtrlCanOpen/TreeCtrlCanOpen.upp
Normal file
9
uppdev/TreeCtrlCanOpen/TreeCtrlCanOpen.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
53
uppdev/TreeCtrlCanOpen/main.cpp
Normal file
53
uppdev/TreeCtrlCanOpen/main.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue