CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

FWDialogBuilder Class Reference

#include <FWDialogBuilder.h>

Inheritance diagram for FWDialogBuilder:
FWLayoutBuilder

List of all members.

Public Member Functions

FWDialogBuilderaddCheckbox (const char *text, TGCheckButton **out=0)
FWDialogBuilderaddColorPicker (const FWColorManager *manager, FWColorSelect **out=0)
FWDialogBuilderaddHSeparator (size_t horizontalPadding=4, size_t verticalPadding=3)
FWDialogBuilderaddHSlider (size_t size, TGHSlider **out=0)
FWDialogBuilderaddHtml (TGHtml **out=0)
FWDialogBuilderaddLabel (const char *text, size_t fontSize=12, size_t weight=0, TGLabel **out=0)
FWDialogBuilderaddNumberEntry (float defaultValue, size_t digits, TGNumberFormat::EStyle style, int min, int max, TGNumberEntry **out)
FWDialogBuilderaddTable (FWTableManagerBase *manager, FWTableWidget **out=0)
FWDialogBuilderaddTextButton (const char *text, TGTextButton **out=0)
FWDialogBuilderaddTextEdit (const char *defaultText=0, TGTextEdit **out=0)
FWDialogBuilderaddTextEntry (const char *defaultText, TGTextEntry **out)
FWDialogBuilderaddTextView (const char *defaultText=0, TGTextView **out=0)
FWDialogBuilderaddValidatingTextEntry (const char *defaultText, FWGUIValidatingTextEntry **out)
FWDialogBuilderbeginTab (const char *label)
FWDialogBuilderendTab (void)
FWDialogBuilderexpand (size_t expandX=true, size_t expandY=false)
FWDialogBuilderfloatLeft (size_t spacing=3)
FWDialogBuilderframeSpaceDown (size_t spacing=3)
FWDialogBuilderframeSpaceLeft (size_t spacing=3)
FWDialogBuilderframeSpaceLeftRight (size_t spacing=3)
FWDialogBuilderframeSpaceRight (size_t spacing=3)
FWDialogBuilderframeSpaceUp (size_t spacing=3)
FWDialogBuilderframeSpaceUpDown (size_t spacing=3)
 FWDialogBuilder (TGCompositeFrame *window, FWDialogBuilder *parent=0, bool expandY=true)
FWDialogBuilderhSpacer (size_t size=0)
FWDialogBuilderindent (int left=2, int right=-1)
FWDialogBuildernewRow ()
FWDialogBuilderspaceDown (size_t spacing=3)
FWDialogBuilderspaceLeft (size_t spacing=3)
FWDialogBuilderspaceLeftRight (size_t spacing=3)
FWDialogBuilderspaceRight (size_t spacing=3)
FWDialogBuilderspaceUp (size_t spacing=3)
FWDialogBuilderspaceUpDown (size_t spacing=3)
FWDialogBuildertabs (TGTab **out)
FWDialogBuilderunindent (void)
FWDialogBuilderuntabs (void)
FWDialogBuildervSpacer (size_t size=0)

Protected Member Functions

template<class T >
FWDialogBuilderextract (T *in, T **out)

Private Attributes

FWDialogBuilderm_parent
TGTab * m_tabs

Detailed Description

Helper class to construct dialogs in a more readable ways.

Encapsulated TGUI layout hiccups and exposes the developer an API which allows to layout items in a top->bottom, right->left manner.

Example:

FWDialogBuilder builder(parent); parent.newRow(2) // New row which has a 2 pixel padding on top. .addLabel("MyLabel:") // A new label. .indent(20) // Whatever follows is indented 20 pixels on the right. .addLabel("MyLabel2") // Another label. .spaceDown(4) .addTextButton("Aligned to MyLabel2 ").floatLeft() .addTextButton("Same Row as previous") .unindent() // back one level in the indentation. .addLabel("Aligned to MyLabel:")

Because in ROOT layout and parenting of widgets are mixed we need to take responsibility for creating the widget objects (sigh!), so we have one "addXYZ" method per widget that can be added. If we find our way around this it would be better to have a generic "addWidget()" method and create widgets outside this class.

TODO: For higher configurability we should have an "addWithCallback(Callbak)" method which can be used to specify a generic widget creation action.

Definition at line 93 of file FWDialogBuilder.h.


