42Drag and Drop support is implemented on Linux via Xdnd, the\n\
43drag and drop protocol for X window system, and on Windows\n\
45Users can selects something in ROOT with a mouse press, drags\n\
46it (moves the mouse while keeping the mouse button pressed) and\n\
47releases the mouse button somewhere else. When the button is\n\
48released the selected data is \"dropped\" at that location. This\n\
49way, a histogram from an opened ROOT file in the browser can be\n\
50dragged to any TCanvas. A script file from the browser can be\n\
51dropped to a TGTextView or TGTextEdit widget in TGTextEditor.\n\
52On Linux, it is possible to drag objects between ROOT and an\n\
53external application. For example to drag a macro file from the\n\
54ROOT browser to the Kate editor. On Windows, drag and drop works\n\
55only within a single ROOT application, but it is possible to drag\n\
56from the Windows Explorer to ROOT (e.g. a picture file to a canvas\n\
57or a text file to a text editor).\n\
60const char gReadyMsg[] =
"Ready. You can drag list tree items to any \
61pad in the canvas, or to the \"Base\" folder of the list tree itself...";
86 void HandleMenu(
Int_t);
87 TObject *GetObject(
const char *obj);
104 "ROOT files",
"*.root",
105 "ROOT macros",
"*.C",
113DNDMainFrame::DNDMainFrame(
const TGWindow *
p,
int w,
int h) :
125 fMenuFile->AddEntry(
" &Open...\tCtrl+O",
M_FILE_OPEN, 0,
126 gClient->GetPicture(
"bld_open.png"));
130 fMenuFile->AddSeparator();
131 fMenuFile->AddEntry(
" E&xit\tCtrl+Q",
M_FILE_EXIT, 0,
132 gClient->GetPicture(
"bld_exit.png"));
133 fMenuFile->Connect(
"Activated(Int_t)",
"DNDMainFrame",
this,
134 "HandleMenu(Int_t)");
138 gClient->GetPicture(
"about.xpm"));
139 fMenuHelp->Connect(
"Activated(Int_t)",
"DNDMainFrame",
this,
140 "HandleMenu(Int_t)");
152 fListTree->Associate(
this);
158 fCanvas =
fEc->GetCanvas();
159 fCanvas->Divide(3, 2);
160 fCanvas->SetBorderMode(0);
161 fBaseLTI = fListTree->AddItem(0,
"Base");
167 fStatus->SetTextColor(0x0000ff);
173 fButtonExit->SetToolTipText(
"Exit Application (ROOT)");
186 fListTree->SetToolTipItem(item,
"Simple Graph");
192 fListTree->SetToolTipItem(item,
"1D Histogram");
198 fListTree->SetToolTipItem(item,
"2D Histogram");
214 pic =
gClient->GetPicturePool()->GetPicture(
"rose512",
img->GetPixmap(),
219 link.Prepend(
"file://");
222 fListTree->SetToolTipItem(item,
link.Data());
228 fListTree->GetFirstItem()->SetDNDTarget(
kTRUE);
231 fListTree->Connect(
"DataDropped(TGListTreeItem*, TDNDData*)",
"DNDMainFrame",
232 this,
"DataDropped(TGListTreeItem*,TDNDData*)");
234 SetWindowName(
"ROOT DND Demo Application");
236 Resize(GetDefaultSize());
237 Connect(
"CloseWindow()",
"DNDMainFrame",
this,
"DoCloseWindow()");
242DNDMainFrame::~DNDMainFrame()
248void DNDMainFrame::DoCloseWindow()
252 if (fGraph) {
delete fGraph; fGraph = 0; }
253 if (fHist1D) {
delete fHist1D; fHist1D = 0; }
254 if (fHist2D) {
delete fHist2D; fHist2D = 0; }
255 fMenuFile->Disconnect(
"Activated(Int_t)",
this,
"HandleMenu(Int_t)");
256 fMenuHelp->Disconnect(
"Activated(Int_t)",
this,
"HandleMenu(Int_t)");
257 fButtonExit->Disconnect(
"Clicked()" ,
this,
"CloseWindow()");
258 fListTree->Disconnect(
"DataDropped(TGListTreeItem*, TDNDData*)",
this,
259 "DataDropped(TGListTreeItem*,TDNDData*)");
270 fStatus->SetTextColor(0xff0000);
271 fStatus->ChangeText(
"I received data!!!");
280 sprintf(tmp,
"Received DND data : Type = \"%s\"; Length = %d bytes;",
289 fListTree->SetToolTipItem(
itm, obj->
GetName());
292 sprintf(tmp,
"Received DND data: \"%s\"", (
char *)
data->fData);
298 pic =
gClient->GetPicturePool()->GetPicture(
"doc_lnk",
img1->GetPixmap(),
305 fListTree->SetToolTipItem(
itm, (
const char *)
data->fData);
308 fStatus->ChangeText(tmp);
314TObject *DNDMainFrame::GetObject(
const char *obj)
319 if (!
strcmp(obj,
"Graph")) {
325 y[i] = 10*sin(
x[i]+0.2);
331 else if (!
strcmp(obj,
"1D Hist")) {
333 fHist1D =
new TH1F(
"1D Hist",
"This is the px distribution",100,-4,4);
335 for (
Int_t i=0; i<10000; i++) {
342 else if (!
strcmp(obj,
"2D Hist")) {
345 130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3
347 TF2 *f2 =
new TF2(
"f2",
"xygaus + xygaus(5) + xylandau(10)",
350 fHist2D =
new TH2F(
"2D Hist",
"xygaus+xygaus(5)+xylandau(10)",
351 20, -4, 4, 20, -4, 4);
352 fHist2D->FillRandom(
"f2",40000);
387 gROOT->MakeDefCanvas();
401void DNDMainFrame::ResetStatus()
405 fStatus->SetTextColor(0x0000ff);
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
R__EXTERN TRandom * gRandom
R__EXTERN TSystem * gSystem
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
Using a TBrowser one can browse all ROOT objects.
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Drag and drop data container.
virtual void SetParameters(const Double_t *params)
A 2-Dim function with parameters.
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
This class creates a file selection dialog.
A composite frame that layout their children in horizontal way.
TGHotString is a string with a "hot" character underlined.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
void SetDNDSource(Bool_t onoff)
A list tree is a widget that can contain a number of items arranged in a tree structure.
Defines top level windows that interact with the system Window Manager.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Yield an action as soon as it is clicked.
ROOT GUI Window base class.
A TGraph is an object made of two arrays X and Y with npoints each.
1-D histogram with a float per channel (see TH1 documentation)
2-D histogram with a float per channel (see TH1 documentation)
An abstract interface to image processing library.
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
const char * GetName() const override
Returns name of object.
Collectable string class.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
This class creates a TGCanvas in which a TCanvas is created.
A TRootHelpDialog is used to display help text (or any text in a dialog window).
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.