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;
53
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;
74 }
75
76 if (event->fCode == kButton4) {
77 //scroll up
79 if (newpos < 0) newpos = 0;
81 }
82 if (event->fCode == kButton5) {
83 // scroll down
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
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
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{
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:60
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kVerticalFrame
Definition GuiTypes.h:381
@ kHorizontalFrame
Definition GuiTypes.h:382
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
@ kButton4
Definition GuiTypes.h:215
@ kButton5
Definition GuiTypes.h:215
@ kAnyButton
Definition GuiTypes.h:214
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
#define gClient
Definition TGClient.h:157
EHeaderType
@ kColumnHeader
@ kRowHeader
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
#define gVirtualX
Definition TVirtualX.h:337
TGFrame * GetContainer() const
Definition TGCanvas.h:216
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
virtual Int_t GetHsbPosition() const
Get position of horizontal scrollbar.
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:992
virtual TList * GetList() const
Definition TGFrame.h:312
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
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
This layout managers does not make use of TGLayoutHints.
Definition TGLayout.h:269
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
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
virtual TGTableHeader * GetTableHeader()
Return a pointer to the table header.
Definition TGTable.cxx:1178
ROOT GUI Window base class.
Definition TGWindow.h:23
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition TQObject.h:48
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:865
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
UInt_t fCode
key or button code
Definition GuiTypes.h:180