Logo ROOT   6.16/01
Reference Guide
TGTableContainer.cxx
Go to the documentation of this file.
1// Author: Roel Aaij 14/08/2007
2
3/*************************************************************************
4 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#include "TGTableContainer.h"
12#include "TGTableCell.h"
13#include "TGLayout.h"
14#include "TGWindow.h"
15#include "TGScrollBar.h"
16#include "TGTable.h"
17
20
21//////////////////////////////////////////////////////////////////////////
22// //
23// TGTableFrame and TGTableHeaderFrame //
24// //
25// TGTableFrame contains a composite frame that uses a TGMatrixLayout //
26// to Layout the frames it contains. //
27// //
28// TGTableHeaderFrame implements a frame used to display TGTableHeaders //
29// in a TGTable. //
30// //
31// Both classes are for internal use in TGTable only. //
32// //
33//////////////////////////////////////////////////////////////////////////
34
35////////////////////////////////////////////////////////////////////////////////
36/// Create the container used to view TGTableCells. p.
37
39 : TQObject(), fFrame(0), fCanvas(0)
40{
43 fFrame->Connect("ProcessedEvent(Event_t*)", "TGTableFrame", this,
44 "HandleMouseWheel(Event_t*)");
45 fCanvas = 0;
46 fFrame->SetLayoutManager(new TGMatrixLayout(fFrame, nrows, ncolumns));
47
51}
52
53////////////////////////////////////////////////////////////////////////////////
54/// Handle mouse wheel to scroll.
55
57{
58 if (event->fType != kButtonPress && event->fType != kButtonRelease)
59 return;
60
61 Int_t page = 0;
62 if (event->fCode == kButton4 || event->fCode == kButton5) {
63 if (!fCanvas) return;
68 }
69
70 if (event->fCode == kButton4) {
71 //scroll up
72 Int_t newpos = fCanvas->GetVsbPosition() - page;
73 if (newpos < 0) newpos = 0;
74 fCanvas->SetVsbPosition(newpos);
75 }
76 if (event->fCode == kButton5) {
77 // scroll down
78 Int_t newpos = fCanvas->GetVsbPosition() + page;
79 fCanvas->SetVsbPosition(newpos);
80 }
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Draw a region of container in viewport.
85
87{
89 // Handle_t id = fId;
90
91 Int_t xx = fCanvas->GetX() + fCanvas->GetHsbPosition() + x; // translate coordinates to current page position
93
94 TIter next(fFrame->GetList());
95
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()))) {
101
102 // draw either in container window or in double-buffer
103 // if (!fMapSubwindows) {
104 // el->fFrame->DrawCopy(id, el->fFrame->GetX() - pos.fX, el->fFrame->GetY() - pos.fY);
105 // } else {
106 gClient->NeedRedraw(el->fFrame);
107 // }
108 }
109 }
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// TGTableHeaderFrame constuctor.
114
117 UInt_t options) :
118 TGCompositeFrame(p, w, h, options), fX0(0), fY0(0), fTable(table)
119{
120 if (type == kRowHeader) {
123 } else if (type == kColumnHeader) {
126 } else {
127 Error("TGTableHeaderFrame::TGTableHeaderFrame",
128 "specify correct header type");
129 }
130
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Draw a region of container in viewport.
135
137{
138 TGFrameElement *el;
139 // Handle_t id = fId;
140
141 Int_t xx = fX0 + x; // translate coordinates to current page position
142 Int_t yy = fY0 + y;
143
144 TIter next(fList);
145
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()))) {
151
153 }
154 }
155}
@ kButtonRelease
Definition: GuiTypes.h:59
@ kButtonPress
Definition: GuiTypes.h:59
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
const Handle_t kNone
Definition: GuiTypes.h:87
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
@ kButton4
Definition: GuiTypes.h:214
@ kButton5
Definition: GuiTypes.h:214
@ kAnyButton
Definition: GuiTypes.h:213
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
float Float_t
Definition: RtypesCore.h:53
#define ClassImp(name)
Definition: Rtypes.h:363
#define gClient
Definition: TGClient.h:166
@ kVerticalFrame
Definition: TGFrame.h:59
@ kHorizontalFrame
Definition: TGFrame.h:60
EHeaderType
Definition: TGTableHeader.h:16
@ kColumnHeader
Definition: TGTableHeader.h:17
@ kRowHeader
Definition: TGTableHeader.h:18
int type
Definition: TGX11.cxx:120
#define gVirtualX
Definition: TVirtualX.h:345
TGFrame * GetContainer() const
Definition: TGCanvas.h:226
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Definition: TGCanvas.cxx:2405
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
Definition: TGCanvas.cxx:2381
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:227
virtual Int_t GetHsbPosition() const
Get position of horizontal scrollbar.
Definition: TGCanvas.cxx:2371
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition: TGFrame.cxx:982
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1025
TList * fList
Definition: TGFrame.h:351
TGFrame * fFrame
Definition: TGLayout.h:119
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
Int_t GetX() const
Definition: TGFrame.h:278
virtual UInt_t GetOptions() const
Definition: TGFrame.h:244
UInt_t GetHeight() const
Definition: TGFrame.h:272
Int_t GetY() const
Definition: TGFrame.h:279
UInt_t GetWidth() const
Definition: TGFrame.h:271
TGClient * fClient
Definition: TGObject.h:37
Handle_t GetId() const
Definition: TGObject.h:47
virtual UInt_t GetWidth() const
Definition: TGTableCell.h:102
virtual UInt_t GetHeight() const
Definition: TGTableCell.h:103
void HandleMouseWheel(Event_t *event)
Handle mouse wheel to scroll.
TGCompositeFrame * fFrame
TGTableFrame(const TGWindow *p, UInt_t nrows, UInt_t ncolumns)
Create the container used to view TGTableCells. p.
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a region of container in viewport.
TGCanvas * fCanvas
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a region of container in viewport.
TGTableHeaderFrame(const TGWindow *p, TGTable *table=0, UInt_t w=1, UInt_t h=1, EHeaderType type=kColumnHeader, UInt_t option=0)
TGTableHeaderFrame constuctor.
virtual TGTableHeader * GetTableHeader()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:49
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:867
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
EGEventType fType
Definition: GuiTypes.h:174
UInt_t fCode
Definition: GuiTypes.h:179
void table()
Definition: table.C:85