Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Problem with Drag&Drop in ArrayCtrl
Re: Problem with Drag&Drop in ArrayCtrl [message #22580 is a reply to message #22577] |
Tue, 28 July 2009 09:49   |
 |
koldo
Messages: 3437 Registered: August 2008
|
Senior Veteran |
|
|
Hello Mirek
Thank you for the testcase. I have changed it to show the problem.
RefreshRow works well but Drag & Drop does not work while there are thumbnails to be loaded.
To run it put the file "c:\\demo.jpg" that will be the thumbnail to be loaded.
Perhaps to do this right would I have to use multitasking ?
Best regards
Koldo
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
Array <Image> imgLst;
struct TestDisplay : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
w.DrawRect(r, paper);
int id = q.Is<int>() ? q : -1;
if (id >= 0 && id < imgLst.GetCount()) {
Rect rect(r.left, r.top, r.left+70, r.top+70);
if (imgLst[id])
w.DrawImage(rect, imgLst[id]);
else
Display::Paint(w, r, "Image not loaded", ink, paper, style);
} else
Display::Paint(w, r, "Image not available", ink, paper, style);
}
};
struct App : TopWindow {
ArrayCtrl a, b;
Splitter s;
TimeCallback tb;
void Timer()
{
for (int i = 0; i < imgLst.GetCount(); ++i) {
if (!imgLst[i]) {
imgLst[i] = StreamRaster::LoadFileAny("c:\\demo.jpg");
a.RefreshRow(i);
return;
}
}
}
void DnD(PasteClip& d)
{
if(AcceptText(d)) {
a.Add(GetString(d), GetString(d));
a.SetFocus();
}
}
void DnDInsert(int line, PasteClip& d)
{
if(AcceptInternal<ArrayCtrl>(d, "array")) {
a.InsertDrop(line, d);
a.SetFocus();
}
if(AcceptText(d)) {
a.Insert(line);
a.Set(line, 0, GetString(d));
a.SetCursor(line);
a.SetFocus();
}
}
void DnDInsertB(int line, PasteClip& d)
{
if(AcceptInternal<ArrayCtrl>(d, "array")) {
const ArrayCtrl& src = GetInternal<ArrayCtrl>(d);
bool self = &src == &b;
Vector< Vector<Value> > data;
for(int i = 0; i < src.GetCount(); i++)
if(src.IsSel(i)) {
Value v = src.Get(i, 0);
data.Add().Add(IsNumber(v) ? FormatIntRoman((int)src.Get(i, 0)) : String(v));
}
b.InsertDrop(line, data, d, self);
b.SetFocus();
}
}
void Drag()
{
if(a.DoDragAndDrop(InternalClip(a, "array")) == DND_MOVE)
a.RemoveSelection();
}
void DragB()
{
if(b.DoDragAndDrop(InternalClip(b, "array"), b.GetDragSample()) == DND_MOVE)
b.RemoveSelection();
}
typedef App CLASSNAME;
App() {
a.AddColumn("You can paste the text here too").SetDisplay(Single<TestDisplay>());
a.MultiSelect();
a.WhenDropInsert = THISBACK(DnDInsert);
a.WhenDrop = THISBACK(DnD);
a.WhenDrag = THISBACK(Drag);
a.SetLineCy(70);
b.AddColumn("Roman numbers");
b.MultiSelect();
b.WhenDropInsert = THISBACK(DnDInsertB);
b.WhenDrag = THISBACK(DragB);
Add(s.Horz(a, b));
for(int i = 0; i < 40; i++) {
a.Add(i);
imgLst.Add();
b.Add(FormatIntRoman(i, true));
}
Sizeable();
tb.Set(-200, THISBACK(Timer));
}
};
GUI_APP_MAIN
{
App().Run();
}
Best regards
IƱaki
|
|
|
 |
|
Problem with Drag&Drop in ArrayCtrl
By: koldo on Wed, 15 July 2009 18:02
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Sat, 18 July 2009 13:51
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Sun, 26 July 2009 17:28
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Sun, 26 July 2009 23:50
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Mon, 27 July 2009 03:19
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Mon, 27 July 2009 09:03
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Mon, 27 July 2009 17:20
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Tue, 28 July 2009 00:15
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Tue, 28 July 2009 03:06
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Tue, 28 July 2009 09:49
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mrjt on Tue, 28 July 2009 13:59
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mrjt on Tue, 28 July 2009 14:24
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Tue, 28 July 2009 16:24
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mrjt on Tue, 28 July 2009 17:08
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Tue, 28 July 2009 22:56
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Wed, 29 July 2009 05:48
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Wed, 29 July 2009 08:34
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Wed, 29 July 2009 08:45
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Wed, 29 July 2009 13:16
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Fri, 31 July 2009 19:04
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: koldo on Thu, 13 August 2009 13:42
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl [SOLVED]
By: koldo on Wed, 26 August 2009 09:17
|
 |
|
Re: Problem with Drag&Drop in ArrayCtrl
By: mirek on Sun, 26 July 2009 17:28
|
Goto Forum:
Current Time: Fri Jul 18 07:32:03 CEST 2025
Total time taken to generate the page: 0.04616 seconds
|