> hello ROOTERS,
>
> I'm trying to make a simple dialog box from within the CINT-environment.
> I already know I have to use TRootContextmenu, or TRootDialog or something
> like that, but I don't seem to get it right.
>
> Can someone please tell me how to make a simple dialog box (and read the
> input) or point me to an example ?
>
> thanx in advance,
>
> Rene Scholte
Try this one:
************************ Cut Here *************************************
// Example of creating a Dialog Window with customizable message
// Returns string typed in text entry
///////////////////////////////////////////////////////////////////////////
// //
// Dialog Window Objects //
// //
///////////////////////////////////////////////////////////////////////////
// Transient frame for standalone Dialo Window
TGTransientFrame *rTFrm;
// Dialog Label showing information string
TGLabel *rDgLbl;
// Text buffer associated with text entry declared bellow
TGTextBuffer *rTFBuf;
// Text entry object for new value for rLbl object string
TGTextEntry *rTE;
// OK button invokec procesdure for applying changes
TGButton *rOKb;
// Cancel button does nothing and close Dialog Window
TGButton *rCancelb;
char *tempstr;
// Create Dialog Window
char *StrDialog(char *desc = "Change String Dialog", char *defval = "Text")
{
rTFrm = new TGTransientFrame(gClient->GetRoot(),
gClient->GetRoot(),
400, 400);
rDgLbl = new TGLabel(rTFrm, desc) ;
rTFBuf = new TGTextBuffer(256);
rTFBuf->AddText(0, defval);
rTE = new TGTextEntry(rTFrm, rTFBuf);
rOKb = new TGTextButton(rTFrm, "Ok", "DialogAction($MSG,$PARM1,$PARM2)",
21
);
rCancelb = new TGTextButton(rTFrm, "Cancel",
"DialogAction($MSG,$PARM1,$PARM2)",
22
);
rTFrm->AddFrame(rDgLbl, new TGLayoutHints(kLHintsExpandX));
rTFrm->AddFrame(rTE, new TGLayoutHints(kLHintsExpandX));
rTFrm->AddFrame(rOKb, new TGLayoutHints(kLHintsExpandX));
rTFrm->AddFrame(rCancelb, new TGLayoutHints(kLHintsExpandX));
rTFrm->SetWindowName("Set String");
rTFrm->MapSubwindows();
rTFrm->Resize(rTFrm->GetDefaultSize());
rTFrm->MapWindow();
gClient->WaitFor(rTFrm);
return(tempstr);
}
// Amalogy for ProcessMessage method
void DialogAction(Long_t msg, Long_t parm1, Long_t parm2)
{
switch (GET_MSG(msg)) {
case kC_COMMAND:
switch (GET_SUBMSG(msg)) {
case kCM_BUTTON:
switch (parm1) {
case 21:
tempstr = StrDup(rTE->GetBuffer()->GetString());
delete rDgLbl;
delete rTE;
delete rOKb;
delete rCancelb;
delete rTFrm;
break;
case 22:
delete rDgLbl;
delete rTE;
delete rOKb;
delete rCancelb;
delete rTFrm;
break;
}
default:
break;
}
default:
break;
}
}
**************************** Cut Here **************************
Sorry for the layout, this was my first interactive ROOT gui and
I didn't make it nicer ....
Happy ROOTing
Radovan