Logo ROOT  
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#include "TVirtualX.h"
18
21
22//////////////////////////////////////////////////////////////////////////
23// //
24// TGTableFrame and TGTableHeaderFrame //
25// //
26// TGTableFrame contains a composite frame that uses a TGMatrixLayout //
27// to Layout the frames it contains. //
28// //
29// TGTableHeaderFrame implements a frame used to display TGTableHeaders //
30// in a TGTable. //
31// //
32// Both classes are for internal use in TGTable only. //
33// //
34//////////////////////////////////////////////////////////////////////////
35
36////////////////////////////////////////////////////////////////////////////////
37/// Create the container used to view TGTableCells. p.
38
40 : TQObject(), fFrame(0), fCanvas(0)
41{
44 fFrame->Connect("ProcessedEvent(Event_t*)", "TGTableFrame", this,
45 "HandleMouseWheel(Event_t*)");
46 fCanvas = 0;
47 fFrame->SetLayoutManager(new TGMatrixLayout(fFrame, nrows, ncolumns));
48
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Handle mouse wheel to scroll.
56
58{
59 if (event->fType != kButtonPress && event->fType != kButtonRelease)
60 return;
61
62 Int_t page = 0;
63 if (event->fCode == kButton4 || event->fCode == kButton5) {
64 if (!fCanvas) return;
69 }
70
71 if (event->fCode == kButton4) {
72 //scroll up
73 Int_t newpos = fCanvas->GetVsbPosition() - page;
74 if (newpos < 0) newpos = 0;
75 fCanvas->SetVsbPosition(newpos);
76 }
77 if (event->fCode == kButton5) {
78 // scroll down
79 Int_t newpos = fCanvas->GetVsbPosition() + page;
80 fCanvas->SetVsbPosition(newpos);
81 }
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Draw a region of container in viewport.
86
88{
90 // Handle_t id = fId;
91
92 Int_t xx = fCanvas->GetX() + fCanvas->GetHsbPosition() + x; // translate coordinates to current page position
94
95 TIter next(fFrame->GetList());
96
97 while ((el = (TGFrameElement *) next())) {
98 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
99 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
100 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
101 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
102
103 // draw either in container window or in double-buffer
104 // if (!fMapSubwindows) {
105 // el->fFrame->DrawCopy(id, el->fFrame->GetX() - pos.fX, el->fFrame->GetY() - pos.fY);
106 // } else {
107 gClient->NeedRedraw(el->fFrame);
108 // }
109 }
110 }
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// TGTableHeaderFrame constuctor.
115
118 UInt_t options) :
119 TGCompositeFrame(p, w, h, options), fX0(0), fY0(0), fTable(table)
120{
121 if (type == kRowHeader) {
124 } else if (type == kColumnHeader) {
127 } else {
128 Error("TGTableHeaderFrame::TGTableHeaderFrame",
129 "specify correct header type");
130 }
131
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Draw a region of container in viewport.
136
138{
139 TGFrameElement *el;
140 // Handle_t id = fId;
141
142 Int_t xx = fX0 + x; // translate coordinates to current page position
143 Int_t yy = fY0 + y;
144
145 TIter next(fList);
146
147 while ((el = (TGFrameElement *) next())) {
148 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
149 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
150 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
151 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
152
154 }
155 }
156}
@ 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
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
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:43
float Float_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:361
#define gClient
Definition: TGClient.h:166
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:338
TGFrame * GetContainer() const
Definition: TGCanvas.h:226
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Definition: TGCanvas.cxx:2403
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
Definition: TGCanvas.cxx:2379
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:227
virtual Int_t GetHsbPosition() const
Get position of horizontal scrollbar.
Definition: TGCanvas.cxx:2369
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:984
virtual TList * GetList() const
Definition: TGFrame.h:347
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1027
TList * fList
Definition: TGFrame.h:329
TGFrame * fFrame
Definition: TGLayout.h:119
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:693
Int_t GetX() const
Definition: TGFrame.h:256
virtual UInt_t GetOptions() const
Definition: TGFrame.h:222
UInt_t GetHeight() const
Definition: TGFrame.h:250
Int_t GetY() const
Definition: TGFrame.h:257
UInt_t GetWidth() const
Definition: TGFrame.h:249
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()
Return a pointer to the table header.
Definition: TGTable.cxx:1193
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
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:866
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