[Wgui-cvs] wgui/src wg_frame.cpp,1.26,1.27 wg_messagebox.cpp,1.3,1.4
Status: Beta
Brought to you by:
greenwire
|
From: Rob W. <gre...@us...> - 2004-12-27 04:59:45
|
Update of /cvsroot/wgui/wgui/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24643/src Modified Files: wg_frame.cpp wg_messagebox.cpp Log Message: Started work on the CMessageBox class. Index: wg_messagebox.cpp =================================================================== RCS file: /cvsroot/wgui/wgui/src/wg_messagebox.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wg_messagebox.cpp 2 Apr 2004 17:26:16 -0000 1.3 --- wg_messagebox.cpp 27 Dec 2004 04:59:36 -0000 1.4 *************** *** 22,23 **** --- 22,105 ---- // + + #include "wgui_include_config.h" + #include "wg_messagebox.h" + + namespace wGui + { + + CMessageBox::CMessageBox(CView* pParent, CFontEngine* pFontEngine, const std::string& sTitle, const std::string& sMessage, int iButtons) : + CFrame(CRect(0, 0, 300, 90), pParent, pFontEngine, sTitle), + m_iButtons(iButtons), + m_ReturnValue(BUTTON_INVALID) + { + m_pMessageLabel = new CLabel(CRect(10, 10, 290, 26), this, sMessage); + // m_bVisible = false; + CPoint BottomRight(290, 60); + if (iButtons & CMessageBox::BUTTON_CANCEL) + { + m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_CANCEL, new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "Cancel"))); + BottomRight = BottomRight - CPoint(60, 0); + } + if (iButtons & CMessageBox::BUTTON_OK) + { + m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_OK, new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "Ok"))); + BottomRight = BottomRight - CPoint(60, 0); + } + if (iButtons & CMessageBox::BUTTON_NO) + { + m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_NO, new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "No"))); + BottomRight = BottomRight - CPoint(60, 0); + } + if (iButtons & CMessageBox::BUTTON_YES) + { + m_ButtonMap.insert(std::make_pair(CMessageBox::BUTTON_YES, new CButton(CRect(BottomRight - CPoint(50, 18), BottomRight), this, "Yes"))); + BottomRight = BottomRight - CPoint(60, 0); + } + } + + /* + CMessageBox::EButton CMessageBox::DoModal(void) + { + SetVisible(true); + } + */ + + bool CMessageBox::HandleMessage(CMessage* pMessage) + { + bool bHandled = false; + + if (pMessage) + { + switch(pMessage->MessageType()) + { + case CMessage::CTRL_LCLICK: + { + if (pMessage->Destination() == this) + { + for (std::map<EButton, CButton*>::iterator iter = m_ButtonMap.begin(); iter != m_ButtonMap.end(); ++iter) + if (pMessage->Source() == iter->second) + { + m_ReturnValue = iter->first; + SetNewParent(0); + CMessageServer::Instance().QueueMessage(new CValueMessage<CMessageBox::EButton>(CMessage::CTRL_MESSAGEBOXRETURN, m_pParentWindow, 0, iter->first)); + CMessageServer::Instance().QueueMessage(new CMessage(CMessage::APP_PAINT, 0, this)); + delete this; + bHandled = true; + } + } + break; + } + default: + break; + } + if (!bHandled) + { + bHandled = CFrame::HandleMessage(pMessage); + } + } + + return bHandled; + } + + } Index: wg_frame.cpp =================================================================== RCS file: /cvsroot/wgui/wgui/src/wg_frame.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** wg_frame.cpp 12 Dec 2004 09:08:19 -0000 1.26 --- wg_frame.cpp 27 Dec 2004 04:59:36 -0000 1.27 *************** *** 30,34 **** { ! CFrame::CFrame(const CRect& WindowRect, CView* pParent, CFontEngine* pFontEngine, std::string sTitle, bool bResizable) : CWindow(WindowRect, pParent), m_TitleBarColor(COLOR_BLUE), --- 30,34 ---- { ! CFrame::CFrame(const CRect& WindowRect, CView* pParent, CFontEngine* pFontEngine, const std::string& sTitle, bool bResizable) : CWindow(WindowRect, pParent), m_TitleBarColor(COLOR_BLUE), *************** *** 64,68 **** ! CFrame::~CFrame(void) { SDL_FreeSurface(m_pSavedSurface); --- 64,68 ---- ! CFrame::~CFrame(void) // virtual { SDL_FreeSurface(m_pSavedSurface); *************** *** 70,74 **** ! void CFrame::Draw(void) const { CWindow::Draw(); --- 70,74 ---- ! void CFrame::Draw(void) const // virtual { CWindow::Draw(); *************** *** 122,135 **** ! void CFrame::SetWindowRect(const CRect& WindowRect) { ! CWindow::SetWindowRect(WindowRect); ! m_TitleBarRect = CRect(2, 0, WindowRect.Width() - 3, m_iTitleBarHeight); ! m_pFrameCloseButton->SetWindowRect(CRect(WindowRect.Width() - 20, (-m_iTitleBarHeight / 2) - 5, WindowRect.Width() - 8, (-m_iTitleBarHeight / 2) + 7)); m_ClientRect = CRect(2, m_iTitleBarHeight + 2, WindowRect.Width() - 1, WindowRect.Height() - 1); } ! void CFrame::SetWindowText(const std::string& sWindowText) { std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(m_pFontEngine, sWindowText, CRenderedString::VALIGN_CENTER)); --- 122,136 ---- ! void CFrame::SetWindowRect(const CRect& WindowRect) // virtual { ! m_TitleBarRect = CRect(2, 2, WindowRect.Width() - 5, m_iTitleBarHeight); ! m_pFrameCloseButton->SetWindowRect(CRect(WindowRect.Width() - 20, (-m_iTitleBarHeight / 2) - 7, WindowRect.Width() - 8, (-m_iTitleBarHeight / 2) + 5)); m_ClientRect = CRect(2, m_iTitleBarHeight + 2, WindowRect.Width() - 1, WindowRect.Height() - 1); + // SetWindowRect() must be called last since it calls Draw(), and needs the titlebar rect and such to be set first + CWindow::SetWindowRect(WindowRect); } ! void CFrame::SetWindowText(const std::string& sWindowText) // virtual { std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(m_pFontEngine, sWindowText, CRenderedString::VALIGN_CENTER)); *************** *** 139,143 **** ! bool CFrame::OnMouseButtonDown(CPoint Point, unsigned int Button) { bool bResult = false; --- 140,144 ---- ! bool CFrame::OnMouseButtonDown(CPoint Point, unsigned int Button) // virtual { bool bResult = false; *************** *** 159,163 **** ! bool CFrame::HandleMessage(CMessage* pMessage) { bool bHandled = false; --- 160,164 ---- ! bool CFrame::HandleMessage(CMessage* pMessage) // virtual { bool bHandled = false; |