00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "TGTableContainer.h"
00012 #include "TGTableCell.h"
00013 #include "TGLayout.h"
00014 #include "TGWindow.h"
00015 #include "TGScrollBar.h"
00016 #include "TGTable.h"
00017
00018 ClassImp(TGTableFrame)
00019 ClassImp(TGTableHeaderFrame)
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 TGTableFrame::TGTableFrame(const TGWindow *p, UInt_t nrows, UInt_t ncolumns)
00037 : TQObject(), fFrame(0), fCanvas(0)
00038 {
00039
00040
00041 fFrame = new TGCompositeFrame(p, 10, 10, kHorizontalFrame,
00042 TGFrame::GetWhitePixel());
00043 fFrame->Connect("ProcessedEvent(Event_t*)", "TGTableFrame", this,
00044 "HandleMouseWheel(Event_t*)");
00045 fCanvas = 0;
00046 fFrame->SetLayoutManager(new TGMatrixLayout(fFrame, nrows, ncolumns));
00047
00048 gVirtualX->GrabButton(fFrame->GetId(), kAnyButton, kAnyModifier,
00049 kButtonPressMask | kButtonReleaseMask |
00050 kPointerMotionMask, kNone, kNone);
00051 }
00052
00053
00054 void TGTableFrame::HandleMouseWheel(Event_t *event)
00055 {
00056
00057
00058 if (event->fType != kButtonPress && event->fType != kButtonRelease)
00059 return;
00060
00061 Int_t page = 0;
00062 if (event->fCode == kButton4 || event->fCode == kButton5) {
00063 if (!fCanvas) return;
00064 if (fCanvas->GetContainer()->GetHeight())
00065 page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
00066 fCanvas->GetViewPort()->GetHeight()) /
00067 fCanvas->GetContainer()->GetHeight());
00068 }
00069
00070 if (event->fCode == kButton4) {
00071
00072 Int_t newpos = fCanvas->GetVsbPosition() - page;
00073 if (newpos < 0) newpos = 0;
00074 fCanvas->SetVsbPosition(newpos);
00075 }
00076 if (event->fCode == kButton5) {
00077
00078 Int_t newpos = fCanvas->GetVsbPosition() + page;
00079 fCanvas->SetVsbPosition(newpos);
00080 }
00081 }
00082
00083
00084 void TGTableFrame::DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
00085 {
00086
00087
00088 TGFrameElement *el;
00089
00090
00091 Int_t xx = fCanvas->GetX() + fCanvas->GetHsbPosition() + x;
00092 Int_t yy = fCanvas->GetY() + fCanvas->GetVsbPosition() + y;
00093
00094 TIter next(fFrame->GetList());
00095
00096 while ((el = (TGFrameElement *) next())) {
00097 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
00098 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
00099 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
00100 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
00101
00102
00103
00104
00105
00106 gClient->NeedRedraw(el->fFrame);
00107
00108 }
00109 }
00110 }
00111
00112
00113 TGTableHeaderFrame::TGTableHeaderFrame(const TGWindow *p, TGTable *table,
00114 UInt_t w, UInt_t h, EHeaderType type,
00115 UInt_t options) :
00116 TGCompositeFrame(p, w, h, options), fX0(0), fY0(0), fTable(table)
00117 {
00118
00119
00120 if (type == kRowHeader) {
00121 ChangeOptions(GetOptions() | kVerticalFrame);
00122 fY0 = fTable->GetTableHeader()->GetHeight();
00123 } else if (type == kColumnHeader) {
00124 ChangeOptions(GetOptions() | kHorizontalFrame);
00125 fX0 = fTable->GetTableHeader()->GetWidth();
00126 } else {
00127 Error("TGTableHeaderFrame::TGTableHeaderFrame",
00128 "specify correct header type");
00129 }
00130
00131 }
00132
00133
00134 void TGTableHeaderFrame::DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
00135 {
00136
00137
00138 TGFrameElement *el;
00139
00140
00141 Int_t xx = fX0 + x;
00142 Int_t yy = fY0 + y;
00143
00144 TIter next(fList);
00145
00146 while ((el = (TGFrameElement *) next())) {
00147 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
00148 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
00149 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
00150 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
00151
00152 fClient->NeedRedraw(el->fFrame);
00153 }
00154 }
00155 }