[sword-svn] r119 - in trunk/src/SwordReader_GUI: . SRFramework
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Wed Apr 16 20:32:23 MST 2008
Author: dtrotzjr
Date: 2008-04-16 20:32:22 -0700 (Wed, 16 Apr 2008)
New Revision: 119
Modified:
trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp
trunk/src/SwordReader_GUI/SRFramework/SRMenu.h
trunk/src/SwordReader_GUI/SRMainFrame.cpp
trunk/src/SwordReader_GUI/SRMainFrame.h
trunk/src/SwordReader_GUI/SRMenuBar.cpp
trunk/src/SwordReader_GUI/SRMenuBar.h
Log:
More restructuring.
Modified: trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp 2008-04-16 04:25:18 UTC (rev 118)
+++ trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp 2008-04-17 03:32:22 UTC (rev 119)
@@ -47,4 +47,8 @@
}
+BOOL SRMenu::CheckMenuItem(UINT nIDCheckItem, UINT nCheck)
+{
+ return ::CheckMenuItem(m_hMenu, nIDCheckItem, nCheck);
+}
Modified: trunk/src/SwordReader_GUI/SRFramework/SRMenu.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRMenu.h 2008-04-16 04:25:18 UTC (rev 118)
+++ trunk/src/SwordReader_GUI/SRFramework/SRMenu.h 2008-04-17 03:32:22 UTC (rev 119)
@@ -20,6 +20,7 @@
void DestroyMenu();
BOOL InsertMenu(const SRMenu & menu, UINT uPosition, UINT uFlags,const WCString & wcsNewItem);
BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem,const WCString &wcsNewItem);
+ BOOL CheckMenuItem(UINT nIDCheckItem, UINT nCheck);
};
}
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-04-16 04:25:18 UTC (rev 118)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-04-17 03:32:22 UTC (rev 119)
@@ -122,6 +122,36 @@
if(!m_menuBar || !m_menuBar->FillTranslationsSubMenu(m_modTexts,MENU_TRANS_START))
return FALSE;
+
+ if(!m_menuBar->FillOptionsSubMenu(m_swmgr,MENU_OPTS_START))
+ return FALSE;
return TRUE;
}
+
+BOOL SRMainFrame::OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl)
+{
+ switch(wID) {
+ case IDOK:
+ SendMessage(m_hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)m_hWnd);
+ SendMessage (m_hWnd, WM_CLOSE, 0, 0);
+ break;
+ case MENU_ABOUT:
+ MessageBox(0, L"Sword reader program for Pocket PC ver. 1.0.1\n\nsee: http://www.crosswire.org/sword/swordreader/\n\nGUI by Johan Gorter, 2004\nNow being maintained by B. Drake, Robin Randall and David Trotz\nProverbs 16:3", L"About", MB_OK);
+ break;
+ case MENU_SHUTDOWN:
+ SendMessage(m_hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)m_hWnd);
+ SendMessage (m_hWnd, WM_CLOSE, 0, 0);
+ exit(0);
+ default:
+ /*
+ if ((wID >= USERBUTTONS)&&(wmId<USERBUTTONS+1000)) {
+ g_navigator->buttonClicked(wmId - USERBUTTONS);
+ break;
+ }
+ else */if (m_menuBar->MenuItemClicked(wID)) {
+ }else
+ return FALSE;
+ }
+ return TRUE;
+}
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRMainFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.h 2008-04-16 04:25:18 UTC (rev 118)
+++ trunk/src/SwordReader_GUI/SRMainFrame.h 2008-04-17 03:32:22 UTC (rev 119)
@@ -27,6 +27,7 @@
BOOL UpdateWindow();
BOOL CreateCommandBar();
BOOL InitSword();
+ BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl);
private:
SRMenuBar *m_menuBar;
SRTextView *m_viewText;
Modified: trunk/src/SwordReader_GUI/SRMenuBar.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMenuBar.cpp 2008-04-16 04:25:18 UTC (rev 118)
+++ trunk/src/SwordReader_GUI/SRMenuBar.cpp 2008-04-17 03:32:22 UTC (rev 119)
@@ -2,11 +2,25 @@
using namespace SRFramework;
SRMenuBar::SRMenuBar(void)
+:m_menuMain(NULL)
+,m_menuTrans(NULL)
+,m_menuOpts(NULL)
+,m_sbufOpts(NULL)
+,m_nTotalOpts(0)
{
+
}
SRMenuBar::~SRMenuBar(void)
{
+ if(m_menuMain)
+ delete m_menuMain;
+ if(m_menuTrans)
+ delete m_menuTrans;
+ if(m_menuOpts)
+ delete m_menuOpts;
+ if(m_sbufOpts)
+ delete [] m_sbufOpts;
}
@@ -40,4 +54,67 @@
m_menuTrans->AppendMenu(0, nCurID++, i->first);
}
return TRUE;
-}
\ No newline at end of file
+}
+
+BOOL SRMenuBar::FillOptionsSubMenu(SWMgr *swmgr, int nStartID)
+{
+ StringList optionNames = swmgr->getGlobalOptions();
+ StringList::iterator i;
+ int nCurID = nStartID;
+ bool fSupported = true;
+ StringList optionValues;
+
+ if (m_menuOpts) {
+ m_nTotalOpts = 0;
+ if (m_sbufOpts)
+ delete [] m_sbufOpts;
+
+ // count the supported options
+ for (i = optionNames.begin(); i != optionNames.end(); i++) {
+ optionValues = swmgr->getGlobalOptionValues(*i);
+ fSupported = true;
+ for (StringList::iterator j = optionValues.begin(); j != optionValues.end(); j++) {
+ if ((*j != "On") && (*j != "Off"))
+ fSupported = false;
+ }
+ if (fSupported)
+ m_nTotalOpts++;
+ }
+
+ m_sbufOpts = new SWBuf[m_nTotalOpts];
+
+ // add options;
+ for (i = optionNames.begin(); i != optionNames.end(); i++) {
+ optionValues = swmgr->getGlobalOptionValues(*i);
+ fSupported = true;
+ for (StringList::iterator j = optionValues.begin(); j != optionValues.end(); j++) {
+ if ((*j != "On") && (*j != "Off"))
+ fSupported = false;
+ }
+ if (fSupported) {
+ m_sbufOpts[nCurID - nStartID] = *i;
+ m_menuOpts->AppendMenu(0, nCurID++, i->c_str());
+ }
+ }
+ }
+ // TODO: if no options, disable options menu
+ return TRUE;
+}
+
+
+BOOL SRMenuBar::CheckTranslationsMenuItem(ModuleMap *texts, UINT nIDCheckItem)
+{
+ int nCurTrans = MENU_OPTS_START;
+
+ for (ModuleMap::iterator i = texts->begin(); i != texts->end(); i++) {
+ m_menuTrans->CheckMenuItem(nCurTrans, (nIDCheckItem == nCurTrans ? MF_CHECKED : MF_UNCHECKED) );
+ nCurTrans++;
+ }
+
+ return TRUE;
+}
+
+BOOL SRMenuBar::MenuItemClicked(WORD wID)
+{
+ return FALSE;
+}
Modified: trunk/src/SwordReader_GUI/SRMenuBar.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMenuBar.h 2008-04-16 04:25:18 UTC (rev 118)
+++ trunk/src/SwordReader_GUI/SRMenuBar.h 2008-04-17 03:32:22 UTC (rev 119)
@@ -3,7 +3,11 @@
#include "SRFramework\SRCommandBar.h"
#include "SwordReaderResource.h"
+#include <swbuf.h>
+#include <swmgr.h>
+
using namespace SRFramework;
+using namespace sword;
class SRMenuBar :
public SRFramework::SRCommandBar
@@ -11,10 +15,15 @@
public:
BOOL Create(SRWnd* pWndParent, UINT nBarID);
BOOL FillTranslationsSubMenu(ModuleMap *texts, int nStartID);
+ BOOL FillOptionsSubMenu(SWMgr *swmgr, int nStartID);
+ BOOL CheckTranslationsMenuItem(ModuleMap *texts, UINT nIDCheckItem);
+ BOOL MenuItemClicked(WORD wID);
SRMenuBar(void);
virtual ~SRMenuBar(void);
private:
SRMenu *m_menuMain;
SRMenu *m_menuTrans;
SRMenu *m_menuOpts;
+ SWBuf *m_sbufOpts;
+ INT m_nTotalOpts;
};
More information about the sword-cvs
mailing list