PRectangle Window::GetMonitorRect(Point pt) { QPoint qpt = PWindow(wid)->mapToGlobal(QPoint(pt.x, pt.y)); QRect qr = QApplication::desktop()->availableGeometry(qpt); qpt = PWindow(wid)->mapFromGlobal(qr.topLeft()); return PRectangle(qpt.x(), qpt.y(), qpt.x() + qr.width(), qpt.y() + qr.height()); }
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's window coordinates */ PRectangle Window::GetMonitorRect(Point pt) { QPoint originGlobal = window(wid)->mapToGlobal(QPoint(0, 0)); QPoint posGlobal = window(wid)->mapToGlobal(QPoint(pt.x, pt.y)); QDesktopWidget *desktop = QApplication::desktop(); QRect rectScreen = desktop->availableGeometry(posGlobal); rectScreen.moveLeft(-originGlobal.x()); rectScreen.moveTop(-originGlobal.y()); return PRectangle(rectScreen.left(), rectScreen.top(), rectScreen.right(), rectScreen.bottom()); }
// Returns rectangle of monitor pt is on PRectangle Window::GetMonitorRect(Point pt) { wxRect rect; if (! wid) return PRectangle(); #if wxUSE_DISPLAY // Get the display the point is found on int n = wxDisplay::GetFromPoint(wxPoint(pt.x, pt.y)); wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); rect = dpy.GetGeometry(); #else wxUnusedVar(pt); #endif return PRectangleFromwxRect(rect); }
PRectangle ListBoxImpl::GetDesiredRect() { ListWidget *list = static_cast<ListWidget *>(wid); int rows = Length(); if (rows == 0 || rows > visibleRows) { rows = visibleRows; } int rowHeight = list->sizeHintForRow(0); int height = (rows * rowHeight) + (2 * list->frameWidth()); QStyle *style = QApplication::style(); int width = list->sizeHintForColumn(0) + (2 * list->frameWidth()); if (Length() > rows) { width += style->pixelMetric(QStyle::PM_ScrollBarExtent); } return PRectangle(0, 0, width, height); }
PRectangle Window::GetPosition() { // Before any size allocated pretend its 1000 wide so not scrolled return wid ? PRectFromQRect(window(wid)->frameGeometry()) : PRectangle(0, 0, 1000, 1000); }
PRectangle Window::GetMonitorRect(Point) { return PRectangle(); }
PRectangle Window::GetClientPosition() { if (! id) return PRectangle(); wxSize sz = GETWIN(id)->GetClientSize(); return PRectangle(0, 0, sz.x, sz.y); }
PRectangle Window::GetPosition() { if (! id) return PRectangle(); wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize()); return PRectangleFromwxRect(rc); }
PRectangle PRectangleFromwxRect(wxRect rc) { return PRectangle(rc.GetLeft(), rc.GetTop(), rc.GetRight()+1, rc.GetBottom()+1); }