int wxSplitWindow::AdjustSashPosition(int sashPos) const { wxWindow *win; win = m_windowOne; if (win) { // the window shouldn't be smaller than its own minimal size nor // smaller than the minimual pane size specified for this splitwindow int minSize = m_splitMode == wxSPLIT_VERTICAL? win->GetMinWidth(): win->GetMinHeight(); if (minSize == -1 || m_minimumPaneSize > minSize) minSize = m_minimumPaneSize; minSize += GetBorderSize(); if (sashPos > 0 && sashPos < minSize) sashPos = minSize; } win = m_windowTwo; if (win) { int minSize = m_splitMode == wxSPLIT_VERTICAL? win->GetMinWidth(): win->GetMinHeight(); if (minSize == -1 || m_minimumPaneSize > minSize) minSize = m_minimumPaneSize; minSize += GetBorderSize(); int maxSize = GetWindowSize() - minSize - GetSashSize(); if (sashPos < GetWindowSize() && sashPos > maxSize) sashPos = maxSize; } return sashPos; }
void CComboBoxUI::PaintStatusImage(HDC hDC) { if (m_sArrowImage.IsEmpty()) CComboUI::PaintStatusImage(hDC); else { // get index if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED; else m_uButtonState &= ~ UISTATE_FOCUSED; if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED; else m_uButtonState &= ~ UISTATE_DISABLED; int nIndex = 0; if ((m_uButtonState & UISTATE_DISABLED) != 0) nIndex = 4; else if ((m_uButtonState & UISTATE_PUSHED) != 0) nIndex = 2; else if ((m_uButtonState & UISTATE_HOT) != 0) nIndex = 1; else if ((m_uButtonState & UISTATE_FOCUSED) != 0) nIndex = 3; // make modify string CDuiString sModify = m_sArrowImage; int nPos1 = sModify.Find(_T("source")); int nPos2 = sModify.Find(_T("'"), nPos1 + 7); if (nPos2 == -1) return; //first int nPos3 = sModify.Find(_T("'"), nPos2 + 1); if (nPos3 == -1) return; //second CDuiRect rcBmpPart; LPTSTR lpszValue = NULL; rcBmpPart.left = _tcstol(sModify.GetData() + nPos2 + 1, &lpszValue, 10); ASSERT(lpszValue); rcBmpPart.top = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); rcBmpPart.right = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); rcBmpPart.bottom = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); m_nArrowWidth = rcBmpPart.GetWidth() / 5; rcBmpPart.left += nIndex * m_nArrowWidth; rcBmpPart.right = rcBmpPart.left + m_nArrowWidth; CDuiRect rcDest(0, 0, m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top); rcDest.Deflate(GetBorderSize(), GetBorderSize()); rcDest.left = rcDest.right - m_nArrowWidth; CDuiString sSource = sModify.Mid(nPos1, nPos3 + 1 - nPos1); CDuiString sReplace; sReplace.SmallFormat(_T("source='%d,%d,%d,%d' dest='%d,%d,%d,%d'"), rcBmpPart.left, rcBmpPart.top, rcBmpPart.right, rcBmpPart.bottom, rcDest.left, rcDest.top, rcDest.right, rcDest.bottom); sModify.Replace(sSource, sReplace); // draw image if (!DrawImage(hDC, m_sArrowImage, sModify)) m_sNormalImage.Empty(); } }
void IFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) { rtEdge = m_pProperties->m_rtWidget; rtEdge.left = rtEdge.top = 0; if (HasBorder()) { FX_FLOAT fCX = GetBorderSize(); FX_FLOAT fCY = GetBorderSize(false); rtEdge.Deflate(fCX, fCY); } }
/** Process a button event. */ void HandleButtonEvent(const XButtonEvent *event) { ClientNode *np; int north, south, east, west; np = FindClientByParent(event->window); if(np) { if(event->type == ButtonPress) { FocusClient(np); RaiseClient(np); } DispatchBorderButtonEvent(event, np); } else if(event->window == rootWindow && event->type == ButtonPress) { if(!ShowRootMenu(event->button, event->x, event->y, 0)) { if(event->button == Button4) { LeftDesktop(); } else if(event->button == Button5) { RightDesktop(); } } } else { const unsigned int mask = event->state & ~lockMask; np = FindClientByWindow(event->window); if(np) { switch(event->button) { case Button1: case Button2: FocusClient(np); RaiseClient(np); if(mask == Mod1Mask) { GetBorderSize(&np->state, &north, &south, &east, &west); MoveClient(np, event->x + west, event->y + north); } break; case Button3: if(mask == Mod1Mask) { GetBorderSize(&np->state, &north, &south, &east, &west); ResizeClient(np, BA_RESIZE | BA_RESIZE_E | BA_RESIZE_S, event->x + west, event->y + north); } else { FocusClient(np); RaiseClient(np); } break; default: break; } JXAllowEvents(display, ReplayPointer, eventTime); } } }
/** Constrain the position of a client. */ void ConstrainPosition(ClientNode *np) { BoundingBox box; int north, south, east, west; /* Get the bounds for placement. */ box.x = 0; box.y = 0; box.width = rootWidth; box.height = rootHeight; SubtractTrayBounds(GetTrays(), &box, np->state.layer); SubtractStrutBounds(&box, np); /* Fix the position. */ GetBorderSize(&np->state, &north, &south, &east, &west); if(np->x + np->width + east + west > box.x + box.width) { np->x = box.x + box.width - np->width - east; } if(np->y + np->height + north + south > box.y + box.height) { np->y = box.y + box.height - np->height - south; } if(np->x < box.x + west) { np->x = box.x + west; } if(np->y < box.y + north) { np->y = box.y + north; } }
void cdxCDynamicWnd::DoOnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { if(IsWindow() && !IsDisabled()) { CSize szDelta = GetBorderSize(); lpMMI->ptMinTrackSize.x = m_szMin.cx + szDelta.cx; lpMMI->ptMinTrackSize.y = m_szMin.cy + szDelta.cy; if(m_Freedom & fdHoriz) { if(m_szMax.cx > 0) lpMMI->ptMaxTrackSize.x = m_szMax.cx + szDelta.cx; } else lpMMI->ptMaxTrackSize.x = lpMMI->ptMinTrackSize.x; if(m_Freedom & fdVert) { if(m_szMax.cy > 0) lpMMI->ptMaxTrackSize.y = m_szMax.cy + szDelta.cy; } else lpMMI->ptMaxTrackSize.y = lpMMI->ptMinTrackSize.y; } }
void CComboBoxUI::PaintStatusImage(HDC hDC) { if (m_sArrowImage.IsEmpty()) CComboUI::PaintStatusImage(hDC); else { // get index if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED; else m_uButtonState &= ~ UISTATE_FOCUSED; if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED; else m_uButtonState &= ~ UISTATE_DISABLED; int nIndex = 0; if ((m_uButtonState & UISTATE_DISABLED) != 0) nIndex = 4; else if ((m_uButtonState & UISTATE_PUSHED) != 0) nIndex = 2; else if ((m_uButtonState & UISTATE_HOT) != 0) nIndex = 1; else if ((m_uButtonState & UISTATE_FOCUSED) != 0) nIndex = 3; CDuiRect rcBmpPart(m_sArrowImage.GetSource()); m_nArrowWidth = rcBmpPart.GetWidth() / 5; rcBmpPart.left += nIndex * m_nArrowWidth; rcBmpPart.right = rcBmpPart.left + m_nArrowWidth; CDuiRect rcDest(0, 0, m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top); rcDest.Deflate(GetBorderSize(), GetBorderSize()); rcDest.left = rcDest.right - m_nArrowWidth; // draw image if (!DrawImage(hDC, m_sArrowImage)) m_sNormalImage.Empty(); else { DrawImage(hDC, m_sArrowImage,rcBmpPart); DrawImage(hDC, m_sArrowImage,rcDest); } } }
//********************************************************************************************************* void CBCGPBaseFilterPopupMenu::RecalcLayout(BOOL bNotify /* = TRUE */) { CBCGPPopupMenu::RecalcLayout(bNotify); if (m_wndMenuBar.GetSafeHwnd() != NULL) { m_wndMenuBar.m_arColumns.RemoveAll(); m_wndMenuBar.AdjustLayout(); } if (m_wndList.GetSafeHwnd() == NULL) { return; } const int nShadowSize = CBCGPToolBar::IsCustomizeMode () ? 0 : m_iShadowSize; const int nBorderSize = GetBorderSize(); CRect rectClient; GetClientRect(rectClient); rectClient.DeflateRect (nBorderSize, nBorderSize); if (GetExStyle() & WS_EX_LAYOUTRTL) { rectClient.left += nShadowSize; } else { rectClient.right -= nShadowSize; } rectClient.top += m_nMenuBarHeight; rectClient.bottom -= nShadowSize; #ifndef _BCGSUITE_ rectClient.left += m_wndMenuBar.GetGutterWidth(); #endif if (!m_rectResize.IsRectEmpty()) { if (m_bIsResizeBarOnTop) { rectClient.top += m_rectResize.Height(); } else { rectClient.bottom -= m_rectResize.Height(); } } m_wndList.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), SWP_NOZORDER | SWP_NOACTIVATE); m_wndList.m_bIsEmptyMenu = GetMenuItemCount() == 0; }
wxSize wxSplitWindow::DoGetBestSize() const { // get best sizes of subwindows wxSize size1, size2; size1.x = 0; size1.y = 0; size2.x = 0; size2.y = 0; if (m_windowOne) size1 = m_windowOne->GetEffectiveMinSize(); if (m_windowTwo) size2 = m_windowTwo->GetEffectiveMinSize(); // sum them up wxSize sizeBest; if (m_splitMode == wxSPLIT_VERTICAL) { sizeBest.x = wxMax(size1.x, m_minimumPaneSize) + wxMax(size2.x, m_minimumPaneSize); sizeBest.y = wxMax(size1.y, size2.y); sizeBest.x += GetSashSize(); }else{ // wxSPLIT_HORIZONTAL sizeBest.x = wxMax(size1.x, size2.x); sizeBest.y = wxMax(size1.y, m_minimumPaneSize) + wxMax(size2.y, m_minimumPaneSize); sizeBest.y += GetSashSize(); } sizeBest.x += 2*GetBorderSize(); sizeBest.y += 2*GetBorderSize(); return sizeBest; }
/** Determine which way to move the client for the border. */ void GetGravityDelta(const ClientNode *np, int gravity, int *x, int *y) { int north, south, east, west; GetBorderSize(&np->state, &north, &south, &east, &west); switch(gravity) { case NorthWestGravity: *y = -north; *x = -west; break; case NorthGravity: *y = -north; *x = (west - east) / 2; break; case NorthEastGravity: *y = -north; *x = west; break; case WestGravity: *x = -west; *y = (north - south) / 2; break; case CenterGravity: *y = (north - south) / 2; *x = (west - east) / 2; break; case EastGravity: *x = west; *y = (north - south) / 2; break; case SouthWestGravity: *y = south; *x = -west; break; case SouthGravity: *x = (west - east) / 2; *y = south; break; case SouthEastGravity: *y = south; *x = west; break; default: /* Static */ *x = 0; *y = 0; break; } }
void IFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { if (!bAutoSize) { rect = m_pProperties->m_rtWidget; return; } if (HasEdge()) { FX_FLOAT fEdge = GetEdgeWidth(); rect.Inflate(fEdge, fEdge); } if (HasBorder()) { FX_FLOAT fBorder = GetBorderSize(); rect.Inflate(fBorder, fBorder); } }
bool cdxCDynamicWndEx::StretchWindow(int iAddPcnt) { if(!IsWindow()) { ASSERT(false); return false; } CSize szDelta = GetCurrentClientSize() + GetBorderSize(); szDelta.cx = (szDelta.cx * iAddPcnt) / 100; szDelta.cy = (szDelta.cy * iAddPcnt) / 100; return StretchWindow(szDelta); }
void CBaseContainerNode::DrawGrabIcon() { const float bSize = GetBorderSize(); surface()->DrawSetColor( Color( 192, 192, 192, 255 ) ); surface()->DrawSetTexture( m_iGrabIcon ); Vector2D icooffset( -GRABICO_OFFSET, GRABICO_OFFSET ); Vector2D gi_max = Vector2D( GetContainerMaxs().x, GetContainerMins().y ) + icooffset; Vector2D gi_min = gi_max + Vector2D( -bSize, bSize ); pNodeView->ToPanelSpace( gi_max ); pNodeView->ToPanelSpace( gi_min ); surface()->DrawTexturedRect( gi_min.x, gi_min.y, gi_max.x, gi_max.y ); }
Vector2D CBaseContainerNode::GetContainerBorderMin( int mode ) { Vector2D out; Vector2D center = GetCenter(); center.x = GetBoundsMaxNodeSpace().x; const float bSize = GetBorderSize(); switch ( mode ) { default: Assert( 0 ); case CBORDER_TOP_LEFT: out.x = center.x; out.y = center.y + m_vecContainerExtents.x - bSize; break; case CBORDER_TOP: out.x = center.x + bSize; out.y = center.y + m_vecContainerExtents.x - bSize; break; case CBORDER_TOP_RIGHT: out.x = center.x + m_vecContainerExtents.y - bSize; out.y = center.y + m_vecContainerExtents.x - bSize; break; case CBORDER_RIGHT: out.x = center.x + m_vecContainerExtents.y - bSize; out.y = center.y + m_vecContainerExtents.z + bSize; break; case CBORDER_BOTTOM_RIGHT: out.x = center.x + m_vecContainerExtents.y - bSize; out.y = center.y + m_vecContainerExtents.z; break; case CBORDER_BOTTOM: out.x = center.x + bSize; out.y = center.y + m_vecContainerExtents.z; break; case CBORDER_BOTTOM_LEFT: out.x = center.x; out.y = center.y + m_vecContainerExtents.z; break; case CBORDER_LEFT: out.x = center.x; out.y = center.y + m_vecContainerExtents.z + bSize; break; } return out; }
/** Cascade placement. */ void CascadeClient(const BoundingBox *box, ClientNode *np) { const ScreenType *sp; int north, south, east, west; int cascadeIndex; char overflow; GetBorderSize(&np->state, &north, &south, &east, &west); sp = GetMouseScreen(); cascadeIndex = sp->index * settings.desktopCount + currentDesktop; /* Set the cascaded location. */ np->x = box->x + west + cascadeOffsets[cascadeIndex]; np->y = box->y + north + cascadeOffsets[cascadeIndex]; cascadeOffsets[cascadeIndex] += settings.borderWidth + settings.titleHeight; /* Check for cascade overflow. */ overflow = 0; if(np->x + np->width - box->x > box->width) { overflow = 1; } else if(np->y + np->height - box->y > box->height) { overflow = 1; } if(overflow) { cascadeOffsets[cascadeIndex] = settings.borderWidth + settings.titleHeight; np->x = box->x + west + cascadeOffsets[cascadeIndex]; np->y = box->y + north + cascadeOffsets[cascadeIndex]; /* Check for client overflow and update cascade position. */ if(np->x + np->width - box->x > box->width) { np->x = box->x + west; } else if(np->y + np->height - box->y > box->height) { np->y = box->y + north; } else { cascadeOffsets[cascadeIndex] += settings.borderWidth + settings.titleHeight; } } ConstrainSize(np); ConstrainPosition(np); }
CSize GetBorderSize(HWND hWnd, bool dwmEnabled) { // Check for Caption DWORD dwStyle = ::GetWindowLong(hWnd, GWL_STYLE); bool caption = (dwStyle & WS_CAPTION) != 0; DWORD dwExStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE); // Get BorderMultiplierFactor int bmfactor = 0; ::SystemParametersInfo(SPI_GETBORDER, 0, &bmfactor, 0); int factor = bmfactor - 1; CSize border; if ((dwExStyle & WS_EX_CLIENTEDGE) != 0) { // Fixed3D border = GetFixedFrameBorderSize() + GetBorder3DSize(); } else if ((dwStyle & WS_THICKFRAME) != 0) { // Dialog if ((dwExStyle & WS_EX_DLGMODALFRAME) != 0) { // Dialog with WS_EX_DLGMODALFRAME has double border int cx = ::GetSystemMetrics(SM_CXDLGFRAME); int cy = ::GetSystemMetrics(SM_CYDLGFRAME); border.SetSize(cx + cx, cy + cy); } // Sizable or SizableToolWindow else if (IsVista()) border = GetFrameBorderSize(); else border = GetFixedFrameBorderSize() + (caption ? GetBorderSize() + CSize(factor, factor) : CSize(factor, factor)); } else { if (dwmEnabled) border = GetFrameBorderSize(); else border = GetFixedFrameBorderSize(); } return border; }
/** Set _NET_FRAME_EXTENTS. */ void WriteFrameExtents(Window win, const ClientState *state) { unsigned long values[4]; int north, south, east, west; GetBorderSize(state, &north, &south, &east, &west); /* left, right, top, bottom */ values[0] = west; values[1] = east; values[2] = north; values[3] = south; JXChangeProperty(display, win, atoms[ATOM_NET_FRAME_EXTENTS], XA_CARDINAL, 32, PropModeReplace, (unsigned char*)values, 4); }
/** Stop move. */ void StopMove(ClientNode *np, int doMove, int oldx, int oldy, MaxFlags maxFlags) { int north, south, east, west; Assert(np); Assert(np->controller); (np->controller)(0); np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); if(!doMove) { np->x = oldx; np->y = oldy; /* Restore maximized status. */ if(maxFlags) { MaximizeClient(np, maxFlags); } return; } GetBorderSize(&np->state, &north, &south, &east, &west); if(np->parent != None) { JXMoveWindow(display, np->parent, np->x - west, np->y - north); } else { JXMoveWindow(display, np->window, np->x - west, np->y - north); } SendConfigureEvent(np); /* Restore maximized status. */ if(maxFlags) { MaximizeClient(np, maxFlags); } }
/** Get a rectangle to represent a client window. */ void GetClientRectangle(const ClientNode *np, RectangleType *r) { int north, south, east, west; GetBorderSize(&np->state, &north, &south, &east, &west); r->left = np->x - west; r->right = np->x + np->width + east; r->top = np->y - north; if(np->state.status & STAT_SHADED) { r->bottom = np->y + south; } else { r->bottom = np->y + np->height + south; } r->valid = 1; }
void ResizeMoveCtrl(HWND hDlg, HWND hCtrl, int dx, int dy, int dw, int dh) { RECT rect; POINT point; SIZE border; GetWindowRect(hCtrl, &rect); point.x = right_to_left_mode?rect.right:rect.left; point.y = rect.top; ScreenToClient(hDlg, &point); GetClientRect(hCtrl, &rect); // If the control has any borders (dialog, edit box), take them into account border = GetBorderSize(hCtrl); MoveWindow(hCtrl, point.x + (int)(fScale*(float)dx), point.y + (int)(fScale*(float)dy), (rect.right - rect.left) + (int)(fScale*(float)dw + border.cx), (rect.bottom - rect.top) + (int)(fScale*(float)dh + border.cy), TRUE); InvalidateRect(hCtrl, NULL, TRUE); }
wxSize wxSplitterWindow::DoGetBestSize() const { // get best sizes of subwindows wxSize size1, size2; if ( m_windowOne ) size1 = m_windowOne->GetEffectiveMinSize(); if ( m_windowTwo ) size2 = m_windowTwo->GetEffectiveMinSize(); // sum them // // pSash points to the size component to which sash size must be added int *pSash; wxSize sizeBest; if ( m_splitMode == wxSPLIT_VERTICAL ) { sizeBest.y = wxMax(size1.y, size2.y); sizeBest.x = wxMax(size1.x, m_minimumPaneSize) + wxMax(size2.x, m_minimumPaneSize); pSash = &sizeBest.x; } else // wxSPLIT_HORIZONTAL { sizeBest.x = wxMax(size1.x, size2.x); sizeBest.y = wxMax(size1.y, m_minimumPaneSize) + wxMax(size2.y, m_minimumPaneSize); pSash = &sizeBest.y; } // account for the sash if the window is actually split if ( m_windowOne && m_windowTwo ) *pSash += GetSashSize(); // account for the border too int border = 2*GetBorderSize(); sizeBest.x += border; sizeBest.y += border; return sizeBest; }
/** Stop move. */ void StopMove(ClientNode *np, int doMove, int oldx, int oldy, int hmax, int vmax) { int north, south, east, west; Assert(np); Assert(np->controller); (np->controller)(0); np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); if(!doMove) { np->x = oldx; np->y = oldy; /* Restore maximized status if only maximized in one direction. */ if((hmax || vmax) && !(hmax && vmax)) { MaximizeClient(np, hmax, vmax); } return; } GetBorderSize(&np->state, &north, &south, &east, &west); JXMoveWindow(display, np->parent, np->x - west, np->y - north); SendConfigureEvent(np); /* Restore maximized status. */ if((hmax || vmax) && !(hmax && vmax)) { MaximizeClient(np, hmax, vmax); } }
/** Snap to the screen. */ void DoSnapScreen(ClientNode *np) { RectangleType client; int screen; const ScreenType *sp; int screenCount; int north, south, east, west; GetClientRectangle(np, &client); GetBorderSize(&np->state, &north, &south, &east, &west); screenCount = GetScreenCount(); for(screen = 0; screen < screenCount; screen++) { sp = GetScreen(screen); if(abs(client.right - sp->width - sp->x) <= settings.snapDistance) { np->x = sp->x + sp->width - west - np->width; } if(abs(client.left - sp->x) <= settings.snapDistance) { np->x = sp->x + east; } if(abs(client.bottom - sp->height - sp->y) <= settings.snapDistance) { np->y = sp->y + sp->height - south; if(!(np->state.status & STAT_SHADED)) { np->y -= np->height; } } if(abs(client.top - sp->y) <= settings.snapDistance) { np->y = north + sp->y; } } }
/** Move a client window. */ char MoveClient(ClientNode *np, int startx, int starty) { XEvent event; int oldx, oldy; int doMove; int north, south, east, west; int height; MaxFlags maxFlags; Assert(np); if(!(np->state.border & BORDER_MOVE)) { return 0; } if(np->state.status & STAT_FULLSCREEN) { return 0; } GrabMouseForMove(); RegisterCallback(0, SignalMove, NULL); np->controller = MoveController; shouldStopMove = 0; oldx = np->x; oldy = np->y; maxFlags = np->state.maxFlags; if(!(GetMouseMask() & (Button1Mask | Button2Mask))) { StopMove(np, 0, oldx, oldy, maxFlags); return 0; } GetBorderSize(&np->state, &north, &south, &east, &west); startx -= west; starty -= north; currentClient = np; atTop = atBottom = atLeft = atRight = 0; doMove = 0; for(;;) { WaitForEvent(&event); if(shouldStopMove) { np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); return doMove; } switch(event.type) { case ButtonRelease: if(event.xbutton.button == Button1 || event.xbutton.button == Button2) { StopMove(np, doMove, oldx, oldy, maxFlags); return doMove; } break; case MotionNotify: DiscardMotionEvents(&event, np->window); np->x = event.xmotion.x_root - startx; np->y = event.xmotion.y_root - starty; /* Get the move time used for desktop switching. */ if(!(atLeft | atTop | atRight | atBottom)) { if(event.xmotion.state & Mod1Mask) { moveTime.seconds = 0; moveTime.ms = 0; } else { GetCurrentTime(&moveTime); } } /* Determine if we are at a border for desktop switching. */ atLeft = atTop = atRight = atBottom = 0; if(event.xmotion.x_root == 0) { atLeft = 1; } else if(event.xmotion.x_root == rootWidth - 1) { atRight = 1; } if(event.xmotion.y_root == 0) { atTop = 1; } else if(event.xmotion.y_root == rootHeight - 1) { atBottom = 1; } if(event.xmotion.state & Mod1Mask) { /* Switch desktops immediately if alt is pressed. */ if(atLeft | atRight | atTop | atBottom) { TimeType now; GetCurrentTime(&now); UpdateDesktop(&now); } } else { /* If alt is not pressed, snap to borders. */ DoSnap(np); } if(!doMove && (abs(np->x - oldx) > MOVE_DELTA || abs(np->y - oldy) > MOVE_DELTA)) { if(np->state.maxFlags) { MaximizeClient(np, MAX_NONE); startx = np->width / 2; starty = -north / 2; MoveMouse(np->parent, startx, starty); } CreateMoveWindow(np); doMove = 1; } if(doMove) { if(settings.moveMode == MOVE_OUTLINE) { ClearOutline(); height = north + south; if(!(np->state.status & STAT_SHADED)) { height += np->height; } DrawOutline(np->x - west, np->y - north, np->width + west + east, height); } else { JXMoveWindow(display, np->parent, np->x - west, np->y - north); SendConfigureEvent(np); } UpdateMoveWindow(np); RequirePagerUpdate(); } break; default: break; } } }
/** Snap to window borders. */ void DoSnapBorder(ClientNode *np) { const ClientNode *tp; const TrayType *tray; RectangleType client, other; RectangleType left = { 0 }; RectangleType right = { 0 }; RectangleType top = { 0 }; RectangleType bottom = { 0 }; int layer; int north, south, east, west; GetClientRectangle(np, &client); GetBorderSize(&np->state, &north, &south, &east, &west); other.valid = 1; /* Work from the bottom of the window stack to the top. */ for(layer = 0; layer < LAYER_COUNT; layer++) { /* Check tray windows. */ for(tray = GetTrays(); tray; tray = tray->next) { if(tray->hidden) { continue; } other.left = tray->x; other.right = tray->x + tray->width; other.top = tray->y; other.bottom = tray->y + tray->height; left.valid = CheckLeftValid(&client, &other, &left); right.valid = CheckRightValid(&client, &other, &right); top.valid = CheckTopValid(&client, &other, &top); bottom.valid = CheckBottomValid(&client, &other, &bottom); if(CheckOverlapTopBottom(&client, &other)) { if(abs(client.left - other.right) <= settings.snapDistance) { left = other; } if(abs(client.right - other.left) <= settings.snapDistance) { right = other; } } if(CheckOverlapLeftRight(&client, &other)) { if(abs(client.top - other.bottom) <= settings.snapDistance) { top = other; } if(abs(client.bottom - other.top) <= settings.snapDistance) { bottom = other; } } } /* Check client windows. */ for(tp = nodeTail[layer]; tp; tp = tp->prev) { if(tp == np || !ShouldSnap(tp)) { continue; } GetClientRectangle(tp, &other); /* Check if this border invalidates any previous value. */ left.valid = CheckLeftValid(&client, &other, &left); right.valid = CheckRightValid(&client, &other, &right); top.valid = CheckTopValid(&client, &other, &top); bottom.valid = CheckBottomValid(&client, &other, &bottom); /* Compute the new snap values. */ if(CheckOverlapTopBottom(&client, &other)) { if(abs(client.left - other.right) <= settings.snapDistance) { left = other; } if(abs(client.right - other.left) <= settings.snapDistance) { right = other; } } if(CheckOverlapLeftRight(&client, &other)) { if(abs(client.top - other.bottom) <= settings.snapDistance) { top = other; } if(abs(client.bottom - other.top) <= settings.snapDistance) { bottom = other; } } } } if(right.valid) { np->x = right.left - np->width - west; } if(left.valid) { np->x = left.right + east; } if(bottom.valid) { np->y = bottom.top - south; if(!(np->state.status & STAT_SHADED)) { np->y -= np->height; } } if(top.valid) { np->y = top.bottom + north; } }
/** Move a client window (keyboard or menu initiated). */ char MoveClientKeyboard(ClientNode *np) { XEvent event; int oldx, oldy; int moved; int height; int north, south, east, west; MaxFlags maxFlags; Assert(np); if(!(np->state.border & BORDER_MOVE)) { return 0; } if(np->state.status & STAT_FULLSCREEN) { return 0; } maxFlags = np->state.maxFlags; if(np->state.maxFlags != MAX_NONE) { MaximizeClient(np, MAX_NONE); } if(JUNLIKELY(JXGrabKeyboard(display, np->parent, True, GrabModeAsync, GrabModeAsync, CurrentTime))) { Debug("MoveClient: could not grab keyboard"); return 0; } GrabMouseForMove(); GetBorderSize(&np->state, &north, &south, &east, &west); oldx = np->x; oldy = np->y; RegisterCallback(0, SignalMove, NULL); np->controller = MoveController; shouldStopMove = 0; CreateMoveWindow(np); UpdateMoveWindow(np); MoveMouse(rootWindow, np->x, np->y); DiscardMotionEvents(&event, np->window); if(np->state.status & STAT_SHADED) { height = 0; } else { height = np->height; } for(;;) { WaitForEvent(&event); if(shouldStopMove) { np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); return 1; } moved = 0; if(event.type == KeyPress) { DiscardKeyEvents(&event, np->window); switch(GetKey(&event.xkey) & 0xFF) { case KEY_UP: if(np->y + height > 0) { np->y -= 10; } break; case KEY_DOWN: if(np->y < rootHeight) { np->y += 10; } break; case KEY_RIGHT: if(np->x < rootWidth) { np->x += 10; } break; case KEY_LEFT: if(np->x + np->width > 0) { np->x -= 10; } break; default: StopMove(np, 1, oldx, oldy, maxFlags); return 1; } MoveMouse(rootWindow, np->x, np->y); DiscardMotionEvents(&event, np->window); moved = 1; } else if(event.type == MotionNotify) { DiscardMotionEvents(&event, np->window); np->x = event.xmotion.x; np->y = event.xmotion.y; moved = 1; } else if(event.type == ButtonRelease) { StopMove(np, 1, oldx, oldy, maxFlags); return 1; } if(moved) { if(settings.moveMode == MOVE_OUTLINE) { ClearOutline(); DrawOutline(np->x - west, np->y - west, np->width + west + east, height + north + west); } else { JXMoveWindow(display, np->parent, np->x - west, np->y - north); SendConfigureEvent(np); } UpdateMoveWindow(np); RequirePagerUpdate(); } } }
/** Move a client window. */ char MoveClient(ClientNode *np, int startx, int starty, int snap) { XEvent event; int oldx, oldy; int doMove; int north, south, east, west; int height; int hmax, vmax; Assert(np); if(!(np->state.border & BORDER_MOVE)) { return 0; } if(np->state.status & STAT_FULLSCREEN) { return 0; } GrabMouseForMove(); RegisterCallback(0, SignalMove, NULL); np->controller = MoveController; shouldStopMove = 0; oldx = np->x; oldy = np->y; vmax = 0; hmax = 0; if(!(GetMouseMask() & (Button1Mask | Button2Mask))) { StopMove(np, 0, oldx, oldy, 0, 0); return 0; } GetBorderSize(&np->state, &north, &south, &east, &west); startx -= west; starty -= north; currentClient = np; atTop = 0; atBottom = 0; atLeft = 0; atRight = 0; doMove = 0; for(;;) { WaitForEvent(&event); if(shouldStopMove) { np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); return doMove; } switch(event.type) { case ButtonRelease: if(event.xbutton.button == Button1 || event.xbutton.button == Button2) { StopMove(np, doMove, oldx, oldy, hmax, vmax); return doMove; } break; case MotionNotify: DiscardMotionEvents(&event, np->window); np->x = event.xmotion.x_root - startx; np->y = event.xmotion.y_root - starty; GetCurrentTime(&moveTime); atLeft = 0; atTop = 0; atRight = 0; atBottom = 0; if(event.xmotion.x_root == 0) { atLeft = 1; } else if(event.xmotion.x_root == rootWidth - 1) { atRight = 1; } if(event.xmotion.y_root == 0) { atTop = 1; } else if(event.xmotion.y_root == rootHeight - 1) { atBottom = 1; } if(snap) { DoSnap(np); } if(!doMove && (abs(np->x - oldx) > MOVE_DELTA || abs(np->y - oldy) > MOVE_DELTA)) { if(np->state.status & (STAT_HMAX | STAT_VMAX)) { if(np->state.status & STAT_HMAX) { hmax = 1; } if(np->state.status & STAT_VMAX) { vmax = 1; } MaximizeClient(np, 0, 0); startx = np->width / 2; starty = -north / 2; MoveMouse(np->parent, startx, starty); } CreateMoveWindow(np); doMove = 1; } if(doMove) { if(settings.moveMode == MOVE_OUTLINE) { ClearOutline(); height = north + south; if(!(np->state.status & STAT_SHADED)) { height += np->height; } DrawOutline(np->x - west, np->y - north, np->width + west + east, height); } else { JXMoveWindow(display, np->parent, np->x - west, np->y - north); SendConfigureEvent(np); } UpdateMoveWindow(np); UpdatePager(); } break; default: break; } } }
// Position and size subwindows. // Note that the border size applies to each subwindow, not // including the edges next to the sash. void wxSplitterWindow::SizeWindows() { // check if we have delayed setting the real sash position if ( m_requestedSashPosition != INT_MAX ) { int newSashPosition = ConvertSashPosition(m_requestedSashPosition); if ( newSashPosition != m_sashPosition ) { DoSetSashPosition(newSashPosition); } if ( newSashPosition <= m_sashPosition && newSashPosition >= m_sashPosition - GetBorderSize() ) { // don't update it any more m_requestedSashPosition = INT_MAX; } } int w, h; GetClientSize(&w, &h); if ( GetWindow1() && !GetWindow2() ) { GetWindow1()->SetSize(GetBorderSize(), GetBorderSize(), w - 2*GetBorderSize(), h - 2*GetBorderSize()); } else if ( GetWindow1() && GetWindow2() ) { const int border = GetBorderSize(), sash = GetSashSize(); int size1 = GetSashPosition() - border, size2 = GetSashPosition() + sash; int x2, y2, w1, h1, w2, h2; if ( GetSplitMode() == wxSPLIT_VERTICAL ) { w1 = size1; w2 = w - 2*border - sash - w1; if (w2 < 0) w2 = 0; h2 = h - 2*border; if (h2 < 0) h2 = 0; h1 = h2; x2 = size2; y2 = border; } else // horz splitter { w2 = w - 2*border; if (w2 < 0) w2 = 0; w1 = w2; h1 = size1; h2 = h - 2*border - sash - h1; if (h2 < 0) h2 = 0; x2 = border; y2 = size2; } GetWindow2()->SetSize(x2, y2, w2, h2); GetWindow1()->SetSize(border, border, w1, h1); } wxClientDC dc(this); DrawSash(dc); }
void SetWMode(int width, int height, bool state) { #ifndef SHADOW_BROODWAR // Compatibility for Xen W-Mode if ( ghMainWnd && !(GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU) ) return; if ( !isCorrectVersion ) return; if ( state ) { wmode = true; if ( !ghMainWnd ) return; // Call the DirectDraw destructor DDrawDestroy(); InitializeWModeBitmap(BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height()); // Hack to enable drawing in Broodwar BW::BWDATA::PrimarySurface = (LPDIRECTDRAWSURFACE)1; const int shift = gdwProcNum > 1 ? 32 : 0; POINT pos = { windowRect.left + shift, windowRect.top + shift }; // Change the window settings SetWindowLong(ghMainWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); SetWindowPos(ghMainWnd, HWND_NOTOPMOST, pos.x, pos.y, width, height, SWP_SHOWWINDOW); ShowWindow(ghMainWnd, SW_RESTORE); SIZE border; GetBorderSize(ghMainWnd, &border); int w = width + border.cx; int h = height + border.cy; int cx = GetSystemMetrics(SM_CXFULLSCREEN); int cy = GetSystemMetrics(SM_CYFULLSCREEN); while ( pos.x < 0 ) pos.x = 0; while ( pos.y < 0 ) pos.y = 0; if ( pos.y + h >= cy ) { if (gdwProcNum > 1) pos.y -= cy - h; else pos.y = cy - h; } if ( pos.x + w >= cx ) { if (gdwProcNum > 1) pos.x -= cx - w; else pos.x = cx - w; } MoveWindow(ghMainWnd, pos.x, pos.y, w, h, TRUE); SetCursor(NULL); SetCursorShowState(false); SetDIBColorTable(hdcMem, 0, 256, wmodebmp.bmiColors); WriteConfig("window", "windowed", "ON"); } else { wmode = false; BW::BWDATA::PrimarySurface = NULL; if ( hdcMem ) DeleteDC(hdcMem); hdcMem = NULL; if (ghMainWnd) { SetWindowLong(ghMainWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_SYSMENU); SetWindowPos(ghMainWnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW); SetCursor(NULL); SetCursorShowState(false); SetFocus(ghMainWnd); } DDrawDestroy(); DDrawInitialize(width, height); WriteConfig("window", "windowed", "OFF"); } #endif }
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if ( wmode ) { // Perform W-Mode only functionality switch ( uMsg ) { case WM_SIZING: { SIZE border; GetBorderSize(hWnd, &border); RECT *rct = (RECT*)lParam; SIZE ws = { rct->right - rct->left - border.cx, rct->bottom - rct->top - border.cy }; if ( ws.cx < WMODE_MIN_WIDTH ) { ws.cx = WMODE_MIN_WIDTH; CorrectWindowWidth(wParam, &ws, rct, &border); } if ( ws.cy < WMODE_MIN_HEIGHT ) { ws.cy = WMODE_MIN_HEIGHT; CorrectWindowHeight(wParam, &ws, rct, &border); } if ( GetKeyState(VK_CONTROL) & 0x8000 && ws.cy != ws.cx * 3 / 4 ) { if ( wParam == WMSZ_TOP || wParam == WMSZ_BOTTOM ) { ws.cx = ws.cy * 4 / 3; CorrectWindowWidth(WMSZ_RIGHT, &ws, rct, &border); } else { ws.cy = ws.cx * 3 / 4; CorrectWindowHeight( (wParam == WMSZ_RIGHT || wParam == WMSZ_LEFT) ? WMSZ_BOTTOM : wParam, &ws, rct, &border); } } if ( isCorrectVersion ) // must be correct version to reference BWDATA { if ( ws.cx >= BW::BWDATA::GameScreenBuffer.width() - WMODE_SNAP_RANGE && ws.cx <= BW::BWDATA::GameScreenBuffer.width() + WMODE_SNAP_RANGE ) { ws.cx = BW::BWDATA::GameScreenBuffer.width(); CorrectWindowWidth( (wParam == WMSZ_TOP || wParam == WMSZ_BOTTOM) ? WMSZ_RIGHT : wParam, &ws, rct, &border); } if ( ws.cy >= BW::BWDATA::GameScreenBuffer.height() - WMODE_SNAP_RANGE && ws.cy <= BW::BWDATA::GameScreenBuffer.height() + WMODE_SNAP_RANGE ) { ws.cy = BW::BWDATA::GameScreenBuffer.height(); CorrectWindowHeight( (wParam == WMSZ_RIGHT || wParam == WMSZ_LEFT) ? WMSZ_BOTTOM : wParam, &ws, rct, &border); } } break; } // case WM_SIZING case WM_SIZE: { switch ( wParam ) { case SIZE_RESTORED: { RECT tempRect; GetClientRect(hWnd, &tempRect); windowRect.right = tempRect.right; windowRect.bottom = tempRect.bottom; WriteConfig("window", "width", tempRect.right); WriteConfig("window", "height", tempRect.bottom); break; } }// wParam switch break; } // case WM_SIZE case WM_MOVE: { RECT tempRect; GetWindowRect(hWnd, &tempRect); if ( tempRect.right > 0 && tempRect.bottom > 0 && tempRect.left < GetSystemMetrics(SM_CXFULLSCREEN) && tempRect.top < GetSystemMetrics(SM_CYFULLSCREEN) ) { windowRect.left = tempRect.left; windowRect.top = tempRect.top; WriteConfig("window", "left", tempRect.left); WriteConfig("window", "top", tempRect.top); } break; } // case WM_MOVE case WM_PAINT: if ( gbWantUpdate && pBits) { static DWORD dwLastUpdate = 0; DWORD dwNewTick = GetTickCount(); if ( dwLastUpdate + (IsIconic(hWnd) ? 200 : 20) > dwNewTick ) break; dwLastUpdate = dwNewTick; gbWantUpdate = false; // begin paint PAINTSTRUCT paint; HDC hdc = BeginPaint(hWnd, &paint); if ( isCorrectVersion ) // must be correct version, @todo: make independent { // Blit to the screen RECT cRect; GetClientRect(hWnd, &cRect); if ( cRect.right == BW::BWDATA::GameScreenBuffer.width() && cRect.bottom == BW::BWDATA::GameScreenBuffer.height() ) { BitBlt(hdc, 0, 0, BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height(), hdcMem, 0, 0, SRCCOPY); } else { SetStretchBltMode(hdc, HALFTONE); //StretchBlt(hdc, 0, 0, cRect.right, cRect.bottom, hdcMem, 0, 0, BW::BWDATA::GameScreenBuffer->wid, BW::BWDATA::GameScreenBuffer->ht, SRCCOPY); StretchDIBits(hdc, 0, 0, cRect.right, cRect.bottom, 0, 0, BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height(), pBits, (BITMAPINFO*)&wmodebmp, DIB_RGB_COLORS, SRCCOPY); } } // end paint EndPaint(hWnd, &paint); } // data break; case WM_NCMOUSEMOVE: SetCursorShowState(true); break; case WM_MOUSEMOVE: SetCursorShowState(false); lParam = FixPoints(lParam); break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: { RECT clientRct; GetClientRect(hWnd, &clientRct); ClientToScreen(hWnd, (LPPOINT)&clientRct.left); ClientToScreen(hWnd, (LPPOINT)&clientRct.right); ClipCursor(&clientRct); lParam = FixPoints(lParam); break; } case WM_MBUTTONUP: case WM_LBUTTONUP: case WM_RBUTTONUP: ClipCursor(NULL); lParam = FixPoints(lParam); break; case WM_MOUSEWHEEL: case WM_RBUTTONDBLCLK: case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: lParam = FixPoints(lParam); break; case WM_ACTIVATEAPP: if ( wOriginalProc ) return CallWindowProc(wOriginalProc, hWnd, WM_ACTIVATEAPP, (WPARAM)1, NULL); case WM_SETCURSOR: case WM_ERASEBKGND: return DefWindowProc(hWnd, uMsg, wParam, lParam); case WM_SYSKEYDOWN: case WM_KEYDOWN: if ( wParam == VK_MENU && !(lParam & 0x40000000)) { RECT rct; GetClientRect(hWnd, &rct); ClientToScreen(hWnd, (LPPOINT)&rct.left); ClientToScreen(hWnd, (LPPOINT)&rct.right); ClipCursor(&rct); gbHoldingAlt = true; } break; case WM_SYSKEYUP: case WM_KEYUP: if ( wParam == VK_MENU ) { ClipCursor(NULL); gbHoldingAlt = false; } break; } // switch } // if wmode if ( isCorrectVersion ) { // Perform BWAPI-added functionality switch ( uMsg ) { case WM_SYSKEYDOWN: if ( wParam == VK_RETURN && (lParam & 0x20000000) && !(lParam & 0x40000000) ) { SetWMode(BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height(), !wmode); return TRUE; } break; case WM_MOUSEMOVE: if ( GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU ) // Compatibility for Xen W-Mode { BW::BWDATA::InputFlags |= 1; POINTS pt = MAKEPOINTS(lParam); BW::BWDATA::Mouse.x = pt.x; BW::BWDATA::Mouse.y = pt.y; return TRUE; } break; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_RBUTTONDBLCLK: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: if ( GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU ) // Compatibility for Xen W-Mode { ButtonEvent(uMsg - WM_MOUSEFIRST + BW_EVN_MOUSEFIRST, lParam); return TRUE; } break; case WM_SYSCOMMAND: if ( wParam == SC_MAXIMIZE ) { SetWMode(BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height(), false); return TRUE; } break; } } // Register Broodwar thread name RegisterThreadName("Broodwar Main"); // Call the original WndProc if ( wOriginalProc ) return CallWindowProc(wOriginalProc, hWnd, uMsg, wParam, lParam); return DefWindowProc(hWnd, uMsg, wParam, lParam); }