Ejemplo n.º 1
0
bool WWindow::processMsg( UINT msg, UINT wparm, LONG lparm )
{
	switch( msg ) {
	case WM_CLOSE:
		close();
		return TRUE;
	case WM_DESTROY:
		ifnil( GetParent( _handle ) ) {
			PostQuitMessage( 0 );
		}
		return TRUE;
	case WM_PAINT:
	{
		PAINTSTRUCT ps;
		_dcHandle = BeginPaint( _handle, &ps );
		bool ret = paint();    // do the actual painting
		_dcHandle = 0;
		EndPaint( _handle, &ps );
		return ret;
	}
	case WM_COMMAND:
		if( LOWORD( lparm ) == 0 ) {
			if( HIWORD( lparm ) == 0 ) {
				//message is from a menu
				WMenuItem* itm = (WMenuItem*)WWindow::_objMap.findThis( (HANDLE)wparm );
				ifptr( itm ) {
					itm->picked();
					return TRUE;
				}
			} else {
				//message is from an accelerator
			}
		} else {
Ejemplo n.º 2
0
Archivo: WMenu.C Proyecto: LifeGo/wt
void WMenu::selectVisual(int index, bool changePath, bool showContents)
{
  if (contentsStack_)
    previousStackIndex_ = contentsStack_->currentIndex();

  WMenuItem *item = index >= 0 ? itemAt(index) : 0;

  if (changePath && internalPathEnabled_ &&
      index != -1 && item->internalPathEnabled()) {
    WApplication *app = wApp;
    previousInternalPath_ = app->internalPath();

    std::string newPath = basePath_ + item->pathComponent();
    if (newPath != app->internalPath())
      emitPathChange_ = true;

    // The change is emitted in select()
    app->setInternalPath(newPath);
  }

  for (int i = 0; i < count(); ++i)
    renderSelected(itemAt(i), (int)i == index);

  if (index == -1)
    return;

  if (showContents && contentsStack_) {
    WWidget *contents = item->contents();
    if (contents)
      contentsStack_->setCurrentWidget(contents);
  }

  itemSelectRendered_.emit(item);
}
Ejemplo n.º 3
0
Archivo: WMenu.C Proyecto: LifeGo/wt
void WMenu::select(int index, bool changePath)
{
  int last = current_;
  setCurrent(index);

  selectVisual(current_, changePath, true);

  if (index != -1) {
    WMenuItem *item = itemAt(index);
    item->show();
    item->loadContents();

    DeletionTracker guard(this);

    if (changePath && emitPathChange_) {
      WApplication *app = wApp;
      app->internalPathChanged().emit(app->internalPath());
      if (guard.deleted())
        return;
      emitPathChange_ = false;
    }

    if (last != index) {
      item->triggered().emit(item);
      if (!guard.deleted()) {
        // item may have been deleted too
        if (ul()->indexOf(item) != -1)
          itemSelected_.emit(item);
        else
          select(-1);
      }
    }
  }
}
Ejemplo n.º 4
0
WMenuItem *WMenu::addMenu(const std::string& iconPath,
			  const WString& text, WMenu *menu)
{
  WMenuItem *item = addItem(iconPath, text);
  item->setMenu(menu);
  return item;
}
Ejemplo n.º 5
0
Archivo: WMenu.C Proyecto: LifeGo/wt
WMenuItem *WMenu::addMenu(const std::string& iconPath,
			  const WString& text, WMenu *menu)
{
  WMenuItem *item = new WMenuItem(iconPath, text, 0, WMenuItem::LazyLoading);
  item->setMenu(menu);
  addItem(item);
  return item;
}
Ejemplo n.º 6
0
Archivo: WMenu.C Proyecto: LifeGo/wt
WMenuItem *WMenu::insertMenu(int index, const std::string& iconPath,
                          const WString& text, WMenu *menu)
{
  WMenuItem *item = new WMenuItem(iconPath, text, 0, WMenuItem::LazyLoading);
  item->setMenu(menu);
  insertItem(index, item);
  return item;
}
Ejemplo n.º 7
0
Archivo: WMenu.C Proyecto: LifeGo/wt
void WMenu::updateItemsInternalPath()
{
  for (int i = 0; i < count(); ++i) {
    WMenuItem *item = itemAt(i);
    item->updateInternalPath();
  }

  updateSelectionEvent();
}
Ejemplo n.º 8
0
WMenuItem * WEXPORT WPopupMenu::removeItemAt( int index ) {
/*********************************************************/

    if( index >= 0 ) {
        WMenuItem *item = (WMenuItem *)_children.removeAt( index );
        item->detachMenu();
        item->setParent( NULL );
        return( item );
    }
    return( NULL );
}
Ejemplo n.º 9
0
void WPopupMenu::connectSignals(WPopupMenu * const topLevel)
{
  topLevel_ = topLevel;
  itemSelected().connect(topLevel, &WPopupMenu::done);

  for (int i = 0; i < count(); ++i) {
    WMenuItem *item = itemAt(i);
    WPopupMenu *subMenu = dynamic_cast<WPopupMenu *>(item->menu());

    if (subMenu)
      subMenu->connectSignals(topLevel);
  }
}
Ejemplo n.º 10
0
void WTabWidget::removeTab(WWidget *child)
{
  int tabIndex = indexOf(child);

  if (tabIndex != -1) {
    contentsWidgets_.erase(contentsWidgets_.begin() + tabIndex);

    WMenuItem *item = menu_->items()[tabIndex];
    menu_->removeItem(item);

    item->takeContents();
    delete item;
  }
}
Ejemplo n.º 11
0
std::unique_ptr<WWidget> WTabWidget::removeTab(WWidget *child)
{
  int tabIndex = indexOf(child);

  if (tabIndex != -1) {
    contentsWidgets_.erase(contentsWidgets_.begin() + tabIndex);

    WMenuItem *item = menu_->itemAt(tabIndex);
    std::unique_ptr<WWidget> result = item->removeContents();
    menu_->removeItem(item);
    return result;
  } else
    return std::unique_ptr<WWidget>();
}
Ejemplo n.º 12
0
void MenuManager::makeItem( WPopupMenu * pop, const SubMenuInfo * info,
                            int idx, bool disable )
//-------------------------------------------------------------------------------
{
    WMenuItem * item;

    if( info[ idx ].menuName != NULL ) {
        item = new WMenuItem( info[ idx ].menuName, this, (cbm) &MenuManager::menuSelected,
                                (cbh) &MenuManager::hintText, info[ idx ].hint );
        item->setTagPtr( (void *) (info + idx) );
    } else {
        item = new WMenuSeparator;
    }

    pop->insertItem( item );

    if( disable ) {
        pop->enableItem( FALSE, idx );
    }
}
Ejemplo n.º 13
0
void WsMenu::loadPopupMenu(NodePtr pNodeParent, Wt::WPopupMenu* menuParent)
{
  std::vector<NodePtr> dirNode = pNodeParent->getAll();
  for (std::vector<NodePtr>::iterator it = dirNode.begin(); it != dirNode.end(); ++it) {
    NodePtr curNode = *it;
    if (!curNode.get()->getDisplayInMenu())
      continue;
    bool popupAllowed = (curNode.get()->getProperties().get()->get("global", "allow_popup", "true") == "true" ? true : false);
    if ( curNode.get()->isDirectory() && popupAllowed ) {
      WPopupMenu* pSubPopupMenu = new WPopupMenu();
      loadPopupMenu(curNode, pSubPopupMenu);
      WMenuItem*   pMenuItem = menuParent->addMenu(curNode.get()->getDisplayName(true), pSubPopupMenu);
      if ( asString(option("directorySelectable")) == "true" )
        pMenuItem->setLink(WLink(WLink::InternalPath, curNode.get()->getPath().string()));;
    } else {
      WPopupMenuItem* pPopupItem = menuParent->addItem(curNode.get()->getDisplayName(true));
      pPopupItem->setLink(makeLink(curNode.get()->getPath().string(), true));
      if ( pPopupItem->link().type() == WLink::Url )
        pPopupItem->setLinkTarget(TargetNewWindow);
    }
  }
}
Ejemplo n.º 14
0
void WMenu::select(int index, bool changePath)
{
  int last = current_;
  setCurrent(index);

  selectVisual(current_, changePath, true);

  if (index != -1) {
    WMenuItem *item = itemAt(index);
    item->show();
    item->loadContents();

    if (changePath && emitPathChange_) {
      WApplication *app = wApp;
      app->internalPathChanged().emit(app->internalPath());
      emitPathChange_ = false;
    }

    if (last != index) {
      item->triggered().emit(item);
      itemSelected_.emit(item);
    }
  }
}
Ejemplo n.º 15
0
void WPopupMenu::adjustPadding()
{
  bool needPadding = false;

  for (int i = 0; i < count(); ++i) {
    WMenuItem *item = itemAt(i);
    if (!item->icon().empty() || item->isCheckable()) {
      needPadding = true;
      break;
    }
  }

  for (int i = 0; i < count(); ++i) {
    WMenuItem *item = itemAt(i);
    item->setItemPadding(needPadding);
    WPopupMenu *subMenu = dynamic_cast<WPopupMenu *>(item->menu());

    if (subMenu)
      subMenu->adjustPadding();
  }
}
Ejemplo n.º 16
0
void WBootstrapTheme::apply(WWidget *widget, DomElement& element,
			    int elementRole) const
{
  {
    WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
    if (popup) {
      WDialog *dialog = dynamic_cast<WDialog *>(widget);
      if (!dialog)
	element.addPropertyWord(PropertyClass, "dropdown-menu");
    }
  }

  switch (element.type()) {

  case DomElement_A:
    if (dynamic_cast<WPushButton *>(widget))
      element.addPropertyWord(PropertyClass, "btn");
    break;

  case DomElement_BUTTON: {
    element.addPropertyWord(PropertyClass, "btn");

    WPushButton *button = dynamic_cast<WPushButton *>(widget);
    if (button) {
      if (button->isDefault())
	element.addPropertyWord(PropertyClass, "btn-primary");

      if (button->menu()) {
	element.addPropertyWord(PropertyInnerHTML,
				"<span class=\"caret\"></span>");
      }
    }

    break;
  }

  case DomElement_DIV:
    {
      WDialog *dialog = dynamic_cast<WDialog *>(widget);
      if (dialog) {
	element.addPropertyWord(PropertyClass, "modal");
	return;
      }

      WPanel *panel = dynamic_cast<WPanel *>(widget);
      if (panel) {
	element.addPropertyWord(PropertyClass, "accordion-group");
	return;
      }

      WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
      if (bar) {
	switch (elementRole) {
	case MainElementThemeRole:
	  element.addPropertyWord(PropertyClass, "progress");
	  break;
	case ProgressBarBarRole:
	  element.addPropertyWord(PropertyClass, "bar");
	  break;
	case ProgressBarLabelRole:
	  element.addPropertyWord(PropertyClass, "bar-label");
	}

	return;
      }

      WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget);
      if (map) {
	element.addPropertyWord(PropertyClass, "Wt-googlemap");
	return;
      }

      WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget);
      if (itemView) {
	element.addPropertyWord(PropertyClass, "form-horizontal");
	return;
      }
    }
    break;

  case DomElement_LABEL:
    {
      WCheckBox *cb = dynamic_cast<WCheckBox *>(widget);
      if (cb) {
	element.addPropertyWord(PropertyClass, "checkbox");
	if (cb->isInline())
	  element.addPropertyWord(PropertyClass, "inline");
      } else {
	WRadioButton *rb = dynamic_cast<WRadioButton *>(widget);
	if (rb) {
	  element.addPropertyWord(PropertyClass, "radio");
	  if (rb->isInline())
	    element.addPropertyWord(PropertyClass, "inline");
	}
      }
    }
    break;

  case DomElement_LI:
    {
      WMenuItem *item = dynamic_cast<WMenuItem *>(widget);
      if (item) {
	if (item->isSeparator())
	  element.addPropertyWord(PropertyClass, "divider");
	if (item->isSectionHeader())
	  element.addPropertyWord(PropertyClass, "nav-header");
      }
    }
    break;

  case DomElement_INPUT:
    {
      WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
      if (spinBox) {
	element.addPropertyWord(PropertyClass, "Wt-spinbox");
	return;
      }

      WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget);
      if (dateEdit) {
	element.addPropertyWord(PropertyClass, "Wt-dateedit");
	return;
      }
    }
    break;

  case DomElement_UL:
    {
      WPopupMenu *popupMenu
	= dynamic_cast<WPopupMenu *>(widget);
      if (popupMenu)
	element.addPropertyWord(PropertyClass, "dropdown-menu");
      else {
	WMenu *menu = dynamic_cast<WMenu *>(widget);
	if (menu) {
	  element.addPropertyWord(PropertyClass, "nav");

	  WTabWidget *tabs
	    = dynamic_cast<WTabWidget *>(menu->parent()->parent());

	  if (tabs)
	    element.addPropertyWord(PropertyClass, "nav-tabs");
	} else {
	  WSuggestionPopup *suggestions
	    = dynamic_cast<WSuggestionPopup *>(widget);

	  if (suggestions)
	    element.addPropertyWord(PropertyClass, "typeahead");
	}
      }
    }

  case DomElement_SPAN:
    {
      WInPlaceEdit *inPlaceEdit
	= dynamic_cast<WInPlaceEdit *>(widget);
      if (inPlaceEdit)
	element.addPropertyWord(PropertyClass, "Wt-in-place-edit");
    }
    break;
  default:
    break;
  }
}
Ejemplo n.º 17
0
void WBootstrapTheme::apply(WWidget *widget, DomElement& element,
			    int elementRole) const
{
  bool creating = element.mode() == DomElement::Mode::Create;

  if (!widget->isThemeStyleEnabled())
    return;

  {
    WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
    if (popup) {
      WDialog *dialog = dynamic_cast<WDialog *>(widget);
      if (!dialog)
	element.addPropertyWord(Property::Class, "dropdown-menu");
    }
  }

  switch (element.type()) {

  case DomElementType::A: {
    if (creating && dynamic_cast<WPushButton *>(widget))
      element.addPropertyWord(Property::Class, classBtn(widget));

    WPushButton *btn = dynamic_cast<WPushButton *>(widget);
    if (creating && btn && btn->isDefault())
      element.addPropertyWord(Property::Class, "btn-primary");

    if (element.getProperty(Property::Class).find("dropdown-toggle")
	!= std::string::npos) {
      WMenuItem *item = dynamic_cast<WMenuItem *>(widget->parent());
      if (!dynamic_cast<WPopupMenu *>(item->parentMenu())) {
	DomElement *b = DomElement::createNew(DomElementType::B);
	b->setProperty(Property::Class, "caret");
	element.addChild(b);
      }
    }
    break;
  }

  case DomElementType::BUTTON: {
    if (creating && !widget->hasStyleClass("list-group-item"))
      element.addPropertyWord(Property::Class, classBtn(widget));

    WPushButton *button = dynamic_cast<WPushButton *>(widget);
    if (button) {
      if (creating && button->isDefault())
	element.addPropertyWord(Property::Class, "btn-primary");

      if (button->menu() && 
	  element.properties().find(Property::InnerHTML) != 
	  element.properties().end()) {
	element.addPropertyWord(Property::InnerHTML,
				"<span class=\"caret\"></span>");
      }

      if (creating && !button->text().empty())
	element.addPropertyWord(Property::Class, "with-label");

      if (!button->link().isNull())
	LOG_ERROR("Cannot use WPushButton::setLink() after the button has "
		  "been rendered with WBootstrapTheme");
    }

    break;
  }

  case DomElementType::DIV:
    {
      WDialog *dialog = dynamic_cast<WDialog *>(widget);
      if (dialog) {
        if (version_ == BootstrapVersion::v2)
          element.addPropertyWord(Property::Class, "modal");
        else
          element.addPropertyWord(Property::Class, "modal-dialog Wt-dialog");
	return;
      }

      WPanel *panel = dynamic_cast<WPanel *>(widget);
      if (panel) {
        element.addPropertyWord(Property::Class, classAccordionGroup());
	return;
      }

      WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
      if (bar) {
	switch (elementRole) {
	case MainElement:
	  element.addPropertyWord(Property::Class, "progress");
	  break;
	case ProgressBarBar:
          element.addPropertyWord(Property::Class, classBar());
	  break;
	case ProgressBarLabel:
	  element.addPropertyWord(Property::Class, "bar-label");
	}

	return;
      }

      WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget);
      if (map) {
	element.addPropertyWord(Property::Class, "Wt-googlemap");
	return;
      }

      WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget);
      if (itemView) {
	element.addPropertyWord(Property::Class, "form-inline");
	return;
      }

      WNavigationBar *navBar = dynamic_cast<WNavigationBar *>(widget);
      if (navBar) {
	element.addPropertyWord(Property::Class, classNavbar());
	return;
      }
    }
    break;

  case DomElementType::LABEL:
    {
      if (elementRole == 1) {
	if (version_ == BootstrapVersion::v3) {
	  WCheckBox *cb = dynamic_cast<WCheckBox *>(widget);
	  WRadioButton *rb = nullptr;
 
	  if (cb) {
	    element.addPropertyWord(Property::Class, widget->isInline() ? 
				    "checkbox-inline" : "checkbox");
	  } else {
	    rb = dynamic_cast<WRadioButton *>(widget);
	    if (rb)
	      element.addPropertyWord(Property::Class, widget->isInline() ?
				      "radio-inline" : "radio");
	  }

	  if ((cb || rb) && !widget->isInline())
	    element.setType(DomElementType::DIV);
	} else {
	  WCheckBox *cb = dynamic_cast<WCheckBox *>(widget);
	  WRadioButton *rb = nullptr;
 
	  if (cb) {
	    element.addPropertyWord(Property::Class, "checkbox");
	  } else {
	    rb = dynamic_cast<WRadioButton *>(widget);
	    if (rb)
	      element.addPropertyWord(Property::Class, "radio");
	  }

	  if ((cb || rb) && widget->isInline())
	    element.addPropertyWord(Property::Class, "inline");
	}
      }
    }
    break;

  case DomElementType::LI:
    {
      WMenuItem *item = dynamic_cast<WMenuItem *>(widget);
      if (item) {
	if (item->isSeparator())
	  element.addPropertyWord(Property::Class, "divider");
	if (item->isSectionHeader())
	  element.addPropertyWord(Property::Class, "nav-header");
	if (item->menu()) {
	  if (dynamic_cast<WPopupMenu *>(item->parentMenu()))
	    element.addPropertyWord(Property::Class, "dropdown-submenu");
	  else
	    element.addPropertyWord(Property::Class, "dropdown");
	}
      }
    }
    break;

  case DomElementType::INPUT:
    {
      if (version_ == BootstrapVersion::v3 && formControlStyle_) {
	WAbstractToggleButton *tb
	  = dynamic_cast<WAbstractToggleButton *>(widget);
	if (!tb)
	  element.addPropertyWord(Property::Class, "form-control");
      }

      WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
      if (spinBox) {
        element.addPropertyWord(Property::Class, "Wt-spinbox");
        return;
      }

      WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget);
      if (dateEdit) {
        element.addPropertyWord(Property::Class, "Wt-dateedit");
        return;
      }

      WTimeEdit *timeEdit = dynamic_cast<WTimeEdit *>(widget);
      if (timeEdit) {
        element.addPropertyWord(Property::Class, "Wt-timeedit");
        return;
      }

    }
    break;
  case DomElementType::TEXTAREA:
  case DomElementType::SELECT:
    if (version_ == BootstrapVersion::v3 && formControlStyle_)
      element.addPropertyWord(Property::Class, "form-control");

    break;
  case DomElementType::UL:
    {
      WPopupMenu *popupMenu
	= dynamic_cast<WPopupMenu *>(widget);
      if (popupMenu) {
        element.addPropertyWord(Property::Class, "dropdown-menu");

	if (popupMenu->parentItem() &&
	    dynamic_cast<WPopupMenu *>(popupMenu->parentItem()->parentMenu()))
	  element.addPropertyWord(Property::Class, "submenu");
      } else {
        WMenu *menu = dynamic_cast<WMenu *>(widget);
        if (menu) {
          element.addPropertyWord(Property::Class, "nav");

          WTabWidget *tabs
              = dynamic_cast<WTabWidget *>(menu->parent()->parent());

          if (tabs)
            element.addPropertyWord(Property::Class, "nav-tabs");
	} else {
	  WSuggestionPopup *suggestions
	    = dynamic_cast<WSuggestionPopup *>(widget);

	  if (suggestions)
	    element.addPropertyWord(Property::Class, "typeahead");
	}
      }
    }

  case DomElementType::SPAN:
    {
      WInPlaceEdit *inPlaceEdit
	= dynamic_cast<WInPlaceEdit *>(widget);
      if (inPlaceEdit)
        element.addPropertyWord(Property::Class, "Wt-in-place-edit");
      else {
	WDatePicker *picker
	  = dynamic_cast<WDatePicker *>(widget);
	if (picker)
	  element.addPropertyWord(Property::Class, "Wt-datepicker");
      }
    }
    break;
  default:
    break;
  }
}
Ejemplo n.º 18
0
void WTabWidget::setTabText(int index, const WString& label)
{
  WMenuItem *item = menu_->itemAt(index);
  item->setText(label);
}
Ejemplo n.º 19
0
const WString& WTabWidget::tabText(int index) const
{
  WMenuItem *item = menu_->itemAt(index);
  return item->text();
}
Ejemplo n.º 20
0
void WsMenu::createMenu(NodePtr curNode, WMenu* menuParent)
{
  std::string path2Icon;
  WsUser*     pUser   = WsApp->wsUser();
  std::string sIcon   = curNode.get()->getProperties().get()->get("global", "icon", "");
  if ( sIcon.size() > 1 ) {
    NodePtr tmpNode = curNode;
    if ( tmpNode.get()->isRegularFile() )
      tmpNode   = curNode.get()->getParent();
    if ( tmpNode.get() ) {
      path2Icon = tmpNode.get()->getFullPath().string() + "/ws.res/icones/" + sIcon;
      if ( !boost::filesystem::exists(path2Icon) )
        path2Icon.clear();
      else {
        boost::algorithm::replace_first(path2Icon, WsApp->docRoot(), "");
      }
    }
  }
  if ( asString(option("useButtons")) == "true" ) {
    if ( curNode.get()->getPath().string() != "/" )
      if ( asString(option("useSeparator")) == "true" ) {
        WText* pText = new WText("|", this);
        pText->addStyleClass("WsMenuSep");
      }
    WPushButton* button = new WPushButton(curNode.get()->getDisplayName(true), this);
    m_vPushButton.push_back(button);
    if ( path2Icon.size() > 1 ) {
      button->setIcon(WLink(WLink::Url, path2Icon));
      if ( curNode.get()->getProperties().get()->get("global", "button_text", "true") == "false" )
        button->setText("");
    }
    // TODO : Ameliorer cette fonction
    if ( (curNode.get()->isDirectory() && asString(option("directorySelectable")) == "true") ||
         pUser->isAdministrator() || pUser->isEditor() ||
         (asString(option("showRoot")) == "true" && curNode.get()->getPath() == "/")
       ) {
      button->setLink(WLink(WLink::InternalPath, curNode.get()->getPath().string()));
    }
    if ( curNode.get()->isRegularFile() ) {
      button->setLink(makeLink(curNode.get()->getPath().string(), false));
      if ( button->link().type() == WLink::Url )
        button->setLinkTarget(TargetNewWindow);
    }
    bool popupAllowed = (curNode.get()->getProperties().get()->get("global", "allow_popup", "true") == "true" ? true : false);
    if ( curNode.get()->isDirectory() && popupAllowed && asString(option("usePopupMenu")) == "true" ) {
      if ( !(asString(option("noRootPopup")) == "true" && curNode.get()->getPath() == "/") ) {
        WPopupMenu* pPopup = new WPopupMenu();
        pPopup->addStyleClass("wt-no-reparent");
        loadPopupMenu(curNode, pPopup);
        button->setMenu(pPopup);
        pPopup->setAutoHide(true);
        button->mouseWentOver().connect(boost::bind(&WsMenu::onMouseWentOver, this, button));
        button->setMouseOverDelay(50);
      }
    }
  } else { // No buttons, standard menu
    if ( curNode.get()->getPath().string() != "/" )
      menuParent->addSeparator();
    WMenuItem* pItem = menuParent->addItem(curNode.get()->getDisplayName(true));
    pItem->setLink(WLink(WLink::InternalPath, curNode.get()->getPath().string()));
    if ( path2Icon.size() > 1 )
      pItem->setIcon(path2Icon);
    if ( curNode.get()->isDirectory() && asString(option("usePopupMenu")) == "true" )
      if ( curNode.get()->getDirectories().size() ) {
        WPopupMenu* pPopup = new WPopupMenu();
        pPopup->addStyleClass("wt-no-reparent");
        loadPopupMenu(curNode, pPopup);
        pItem->setMenu(pPopup);
      }
  }
}
Ejemplo n.º 21
0
void WTabWidget::setTabToolTip(int index, const WString& tip)
{
  WMenuItem *item = menu_->itemAt(index);
  item->setToolTip(tip);
}
Ejemplo n.º 22
0
WString WTabWidget::tabToolTip(int index) const
{
  WMenuItem *item = menu_->itemAt(index);
  return item->toolTip();
}
Ejemplo n.º 23
0
void WCssTheme::apply(WWidget *widget, DomElement& element, int elementRole)
  const
{
  {
    WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
    if (popup)
      element.addPropertyWord(PropertyClass, "Wt-outset");
  }

  switch (element.type()) {
  case DomElement_BUTTON:
    element.addPropertyWord(PropertyClass, "Wt-btn");
    break;

  case DomElement_UL:
    if (dynamic_cast<WPopupMenu *>(widget))
      element.addPropertyWord(PropertyClass, "Wt-popupmenu Wt-outset");
    else {
      WTabWidget *tabs
	= dynamic_cast<WTabWidget *>(widget->parent()->parent());

      if (tabs)
	element.addPropertyWord(PropertyClass, "Wt-tabs");
      else {
	WSuggestionPopup *suggestions
	  = dynamic_cast<WSuggestionPopup *>(widget);

	if (suggestions)
	  element.addPropertyWord(PropertyClass, "Wt-suggest");
      }
    }
    break;

  case DomElement_LI:
    {
      WMenuItem *item = dynamic_cast<WMenuItem *>(widget);
      if (item) {
	if (item->isSeparator())
	  element.addPropertyWord(PropertyClass, "Wt-separator");
   	if (item->isSectionHeader())
	  element.addPropertyWord(PropertyClass, "Wt-sectheader");
	if (item->menu())
	  element.addPropertyWord(PropertyClass, "submenu");
      }
    }
    break;

  case DomElement_DIV:
    {
      WDialog *dialog = dynamic_cast<WDialog *>(widget);
      if (dialog) {
	element.addPropertyWord(PropertyClass, "Wt-dialog");
	return;
      }

      WPanel *panel = dynamic_cast<WPanel *>(widget);
      if (panel) {
	element.addPropertyWord(PropertyClass, "Wt-panel Wt-outset");
	return;
      }

      WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
      if (bar) {
	switch (elementRole) {
	case MainElementThemeRole:
	  element.addPropertyWord(PropertyClass, "Wt-progressbar");
	  break;
	case ProgressBarBarRole:
	  element.addPropertyWord(PropertyClass, "Wt-pgb-bar");
	  break;
	case ProgressBarLabelRole:
	  element.addPropertyWord(PropertyClass, "Wt-pgb-label");
	}
	return;
      }
    }

    break;

  case DomElement_INPUT:
    {
      WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
      if (spinBox) {
	element.addPropertyWord(PropertyClass, "Wt-spinbox");
	return;
      }

      WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget);
      if (dateEdit) {
	element.addPropertyWord(PropertyClass, "Wt-dateedit");
	return;
      }
    }
    break;
  default:
    break;
  }
}