Constructor & Destructor Documentation

FWDialogBuilder::FWDialogBuilder ( TGCompositeFrame *  window,
FWDialogBuilder parent = 0,
bool  expandY = true 
)

Helper class to construct dialogs in a more readable ways.

Encapsulated TGUI layout hiccups and exposes the developer an API which allows to layout items in a top->bottom, right->left manner.

Example:

FWDialogBuilder builder(parent); parent.newRow(2) // New row which has a 2 pixel padding on top. .addLabel("MyLabel:") // A new label. .indent(20) // Whatever follows is indented 20 pixels on the right. .addLabel("MyLabel2") // Another label. .spaceDown(4) .addTextButton("Aligned to MyLabel2 ").floatLeft() .addTextButton("Same Row as previous") .unindent() // back one level in the indentation. .addLabel("Aligned to MyLabel:")

Because in ROOT layout and parenting of widgets are mixed we need to take responsibility for creating the widget objects (sigh!), so we have one "addXYZ" method per widget that can be added. If we find our way around this it would be better to have a generic "addWidget()" method and create widgets outside this class.

TODO: For higher configurability we should have an "addWithCallback(Callbak)" method which can be used to specify a generic widget creation action.

Definition at line 228 of file FWDialogBuilder.cc.

Referenced by beginTab().

   : FWLayoutBuilder(window, expandY),
     m_parent(parent),
     m_tabs(0)
{}

Member Function Documentation

FWDialogBuilder & FWDialogBuilder::addCheckbox ( const char *  text,
TGCheckButton **  out = 0 
)

Definition at line 398 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI(), CmsShowModelPopup::CmsShowModelPopup(), and FWGUIEventDataAdder::createWindow().

{
   TGCheckButton *button = new TGCheckButton(nextFrame(), text);
   button->SetState(kButtonDown, false);
   button->SetEnabled(false);
   currentFrame()->AddFrame(button, nextHints());
   
   return extract(button, out);
}
FWDialogBuilder & FWDialogBuilder::addColorPicker ( const FWColorManager manager,
FWColorSelect **  out = 0 
)

Definition at line 323 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI(), and CmsShowModelPopup::CmsShowModelPopup().

{
   const char* graphicsLabel = " ";
   FWColorSelect *widget = new FWColorSelect(nextFrame(), graphicsLabel,
                                             0, manager, -1);
   
   currentFrame()->AddFrame(widget, nextHints());
   widget->SetEnabled(kFALSE);
   
   return extract(widget, out);
}
FWDialogBuilder & FWDialogBuilder::addHSeparator ( size_t  horizontalPadding = 4,
size_t  verticalPadding = 3 
)

Definition at line 421 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), newRow(), and FWLayoutBuilder::nextFrame().

Referenced by CmsShowEDI::CmsShowEDI(), and CmsShowModelPopup::CmsShowModelPopup().

{
   TGLayoutHints *hints = new TGLayoutHints(kLHintsExpandX,
                                            horizontalPadding,
                                            horizontalPadding,
                                            verticalPadding,
                                            verticalPadding);

   TGHorizontal3DLine* separator = new TGHorizontal3DLine(nextFrame(), 200, 2);
   currentFrame()->AddFrame(separator, hints);
   return newRow();
}
FWDialogBuilder & FWDialogBuilder::addHSlider ( size_t  size,
TGHSlider **  out = 0 
)

Definition at line 337 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI(), and CmsShowModelPopup::CmsShowModelPopup().

{
   TGHSlider *slider = new TGHSlider(nextFrame(), size, kSlider1);
   currentFrame()->AddFrame(slider, nextHints());
   slider->SetRange(0, 100);
   slider->SetPosition(100);
   slider->SetEnabled(false);
   
   return extract(slider, out);
}
FWDialogBuilder & FWDialogBuilder::addHtml ( TGHtml **  out = 0)

Definition at line 302 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), expand(), extract(), packageDocSplitter::html, FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

{
  TGHtml *html = new TGHtml(nextFrame(), 100, 100);
  currentFrame()->AddFrame(html, nextHints());   
  expand(true, true);
  return extract(html, out);
}
FWDialogBuilder & FWDialogBuilder::addLabel ( const char *  text,
size_t  fontSize = 12,
size_t  weight = 0,
TGLabel **  out = 0 
)

