HRESULT DockPanel_OnSize(DOCKPANEL *dpp) { if(dpp->fDocked == FALSE) { RECT rect;//, rect2; // get the new client-area, and subtract any borders/splitter // to get the working area GetClientRect(dpp->hwndPanel, &rect); //GetClientRect(dpp->hwndPanel, &rect2); if(!IsRectEmpty(&rect)) AdjustRectBorders(dpp, &rect, -1); //TRACEA("WM_SIZE: client=%d %d %d %d adjusted=%d %d %d %d\n", // rect2.left, rect2.top, rect2.right, rect2.bottom, // rect.left, rect.top, rect.right, rect.bottom // ); dpp->FloatSize.cx = RectWidth(&rect); dpp->FloatSize.cy = RectHeight(&rect); } PositionContent(dpp); return 0; }
LRESULT DockPanel_OnMouseMove(DOCKPANEL *dpp, int x, int y) { // make the splitter-bar work if(dpp->fSplitting) { SIZE oldsize = dpp->DockSize; if(dpp->dwStyle & DWS_DOCKED_TOP) { dpp->DockSize.cy = y; } else if(dpp->dwStyle & DWS_DOCKED_BOTTOM) { dpp->DockSize.cy -= y; } else if(dpp->dwStyle & DWS_DOCKED_RIGHT) { dpp->DockSize.cx -= x; } else if(dpp->dwStyle & DWS_DOCKED_LEFT) { dpp->DockSize.cx = x; } if(dpp->DockSize.cy < 4) dpp->DockSize.cy = 4; if(dpp->DockSize.cx < 4) dpp->DockSize.cx = 4; if(oldsize.cx != dpp->DockSize.cx || oldsize.cy != dpp->DockSize.cy) { PositionContent(dpp); SendFakeWMSize(dpp->hwndMain); InvalidateRect(dpp->hwndMain, 0, TRUE); InvalidateRect(dpp->hwndPanel, 0, TRUE); UpdateWindow(dpp->hwndMain); } } // should we detach this tab from the current dockpanel // and float it as a new window? else if(dpp->fUndockNextMsg) { DragOff(dpp); } return 0; }
void SizeToContent(DOCKPANEL *dwp) { RECT rect = { 0,0,0,0 }, rect2; int x = 0, y = 0; if(dwp->hwndPanel == 0 || dwp->hwndContents == 0) return; if(dwp->DockSize.cx == 0 || (dwp->dwStyle & DWS_FIXED_HORZ)) dwp->DockSize.cx = GetWindowWidth(dwp->hwndContents); if(dwp->FloatSize.cx == 0 || (dwp->dwStyle & DWS_FIXED_HORZ)) dwp->FloatSize.cx = GetWindowWidth(dwp->hwndContents); if(dwp->DockSize.cy == 0 || (dwp->dwStyle & DWS_FIXED_VERT)) dwp->DockSize.cy = GetWindowHeight(dwp->hwndContents); if(dwp->FloatSize.cy == 0 || (dwp->dwStyle & DWS_FIXED_VERT)) dwp->FloatSize.cy = GetWindowHeight(dwp->hwndContents); if(dwp->fDocked) { rect.right = dwp->DockSize.cx; rect.bottom = dwp->DockSize.cy; } else { rect.right = dwp->FloatSize.cx; rect.bottom = dwp->FloatSize.cy; } CopyRect(&rect2, &rect); AdjustRectBorders(dwp, &rect, 1); TRACEA("SizeToContent: client=%d %d %d %d adjusted=%d %d %d %d\n", rect2.left, rect2.top, rect2.right, rect2.bottom, rect.left, rect.top, rect.right, rect.bottom ); if(!dwp->fDocked) CalcFloatingRect(dwp->hwndPanel, &rect); SetWindowSize(dwp->hwndPanel, RectWidth(&rect), RectHeight(&rect), NULL); PositionContent(dwp); }
void NervStandardPanel::BindContent(std::unique_ptr<NervContentWindow> in_content){ if (content){ content->UnbindCallback(NervEvent::MouseScroll); content->UnbindCallback(NervEvent::SizeChanged); content->UnbindCallback(NervEvent::SizeLimitChanged); } content = std::move(in_content); content->SetParent(*this); content->BindCallback(NervEvent::MouseScroll, std::make_unique<NervCallback>([this](void*){ SetFocus(hwnd); })); content->BindCallback(NervEvent::SizeLimitChanged, std::make_unique<NervCallback>([this](void*){ OnContentSizeChanged(); })); PositionContent(*content.get()); content->Show(); }
void DockWindow(DOCKPANEL *dpp) { HWND hwndOld = dpp->hwndPanel; dpp->fDocked = !dpp->fDocked; if(dpp->hwndPanel == 0) return; DockWnd_CreatePanel(dpp); PositionContent(dpp); SendFakeWMSize(dpp->hwndMain); // blah DockPanel_NotifyParent(dpp, DWN_DOCKCHANGE, 0); DestroyWindow(hwndOld); ShowWindow(dpp->hwndPanel, SW_SHOW); }
BOOL DockWnd_ShowInternal2(DOCKWND *dwp) { DOCKPANEL *dpp = dwp->pDockPanel; HWND hwndOldContent = dpp->hwndContents; // // Create containing panel if necessary // (it might already be visible if another tab is open) // if(dpp->hwndPanel == 0) { DockWnd_CreatePanel(dpp); } // // Create the user-contents if necessary // if(dwp->hwndContents == 0) { HKEY hSubKey = DockWnd_GetKey(dpp->hwndMain, KEY_READ, dwp->uWndId); // ask the parent of the panel to create the content DockWnd_CreateContent(dpp, dwp, hSubKey); RegCloseKey(hSubKey); } // if it's not already visible... if(hwndOldContent != dpp->hwndContents || dwp->hwndContents != dpp->hwndContents) { if(hwndOldContent == 0) hwndOldContent = dpp->hwndContents; ShowWindow(hwndOldContent, SW_HIDE);//dpp->hwndContents, SW_HIDE); dpp->hwndContents = dwp->hwndContents; ShowWindow(dwp->hwndContents, SW_SHOW); InvalidateRect(dpp->hwndPanel, 0, 0); } //SetRect(&rect, dpp->xpos, dpp->ypos, dpp-> //if(IsRectEmpty( PositionContent(dpp); ShowWindow(dwp->hwndContents, SW_SHOW); // only show if it's floating; the main window resizing will cause // any docked windows to be shown if(dpp->fDocked == FALSE) { // DeferWindowPos if the HDWP is set if(dpp->pDockServer->fDeferShowWindow) { dpp->uDeferShowCmd = SW_SHOW; } else { ShowWindow(dpp->hwndPanel, SW_SHOW); //dpp->pDockServer->hdwp = ShowHideWindow(dpp->hwndPanel, SW_SHOW, dpp->pDockServer->hdwp); } // } dpp->fVisible = TRUE; dwp->fVisible = TRUE; dpp->uCurrentTabId = dwp->uWndId; UpdateDockTabView(dpp); return TRUE; }