Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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 "TGWindow.h"
14#include "TGTable.h"
15#include "TVirtualX.h"
16
17
18
19// TGTableFrame and TGTableHeaderFrame
20/** \class TGTableFrame
21 \ingroup guiwidgets
22
23TGTableFrame contains a composite frame that uses a TGMatrixLayout
24to Layout the frames it contains.
25
26Internal use in TGTable only.
27
28*/
29
30/** \class TGTableHeaderFrame
31 \ingroup guiwidgets
32
33TGTableHeaderFrame implements a frame used to display TGTableHeaders
34in a TGTable.
35
36Internal use in TGTable only.
37
38*/
39
40
41////////////////////////////////////////////////////////////////////////////////
42/// Create the container used to view TGTableCells. p.
43
45 : TQObject(), fFrame(0), fCanvas(0)
46{
49 fFrame->Connect("ProcessedEvent(Event_t*)", "TGTableFrame", this,
50 "HandleMouseWheel(Event_t*)");
51 fCanvas = 0;
52 fFrame->SetLayoutManager(new TGMatrixLayout(fFrame, nrows, ncolumns));
53
54 gVirtualX->GrabButton(fFrame->GetId(), kAnyButton, kAnyModifier,
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Handle mouse wheel to scroll.
61
63{
64 if (event->fType != kButtonPress && event->fType != kButtonRelease)
65 return;
66
67 Int_t page = 0;
68 if (event->fCode == kButton4 || event->fCode == kButton5) {
69 if (!fCanvas) return;
70 if (fCanvas->GetContainer()->GetHeight())
71 page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
72 fCanvas->GetViewPort()->GetHeight()) /
73 fCanvas->GetContainer()->GetHeight());
74 }
75
76 if (event->fCode == kButton4) {
77 //scroll up
78 Int_t newpos = fCanvas->GetVsbPosition() - page;
79 if (newpos < 0) newpos = 0;
80 fCanvas->SetVsbPosition(newpos);
81 }
82 if (event->fCode == kButton5) {
83 // scroll down
84 Int_t newpos = fCanvas->GetVsbPosition() + page;
85 fCanvas->SetVsbPosition(newpos);
86 }
87}
88
89////////////////////////////////////////////////////////////////////////////////
90/// Draw a region of container in viewport.
91
93{
95 // Handle_t id = fId;
96
97 Int_t xx = fCanvas->GetX() + fCanvas->GetHsbPosition() + x; // translate coordinates to current page position
98 Int_t yy = fCanvas->GetY() + fCanvas->GetVsbPosition() + y;
99
100 TIter next(fFrame->GetList());
101
102 while ((el = (TGFrameElement *) next())) {
103 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
104 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
105 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
106 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
107
108 // draw either in container window or in double-buffer
109 // if (!fMapSubwindows) {
110 // el->fFrame->DrawCopy(id, el->fFrame->GetX() - pos.fX, el->fFrame->GetY() - pos.fY);
111 // } else {
112 gClient->NeedRedraw(el->fFrame);
113 // }
114 }
115 }
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// TGTableHeaderFrame constructor.
120
122 UInt_t w, UInt_t h, EHeaderType type,
123 UInt_t options) :
124 TGCompositeFrame(p, w, h, options), fX0(0), fY0(0), fTable(table)
125{
126 if (type == kRowHeader) {
128 fY0 = fTable->GetTableHeader()->GetHeight();
129 } else if (type == kColumnHeader) {
131 fX0 = fTable->GetTableHeader()->GetWidth();
132 } else {
133 Error("TGTableHeaderFrame::TGTableHeaderFrame",
134 "specify correct header type");
135 }
136
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Draw a region of container in viewport.
141
143{
144 TGFrameElement *el;
145 // Handle_t id = fId;
146
147 Int_t xx = fX0 + x; // translate coordinates to current page position
148 Int_t yy = fY0 + y;
149
150 TIter next(fList);
151
152 while ((el = (TGFrameElement *) next())) {
153 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
154 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
155 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
156 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
157
158 fClient->NeedRedraw(el->fFrame);
159 }
160 }
161}
@ kButtonRelease
Definition GuiTypes.h:61
@ kButtonPress
Definition GuiTypes.h:61
const Mask_t kButtonPressMask
Definition GuiTypes.h:162
const Mask_t kAnyModifier
Definition GuiTypes.h:211
const Mask_t kPointerMotionMask
Definition GuiTypes.h:164
@ kVerticalFrame
Definition GuiTypes.h:382
@ kHorizontalFrame
Definition GuiTypes.h:383
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:163
@ kButton4
Definition GuiTypes.h:216
@ kButton5
Definition GuiTypes.h:216
@ kAnyButton
Definition GuiTypes.h:215
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define gClient
Definition TGClient.h:157
EHeaderType
@ kColumnHeader
@ kRowHeader
#define gVirtualX
Definition TVirtualX.h:375
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGCompositeFrame(const TGCompositeFrame &)=delete
TList * fList
container of frame elements
Definition TGFrame.h:294
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1035
TGFrame * fFrame
Definition TGLayout.h:112
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:701
Int_t GetX() const
Definition TGFrame.h:233
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
UInt_t GetHeight() const
Definition TGFrame.h:227
Int_t GetY() const
Definition TGFrame.h:234
UInt_t GetWidth() const
Definition TGFrame.h:226
This layout managers does not make use of TGLayoutHints.
Definition TGLayout.h:269
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
void HandleMouseWheel(Event_t *event)
Handle mouse wheel to scroll.
TGCompositeFrame * fFrame
Composite frame used as a container.
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
Pointer to the canvas that used this frame.
Int_t fX0
X coordinate of the header frame.
Int_t fY0
Y coordinate of the header frame.
TGTable * fTable
Table that this frame belongs to.
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=nullptr, UInt_t w=1, UInt_t h=1, EHeaderType type=kColumnHeader, UInt_t option=0)
TGTableHeaderFrame constructor.
Create an array to hold a bunch of numbers.
Definition TGTable.h:34
ROOT GUI Window base class.
Definition TGWindow.h:23
TGWindow(Window_t id)
Definition TGWindow.h:34
TQObject(const TQObject &)=delete
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:175
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:176
UInt_t fCode
key or button code
Definition GuiTypes.h:181