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
19
20
21// TGTableFrame and TGTableHeaderFrame
22/** \class TGTableFrame
23 \ingroup guiwidgets
24
25TGTableFrame contains a composite frame that uses a TGMatrixLayout
26to Layout the frames it contains.
27
28Internal use in TGTable only.
29
30*/
31
32/** \class TGTableHeaderFrame
33 \ingroup guiwidgets
34
35TGTableHeaderFrame implements a frame used to display TGTableHeaders
36in a TGTable.
37
38Internal use in TGTable only.
39
40*/
41
42
43////////////////////////////////////////////////////////////////////////////////
44/// Create the container used to view TGTableCells. p.
45
47 : TQObject(), fFrame(0), fCanvas(0)
48{
51 fFrame->Connect("ProcessedEvent(Event_t*)", "TGTableFrame", this,
52 "HandleMouseWheel(Event_t*)");
53 fCanvas = 0;
54 fFrame->SetLayoutManager(new TGMatrixLayout(fFrame, nrows, ncolumns));
55
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Handle mouse wheel to scroll.
63
65{
66 if (event->fType != kButtonPress && event->fType != kButtonRelease)
67 return;
68
69 Int_t page = 0;
70 if (event->fCode == kButton4 || event->fCode == kButton5) {
71 if (!fCanvas) return;
76 }
77
78 if (event->fCode == kButton4) {
79 //scroll up
80 Int_t newpos = fCanvas->GetVsbPosition() - page;
81 if (newpos < 0) newpos = 0;
82 fCanvas->SetVsbPosition(newpos);
83 }
84 if (event->fCode == kButton5) {
85 // scroll down
86 Int_t newpos = fCanvas->GetVsbPosition() + page;
87 fCanvas->SetVsbPosition(newpos);
88 }
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Draw a region of container in viewport.
93
95{
97 // Handle_t id = fId;
98
99 Int_t xx = fCanvas->GetX() + fCanvas->GetHsbPosition() + x; // translate coordinates to current page position
100 Int_t yy = fCanvas->GetY() + fCanvas->GetVsbPosition() + y;
101
102 TIter next(fFrame->GetList());
103
104 while ((el = (TGFrameElement *) next())) {
105 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
106 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
107 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
108 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
109
110 // draw either in container window or in double-buffer
111 // if (!fMapSubwindows) {
112 // el->fFrame->DrawCopy(id, el->fFrame->GetX() - pos.fX, el->fFrame->GetY() - pos.fY);
113 // } else {
114 gClient->NeedRedraw(el->fFrame);
115 // }
116 }
117 }
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// TGTableHeaderFrame constructor.
122
125 UInt_t options) :
126 TGCompositeFrame(p, w, h, options), fX0(0), fY0(0), fTable(table)
127{
128 if (type == kRowHeader) {
131 } else if (type == kColumnHeader) {
134 } else {
135 Error("TGTableHeaderFrame::TGTableHeaderFrame",
136 "specify correct header type");
137 }
138
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Draw a region of container in viewport.
143
145{
146 TGFrameElement *el;
147 // Handle_t id = fId;
148
149 Int_t xx = fX0 + x; // translate coordinates to current page position
150 Int_t yy = fY0 + y;
151
152 TIter next(fList);
153
154 while ((el = (TGFrameElement *) next())) {
155 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
156 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
157 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
158 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
159
161 }
162 }
163}
@ 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
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
#define ClassImp(name)
Definition Rtypes.h:377
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
#define gClient
Definition TGClient.h:156
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:372
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:1000
virtual TList * GetList() const
Definition TGFrame.h:310
TList * fList
container of frame elements
Definition TGFrame.h:292
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1043
TGFrame * fFrame
Definition TGLayout.h:112
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
Int_t GetX() const
Definition TGFrame.h:231
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
UInt_t GetHeight() const
Definition TGFrame.h:225
Int_t GetY() const
Definition TGFrame.h:232
UInt_t GetWidth() const
Definition TGFrame.h:224
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
virtual UInt_t GetWidth() const
Definition TGTableCell.h:93
virtual UInt_t GetHeight() const
Definition TGTableCell.h:94
TGTableFrame contains a composite frame that uses a TGMatrixLayout to Layout the frames it contains.
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.
TGTableHeaderFrame implements a frame used to display TGTableHeaders in a TGTable.
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:1180
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:869
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