Exemple #1
0
void MainUI::createUI(Wt::WContainerWidget *parent) {

  Wt::WMenu *menu =  new Wt::WMenu();

  pugi::xml_document doc;

  /* input file of menudata*/
  const std::string MENUDATA_XML_FILE = Wt::WApplication::instance()->docRoot() + "/menu-xml/menudata.xml";
  pugi::xml_parse_result tos = doc.load_file(MENUDATA_XML_FILE.c_str());

  std::cout << "Load result: " << tos.description() << std::endl;

  /* iteration over menudata but since only one is there so */
  pugi::xml_node menudata_node = doc.child("menudata");
  /* iteration over menubar but since only one is there so */
  pugi::xml_node menubar_node = menudata_node.child("menubar");

  /* iteration over fisrt occurane of menu */
  pugi::xml_node menu_node = menubar_node.child("menu");
  while( menu_node ) {


    /* first menu creation */
    Wt::WPopupMenu *firstLevel = new Wt::WPopupMenu();
    menu->addMenu(menu_node.child_value("label"), firstLevel);
    /* iteration over first occurance of items */
    pugi::xml_node menu_items_node = menu_node.child("items");
    while( menu_items_node ) {
       /* iteration over second occurane of menu */
       pugi::xml_node menu_items_menu_node = menu_items_node.child("menu");
       while( menu_items_menu_node ) {
          /* submenu creation */
          Wt::WPopupMenu *nextLevel = new Wt::WPopupMenu();
          firstLevel->addMenu(menu_items_menu_node.child_value("label"), nextLevel);
          /* iteration over second occurance of items */
          pugi::xml_node menu_items_menu_items_node = menu_items_menu_node.child("items");
          while ( menu_items_menu_items_node ) {
             /* iteration over internal occurance of menuitem */
             pugi::xml_node menu_items_menu_items_menuitem_node = menu_items_menu_items_node.child("menuitem");
             while( menu_items_menu_items_menuitem_node ) {
                nextLevel->addItem(menu_items_menu_items_menuitem_node.child_value("label"));
                menu_items_menu_items_menuitem_node = menu_items_menu_items_menuitem_node.next_sibling("menuitem");
             }
             menu_items_menu_items_node = menu_items_menu_items_node.next_sibling("items");
          }
          menu_items_menu_node = menu_items_menu_node.next_sibling("menu");
       }

       /* iteration over outer occurance of menuitem */
       pugi::xml_node menu_items_menuitem_node = menu_items_node.child("menuitem");
       while ( menu_items_menuitem_node ) {
          firstLevel->addItem(menu_items_menuitem_node.child_value("label"));
          menu_items_menuitem_node = menu_items_menuitem_node.next_sibling("menuitem");
       }

       menu_items_node = menu_items_node.next_sibling("items");

       menu_node = menu_node.next_sibling("menu");
    }
  }

  Wt::WNavigationBar *naivgationbar = new Wt::WNavigationBar();
  naivgationbar->setResponsive(true);
  naivgationbar->addMenu(menu);
  addWidget(naivgationbar);

}
Exemple #2
0
void studentPasswords::create() {
  Wt::WPanel * panel = new Wt::WPanel(this);
  
  panel->setStyleClass("panel panel-primary");
  panel->setTitle("<h3>Wachtwoorden Administratie</h3>");
  panel->setMinimumSize(800, 800);
  panel->setMaximumSize(800, Wt::WLength::Auto);
  panel->setMargin("0 auto");
  
  Wt::WContainerWidget * content = new Wt::WContainerWidget();
  panel->setCentralWidget(content);
  content->setPadding("1%");
  
  buttons = new Wt::WContainerWidget(content);
  Wt::WHBoxLayout * buttonLayout = new Wt::WHBoxLayout();
  buttons->setLayout(buttonLayout);
  
  Wt::WPopupMenu * popup = new Wt::WPopupMenu();
  Wt::WPushButton * button = new Wt::WPushButton();
  button->setMenu(popup);
  button->setText("Selecteer een klas");
  buttonLayout->addWidget(button);
  
  Wt::WPushButton * button2 = new Wt::WPushButton();
  button2->setText("Selectie Aanpassen");
  button2->setStyleClass("btn btn-success");
  buttonLayout->addWidget(button2);
  button2->clicked().connect(this, &studentPasswords::changePasswords);
  
  Wt::WContainerWidget * tableContent = new Wt::WContainerWidget(content);
  table = new Wt::WTable(tableContent);
  
  // add classes
  Wt::WPopupMenu * subMenu[7];
  
  for(int i = 0; i < 7; i++) {
    subMenu[i] = new Wt::WPopupMenu();
    if(i == 0) {
      popup->addMenu("1ste jaar", subMenu[i]);
    } else {
      string s = string(i+1) + "de jaar";
      popup->addMenu(s.wt(), subMenu[i]);
    }
  }
  
  CLASSES & classes = server->getClasses();
  
  for(int i = 0; i < classes.elms(); i++) {
    string name = classes[i].cn().get();
    if(name.empty()) continue;
    
    int year = -1;
    switch(name[0]) {
      case '1': year = 0; break;
      case '2': year = 1; break;
      case '3': year = 2; break;
      case '4': year = 3; break;
      case '5': year = 4; break;
      case '6': year = 5; break;
      case '7': year = 6; break;
    }
    if(year < 0) continue;
    
    subMenu[year]->addItem(name.wt())->triggered().connect(std::bind([=] () {
      showClass(name);
    }));
  }
  
  progress = new Wt::WProgressBar(content);
  progress->hide();
  
  anchor = new Wt::WAnchor(Wt::WLink(&pfile), "Download passwords", content);
  anchor->setTarget(Wt::TargetNewWindow);
  anchor->clicked().connect(this, &studentPasswords::reset);
  anchor->hide();
}