[Wgui-cvs] wgui/src wg_menu.cpp,1.49,1.50 wg_tooltip.cpp,1.22,1.23
Status: Beta
Brought to you by:
greenwire
|
From: Rob W. <gre...@us...> - 2004-07-08 21:42:59
|
Update of /cvsroot/wgui/wgui/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10783/src Modified Files: wg_menu.cpp wg_tooltip.cpp Log Message: Draw architecture changes. Index: wg_tooltip.cpp =================================================================== RCS file: /cvsroot/wgui/wgui/src/wg_tooltip.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** wg_tooltip.cpp 6 Jul 2004 16:32:25 -0000 1.22 --- wg_tooltip.cpp 8 Jul 2004 21:42:51 -0000 1.23 *************** *** 98,102 **** ! void CToolTip::PaintToSurface(SDL_Surface& ScreenSurface, SDL_Surface& FloatingSurface, const CPoint& Offset) const { if (m_bVisible) --- 98,102 ---- ! void CToolTip::PaintToSurface(SDL_Surface& /*ScreenSurface*/, SDL_Surface& FloatingSurface, const CPoint& Offset) const { if (m_bVisible) *************** *** 108,112 **** for (std::list<CWindow*>::const_iterator iter = m_ChildWindows.begin(); iter != m_ChildWindows.end(); ++iter) { ! (*iter)->PaintToSurface(ScreenSurface, FloatingSurface, NewOffset); } } --- 108,112 ---- for (std::list<CWindow*>::const_iterator iter = m_ChildWindows.begin(); iter != m_ChildWindows.end(); ++iter) { ! (*iter)->PaintToSurface(FloatingSurface, FloatingSurface, NewOffset); } } Index: wg_menu.cpp =================================================================== RCS file: /cvsroot/wgui/wgui/src/wg_menu.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** wg_menu.cpp 29 Jun 2004 22:14:20 -0000 1.49 --- wg_menu.cpp 8 Jul 2004 21:42:51 -0000 1.50 *************** *** 130,141 **** { CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage); ! if (m_bVisible && pMouseMessage && m_WindowRect.HitTest(pMouseMessage->Point) == CRect::RELPOS_INSIDE) { UpdateCachedRects(); SMenuItem* pOldHighlight = m_pHighlightedItem; m_pHighlightedItem = 0; for (t_MenuItemVector::iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) { ! if (iter->second.second.HitTest(pMouseMessage->Point) == CRect::RELPOS_INSIDE && !iter->first.bSpacer) { if (m_pHighlightedItem != &(iter->first)) --- 130,142 ---- { CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage); ! if (m_bVisible && pMouseMessage && m_WindowRect.HitTest(ViewToWindow(pMouseMessage->Point)) == CRect::RELPOS_INSIDE) { UpdateCachedRects(); SMenuItem* pOldHighlight = m_pHighlightedItem; m_pHighlightedItem = 0; + CPoint WindowPoint(ViewToWindow(pMouseMessage->Point)); for (t_MenuItemVector::iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) { ! if (iter->second.second.HitTest(WindowPoint) == CRect::RELPOS_INSIDE && !iter->first.bSpacer) { if (m_pHighlightedItem != &(iter->first)) *************** *** 258,267 **** if (! CMenuBase::OnMouseButtonDown(Point, Button) && m_bVisible && (Button == CMouseMessage::LEFT) && ! (m_WindowRect.SizeRect().HitTest(ViewToClient(Point)) == CRect::RELPOS_INSIDE)) { UpdateCachedRects(); for (t_MenuItemVector::iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) { ! if (iter->second.second.HitTest(Point) == CRect::RELPOS_INSIDE && !iter->first.bSpacer) { HideActivePopup(); --- 259,268 ---- if (! CMenuBase::OnMouseButtonDown(Point, Button) && m_bVisible && (Button == CMouseMessage::LEFT) && ! (m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE)) { UpdateCachedRects(); for (t_MenuItemVector::iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) { ! if (iter->second.second.HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE && !iter->first.bSpacer) { HideActivePopup(); *************** *** 428,432 **** } ! SetWindowRect(CRect(Position, Position + CPoint(m_WindowRect.Width() - 1, iHeight + 2))); m_bVisible = true; CView* pView = GetView(); --- 429,433 ---- } ! SetWindowRect(GetAncestor(PARENT)->ViewToClient(CRect(Position, Position + CPoint(m_WindowRect.Width() - 1, iHeight + 2)))); m_bVisible = true; CView* pView = GetView(); *************** *** 478,482 **** bool CPopupMenu::IsInsideChild(const CPoint& Point) const { ! if (m_WindowRect.SizeRect().HitTest(ViewToClient(Point)) == CRect::RELPOS_INSIDE) { return true; --- 479,483 ---- bool CPopupMenu::IsInsideChild(const CPoint& Point) const { ! if (m_WindowRect.SizeRect().HitTest(ViewToWindow(Point)) == CRect::RELPOS_INSIDE) { return true; *************** *** 495,501 **** CPainter Painter(m_pSDLSurface); ! Painter.DrawRect(m_WindowRect, false, COLOR_LIGHTGRAY); ! Painter.DrawHLine(m_WindowRect.Left(), m_WindowRect.Right(), m_WindowRect.Bottom(), COLOR_DARKGRAY); ! Painter.DrawVLine(m_WindowRect.Top(), m_WindowRect.Bottom(), m_WindowRect.Right(), COLOR_DARKGRAY); UpdateCachedRects(); for (t_MenuItemVector::const_iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) --- 496,502 ---- CPainter Painter(m_pSDLSurface); ! Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_LIGHTGRAY); ! Painter.DrawHLine(0, m_WindowRect.Width(), m_WindowRect.Height(), COLOR_DARKGRAY); ! Painter.DrawVLine(0, m_WindowRect.Height(), m_WindowRect.Width(), COLOR_DARKGRAY); UpdateCachedRects(); for (t_MenuItemVector::const_iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) *************** *** 536,550 **** bool CPopupMenu::OnMouseButtonDown(CPoint Point, unsigned int Button) { bool bResult = false; if (! CMenuBase::OnMouseButtonDown(Point, Button) && m_bVisible && ! (m_WindowRect.SizeRect().HitTest(ViewToClient(Point)) == CRect::RELPOS_INSIDE)) { UpdateCachedRects(); for (t_MenuItemVector::iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) { ! if (iter->second.second.HitTest(Point) == CRect::RELPOS_INSIDE && !iter->first.bSpacer) { if (!iter->first.pPopup) --- 537,568 ---- + void CPopupMenu::PaintToSurface(SDL_Surface& /*ScreenSurface*/, SDL_Surface& FloatingSurface, const CPoint& Offset) const + { + if (m_bVisible) + { + SDL_Rect SourceRect = CRect(m_WindowRect.SizeRect()).SDLRect(); + SDL_Rect DestRect = CRect(m_WindowRect + Offset).SDLRect(); + SDL_BlitSurface(m_pSDLSurface, &SourceRect, &FloatingSurface, &DestRect); + CPoint NewOffset = m_ClientRect.TopLeft() + m_WindowRect.TopLeft() + Offset; + for (std::list<CWindow*>::const_iterator iter = m_ChildWindows.begin(); iter != m_ChildWindows.end(); ++iter) + { + (*iter)->PaintToSurface(FloatingSurface, FloatingSurface, NewOffset); + } + } + } + + bool CPopupMenu::OnMouseButtonDown(CPoint Point, unsigned int Button) { bool bResult = false; + CPoint WindowPoint(ViewToWindow(Point)); if (! CMenuBase::OnMouseButtonDown(Point, Button) && m_bVisible && ! (m_WindowRect.SizeRect().HitTest(WindowPoint) == CRect::RELPOS_INSIDE)) { UpdateCachedRects(); for (t_MenuItemVector::iterator iter = m_MenuItems.begin(); iter != m_MenuItems.end(); ++iter) { ! if (iter->second.second.HitTest(WindowPoint) == CRect::RELPOS_INSIDE && !iter->first.bSpacer) { if (!iter->first.pPopup) *************** *** 585,589 **** { CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage); ! if (m_bVisible && pMouseMessage && (m_WindowRect.HitTest(pMouseMessage->Point) != CRect::RELPOS_INSIDE)) { // If the user clicked outside the window, we just want to hide the window, --- 603,608 ---- { CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage); ! if (m_bVisible && pMouseMessage && ! m_WindowRect.SizeRect().HitTest(ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE) { // If the user clicked outside the window, we just want to hide the window, *************** *** 591,595 **** // But we only want the root popup to do this, and only if none of it's children were hit if (!dynamic_cast<CPopupMenu*>(m_pParentWindow) && !IsInsideChild(pMouseMessage->Point) && ! !(m_pParentMenu && m_pParentMenu->GetWindowRect().HitTest(pMouseMessage->Point) == CRect::RELPOS_INSIDE)) { HideAll(); --- 610,615 ---- // But we only want the root popup to do this, and only if none of it's children were hit if (!dynamic_cast<CPopupMenu*>(m_pParentWindow) && !IsInsideChild(pMouseMessage->Point) && ! !(m_pParentMenu && m_pParentMenu->GetWindowRect().SizeRect().HitTest( ! m_pParentMenu->ViewToWindow(pMouseMessage->Point)) == CRect::RELPOS_INSIDE)) { HideAll(); *************** *** 675,683 **** if (BoundingRect.HitTest(ParentRect.TopRight() + CPoint(5, 0) + CPoint(MenuRect.Width(), 0)) & CRect::RELPOS_RIGHT) { ! m_pActivePopup->Show(ParentRect.TopLeft() - CPoint(MenuRect.Width() + 5, 0)); } else { ! m_pActivePopup->Show(ParentRect.TopRight() + CPoint(5, 0)); } } --- 695,703 ---- if (BoundingRect.HitTest(ParentRect.TopRight() + CPoint(5, 0) + CPoint(MenuRect.Width(), 0)) & CRect::RELPOS_RIGHT) { ! m_pActivePopup->Show(ClientToView(ParentRect.TopLeft() - CPoint(MenuRect.Width() + 5, 0)) - m_ClientRect.TopLeft()); } else { ! m_pActivePopup->Show(ClientToView(ParentRect.TopRight() + CPoint(5, 0)) - m_ClientRect.TopLeft()); } } |