UIHexEditorWnd::UIHexEditorWnd( QWidget* p ) : QAbstractScrollArea( p ) { gapSizeAddrHex = 10; gapSizeHexText = 16; bytesPerLine = 16; bytesPerGroup = 2; nibblesPerGroup = bytesPerGroup * 2; hexCharsInLine = bytesPerLine * 2 + (bytesPerLine / bytesPerGroup) - 1; textEdit = false; setStartAddress(0); setEndAddress(0xFFFFFFFF); setAddrAreaColor(this->palette().color(QPalette::AlternateBase)); adjustSettings(); resetSelection(0); goToAddress(0); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(sliderUpdate(int))); connect(&cursorTimer, SIGNAL(timeout()), this, SLOT(updateCursor())); cursorTimer.setInterval(500); cursorTimer.start(); connect(&autoScrollTimer, SIGNAL(timeout()), this, SLOT(autoScroll())); autoScrollTimer.setInterval(5); setMouseTracking(true); }
void WicdApplet::loadNetworks() { m_networkView->loadNetworks(); graphicsWidget()->adjustSize(); //we need to defer the scrolling to let adjustSize() do its work to prevent a graphical glitch QTimer::singleShot(0, this, SLOT(autoScroll())); }
UBDocumentThumbnailWidget::UBDocumentThumbnailWidget(QWidget* parent) : UBThumbnailWidget(parent) , mDropCaretRectItem(0) , mClosestDropItem(0) , mDragEnabled(true), mScrollMagnitude(0) { mScrollTimer = new QTimer(this); connect(mScrollTimer, SIGNAL(timeout()), this, SLOT(autoScroll())); }
void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree, tree_update *arg ) { if( arg->type == arg->UpdateItem ) // Item update { if( arg->b_active_item ) autoScroll(); if( isItemVisible( arg->i_id ) ) { makeImage(); notifyLayout(); } } else if ( arg->type == arg->ResetAll ) // Global change or deletion { m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin(); makeImage(); notifyLayout(); } else if ( arg->type == arg->AppendItem ) // Item-append { if( m_flat && m_firstPos->size() ) { m_firstPos = m_rTree.getNextLeaf( m_firstPos ); makeImage(); notifyLayout(); } else if( isItemVisible( arg->i_id ) ) { makeImage(); notifyLayout(); } } else if( arg->type == arg->DeleteItem ) // item-del { /* Make sure firstPos is valid */ VarTree::Iterator it_old = m_firstPos; while( m_firstPos->isDeleted() && m_firstPos != (m_flat ? m_rTree.firstLeaf() : m_rTree.begin()) ) { m_firstPos = m_flat ? m_rTree.getPrevLeaf( m_firstPos ) : m_rTree.getPrevVisibleItem( m_firstPos ); } if( m_firstPos->isDeleted() ) m_firstPos = m_rTree.begin(); if( m_firstPos != it_old || isItemVisible( arg->i_id ) ) { makeImage(); notifyLayout(); } } }
//配置所有用户的聊天内容显示的属性 void ChatWindow::originAllContents() { _allContents=new QTextBrowser(this); _allContents->setGeometry(0,169,300,350); QFont font;font.setPointSize(12);font.setBold(true); _allContents->setFont(font); _allContents->setStyleSheet("border:2px solid #e8e8e8;background-color:#ffffff;color:#333333"); connect(_allContents,SIGNAL(cursorPositionChanged()),this,SLOT(autoScroll())); _allContents->hide(); }
// The following function takes a visible row index (hidden rows skipped) // dir: -1 = left (close), 0 = auto (toggle), 1 = right (open) void GUITable::toggleVisibleTree(s32 row_i, int dir, bool move_selection) { // Check if the chosen tree is currently open const Row *row = getRow(row_i); if (row == NULL) return; bool was_open = false; for (s32 j = 0; j < row->cellcount; ++j) { if (row->cells[j].content_type == COLUMN_TYPE_TREE) { was_open = row->cells[j].content_index == 0; break; } } // Check if the chosen tree should be opened bool do_open = !was_open; if (dir < 0) do_open = false; else if (dir > 0) do_open = true; // Close or open the tree; the heavy lifting is done by setOpenedTrees if (was_open && !do_open) closeTree(m_visible_rows[row_i]); else if (!was_open && do_open) openTree(m_visible_rows[row_i]); // Change selected row if requested by caller, // this is useful for keyboard navigation if (move_selection) { s32 sel = row_i; if (was_open && do_open) { // Move selection to first child const Row *maybe_child = getRow(sel + 1); if (maybe_child && maybe_child->indent > row->indent) sel++; } else if (!was_open && !do_open) { // Move selection to parent assert(getRow(sel) != NULL); while (sel > 0 && getRow(sel - 1)->indent >= row->indent) sel--; sel--; if (sel < 0) // was root already selected? sel = row_i; } if (sel != m_selected) { m_selected = sel; autoScroll(); sendTableEvent(0, false); } } }
void RegistWindow::originFdRegion() { QFont font; font.setBold(true); font.setPointSize(15); _fdRegion = new QTextBrowser(this); _fdRegion->setGeometry(0,0,800,500); _fdRegion->setStyleSheet("color:green;background-color:black;border:3px solid orange"); _fdRegion->setFont(font); connect(_fdRegion,SIGNAL(cursorPositionChanged()),this,SLOT(autoScroll())); }
void EmbeddedWebView::mouseMoveEvent(QMouseEvent *e) { if ((e->buttons() & Qt::LeftButton) && m_scrollParent) { m_autoScrollPixels = 0; const QPoint pos = mapTo(m_scrollParent, e->pos()); if (pos.y() < 0) m_autoScrollPixels = pos.y(); else if (pos.y() > m_scrollParent->rect().height()) m_autoScrollPixels = pos.y() - m_scrollParent->rect().height(); autoScroll(); m_autoScrollTimer->start(); } QWebView::mouseMoveEvent(e); }
void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree, tree_update *arg ) { if( arg->i_type == 0 ) // Item update { if( arg->b_active_item ) { autoScroll(); ///\todo We should make image if we are visible in the view makeImage(); } } /// \todo handle delete in a more clever way else if ( arg->i_type == 1 ) // Global change or deletion { m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin(); makeImage(); } else if ( arg->i_type == 2 ) // Item-append { if( m_flat && m_firstPos->size() ) m_firstPos = m_rTree.getNextLeaf( m_firstPos ); /// \todo Check if the item is really visible in the view // (we only check if it in the document) if( arg->b_visible == true ) { makeImage(); } } else if( arg->i_type == 3 ) // item-del { /* Make sure firstPos and lastSelected are still valid */ while( m_firstPos->m_deleted && m_firstPos != m_rTree.root()->begin() ) { m_firstPos = m_flat ? m_rTree.getPrevLeaf( m_firstPos ) : m_rTree.getPrevVisibleItem( m_firstPos ); } if( m_firstPos->m_deleted ) m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.root()->begin(); if( arg->b_visible == true ) { makeImage(); } } notifyLayout(); }
BOOL LLAccordionCtrl::handleDragAndDrop (S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, std::string& tooltip_msg) { // Scroll folder view if needed. Never accepts a drag or drop. *accept = ACCEPT_NO; BOOL handled = autoScroll(x, y); if( !handled ) { handled = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg) != NULL; } return TRUE; }
void KoView::slotAutoScroll( ) { QPoint scrollDistance; bool actuallyDoScroll = false; QPoint pos( mapFromGlobal( QCursor::pos() ) ); //Provide progressive scrolling depending on the mouse position if ( pos.y() < topBorder() ) { scrollDistance.setY ((int) - autoScrollAcceleration( - pos.y() + topBorder() )); actuallyDoScroll = true; } else if ( pos.y() > height() - bottomBorder() ) { scrollDistance.setY ((int) autoScrollAcceleration(pos.y() - height() + bottomBorder() )); actuallyDoScroll = true; } if ( pos.x() < leftBorder() ) { scrollDistance.setX ((int) - autoScrollAcceleration( - pos.x() + leftBorder() )); actuallyDoScroll = true; } else if ( pos.x() > width() - rightBorder() ) { scrollDistance.setX ((int) autoScrollAcceleration( pos.x() - width() + rightBorder() )); actuallyDoScroll = true; } if ( actuallyDoScroll ) { int state=0; #if KDE_IS_VERSION(3,4,0) state = kapp->keyboardMouseState(); #endif pos = canvas()->mapFrom(this, pos); QMouseEvent * event = new QMouseEvent(QEvent::MouseMove, pos, 0, state); QApplication::postEvent( canvas(), event ); emit autoScroll( scrollDistance ); } }
void GUITable::setSelected(s32 index) { s32 old_selected = m_selected; m_selected = -1; m_sel_column = 0; m_sel_doubleclick = false; --index; // Switch from 1-based indexing to 0-based indexing s32 rowcount = m_rows.size(); if (rowcount == 0) { return; } else if (index < 0) { index = 0; } else if (index >= rowcount) { index = rowcount - 1; } // If the selected row is not visible, open its ancestors to make it visible bool selection_invisible = m_rows[index].visible_index < 0; if (selection_invisible) { std::set<s32> opened_trees; getOpenedTrees(opened_trees); s32 indent = m_rows[index].indent; for (s32 j = index - 1; j >= 0; --j) { if (m_rows[j].indent < indent) { opened_trees.insert(j); indent = m_rows[j].indent; } } setOpenedTrees(opened_trees); } if (index >= 0) { m_selected = m_rows[index].visible_index; assert(m_selected >= 0 && m_selected < (s32) m_visible_rows.size()); } if (m_selected != old_selected || selection_invisible) { autoScroll(); } }
BOOL LLScrollContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, std::string& tooltip_msg) { static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); // Scroll folder view if needed. Never accepts a drag or drop. *accept = ACCEPT_NO; BOOL handled = autoScroll(x, y); if( !handled ) { handled = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg) != NULL; } return TRUE; }
void GUITable::setSelected(s32 index) { m_selected = -1; m_sel_column = 0; m_sel_doubleclick = false; --index; s32 rowcount = m_rows.size(); if (index >= rowcount) index = rowcount - 1; while (index >= 0 && m_rows[index].visible_index < 0) --index; if (index >= 0) { m_selected = m_rows[index].visible_index; assert(m_selected >= 0 && m_selected < (s32) m_visible_rows.size()); } autoScroll(); }
bool GUITable::OnEvent(const SEvent &event) { if (!isEnabled()) return IGUIElement::OnEvent(event); if (event.EventType == EET_KEY_INPUT_EVENT) { if (event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_DOWN || event.KeyInput.Key == KEY_UP || event.KeyInput.Key == KEY_HOME || event.KeyInput.Key == KEY_END || event.KeyInput.Key == KEY_NEXT || event.KeyInput.Key == KEY_PRIOR)) { s32 offset = 0; switch (event.KeyInput.Key) { case KEY_DOWN: offset = 1; break; case KEY_UP: offset = -1; break; case KEY_HOME: offset = - (s32) m_visible_rows.size(); break; case KEY_END: offset = m_visible_rows.size(); break; case KEY_NEXT: offset = AbsoluteRect.getHeight() / m_rowheight; break; case KEY_PRIOR: offset = - (s32) (AbsoluteRect.getHeight() / m_rowheight); break; default: break; } s32 old_selected = m_selected; s32 rowcount = m_visible_rows.size(); if (rowcount != 0) { m_selected = rangelim(m_selected + offset, 0, rowcount-1); autoScroll(); } if (m_selected != old_selected) sendTableEvent(0, false); return true; } else if (event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_LEFT || event.KeyInput.Key == KEY_RIGHT)) { // Open/close subtree via keyboard if (m_selected >= 0) { int dir = event.KeyInput.Key == KEY_LEFT ? -1 : 1; toggleVisibleTree(m_selected, dir, true); } return true; } else if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) { sendTableEvent(0, true); return true; } else if (event.KeyInput.Key == KEY_ESCAPE || event.KeyInput.Key == KEY_SPACE) { // pass to parent } else if (event.KeyInput.PressedDown && event.KeyInput.Char) { // change selection based on text as it is typed s32 now = getTimeMs(); if (now - m_keynav_time >= 500) m_keynav_buffer = L""; m_keynav_time = now; // add to key buffer if not a key repeat if (!(m_keynav_buffer.size() == 1 && m_keynav_buffer[0] == event.KeyInput.Char)) { m_keynav_buffer.append(event.KeyInput.Char); } // find the selected item, starting at the current selection // don't change selection if the key buffer matches the current item s32 old_selected = m_selected; s32 start = MYMAX(m_selected, 0); s32 rowcount = m_visible_rows.size(); for (s32 k = 1; k < rowcount; ++k) { s32 current = start + k; if (current >= rowcount) current -= rowcount; if (doesRowStartWith(getRow(current), m_keynav_buffer)) { m_selected = current; break; } } autoScroll(); if (m_selected != old_selected) sendTableEvent(0, false); return true; } } if (event.EventType == EET_MOUSE_INPUT_EVENT) { core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); if (event.MouseInput.Event == EMIE_MOUSE_WHEEL) { m_scrollbar->setPos(m_scrollbar->getPos() + (event.MouseInput.Wheel < 0 ? -3 : 3) * - (s32) m_rowheight / 2); return true; } // Find hovered row and cell bool really_hovering = false; s32 row_i = getRowAt(p.Y, really_hovering); const Cell *cell = NULL; if (really_hovering) { s32 cell_j = getCellAt(p.X, row_i); if (cell_j >= 0) cell = &(getRow(row_i)->cells[cell_j]); } // Update tooltip setToolTipText(cell ? m_strings[cell->tooltip_index].c_str() : L""); // Fix for #1567/#1806: // IGUIScrollBar passes double click events to its parent, // which we don't want. Detect this case and discard the event if (event.MouseInput.Event != EMIE_MOUSE_MOVED && m_scrollbar->isVisible() && m_scrollbar->isPointInside(p)) return true; if (event.MouseInput.isLeftPressed() && (isPointInside(p) || event.MouseInput.Event == EMIE_MOUSE_MOVED)) { s32 sel_column = 0; bool sel_doubleclick = (event.MouseInput.Event == EMIE_LMOUSE_DOUBLE_CLICK); bool plusminus_clicked = false; // For certain events (left click), report column // Also open/close subtrees when the +/- is clicked if (cell && ( event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN || event.MouseInput.Event == EMIE_LMOUSE_DOUBLE_CLICK || event.MouseInput.Event == EMIE_LMOUSE_TRIPLE_CLICK)) { sel_column = cell->reported_column; if (cell->content_type == COLUMN_TYPE_TREE) plusminus_clicked = true; } if (plusminus_clicked) { if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) { toggleVisibleTree(row_i, 0, false); } } else { // Normal selection s32 old_selected = m_selected; m_selected = row_i; autoScroll(); if (m_selected != old_selected || sel_column >= 1 || sel_doubleclick) { sendTableEvent(sel_column, sel_doubleclick); } // Treeview: double click opens/closes trees if (m_has_tree_column && sel_doubleclick) { toggleVisibleTree(m_selected, 0, false); } } } return true; } if (event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED && event.GUIEvent.Caller == m_scrollbar) { // Don't pass events from our scrollbar to the parent return true; } return IGUIElement::OnEvent(event); }
void CtrlList::onUpdate( Subject<VarList> &rList, void *arg ) { (void)rList; (void)arg; autoScroll(); m_pLastSelected = NULL; }