[sword-cvs] swordreader/src/gui NavPage.cpp,NONE,1.1 NavPage.h,NONE,1.1 NavBooks.cpp,1.2,1.3 NavBooks.h,1.2,1.3 NavFind.cpp,1.1,1.2 NavFind.h,1.1,1.2 NavNumbers.cpp,1.2,1.3 NavNumbers.h,1.2,1.3 NavRenderText.cpp,1.7,1.8 NavRenderText.h,1.2,1.3 Navigator.cpp,1.6,1.7 Navigator.h,1.5,1.6 Utils.cpp,1.1.1.1,1.2 gui.vcl,1.17,1.18 gui.vcp,1.6,1.7
sword@www.crosswire.org
sword@www.crosswire.org
Sun, 22 Feb 2004 09:12:29 -0700
Update of /cvs/core/swordreader/src/gui
In directory www:/tmp/cvs-serv10069/src/gui
Modified Files:
NavBooks.cpp NavBooks.h NavFind.cpp NavFind.h NavNumbers.cpp
NavNumbers.h NavRenderText.cpp NavRenderText.h Navigator.cpp
Navigator.h Utils.cpp gui.vcl gui.vcp
Added Files:
NavPage.cpp NavPage.h
Log Message:
First steps towards two gui's: an abstract page
--- NEW FILE: NavPage.cpp ---
// NavPage.cpp: implementation of the NavPage class.
//
//////////////////////////////////////////////////////////////////////
#include "NavPage.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
NavPage::NavPage(Navigator* navigator) {
this->navigator=navigator;
// In a derived class, use this constructor to instantiate visual
// components using CreateWindow. For example:
//
// anEdit = CreateWindow(_T("edit"), NULL,
// WS_CHILD | WS_BORDER,
// RECT_SCREEN.left, RECT_SCREEN.top, 30, 20,
// g_hWnd, NULL, g_hInst, NULL);
//
// In order to listen to button clicks, they first need to be
// registered here in the navigator like this:
//
// aButtonID=navigator->getID();
//
// aButton = CreateWindow(_T("button"), L"Go",
// WS_CHILD | BS_PUSHBUTTON,
// RECT_SCREEN.right-30, RECT_SCREEN.top, 30, 20,
// g_hWnd, registerID(goButtonID), g_hInst, NULL);
}
NavPage::~NavPage() {
}
void NavPage::show() {
// In the derived class, show all visual components here using
// ShowWindow. For example:
//
// ShowWindow(anEdit,SW_SHOW);
}
void NavPage::hide() {
// In the derived class, hide all visual components here using
// ShowWindow. For example:
//
// ShowWindow(anEdit,SW_HIDE);
}
void NavPage::paint() {
// In the derived class, use this method to do all custom
// painting, using methods from ApplicationInterface.cpp
//
// drawText(&RECT_SCREEN, L"Under construction");
}
void NavPage::buttonClicked(int id) {
// In the derived class, use this method to listen to buttons being
// clicked. See the comment in the constructor on how to obtain the id
}
int NavPage::userTap(int x, int y) {
// In the derived class, use this method to listen to 'mouse clicks'
// that do not occur inside visual components.
// Should return -1, or else a useful number for the navigator
return -1;
}
void NavPage::keyDown(WPARAM id, LPARAM lparam) {
// In the derived class, use this method to listen to keys being pressed
}
--- NEW FILE: NavPage.h ---
#ifndef NAVPAGE_H
#define NAVPAGE_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "utils.h"
class Navigator;
class NavPage
{
public:
NavPage(Navigator* navigator);
~NavPage();
virtual void show();
virtual void paint();
virtual void hide();
virtual void buttonClicked(int id);
virtual int userTap(int x, int y);
virtual void keyDown(WPARAM id, LPARAM lparam);
protected:
Navigator* navigator;
};
#endif
Index: NavBooks.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavBooks.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- NavBooks.cpp 31 Jan 2004 22:43:32 -0000 1.2
+++ NavBooks.cpp 22 Feb 2004 16:12:27 -0000 1.3
@@ -19,12 +19,7 @@
#define STARTNTROW 160
#define LASTROW 240
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-NavBooks::NavBooks(Navigator* navigator) {
- this->navigator=navigator;
+NavBooks::NavBooks(Navigator* navigator): NavPage(navigator) {
this->position=&(navigator->position);
this->command=UString(L"Select a book:");
this->maxOTNumber=position->otBookCount();
Index: NavBooks.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavBooks.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- NavBooks.h 31 Jan 2004 22:43:32 -0000 1.2
+++ NavBooks.h 22 Feb 2004 16:12:27 -0000 1.3
@@ -5,13 +5,13 @@
#pragma once
#endif // _MSC_VER > 1000
-#include "utils.h"
+#include "utils.h"
+#include "NavPage.h"
class Navigator;
class SwordIndex;
-class NavBooks
-{
+class NavBooks: public NavPage {
public:
NavBooks(Navigator* navigator);
virtual ~NavBooks();
@@ -21,7 +21,6 @@
// returns: the number that the user has tapped. -1 if no number
int userTap(int x, int y);
private:
- Navigator* navigator;
SwordIndex* position;
UString command;
int maxNumber, maxOTNumber;
Index: NavFind.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavFind.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- NavFind.cpp 31 Jan 2004 22:44:40 -0000 1.1
+++ NavFind.cpp 22 Feb 2004 16:12:27 -0000 1.2
@@ -3,10 +3,11 @@
#include "Navigator.h"
#include <winuser.h>
-NavFind::NavFind(Navigator* navigator) {
- this->navigator=navigator;
+NavFind::NavFind(Navigator* navigator) : NavPage(navigator) {
+ //this->navigator=navigator;
goButtonID=navigator->getID();
- query=L"Busy implementing";
+ query=L"Busy implementing, id=";
+ query+=toUString(goButtonID);
queryEdit = CreateWindow(_T("edit"), NULL,
WS_CHILD | ES_AUTOHSCROLL | ES_LEFT | WS_TABSTOP | WS_BORDER,
RECT_SCREEN.left, RECT_SCREEN.top, RECT_SCREEN.right-30, 20,
Index: NavFind.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavFind.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- NavFind.h 31 Jan 2004 22:44:40 -0000 1.1
+++ NavFind.h 22 Feb 2004 16:12:27 -0000 1.2
@@ -5,12 +5,12 @@
#pragma once
#endif // _MSC_VER > 1000
-#include "utils.h"
+#include "utils.h"
+#include "NavPage.h"
class Navigator;
-class NavFind
-{
+class NavFind: public NavPage {
public:
NavFind(Navigator* navigator);
~NavFind();
@@ -19,7 +19,7 @@
void hide();
void buttonClicked(int id);
private:
- Navigator* navigator;
+ //Navigator* navigator;
HWND queryEdit,go;
int goButtonID;
UString query;
Index: NavNumbers.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavNumbers.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- NavNumbers.cpp 31 Jan 2004 22:43:32 -0000 1.2
+++ NavNumbers.cpp 22 Feb 2004 16:12:27 -0000 1.3
@@ -20,16 +20,15 @@
#define ROW2 45
#define LASTROW 240
-NavNumbers::NavNumbers(Navigator* navigator) {
- this->navigator=navigator;
+NavNumbers::NavNumbers(Navigator* navigator):NavPage(navigator) {
}
NavNumbers::~NavNumbers() {
}
-void NavNumbers::show(int maxNumber, UString command) {
- this->maxNumber=maxNumber;
- this->command=command;
+void NavNumbers::show() {
+ this->maxNumber=navigator->numbersMax;
+ this->command=navigator->numbersTitle;
start=1;
}
Index: NavNumbers.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavNumbers.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- NavNumbers.h 31 Jan 2004 22:43:32 -0000 1.2
+++ NavNumbers.h 22 Feb 2004 16:12:27 -0000 1.3
@@ -6,24 +6,23 @@
#endif // _MSC_VER > 1000
#include "utils.h"
+#include "NavPage.h"
class Navigator;
-class NavNumbers
-{
+class NavNumbers: public NavPage {
public:
NavNumbers(Navigator* navigator);
virtual ~NavNumbers();
// initialize with this maximum number
- void show(int maxNumber, UString command);
+ void show();
// redraw the screen. This should use methods in ApplicationInterface.h to do the drawing
void paint();
// signals that the user has tapped somewhere.
// returns: the number that the user has tapped. -1 if no number
int userTap(int x, int y);
private:
- Navigator* navigator;
int maxNumber;
UString command;
int start;
Index: NavRenderText.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavRenderText.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- NavRenderText.cpp 8 Feb 2004 18:25:23 -0000 1.7
+++ NavRenderText.cpp 22 Feb 2004 16:12:27 -0000 1.8
@@ -1,6 +1,7 @@
#include "ApplicationInterface.h"
#include "NavRenderText.h"
-#include "Navigator.h"
+#include "Navigator.h"
+
#include <swordce.h>
//#define NOHTML
@@ -25,10 +26,7 @@
#define controlToVerse(window,versenr) SendMessage(window, DTM_ANCHORW, FALSE, (LPARAM)(toUString(versenr).c_str()))
-NavRenderText::NavRenderText(Navigator* navigator) {
- this->navigator=navigator;
- currentBook=-1;
- verseCount=5;
+NavRenderText::NavRenderText(Navigator* navigator):NavPage(navigator) {
VERIFY(InitHTMLControl(g_hInst));
htmlControl = CreateWindowEx(WS_EX_NOACTIVATE, WC_HTML, NULL,
WS_CHILD | HS_CLEARTYPE | HS_NOSCRIPTING |
@@ -41,15 +39,14 @@
NavRenderText::~NavRenderText() {
}
-void NavRenderText::show(bool forceRefresh) {
+void NavRenderText::show() {
ShowWindow(htmlControl,SW_SHOW);
- showText(forceRefresh);
+ showText();
}
-void NavRenderText::showText(bool forceRefresh) {
+void NavRenderText::showText() {
int verse=navigator->position.getVerse();
- if ((currentBook!=navigator->position.getBook())
- ||(currentChapter!=navigator->position.getChap()) || forceRefresh) {
+ if (!(navigator->chapterCache)) {
clearHtml(htmlControl);
ShowWindow(htmlControl,SW_HIDE);
load();
@@ -59,6 +56,7 @@
}
else
controlToVerse(htmlControl,verse);
+ navigator->chapterCache=true;
}
void NavRenderText::load() {
@@ -67,8 +65,6 @@
#endif
navigator->position.setMark();
navigator->position.setVerse(1);
- currentBook=navigator->position.getBook();
- currentChapter=navigator->position.getChap();
UString text = L"";
// text += L"<?xml version=\"1.0\" encoding=\"UTF-16\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; // This is not recognized properly
text += L"<html><head><title>c</title>"; // a <style> section presumably gets skipped
@@ -139,18 +135,23 @@
void NavRenderText::keyDown(WPARAM id, LPARAM lparam) {
switch (id) {
case VK_UP:
- navigator->position--;
+ navigator->position--;
+ if (navigator->position.getVerse()==navigator->position.verseCount())
+ navigator->chapterCache=false;
break;
case VK_DOWN:
navigator->position++;
+ if (navigator->position.getVerse()==1) navigator->chapterCache=false;
break;
case VK_LEFT:
navigator->position.setVerse(1);
navigator->position--;
+ navigator->chapterCache=false;
break;
case VK_RIGHT:
navigator->position.setVerse(navigator->position.verseCount());
- navigator->position++;
+ navigator->position++;
+ navigator->chapterCache=false;
break;
}
showText();
@@ -162,8 +163,7 @@
// A simpeler graphical representation not using the HTML component
-NavRenderText::NavRenderText(Navigator* navigator) {
- this->navigator=navigator;
+NavRenderText::NavRenderText(Navigator* navigator): NavPage(navigator) {
}
Index: NavRenderText.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/NavRenderText.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- NavRenderText.h 18 Jan 2004 01:03:23 -0000 1.2
+++ NavRenderText.h 22 Feb 2004 16:12:27 -0000 1.3
@@ -6,29 +6,26 @@
#endif // _MSC_VER > 1000
#include "utils.h"
+#include "NavPage.h"
class Navigator;
-class NavRenderText
-{
+class NavRenderText: public NavPage {
public:
int verseCount; //number of verses on screen
NavRenderText(Navigator* navigator);
virtual ~NavRenderText();
- void show(bool forceRefresh=false);
+ void show();
void paint();
void hide();
void keyDown(WPARAM id, LPARAM lparam);
private:
- Navigator* navigator;
HWND htmlControl;
void load();
- void showText(bool forceRefresh=false);
+ void showText();
UString getVerseHeader();
- int currentBook;
- int currentChapter;
};
#endif // !defined(NAVRENDERTEXT_H)
Index: Navigator.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/Navigator.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Navigator.cpp 3 Feb 2004 18:45:35 -0000 1.6
+++ Navigator.cpp 22 Feb 2004 16:12:27 -0000 1.7
@@ -24,12 +24,12 @@
Navigator::Navigator(RECT* screen) {
RECT_SCREEN=*screen;
mode=-1;
+ nextID = 1;
+ chapterCache=false;
numbers=new NavNumbers(this);
books=new NavBooks(this);
text=new NavRenderText(this);
-
find=new NavFind(this);
- nextID = 1;
optStartID = 0;
optEndID = 0;
transStartID = 0;
@@ -88,12 +88,16 @@
}
}
-void Navigator::showChap() {
- numbers->show(position.chapCount(),UString(L"Select a chapter:"));
+void Navigator::showChap() {
+ numbersMax=position.chapCount();
+ numbersTitle=L"Select a chapter:";
+ numbers->show();
}
void Navigator::showVerse() {
- numbers->show(position.verseCount(),UString(L"Select a verse:"));
+ numbersMax=position.verseCount();
+ numbersTitle=L"Select a verse:";
+ numbers->show();
}
void Navigator::updateTitle() {
@@ -105,13 +109,15 @@
void Navigator::buttonClicked(int id) {
if ((id >= transStartID) && (id <= transEndID)) {
setModule(id);
- checkModuleMenu(id);
- text->show(true);
+ checkModuleMenu(id);
+ chapterCache=false;
+ text->show();
}
else if ((id >= optStartID) && (id <= optEndID)) {
toggleOptionMenu(id);
- setMode(MODE_TEXT);
- text->show(true);
+ setMode(MODE_TEXT);
+ chapterCache=false;
+ text->show();
}
else if (mode==MODE_FIND)
@@ -133,14 +139,16 @@
case MODE_BOOK:
number=books->userTap(x,y);
if (number>0) {
- position.setBook(number);
+ position.setBook(number);
+ chapterCache=false;
setMode(MODE_CHAP);
}
break;
case MODE_CHAP:
number=numbers->userTap(x,y);
if (number>0) {
- position.setChap(number);
+ position.setChap(number);
+ chapterCache=false;
setMode(MODE_VERSE);
}
break;
Index: Navigator.h
===================================================================
RCS file: /cvs/core/swordreader/src/gui/Navigator.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Navigator.h 31 Jan 2004 22:43:32 -0000 1.5
+++ Navigator.h 22 Feb 2004 16:12:27 -0000 1.6
@@ -7,7 +7,8 @@
#include "utils.h"
-#include "SwordIndex.h"
+#include "SwordIndex.h"
+#include "NavPage.h"
#include <swbuf.h>
using namespace sword;
@@ -54,10 +55,15 @@
public:
SwordIndex position;
- NavNumbers* numbers;
- NavBooks* books;
- NavRenderText* text;
- NavFind* find;
+ NavPage* numbers;
+ NavPage* books;
+ NavPage* text;
+ NavPage* find;
+
+ bool chapterCache; // to be set to false if 'text' should reload
+ // its chapter
+ int numbersMax; // When selecting a number, the maximum number
+ UString numbersTitle;
Navigator(RECT* screen);
virtual ~Navigator();
Index: Utils.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/Utils.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Utils.cpp 16 Jan 2004 17:34:20 -0000 1.1.1.1
+++ Utils.cpp 22 Feb 2004 16:12:27 -0000 1.2
@@ -17,12 +17,12 @@
};
UString toUString(int i) {
- TCHAR buffer[8];
+ TCHAR buffer[12];
return UString(_itow(i, buffer, 10));
}
String toCString(int i) {
- char buffer[8];
+ char buffer[12];
return String(_itoa(i, buffer, 10));
}
Index: gui.vcl
===================================================================
RCS file: /cvs/core/swordreader/src/gui/gui.vcl,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- gui.vcl 8 Feb 2004 18:25:23 -0000 1.17
+++ gui.vcl 22 Feb 2004 16:12:27 -0000 1.18
@@ -1,17 +1,48 @@
-<html>
-<body>
-<pre>
-<h1>Build Log</h1>
-<h3>
---------------------Configuration: gui - Win32 (WCE x86) Debug--------------------
-</h3>
-<h3>Command Lines</h3>
-
-
-
-
-<h3>Results</h3>
-gui.exe - 0 error(s), 0 warning(s)
-</pre>
-</body>
-</html>
+<html>
+<body>
+<pre>
+<h1>Build Log</h1>
+<h3>
+--------------------Configuration: gui - Win32 (WCE ARM) Release--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "E:\DOCUME~1\Johan\LOCALS~1\Temp\RSP37.tmp" with contents
+[
+/nologo /W3 /I "..\STL_eVC" /I "..\..\..\sword\include" /I "..\dll1\wincesword\include" /D _WIN32_WCE=300 /D "WIN32_PLATFORM_PSPC=310" /D "ARM" /D "_ARM_" /D UNDER_CE=300 /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /FR"ARMRel/" /Fp"ARMRel/gui.pch" /YX /Fo"ARMRel/" /Oxs /MC /c
+"D:\SwordReader\swordreader\src\gui\NavRenderText.cpp"
+]
+Creating command line "clarm.exe @E:\DOCUME~1\Johan\LOCALS~1\Temp\RSP37.tmp"
+Creating temporary file "E:\DOCUME~1\Johan\LOCALS~1\Temp\RSP38.tmp" with contents
+[
+..\Dll1\ARMRel\sword.lib htmlview.lib oleaut32.lib commctrl.lib coredll.lib aygshell.lib ..\Dll1\ARMRel\sword.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /incremental:no /pdb:"ARMRel/gui.pdb" /nodefaultlib:"libc.lib /nodefaultlib:libcd.lib /nodefaultlib:libcmt.lib /nodefaultlib:libcmtd.lib /nodefaultlib:msvcrt.lib /nodefaultlib:msvcrtd.lib /nodefaultlib:oldnames.lib" /out:"ARMRel/gui.exe" /libpath:"..\STL_eVC" /libpath:"C:\IpaqProgs\SwordReader\src\STL_eVC\\" /subsystem:windowsce,3.00 /align:"4096" /MACHINE:ARM
+.\ARMRel\ApplicationInterface.obj
+.\ARMRel\Main.obj
+.\ARMRel\NavBooks.obj
+.\ARMRel\NavFind.obj
+.\ARMRel\Navigator.obj
+.\ARMRel\NavNumbers.obj
+.\ARMRel\NavPage.obj
+.\ARMRel\NavRenderText.obj
+.\ARMRel\SwordIndex.obj
+.\ARMRel\Utils.obj
+.\ARMRel\BibleReader.res
+]
+Creating command line "link.exe @E:\DOCUME~1\Johan\LOCALS~1\Temp\RSP38.tmp"
+<h3>Output Window</h3>
+Compiling...
+NavRenderText.cpp
+D:\SwordReader\swordreader\src\gui\NavRenderText.cpp(112) : warning C4509: nonstandard extension used: 'load' uses SEH and 'heading' has destructor
+ D:\SwordReader\swordreader\src\gui\NavRenderText.cpp(73) : see declaration of 'heading'
+D:\SwordReader\swordreader\src\gui\NavRenderText.cpp(112) : warning C4509: nonstandard extension used: 'load' uses SEH and 's' has destructor
+ D:\SwordReader\swordreader\src\gui\NavRenderText.cpp(72) : see declaration of 's'
+D:\SwordReader\swordreader\src\gui\NavRenderText.cpp(112) : warning C4509: nonstandard extension used: 'load' uses SEH and 'text' has destructor
+ D:\SwordReader\swordreader\src\gui\NavRenderText.cpp(68) : see declaration of 'text'
+Linking...
+
+
+
+<h3>Results</h3>
+gui.exe - 0 error(s), 3 warning(s)
+</pre>
+</body>
+</html>
Index: gui.vcp
===================================================================
RCS file: /cvs/core/swordreader/src/gui/gui.vcp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gui.vcp 3 Feb 2004 18:45:35 -0000 1.6
+++ gui.vcp 22 Feb 2004 16:12:27 -0000 1.7
@@ -1,1580 +1,1638 @@
-# Microsoft eMbedded Visual Tools Project File - Name="gui" - Package Owner=<4>
-# Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (WCE x86) Application" 0x8301
-# TARGTYPE "Win32 (WCE ARM) Application" 0x8501
-
-CFG=gui - Win32 (WCE ARM) Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
[...3187 lines suppressed...]
+SOURCE=.\BibleReader.ICO
+# End Source File
+# Begin Source File
+
+SOURCE=.\BibleReader.rc
+
+!IF "$(CFG)" == "gui - Win32 (WCE ARM) Release"
+
+!ELSEIF "$(CFG)" == "gui - Win32 (WCE ARM) Debug"
+
+!ELSEIF "$(CFG)" == "gui - Win32 (WCE x86) Release"
+
+!ELSEIF "$(CFG)" == "gui - Win32 (WCE x86) Debug"
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project