[sword-svn] r185 - trunk/src/SwordReader_GUI
dtrotzjr at crosswire.org
dtrotzjr at crosswire.org
Thu Jan 1 21:58:40 MST 2009
Author: dtrotzjr
Date: 2009-01-01 21:58:40 -0700 (Thu, 01 Jan 2009)
New Revision: 185
Added:
trunk/src/SwordReader_GUI/SRLexiView.cpp
trunk/src/SwordReader_GUI/SRLexiView.h
Modified:
trunk/src/SwordReader_GUI/SRModuleView.h
trunk/src/SwordReader_GUI/SRTabbedViews.cpp
trunk/src/SwordReader_GUI/SRTabbedViews.h
trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
Initial support for dictionaries and lexicons. Builds and runs but does not currently show any dictionary material.
Added: trunk/src/SwordReader_GUI/SRLexiView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiView.cpp (rev 0)
+++ trunk/src/SwordReader_GUI/SRLexiView.cpp 2009-01-02 04:58:40 UTC (rev 185)
@@ -0,0 +1,95 @@
+#include "SRLexiView.h"
+
+SRLexiView::SRLexiView()
+:m_pModule(NULL)
+,m_fSwordInit(FALSE)
+{
+
+}
+
+
+SRLexiView::~SRLexiView()
+{
+
+}
+
+VOID SRLexiView::SetEntry(const WCString &entry)
+{
+ m_keyEntry.setText(entry.c_str());
+ LoadTextView();
+}
+
+VOID SRLexiView::SetModule(SWModule *pModule)
+{
+ if(m_pModule == pModule)
+ return;
+ m_pModule = pModule;
+ m_fEntryChanged = TRUE;
+ LoadTextView();
+}
+
+VOID SRLexiView::LoadTextView()
+{
+ WCString buf = "<html><body>";
+ WCString tmp = "";
+
+ if(!m_pModule){
+ buf += "<b>No Lexicon/Dictionary selected; nothing to load.</b></body></html>";
+ AddText(buf.w_str(), buf.length());
+ return;
+ }
+ if(!m_fSwordInit || !m_fEntryChanged)
+ return;
+
+ m_pModule->SetKey(m_keyEntry);
+ tmp = m_pModule->RenderText();
+ if(tmp.length() == 0){
+ tmp = "<b>The current lexicon module (";
+ tmp += m_pModule->Name();
+ tmp += ") does not have an entry for string \"";
+ tmp += m_keyEntry.getText();
+ tmp += "\"</b>";
+ }else{
+ buf += "<b>";
+ buf += m_keyEntry.getText();
+ buf += "</b><br><br>";
+ }
+ buf += tmp;
+ buf += "</body></html>";
+ AddText(buf.w_str(), buf.length());
+}
+
+VOID SRLexiView::RefreshScreen(BOOL fReloadText)
+{
+ if(fReloadText)
+ m_fEntryChanged = TRUE;
+ LoadTextView();
+}
+
+BOOL SRLexiView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+ INT a = 0;
+ switch(nChar)
+ {
+ case VK_UP:
+ ScrollFullPage(1);
+ break;
+ case VK_DOWN:
+ ScrollFullPage(-1);
+ break;
+ case VK_LEFT:
+ break;
+ case VK_RIGHT:
+ break;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+VOID SRLexiView::Show()
+{
+ SRTextView::Show();
+ LoadTextView();
+}
\ No newline at end of file
Added: trunk/src/SwordReader_GUI/SRLexiView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRLexiView.h (rev 0)
+++ trunk/src/SwordReader_GUI/SRLexiView.h 2009-01-02 04:58:40 UTC (rev 185)
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "SRFramework/WCString.h"
+#include "SRTextView.h"
+#include <strkey.h>
+#include <swmodule.h>
+
+using namespace sword;
+using namespace SRFramework;
+
+class SRLexiView : public SRTextView
+{
+public:
+ SRLexiView();
+ virtual ~SRLexiView();
+
+ VOID SetEntry(const WCString &entry);
+ VOID SetModule(SWModule *pModule);
+ VOID SetSwordReady() { m_fSwordInit = TRUE; }
+ VOID RefreshScreen(BOOL fReloadText);
+ BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
+ VOID Show();
+private:
+ VOID LoadTextView();
+
+ BOOL m_fEntryChanged;
+ BOOL m_fSwordInit;
+ StrKey m_keyEntry;
+ SWModule *m_pModule;
+};
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRModuleView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleView.h 2009-01-02 00:42:58 UTC (rev 184)
+++ trunk/src/SwordReader_GUI/SRModuleView.h 2009-01-02 04:58:40 UTC (rev 185)
@@ -1,5 +1,5 @@
#pragma once
-#include "srtextview.h"
+#include "SRTextView.h"
#include <versekey.h>
#include <swmodule.h>
Modified: trunk/src/SwordReader_GUI/SRTabbedViews.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.cpp 2009-01-02 00:42:58 UTC (rev 184)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.cpp 2009-01-02 04:58:40 UTC (rev 185)
@@ -18,6 +18,8 @@
delete m_viewBible;
if(m_viewComm)
delete m_viewComm;
+ if(m_viewDict)
+ delete m_viewDict;
}
BOOL SRTabbedViews::Create(SRWnd *pParentWnd, RECT bounds)
@@ -68,6 +70,8 @@
return FALSE;
if(m_tabs.InsertItem(SR_TAB_DICT, "Dict") == -1)
return FALSE;
+ if(m_tabs.InsertItem(SR_TAB_ABOUT, "About") == -1)
+ return FALSE;
return TRUE;
}
@@ -85,6 +89,11 @@
return FALSE;
m_viewComm->Hide();
+ m_viewDict = new SRLexiView();
+ if(!m_viewDict || !m_viewDict->Create(this, m_rect))
+ return FALSE;
+ m_viewDict->Hide();
+
// Create the tab control
if(!m_tabs.Create(this, m_rect, WS_CHILD | WS_VISIBLE | TCS_BOTTOM | TCS_FOCUSNEVER))
return FALSE;
@@ -108,6 +117,7 @@
m_viewBible->MoveWindow(&views_rect, TRUE);
m_viewComm->MoveWindow(&views_rect, TRUE);
+ m_viewDict->MoveWindow(&views_rect, TRUE);
return TRUE;
}
@@ -171,7 +181,8 @@
m_viewBible->SetSwordReady();
if(m_viewComm)
m_viewComm->SetSwordReady();
- /* ... */
+ if(m_viewDict)
+ m_viewDict->SetSwordReady();
}
@@ -184,7 +195,7 @@
case SR_TAB_COMM:
return m_viewComm;
case SR_TAB_DICT:
- return NULL;
+ return m_viewDict;
default:
return NULL;
}
@@ -193,10 +204,16 @@
VOID SRTabbedViews::RefreshScreen(BOOL fReloadText)
{
- SRModuleView *view = dynamic_cast<SRModuleView *>(GetCurrentView());
- if(!view)
+ SRModuleView *mview = dynamic_cast<SRModuleView *>(GetCurrentView());
+ if(mview){
+ mview->RefreshScreen(fReloadText);
return;
- view->RefreshScreen(fReloadText);
+ }
+ SRLexiView *lview = dynamic_cast<SRLexiView *>(GetCurrentView());
+ if(mview){
+ lview->RefreshScreen(fReloadText);
+ return;
+ }
}
@@ -264,6 +281,8 @@
m_viewBible->MoveWindow(lpRect, bRepaint);
if(m_viewComm)
m_viewComm->MoveWindow(lpRect, bRepaint);
+ if(m_viewDict)
+ m_viewDict->MoveWindow(lpRect, bRepaint);
/* ... */
}
@@ -295,7 +314,7 @@
BOOL SRTabbedViews::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- SRModuleView *view = dynamic_cast<SRModuleView *>(GetCurrentView());
+ SRTextView *view = GetCurrentView();
if(!view)
return FALSE;
return view->OnKeyDown(nChar, nRepCnt, nFlags);
@@ -377,6 +396,8 @@
if(m_viewComm){
m_viewComm->Hide();
}
+ if(m_viewDict)
+ m_viewDict->Hide();
return SR_TAB_BIBLE;
case SR_TAB_COMM:
if(m_viewComm){
@@ -386,8 +407,13 @@
if(m_viewBible){
m_viewBible->Hide();
}
+ if(m_viewDict)
+ m_viewDict->Hide();
return SR_TAB_COMM;
case SR_TAB_DICT:
+ if(m_viewDict){
+ m_viewDict->Show();
+ }
if(m_viewBible){
m_viewBible->Hide();
}
Modified: trunk/src/SwordReader_GUI/SRTabbedViews.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.h 2009-01-02 00:42:58 UTC (rev 184)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.h 2009-01-02 04:58:40 UTC (rev 185)
@@ -2,10 +2,12 @@
#include "SRFramework/SRWnd.h"
#include "SRFramework/SRTabCtrl.h"
#include "SRModuleView.h"
+#include "SRLexiView.h"
#define SR_TAB_BIBLE 0
#define SR_TAB_COMM 1
#define SR_TAB_DICT 2
+#define SR_TAB_ABOUT 3
using namespace SRFramework;
using namespace sword;
@@ -62,5 +64,6 @@
SRModuleView *m_viewBible;
SRModuleView *m_viewComm;
+ SRLexiView *m_viewDict;
VerseKey m_keyLinked;
};
Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2009-01-02 00:42:58 UTC (rev 184)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2009-01-02 04:58:40 UTC (rev 185)
@@ -874,6 +874,10 @@
>
</File>
<File
+ RelativePath=".\SRLexiView.cpp"
+ >
+ </File>
+ <File
RelativePath=".\SRMainFrame.cpp"
>
</File>
@@ -975,6 +979,10 @@
>
</File>
<File
+ RelativePath=".\SRLexiView.h"
+ >
+ </File>
+ <File
RelativePath=".\SRMainFrame.h"
>
</File>
More information about the sword-cvs
mailing list