The solution should be:
Adding CentreOnParent(); in DebuggerSettingsDlg::DebuggerSettingsDlg(), right?
It will most likely break the configuration made in "Settings -> View -> Enhanced multi-monitor placement", and if it does, these settings are ignored in trunk already.
I'm not fully understand your meaning, here is the code:
void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode, bool enforce)
{
HMONITOR hMonitor;
MONITORINFO mi;
RECT r;
int the_mode;
if (!w)
cbThrow(_T("Passed NULL pointer to PlaceWindow."));
wxWindow* referenceWindow = Manager::Get()->GetAppWindow();
if (!referenceWindow) // no application window available, so this is as good as we can get
referenceWindow = w;
wxRect windowRect = w->GetRect();
ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("app"));
if (!enforce && cfg->ReadBool(_T("/dialog_placement/do_place")) == false)
return;
if (mode == pdlBest)
the_mode = cfg->ReadInt(_T("/dialog_placement/dialog_position"), (int) pdlCentre);
else
the_mode = (int) mode;
static MonitorFromWindow_t MonitorFromWindowProc = (MonitorFromWindow_t) GetProcAddress(GetModuleHandle(_T("user32.dll")), "MonitorFromWindow");
static GetMonitorInfo_t GetMonitorInfoProc = (GetMonitorInfo_t) GetProcAddress(GetModuleHandle(_T("user32.dll")), "GetMonitorInfoA");
int monitorWidth;
int monitorHeight;
if (GetMonitorInfoProc)
{
hMonitor = MonitorFromWindowProc((HWND) referenceWindow->GetHandle(), MONITOR_DEFAULTTONEAREST);
mi.cbSize = sizeof(mi);
GetMonitorInfoProc(hMonitor, &mi);
r = mi.rcWork;
monitorWidth = r.right - r.left;
monitorHeight = r.bottom - r. top;
}
else // Win95, NT4: support only single monitor
{
wxDisplaySize(&monitorWidth, &monitorHeight);
r.left = r.top = 0;
}
switch(the_mode)
{
case pdlCentre:
{
windowRect.x = r.left + (monitorWidth - windowRect.width)/2;
windowRect.y = r.top + (monitorHeight - windowRect.height)/2;
}
break;
case pdlHead:
{
windowRect.x = r.left + (monitorWidth - windowRect.width)/2;
windowRect.y = r.top + (monitorHeight - windowRect.height)/3;
}
break;
case pdlConstrain:
{
int x1 = windowRect.x;
int x2 = windowRect.x + windowRect.width;
int y1 = windowRect.y;
int y2 = windowRect.y + windowRect.height;
if (windowRect.width > monitorWidth) // cannot place without clipping, so centre it
{
x1 = r.left + (monitorWidth - windowRect.width)/2;
x2 = x1 + windowRect.width;
}
else
{
x2 = std::min((int) r.right, windowRect.GetRight());
x1 = std::max(x2 - windowRect.width, (int) r.left);
x2 = x1 + windowRect.width;
}
if (windowRect.height > monitorHeight) // cannot place without clipping, so centre it
{
y1 = r.top + (monitorHeight - windowRect.height)/2;
y2 = y1 + windowRect.height;
}
else
{
y2 = std::min((int) r.bottom, windowRect.GetBottom());
y1 = std::max(y2 - windowRect.height, (int) r.top);
y2 = y1 + windowRect.height;
}
windowRect = wxRect(x1, y1, x2-x1, y2-y1);
}
break;
case pdlClip:
{
int x1 = windowRect.x;
int x2 = windowRect.x + windowRect.width;
int y1 = windowRect.y;
int y2 = windowRect.y + windowRect.height;
x1 = std::max(x1, (int) r.left);
x2 = std::min(x2, (int) r.right);
y1 = std::max(y1, (int) r.top);
y2 = std::min(y2, (int) r.bottom);
windowRect = wxRect(x1, y1, x2-x1, y2-y1);
}
break;
}
w->SetSize(windowRect.x, windowRect.y, windowRect.width, windowRect.height, wxSIZE_ALLOW_MINUS_ONE);
}
I do not check on any multiply-monitor related options, so this function is in fact do nothing and return from:
if (!enforce && cfg->ReadBool(_T("/dialog_placement/do_place")) == false)
return;
So, if you have "Settings -> View -> Enhanced multi-monitor placement" settings check on, this function will go further to adjust the dialog position.
I think this should be th eplace for changes:
The settings dialog, to be clear that it can be used for multimonitor systems and for single monitors, and possible the ability to centre a dialog oin the parent and not only on the screen (Changes in PlaceWindow).
Not fully understand this either. Sorry.
, you mean the dialog SHOULD be placed in the center of parent window or screen?