bool CWinSystemWin32DX::CreateNewWindow(std::string name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) { if(!CWinSystemWin32::CreateNewWindow(name, fullScreen, res, userFunction)) return false; SetFocusWnd(m_hWnd); SetDeviceWnd(m_hWnd); CRenderSystemDX::m_interlaced = ((res.dwFlags & D3DPRESENTFLAG_INTERLACED) != 0); CRenderSystemDX::m_useWindowedDX = UseWindowedDX(fullScreen); SetRenderParams(m_nWidth, m_nHeight, fullScreen, res.fRefreshRate); SetMonitor(GetMonitor(res.iScreen).hMonitor); return true; }
/* bool LayoutManager::ResetFocus(Window* wnd) { assert(wnd); assert(_focusWnd); if( wnd == _focusWnd ) { // // search for first appropriate parent // Window *tmp = wnd; for( Window *w = wnd->GetParent(); w; w = w->GetParent() ) { if( !w->GetVisibleCombined() || !w->GetEnabled() ) { tmp = w->GetParent(); } } while( tmp ) { if( wnd != tmp && SetFocusWnd(tmp) ) { break; } Window *r; // try to pass focus to next siblings for( r = tmp->GetNextSibling(); r; r = r->GetNextSibling() ) { if( r->GetVisibleCombined() && r->GetEnabled() ) { if( SetFocusWnd(r) ) break; } } if( r ) break; // try to pass focus to previous siblings for( r = tmp->GetPrevSibling(); r; r = r->GetPrevSibling() ) { if( r->GetVisibleCombined() && r->GetEnabled() ) { if( SetFocusWnd(r) ) break; } } if( r ) break; // and finally try to pass focus to the parent and its siblings tmp = tmp->GetParent(); assert(!tmp || (tmp->GetVisibleCombined() && tmp->GetEnabled())); } if( !tmp ) { SetFocusWnd(nullptr); } assert(wnd != _focusWnd); return true; } for( Window *w = wnd->GetFirstChild(); w; w = w->GetNextSibling() ) { if( ResetFocus(w) ) { return true; } } return false; } */ void LayoutManager::ResetWindow(UIWindow* wnd) { assert(wnd); if( GetFocusWnd() == wnd ) SetFocusWnd(nullptr); if( _hotTrackWnd.Get() == wnd ) { _hotTrackWnd->OnMouseLeave(); _hotTrackWnd.Set(nullptr); } _pointerCaptures.clear(); }
void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool dropshadow, bool topmost) { ASSERT(!IsChild() && !IsOpen() && FindTopCtrl() < 0); NewTop(); if(owner) { Ctrl *owner_window = owner->GetTopWindow(); if(!owner_window) owner_window = owner->GetTopCtrl(); ASSERT(owner_window->IsOpen()); if(owner_window != desktop) { owner_window->SetForeground(); top->owner_window = owner_window; } } topctrl.Add(this); popup = isopen = true; RefreshLayoutDeep(); if(activate) SetFocusWnd(); AddInvalid(GetRect()); }
bool LayoutManager::ProcessPointerInternal(UIWindow* wnd, float x, float y, float z, Msg msg, int buttons, PointerType pointerType, unsigned int pointerID, bool topMostPass, bool insideTopMost) { insideTopMost |= wnd->GetTopMost(); if (!wnd->GetEnabled() || !wnd->GetVisible() || (insideTopMost && !topMostPass)) return false; bool pointerInside = (x >= 0 && x < wnd->GetWidth() && y >= 0 && y < wnd->GetHeight()); if( (pointerInside || !wnd->GetClipChildren()) && GetCapture(pointerID) != wnd ) { // route message to each child in reverse order until someone process it for(UIWindow *w = wnd->GetLastChild(); w; w = w->GetPrevSibling() ) { #ifndef NDEBUG WindowWeakPtr wp(w); #endif if( ProcessPointerInternal(w, x - w->GetX(), y - w->GetY(), z, msg, buttons, pointerType, pointerID, topMostPass, insideTopMost) ) { return true; } assert(wp.Get()); } } if( insideTopMost == topMostPass && (pointerInside || GetCapture(pointerID) == wnd) ) { // window is captured or the pointer is inside the window WindowWeakPtr wp(wnd); bool msgProcessed = false; switch( msg ) { case Msg::PointerDown: msgProcessed = wnd->OnPointerDown(x, y, buttons, pointerType, pointerID); break; case Msg::PointerUp: case Msg::PointerCancel: msgProcessed = wnd->OnPointerUp(x, y, buttons, pointerType, pointerID); break; case Msg::PointerMove: msgProcessed = wnd->OnPointerMove(x, y, pointerType, pointerID); break; case Msg::MOUSEWHEEL: msgProcessed = wnd->OnMouseWheel(x, y, z); break; case Msg::TAP: msgProcessed = wnd->OnTap(x, y); break; default: assert(false); } // if window did not process the message, it should not destroy itself assert(msgProcessed || wp.Get()); if( wp.Get() && msgProcessed ) { switch( msg ) { case Msg::PointerDown: case Msg::TAP: SetFocusWnd(wnd); // may destroy wnd default: break; } if( wp.Get() && wnd != _hotTrackWnd.Get() ) { if( _hotTrackWnd.Get() ) _hotTrackWnd->OnMouseLeave(); // may destroy wnd if( wp.Get() && wnd->GetVisibleCombined() && wnd->GetEnabledCombined() ) { _hotTrackWnd.Set(wnd); _hotTrackWnd->OnMouseEnter(x, y); } } } return msgProcessed; } return false; }