#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class DndTest : public TopWindow {
public:
typedef DndTest CLASSNAME;
DndTest();
Vector<String> files;
virtual void Paint(Draw &w);
void TextLine(Draw &w, Point &p, const String &txt);
virtual void DragAndDrop(Point p, PasteClip& d);
};
void DndTest::Paint(Draw &w)
{
TopWindow::Paint(w);
Point p(2, 2);
TextLine(w, p, "Files:");
if (files.GetCount())
for (int i = 0; i < files.GetCount(); i++)
TextLine(w, p, files[i]);
else
TextLine(w, p, "None");
}
void DndTest::TextLine(Draw &w, Point &p, const String &txt)
{
w.DrawText(p.x, p.y, txt);
p.y += StdFont().GetHeight()+1;
}
// This is the important bit:
void DndTest::DragAndDrop(Point p, PasteClip& d)
{
if (AcceptFiles(d)) {
files = GetFiles(d);
Refresh();
}
}
DndTest::DndTest()
{
Title("I need files!");
SetRect(0, 0, 200, 400);
CenterScreen();
}
GUI_APP_MAIN
{
DndTest().Run();
}
]]>