[sword-svn] r125 - trunk/src/SwordReader_GUI
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Sat Apr 26 20:09:30 MST 2008
Author: dtrotzjr
Date: 2008-04-26 20:09:29 -0700 (Sat, 26 Apr 2008)
New Revision: 125
Modified:
trunk/src/SwordReader_GUI/SRMainFrame.cpp
trunk/src/SwordReader_GUI/SRMainFrame.h
trunk/src/SwordReader_GUI/SRNumberChooser.cpp
trunk/src/SwordReader_GUI/SRNumberChooser.h
trunk/src/SwordReader_GUI/SwordReaderResource.h
Log:
Implemented message passing between SRNumberChooser and SRMainFrame
Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-04-25 23:22:59 UTC (rev 124)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-04-27 03:09:29 UTC (rev 125)
@@ -109,11 +109,11 @@
m_viewText->AddText(test_str.w_str(),test_str.length());
- m_viewVerse = new SRNumberChooser("Select a Verse:",MENU_TEXT);
+ m_viewVerse = new SRNumberChooser(ChooserType::VERSE, "Select a Verse:",MENU_TEXT);
if(!m_viewVerse->Create(this, view_rect))
return FALSE;
- m_viewChapter = new SRNumberChooser("Select a Chapter:",MENU_VERSE);
+ m_viewChapter = new SRNumberChooser(ChooserType::CHAPTER, "Select a Chapter:",MENU_VERSE);
if(!m_viewChapter->Create(this, view_rect))
return FALSE;
@@ -194,6 +194,8 @@
{
INT nTransID = 0;
INT nOptsID = 0;
+ INT newValue = (INT)hWndCtl; // I am using this parameter in a strange way I know.
+
switch(wID) {
case IDOK:
SendMessage(m_hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)m_hWnd);
@@ -225,18 +227,23 @@
m_viewVerse->Hide();
break;
case MENU_CHAP:
- m_viewChapter->SetEndNumber(m_keyCurVerse->books[m_keyCurVerse->Book()]->chapmax);
+ m_viewChapter->SetEndNumber(GetMaxChapters());
m_viewChapter->Show();
m_viewText->Hide();
m_viewVerse->Hide();
break;
case MENU_VERSE:
- m_keyCurVerse->Verse(MAXVERSE);
- m_viewVerse->SetEndNumber(m_keyCurVerse->Verse());
+ m_viewVerse->SetEndNumber(GetMaxVerses());
m_viewVerse->Show();
m_viewChapter->Hide();
m_viewText->Hide();
break;
+ case SR_SETCHAPTER:
+ m_keyCurVerse->Chapter(newValue);
+ break;
+ case SR_SETVERSE:
+ m_keyCurVerse->Verse(newValue);
+ break;
default:
return FALSE;
}
@@ -306,4 +313,18 @@
}
}
}
+}
+
+INT SRMainFrame::GetMaxChapters()
+{
+ VerseKey ref(m_keyCurVerse);
+ ref = MAXCHAPTER;
+ return ref.Chapter();
+}
+
+INT SRMainFrame::GetMaxVerses()
+{
+ VerseKey ref(m_keyCurVerse);
+ ref = MAXVERSE;
+ return ref.Verse();
}
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRMainFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.h 2008-04-25 23:22:59 UTC (rev 124)
+++ trunk/src/SwordReader_GUI/SRMainFrame.h 2008-04-27 03:09:29 UTC (rev 125)
@@ -28,12 +28,16 @@
BOOL Create();
BOOL UpdateWindow();
BOOL CreateCommandBar();
- BOOL InitSword();
BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl);
void SelectModule(INT nModIndex);
void GetSupportedOptions();
void ToggleOption(WORD wID);
+
+ // Sword related
+ BOOL InitSword();
+ INT GetMaxChapters();
+ INT GetMaxVerses();
private:
INT m_nTotalOpts;
SWConfig *m_confOptions;
Modified: trunk/src/SwordReader_GUI/SRNumberChooser.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRNumberChooser.cpp 2008-04-25 23:22:59 UTC (rev 124)
+++ trunk/src/SwordReader_GUI/SRNumberChooser.cpp 2008-04-27 03:09:29 UTC (rev 125)
@@ -8,12 +8,13 @@
#define ROW0 5
#define LASTROW ROW0+getMaxRows()*(BUTTON_HEIGHT+PADDING_HEIGHT)
-SRNumberChooser::SRNumberChooser(WCString wcsPrompt, WORD wNextMenuID)
+SRNumberChooser::SRNumberChooser(ChooserType type, WCString wcsPrompt, WORD wNextMenuID)
:m_nEndNumber(0)
,m_nSelectedNumber(0)
,m_nStartAt(1)
,m_wcsPrompt(wcsPrompt)
,m_wNextMenuID(wNextMenuID)
+,m_type(type)
{
m_wcsClassName = "SRNumberChooser";
m_wcsWindowName = "Number Chooser";
@@ -224,7 +225,9 @@
return TRUE;
}else if(found != 0 && found != -1){
m_nSelectedNumber = found;
- ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND,m_wNextMenuID,0);
+ // We also send the value found, thus when this messge is recv'd the new value can be processed.
+ ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND,m_type == CHAPTER ? SR_SETCHAPTER : SR_SETVERSE, found);
+ ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND,m_wNextMenuID, found);
}
return TRUE;
}
Modified: trunk/src/SwordReader_GUI/SRNumberChooser.h
===================================================================
--- trunk/src/SwordReader_GUI/SRNumberChooser.h 2008-04-25 23:22:59 UTC (rev 124)
+++ trunk/src/SwordReader_GUI/SRNumberChooser.h 2008-04-27 03:09:29 UTC (rev 125)
@@ -2,12 +2,13 @@
#define SRNUMBERCHOOSER_H
#include "SRFramework/SRWnd.h"
-
using namespace SRFramework;
+enum ChooserType { CHAPTER, VERSE };
+
class SRNumberChooser: public SRWnd {
public:
- SRNumberChooser(WCString wcsPrompt, WORD wNextMenuID);
+ SRNumberChooser(ChooserType type, WCString wcsPrompt, WORD wNextMenuID);
virtual ~SRNumberChooser();
// redraw the screen. This should use methods in ApplicationInterface.h to do the drawing
@@ -29,6 +30,7 @@
INT m_nStartAt;
INT m_nSelectedNumber;
WORD m_wNextMenuID;
+ ChooserType m_type;
WCString m_wcsPrompt;
static BOOL m_fRegistered;
};
Modified: trunk/src/SwordReader_GUI/SwordReaderResource.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderResource.h 2008-04-25 23:22:59 UTC (rev 124)
+++ trunk/src/SwordReader_GUI/SwordReaderResource.h 2008-04-27 03:09:29 UTC (rev 125)
@@ -18,6 +18,10 @@
#define WM_TXT_START WM_USER + 0x00F1
#define WM_TXT_END WM_USER + 0x00F2
+#define SR_SETBOOK 0x00FB
+#define SR_SETCHAPTER 0x00FC
+#define SR_SETVERSE 0x00FD
+
#define BUTTON_BACKGROUND 0x00b9ccd5
#define BUTTON_WIDTH_BOOK 26
#define BUTTON_WIDTH_NUMBER 20
More information about the sword-cvs
mailing list