#include "SRCommWidget.h" #include SRCommWidget::SRCommWidget() :m_viewScripRef(NULL) ,m_fScripRefVisible(FALSE) { /* m_wcsClassName = "SRCommWidget"; m_wcsWindowName = ""; m_hInstance = SRFramework::SRApp::GetInstanceHandle(); */ } SRCommWidget::~SRCommWidget() { if(m_viewScripRef) delete m_viewScripRef; if(m_subWndScripRef) delete m_subWndScripRef; } VOID SRCommWidget::SetSwordReady() { if(m_viewModule) m_viewModule->SetSwordReady(); if(m_viewScripRef) m_viewScripRef->SetSwordReady(); } BOOL SRCommWidget::Init() { RECT clientRect; RECT bibleRect = {0,0,0,0}; GetClientRect(m_hWnd, &clientRect); m_viewModule = new SRModuleView(CommView); if(!m_viewModule || !m_viewModule->Create(this, clientRect)) return FALSE; m_viewScripRef = new SRScripRefView(); if(!m_viewScripRef) // Create is handled in the sub-window return FALSE; m_subWndScripRef = new SRSubWindow(m_viewScripRef); if(!m_subWndScripRef || !m_subWndScripRef->Create(this, bibleRect)) return FALSE; return TRUE; } VOID SRCommWidget::Show() { SRWnd::Show(); if(m_viewModule) m_viewModule->Show(); } VOID SRCommWidget::MoveWindow(LPCRECT lpRect,BOOL bRepaint) { SRModuleWidget::MoveWindow(lpRect, bRepaint); RECT clientRect = GetBounds(); RECT mainRect = clientRect; RECT scripRect = clientRect; if(m_fScripRefVisible){ mainRect.bottom = GetSplitPoint(); scripRect.top = mainRect.bottom; }else{ scripRect.top = mainRect.bottom; } m_viewModule->MoveWindow(&mainRect, bRepaint); m_subWndScripRef->MoveWindow(&scripRect, bRepaint); } BOOL SRCommWidget::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if(m_viewModule) return m_viewModule->OnKeyDown(nChar, nRepCnt, nFlags); return FALSE; } VOID SRCommWidget::ShowScripRefSubWindow() { if(m_fScripRefVisible) return; ShowSubWindow(m_subWndScripRef); m_fScripRefVisible = TRUE; } VOID SRCommWidget::ShowScripRef(SWModule *pModule, const WCString &key) { VerseKey context = m_viewModule->GetVerseKey(); ListKey verses = context.ParseVerseList(key.c_str()); if(!pModule || !m_viewScripRef) return; m_viewScripRef->SetModule(pModule); m_viewScripRef->SetKeys(verses); if(!m_fScripRefVisible){ ShowScripRefSubWindow(); } } VOID SRCommWidget::ShowScripRef(const WCString &key) { VerseKey context = m_viewModule->GetVerseKey(); ListKey verses = context.ParseVerseList(key.c_str()); if(!m_viewScripRef) return; m_viewScripRef->SetKeys(verses); if(!m_fScripRefVisible){ ShowScripRefSubWindow(); } } VOID SRCommWidget::HideSubWindow(SRSubWindow *pSubWnd) { SRModuleWidget::HideSubWindow(pSubWnd); m_fScripRefVisible = FALSE; } VOID SRCommWidget::SetScripRefModule(SWModule *pModule) { if(m_viewScripRef) m_viewScripRef->SetModule(pModule); }