Definition at line 257 of file FWDialogBuilder.cc.

References asciidump::attributes, FWLayoutBuilder::currentFrame(), extract(), diffTwoXMLs::label, FWLayoutBuilder::nextFrame(), FWLayoutBuilder::nextHints(), and fetchall_from_DQM_v2::pool.

Referenced by CmsShowEDI::CmsShowEDI(), CmsShowModelPopup::CmsShowModelPopup(), FWGUIEventDataAdder::createWindow(), and FWPathsPopup::FWPathsPopup().

{
   TGLabel *label = new TGLabel(nextFrame(), text);

   if (fontSize != 0)
   {
      FontStruct_t defaultFontStruct = label->GetDefaultFontStruct();
      try
      {
         TGFontPool *pool = gClient->GetFontPool();
         TGFont* defaultFont = pool->GetFont(defaultFontStruct);
         FontAttributes_t attributes = defaultFont->GetFontAttributes();
         label->SetTextFont(pool->GetFont(attributes.fFamily, fontSize, 
                                          attributes.fWeight, attributes.fSlant));
      } 
      catch(...)
      {
         // Ignore exceptions.
      }
   }

   label->SetTextJustify(kTextLeft);
   
   TGLayoutHints *hints = nextHints();
   UInt_t style = hints->GetLayoutHints() | kLHintsCenterY;
   hints->SetLayoutHints(style);
   currentFrame()->AddFrame(label, hints);
   
   return extract(label, out);
}
FWDialogBuilder & FWDialogBuilder::addNumberEntry ( float  defaultValue,
size_t  digits,
TGNumberFormat::EStyle  style,
int  min,
int  max,
TGNumberEntry **  out 
)

Definition at line 380 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI().

{
   TGNumberEntry *entry = new TGNumberEntry(nextFrame(), defaultValue, 
                                            digits, -1, style,
                                            TGNumberFormat::kNEAAnyNumber,
                                            TGNumberFormat::kNELLimitMinMax,
                                            min, max);
   currentFrame()->AddFrame(entry, nextHints());
   entry->GetNumberEntry()->SetEnabled(kFALSE);
   entry->GetButtonUp()->SetEnabled(kFALSE);
   entry->GetButtonDown()->SetEnabled(kFALSE);
   return extract(entry, out);
}
FWDialogBuilder & FWDialogBuilder::addTable ( FWTableManagerBase manager,
FWTableWidget **  out = 0 
)

Definition at line 409 of file FWDialogBuilder.cc.

References expand(), extract(), asciidump::table, and FWLayoutBuilder::verticalFrame().

Referenced by FWGUIEventDataAdder::createWindow(), and FWPathsPopup::FWPathsPopup().

{
   expand(true, true);
   TGCompositeFrame *frame = verticalFrame();
   TGLayoutHints *hints = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY);
   FWTableWidget *table = new FWTableWidget(manager, frame);
   frame->AddFrame(table, hints);
   return extract(table, out);
}
FWDialogBuilder & FWDialogBuilder::addTextButton ( const char *  text,
TGTextButton **  out = 0 
)

Definition at line 349 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI(), FWGUIEventDataAdder::createWindow(), and FWPathsPopup::FWPathsPopup().

{
   TGTextButton *button = new TGTextButton(nextFrame(), text);
   currentFrame()->AddFrame(button, nextHints());
   button->SetEnabled(false);
   
   return extract(button, out);
}
FWDialogBuilder & FWDialogBuilder::addTextEdit ( const char *  defaultText = 0,
TGTextEdit **  out = 0 
)

