Add wxDisplay::GetFromRect()
For now this is just the same thing as GetFromPoint(center-of-rectangle) but it's already more convenient to use and it will also be changed in the upcoming commits.
This commit is contained in:
parent
d39aac0fa8
commit
0da3f1c11f
4 changed files with 32 additions and 3 deletions
|
|
@ -67,6 +67,10 @@ public:
|
|||
// it doesn't belong to any display
|
||||
static int GetFromPoint(const wxPoint& pt);
|
||||
|
||||
// find the display which has the biggest intersection with the given
|
||||
// rectangle or wxNOT_FOUND if the rectangle doesn't intersect any display
|
||||
static int GetFromRect(const wxRect& rect);
|
||||
|
||||
// find the display where the given window lies, return wxNOT_FOUND if it
|
||||
// is not shown at all
|
||||
static int GetFromWindow(const wxWindow *window);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@ public:
|
|||
// return the display for the given point or wxNOT_FOUND
|
||||
virtual int GetFromPoint(const wxPoint& pt) = 0;
|
||||
|
||||
// return the display with biggest intersection with the given rectangle or
|
||||
// wxNOT_FOUND
|
||||
virtual int GetFromRect(const wxRect& rect);
|
||||
|
||||
// return the display for the given window or wxNOT_FOUND
|
||||
//
|
||||
// the window pointer must not be null (i.e. caller should check it)
|
||||
|
|
|
|||
|
|
@ -94,6 +94,18 @@ public:
|
|||
*/
|
||||
static int GetFromPoint(const wxPoint& pt);
|
||||
|
||||
/**
|
||||
Returns the index of the display with biggest intersection with the
|
||||
given rectangle or @c wxNOT_FOUND if the rectangle doesn't intersect
|
||||
any display.
|
||||
|
||||
@param rect
|
||||
The rectangle to check.
|
||||
|
||||
@since 3.3.0
|
||||
*/
|
||||
static int GetFromRect(const wxRect& rect);
|
||||
|
||||
/**
|
||||
Returns the index of the display on which the given window lies.
|
||||
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ wxDisplay::wxDisplay(const wxWindow* window)
|
|||
return Factory().GetFromPoint(pt);
|
||||
}
|
||||
|
||||
/* static */ int wxDisplay::GetFromRect(const wxRect& rect)
|
||||
{
|
||||
return Factory().GetFromRect(rect);
|
||||
}
|
||||
|
||||
/* static */ int wxDisplay::GetFromWindow(const wxWindow *window)
|
||||
{
|
||||
wxCHECK_MSG( window, wxNOT_FOUND, wxT("invalid window") );
|
||||
|
|
@ -241,6 +246,12 @@ wxDisplayImpl* wxDisplayFactory::GetPrimaryDisplay()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int wxDisplayFactory::GetFromRect(const wxRect& r)
|
||||
{
|
||||
// consider that the window belongs to the display containing its centre
|
||||
return GetFromPoint(wxPoint(r.x + r.width/2, r.y + r.height/2));
|
||||
}
|
||||
|
||||
int wxDisplayFactory::GetFromWindow(const wxWindow *window)
|
||||
{
|
||||
wxCHECK_MSG( window, wxNOT_FOUND, "window can't be null" );
|
||||
|
|
@ -252,9 +263,7 @@ int wxDisplayFactory::GetFromWindow(const wxWindow *window)
|
|||
if ( !window->GetHandle() )
|
||||
return wxNOT_FOUND;
|
||||
|
||||
// consider that the window belongs to the display containing its centre
|
||||
const wxRect r(window->GetScreenRect());
|
||||
return GetFromPoint(wxPoint(r.x + r.width/2, r.y + r.height/2));
|
||||
return GetFromRect(window->GetScreenRect());
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue