28 ClassImp(TGVSplitter);
29 ClassImp(TGHSplitter);
30 ClassImp(TGVFileSplitter);
36 TGSplitter::TGSplitter(
const TGWindow *p, UInt_t w, UInt_t h,
37 UInt_t options, ULong_t back) :
38 TGFrame(p, w, h, options, back),
40 fExternalHandler (kFALSE),
44 fEditDisabled = kTRUE;
50 void TGSplitter::DragStarted()
52 Emit(
"DragStarted()");
58 void TGSplitter::Moved(Int_t delta)
60 Emit(
"Moved(Int_t)", delta);
66 TGVSplitter::TGVSplitter(
const TGWindow *p, UInt_t w, UInt_t h,
67 UInt_t options, ULong_t back) : TGSplitter(p, w, h, options, back)
70 fSplitterPic = fClient->GetPicture(
"splitterv.xpm");
79 Error(
"TGVSplitter",
"splitterv.xpm not found");
81 if (p && !p->InheritsFrom(TGCompositeFrame::Class())) {
82 Error(
"TGVSplitter",
"parent must inherit from a TGCompositeFrame");
85 if (p && !(((TGCompositeFrame*)p)->GetOptions() & kHorizontalFrame)) {
86 Error(
"TGVSplitter",
"parent must have a horizontal layout manager");
90 fSplitCursor = gVirtualX->CreateCursor(kArrowHor);
92 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
93 kButtonPressMask | kButtonReleaseMask |
94 kPointerMotionMask, kNone, kNone);
96 AddInput(kEnterWindowMask | kLeaveWindowMask);
102 TGVSplitter::TGVSplitter(
const TGWindow *p, UInt_t w, UInt_t h, Bool_t external) :
103 TGSplitter(p, w, h, kChildFrame, GetDefaultFrameBackground())
105 fExternalHandler = external;
107 fSplitCursor = kNone;
108 fSplitterPic = fClient->GetPicture(
"splitterv.xpm");
111 Error(
"TGVSplitter",
"splitterv.xpm not found");
113 fSplitCursor = gVirtualX->CreateCursor(kArrowHor);
121 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
122 kButtonPressMask | kButtonReleaseMask |
123 kPointerMotionMask, kNone, kNone);
125 AddInput(kEnterWindowMask | kLeaveWindowMask);
131 TGVSplitter::~TGVSplitter()
133 if (fSplitterPic) fClient->FreePicture(fSplitterPic);
140 void TGVSplitter::SetFrame(TGFrame *frame, Bool_t left)
145 if (!fExternalHandler && !(fFrame->GetOptions() & kFixedWidth))
146 Error(
"SetFrame",
"resize frame must have kFixedWidth option set");
152 Bool_t TGVSplitter::HandleButton(Event_t *event)
154 if (fSplitCursor == kNone)
return kTRUE;
156 if (!fExternalHandler && !fFrame) {
157 Error(
"HandleButton",
"frame to be resized not set");
161 if (event->fType == kButtonPress) {
162 fStartX =
event->fXRoot;
165 if (fExternalHandler) {
171 gVirtualX->GetWindowSize(fFrame->GetId(), x, y, fFrameWidth, fFrameHeight);
177 gVirtualX->GetWindowSize(fParent->GetId(), x, y, w, h);
178 gVirtualX->TranslateCoordinates(fParent->GetParent()->GetId(),
179 fClient->GetDefaultRoot()->GetId(),
180 x, y, xroot, yroot, wdum);
182 fMax = xroot + w - 2;
186 gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask |
187 kPointerMotionMask, kNone, fSplitCursor,
191 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
199 Bool_t TGVSplitter::HandleMotion(Event_t *event)
202 Int_t xr =
event->fXRoot;
203 if (xr > fMax) xr = fMax;
204 if (xr < fMin) xr = fMin;
205 Int_t delta = xr - fStartX;
206 if (fExternalHandler) {
212 Int_t w = (Int_t) fFrameWidth;
222 fFrame->Resize(fFrameWidth, fFrameHeight);
224 TGCompositeFrame *p = (TGCompositeFrame *) GetParent();
235 Bool_t TGVSplitter::HandleCrossing(Event_t *event)
237 if (event->fType == kEnterNotify)
238 gVirtualX->SetCursor(fId, fSplitCursor);
240 gVirtualX->SetCursor(fId, kNone);
248 void TGVSplitter::DrawBorder()
251 Int_t posx = (fWidth/2)-(fSplitterPic->GetWidth()/2);
252 Int_t posy = (fHeight/2)-(fSplitterPic->GetHeight()/2);
253 fSplitterPic->Draw(fId, GetBckgndGC()(), posx, posy);
261 TGHSplitter::TGHSplitter(
const TGWindow *p, UInt_t w, UInt_t h,
262 UInt_t options, ULong_t back) : TGSplitter(p, w, h, options, back)
264 fSplitCursor = kNone;
274 if (p && !p->InheritsFrom(TGCompositeFrame::Class())) {
275 Error(
"TGHSplitter",
"parent must inherit from a TGCompositeFrame");
278 if (p && !(((TGCompositeFrame*)p)->GetOptions() & kVerticalFrame)) {
279 Error(
"TGHSplitter",
"parent must have a vertical layout manager");
283 fSplitterPic = fClient->GetPicture(
"splitterh.xpm");
286 Error(
"TGHSplitter",
"splitterh.xpm not found");
288 fSplitCursor = gVirtualX->CreateCursor(kArrowVer);
290 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
291 kButtonPressMask | kButtonReleaseMask |
292 kPointerMotionMask, kNone, kNone);
294 AddInput(kEnterWindowMask | kLeaveWindowMask);
300 TGHSplitter::TGHSplitter(
const TGWindow *p, UInt_t w, UInt_t h, Bool_t external) :
301 TGSplitter(p, w, h, kChildFrame, GetDefaultFrameBackground())
303 fExternalHandler = external;
305 fSplitCursor = kNone;
307 fSplitterPic = fClient->GetPicture(
"splitterh.xpm");
310 Error(
"TGHSplitter",
"splitterh.xpm not found");
312 fSplitCursor = gVirtualX->CreateCursor(kArrowVer);
320 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
321 kButtonPressMask | kButtonReleaseMask |
322 kPointerMotionMask, kNone, kNone);
324 AddInput(kEnterWindowMask | kLeaveWindowMask);
330 TGHSplitter::~TGHSplitter()
332 if (fSplitterPic) fClient->FreePicture(fSplitterPic);
339 void TGHSplitter::SetFrame(TGFrame *frame, Bool_t above)
344 if (!fExternalHandler && !(fFrame->GetOptions() & kFixedHeight))
345 Error(
"SetFrame",
"resize frame must have kFixedHeight option set");
351 Bool_t TGHSplitter::HandleButton(Event_t *event)
353 if (fSplitCursor == kNone)
return kTRUE;
355 if (!fExternalHandler && !fFrame) {
356 Error(
"HandleButton",
"frame to be resized not set");
360 if (event->fType == kButtonPress) {
361 fStartY =
event->fYRoot;
364 if (fExternalHandler) {
370 gVirtualX->GetWindowSize(fFrame->GetId(), x, y, fFrameWidth, fFrameHeight);
376 gVirtualX->GetWindowSize(fParent->GetId(), x, y, w, h);
377 gVirtualX->TranslateCoordinates(fParent->GetParent()->GetId(),
378 fClient->GetDefaultRoot()->GetId(),
379 x, y, xroot, yroot, wdum);
381 fMax = yroot + h - 2;
385 gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask |
386 kPointerMotionMask, kNone, fSplitCursor,
390 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
398 Bool_t TGHSplitter::HandleMotion(Event_t *event)
401 Int_t yr =
event->fYRoot;
402 if (yr > fMax) yr = fMax;
403 if (yr < fMin) yr = fMin;
404 Int_t delta = yr - fStartY;
405 if (fExternalHandler) {
411 Int_t h = (Int_t) fFrameHeight;
421 fFrame->Resize(fFrameWidth, fFrameHeight);
423 TGCompositeFrame *p = (TGCompositeFrame *) GetParent();
434 Bool_t TGHSplitter::HandleCrossing(Event_t *event)
436 if (event->fType == kEnterNotify)
437 gVirtualX->SetCursor(fId, fSplitCursor);
439 gVirtualX->SetCursor(fId, kNone);
447 void TGHSplitter::DrawBorder()
450 Int_t posx = (fWidth/2)-(fSplitterPic->GetWidth()/2);
451 Int_t posy = (fHeight/2)-(fSplitterPic->GetHeight()/2);
452 fSplitterPic->Draw(fId, GetBckgndGC()(), posx, posy);
459 TGVFileSplitter::TGVFileSplitter(
const TGWindow *p, UInt_t w, UInt_t h,
460 UInt_t options, Pixel_t back):
461 TGVSplitter(p, w, h, options, back)
470 TGVFileSplitter::~TGVFileSplitter()
477 Bool_t TGVFileSplitter::HandleMotion(Event_t *event)
482 Int_t xr =
event->fXRoot;
483 if (xr > fMax) xr = fMax;
484 if (xr < fMin) xr = fMin;
485 Int_t delta = xr - fStartX;
486 Int_t w = (Int_t) fFrameWidth;
496 delta = w - fFrameWidth;
499 TGCompositeFrame *p = (TGCompositeFrame *) GetParent();
500 p->Resize( p->GetWidth() + delta, p->GetHeight() );
502 fFrame->Resize(fFrameWidth, fFrameHeight);
505 LayoutHeader((TGFrame *)fFrame);
514 Bool_t TGVFileSplitter::HandleButton(Event_t *event)
516 if ( event->fType == kButtonPress) {
518 }
else if ( event->fType == kButtonRelease) {
522 }
else if ( event->fType == kButtonDoubleClick ) {
525 return TGVSplitter::HandleButton(event);
531 void TGVFileSplitter::LayoutHeader(TGFrame *f)
533 Emit(
"LayoutHeader(TGFrame*)", (Long_t)f);
539 void TGVFileSplitter::LayoutListView()
541 Emit(
"LayoutListView()");
547 void TGVFileSplitter::ButtonPressed()
549 Emit(
"ButtonPressed()");
555 void TGVFileSplitter::ButtonReleased()
557 Emit(
"ButtonReleased()");
563 void TGVFileSplitter::DoubleClicked(TGVFileSplitter* splitter)
565 Emit(
"DoubleClicked(TGVFileSplitter*)", (Long_t) splitter);
571 Bool_t TGVFileSplitter::HandleDoubleClick(Event_t *)
580 void TGVSplitter::SavePrimitive(std::ostream &out, Option_t *option )
582 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
584 out <<
" TGVSplitter *";
585 out << GetName() <<
" = new TGVSplitter("<< fParent->GetName()
586 <<
"," << GetWidth() <<
"," << GetHeight();
588 if (fBackground == GetDefaultFrameBackground()) {
590 out <<
");" << std::endl;
592 out <<
"," << GetOptionString() <<
");" << std::endl;
595 out <<
"," << GetOptionString() <<
",ucolor);" << std::endl;
597 if (option && strstr(option,
"keep_names"))
598 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
604 out <<
" " << GetName() <<
"->SetFrame(" << GetFrame()->GetName();
605 if (GetLeft()) out <<
",kTRUE);" << std::endl;
606 else out <<
",kFALSE);"<< std::endl;
613 void TGHSplitter::SavePrimitive(std::ostream &out, Option_t *option )
615 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
617 out <<
" TGHSplitter *";
618 out << GetName() <<
" = new TGHSplitter("<< fParent->GetName()
619 <<
"," << GetWidth() <<
"," << GetHeight();
621 if (fBackground == GetDefaultFrameBackground()) {
623 out <<
");" << std::endl;
625 out <<
"," << GetOptionString() <<
");" << std::endl;
628 out <<
"," << GetOptionString() <<
",ucolor);" << std::endl;
630 if (option && strstr(option,
"keep_names"))
631 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
637 out <<
" " << GetName() <<
"->SetFrame(" << GetFrame()->GetName();
638 if (GetAbove()) out <<
",kTRUE);" << std::endl;
639 else out <<
",kFALSE);"<< std::endl;
646 void TGVFileSplitter::SavePrimitive(std::ostream &out, Option_t *option )
648 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
650 out <<
" TGVFileSplitter *";
651 out << GetName() <<
" = new TGVFileSplitter("<< fParent->GetName()
652 <<
"," << GetWidth() <<
"," << GetHeight();
654 if (fBackground == GetDefaultFrameBackground()) {
656 out <<
");" << std::endl;
658 out <<
"," << GetOptionString() <<
");" << std::endl;
661 out <<
"," << GetOptionString() <<
",ucolor);" << std::endl;
663 if (option && strstr(option,
"keep_names"))
664 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
666 out <<
" " << GetName() <<
"->SetFrame(" << GetFrame()->GetName();
667 if (GetLeft()) out <<
",kTRUE);" << std::endl;
668 else out <<
",kFALSE);"<< std::endl;