KDecoration::Position Manager::mousePosition(const TQPoint& p) const { Position m = PositionCenter; // Look out for off-by-one errors here. if (isResizable()) { if (p.y() > (height() - (Static::instance()->resizeHeight() + 1))) { // Keep order ! if (p.x() >= (width() - 30)) m = PositionBottomRight; else if (p.x() <= 30) m = PositionBottomLeft; else m = PositionBottom; } else { m = PositionCenter; // Client::mousePosition(p); } } else { m = PositionCenter; // Client::mousePosition(p); } return m; }
TQColor KColorDialog::grabColor(const TQPoint &p) { TQWidget *desktop = TQT_TQWIDGET(TQApplication::desktop()); TQPixmap pm = TQPixmap::grabWindow( desktop->winId(), p.x(), p.y(), 1, 1); TQImage i = pm.convertToImage(); return i.pixel(0,0); }
void CityList::paint(TQPainter *p, int width, int height, int offset) { p->setPen(TQt::black); TQPtrListIterator<City> it(_cities); for ( ; it.current(); ++it) { TQPoint pos = getPosition(it.current()->latitude(), it.current()->longitude(), width, height, offset); if (width > 100) p->drawEllipse(pos.x(), pos.y(), 3,3); else p->drawPoint(pos); } }
void QuickLauncher::updateStickyHighlightLayer() { // Creates a transparent image which is used // to highlight those buttons which will never // be removed automatically from the launcher TQPixmap areaPix(width(), height()); TQPainter areaPixPainter(&areaPix); areaPixPainter.fillRect(0, 0, width(), height(), TQColor(255, 255, 255)); TQSize itemSize = m_manager->itemSize(); TQSize spaceSize = m_manager->spaceSize(); for (uint n=0; n<m_buttons->size(); ++n) { TQPoint pos = m_manager->pos(n); if ((*m_buttons)[n]->sticky() == false) { areaPixPainter.fillRect(pos.x()-(spaceSize.width()+1)/2, pos.y()-(spaceSize.height()+1)/2, itemSize.width()+spaceSize.width()+1, itemSize.height()+spaceSize.height()+1, TQColor(0, 0, 0)); } } TQImage areaLayer = areaPix.convertToImage(); m_stickyHighlightLayer = TQImage(width(), height(), 32); m_stickyHighlightLayer.setAlphaBuffer(true); int pix, tlPix, brPix, w(width()), h(height()); QRgb transparent(tqRgba(0, 0, 0, 0)); for (int y = h-1; y >= 0; --y) { for (int x = w-1; x >= 0; --x) { pix = tqRed(areaLayer.pixel(x, y)); if (pix == 0) { tlPix = (y>0 && x>0) ? tqRed(areaLayer.pixel(x-1,y-1)) : 255; brPix = (y<h-1 && x<w-1) ? tqRed(areaLayer.pixel(x+1,y+1)) : 255; int c = tlPix-brPix < 0 ? 255 : 0; int alpha = abs(tlPix-brPix)/2; m_stickyHighlightLayer.setPixel(x, y, tqRgba(c, c, c, alpha)); } else { m_stickyHighlightLayer.setPixel(x, y, transparent); } } } repaint(); }
int KColorCells::posToCell(const TQPoint &pos, bool ignoreBorders) { int row = pos.y() / cellHeight(); int col = pos.x() / cellWidth(); int cell = row * numCols() + col; if (!ignoreBorders) { int border = 2; int x = pos.x() - col * cellWidth(); int y = pos.y() - row * cellHeight(); if ( (x < border) || (x > cellWidth()-border) || (y < border) || (y > cellHeight()-border)) return -1; } return cell; }
KDecoration::Position NextClient::mousePosition( const TQPoint& p ) const { Position m = PositionCenter; if (p.y() < (height() - handleSize)) m = KDecoration::mousePosition(p); else { int corner = 16 + 3*handleSize/2; if (p.x() >= (width() - corner)) m = PositionBottomRight; else if (p.x() <= corner) m = PositionBottomLeft; else m = PositionBottom; } return m; }
City *CityList::getNearestCity(int w, int h, int offset, int x, int y, TQPoint &where) { City *result = 0; double dist = 1.0e10; TQPtrListIterator<City> it(_cities); for ( ; it.current(); ++it) { TQPoint pos = getPosition(it.current()->latitude(), it.current()->longitude(), w, h, offset); double d = (pos.x()-x)*(pos.x()-x) + (pos.y()-y)*(pos.y()-y); if (d < dist) { dist = d; where = pos; result = it.current(); } } return result; }
TQDragObject *KFileDetailView::dragObject() { // create a list of the URL:s that we want to drag KURL::List urls; KFileItemListIterator it( * KFileView::selectedItems() ); for ( ; it.current(); ++it ){ urls.append( (*it)->url() ); } TQPixmap pixmap; if( urls.count() > 1 ) pixmap = DesktopIcon( "tdemultiple", TDEIcon::SizeSmall ); if( pixmap.isNull() ) pixmap = currentFileItem()->pixmap( TDEIcon::SizeSmall ); TQPoint hotspot; hotspot.setX( pixmap.width() / 2 ); hotspot.setY( pixmap.height() / 2 ); TQDragObject* myDragObject = new KURLDrag( urls, widget() ); myDragObject->setPixmap( pixmap, hotspot ); return myDragObject; }
void EvaLVToolTip::maybeTip(const TQPoint &p) { EvaListViewItem *item = dynamic_cast<EvaListViewItem *>(m_lv->itemAt(p)); if(!item) return; int section = m_lv->header()->sectionAt(p.x()); TQRect itemRect = m_lv->itemRect(item); TQRect headerRect = m_lv->header()->sectionRect(section); TQRect destRect(headerRect.left(), itemRect.top(), headerRect.width(), itemRect.height()); tip(destRect, item->tip()); }
void MenuManager::popupKMenu(const TQPoint &p) { if (m_kmenu->isVisible()) { m_kmenu->hide(); } else if (p.isNull()) { m_kmenu->popup(TQCursor::pos()); } else { m_kmenu->popup( p ); } }
void DraggableMonitor::mouseMoveEvent(TQMouseEvent *event) { TQPoint mousePos = event->pos(); TQPoint mouseMove = TQPoint(mousePos.x() - lastMousePosition.x(), mousePos.y() - lastMousePosition.y()); int moveToX = x()+mouseMove.x(); int moveToY = y()+mouseMove.y(); int maxX = parentWidget()->width() - width() - 1; int maxY = parentWidget()->height() - height() - 1; if (moveToX < 1) moveToX = 1; if (moveToY < 1) moveToY = 1; if (moveToX > maxX) moveToX = maxX; if (moveToY > maxY) moveToY = maxY; if (!is_primary) move(moveToX, moveToY); }
Decoration::MousePosition Decoration::mousePosition( const TQPoint& p ) const { const int range = 16; const int border = 4; MousePosition m = Nowhere; int width = widget()->width(); int height = widget()->height(); if ( ( p.x() > border && p.x() < width - border ) && ( p.y() > border && p.y() < height - border ) ) return Center; if ( p.y() <= range && p.x() <= range) m = TopLeft2; else if ( p.y() >= height-range && p.x() >= width-range) m = BottomRight2; else if ( p.y() >= height-range && p.x() <= range) m = BottomLeft2; else if ( p.y() <= range && p.x() >= width-range) m = TopRight2; else if ( p.y() <= border ) m = Top; else if ( p.y() >= height-border ) m = Bottom; else if ( p.x() <= border ) m = Left; else if ( p.x() >= width-border ) m = Right; else m = Center; return m; }
void QuickLauncher::refreshContents() { int idim, d(dimension()); // make sure show desktop setting is honored TQStringList urls, volatileUrls; ButtonIter iter = m_buttons->begin(); while (iter != m_buttons->end()) { if ((*iter)->sticky() == false) { volatileUrls.append((*iter)->menuId()); } urls.append((*iter)->menuId()); ++iter; } if (m_settings->showDesktopEnabled()) { if (!urls.contains("SPECIAL_BUTTON__SHOW_DESKTOP")) { urls.prepend("SPECIAL_BUTTON__SHOW_DESKTOP"); addApp("SPECIAL_BUTTON__SHOW_DESKTOP", 0, true); } } else { if (urls.contains("SPECIAL_BUTTON__SHOW_DESKTOP")) { urls.remove("SPECIAL_BUTTON__SHOW_DESKTOP"); removeApp("SPECIAL_BUTTON__SHOW_DESKTOP", true); } } // determine button size if (m_settings->iconDim() == SIZE_AUTO) { if (d < 18) { idim = std::min(16,d); } else if (d < 64) { idim = 16; } else if (d < 80) { idim = 20; } else if (d < 122) { idim = 24; } else { idim = 28; } } else { idim = std::min(m_settings->iconDim(), d - std::max((d/8)-1, 0) * 2); } m_space = std::max((idim/8)-1, 0); m_border = m_space; m_buttonSize = TQSize(idim, idim); m_manager->setOrientation(orientation()); m_manager->setNumItems(m_buttons->size()); m_manager->setFrameSize(size()); m_manager->setItemSize(m_buttonSize); m_manager->setSpaceSize(TQSize(m_space, m_space)); m_manager->setBorderSize(TQSize(m_border, m_border)); if (!m_refreshEnabled) { m_needsRefresh=true; return; } if (!m_manager->isValid()) { kdDebug()<<endl<<"******WARNING****** Layout is invalid."<< endl << flush; m_manager->dump(); return; } unsigned index; TQPoint pos; setUpdatesEnabled(false); m_buttons->setUpdatesEnabled(false); for (index = 0; index < m_buttons->size(); index++) { pos = m_manager->pos(index); QuickButton *button = (*m_buttons)[index]; button->resize(m_manager->itemSize()); button->move(pos.x(), pos.y()); button->setDragging(false); button->setEnableDrag(isDragEnabled()); button->setDynamicModeEnabled(m_settings->autoAdjustEnabled()); } if (m_newButtons) { m_newButtons->setDragging(false); } if (m_dragButtons) { m_dragButtons->setDragging(true); } m_buttons->show(); setUpdatesEnabled(true); update(); m_buttons->setUpdatesEnabled(true); updateGeometry(); emit updateLayout(); updateStickyHighlightLayer(); }