[sword-svn] r132 - trunk/src/SwordReader_GUI
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Tue May 20 15:40:18 MST 2008
Author: dtrotzjr
Date: 2008-05-20 15:40:17 -0700 (Tue, 20 May 2008)
New Revision: 132
Modified:
trunk/src/SwordReader_GUI/SRMainFrame.cpp
trunk/src/SwordReader_GUI/SRMainFrame.h
trunk/src/SwordReader_GUI/SRTextView.cpp
trunk/src/SwordReader_GUI/SRTextView.h
Log:
Forgot about scrolling in the text window, and the title bar. These are now added.
Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-05-20 20:30:22 UTC (rev 131)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-05-20 22:40:17 UTC (rev 132)
@@ -135,7 +135,6 @@
m_viewBook->Hide();
m_viewChapter->Hide();
m_viewVerse->Hide();
-
return TRUE;
}
@@ -152,7 +151,8 @@
return TRUE;
}
BOOL SRMainFrame::UpdateWindow()
-{
+{
+ UpdateWindowTitle();
return m_viewText->UpdateWindow();
}
@@ -279,6 +279,7 @@
m_viewText->RefreshWindow();
m_viewText->ScrollToVerse(m_keyCurVerse->Verse());
+ UpdateWindowTitle();
}
@@ -357,9 +358,11 @@
break;
case SR_SETCHAPTER:
m_keyCurVerse->Chapter(newValue);
+ UpdateWindowTitle();
break;
case SR_SETVERSE:
m_keyCurVerse->Verse(newValue);
+ UpdateWindowTitle();
break;
default:
// Check the custom made menu items...
@@ -378,13 +381,47 @@
return TRUE;
}
+BOOL SRMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+ INT a = 0;
+ switch(nChar)
+ {
+ case VK_UP:
+ m_viewText->ScrollFullPage(1);
+ m_keyCurVerse->Verse(m_viewText->GetVerseNum());
+ UpdateWindowTitle();
+ break;
+ case VK_DOWN:
+ m_viewText->ScrollFullPage(-1);
+ m_keyCurVerse->Verse(m_viewText->GetVerseNum());
+ UpdateWindowTitle();
+ break;
+ case VK_LEFT:
+ if(m_keyCurVerse->Verse() > 1)
+ m_keyCurVerse->Verse(1);
+ else
+ m_keyCurVerse->Chapter(m_keyCurVerse->Chapter() - 1);
+ LoadTextView();
+ break;
+ case VK_RIGHT:
+ m_keyCurVerse->Chapter(m_keyCurVerse->Chapter() + 1);
+ LoadTextView();
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
void SRMainFrame::SelectModule(INT nModIndex)
{
+ SWModule *tmp = m_modCurText;
ModuleMap::iterator it = m_modTexts->begin();
for(int i = 0; i < nModIndex; i++)
it++;
m_modCurText = it->second;
-
+ if(tmp != m_modCurText)
+ LoadTextView();
}
BOOL SRMainFrame::GetSupportedOptions()
@@ -450,7 +487,20 @@
}
}
}
+
+void SRMainFrame::UpdateWindowTitle()
+{
+ wchar_t wverse[16] = {0};
+ wchar_t wchapt[16] = {0};
+ WCString title =
+ WCString(m_modCurText->Name()) + " " +
+ s_wcsBookNames[(m_keyCurVerse->Book() - 1) + BIBLE_OT_BOOKS*(m_keyCurVerse->Testament() - 1)] + WCString(" ") +
+ WCString(_itow(m_keyCurVerse->Chapter(),wchapt, 10)) + WCString(":") +
+ WCString(_itow(m_keyCurVerse->Verse(), wverse, 10));
+ SetWindowText(m_hWnd,title.w_str());
+}
+
INT SRMainFrame::GetMaxChapters()
{
VerseKey ref(m_keyCurVerse);
Modified: trunk/src/SwordReader_GUI/SRMainFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.h 2008-05-20 20:30:22 UTC (rev 131)
+++ trunk/src/SwordReader_GUI/SRMainFrame.h 2008-05-20 22:40:17 UTC (rev 132)
@@ -13,9 +13,6 @@
#include "SRNumberChooser.h"
#include "SRBookChooser.h"
-// The one and only command bar.
-#define SR_COMMAND_BAR_ID 0x0001
-
using namespace SRFramework;
using namespace sword;
@@ -34,6 +31,8 @@
void SelectModule(INT nModIndex);
BOOL GetSupportedOptions();
void ToggleOption(WORD wID);
+
+ void UpdateWindowTitle();
// Sword related
BOOL InitSword();
@@ -42,6 +41,7 @@
static const WCString *GetBookNames() { return s_wcsBookNames; }
void LoadTextView();
WCString GetVerseHeader(VerseKey key);
+ BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
private:
INT m_nTotalOpts;
SWConfig *m_confOptions;
Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp 2008-05-20 20:30:22 UTC (rev 131)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp 2008-05-20 22:40:17 UTC (rev 132)
@@ -814,6 +814,7 @@
m_nDragStart = pt.y;
}
+ SendVerseChangedMessage();
}
VOID SRTextView::RollTillStopped()
@@ -843,8 +844,14 @@
::UpdateWindow(m_hWnd);
m_nRollVelocity = (m_nRollVelocity - m_nRollVelocity/6) - ((nDirection*m_nRollVelocity < 10) ? nDirection : 0); // the nDirection part ensures continual degrading in the velocity
}
+ SendVerseChangedMessage();
}
+VOID SRTextView::SendVerseChangedMessage()
+{
+ ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND, SR_SETVERSE, GetVerseNum());
+}
+
VOID SRTextView::ScrollFullPage(INT nDirection)
{
RECT rectUpdateRect;
@@ -877,6 +884,7 @@
InvalidateRect(m_hWnd, &rectUpdateRect, TRUE);
::UpdateWindow(m_hWnd);
}
+ SendVerseChangedMessage();
}
VOID SRTextView::ScrollToPosition(INT yPos)
@@ -895,6 +903,7 @@
InvalidateRect(m_hWnd, &rectUpdateRect, TRUE);
::UpdateWindow(m_hWnd);
}
+ SendVerseChangedMessage();
}
VOID SRTextView::ScrollToVerse(WORD wVerseNum)
@@ -902,6 +911,12 @@
ScrollToPosition(m_BTLines.GetVersePosition(wVerseNum));
}
+
+WORD SRTextView::GetVerseNum()
+{
+ return m_BTLines.GetVerseAt(m_nTop);
+}
+
BOOL SRTextView::AddText(const TCHAR *szText, DWORD dwSize)
{
DWORD i = 0;
@@ -1133,6 +1148,17 @@
return -1;
}
+WORD SRTextView::SRTextLines::GetVerseAt(INT yPos)
+{
+ for(INT i = 0; i < m_dwLastLine; i++){
+ if(!m_lppLinesLastWord[i]->m_lpPrevWord)
+ continue; // We hit a blank line (not neccesarrily the end).
+ if(m_lppLinesLastWord[i]->m_lpPrevWord->m_rect.top >= -yPos)
+ return m_lppLinesLastWord[i]->m_lpPrevWord->m_wVerseNum;
+ }
+ return -1;
+}
+
SRTextView::SRTextLines & SRTextView::SRTextLines::operator=(CONST SRTextView::SRTextLines &rhs)
{
if(this == &rhs)
Modified: trunk/src/SwordReader_GUI/SRTextView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.h 2008-05-20 20:30:22 UTC (rev 131)
+++ trunk/src/SwordReader_GUI/SRTextView.h 2008-05-20 22:40:17 UTC (rev 132)
@@ -25,6 +25,7 @@
#pragma once
#include <windows.h>
#include "SRFramework/SRWnd.h"
+#include "SwordReaderResource.h"
using namespace SRFramework;
@@ -167,6 +168,8 @@
//! @param pWord pointer to the word being copied in.
//! @param dwWordLen length of the word being copied in.
VOID OwnWord(TCHAR *lpszWord, DWORD dwWordLen);
+
+
//! Points to a specific word inside a buffered string stored and
//! managed outside of this class.
//! Thus we do not try to manage the memory, unless the m_fOwner
@@ -288,6 +291,11 @@
@return the y coordinate of the verse number, -1 otherwise.
*/
INT GetVersePosition(WORD wVerseNum);
+ //! Returns the verse number that corresponds to the given y coordinate.
+ /*! @param yPos the y coordinate of the line we want the verse number for.
+ @return the verse number correpsonding to the y coordinate.
+ */
+ WORD GetVerseAt(INT yPos);
//! Indicates the total number of lines currently allocated.
DWORD m_dwLines;
//! Indicates the last line actually being used,
@@ -447,12 +455,17 @@
VOID MoveWindow(INT x, INT y, INT w, INT h);
//! Clears the text from m_lpszBuff and removes the lines from m_BTLines.
VOID Clear();
-
+ //! Redraws the window, including a pre-render stage if neccesarry.
BOOL UpdateWindow();
-
+ //! Calls the low level WinCE API window creation functions and creates a new window.
BOOL Create(SRWnd *pParentWnd, RECT bounds);
-
- // Friend classes, not needed in Visual Studio 2005
+ //! Gets the verse of the line at the top window.
+ /*! @return the verse number of the word at the end of the top line
+ visible in the window.
+ */
+ WORD GetVerseNum();
+
+ // Friend classes, not needed in Visual Studio 2005
// but needed in eVC 3
friend class SRTextWord;
friend class SRTextLines;
@@ -661,10 +674,11 @@
*/
VOID PreRenderBuff(HDC hdc);
- VOID ClearFontCache(HDC hdc);
+ VOID ClearFontCache(HDC hdc);
- BOOL Register();
-
+ BOOL Register();
+ //! Alerts all listening parties that the current verse has changed in this window.
+ VOID SendVerseChangedMessage();
// Private data members
More information about the sword-cvs
mailing list