91 "Enacapsulated PostScript",
"*.eps",
94 "ASImage XML",
"*.xml",
117 virtual ~TGuiBldMenuDialog();
122 void ConnectButtonSignals();
126 void Add(
const char *argname,
const char *value,
const char *
type);
143 fWidgets =
new TList();
153 ConnectButtonSignals();
165TGuiBldMenuDialog::~TGuiBldMenuDialog()
176void TGuiBldMenuDialog::ConnectButtonSignals()
180 fCancel->Connect(
"Pressed()",
"TGuiBldDragManager",
gGuiBldDragManager,
"DoDialogCancel()");
186void TGuiBldMenuDialog::ApplyMethod()
189 fObject->Execute(fMethod->GetName(), params);
197 static char params[1024];
210 TIter next(fWidgets);
213 while ((obj = next())) {
221 const char *data = 0;
229 if (selfobjpos == nparam-1) {
230 if (params[0]) strlcat(params,
",", 1024-strlen(params));
232 strlcat(params, param, 1024-strlen(params));
235 if (params[0]) strlcat(params,
",", 1024-strlen(params));
237 if (!strncmp(
type,
"char*", 5))
238 snprintf(param, 255,
"\"%s\"", data);
240 strlcpy(param, data,
sizeof(param));
242 strlcpy(param,
"0",
sizeof(param));
244 strlcat(params, param, 1024-strlen(params));
248 if (selfobjpos == nparam) {
249 if (params[0]) strlcat(params,
",", 1024-strlen(params));
251 strlcat(params, param, 1024-strlen(params));
267 ret +=
" [default: ";
283 b->AddText(0, value);
299void TGuiBldMenuDialog::CloseWindow()
307void TGuiBldMenuDialog::Build()
310 Int_t selfobjpos = -1;
312 TIter next(fMethod->GetListOfMethodArgs());
317 if (selfobjpos != argpos) {
319 const char *argname = arg_name.
Data();
322 const char *charstar =
"char*";
326 strlcpy(basictype, datatype->
GetTypeName(),
sizeof(basictype));
330 Warning(
"Dialog",
"data type is not basic type, assuming (int)");
331 strlcpy(basictype,
"int",
sizeof(basictype));
334 if (strchr(argname,
'*')) {
335 strlcat(basictype,
"*", 32-strlen(basictype));
340 if (
m &&
m->GetterMethod(fObject->IsA())) {
345 if (!strncmp(basictype,
"char*", 5)) {
347 m->GetterMethod()->Execute(fObject,
"", &tdefval);
348 if (tdefval && strlen(tdefval))
349 strlcpy(val, tdefval,
sizeof(val));
350 }
else if (!strncmp(basictype,
"float", 5) ||
351 !strncmp(basictype,
"double", 6)) {
353 m->GetterMethod()->Execute(fObject,
"", ddefval);
355 }
else if (!strncmp(basictype,
"char", 4) ||
356 !strncmp(basictype,
"bool", 4) ||
357 !strncmp(basictype,
"int", 3) ||
358 !strncmp(basictype,
"long", 4) ||
359 !strncmp(basictype,
"short", 5)) {
361 m->GetterMethod()->Execute(fObject,
"", ldefval);
369 if ((opt =
m->GetOptions())) {
370 Warning(
"Dialog",
"option menu not yet implemented");
380 if (tval) strlcpy(val, tval,
sizeof(val));
397 height = fOK->GetDefaultHeight();
410 fWidgets->Add(fCancel);
411 height = fCancel->GetDefaultHeight();
429void TGuiBldMenuDialog::Popup()
446 SetWMSize(
width, height);
447 SetWMSizeHints(
width, height,
width, height, 0, 0);
474 !
gClient->IsEditable())
return 0;
476 dst = src = child =
gVirtualX->GetDefaultRootWindow();
478 while (child && dst) {
481 gVirtualX->TranslateCoordinates(src, dst, xx, yy, xx, yy, child);
518 const char * ,
const char * )
523class TGuiBldDragManagerGrid {
534 TGuiBldDragManagerGrid();
535 ~TGuiBldDragManagerGrid();
537 void SetStep(
UInt_t step);
543ULong_t TGuiBldDragManagerGrid::fgPixel = 0;
544TGGC *TGuiBldDragManagerGrid::fgBgnd = 0;
549TGuiBldDragManagerGrid::TGuiBldDragManagerGrid()
564TGuiBldDragManagerGrid::~TGuiBldDragManagerGrid()
566 fWindow =
gClient->GetWindowById(fWinId);
569 fWindow->SetBackgroundPixmap(0);
570 fWindow->SetBackgroundColor(((
TGFrame*)fWindow)->GetBackground());
585void TGuiBldDragManagerGrid::SetStep(
UInt_t step)
592 fWinId = fWindow->
GetId();
601void TGuiBldDragManagerGrid::InitBgnd()
616 fgBgnd->SetForeground(fgPixel);
622void TGuiBldDragManagerGrid::InitPixmap()
628 fPixmap =
gVirtualX->CreatePixmap(
gClient->GetDefaultRoot()->GetId(), fgStep, fgStep);
629 gVirtualX->FillRectangle(fPixmap, fgBgnd->GetGC(), 0, 0, fgStep, fgStep);
633 fgStep - 1, fgStep - 1, 1, 1);
646 fWindow =
gClient->GetWindowById(fWinId);
648 if (fWindow && (fWindow !=
gClient->GetRoot())) {
659 fWinId = fWindow->
GetId();
667class TGuiBldDragManagerRepeatTimer :
public TTimer {
680class TGGrabRect :
public TGFrame {
734 gVirtualX->ChangeWindowAttributes(fId, &attr);
742 fClient->GetColorByName(
"black", back);
751 SetBackgroundPixmap(fPixmap);
766class TGAroundFrame :
public TGFrame {
776TGAroundFrame::TGAroundFrame() :
TGFrame(
gClient->GetDefaultRoot(), 1, 1,
784 gVirtualX->ChangeWindowAttributes(fId, &attr);
786 fClient->GetColorByName(
"blue", blue);
787 SetBackgroundColor(blue);
792class TGuiBldDragManagerPimpl {
803 TGuiBldDragManagerGrid *fGrid;
808 Int_t fGrabX, fGrabY;
810 Int_t fLastPopupAction;
821 TList *fFrameMenuTrash;
830 for (i = 0; i <8; i++) {
833 for (i = 0; i <4; i++) {
834 fAroundFrame[i] =
new TGAroundFrame();
837 fFrameMenuTrash =
new TList();
846 fX0 = fY0 =
fX =
fY = fXf = fYf = fGrabX = fGrabY = 0;
853 fGrabListPosition = 0;
857 fSpacePressedFrame = 0;
859 fFrameMenuTrash->
Delete();
863 ~TGuiBldDragManagerPimpl() {
865 for (i = 0; i <8; i++) {
868 for (i = 0; i <4; i++) {
869 delete fAroundFrame[i];
874 fFrameMenuTrash->
Delete();
875 delete fFrameMenuTrash;
900 fPimpl =
new TGuiBldDragManagerPimpl(
this);
927 fName =
"Gui Builder Drag Manager";
984 TList *methodList = IsA()->GetListOfMethods();
985 TIter next(methodList);
989 while ((method = (
TMethod*) next())) {
1008 fPimpl->fGrid =
new TGuiBldDragManagerGrid();
1025 fPimpl->fGrid->SetStep(step);
1108 if (
fPimpl->fGrab && (gid !=
fPimpl->fGrab->GetId())) {
1111 gid =
fPimpl->fGrab->GetId();
1132 for (
int i = 0; i < 8; i++) {
1171 if (
fStop || !frame) {
1193 str +=
" cannot be editted.";
1199 if (frame != comp) {
1227 str +=
"can not be selected";
1239 static Int_t x, x0,
y, y0, xx, yy;
1260 str +=
" Press SpaceBar to unselect the frame.";
1261 if (
IsFixedSize(frame)) str +=
" This frame cannot be resized.";
1282 fPimpl->fGrab->RequestFocus();
1385 str +=
" is grabbed";
1409 str +=
fPimpl->fGrab->GetName();
1410 str +=
" ungrabbed";
1423 while (parent && (parent !=
gClient->GetDefaultRoot())) {
1424 if (parent->
GetId() ==
id) {
1446 dst = src = child = w;
1451 gVirtualX->TranslateCoordinates(src, dst,
x,
y,
x,
y, child);
1478 if (
fPimpl->fPlacePopup) {
1487 if (now-was < 100) {
1507 fPimpl->fGrab->GetHeight()-2)) {
1539 fPimpl->fAroundFrame[0]->MapRaised();
1541 fPimpl->fAroundFrame[1]->MapRaised();
1543 fPimpl->fAroundFrame[2]->MapRaised();
1545 fPimpl->fAroundFrame[3]->MapRaised();
1547 for (
int i = 0; i < 4; i++)
fPimpl->fAroundFrame[i]->UnmapWindow();
1573 fPimpl->fGrabRect[i]->MapRaised();
1584 if (
fStop || !win || (win == gw)) {
1604 fPimpl->fPlane->ChangeOptions(
fPimpl->fPlane->GetOptions() & ~kRaisedFrame);
1634 static Int_t gy = 0;
1635 static Int_t gx = 0;
1636 static UInt_t gstate = 0;
1650 if (
fPimpl->fRepeatTimer) {
1652 fPimpl->fRepeatTimer->Reset();
1653 fPimpl->fRepeatTimer->Remove();
1708 fPimpl->fButtonPressed) {
1763 if (!
fPimpl->fSpacePressedFrame) {
1769 context_fr =
fPimpl->fSpacePressedFrame;
1779 fPimpl->fX0 =
event->fXRoot;
1780 fPimpl->fY0 =
event->fYRoot;
1784 fPimpl->fClickFrame = frame;
1798 if (frame ==
fPimpl->fGrab) {
1809 fPimpl->fX =
event->fXRoot;
1810 fPimpl->fY =
event->fYRoot;
1825 if (frame ==
fPimpl->fGrab) {
1870 fPimpl->fX =
event->fXRoot;
1871 fPimpl->fY =
event->fYRoot;
1884 if (
fStop || !frame) {
1984 win =
event->fWindow;
2003 switch (event->
fType) {
2027 static Long_t gLastClick = 0;
2028 static UInt_t gLastButton = 0;
2029 static Int_t gDbx = 0;
2030 static Int_t gDby = 0;
2032 if ((event->
fTime - gLastClick < 350) &&
2033 (event->
fCode == gLastButton) &&
2044 }
else if (!(event->
fState & 0xFF)) {
2058 gDbw =
event->fWindow;
2059 gLastClick =
event->fTime;
2060 gLastButton =
event->fCode;
2061 gDbx =
event->fXRoot;
2062 gDby =
event->fYRoot;
2217 event->fUser[0] = fr->
GetId();
2255 event->fUser[0] = w->
GetId();
2274 !
fPimpl->fGrab->IsEditable()) {
2316 return ((
TGFrame*)w)->HandleKey(event);
2326 event->fWindow = parent->
GetId();
2329 return ((
TGFrame*)w)->HandleKey(event);
2333 fPimpl->fSpacePressedFrame = 0;
2346 gVirtualX->LookupString(event, tmp,
sizeof(tmp), keysym);
2350 switch ((
EKeySym)keysym & ~0x20) {
2365 if (
fPimpl->fClickFrame && !
fPimpl->fClickFrame->IsEditable()) {
2465 }
else if (
fPimpl->fGrab) {
2513 Int_t x0, y0, xx, yy;
2517 if (!newfr || !newfr->
GetId() || !oldfr || !oldfr->
GetId())
return;
2522 x0 = x0 < 0 ? 0 : x0;
2523 y0 = y0 < 0 ? 0 : y0;
2540 if ((frame->
GetX() >= x0) && (frame->
GetY() >= y0) &&
2544 if (frame ==
fPimpl->fGrab) {
2551 frame->
GetX(), frame->
GetY(), xx, yy,
c);
2637 if (
fStop || !cont) {
2647 w = w < 100 ? 100 : w;
2648 h =
h < 100 ? 100 :
h;
2757 TString str =
"Grab action performed.";
2758 str +=
" Press Cntrl-Return to Drop grabbed frames.";
2759 str +=
" Presss Return for TCanvas Grab";
2763 }
else if (on &&
fPimpl->fGrab) {
2835 if ((fr->
GetX() >= x0) && (fr->
GetY() >= y0) &&
2845 else fr->
Move(x0, y0);
2859 else fr->
Move(x0, y0);
2922 str +=
fPimpl->fGrab->GetName();
2923 str +=
" cannot be deleted";
2969 if ((fr->
GetX() >= x0) && (fr->
GetY() >= y0) &&
3020 if (
fStop || !frame) {
3039 if (frame ==
fPimpl->fGrab) {
3076 fPimpl->fGrab->GetWidth(),
3077 fPimpl->fGrab->GetHeight());
3122 str +=
fPimpl->fGrab->GetName();
3123 str +=
" copied to clipboard";
3152 if (!
fPimpl->fReplaceOn) {
3207 str +=
fPimpl->fGrab->GetName();
3208 str +=
" replaced by ";
3219 fPimpl->fGrab->DestroyWindow();
3279 f->Resize(
f->GetWidth() + 10,
f->GetHeight() + 10);
3324 main->SetWMSizeHints(
main->GetDefaultWidth(),
main->GetDefaultHeight(), 10000, 10000, 0, 0);
3329 if (
gVirtualX->InheritsFrom(
"TGX11"))
main->SetIconPixmap(
"bld_rgb.xpm");
3330 main->SaveSource(fname.
Data(),
file ?
"keep_names quiet" :
"keep_names");
3347 main->RaiseWindow();
3436static Int_t canResize(TGFrame *frame, Int_t x, Int_t y, UInt_t &w, UInt_t &h)
3438 if (frame->InheritsFrom(TGCompositeFrame::Class())) return 0;
3440 TGCompositeFrame *comp = (TGCompositeFrame*)frame;
3442 TIter next(comp->GetList());
3444 Int_t d = gGuiBldDragManager->GetGridStep();
3447 while ((fe = (TGFrameElement*)next())) {
3448 if (x + fe->fFrame->GetX() + fe->fFrame->GetWidth() > w) {
3449 w = fe->fFrame->GetX() + x + fe->fFrame->GetWidth();
3452 if (y + fe->fFrame->GetY() + fe->fFrame->GetHeight() > h) {
3453 h = fe->fFrame->GetY() + y + fe->fFrame->GetHeight();
3502 switch (
fPimpl->fResizeType) {
3504 if ((((
int)fr->
GetWidth() >
x) || (
x < 0)) &&
3507 if (fr->
GetY() +
y < 2) {
3510 if (fr->
GetX() +
x < 2) {
3533 if ((
x > 0) && (((
int)fr->
GetHeight() >
y) || (
y < 0))) {
3535 if (fr->
GetY() +
y < 2) {
3561 if (fr->
GetY() +
y < 2) {
3573 if ((((
int)fr->
GetWidth() >
x) || (
x < 0)) && (
y > 0)) {
3575 if (fr->
GetX() +
x < 2) {
3598 if ((
x > 0) && (
y > 0)) {
3603 w = fr->
GetX() + w > wp ? wp - fr->
GetX() : w;
3628 if (fr->
GetX() +
x < 2) {
3706 Bool_t move = (
x > 0) && (
y > 0) && ((
x +
fPimpl->fGrab->GetWidth()) < (w - 0)) &&
3707 ((
y +
fPimpl->fGrab->GetHeight()) < (
h - 30));
3711 if (!move && !
gVirtualX->InheritsFrom(
"TGX11")) {
3722 str +=
fPimpl->fGrab->GetName();
3723 str +=
" is moved to absolute position ";
3757 if (
fStop || !comp) {
3821 if (w && (w !=
gVirtualX->GetDefaultRootWindow())) {
3841 if ((comp !=
fPimpl->fGrab) && (
x >= 0) && (
y >= 0) &&
3894 static Int_t gy =
event->fYRoot;
3895 static Int_t gx =
event->fXRoot;
3915 fPimpl->fX =
event->fXRoot;
3916 fPimpl->fY =
event->fYRoot;
3966 x =
x > x0 ? x0 :
x;
3967 y =
y > y0 ? y0 :
y;
3984 frame->
Resize(w < grid ? grid : w,
h < grid ? grid :
h);
3987 frame->
Resize(w < grid ? 15*grid : w,
h < grid ? 30*grid :
h);
3989 frame->
Resize(w < grid ? 30*grid : w,
h < grid ? 15*grid :
h);
3991 else frame->
Resize(w < 2*grid ? 2*grid : w,
h < 2*grid ? 2*grid :
h);
4028 frame = ((
TGCanvas*)frame)->GetContainer();
4060 if ((
x == x0) || (
y==y0 ))
return;
4063 x0 = x0 < 0 ? 0 : x0;
4073 y0 = y0 < 0 ? 0 : y0;
4092 xswap ?
x : x0, yswap ?
y : y0,
4095 xswap ? x0 :
x, yswap ? y0 :
y,
4111 TString str =
"Lasso drawn. Align frames inside or presss Return key to grab frames.";
4270 if (
fPimpl->fSpacePressedFrame) {
4273 mov =
fPimpl->fSpacePressedFrame;
4275 fPimpl->fSpacePressedFrame = 0;
4296 fPimpl->fRepeatTimer->Reset();
4358 fPimpl->fSpacePressedFrame = 0;
4457 str +=
" dropped into ";
4461 str +=
" at position ";
4468 if (parent && (parent ==
fPimpl->fGrabParent) &&
fPimpl->fGrabListPosition &&
4489 fPimpl->fGrabListPosition = 0;
4561 if ((
d.fWidth > 10) && (
d.fHeight > 10)) {
4563 }
else if (
d.fWidth > 10) {
4565 }
else if (
d.fHeight > 10) {
4583 if ((
d.fWidth > 10) && (
d.fHeight > 10)) {
4585 }
else if (
d.fWidth > 10) {
4587 }
else if (
d.fHeight > 10) {
4626 if (
fPimpl->fRepeatTimer) {
4627 fPimpl->fRepeatTimer->Reset();
4638 if (
fPimpl->fRepeatTimer) {
4639 fPimpl->fRepeatTimer->Remove();
4691 fPimpl->fLastPopupAction = act;