void WidgetScrollBox::logic(int x, int y) { Point mouse(x, y); if (isWithin(pos,mouse)) { inpt->lock_scroll = true; if (inpt->scroll_up) scrollUp(); if (inpt->scroll_down) scrollDown(); } else { inpt->lock_scroll = false; } // check ScrollBar clicks if (contents && contents->getGraphicsHeight() > pos.h && scrollbar) { switch (scrollbar->checkClick(mouse.x,mouse.y)) { case 1: scrollUp(); break; case 2: scrollDown(); break; case 3: cursor = scrollbar->getValue(); break; default: break; } } }
int qmapcontrol::MapControl::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: mouseEventCoordinate((*reinterpret_cast< const QMouseEvent*(*)>(_a[1])),(*reinterpret_cast< const QPointF(*)>(_a[2]))); break; case 1: boxDragged((*reinterpret_cast< const QRectF(*)>(_a[1]))); break; case 2: geometryClicked((*reinterpret_cast< Geometry*(*)>(_a[1])),(*reinterpret_cast< QPoint(*)>(_a[2]))); break; case 3: viewChanged((*reinterpret_cast< const QPointF(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 4: zoomIn(); break; case 5: zoomOut(); break; case 6: setZoom((*reinterpret_cast< int(*)>(_a[1]))); break; case 7: scrollLeft((*reinterpret_cast< int(*)>(_a[1]))); break; case 8: scrollLeft(); break; case 9: scrollRight((*reinterpret_cast< int(*)>(_a[1]))); break; case 10: scrollRight(); break; case 11: scrollUp((*reinterpret_cast< int(*)>(_a[1]))); break; case 12: scrollUp(); break; case 13: scrollDown((*reinterpret_cast< int(*)>(_a[1]))); break; case 14: scrollDown(); break; case 15: scroll((*reinterpret_cast< const QPoint(*)>(_a[1]))); break; case 16: updateRequest((*reinterpret_cast< QRect(*)>(_a[1]))); break; case 17: updateRequestNew(); break; case 18: resize((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 19: tick(); break; case 20: loadingFinished(); break; case 21: positionChanged((*reinterpret_cast< Geometry*(*)>(_a[1]))); break; default: ; } _id -= 22; } return _id; }
void IbmPcVgaTerminal::syphon(const utf8Char *str, uarch_t len) { // FIXME: Remember to do utf-8 expansion here. if (buff == NULL || str == NULL) { return; }; for (; len != 0; len--, str++) { switch(*str) { case '\n': if (row >= maxRow-1) { scrollDown(); row = maxRow-1; col = 0; break; } row++; col = 0; break; case '\r': col = 0; break; case '\t': col += 8; col &= ~0x7; break; default: if (*str < 0x20) { break; }; if (col >= maxCol) { row++; if (row >= maxRow-1) { scrollDown(); row = maxRow-1; }; col = 0; }; // For now we truncate all codepoints. buff[row * maxCol + col].ch = (ubit8)*str; buff[row * maxCol + col].attr = 0x07; col++; break; }; }; }
void dragTarget::scrollDown() { disconnect(scrollDownTimer, SIGNAL(timeout()), this, SLOT(scrollDown())); puts("scrollDown chiamato"); this -> scrollToItem(tempScroll); tempScroll = itemBelow(tempScroll); connect(scrollDownTimer, SIGNAL(timeout()), this, SLOT(scrollDown())); if(tempScroll == NULL) { disconnect(scrollDownTimer, SIGNAL(timeout()), this, SLOT(scrollDown())); scrollDownTimer -> stop(); } }
//// // Scrolling Routines //// bool CMap::gotoPos(int x, int y) { int dx,dy; bool retval = false; dx = x - m_scrollx; dy = y - m_scrolly; if( dx > 0 ) for( int scrollx=0 ; scrollx<dx ; scrollx++) scrollRight(true); else retval = true; if( dx < 0 ) for( int scrollx=0 ; scrollx<-dx ; scrollx++) scrollLeft(true); else retval = true; if( dy > 0 ) for( int scrolly=0 ; scrolly<dy ; scrolly++) scrollDown(true); else retval = true; if( dy < 0 ) for( int scrolly=0 ; scrolly<-dy ; scrolly++) scrollUp(true); else retval = true; return retval; }
void CMap::renderShaking() { if(mMaxShakeCounter == 0) return; if(mShakeCounter < mMaxShakeCounter) { // shake by changing the relative position if(mShakeDir > 0) { // Shake downwards for(int i=0 ; i<mMaxShakeVAmt ; i++) scrollDown(); mShakeDir = -1; } else { // Shake upwards for(int i=0 ; i<mMaxShakeVAmt ; i++) scrollUp(); mShakeDir = 1; } mShakeCounter++; } else { // Stop the shaking mMaxShakeCounter = 0; mShakeDir = 0; mShakeCounter = 0; } }
bool MainWindow::connectRobot (const QString& address) { if (m_connectedRobots.end() != m_connectedRobots.find(address)) { /* The requested robot is already connected */ return true; } auto newrobot = new mobot_t; Mobot_init(newrobot); /* extract the 8-bit byte array from QString, from which we can then extract * the C-string */ auto baAddress = address.toLocal8Bit(); if (-1 == Mobot_connectWithAddress(newrobot, baAddress.data(), 1)) { delete newrobot; qDebug() << "(barobolab) ERROR: Mobot_connectWithTTY failed\n"; return false; } Mobot_enableButtonCallback(newrobot, strdup(baAddress.data()), JsInterface::robotButtonCallback); auto l = new RobotListener(newrobot, address); QObject::connect(l, SIGNAL(scrollUp(QString)), m_interface, SLOT(scrollUpSlot(QString))); QObject::connect(l, SIGNAL(scrollDown(QString)), m_interface, SLOT(scrollDownSlot(QString))); QThread *thread = new QThread(this); l->moveToThread(thread); thread->start(); QMetaObject::invokeMethod(l, "startWork", Qt::QueuedConnection); m_connectedRobots.insert(std::make_pair(address, newrobot)); m_robotListeners.insert(std::make_pair(address, l)); return true; }
void RKProgressControlDialog::addOutput (const ROutput *output) { RK_TRACE (MISC); // scrolled all the way to the bottom? bool at_end = true; QScrollBar *bar = output_text->verticalScrollBar (); if (bar && (bar->value () < bar->maximum ())) at_end = false; if (output->type != last_output_type) { last_output_type = output->type; output_text->insertPlainText ("\n"); if (output->type == ROutput::Output) { output_text->setTextColor (Qt::black); } else { output_text->setTextColor (Qt::red); if (!isDetailsWidgetVisible ()) setDetailsWidgetVisible (true); error_indicator->show (); } } output_text->insertPlainText (output->output); // if previously at end, auto-scroll if (at_end && output_text->isVisible ()) scrollDown (); }
// Most common render function for this TextViewer void CTextViewer::process() { // Normal Keys/Axes if( g_pInput->getHoldedCommand(IC_DOWN) ) { m_timer++; if(m_timer >= 2) scrollDown(); } if( g_pInput->getHoldedCommand(IC_UP) ) { m_timer++; if(m_timer >= 2) scrollUp(); } // Page Keys if( g_pInput->getPressedKey(KPGDN) ) setPosition(m_linepos+16); if( g_pInput->getPressedKey(KPGUP) ) setPosition(m_linepos-16); if(m_timer>=8) m_timer=0; if(g_pInput->getPressedKey(KQUIT) || g_pInput->getPressedKey(KQ) ) m_mustclose = true; renderBox(); // This comes after, because it does transparent overlay }
void ScriptConsoleView::printOutput(const QString &output) { if (!output.isEmpty()) m_ui->commandsList->insertPlainText(output + "\n"); scrollDown(); }
void Console::insertPrompt() { textCursor().insertText(prompt); scrollDown(); locked = false; }
void Console::output(QString str) { textCursor().insertBlock(); textCursor().insertText(str); scrollDown(); }
void GsScrollbar::processLogic() { // Here we check if the mouse-cursor/Touch entry clicked on something!! const float fx = mRect.x; const float fw = mRect.w; const float fy = mRect.y; const float fh = mRect.h; const float y_innerbound_max = fy+fh; //const float x_innerbound_min = fx + static_cast<float>(TEXT_HEIGHT)/bw; GsRect<float> rRect(fx, fy, fw, fh); GsRect<float> parRect(mpParent->mRect); rRect.transform(parRect); GsPointingState &pointingState = gPointDevice.mPointingState; processPointingState(rRect); Vector2D<float> MousePos = pointingState.mPos; const bool scrollAction = mReleased || mPressed; if( rRect.HasPoint(MousePos) ) { if( MousePos.y > fy && MousePos.y < y_innerbound_max ) { if(scrollAction) // If clicked or pressed on scroll bar { float relPos = float(mScrollPos) / float(mMaxScrollAmt); const float scrollAreaY1 = rRect.y + mArrowHeight + mSliderHeight*0.5f; const float scrollAreaY2 = rRect.y + rRect.h - mArrowHeight - mSliderHeight*0.5f; const float scrollHeight = scrollAreaY2-scrollAreaY1; const float midPart_y = scrollAreaY1+(scrollHeight*relPos); if(mPressed) { if(MousePos.y < scrollAreaY1 || MousePos.y > scrollAreaY2) return; } // The tolerance will remove the jitter effect in scrolling const float tolerance = scrollHeight/float(mMaxScrollAmt); if(MousePos.y < midPart_y-tolerance) // Go up! { scrollUp(); } else if(MousePos.y > midPart_y+tolerance) // Go down! { scrollDown(); } } } } }
bool EditboxVScrollView::mouseDrag(int x, int y) { int textheight; textheight = text_height(textfont); if(model->getSelection().isSelecting()) { return BasicEditboxView::mouseDrag(x,y); } else { //maybe pressing arrow, or sliding? if(toparrow_state == 1) { scrollUp(); return true; } if(bottomarrow_state == 1) { scrollDown(); return true; } if(barstate == 1) { //fake a click //first, clip the coords int fakex = toparrow_x+1; return mouseClick(fakex,y); } return mouseDragOther(x,y); } }
void WidgetListBox::subActive(Widget &widget) { if (widget.getTag().endsWith("#Up")) { scrollUp(1); return; } if (widget.getTag().endsWith("#Down")) { scrollDown(1); return; } if (widget.getTag().endsWith("#Bar")) { ptrdiff_t max = _items.size() - _visibleItems.size(); if (max <= 0) return; size_t startItem = _scrollbar->getState() * max; if (startItem == _startItem) return; _startItem = startItem; updateVisible(); return; } WidgetListItem *listItem = dynamic_cast<WidgetListItem *>(&widget); if (listItem) { if (_selectedItem != listItem->_itemNumber) { _selectedItem = listItem->_itemNumber; setActive(true); } } }
// Most common render function for this TextViewer void CTextViewer::ponder() { // Normal Keys/Axes if( g_pInput->getHoldedCommand(IC_DOWN) ) { m_timer++; if(m_timer >= 2) scrollDown(); } if( g_pInput->getHoldedCommand(IC_UP) ) { m_timer++; if(m_timer >= 2) scrollUp(); } // Page Keys if( g_pInput->getPressedKey(KPGDN) ) setPosition(m_linepos+16); if( g_pInput->getPressedKey(KPGUP) ) setPosition(m_linepos-16); if(m_timer>=8) m_timer=0; if(g_pInput->getPressedKey(KQUIT) || g_pInput->getPressedKey(KQ) || g_pInput->getPressedCommand(IC_BACK) ) m_mustclose = true; }
void SignalChainManager::createNewTab(GenericEditor* editor) { int index = signalChainArray.size(); SignalChainTabButton* t = new SignalChainTabButton(); t->setManager(this); t->setEditor(editor); ev->addChildComponent(t); signalChainArray.add(t); editor->tabNumber(signalChainArray.size()-1); t->setToggleState(true,false); t->setNumber(index); index -= topTab; ev->leftmostEditor = 0; if (signalChainArray.size()-topTab > 4) { scrollDown(); } refreshTabs(); }
void KoHelpWidget::timerEvent( QTimerEvent* ) { if ( m_scrollDown ) scrollDown(); else scrollUp(); } // KoHelpWidget::timerEvent
void ConsoleArea::addText(QString text) { label->setText(label->text() + text); label->adjustSize(); label->setFixedWidth(width() - 20); scrollDown(); widget->adjustSize(); }
void ScriptConsoleView::printError(const QString &error) { m_ui->commandsList->setTextColor(Qt::red); m_ui->commandsList->insertPlainText(error + "\n"); m_ui->commandsList->setTextColor(Qt::black); scrollDown(); }
bool CPetConversations::MouseWheelMsg(CMouseWheelMsg *msg) { if (msg->_wheelUp) scrollUp(); else scrollDown(); return true; }
void Screen::reverseIndex() //=RI { if (cuY == _topMargin) scrollDown(_topMargin,1); else if (cuY > 0) cuY -= 1; }
RKProgressControlDialog::RKProgressControlDialog (const QString &text, const QString &caption, int mode_flags, bool modal) : KDialog (0) { RK_TRACE (MISC); setAttribute (Qt::WA_DeleteOnClose, true); setModal (modal); setCaption (caption); KVBox *vbox = new KVBox (this); vbox->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); setMainWidget (vbox); QLabel *label = new QLabel (text, vbox); label->setWordWrap (true); error_indicator = new QLabel (i18n ("<b>There have been errors and / or warnings! See below for a transcript</b>"), vbox); QPalette palette = error_indicator->palette (); palette.setColor (error_indicator->foregroundRole (), QColor (255, 0, 0)); error_indicator->setPalette (palette); error_indicator->hide (); KVBox* output_box = new KVBox (); if (mode_flags & (RKProgressControl::IncludeErrorOutput | RKProgressControl::IncludeRegularOutput)) { QString ocaption; if (mode_flags & RKProgressControl::IncludeRegularOutput) { output_button_text = i18n ("Output"); ocaption = i18n ("Output:"); } else { output_button_text = i18n ("Errors / Warnings"); ocaption = i18n ("Errors / Warnings:"); } new QLabel (ocaption, output_box); output_text = new QTextEdit (output_box); output_text->setReadOnly (true); output_text->setPlainText (QString ()); output_text->setUndoRedoEnabled (false); output_text->setLineWrapMode (QTextEdit::NoWrap); output_text->setMinimumWidth (QFontMetrics (output_text->font ()).averageCharWidth () * RKSettingsModuleR::getDefaultWidth ()); output_box->setStretchFactor (output_text, 10); } setDetailsWidget (output_box); // it's important to use a queued connection, here. Otherwise, if the details widget gets shown due to error output, scrollDown() would only scroll to the position directly *above* the new output. connect (this, SIGNAL(aboutToShowDetails()), this, SLOT(scrollDown()), Qt::QueuedConnection); KDialog::ButtonCodes button_codes = KDialog::Cancel; if (mode_flags & RKProgressControl::OutputSwitchable) button_codes |= KDialog::Details; setButtons (button_codes); if (button_codes & KDialog::Details) setButtonText (KDialog::Details, output_button_text); if (mode_flags & RKProgressControl::AllowCancel) setButtonText (KDialog::Cancel, i18n ("Cancel")); else (setCloseTextToClose ()); if (mode_flags & RKProgressControl::OutputShownByDefault) setDetailsWidgetVisible (true); prevent_close = (mode_flags & RKProgressControl::PreventClose); last_output_type = ROutput::Output; is_done = false; }
void EditorScreen::moveCursor(int newLineIndex, int newOffset, bool *scrolled) { int line = 0; int col = 0; bool done = false; while (newLineIndex < _topLineIndex || (newLineIndex == _topLineIndex && newOffset / 16 < _topLineSubIndex)) if (scrollUp()) done = true; else break; if (done) { feedScreen(); emit screenChanged(); if (scrolled) *scrolled = true; } for (int index = _topLineIndex; index < newLineIndex; ++index) { const TextLine &textLine = _lines[index]; line += textLine.rowCount(); if (index == _topLineIndex) line -= _topLineSubIndex; } line += newOffset / 16; if (newLineIndex == _topLineIndex) line -= _topLineSubIndex; col = newOffset % 16; // Must scroll down? done = false; for (int i = 0; i < line - 7; i++) if (scrollDown()) done = true; else break; if (done) { line = 7; if (scrolled) *scrolled = true; feedScreen(); emit screenChanged(); } TextScreen::moveCursor(col, line); _cursorLineIndex = newLineIndex; _cursorOffset = newOffset; }
void RKProgressControlDialog::scrollDown () { RK_TRACE (MISC); // oh what an ugly hack... (to cope with changing slider position just when the details widget becomes visible if (!output_text->isVisible ()) QTimer::singleShot (0, this, SLOT(scrollDown())); QScrollBar *bar = output_text->verticalScrollBar (); if (bar) bar->setValue (bar->maximum ()); }
void WidgetListBox::mouseWheel(uint8 UNUSED(state), int UNUSED(x), int y) { if (isDisabled()) return; if (y > 0) scrollUp(1); else if (y < 0) scrollDown(1); }
void IncSearchWidget::keyPressEvent( QKeyEvent *event ) { if ( event->key() == Qt::Key_Up ) { event->accept(); emit scrollUp(); } else if ( event->key() == Qt::Key_Down ) { event->accept(); emit scrollDown(); } }
void QUAboutDialog::scrollDown() { QScrollBar *bar = credits->verticalScrollBar(); if(bar->value() >= bar->maximum()) QTimer::singleShot(RESET_GAP, this, SLOT(resetText())); else { bar->setValue(bar->value() + SCROLL_STEP); QTimer::singleShot(SCROLL_GAP, this, SLOT(scrollDown())); } }
void Console::insertPrompt(bool insertNewBlock) { if(insertNewBlock) textCursor().insertBlock(); QTextCharFormat format; format.setForeground(Qt::green); textCursor().setBlockCharFormat(format); textCursor().insertText(prompt); scrollDown(); }
void KTinyTabBar::wheelEvent( QWheelEvent* event ) { event->accept(); if (event->delta() < 0) { scrollDown(); } else { scrollUp(); } }