#include "SRBibleWidget.h" SRBibleWidget::SRBibleWidget() :m_viewLexi(NULL) ,m_viewNote(NULL) ,m_modGreekDef(NULL) ,m_modGreekMorph(NULL) ,m_modHebrewDef(NULL) ,m_modHebrewMorph(NULL) ,m_fLexiVisible(FALSE) ,m_fNoteVisible(FALSE) { /* m_wcsClassName = "SRBibleWidget"; m_wcsWindowName = ""; m_hInstance = SRFramework::SRApp::GetInstanceHandle(); */ } SRBibleWidget::~SRBibleWidget() { if(m_viewLexi) delete m_viewLexi; if(m_subWndLexi) delete m_subWndLexi; if(m_viewNote) delete m_viewNote; if(m_subWndNote) delete m_subWndNote; } VOID SRBibleWidget::SetSwordReady() { if(m_viewModule) m_viewModule->SetSwordReady(); if(m_viewLexi) m_viewLexi->SetSwordReady(); } BOOL SRBibleWidget::Init() { RECT clientRect = GetBounds(); RECT lexiRect = {0,0,0,0}; RECT notesRect = {0,0,0,0}; m_viewModule = new SRModuleView(BibleView); if(!m_viewModule || !m_viewModule->Create(this, clientRect)) return FALSE; m_viewLexi = new SRLexiView(TRUE); if(!m_viewLexi) // Create is handled in the sub-window return FALSE; m_subWndLexi = new SRSubWindow(m_viewLexi); if(!m_subWndLexi || !m_subWndLexi->Create(this, lexiRect)) return FALSE; m_viewNote = new SRTextView(TRUE); if(!m_viewNote) // Create is handled in the sub-window return FALSE; m_subWndNote = new SRSubWindow(m_viewNote); if(!m_subWndNote || !m_subWndNote->Create(this, notesRect)) return FALSE; return TRUE; } VOID SRBibleWidget::Show() { SRWnd::Show(); if(m_viewModule) m_viewModule->Show(); } VOID SRBibleWidget::MoveWindow(LPCRECT lpRect,BOOL bRepaint) { SRModuleWidget::MoveWindow(lpRect, bRepaint); RECT clientRect = GetBounds(); RECT mainRect = clientRect; RECT lexiRect = clientRect; RECT noteRect = clientRect; if(m_fLexiVisible){ mainRect.bottom = GetSplitPoint(); lexiRect.top = mainRect.bottom; noteRect.top = noteRect.bottom; }else if(m_fNoteVisible){ mainRect.bottom = GetSplitPoint(); noteRect.top = mainRect.bottom; lexiRect.top = lexiRect.bottom; }else{ lexiRect.top = mainRect.bottom; noteRect.top = mainRect.bottom; } m_viewModule->MoveWindow(&mainRect, bRepaint); m_subWndLexi->MoveWindow(&lexiRect, bRepaint); m_subWndNote->MoveWindow(¬eRect, bRepaint); } BOOL SRBibleWidget::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if(m_viewModule) return m_viewModule->OnKeyDown(nChar, nRepCnt, nFlags); return FALSE; } VOID SRBibleWidget::SetGreekDefModule(SWModule *pModule) { m_modGreekDef = pModule; } VOID SRBibleWidget::SetGreekMorphModule(SWModule *pModule) { m_modGreekMorph = pModule; } VOID SRBibleWidget::SetHebrewDefModule(SWModule *pModule) { m_modHebrewDef = pModule; } VOID SRBibleWidget::SetHebrewMorphModule(SWModule *pModule) { m_modHebrewMorph = pModule; } VOID SRBibleWidget::ShowLexiSubWindow() { if(m_fLexiVisible) return; else if(m_fNoteVisible){ HideSubWindow(m_subWndNote); m_fNoteVisible = FALSE; } ShowSubWindow(m_subWndLexi); m_fLexiVisible = TRUE; } VOID SRBibleWidget::ShowNoteSubWindow() { if(m_fNoteVisible) return; else if(m_fLexiVisible){ HideSubWindow(m_subWndLexi); m_fLexiVisible = FALSE; } ShowSubWindow(m_subWndNote); m_fNoteVisible = TRUE; } VOID SRBibleWidget::ShowGreekDef(const WCString &key) { if(m_modGreekDef) ShowLexiEntry(m_modGreekDef, key); else ::MessageBox(0, L"No Dictionary found - install Strong's Greek module", L"Greek Defs Missing", MB_OK); } VOID SRBibleWidget::ShowHebrewDef(const WCString &key) { if(m_modHebrewDef) ShowLexiEntry(m_modHebrewDef, key); else ::MessageBox(0, L"No Dictionary found - install Strong's Hebrew module", L"Hebrew Defs Missing", MB_OK); } VOID SRBibleWidget::ShowGreekMorph(const WCString &key) { if(m_modGreekMorph) ShowLexiEntry(m_modGreekMorph, key); else ::MessageBox(0, L"No Dictionary found - install Strong's Greek module", L"Greek Defs Missing", MB_OK); } VOID SRBibleWidget::ShowHebrewMorph(const WCString &key) { if(m_modHebrewMorph) ShowLexiEntry(m_modHebrewMorph, key); else ::MessageBox(0, L"No Dictionary found - install Strong's Hebrew module", L"Hebrew Defs Missing", MB_OK); } VOID SRBibleWidget::ShowLexiEntry(SWModule *pModule, const WCString &key) { if(!pModule || !m_viewLexi) return; m_viewLexi->SetModule(pModule); m_viewLexi->SetKey(key.c_str()); if(!m_fLexiVisible){ ShowLexiSubWindow(); } } VOID SRBibleWidget::ShowBibleNote(const WCString ¬e) { if(!m_viewNote) return; m_viewNote->Clear(); m_viewNote->AddText(note.w_str(), note.length()); m_viewNote->RefreshWindow(); if(!m_fNoteVisible){ ShowNoteSubWindow(); } } VOID SRBibleWidget::HideSubWindow(SRSubWindow *pSubWnd) { SRModuleWidget::HideSubWindow(pSubWnd); if(pSubWnd == m_subWndLexi) m_fLexiVisible = FALSE; else if(pSubWnd == m_subWndNote) m_fNoteVisible = FALSE; }