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// //
22// TGTableFrame and TGTableHeaderFrame //
23// //
24// TGTableFrame contains a composite frame that uses a TGMatrixLayout //
25// to Layout the frames it contains. //
26// //
27// TGTableHeaderFrame implements a frame used to display TGTableHeaders //
28// in a TGTable. //
29// //
30// Both classes are for internal use in TGTable only. //
31// //
32//////////////////////////////////////////////////////////////////////////
33
34////////////////////////////////////////////////////////////////////////////////
35/// Create the container used to view TGTableCells. p.
36
38 : TQObject(), fFrame(0), fCanvas(0)
39{
42 fFrame->Connect("ProcessedEvent(Event_t*)", "TGTableFrame", this,
43 "HandleMouseWheel(Event_t*)");
44 fCanvas = 0;
45 fFrame->SetLayoutManager(new TGMatrixLayout(fFrame, nrows, ncolumns));
46
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// Handle mouse wheel to scroll.
54
56{
57 if (event->fType != kButtonPress && event->fType != kButtonRelease)
58 return;
59
60 Int_t page = 0;
61 if (event->fCode == kButton4 || event->fCode == kButton5) {
62 if (!fCanvas) return;
67 }
68
69 if (event->fCode == kButton4) {
70 //scroll up
71 Int_t newpos = fCanvas->GetVsbPosition() - page;
72 if (newpos < 0) newpos = 0;
73 fCanvas->SetVsbPosition(newpos);
74 }
75 if (event->fCode == kButton5) {
76 // scroll down
77 Int_t newpos = fCanvas->GetVsbPosition() + page;
78 fCanvas->SetVsbPosition(newpos);
79 }
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Draw a region of container in viewport.
84
86{
88 // Handle_t id = fId;
89
90 Int_t xx = fCanvas->GetX() + fCanvas->GetHsbPosition() + x; // translate coordinates to current page position
92
93 TIter next(fFrame->GetList());
94
95 while ((el = (TGFrameElement *) next())) {
96 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
97 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
98 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
99 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
100
101 // draw either in container window or in double-buffer
102 // if (!fMapSubwindows) {
103 // el->fFrame->DrawCopy(id, el->fFrame->GetX() - pos.fX, el->fFrame->GetY() - pos.fY);
104 // } else {
105 gClient->NeedRedraw(el->fFrame);
106 // }
107 }
108 }
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// TGTableHeaderFrame constuctor.
113
116 UInt_t options) :
117 TGCompositeFrame(p, w, h, options), fX0(0), fY0(0), fTable(table)
118{
119 if (type == kRowHeader) {
122 } else if (type == kColumnHeader) {
125 } else {
126 Error("TGTableHeaderFrame::TGTableHeaderFrame",
127 "specify correct header type");
128 }
129
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Draw a region of container in viewport.
134
136{
137 TGFrameElement *el;
138 // Handle_t id = fId;
139
140 Int_t xx = fX0 + x; // translate coordinates to current page position
141 Int_t yy = fY0 + y;
142
143 TIter next(fList);
144
145 while ((el = (TGFrameElement *) next())) {
146 if ((Int_t(el->fFrame->GetY()) >= yy - (Int_t)el->fFrame->GetHeight()) &&
147 (Int_t(el->fFrame->GetX()) >= xx - (Int_t)el->fFrame->GetWidth()) &&
148 (Int_t(el->fFrame->GetY()) <= yy + Int_t(h + el->fFrame->GetHeight())) &&
149 (Int_t(el->fFrame->GetX()) <= xx + Int_t(w + el->fFrame->GetWidth()))) {
150
152 }
153 }
154}
@ 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:364
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
#define gClient
Definition TGClient.h:166
EHeaderType
@ kColumnHeader
@ kRowHeader
int type
Definition TGX11.cxx:121
#define gVirtualX
Definition TVirtualX.h:338
TGFrame * GetContainer() const
Definition TGCanvas.h:226
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:227
virtual Int_t GetHsbPosition() const
Get position of horizontal scrollbar.
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:371
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:985
virtual TList * GetList() const
Definition TGFrame.h:346
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1028
TList * fList
Definition TGFrame.h:328
TGFrame * fFrame
Definition TGLayout.h:119
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
Int_t GetX() const
Definition TGFrame.h:255
virtual UInt_t GetOptions() const
Definition TGFrame.h:221
UInt_t GetHeight() const
Definition TGFrame.h:249
Int_t GetY() const
Definition TGFrame.h:256
UInt_t GetWidth() const
Definition TGFrame.h:248
TGClient * fClient
Definition TGObject.h:37
Handle_t GetId() const
Definition TGObject.h:47
virtual UInt_t GetWidth() const
virtual UInt_t GetHeight() const
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:1186
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
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