Exemplo n.º 1
0
TreeViewExample::TreeViewExample(WStandardItemModel *model,
				 const WString& titleText)
  : model_(model)
{
  belgium_ = model_->item(0, 0)->child(0, 0);

  new WText(titleText, this);

  /*
   * Now create the view
   */
  WPanel *panel = new WPanel(this);
  panel->resize(600, 300);
  panel->setCentralWidget(treeView_ = new WTreeView());
  if (!WApplication::instance()->environment().ajax())
    treeView_->resize(WLength::Auto, 290);

  treeView_->setAlternatingRowColors(true);
  treeView_->setRowHeight(25);
  treeView_->setModel(model_);

  treeView_->setColumnWidth(1, WLength(100));
  treeView_->setColumnAlignment(1, AlignCenter);
  treeView_->setColumnWidth(3, WLength(100));
  treeView_->setColumnAlignment(3, AlignCenter);

  /*
  treeView_->setRowHeaderCount(1);
  treeView_->setColumnWidth(0, 300);
  */

  /*
   * Expand the first (and single) top level node
   */
  treeView_->setExpanded(model->index(0, 0), true);
  treeView_->setExpanded(model->index(0, 0, model->index(0, 0)), true);

  /*
   * Setup some buttons to manipulate the view and the model.
   */
  WContainerWidget *wc = new WContainerWidget(this);
  WPushButton *b;
  
  b = new WPushButton("Toggle row height", wc);
  b->clicked().connect(this, &TreeViewExample::toggleRowHeight);
  b->setToolTip("Toggles row height between 31px and 25px");
  
  b = new WPushButton("Toggle stripes", wc);
  b->clicked().connect(this, &TreeViewExample::toggleStripes);
  b->setToolTip("Toggle alternating row colors");
  
  b = new WPushButton("Toggle root", wc);
  b->clicked().connect(this, &TreeViewExample::toggleRoot);
  b->setToolTip("Toggles root item between all and the first continent.");

  b = new WPushButton("Add rows", wc);
  b->clicked().connect(this, &TreeViewExample::addRows);
  b->setToolTip("Adds some cities to Belgium");
}
Exemplo n.º 2
0
WPanel *PanelList::addWidget(const WString& text, WWidget *w)
{
  WPanel *p = new WPanel();
  p->setTitle(text);
  p->setCentralWidget(w);

  addPanel(p);

  return p;
}
Exemplo n.º 3
0
pair<WPanel *, WContainerWidget *> MediaInfoPanel::Private::createPanel( string titleKey )
{
  WPanel *panel = new WPanel();
  panel->setTitle( wtr( titleKey ) );
  panel->setCollapsible( true );
  panel->setMargin( 10, Wt::Side::Top );
  settings->setAnimation( Settings::PanelAnimation, panel );
  setHeaderCollapsible( panel );
  WContainerWidget *container = new WContainerWidget();
  panel->setCentralWidget( container );
  return {panel, container};
}
Exemplo n.º 4
0
void PanelList::onExpand(bool notUndo)
{
  WPanel *panel = dynamic_cast<WPanel *>(sender());

  if (notUndo) {
    wasExpanded_ = -1;

    for (unsigned i = 0; i < children().size(); ++i) {
      WPanel *p = dynamic_cast<WPanel *>(children()[i]);
      if (p != panel) {
	if (!p->isCollapsed())
	  wasExpanded_ = i;
	p->collapse();
      }
    }
  } else {
    if (wasExpanded_ != -1) {
      WPanel *p = dynamic_cast<WPanel *>(children()[wasExpanded_]);
      p->expand();
    }
  }
}
Exemplo n.º 5
0
StatusPanel::StatusPanel(WContainerWidget *pParent) :
   WContainerWidget(pParent)
{
   WPanel *pPanel = new WPanel(this);
   pPanel->setTitle("Status LEDs");
   

   WTable *pLedTable = new WTable();
   pLedTable->setMargin(WLength::Auto, Left | Right);
   mpAlarmMinor = new LedWidget(new WText("Minor"), Bottom);

   mpAlarmMajor = new LedWidget(new WText("Major"), Bottom);

   mpAlarmCritical = new LedWidget(new WText("Critical"), Bottom);

   pLedTable->elementAt(0, 0)->addWidget(mpAlarmMinor);
   pLedTable->elementAt(0, 1)->addWidget(mpAlarmMajor);
   pLedTable->elementAt(0, 2)->addWidget(mpAlarmCritical);

   pPanel->setCentralWidget(pLedTable);
   pPanel->setCollapsible(true);
}