LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evdb::ParamFrame Class Reference

Helper class to setup scroll bars in evdb::ParameterSetEdit. More...

#include "ParameterSetEdit.h"

Public Member Functions

 ParamFrame (const TGWindow *p, std::vector< std::string > &names, std::vector< std::string > &value, std::vector< TGTextEntry * > &fT2)
 
virtual ~ParamFrame ()
 
TGGroupFrame * GetFrame () const
 
void SetCanvas (TGCanvas *canvas)
 
void HandleMouseWheel (Event_t *event)
 
int GetHeight () const
 
int GetWidth () const
 

Private Attributes

TGGroupFrame * fFrame
 
TGCanvas * fCanvas
 
TGMatrixLayout * fML
 

Detailed Description

Helper class to setup scroll bars in evdb::ParameterSetEdit.

Definition at line 21 of file ParameterSetEdit.h.

Constructor & Destructor Documentation

evdb::ParamFrame::ParamFrame ( const TGWindow *  p,
std::vector< std::string > &  names,
std::vector< std::string > &  value,
std::vector< TGTextEntry * > &  fT2 
)

Definition at line 61 of file ParameterSetEdit.cxx.

References fCanvas, fFrame, and fML.

65  {
66  // Create tile view container. Used to show colormap.
67 
68  fFrame = new TGGroupFrame(p, "Parameters", kVerticalFrame);
69 
70  TGLayoutHints* fLH3 = new TGLayoutHints(kLHintsCenterX|kLHintsExpandX,
71  2,2,2,2);
72 
73  fML = new TGMatrixLayout(fFrame, 0, 2, 2);
74  fFrame->SetLayoutManager(fML);
75  int h=26;
76 
77  for (unsigned int i=0; i<name.size(); ++i) {
78  // skip if the name is module_label, module_type or service_type
79  if((name[i].compare("module_label") == 0) ||
80  (name[i].compare("module_type") == 0) ||
81  (name[i].compare("service_type") == 0)) continue;
82 
83  // Build the parameter label
84  TGTextButton*
85  b = new TGTextButton(fFrame,
86  name[i].c_str(),
87  -1,
88  TGButton::GetDefaultGC()(),
89  TGTextButton::GetDefaultFontStruct(),
90  0);
91  fFrame->AddFrame(b, fLH3);
92 
93  // Build the text edit box for the values
94  TGTextEntry* t = new TGTextEntry(fFrame, value[i].c_str());
95 
96  // Set the size of the edit box
97  t->Resize(225,18);
98  fFrame->AddFrame(t, fLH3);
99  fT2.push_back(t);
100  h += 26;
101  }
102  if (h>30*26) h = 30*26;
103 
104  fFrame->Resize(fFrame->GetWidth(), h);
105 
106  fFrame->Connect("ProcessedEvent(Event_t*)", "evdb::ParamFrame", this,
107  "HandleMouseWheel(Event_t*)");
108  fCanvas = 0;
109 
110  delete fLH3;
111  }
TGMatrixLayout * fML
TGGroupFrame * fFrame
virtual evdb::ParamFrame::~ParamFrame ( )
inlinevirtual

Definition at line 35 of file ParameterSetEdit.h.

References fFrame.

35 { delete fFrame; }
TGGroupFrame * fFrame

Member Function Documentation

TGGroupFrame* evdb::ParamFrame::GetFrame ( ) const
inline

Definition at line 37 of file ParameterSetEdit.h.

References fFrame.

Referenced by evdb::ParameterSetEdit::ParameterSetEdit().

37 { return fFrame; }
TGGroupFrame * fFrame
int evdb::ParamFrame::GetHeight ( ) const

Definition at line 115 of file ParameterSetEdit.cxx.

References fFrame.

Referenced by evdb::ParameterSetEdit::ParameterSetEdit(), and SetCanvas().

116  {
117  if (fFrame) return fFrame->GetHeight();
118  else return 0;
119  }
TGGroupFrame * fFrame
int evdb::ParamFrame::GetWidth ( ) const

Definition at line 123 of file ParameterSetEdit.cxx.

References fFrame.

Referenced by SetCanvas().

124  {
125  if (fFrame) return fFrame->GetWidth();
126  else return 0;
127  }
TGGroupFrame * fFrame
void evdb::ParamFrame::HandleMouseWheel ( Event_t *  event)

Definition at line 131 of file ParameterSetEdit.cxx.

References fCanvas.

Referenced by SetCanvas().

132  {
133  // Handle mouse wheel to scroll.
134 
135  if (event->fType != kButtonPress && event->fType != kButtonRelease)
136  return;
137 
138  Int_t page = 0;
139  if (event->fCode == kButton4 || event->fCode == kButton5) {
140  if (!fCanvas) return;
141  if (fCanvas->GetContainer()->GetHeight())
142  page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
143  fCanvas->GetViewPort()->GetHeight()) /
144  fCanvas->GetContainer()->GetHeight());
145  }
146 
147  if (event->fCode == kButton4) {
148  //scroll up
149  Int_t newpos = fCanvas->GetVsbPosition() - page;
150  if (newpos < 0) newpos = 0;
151  fCanvas->SetVsbPosition(newpos);
152  }
153  if (event->fCode == kButton5) {
154  // scroll down
155  Int_t newpos = fCanvas->GetVsbPosition() + page;
156  fCanvas->SetVsbPosition(newpos);
157  }
158  }
Event finding and building.
void evdb::ParamFrame::SetCanvas ( TGCanvas *  canvas)
inline

Definition at line 39 of file ParameterSetEdit.h.

References GetHeight(), GetWidth(), and HandleMouseWheel().

Referenced by evdb::ParameterSetEdit::ParameterSetEdit().

39 { fCanvas = canvas; }

Member Data Documentation

TGCanvas* evdb::ParamFrame::fCanvas
private

Definition at line 26 of file ParameterSetEdit.h.

Referenced by HandleMouseWheel(), and ParamFrame().

TGGroupFrame* evdb::ParamFrame::fFrame
private

Definition at line 25 of file ParameterSetEdit.h.

Referenced by GetFrame(), GetHeight(), GetWidth(), ParamFrame(), and ~ParamFrame().

TGMatrixLayout* evdb::ParamFrame::fML
private

Definition at line 27 of file ParameterSetEdit.h.

Referenced by ParamFrame().


The documentation for this class was generated from the following files: