#include "SRMenuBar.h" using namespace SRFramework; SRMenuBar::SRMenuBar(void) :m_menuMain(NULL) ,m_menuBibles(NULL) ,m_menuOpts(NULL) ,m_nTotalOpts(0) { } SRMenuBar::~SRMenuBar(void) { if(m_menuMain) delete m_menuMain; if(m_menuBibles) delete m_menuBibles; if(m_menuComms) delete m_menuComms; if(m_menuOpts) delete m_menuOpts; if(m_menuDicts) delete m_menuDicts; } BOOL SRMenuBar::Create(SRWnd* pWndParent, UINT nBarID) { if(!SRCommandBar::Create(pWndParent, nBarID)){ return FALSE; } m_menuMain = new SRMenu(GetSubMenu(5)); // Create the options menu m_menuOpts = new SRMenu(); if(!m_menuOpts->CreatePopupMenu()) return FALSE; if(!m_menuMain->InsertMenu(*m_menuOpts,0, MF_BYPOSITION | MF_POPUP | MF_STRING, "Options")) return FALSE; // Create the translations menu m_menuDicts = new SRMenu(); if(!m_menuDicts->CreatePopupMenu()) return FALSE; if(!m_menuMain->InsertMenu(*m_menuDicts,0, MF_BYPOSITION | MF_POPUP | MF_STRING, "Dictionaries")) return FALSE; m_menuComms = new SRMenu(); if(!m_menuComms->CreatePopupMenu()) return FALSE; if(!m_menuMain->InsertMenu(*m_menuComms,0, MF_BYPOSITION | MF_POPUP | MF_STRING, "Commentaries")) return FALSE; m_menuBibles = new SRMenu(); if(!m_menuBibles->CreatePopupMenu()) return FALSE; if(!m_menuMain->InsertMenu(*m_menuBibles,0, MF_BYPOSITION | MF_POPUP | MF_STRING, "Bibles")) return FALSE; return TRUE; } BOOL SRMenuBar::FillBiblesSubMenu(ModuleMap *texts, const SWModule *modCurr, int nStartID) { int nCurID = nStartID; m_nTotalBibles = 0; if(!m_menuBibles) return FALSE; for (ModuleMap::iterator i = texts->begin(); i != texts->end(); i++) { m_menuBibles->AppendMenu(0, nCurID, i->first); m_nTotalBibles++; if(i->second == modCurr){ CheckBiblesMenuItem(nCurID); } nCurID++; } return TRUE; } BOOL SRMenuBar::FillCommsSubMenu(ModuleMap *texts, const SWModule *modCurr, int nStartID) { int nCurID = nStartID; m_nTotalComms = 0; if(!m_menuComms) return FALSE; for (ModuleMap::iterator i = texts->begin(); i != texts->end(); i++) { m_menuComms->AppendMenu(0, nCurID, i->first); m_nTotalComms++; if(i->second == modCurr){ CheckCommsMenuItem(nCurID); } nCurID++; } return TRUE; } BOOL SRMenuBar::FillDictsSubMenu(ModuleMap *texts, const SWModule *modCurr, int nStartID) { int nCurID = nStartID; m_nTotalDicts = 0; if(!m_menuDicts) return FALSE; for (ModuleMap::iterator i = texts->begin(); i != texts->end(); i++) { m_menuDicts->AppendMenu(0, nCurID, i->first); m_nTotalDicts++; if(i->second == modCurr){ CheckDictsMenuItem(nCurID); } nCurID++; } return TRUE; } BOOL SRMenuBar::FillOptionsSubMenu(SWBuf *bufOpts, bool *fOptsState, int nStartID, int nTotalOpts) { int nCurID = nStartID; if (m_menuOpts) { m_nTotalOpts = nTotalOpts; // count the supported options for (int i = 0; i < m_nTotalOpts; i++){ m_menuOpts->AppendMenu(0,nCurID, (bufOpts[i]).c_str()); m_menuOpts->CheckMenuItem(nCurID, fOptsState[i] ? MF_CHECKED : MF_UNCHECKED); nCurID++; } } // TODO: if no options, disable options menu return TRUE; } BOOL SRMenuBar::CheckBiblesMenuItem(UINT nIDCheckItem) { for (int nCurTrans = MENU_BIBLE_TRANS_START; nCurTrans < MENU_BIBLE_TRANS_START + m_nTotalBibles; nCurTrans++) { m_menuBibles->CheckMenuItem(nCurTrans, (nIDCheckItem == nCurTrans ? MF_CHECKED : MF_UNCHECKED) ); } return TRUE; } BOOL SRMenuBar::CheckCommsMenuItem(UINT nIDCheckItem) { for (int nCurTrans = MENU_COMM_TRANS_START; nCurTrans < MENU_COMM_TRANS_START + m_nTotalComms; nCurTrans++) { m_menuComms->CheckMenuItem(nCurTrans, (nIDCheckItem == nCurTrans ? MF_CHECKED : MF_UNCHECKED) ); } return TRUE; } BOOL SRMenuBar::CheckDictsMenuItem(UINT nIDCheckItem) { for (int nCurTrans = MENU_DICT_TRANS_START; nCurTrans < MENU_DICT_TRANS_START + m_nTotalDicts; nCurTrans++) { m_menuDicts->CheckMenuItem(nCurTrans, (nIDCheckItem == nCurTrans ? MF_CHECKED : MF_UNCHECKED) ); } return TRUE; } BOOL SRMenuBar::CheckOptionsMenuItem(UINT nIDCheckItem, BOOL fChecked) { return m_menuOpts->CheckMenuItem(nIDCheckItem, (fChecked ? MF_CHECKED : MF_UNCHECKED)); }