mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-10-06 00:30:10 -06:00
Merge continued
git-svn-id: svn://ultimatepp.org/upp/trunk@10263 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2582d7f364
commit
3cd394812c
3860 changed files with 1161787 additions and 438 deletions
62
uppdev/TreeCtrlDnD/main.cpp
Normal file
62
uppdev/TreeCtrlDnD/main.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#include "CtrlLib/CtrlLib.h"
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct App : TopWindow {
|
||||
TreeCtrl tree;
|
||||
Array<Option> option;
|
||||
|
||||
typedef App CLASSNAME;
|
||||
|
||||
void DropInsert(int parent, int ii, PasteClip& d)
|
||||
{
|
||||
tree.AdjustAction(parent, d);
|
||||
if(AcceptInternal<TreeCtrl>(d, "mytreedrag")) {
|
||||
tree.InsertDrop(parent, ii, d);
|
||||
tree.SetFocus();
|
||||
return;
|
||||
}
|
||||
if(AcceptText(d)) {
|
||||
tree.SetCursor(tree.Insert(parent, ii, Image(), GetString(d)));
|
||||
tree.SetFocus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Drag()
|
||||
{
|
||||
int c = tree.DoDragAndDrop(InternalClip(tree, "mytreedrag"),
|
||||
tree.GetDragSample());
|
||||
PromptOK(AsString(c));
|
||||
if(c == DND_MOVE) {
|
||||
PromptOK("Hey!");
|
||||
tree.RemoveSelection();
|
||||
}
|
||||
}
|
||||
|
||||
App() {
|
||||
Add(tree.SizePos());
|
||||
Vector<int> parent, parent2;
|
||||
parent.Add(0);
|
||||
tree.SetRoot(Image(), "The Tree");
|
||||
for(int i = 1; i < 10000; i++) {
|
||||
|
||||
TreeCtrl::Node node(CtrlImg::File(), option.Add(), 20); // mine
|
||||
node.Set(FormatIntRoman(i, true));
|
||||
option.Top().NoWantFocus();
|
||||
parent.Add(tree.Add(parent[rand() % parent.GetCount()], node)); // mine
|
||||
if((rand() & 3) == 0)
|
||||
tree.Open(parent.Top());
|
||||
}
|
||||
tree.Open(0);
|
||||
tree.WhenDropInsert = THISBACK(DropInsert);
|
||||
tree.WhenDrag = THISBACK(Drag);
|
||||
tree.MultiSelect();
|
||||
Sizeable();
|
||||
}
|
||||
};
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
App().Run();
|
||||
}
|
||||
Loading…
Reference in a new issue