mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
CtrlCore: Fixed minor problem with custom bar geometry in Win32
This commit is contained in:
parent
d4b318922b
commit
c237e6baab
4 changed files with 40 additions and 18 deletions
|
|
@ -45,6 +45,9 @@ protected:
|
||||||
void Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow);
|
void Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow);
|
||||||
Image DoMouse(int e, Point p, int zd = 0);
|
Image DoMouse(int e, Point p, int zd = 0);
|
||||||
|
|
||||||
|
Rect AdjustWindowRect(const Rect& client, dword style, dword exstyle);
|
||||||
|
Rect AdjustWindowRect(const Rect& client);
|
||||||
|
|
||||||
void PaintWinBarBackground(SystemDraw& w, const Rect& clip);
|
void PaintWinBarBackground(SystemDraw& w, const Rect& clip);
|
||||||
void PaintWinBar(SystemDraw& w, const Rect& clip);
|
void PaintWinBar(SystemDraw& w, const Rect& clip);
|
||||||
int GetActiveTitleBarButton();
|
int GetActiveTitleBarButton();
|
||||||
|
|
|
||||||
|
|
@ -896,16 +896,8 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
||||||
MINMAXINFO *mmi = (MINMAXINFO *)lParam;
|
MINMAXINFO *mmi = (MINMAXINFO *)lParam;
|
||||||
Rect frmrc = Size(200, 200);
|
Rect frmrc = Size(200, 200);
|
||||||
::AdjustWindowRect(frmrc, WS_OVERLAPPEDWINDOW, FALSE);
|
::AdjustWindowRect(frmrc, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
// Size msz = Ctrl::GetWorkArea().Deflated(-frmrc.left, -frmrc.top,
|
Rect minr = AdjustWindowRect(Rect(Point(50, 50), GetMinSize()));
|
||||||
// frmrc.right - 200, frmrc.bottom - 200).GetSize();
|
Rect maxr = AdjustWindowRect(Rect(Point(50, 50), GetMaxSize()));
|
||||||
// Rect minr(Point(50, 50), min(msz, GetMinSize()));
|
|
||||||
// Rect maxr(Point(50, 50), min(msz, GetMaxSize())); // Removed cxl&nixnixnix 2012-6-12
|
|
||||||
Rect minr(Point(50, 50), GetMinSize());
|
|
||||||
Rect maxr(Point(50, 50), GetMaxSize());
|
|
||||||
dword style = ::GetWindowLong(hwnd, GWL_STYLE);
|
|
||||||
dword exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
|
||||||
AdjustWindowRectEx(minr, style, FALSE, exstyle);
|
|
||||||
AdjustWindowRectEx(maxr, style, FALSE, exstyle);
|
|
||||||
mmi->ptMinTrackSize = Point(minr.Size());
|
mmi->ptMinTrackSize = Point(minr.Size());
|
||||||
mmi->ptMaxTrackSize = Point(maxr.Size());
|
mmi->ptMaxTrackSize = Point(maxr.Size());
|
||||||
LLOG("WM_GETMINMAXINFO: MinTrackSize = " << Point(mmi->ptMinTrackSize) << ", MaxTrackSize = " << Point(mmi->ptMaxTrackSize));
|
LLOG("WM_GETMINMAXINFO: MinTrackSize = " << Point(mmi->ptMinTrackSize) << ", MaxTrackSize = " << Point(mmi->ptMaxTrackSize));
|
||||||
|
|
|
||||||
|
|
@ -472,14 +472,40 @@ void Ctrl::UseImmersiveDarkModeForWindowBorder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect Ctrl::AdjustWindowRect(const Rect& client, dword style, dword exstyle)
|
||||||
|
{
|
||||||
|
Rect r = client;
|
||||||
|
TopWindow *tw = dynamic_cast<TopWindow *>(this);
|
||||||
|
if(tw && tw->custom_bar_frame) {
|
||||||
|
Rect mr(100, 100, 200, 200);
|
||||||
|
AdjustWindowRectEx(mr, style, FALSE, exstyle);
|
||||||
|
|
||||||
|
r.left -= (100 - mr.left);
|
||||||
|
r.right += (mr.right - 200);
|
||||||
|
r.bottom += (mr.bottom - 200);
|
||||||
|
|
||||||
|
r.top -= tw->GetCustomTitleBarMetrics().height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AdjustWindowRectEx(r, style, FALSE, exstyle);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect Ctrl::AdjustWindowRect(const Rect& client)
|
||||||
|
{
|
||||||
|
HWND hwnd = GetHWND();
|
||||||
|
return hwnd ? AdjustWindowRect(client, ::GetWindowLong(hwnd, GWL_STYLE), ::GetWindowLong(hwnd, GWL_EXSTYLE))
|
||||||
|
: client;
|
||||||
|
}
|
||||||
|
|
||||||
void Ctrl::Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow)
|
void Ctrl::Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow)
|
||||||
{
|
{
|
||||||
GuiLock __;
|
GuiLock __;
|
||||||
ASSERT_(IsMainThread(), "Window creation can only happen in the main thread");
|
ASSERT_(IsMainThread(), "Window creation can only happen in the main thread");
|
||||||
LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << LOG_BEGIN);
|
LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << LOG_BEGIN);
|
||||||
ASSERT(!IsChild() && !IsOpen());
|
ASSERT(!IsChild() && !IsOpen());
|
||||||
Rect r = GetRect();
|
Rect r = AdjustWindowRect(GetRect(), style, exstyle);
|
||||||
AdjustWindowRectEx(r, style, FALSE, exstyle);
|
|
||||||
isopen = true;
|
isopen = true;
|
||||||
Top *top = new Top;
|
Top *top = new Top;
|
||||||
SetTop(top);
|
SetTop(top);
|
||||||
|
|
@ -1100,9 +1126,7 @@ void Ctrl::WndSetPos(const Rect& rect)
|
||||||
LLOG("WndSetPos " << UPP::Name(this) << " " << rect);
|
LLOG("WndSetPos " << UPP::Name(this) << " " << rect);
|
||||||
HWND hwnd = GetHWND();
|
HWND hwnd = GetHWND();
|
||||||
if(hwnd) {
|
if(hwnd) {
|
||||||
Rect r = rect;
|
Rect r = AdjustWindowRect(rect);
|
||||||
AdjustWindowRectEx(r, ::GetWindowLong(hwnd, GWL_STYLE), FALSE,
|
|
||||||
::GetWindowLong(hwnd, GWL_EXSTYLE));
|
|
||||||
SetWindowPos(hwnd, NULL, r.left, r.top, r.Width(), r.Height(),
|
SetWindowPos(hwnd, NULL, r.left, r.top, r.Width(), r.Height(),
|
||||||
SWP_NOACTIVATE|SWP_NOZORDER);
|
SWP_NOACTIVATE|SWP_NOZORDER);
|
||||||
if(HasFocusDeep()) {
|
if(HasFocusDeep()) {
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ struct App : public TopWindow
|
||||||
struct App2 : App {
|
struct App2 : App {
|
||||||
Label title;
|
Label title;
|
||||||
|
|
||||||
App2() {
|
App2(int h = GetStdFontCy() + DPI(4)) {
|
||||||
SetRect(700, 200, 500, 500);
|
SetRect(700, 200, 500, 500);
|
||||||
Ctrl *tb = CustomTitleBar(SYellow(), GetStdFontCy() + DPI(4));
|
Ctrl *tb = CustomTitleBar(SYellow(), h);
|
||||||
if(tb)
|
if(tb)
|
||||||
*tb << title.SizePos();
|
*tb << title.SizePos();
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ struct App2 : App {
|
||||||
GUI_APP_MAIN
|
GUI_APP_MAIN
|
||||||
{
|
{
|
||||||
App app, app_csd;
|
App app, app_csd;
|
||||||
App2 app2;
|
App2 app2, app3(DPI(128));
|
||||||
|
|
||||||
app.Title("SSD");
|
app.Title("SSD");
|
||||||
app.OpenMain();
|
app.OpenMain();
|
||||||
|
|
@ -85,5 +85,8 @@ GUI_APP_MAIN
|
||||||
|
|
||||||
app2.OpenMain();
|
app2.OpenMain();
|
||||||
|
|
||||||
|
app3.SetRect(1900, 200, 500, 500);
|
||||||
|
app3.OpenMain();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue