Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_WindowWin32.cpp
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| if (state == GHOST_kWindowStateFullScreen) { | if (state == GHOST_kWindowStateFullScreen) { | ||||
| style |= WS_MAXIMIZE; | style |= WS_MAXIMIZE; | ||||
| } | } | ||||
| /* Forces owned windows onto taskbar and allows minimization. */ | /* Forces owned windows onto taskbar and allows minimization. */ | ||||
| DWORD extended_style = parentwindow ? WS_EX_APPWINDOW : 0; | DWORD extended_style = parentwindow ? WS_EX_APPWINDOW : 0; | ||||
| if (dialog) { | |||||
| style = WS_POPUPWINDOW | WS_CAPTION; | |||||
| extended_style = WS_EX_DLGMODALFRAME | WS_EX_TOPMOST; | |||||
| } | |||||
| /* Monitor details. */ | /* Monitor details. */ | ||||
| MONITORINFOEX monitor; | MONITORINFOEX monitor; | ||||
| monitor.cbSize = sizeof(MONITORINFOEX); | monitor.cbSize = sizeof(MONITORINFOEX); | ||||
| monitor.dwFlags = 0; | monitor.dwFlags = 0; | ||||
| GetMonitorInfo( | GetMonitorInfo( | ||||
| MonitorFromRect(parentwindow ? &parent_rect : &win_rect, MONITOR_DEFAULTTONEAREST), | MonitorFromRect(parentwindow ? &parent_rect : &win_rect, MONITOR_DEFAULTTONEAREST), | ||||
| &monitor); | &monitor); | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| else { | else { | ||||
| success = GHOST_kSuccess; | success = GHOST_kSuccess; | ||||
| } | } | ||||
| return success; | return success; | ||||
| } | } | ||||
| GHOST_TWindowState GHOST_WindowWin32::getState() const | GHOST_TWindowState GHOST_WindowWin32::getState() const | ||||
| { | { | ||||
| GHOST_TWindowState state; | |||||
| // XXX 27.04.2011 | |||||
| // we need to find a way to combine parented windows + resizing if we simply set the | |||||
| // state as GHOST_kWindowStateEmbedded we will need to check for them somewhere else. | |||||
| // It's also strange that in Windows is the only platform we need to make this separation. | |||||
| if ((m_parentWindowHwnd != 0) && !isDialog()) { | |||||
| state = GHOST_kWindowStateEmbedded; | |||||
| return state; | |||||
| } | |||||
| if (::IsIconic(m_hWnd)) { | if (::IsIconic(m_hWnd)) { | ||||
| state = GHOST_kWindowStateMinimized; | return GHOST_kWindowStateMinimized; | ||||
| } | } | ||||
| else if (::IsZoomed(m_hWnd)) { | else if (::IsZoomed(m_hWnd)) { | ||||
| LONG_PTR result = ::GetWindowLongPtr(m_hWnd, GWL_STYLE); | LONG_PTR result = ::GetWindowLongPtr(m_hWnd, GWL_STYLE); | ||||
| if ((result & (WS_DLGFRAME | WS_MAXIMIZE)) == (WS_DLGFRAME | WS_MAXIMIZE)) | return (result & WS_CAPTION) ? GHOST_kWindowStateMaximized : GHOST_kWindowStateFullScreen; | ||||
| state = GHOST_kWindowStateMaximized; | |||||
| else | |||||
| state = GHOST_kWindowStateFullScreen; | |||||
| } | |||||
| else { | |||||
| state = GHOST_kWindowStateNormal; | |||||
| } | } | ||||
| return state; | return GHOST_kWindowStateNormal; | ||||
| } | } | ||||
| void GHOST_WindowWin32::screenToClient(GHOST_TInt32 inX, | void GHOST_WindowWin32::screenToClient(GHOST_TInt32 inX, | ||||
| GHOST_TInt32 inY, | GHOST_TInt32 inY, | ||||
| GHOST_TInt32 &outX, | GHOST_TInt32 &outX, | ||||
| GHOST_TInt32 &outY) const | GHOST_TInt32 &outY) const | ||||
| { | { | ||||
| POINT point = {inX, inY}; | POINT point = {inX, inY}; | ||||
| Show All 11 Lines | |||||
| ::ClientToScreen(m_hWnd, &point); | ::ClientToScreen(m_hWnd, &point); | ||||
| outX = point.x; | outX = point.x; | ||||
| outY = point.y; | outY = point.y; | ||||
| } | } | ||||
| GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state) | GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state) | ||||
| { | { | ||||
| GHOST_TWindowState curstate = getState(); | GHOST_TWindowState curstate = getState(); | ||||
| LONG_PTR newstyle = -1; | LONG_PTR style = GetWindowLongPtr(m_hWnd, GWL_STYLE) | WS_CAPTION; | ||||
| WINDOWPLACEMENT wp; | WINDOWPLACEMENT wp; | ||||
| wp.length = sizeof(WINDOWPLACEMENT); | wp.length = sizeof(WINDOWPLACEMENT); | ||||
| ::GetWindowPlacement(m_hWnd, &wp); | ::GetWindowPlacement(m_hWnd, &wp); | ||||
| if (state == GHOST_kWindowStateNormal) | |||||
| state = m_normal_state; | |||||
| switch (state) { | switch (state) { | ||||
| case GHOST_kWindowStateMinimized: | case GHOST_kWindowStateMinimized: | ||||
| wp.showCmd = SW_SHOWMINIMIZED; | wp.showCmd = SW_SHOWMINIMIZED; | ||||
| break; | break; | ||||
| case GHOST_kWindowStateMaximized: | case GHOST_kWindowStateMaximized: | ||||
| wp.showCmd = SW_SHOWMAXIMIZED; | wp.showCmd = SW_SHOWMAXIMIZED; | ||||
| newstyle = WS_OVERLAPPEDWINDOW; | |||||
| break; | break; | ||||
| case GHOST_kWindowStateFullScreen: | case GHOST_kWindowStateFullScreen: | ||||
| if (curstate != state && curstate != GHOST_kWindowStateMinimized) | if (curstate != state && curstate != GHOST_kWindowStateMinimized) { | ||||
| m_normal_state = curstate; | m_normal_state = curstate; | ||||
| } | |||||
| wp.showCmd = SW_SHOWMAXIMIZED; | wp.showCmd = SW_SHOWMAXIMIZED; | ||||
| wp.ptMaxPosition.x = 0; | wp.ptMaxPosition.x = 0; | ||||
| wp.ptMaxPosition.y = 0; | wp.ptMaxPosition.y = 0; | ||||
| newstyle = WS_MAXIMIZE; | style &= ~WS_CAPTION; | ||||
| break; | |||||
| case GHOST_kWindowStateEmbedded: | |||||
| newstyle = WS_CHILD; | |||||
| break; | break; | ||||
| case GHOST_kWindowStateNormal: | case GHOST_kWindowStateNormal: | ||||
| default: | default: | ||||
| wp.showCmd = SW_SHOWNORMAL; | wp.showCmd = SW_SHOWNORMAL; | ||||
| newstyle = WS_OVERLAPPEDWINDOW; | |||||
| break; | break; | ||||
| } | } | ||||
| if ((newstyle >= 0) && !isDialog()) { | ::SetWindowLongPtr(m_hWnd, GWL_STYLE, style); | ||||
| ::SetWindowLongPtr(m_hWnd, GWL_STYLE, newstyle); | |||||
| } | |||||
| /* Clears window cache for SetWindowLongPtr */ | |||||
| ::SetWindowPos(m_hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); | |||||
| return ::SetWindowPlacement(m_hWnd, &wp) == TRUE ? GHOST_kSuccess : GHOST_kFailure; | return ::SetWindowPlacement(m_hWnd, &wp) == TRUE ? GHOST_kSuccess : GHOST_kFailure; | ||||
| } | } | ||||
| GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order) | GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order) | ||||
| { | { | ||||
| HWND hWndInsertAfter, hWndToRaise; | HWND hWndInsertAfter, hWndToRaise; | ||||
| if (order == GHOST_kWindowOrderBottom) { | if (order == GHOST_kWindowOrderBottom) { | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| } | } | ||||
| bool GHOST_WindowWin32::isDialog() const | bool GHOST_WindowWin32::isDialog() const | ||||
| { | { | ||||
| HWND parent = (HWND)::GetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT); | HWND parent = (HWND)::GetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT); | ||||
| long int style = (long int)::GetWindowLongPtr(m_hWnd, GWL_STYLE); | long int style = (long int)::GetWindowLongPtr(m_hWnd, GWL_STYLE); | ||||
| return (parent != 0) && (style & WS_POPUPWINDOW); | return (parent != 0) && ((style & WS_MAXIMIZEBOX) == 0); | ||||
| } | } | ||||
| void GHOST_WindowWin32::updateMouseCapture(GHOST_MouseCaptureEventWin32 event) | void GHOST_WindowWin32::updateMouseCapture(GHOST_MouseCaptureEventWin32 event) | ||||
| { | { | ||||
| switch (event) { | switch (event) { | ||||
| case MousePressed: | case MousePressed: | ||||
| m_nPressedButtons++; | m_nPressedButtons++; | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||