void WInteractWidget::setDraggable(const std::string& mimeType, WWidget *dragWidget, bool isDragWidgetOnly, WObject *sourceObject) { if (dragWidget == 0) dragWidget = this; if (sourceObject == 0) sourceObject = this; if (isDragWidgetOnly) { dragWidget->hide(); } WApplication *app = WApplication::instance(); setAttributeValue("dmt", mimeType); setAttributeValue("dwid", dragWidget->id()); setAttributeValue("dsid", app->encodeObject(sourceObject)); if (!dragSlot_) { dragSlot_ = new JSlot(); dragSlot_->setJavaScript("function(o,e){" + app->javaScriptClass() + "._p_.dragStart(o,e);" + "}"); } mouseWentDown().connect(*dragSlot_); }
void WInteractWidget::unsetDraggable() { if (dragSlot_) { mouseWentDown().disconnect(*dragSlot_); delete dragSlot_; dragSlot_ = 0; } }
PaintBrush::PaintBrush(int width, int height, WContainerWidget *parent) : WPaintedWidget(parent) { setSelectable(false); interactionCount_ = 0; undo_ = false; // setPositionScheme(Absolute); resize(WLength(width), WLength(height)); decorationStyle().setCursor("icons/pencil.cur", CrossCursor); mouseWentDown().connect(this, &PaintBrush::mouseDown); color_ = WColor(black); // setPreferredMethod(InlineSvgVml); }
PaintBrush::PaintBrush(int width, int height, WContainerWidget *parent) : WPaintedWidget(parent) { setSelectable(false); resize(WLength(width), WLength(height)); decorationStyle().setCursor("icons/pencil.cur", CrossCursor); mouseDragged().connect(this, &PaintBrush::mouseDrag); mouseWentDown().connect(this, &PaintBrush::mouseDown); touchStarted().connect(this, &PaintBrush::touchStart); touchMoved().connect(this, &PaintBrush::touchMove); touchMoved().preventDefaultAction(); color_ = WColor(black); // setPreferredMethod(InlineSvgVml); }
void WDateEdit::defineJavaScript() { WApplication *app = WApplication::instance(); LOAD_JAVASCRIPT(app, "js/WDateEdit.js", "WDateEdit", wtjs1); std::string jsObj = "new " WT_CLASS ".WDateEdit(" + app->javaScriptClass() + "," + jsRef() + "," + popup_->jsRef() + ");"; setJavaScriptMember(" WDateEdit", jsObj); #ifdef WT_CNOR EventSignalBase& b = mouseMoved(); EventSignalBase& c = keyWentDown(); #endif connectJavaScript(mouseMoved(), "mouseMove"); connectJavaScript(mouseWentUp(), "mouseUp"); connectJavaScript(mouseWentDown(), "mouseDown"); connectJavaScript(mouseWentOut(), "mouseOut"); }
void WAbstractSpinBox::setup() { setup_ = true; bool useNative = nativeControl(); if (!useNative) { defineJavaScript(); #ifdef WT_CNOR EventSignalBase& b = mouseMoved(); EventSignalBase& c = keyWentDown(); #endif connectJavaScript(mouseMoved(), "mouseMove"); connectJavaScript(mouseWentUp(), "mouseUp"); connectJavaScript(mouseWentDown(), "mouseDown"); connectJavaScript(mouseWentOut(), "mouseOut"); connectJavaScript(keyWentDown(), "keyDown"); connectJavaScript(keyWentUp(), "keyUp"); if (!prefix_.empty() || !suffix_.empty()) setValidator(new SpinBoxValidator(this)); } }
void WAbstractSpinBox::setup(bool useNative) { if (useNative) { setValidator(createValidator()); } else { defineJavaScript(); addStyleClass("Wt-spinbox"); #ifdef WT_CNOR EventSignalBase& b = mouseMoved(); EventSignalBase& c = keyWentDown(); #endif connectJavaScript(mouseMoved(), "mouseMove"); connectJavaScript(mouseWentUp(), "mouseUp"); connectJavaScript(mouseWentDown(), "mouseDown"); connectJavaScript(mouseWentOut(), "mouseOut"); connectJavaScript(keyWentDown(), "keyDown"); connectJavaScript(keyWentUp(), "keyUp"); setValidator(new SpinBoxValidator(this)); } }