18 ClassImp(TGTableFrame);
19 ClassImp(TGTableHeaderFrame);
38 TGTableFrame::TGTableFrame(
const TGWindow *p, UInt_t nrows, UInt_t ncolumns)
39 : TQObject(), fFrame(0), fCanvas(0)
41 fFrame =
new TGCompositeFrame(p, 10, 10, kHorizontalFrame,
42 TGFrame::GetWhitePixel());
43 fFrame->Connect(
"ProcessedEvent(Event_t*)",
"TGTableFrame",
this,
44 "HandleMouseWheel(Event_t*)");
46 fFrame->SetLayoutManager(
new TGMatrixLayout(fFrame, nrows, ncolumns));
48 gVirtualX->GrabButton(fFrame->GetId(), kAnyButton, kAnyModifier,
49 kButtonPressMask | kButtonReleaseMask |
50 kPointerMotionMask, kNone, kNone);
56 void TGTableFrame::HandleMouseWheel(Event_t *event)
58 if (event->fType != kButtonPress && event->fType != kButtonRelease)
62 if (event->fCode == kButton4 || event->fCode == kButton5) {
64 if (fCanvas->GetContainer()->GetHeight())
65 page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
66 fCanvas->GetViewPort()->GetHeight()) /
67 fCanvas->GetContainer()->GetHeight());
70 if (event->fCode == kButton4) {
72 Int_t newpos = fCanvas->GetVsbPosition() - page;
73 if (newpos < 0) newpos = 0;
74 fCanvas->SetVsbPosition(newpos);
76 if (event->fCode == kButton5) {
78 Int_t newpos = fCanvas->GetVsbPosition() + page;
79 fCanvas->SetVsbPosition(newpos);
86 void TGTableFrame::DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
91 Int_t xx = fCanvas->GetX() + fCanvas->GetHsbPosition() + x;
92 Int_t yy = fCanvas->GetY() + fCanvas->GetVsbPosition() + y;
94 TIter next(fFrame->GetList());
96 while ((el = (TGFrameElement *) next())) {
97 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
98 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
99 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
100 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
106 gClient->NeedRedraw(el->fFrame);
115 TGTableHeaderFrame::TGTableHeaderFrame(
const TGWindow *p, TGTable *table,
116 UInt_t w, UInt_t h, EHeaderType type,
118 TGCompositeFrame(p, w, h, options), fX0(0), fY0(0), fTable(table)
120 if (type == kRowHeader) {
121 ChangeOptions(GetOptions() | kVerticalFrame);
122 fY0 = fTable->GetTableHeader()->GetHeight();
123 }
else if (type == kColumnHeader) {
124 ChangeOptions(GetOptions() | kHorizontalFrame);
125 fX0 = fTable->GetTableHeader()->GetWidth();
127 Error(
"TGTableHeaderFrame::TGTableHeaderFrame",
128 "specify correct header type");
136 void TGTableHeaderFrame::DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
146 while ((el = (TGFrameElement *) next())) {
147 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
148 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
149 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
150 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
152 fClient->NeedRedraw(el->fFrame);