void HTMLTextAreaElement::subtreeHasChanged() { setChangedSinceLastFormControlChangeEvent(true); m_valueIsUpToDate = false; setNeedsValidityCheck(); setAutofilled(false); updatePlaceholderVisibility(); if (!focused()) return; // When typing in a textarea, childrenChanged is not called, so we need to force the directionality check. calculateAndAdjustDirectionality(); ASSERT(document().isActive()); document().frameHost()->chromeClient().didChangeValueInTextField(*this); }
void HTMLAreaElement::setFocus(bool shouldBeFocused) { if (focused() == shouldBeFocused) return; HTMLAnchorElement::setFocus(shouldBeFocused); HTMLImageElement* imageElement = this->imageElement(); if (!imageElement) return; LayoutObject* layoutObject = imageElement->layoutObject(); if (!layoutObject || !layoutObject->isImage()) return; toLayoutImage(layoutObject)->areaElementFocusChanged(this); }
dtkComposerViewLayoutItemProxy::~dtkComposerViewLayoutItemProxy(void) { // qDebug() << __func__ << 1; if(!d->view) goto finalize; if(!d->view->widget()) goto finalize; if(!d->view->widget()->parentWidget()) goto finalize; // qDebug() << __func__ << 2; if(dtkComposerViewLayoutItemProxy *proxy = dynamic_cast<dtkComposerViewLayoutItemProxy *>(d->view->widget()->parentWidget())) { // qDebug() << __func__ << 3; if(proxy == this) { // qDebug() << __func__ << 4; layout()->removeWidget(d->view); // qDebug() << __func__ << 5; d->view->widget()->setParent(0); // qDebug() << __func__ << 6; disconnect(d->view, SIGNAL(focused()), proxy, SIGNAL(focusedIn())); d->view = NULL; } } // qDebug() << __func__ << 7; finalize: delete d; d = NULL; }
void SVGAElement::defaultEventHandler(Event* event) { if (isLink()) { ASSERT(event->target()); Node* target = event->target()->toNode(); ASSERT(target); if ((focused() || target->focused()) && isEnterKeyKeypressEvent(event)) { event->setDefaultHandled(); dispatchSimulatedClick(event); return; } if (isLinkClick(event)) { String url = stripLeadingAndTrailingHTMLSpaces(hrefString()); if (url[0] == '#') { Element* targetElement = treeScope().getElementById(AtomicString(url.substring(1))); if (targetElement && isSVGSMILElement(*targetElement)) { toSVGSMILElement(targetElement)->beginByLinkActivation(); event->setDefaultHandled(); return; } } AtomicString target(m_svgTarget->currentValue()->value()); if (target.isEmpty() && fastGetAttribute(XLinkNames::showAttr) == "new") target = AtomicString("_blank", AtomicString::ConstructFromLiteral); event->setDefaultHandled(); LocalFrame* frame = document().frame(); if (!frame) return; FrameLoadRequest frameRequest(&document(), ResourceRequest(document().completeURL(url)), target); frameRequest.setTriggeringEvent(event); frame->loader().load(frameRequest); return; } } SVGGraphicsElement::defaultEventHandler(event); }
void SVGAElement::defaultEventHandler(Event& event) { if (isLink()) { if (focused() && isEnterKeyKeydownEvent(event)) { event.setDefaultHandled(); dispatchSimulatedClick(&event); return; } if (MouseEvent::canTriggerActivationBehavior(event)) { String url = stripLeadingAndTrailingHTMLSpaces(href()); if (url[0] == '#') { Element* targetElement = treeScope().getElementById(url.substringSharingImpl(1)); if (is<SVGSMILElement>(targetElement)) { downcast<SVGSMILElement>(*targetElement).beginByLinkActivation(); event.setDefaultHandled(); return; } // Only allow navigation to internal <view> anchors. if (targetElement && !targetElement->hasTagName(SVGNames::viewTag)) return; } String target = this->target(); if (target.isEmpty() && attributeWithoutSynchronization(XLinkNames::showAttr) == "new") target = "_blank"; event.setDefaultHandled(); Frame* frame = document().frame(); if (!frame) return; if (document().pageCacheState() != Document::NotInPageCache) return; frame->loader().urlSelected(document().completeURL(url), target, &event, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate()); return; } } SVGGraphicsElement::defaultEventHandler(event); }
DownloadPathBox::DownloadPathBox() : _path(cDownloadPath()), _defaultRadio(this, qsl("dir_type"), 0, lang(lng_download_path_default_radio), _path.isEmpty()), _tempRadio(this, qsl("dir_type"), 1, lang(lng_download_path_temp_radio), _path == qsl("tmp")), _dirRadio(this, qsl("dir_type"), 2, lang(lng_download_path_dir_radio), !_path.isEmpty() && _path != qsl("tmp")), _dirInput(this, st::inpDownloadDir, QString(), (_path.isEmpty() || _path == qsl("tmp")) ? QString() : QDir::toNativeSeparators(_path)), _saveButton(this, lang(lng_connection_save), st::btnSelectDone), _cancelButton(this, lang(lng_cancel), st::btnSelectCancel) { connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave())); connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose())); connect(&_defaultRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(&_tempRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(&_dirRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(&_dirInput, SIGNAL(focused()), this, SLOT(onEditPath())); _dirInput.setCursorPosition(0); prepare(); }
void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) const { ASSERT(event); ASSERT(renderer()); int signedMaxLength = maxLength(); if (signedMaxLength < 0) return; unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength); unsigned currentLength = computeLengthForSubmission(innerTextValue()); // selectionLength represents the selection length of this text field to be // removed by this insertion. // If the text field has no focus, we don't need to take account of the // selection length. The selection is the source of text drag-and-drop in // that case, and nothing in the text field will be removed. unsigned selectionLength = focused() ? computeLengthForSubmission(plainText(document()->frame()->selection()->selection().toNormalizedRange().get())) : 0; ASSERT(currentLength >= selectionLength); unsigned baseLength = currentLength - selectionLength; unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLength - baseLength : 0; event->setText(sanitizeUserInputValue(event->text(), appendableLength)); }
//----------------------------------------------------------------------- // r e n d e r //----------------------------------------------------------------------- void TGButton::render() { if(isRenderCached()) return; int x1, y1, x2, y2; TGFrameStyle fs = FS_FLAT; getBounds(x1, y1, x2, y2); if (getMouseOverControl()) fs = m_pushed?FS_LOWERED:FS_RAISED; else fs = FS_FLAT; drawFrame(x1, y1, x2, y2, fs); if (focused()) { drawOwnFocus(); } TGSBrush brush; if (m_pushed) brush = m_theme.getTextInvertedBrush(); else { if(getMouseOverControl()) brush = m_theme.getTextFocusedBrush(); else brush = m_theme.getTextBrush(); } x1 = (x2 - x1 + 1)/2 + x1; x1 -= stringWidth(m_caption)/2; x2 = 0; openClip(); drawString(x1 + x2, (y2-y1 + 1)/2 + y1 - stringHeight()/2, m_caption, brush); closeClip(); }
void SVGAElement::defaultEventHandler(Event* event) { if (isLink()) { if (focused() && isEnterKeyKeydownEvent(event)) { event->setDefaultHandled(); dispatchSimulatedClick(event); return; } if (isLinkClick(event)) { String url = stripLeadingAndTrailingHTMLSpaces(href()); if (url[0] == '#') { Element* targetElement = treeScope().getElementById(url.substringSharingImpl(1)); if (targetElement && isSVGSMILElement(*targetElement)) { toSVGSMILElement(*targetElement).beginByLinkActivation(); event->setDefaultHandled(); return; } // Only allow navigation to internal <view> anchors. if (targetElement && !targetElement->hasTagName(SVGNames::viewTag)) return; } String target = this->target(); if (target.isEmpty() && fastGetAttribute(XLinkNames::showAttr) == "new") target = "_blank"; event->setDefaultHandled(); Frame* frame = document().frame(); if (!frame) return; frame->loader().urlSelected(document().completeURL(url), target, event, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer); return; } } SVGGraphicsElement::defaultEventHandler(event); }
bool Console::mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers) { //std::cout << "mouseButtonEvent " << p.x()<<","<<p.y() << " " << button << " " << // down << " " << modifiers << std::endl; if (button == GLFW_MOUSE_BUTTON_1 && down && !mFocused) { requestFocus(); } if (focused()) { if (down) { mMouseDownPos = p; mMouseDownModifier = modifiers; } else { mMouseDownPos = Vector2i(-1, -1); mMouseDragPos = Vector2i(-1, -1); } return true; } return false; }
char *focused_read(int wid) { (void) wid; int focusedid=focused(); char * focusedwin = malloc(focusedid ? WID_STRING_LENGTH + 1 : 6); if ( !focusedwin ) { syslog(LOG_ERR, "failed to allocate in %s: %s\n", __func__, strerror(ENOMEM)); } int stat = 0; if ( !focusedid ) { stat = sprintf(focusedwin, "root\n"); } else { stat = sprintf(focusedwin, "0x%08x\n", focusedid); } if ( stat < 0 ) { syslog(LOG_ERR, "failed to store focused window in %s\n", __func__); } return focusedwin; }
void ImageCollection::layoutImmExpanded() { tl.complete(); GfxCanvasItem *i = nameItem(false); if(i) i->visible().setValue(0.); int f = focused(); for(int ii = 0; ii < count(); ++ii) { Image *img = image(ii); img->imageParent().setValue(0.); img->x().setValue(0); img->y().setValue(0); img->visible().setValue(1.); if(f == ii) img->scale().setValue(ZOOMED_ZOOM); else img->scale().setValue(SMALL_ZOOM); img->rotate().setValue(0.); } }
void GuiMenu::render(RenderDevice* rd) const { if (m_morph.active) { GuiMenu* me = const_cast<GuiMenu*>(this); me->m_morph.update(me); } m_skin->beginRendering(rd); { m_skin->renderWindow(m_rect, focused(), false, false, false, m_text, GuiTheme::WindowStyle(m_style)); m_skin->pushClientRect(m_clientRect); // Draw the hilight (the root pane is invisible, so it will not overwrite) int i = m_highlightIndex; if ((i >= 0) && (i < m_labelArray.size())) { const Rect2D& r = m_labelArray[i]->rect(); m_skin->renderSelection(Rect2D::xywh(0, r.y0(), m_clientRect.width(), r.height())); } m_rootPane->render(rd, m_skin); m_skin->popClientRect(); } m_skin->endRendering(); }
void GuiFunctionBox::render(RenderDevice* rd, const GuiThemeRef& skin) const { GuiFunctionBox* me = const_cast<GuiFunctionBox*>(this); me->m_clipBounds = skin->canvasToClientBounds(m_rect, m_captionSize); int shrink = 4; // Shrink bounds slightly so that we can see axes and points rendered against the edge me->m_bounds = Rect2D::xywh(m_clipBounds.x0y0() + Vector2(shrink, shrink), m_clipBounds.wh() - Vector2(shrink, shrink) * 2); // Use textbox borders skin->renderCanvas(m_rect, m_enabled, focused(), m_caption, m_captionSize); me->m_scale.x = (m_maxTime - m_minTime) / m_bounds.width(); me->m_scale.y = (m_maxValue - m_minValue) / m_bounds.height(); static int count = 0; count = (count + 1) % 10; if (count == 0) { // Make sure that the spline hasn't been corrupted by the // program since we last checked it. Avoid doing this every // frame, however. me->clampTimes(m_selected); me->clampValues(); } skin->pauseRendering(); { // Scissor region ignores transformation matrix const CoordinateFrame& matrix = rd->objectToWorldMatrix(); rd->setClip2D(m_clipBounds + matrix.translation.xy()); drawBackground(rd, skin); drawSpline(rd, skin); drawControlPoints(rd, skin); } skin->resumeRendering(); }
DownloadPathBox::DownloadPathBox() : _hiding(false), _path(cDownloadPath()), _tempRadio(this, qsl("dir_type"), 0, lang(lng_download_path_temp_radio), _path.isEmpty()), _dirRadio(this, qsl("dir_type"), 1, lang(lng_download_path_dir_radio), !_path.isEmpty()), _dirInput(this, st::inpDownloadDir, QString(), QDir::toNativeSeparators(_path)), _saveButton(this, lang(lng_connection_save), st::btnSelectDone), _cancelButton(this, lang(lng_cancel), st::btnSelectCancel), a_opacity(0, 1) { _width = st::addContactWidth; connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave())); connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onCancel())); connect(&_tempRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(&_dirRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(&_dirInput, SIGNAL(focused()), this, SLOT(onEditPath())); _dirInput.setCursorPosition(0); showAll(); _cache = grab(rect()); hideAll(); }
void WebkitBrowser::copy() { if (focused()) { webkit_web_view_copy_clipboard (WEBKIT_WEB_VIEW (webview)); } }
void AbstractDataView::focusInEvent(QFocusEvent * event) { DockableWidget::focusInEvent(event); emit focused(this); }
Controller::Controller() : _deviceNeedResolve(0), _lastTimeFocused(0), _service(&_udpDiscovery, this), _udpDiscoveryTimer(this) { _service.moveToThread(&_serviceThread); _serviceThread.start(); _view = new View(&_model); _bonjourBrowser = new BonjourServiceBrowser(this); connect(&_udpDiscovery, SIGNAL(devicesFound(const QList<Device *> &)), this, SLOT(updateDevices(const QList<Device *> &))); connect(&_udpDiscovery, SIGNAL(pongReceived(const QString&)), this, SLOT(onPong(const QString &))); connect(_bonjourBrowser, SIGNAL(currentBonjourRecordsChanged(const QList<BonjourRecord> &)), this, SLOT(updateRecords(const QList<BonjourRecord> &))); connect(_bonjourBrowser, SIGNAL(error(DNSServiceErrorType)), this, SLOT(error(DNSServiceErrorType))); connect(_view, SIGNAL(sendFile(const QString&, const QList<QUrl>&, DataType)), this, SLOT(onSendFile(const QString&, const QList<QUrl>&, DataType))); connect(_view, SIGNAL(sendText(const QString&, const QString&, DataType)), this, SLOT(onSendText(const QString&, const QString&, DataType))); connect(_view, SIGNAL(cancelTransfert(const QString&)), this, SLOT(onCancelTransfert(const QString&))); connect(_view, SIGNAL(focused()), this, SLOT(onWindowFocused())); connect(_view, SIGNAL(forceRefresh()), this, SLOT(onForceRefresh())); connect(_view, SIGNAL(registerService()), &_service, SLOT(serviceRegister())); connect(_view, SIGNAL(unregisterService()), &_service, SLOT(serviceUnregister())); connect(_view, SIGNAL(deleteFromHistory(int)), &_service, SLOT(onDeleteFromHistory(int))); connect(_view, SIGNAL(clearHistoryTriggered()), &_service, SLOT(onClearHistory())); connect(_view, SIGNAL(serviceNameChanged()), &_service, SLOT(onTimerOut())); connect(_view, SIGNAL(cancelIncomingTransfert()), &_service, SLOT(deleteFileReset())); connect(&_service, SIGNAL(historyChanged(const QList<HistoryElement>&)), _view, SLOT(onHistoryChanged(const QList<HistoryElement>&))); connect(&_service, SIGNAL(historyElementProgressUpdated(unsigned)), _view, SLOT(historyElementProgressUpdated(unsigned))); connect(&_service, SIGNAL(serviceError(ServiceErrorState,bool)), _view, SLOT(onServiceError(ServiceErrorState,bool))); connect(&_service, SIGNAL(receivingFile(const QString&,int)), _view, SLOT(onReceivingFile(const QString&,int))); connect(&_service, SIGNAL(receivingFolder(const QString&,int)), _view, SLOT(onReceivingFolder(const QString&,int))); connect(&_service, SIGNAL(receivingText(const QString&)), _view, SLOT(onReceivingText(const QString&))); connect(&_service, SIGNAL(receivingUrl(const QString&)), _view, SLOT(onReceivingUrl(const QString&))); connect(&_model, SIGNAL(newDeviceCreated(Device*)), this, SLOT(onNewDeviceCreated(Device*))); connect(&_model, SIGNAL(deviceRemoved()), _view, SLOT(updateDevices())); connect(&_updater, SIGNAL(updateNeeded(const QString&,const QString&)), _view, SLOT(onUpdateNeeded(const QString&,const QString&))); checkForBonjourState(); _view->updateDevices(); _view->onHistoryChanged(_service.getHistory()); _bonjourBrowser->browseForServiceType(QLatin1String("_fdnd._tcp.")); connect(&_udpDiscoveryTimer, SIGNAL(timeout()), &_udpDiscovery, SLOT(startDiscovery())); _udpDiscoveryTimer.start(UDP_DISCOVERY_INTERVAL); _udpDiscovery.startDiscovery(); createSendTo(); }
void CListWidget::update(int c) { if(_visible) { uint tw = _size.width(); uint th = _size.height(); if(focused()) { #ifdef __PDCURSES__ // Mouse wheel scrolling if(c == KEY_MOUSE && _count > th) { if(Mouse_status.changes == MOUSE_WHEEL_DOWN) { _scroll += 4; _changed = true; } else if(Mouse_status.changes == MOUSE_WHEEL_UP && _scroll >= 4) { _scroll -= 4; _changed = true; } } #endif } if((_listenKeys || focused()) && _count > th) { if(c == KEY_NPAGE) // PAGE DOWN { _scroll += 4; _changed = true; } else if(c == KEY_PPAGE && _scroll >= 4) // PAGE UP { _scroll -= 4; _changed = true; } } if(_changed) { move_panel(_panel, _pos.y(), _pos.x()); top_panel(_panel); wclear(_window); if((_count < th && _scroll < _count) || (_count > th && _scroll > _count)) _scroll = _count; if(_count > th && _scroll < th) _scroll = th; uint b = 0, n = 0; for(uint i = 0; i < _items.size() && i < _scroll + b; ++i) { if(_items[i]->nocrlf()) b++; if(!_items[i]->nocrlf()) n = 0; const string &message = _items[i]->text(); for(uint j = 0; j < _leftMargin; ++j) waddch(_window, ' '); attr_t a = attribute(_items[i]->backgroundColor(), _items[i]->foregroundColor(), _items[i]->bold()); wattr_on(_window, a, 0); n++; for(uint j = 0; j < message.size(); ++j, n++) { if(n >= tw - _leftMargin - _rightMargin) { n = 0; wattr_off(_window, a, 0); waddch(_window, '\n'); for(uint j = 0; j < _leftMargin; ++j) waddch(_window, ' '); wattr_on(_window, a, 0); } waddch(_window, toULong(message[j])); } wattr_off(_window, a, 0); if(i < _scroll + b - 1 && i != _items.size() - 1 && !_items[i]->nocrlf()) waddch(_window, '\n'); } _changed = false; } } }
// Anybody can call this to force the label to draw anywhere, this is // used by Fl_Group and Fl_Tabs to draw outside labels: void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Flags flags) const { fl_font(label_font(), float(label_size())); if (!active_r()) flags.set(FL_INACTIVE); Fl_Color color; // Figure out if alignment puts the label inside the widget: if (!(this->flags()&15) || (this->flags() & FL_ALIGN_INSIDE)) { // yes, inside label is affected by selection or highlight: if (flags&FL_SELECTED) color = selection_text_color(); else if (flags&FL_HIGHLIGHT && highlight_label_color()) color = highlight_label_color(); else color = label_color(); if (focused()) flags.set(FL_SELECTED); } else { color = label_color(); } if (flags & FL_ALIGN_CLIP) fl_push_clip(X, Y, W, H); if (image_) { fl_color(fl_inactive(color, flags)); if(flags & FL_ALIGN_TILED || flags & FL_ALIGN_SCALE) { image_->draw(X, Y, W, H, flags); } else { int w = W; int h = H; image_->measure(w, h); // If all the flags are off, draw the image and label centered "nicely" // by measuring their total size and centering that rectangle: if (!(flags & (FL_ALIGN_LEFT|FL_ALIGN_RIGHT|FL_ALIGN_TOP|FL_ALIGN_BOTTOM| FL_ALIGN_INSIDE)) && !label_.empty()) { int d = (H-int(h+fl_height()))>>1; if (d >= 0) { // put the image atop the text Y += d; H -= d; flags.set(FL_ALIGN_TOP); } else { // put image to left int text_w = W; int text_h = H; fl_measure(label_.c_str(), text_w, text_h, flags); int d = (W-(h+text_w))>>1; if (d > 0) {X += d; W -= d;} flags.set(FL_ALIGN_LEFT); } } int cx,cy; // point in image to put at X,Y if (flags & FL_ALIGN_RIGHT) { cx = w-W; if (flags & FL_ALIGN_LEFT && cx < 0) cx = 0; } else if (flags & FL_ALIGN_LEFT) cx = 0; else cx = w/2-W/2; if (flags & FL_ALIGN_BOTTOM) { cy = h-H; if (flags & FL_ALIGN_TOP && cy < 0) cy = 0; } else if (flags & FL_ALIGN_TOP) cy = 0; else cy = h/2-H/2; image_->draw(X-cx, Y-cy, W, H, 0,0,0,0,flags); // figure out the rectangle that remains for text: if (flags & FL_ALIGN_LEFT) { X += (w+2); W -= (w+4); } else if (flags & FL_ALIGN_RIGHT) W -= (w+4); else if (flags & FL_ALIGN_TOP) {Y += h; H -= h;} else if (flags & FL_ALIGN_BOTTOM) H -= h; else { /*flags |= FL_ALIGN_TOP;*/ Y += (h-cy); H -= (h-cy); } } }
void WMLAnchorElement::defaultEventHandler(Event* event) { bool shouldHandle = false; if (event->type() == eventNames().clickEvent) shouldHandle = true; else if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && focused()) shouldHandle = static_cast<KeyboardEvent*>(event)->keyIdentifier() == "Enter"; if (shouldHandle && m_task) { m_task->executeTask(); event->setDefaultHandled(); return; } // Skip WMLAElement::defaultEventHandler, we don't own a href attribute, that needs to be handled. WMLElement::defaultEventHandler(event); }
void GuiTextBox::render(RenderDevice* rd, const shared_ptr<GuiTheme>& theme, bool ancestorsEnabled) const { (void)rd; (void)theme; GuiTextBox* me = const_cast<GuiTextBox*>(this); if (m_visible) { if (m_editing) { if (! focused()) { // Just lost focus if ((m_update == DELAYED_UPDATE) && (m_oldValue != m_userValue)) { me->m_oldValue = m_userValue; me->commit(); GEvent response; response.gui.type = GEventType::GUI_CHANGE; response.gui.control = me->m_eventSource; m_gui->fireEvent(response); } me->m_editing = false; } else if (String(*m_value) != m_oldValue) { // The value has been changed by the program while we // were editing; override our copy with the // programmatic value. me->m_userValue = *m_value; me->m_cursorPos = min(m_cursorPos, (int)m_userValue.size()); } } else if (focused()) { // Just gained focus me->m_userValue = *m_value; me->m_oldValue = m_userValue; me->m_editing = true; } static RealTime then = System::time(); RealTime now = System::time(); bool hasKeyDown = (m_repeatKeysym.sym != GKey::UNKNOWN); // Amount of time that the last simulation step took. // This is used to limit the key repeat rate // so that it is not faster than the frame rate. RealTime frameTime = then - now; // If a key is being pressed, process it on a steady repeat schedule. if (hasKeyDown && (now > m_keyRepeatTime)) { me->processRepeatKeysym(); me->m_keyRepeatTime = max(now + frameTime * 1.1, now + 1.0 / keyRepeatRate); } then = now; // Only blink the cursor when keys are not being pressed or // have not recently been pressed. bool solidCursor = hasKeyDown || (now - m_keyRepeatTime < 1.0 / blinkRate); if (! solidCursor) { static const RealTime zero = System::time(); solidCursor = isOdd((int)((now - zero) * blinkRate)); } // Note that textbox does not have a mouseover state theme->renderTextBox (m_rect, m_enabled && ancestorsEnabled, focused(), m_caption, m_captionWidth, m_editing ? m_userValue : *m_value, solidCursor ? m_cursor : GuiText(), m_cursorPos, m_style); } }
void SVGAElement::defaultEventHandler(Event* evt) { if (isLink() && (evt->type() == eventNames().clickEvent || (evt->type() == eventNames().keydownEvent && focused()))) { MouseEvent* e = 0; if (evt->type() == eventNames().clickEvent && evt->isMouseEvent()) e = static_cast<MouseEvent*>(evt); KeyboardEvent* k = 0; if (evt->type() == eventNames().keydownEvent && evt->isKeyboardEvent()) k = static_cast<KeyboardEvent*>(evt); if (e && e->button() == RightButton) { SVGStyledTransformableElement::defaultEventHandler(evt); return; } if (k) { if (k->keyIdentifier() != "Enter") { SVGStyledTransformableElement::defaultEventHandler(evt); return; } evt->setDefaultHandled(); dispatchSimulatedClick(evt); return; } String target = this->target(); if (e && e->button() == MiddleButton) target = "_blank"; else if (target.isEmpty()) // if target is empty, default to "_self" or use xlink:target if set target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self"; if (!evt->defaultPrevented()) { String url = deprecatedParseURL(href()); #if ENABLE(SVG_ANIMATION) if (url.startsWith("#")) { Element* targetElement = document()->getElementById(url.substring(1)); if (SVGSMILElement::isSMILElement(targetElement)) { SVGSMILElement* timed = static_cast<SVGSMILElement*>(targetElement); timed->beginByLinkActivation(); evt->setDefaultHandled(); SVGStyledTransformableElement::defaultEventHandler(evt); return; } } #endif if (document()->frame()) document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, false, true, SendReferrer); } evt->setDefaultHandled(); } SVGStyledTransformableElement::defaultEventHandler(evt); }
void ListBaseTestCase::ItemClick() { #if wxUSE_UIACTIONSIMULATOR #ifdef __WXMSW__ // FIXME: This test fails on MSW buildbot slaves although works fine on // development machine, no idea why. It seems to be a problem with // wxUIActionSimulator rather the wxListCtrl control itself however. if ( IsAutomaticTest() ) return; #endif // __WXMSW__ wxListCtrl* const list = GetList(); list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); list->InsertItem(0, "Item 0"); list->SetItem(0, 1, "first column"); list->SetItem(0, 2, "second column"); EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED); EventCounter focused(list, wxEVT_LIST_ITEM_FOCUSED); EventCounter activated(list, wxEVT_LIST_ITEM_ACTIVATED); EventCounter rclick(list, wxEVT_LIST_ITEM_RIGHT_CLICK); wxUIActionSimulator sim; wxRect pos; list->GetItemRect(0, pos); //We move in slightly so we are not on the edge wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 5); sim.MouseMove(point); wxYield(); sim.MouseClick(); wxYield(); sim.MouseDblClick(); wxYield(); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); // when the first item was selected the focus changes to it, but not // on subsequent clicks // FIXME: This test fail under wxGTK & wxOSX because we get 3 FOCUSED events and // 2 SELECTED ones instead of the one of each we expect for some // reason, this needs to be debugged as it may indicate a bug in the // generic wxListCtrl implementation. #ifndef _WX_GENERIC_LISTCTRL_H_ CPPUNIT_ASSERT_EQUAL(1, focused.GetCount()); CPPUNIT_ASSERT_EQUAL(1, selected.GetCount()); #endif CPPUNIT_ASSERT_EQUAL(1, activated.GetCount()); CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); //tidy up when we are finished list->ClearAll(); #endif // wxUSE_UIACTIONSIMULATOR }
// Draw button-like widgets with an optional glyph. The glyph is given // a size (negative to put it on the right) void Fl_Button::draw(int glyph, int glyph_width) const { // Figure out the colors to use. The flags are used by the label and // glyph functions to figure out their colors: Fl_Flags flags; Fl_Color color; if (!active_r()) { flags = FL_INACTIVE; color = this->color(); } else if (belowmouse()) { flags = FL_HIGHLIGHT; color = highlight_color(); if (!color) color = this->color(); } else { flags = 0; color = this->color(); } Fl_Flags glyph_flags = flags; if (glyph_width) { if (this == held_down) flags.set(FL_VALUE); if (value()) glyph_flags.set(FL_VALUE); } else if (value()) { flags.set(FL_VALUE); // Use the pushed-in color if the user has explicitly set it // on this widget: if (style()->selection_color) { color = style()->selection_color; flags.set(FL_SELECTED); // this makes label use selected_text_color() } } bool draw_label = true; int x = 0, y = 0, w = this->w(), h = this->h(); if (box() == FL_NO_BOX) { // If the box is FL_NO_BOX we need to avoid drawing the label so // that it does not blink and does not draw multiple times (which // will make it look bold if antialiasing is on). /* if (!label()) { // don't do anything if no label, so buttons that are an image // only will redraw correctly and with minimum blinking. } else */ if ((damage()&FL_DAMAGE_EXPOSE) || (damage()&FL_DAMAGE_HIGHLIGHT) && !focused()) { // erase the background behind where the label will draw: fl_push_clip(0, 0, w, h); parent()->draw_group_box(); fl_pop_clip(); } else { // Don't draw the label unnecessarily: draw_label = false; } } else { bool drawed = false; if(image() && !image()->get_mask()) { if((align()&FL_ALIGN_TILED || align()&FL_ALIGN_SCALE) && ( !(align()&(FL_ALIGN_LEFT|FL_ALIGN_RIGHT|FL_ALIGN_TOP|FL_ALIGN_BOTTOM)) || (align()&FL_ALIGN_INSIDE) ) ) { // We can draw only frame, if drawing image tiled or scale // And no mask defined to image... draw_frame(); drawed = true; } } if(!drawed) { if (damage()&FL_DAMAGE_EXPOSE && !box()->fills_rectangle()) { fl_push_clip(0, 0, w, h); parent()->draw_group_box(); fl_pop_clip(); } // Draw the box: box()->draw(0, 0, w, h, color, flags); } box()->inset(x,y,w,h); } if (glyph_width < 0) { int g = -glyph_width; draw_glyph(glyph, x+w-g-3, y+((h-g)>>1), g, g, glyph_flags); if (draw_label) draw_inside_label(x, y, w-g-3, h, flags); }
void dtkComposerViewLayoutItem::notify(dtkComposerViewWidget *view) { if(d->root == this) emit focused(view); }
bool View::eventFilter( QObject * watched, QEvent * e ) { // kDebug() << k_funcinfo << e->type() << endl; if ( watched != m_pFocusWidget ) return false; switch ( e->type() ) { case QEvent::FocusIn: { p_viewContainer->setActiveViewArea( viewAreaId() ); if ( KTechlab * ktl = KTechlab::self() ) { ktl->actionByName("file_save")->setEnabled(true); ktl->actionByName("file_save_as")->setEnabled(true); ktl->actionByName("file_close")->setEnabled(true); ktl->actionByName("file_print")->setEnabled(true); ktl->actionByName("edit_paste")->setEnabled(true); ktl->actionByName("view_split_leftright")->setEnabled(true); ktl->actionByName("view_split_topbottom")->setEnabled(true); ItemInterface::self()->updateItemActions(); } // kDebug() << k_funcinfo << "Focused In\n"; emit focused(this); break; } case QEvent::FocusOut: { // kDebug() << k_funcinfo << "Focused Out.\n"; QFocusEvent *fe = static_cast<QFocusEvent*>(e); if ( QWidget * fw = qApp->focusWidget() ) { QString fwClassName( fw->className() ); // kDebug() << "New focus widget is \""<<fw->name()<<"\" of type " << fwClassName << endl; if ( (fwClassName != "KateViewInternal") && (fwClassName != "QViewportWidget") ) { // kDebug() << "Returning as a non-view widget has focus.\n"; break; } } else { // kDebug() << "No widget currently has focus.\n"; } if ( fe->reason() == Qt::PopupFocusReason ) { // kDebug() << k_funcinfo << "Ignoring focus-out event as was a popup.\n"; break; } if ( fe->reason() == Qt::ActiveWindowFocusReason ) { // kDebug() << k_funcinfo << "Ignoring focus-out event as main window lost focus.\n"; break; } emit unfocused(); break; } default: break; } return false; }
void ImageCollection::layoutCollapsed() { tl.complete(); _collapseLayer.moveToParent(&_iconItem); QPoint p = collapsePoint(); int seenOnScreen = 0; int f = focused(); _collapseLayer.z().setValue(-10000.); for(int ii = count() - 1; ii >= 0; --ii) { Image *img = image(ii); img->moveToParent(iconItem()); if(!isOnScreen(ii)) continue; seenOnScreen++; int pauseTime = (seenOnScreen - 1) * 50; tl.pause(img->x(), pauseTime); tl.pause(img->y(), pauseTime); tl.pause(img->rotate(), pauseTime); img->z().setValue(-ii); if(ii == f) { tl.move(img->scale(), SMALL_ZOOM, 50); tl.sync(img->z(), img->scale()); img->z().setValue(1); tl.set(img->z(), -ii); if(pauseTime > 50) tl.pause(img->scale(), pauseTime - 50); } else { tl.pause(img->scale(), pauseTime); } } seenOnScreen = 0; for(int ii = 0; ii < count(); ++ii) { if(!isOnScreen(ii)) continue; seenOnScreen++; Image *img = image(ii); #define PHOTO_OFFSET 7 int idx = seenOnScreen; switch(idx) { case 0: tl.move(img->x(), p.x() - PHOTO_OFFSET, 150); tl.move(img->y(), p.y() - PHOTO_OFFSET, 150); tl.sync(img->quality(), img->x()); tl.set(img->quality(), 1.); break; case 1: tl.move(img->x(), p.x() + PHOTO_OFFSET, 150); tl.move(img->y(), p.y() - PHOTO_OFFSET, 150); tl.sync(img->quality(), img->x()); tl.set(img->quality(), 1.); break; case 2: tl.move(img->x(), p.x() + PHOTO_OFFSET, 150); tl.move(img->y(), p.y() + PHOTO_OFFSET, 150); tl.sync(img->quality(), img->x()); tl.set(img->quality(), 1.); break; case 3: tl.move(img->x(), p.x() - PHOTO_OFFSET, 150); tl.move(img->y(), p.y() + PHOTO_OFFSET, 150); tl.sync(img->quality(), img->x()); tl.set(img->quality(), 1.); break; default: tl.move(img->x(), p.x(), 150); tl.move(img->y(), p.y(), 150); //tl.set(img->quality(), 0.); break; } int rotate = (qrand() % 40) - 20; if(isOnScreen(ii)) { tl.move(img->scale(), SMALL_ZOOM * .7, 150); tl.move(img->rotate(), rotate, 150); tl.sync(image(ii)->imageParent(), image(ii)->x()); tl.set(image(ii)->imageParent(), 1.); } else { img->scale().setValue(SMALL_ZOOM * .7); img->rotate().setValue(rotate); img->visible().setValue(0.); img->imageParent().setValue(1.); } } tl.sync(); seenOnScreen = 0; for(int ii = 0; ii < count(); ++ii) { if(!isOnScreen(ii)) continue; seenOnScreen++; if(seenOnScreen > 4) tl.set(image(ii)->visible(), 0.); } GfxCanvasItem *i = nameItem(); tl.move(i->visible(), 1., 300); }
void Fl_Roller::draw() { if (damage()&(FL_DAMAGE_ALL|FL_DAMAGE_HIGHLIGHT)) draw_box(); int X=0; int Y=0; int W=w(); int H=h(); box()->inset(X,Y,W,H); if (W<=0 || H<=0) return; double s = step(); if (!s) s = (maximum()-minimum())/100; int offset = int(value()/s); const double ARC = 1.5; // 1/2 the number of radians visible const double delta = .2; // radians per knurl if (type()==HORIZONTAL) { // draw shaded ends of wheel: int h1 = W/4+1; // distance from end that shading starts fl_color(button_color()); fl_rectf(X+h1,Y,W-2*h1,H); for (int i=0; h1; i++) { fl_color((Fl_Color)(FL_GRAY-i-1)); int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0; fl_rectf(X+h2,Y,h1-h2,H); fl_rectf(X+W-h1,Y,h1-h2,H); h1 = h2; } if (active_r()) { // draw ridges: double junk; for (double y = -ARC+modf(offset*sin(ARC)/(W/2)/delta,&junk)*delta;; y += delta) { int y1 = int((sin(y)/sin(ARC)+1)*W/2); if (y1 <= 0) continue; else if (y1 >= W-1) break; fl_color(FL_DARK3); fl_line(X+y1,Y+1,X+y1,Y+H-1); if (y < 0) y1--; else y1++; fl_color(FL_LIGHT1);fl_line(X+y1,Y+1,X+y1,Y+H-1); } // draw edges: h1 = W/8+1; // distance from end the color inverts fl_color(FL_DARK2); fl_line(X+h1,Y+H-1,X+W-h1,Y+H-1); fl_color(FL_DARK3); fl_line(X,Y+H,X,Y); fl_line(X,Y,X+h1,Y); fl_line(X+W-h1,Y,X+W,Y); fl_color(FL_LIGHT2); fl_line(X+h1,Y,X+W-h1,Y); fl_line(X+W,Y,X+W,Y+H); fl_line(X+W,Y+H,X+W-h1,Y+H); fl_line(X+h1,Y+H,X,Y+H); } } // vertical one else { offset = (1-offset); // draw shaded ends of wheel: int h1 = H/4+1; // distance from end that shading starts fl_color(button_color()); fl_rectf(X,Y+h1,W,H-2*h1); for (int i=0; h1; i++) { fl_color((Fl_Color)(FL_GRAY-i-1)); int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0; fl_rectf(X,Y+h2,W,h1-h2); fl_rectf(X,Y+H-h1,W,h1-h2); h1 = h2; } if (active_r()) { // draw ridges: double junk; for (double y = -ARC+modf(offset*sin(ARC)/(H/2)/delta,&junk)*delta; ; y += delta) { int y1 = int((sin(y)/sin(ARC)+1)*H/2); if (y1 <= 0) continue; else if (y1 >= H-1) break; fl_color(FL_DARK3); fl_line(X+1,Y+y1,X+W-1,Y+y1); if (y < 0) y1--; else y1++; fl_color(FL_LIGHT1);fl_line(X+1,Y+y1,X+W-1,Y+y1); } // draw edges: h1 = H/8+1; // distance from end the color inverts fl_color(FL_DARK2); fl_line(X+W-1,Y+h1,X+W-1,Y+H-h1); fl_color(FL_DARK3); fl_line(X+W,Y,X,Y); fl_line(X,Y,X,Y+h1); fl_line(X,Y+H-h1,X,Y+H); fl_color(FL_LIGHT2); fl_line(X,Y+h1,X,Y+H-h1); fl_line(X,Y+H,X+W,Y+H); fl_line(X+W,Y+H,X+W,Y+H-h1); fl_line(X+W,Y+h1,X+W,Y); } } if (focused()) { focus_box()->draw(0,0,w(),h(), FL_BLACK, FL_INVISIBLE); } }
void Fl_Slider::draw() { // figure out the inner size of the box: Fl_Boxtype box = this->box(); int ix = 0, iy = 0, iw = w(), ih = h(); box->inset(ix,iy,iw,ih); // figure out where to draw the slider, leaving room for tick marks: int sx = ix, sy = iy, sw = iw, sh = ih; if (tick_size_ && (type()&TICK_BOTH)) { if (horizontal()) { sh -= tick_size_; switch (type()&TICK_BOTH) { case TICK_BOTH: sy += tick_size_/2; break; case TICK_ABOVE: sy += tick_size_; break; } } else { sw -= tick_size_; switch (type()&TICK_BOTH) { case TICK_BOTH: sx += tick_size_/2; break; case TICK_ABOVE: sx += tick_size_; break; } } } Fl_Flags flags = 0; if (!active_r()) { flags.set(FL_INACTIVE); } else { if (Fl::pushed() == this) flags.set(FL_VALUE); if (belowmouse()) flags.set(FL_HIGHLIGHT); } if(!(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT)) { // draw the box or the visible parts of the window if (!box->fills_rectangle()) parent()->draw_group_box(); box->draw(0, 0, w(), h(), color(), flags); } // minimal-update the slider, if it indicates the background needs // to be drawn, draw that. We draw the slot if the current box type // has no border: if (draw(sx, sy, sw, sh, flags, iy==0)) { if(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT) { // draw the box or the visible parts of the window if (!box->fills_rectangle()) parent()->draw_group_box(); box->draw(0, 0, w(), h(), color(), flags); } // draw the focus indicator inside the box: if (focused()) { focus_box()->draw(ix+1, iy+1, iw-2, ih-2, label_color(), FL_INVISIBLE); } if (type() & TICK_BOTH) { if (horizontal()) { switch (type()&TICK_BOTH) { case TICK_ABOVE: ih = sy+sh/2-iy; break; case TICK_BELOW: ih += iy; iy = sy+sh/2+(iy?0:3); ih -= iy; break; } } else { switch (type()&TICK_BOTH) { case TICK_ABOVE: iw = sx+sw/2-ix; break; case TICK_BELOW: iw += ix; ix = sx+sw/2+(iy?0:3); iw -= ix; break; } } Fl_Color color = text_color(); if (!active_r()) color = fl_inactive(color); fl_color(color); draw_ticks(ix, iy, iw, ih, (slider_size_+1)/2); } fl_pop_clip(); } }