Keep wxSTC call tips inside the current display
Make it harder for the calltip to be invisible * This required changes to the Window::SetPositionRelative. * Use the Qt version as a base. * The idea is to confine the window to the boundaries of the display the scintilla control is at the moment of the call. Closes #18115.
This commit is contained in:
committed by
Vadim Zeitlin
parent
882c425f42
commit
4cdd3001c2
@@ -1852,8 +1852,35 @@ void Window::SetPosition(PRectangle rc) {
|
||||
GETWIN(wid)->SetSize(r);
|
||||
}
|
||||
|
||||
void Window::SetPositionRelative(PRectangle rc, Window) {
|
||||
SetPosition(rc); // ????
|
||||
void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
|
||||
wxWindow *relativeWin = GETWIN(relativeTo.wid);
|
||||
|
||||
wxPoint position = relativeWin->GetScreenPosition();
|
||||
position.x = wxRound(position.x + rc.left);
|
||||
position.y = wxRound(position.y + rc.top);
|
||||
|
||||
const int currentDisplay = wxDisplay::GetFromWindow(relativeWin);
|
||||
const wxRect displayRect = wxDisplay(currentDisplay).GetClientArea();
|
||||
|
||||
if (position.x < displayRect.GetLeft())
|
||||
position.x = displayRect.GetLeft();
|
||||
|
||||
const int width = rc.Width();
|
||||
if (width > displayRect.GetWidth())
|
||||
{
|
||||
// We want to show at least the beginning of the window.
|
||||
position.x = displayRect.GetLeft();
|
||||
}
|
||||
else if (position.x + width > displayRect.GetRight())
|
||||
position.x = displayRect.GetRight() - width;
|
||||
|
||||
const int height = rc.Height();
|
||||
if (position.y + height > displayRect.GetBottom())
|
||||
position.y = displayRect.GetBottom() - height;
|
||||
|
||||
position = relativeWin->ScreenToClient(position);
|
||||
wxWindow *window = GETWIN(wid);
|
||||
window->SetSize(position.x, position.y, width, height);
|
||||
}
|
||||
|
||||
PRectangle Window::GetClientPosition() {
|
||||
|
Reference in New Issue
Block a user