Definition at line 311 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), expand(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

{
   TGTextEdit *edit = new TGTextEdit(nextFrame(), 100, 100);
   if (defaultText)
      edit->AddLine(defaultText);
   currentFrame()->AddFrame(edit, nextHints());
   expand(true, true);
   return extract(edit, out);
}
FWDialogBuilder & FWDialogBuilder::addTextEntry ( const char *  defaultText,
TGTextEntry **  out 
)

Definition at line 369 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI(), FWGUIEventDataAdder::createWindow(), and FWPathsPopup::FWPathsPopup().

{
   TGTextEntry *entry = new TGTextEntry(nextFrame());
   currentFrame()->AddFrame(entry, nextHints());
   entry->SetEnabled(kFALSE);
   
   return extract(entry, out);
}
FWDialogBuilder & FWDialogBuilder::addTextView ( const char *  defaultText = 0,
TGTextView **  out = 0 
)

Definition at line 290 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), expand(), extract(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI().

{
   TGTextView *view = new TGTextView(nextFrame(), 100, 100);
   if (defaultText)
      view->AddLine(defaultText);
   currentFrame()->AddFrame(view, nextHints());
   expand(true, true);
   return extract(view, out);
}
FWDialogBuilder & FWDialogBuilder::addValidatingTextEntry ( const char *  defaultText,
FWGUIValidatingTextEntry **  out 
)
FWDialogBuilder & FWDialogBuilder::beginTab ( const char *  label)

Adds a new tab called label. A new tab gets a new builder so that tab building is completely scoped.

Definition at line 479 of file FWDialogBuilder.cc.

References FWDialogBuilder(), m_tabs, newRow(), and accesses::tab.

Referenced by CmsShowEDI::CmsShowEDI().

{
   TGCompositeFrame *tab = m_tabs->AddTab(label);
   
   FWDialogBuilder *builder = new FWDialogBuilder(tab, this, false);
   return builder->newRow();
}
FWDialogBuilder & FWDialogBuilder::endTab ( void  )

When we are done with the tab, we delete ourself and return the parent.

Definition at line 490 of file FWDialogBuilder.cc.

References m_parent, and dbtoconf::parent.

Referenced by CmsShowEDI::CmsShowEDI().

{
   FWDialogBuilder *parent = m_parent;
   delete this;
   return *parent;
}
FWDialogBuilder & FWDialogBuilder::expand ( size_t  expandX = true,
size_t  expandY = false 
)
template<class T >
FWDialogBuilder& FWDialogBuilder::extract ( T in,
T **  out 
) [inline, protected]
FWDialogBuilder & FWDialogBuilder::floatLeft ( size_t  spacing = 3)

Make sure that the current layout element is going to float on the left of the next one.

Reimplemented from FWLayoutBuilder.

Definition at line 498 of file FWDialogBuilder.cc.

Referenced by CmsShowEDI::CmsShowEDI(), FWGUIEventDataAdder::createWindow(), and FWPathsPopup::FWPathsPopup().

{
   FWLayoutBuilder::floatLeft(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::frameSpaceDown ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 559 of file FWDialogBuilder.cc.

Referenced by FWGUIEventDataAdder::createWindow(), and frameSpaceUpDown().

{
   FWLayoutBuilder::frameSpaceDown(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::frameSpaceLeft ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 574 of file FWDialogBuilder.cc.

Referenced by frameSpaceLeftRight().

{
   FWLayoutBuilder::frameSpaceLeft(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::frameSpaceLeftRight ( size_t  spacing = 3)

Definition at line 588 of file FWDialogBuilder.cc.

References frameSpaceLeft(), and frameSpaceRight().

FWDialogBuilder & FWDialogBuilder::frameSpaceRight ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 581 of file FWDialogBuilder.cc.

Referenced by frameSpaceLeftRight().

{
   FWLayoutBuilder::frameSpaceRight(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::frameSpaceUp ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 552 of file FWDialogBuilder.cc.

Referenced by frameSpaceUpDown().

{
   FWLayoutBuilder::frameSpaceUp(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::frameSpaceUpDown ( size_t  spacing = 3)

Definition at line 566 of file FWDialogBuilder.cc.

References frameSpaceDown(), and frameSpaceUp().

Referenced by FWGUIEventDataAdder::createWindow().

{
   FWLayoutBuilder::frameSpaceUp(spacing);
   FWLayoutBuilder::frameSpaceDown(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::hSpacer ( size_t  size = 0)

Definition at line 623 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), expand(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by FWGUIEventDataAdder::createWindow().

{
   TGFrame *frame;
   if (size) 
      frame = new TGFrame(nextFrame(), size, 1);
   else
      frame = new TGFrame(nextFrame());
   
   currentFrame()->AddFrame(frame, nextHints());
   
   if (!size)
      expand(true, false);
   else
      expand(false, false);
   
   return *this;
}
FWDialogBuilder & FWDialogBuilder::indent ( int  left = 2,
int  right = -1 
)
FWDialogBuilder & FWDialogBuilder::newRow ( void  )

Reimplemented from FWLayoutBuilder.

Definition at line 236 of file FWDialogBuilder.cc.

Referenced by addHSeparator(), beginTab(), and vSpacer().

{
   FWLayoutBuilder::newRow();
   return *this;
}
FWDialogBuilder & FWDialogBuilder::spaceDown ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 512 of file FWDialogBuilder.cc.

Referenced by FWGUIEventDataAdder::createWindow(), FWPathsPopup::FWPathsPopup(), and spaceUpDown().

{
   FWLayoutBuilder::spaceDown(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::spaceLeft ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 527 of file FWDialogBuilder.cc.

Referenced by spaceLeftRight().

{
   FWLayoutBuilder::spaceLeft(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::spaceLeftRight ( size_t  spacing = 3)

Definition at line 541 of file FWDialogBuilder.cc.

References spaceLeft(), and spaceRight().

{
   FWLayoutBuilder::spaceLeft(spacing);
   FWLayoutBuilder::spaceRight(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::spaceRight ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 534 of file FWDialogBuilder.cc.

Referenced by FWGUIEventDataAdder::createWindow(), and spaceLeftRight().

{
   FWLayoutBuilder::spaceRight(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::spaceUp ( size_t  spacing = 3)

Reimplemented from FWLayoutBuilder.

Definition at line 505 of file FWDialogBuilder.cc.

Referenced by FWGUIEventDataAdder::createWindow(), and spaceUpDown().

{
   FWLayoutBuilder::spaceUp(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::spaceUpDown ( size_t  spacing = 3)

Definition at line 519 of file FWDialogBuilder.cc.

References spaceDown(), and spaceUp().

{
   FWLayoutBuilder::spaceUp(spacing);
   FWLayoutBuilder::spaceDown(spacing);
   return *this;
}
FWDialogBuilder & FWDialogBuilder::tabs ( TGTab **  out)

Support for tabs.

This is done by creating a new DialogBuilder and returning it for each of the added tabs.

builder.tabs() // Adds a TGTab widget to the current frame. .beginTab("Foo") // Add a tab to the TGTab. .textButton("In Foo") // This is inside the tab "Foo", the layouting is independent from previous calls since a separate builder was returned by

.endTab("Foo") // End of the tab. .beginTab("Bar") .endTab("") .untabs(); // Tabs completed. .textButton("Main scope") // This is on the same level as the TGTab.

Definition at line 454 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), expand(), extract(), m_tabs, FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI().

{
   // Calls to tabs cannot be nested within the same builder. Multiple
   // builders are used to support nested tabs.
   assert(!m_tabs);
   expand(true, true);
   m_tabs = new TGTab(nextFrame());
   currentFrame()->AddFrame(m_tabs, nextHints());
   expand(true, true);
   return extract(m_tabs, out);
}
FWDialogBuilder & FWDialogBuilder::unindent ( void  )

Removes all the frames on the stack since last indent.

Reimplemented from FWLayoutBuilder.

Definition at line 250 of file FWDialogBuilder.cc.

{
   FWLayoutBuilder::unindent();
   return *this;
}
FWDialogBuilder & FWDialogBuilder::untabs ( void  )

Definition at line 467 of file FWDialogBuilder.cc.

References m_tabs.

Referenced by CmsShowEDI::CmsShowEDI().

{
   // No untabs() without tabs().
   assert(m_tabs);
   m_tabs = 0;
   return *this;
}
FWDialogBuilder & FWDialogBuilder::vSpacer ( size_t  size = 0)

Definition at line 604 of file FWDialogBuilder.cc.

References FWLayoutBuilder::currentFrame(), expand(), newRow(), FWLayoutBuilder::nextFrame(), and FWLayoutBuilder::nextHints().

Referenced by CmsShowEDI::CmsShowEDI().

{
   newRow().expand(true, true);
   
   TGFrame *frame;
   if (size) 
      frame = new TGFrame(nextFrame(), 1, size);
   else
      frame = new TGFrame(nextFrame());
   
   currentFrame()->AddFrame(frame, nextHints());

   expand(true, true);
   
   return *this;
}

Member Data Documentation

Definition at line 171 of file FWDialogBuilder.h.

Referenced by endTab().

TGTab* FWDialogBuilder::m_tabs [private]

Definition at line 172 of file FWDialogBuilder.h.

Referenced by beginTab(), tabs(), and untabs().