[sword-svn] r52 - in trunk/src: . gui
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Mon Dec 10 11:18:33 MST 2007
Author: dtrotzjr
Date: 2007-12-10 11:18:33 -0700 (Mon, 10 Dec 2007)
New Revision: 52
Modified:
trunk/src/SwRd.vcb
trunk/src/SwRd.vco
trunk/src/gui/ApplicationInterface.h
trunk/src/gui/NavBooks.cpp
trunk/src/gui/NavBooks.h
trunk/src/gui/NavNumbers.cpp
trunk/src/gui/NavNumbers.h
trunk/src/gui/NavPage.h
trunk/src/gui/NavRenderText.cpp
trunk/src/gui/TextControl.cpp
trunk/src/gui/Utils.cpp
trunk/src/gui/Utils.h
Log:
Modified: trunk/src/SwRd.vcb
===================================================================
(Binary files differ)
Modified: trunk/src/SwRd.vco
===================================================================
(Binary files differ)
Modified: trunk/src/gui/ApplicationInterface.h
===================================================================
--- trunk/src/gui/ApplicationInterface.h 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/ApplicationInterface.h 2007-12-10 18:18:33 UTC (rev 52)
@@ -34,6 +34,13 @@
#define NOCOLOR 0xFFFFFFFF
+#define BUTTON_WIDTH_BK 26
+#define BUTTON_WIDTH_NM 20
+#define BUTTON_HEIGHT 17
+
+#define PADDING_WIDTH 3
+#define PADDING_HEIGHT 3
+
void initApplicationInterface();
// load string from string table
Modified: trunk/src/gui/NavBooks.cpp
===================================================================
--- trunk/src/gui/NavBooks.cpp 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/NavBooks.cpp 2007-12-10 18:18:33 UTC (rev 52)
@@ -5,15 +5,8 @@
//RECT RECT_SCREEN = {0,0,240,294};
-
-#define BUTTON_WIDTH 26
-#define BUTTON_HEIGHT 17
-
-#define PADDING_WIDTH 3
-#define PADDING_HEIGHT 3
-
// #define MAXVERTICAL 10 // altered BD Nov 07 to make OK in landscape
-#define MAXVERTICAL 9
+//#define MAXVERTICAL 9
#define MAX_OT_COLS 5
@@ -40,8 +33,13 @@
void NavBooks::paint() {
RECT rt;
memset(&rt,0,sizeof(rt));
- RECT_SCREEN.bottom = 320; // portrait or landscape for clearing (Big square area)
- RECT_SCREEN.right = 320;
+
+ //RECT_SCREEN.bottom = 320; // portrait or landscape for clearing (Big square area)
+ //RECT_SCREEN.right = 320;
+
+ RECT_SCREEN.bottom = GetSystemMetrics(SM_CYSCREEN) - 2*MENU_HEIGHT;
+ RECT_SCREEN.right = GetSystemMetrics(SM_CXSCREEN);
+
rt.right=RECT_SCREEN.right;
// to see if the whole screen gets filled
@@ -73,8 +71,8 @@
//Paint one testament
while (current<=maxTNumber) {
int colStart=current;
- rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW0;
- while ((current<=maxTNumber)&&(current-colStart<MAXVERTICAL)) {
+ rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH_BK; rt.bottom=ROW0;
+ while ((current<=maxTNumber)&&(current-colStart<getMaxRows())) {
//padding top of button
rt.top=rt.bottom;rt.bottom=rt.top+PADDING_HEIGHT;
clearRect(&rt);
@@ -108,8 +106,8 @@
// next three lines draw text which will only be seen in portrait mode
setBackground(0xFFFFFFFF); // white
rt.left=0;
- rt.top=ROW0+20+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT);
- rt.bottom=ROW0+20+BUTTON_HEIGHT+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT);
+ rt.top = ROW0 + 20 + getMaxRows()*(BUTTON_HEIGHT+PADDING_HEIGHT);
+ rt.bottom=ROW0+20+BUTTON_HEIGHT+getMaxRows()*(BUTTON_HEIGHT+PADDING_HEIGHT);
drawText(&rt,command);
setBackground();
setFont();
@@ -118,38 +116,38 @@
int NavBooks::numberAt(int x, int y) {
// if ((y>=ROW2)&&(y<ROW2+MAXVERTICAL*(PADDING_HEIGHT+BUTTON_HEIGHT))) {
// y=y-ROW2;
-if ((y>=ROW0)&&(y<ROW0+MAXVERTICAL*(PADDING_HEIGHT+BUTTON_HEIGHT))) {
+if ((y>=ROW0)&&(y < ROW0 + getMaxRows()*(PADDING_HEIGHT+BUTTON_HEIGHT))) {
y=y-ROW0;
// if ((x>=PADDING_WIDTH)&&(x<PADDING_WIDTH+4*(BUTTON_WIDTH+PADDING_WIDTH))) {
// change below needed to make the 'tap' read the 'fifth' column (MAX_OT_COLS = 5)
- if ((x>=PADDING_WIDTH)&&(x<PADDING_WIDTH+MAX_OT_COLS*(BUTTON_WIDTH+PADDING_WIDTH))) {
+ if ((x>=PADDING_WIDTH)&&(x<PADDING_WIDTH+MAX_OT_COLS*(BUTTON_WIDTH_BK+PADDING_WIDTH))) {
x=x-PADDING_WIDTH;
- int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
- x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH);
+ int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH_BK));
+ x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH_BK);
int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
- if (vertical<MAXVERTICAL) {
+ if (vertical<getMaxRows()) {
y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
//button is in bottom left corner
- if ((x<BUTTON_WIDTH)&&(y>=PADDING_HEIGHT)) {
- int current=horizontal*MAXVERTICAL+vertical+1;
+ if ((x<BUTTON_WIDTH_BK)&&(y>=PADDING_HEIGHT)) {
+ int current=horizontal*getMaxRows()+vertical+1;
if (current<=maxOTNumber) return current; // it was a valid OT book
}
}
}
// it wasn't an old testament book, so try for NT book
- else if (x>=PADDING_WIDTH+MAX_OT_COLS*(BUTTON_WIDTH+PADDING_WIDTH)) {
- x=x-(PADDING_WIDTH+5*(BUTTON_WIDTH+PADDING_WIDTH));
- int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
- x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH);
+ else if (x>=PADDING_WIDTH+MAX_OT_COLS*(BUTTON_WIDTH_BK+PADDING_WIDTH)) {
+ x=x-(PADDING_WIDTH+5*(BUTTON_WIDTH_BK+PADDING_WIDTH));
+ int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH_BK));
+ x=x-horizontal*(PADDING_WIDTH+BUTTON_WIDTH_BK);
int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
- if (vertical<MAXVERTICAL) {
+ if (vertical<getMaxRows()) {
y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
//button is in bottom left corner
- if ((x<BUTTON_WIDTH)&&(y>=PADDING_HEIGHT)) {
- int current=horizontal*MAXVERTICAL+vertical+maxOTNumber+1;
+ if ((x<BUTTON_WIDTH_BK)&&(y>=PADDING_HEIGHT)) {
+ int current=horizontal*getMaxRows()+vertical+maxOTNumber+1;
if (current<=maxNumber) return current;
}
}
Modified: trunk/src/gui/NavBooks.h
===================================================================
--- trunk/src/gui/NavBooks.h 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/NavBooks.h 2007-12-10 18:18:33 UTC (rev 52)
@@ -19,7 +19,10 @@
void paint();
// signals that the user has tapped somewhere.
// returns: the number that the user has tapped. -1 if no number
- void userTap(int x, int y);
+ void userTap(int x, int y);
+ int getMaxRows() {
+ return (GetSystemMetrics(SM_CYSCREEN) - 2*MENU_HEIGHT) / (BUTTON_HEIGHT + PADDING_HEIGHT) - 1;
+ };
private:
int numberAt(int x, int y);
SwordIndex* position;
Modified: trunk/src/gui/NavNumbers.cpp
===================================================================
--- trunk/src/gui/NavNumbers.cpp 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/NavNumbers.cpp 2007-12-10 18:18:33 UTC (rev 52)
@@ -5,16 +5,11 @@
//RECT RECT_SCREEN = {0,0,240,294};
-#define BUTTON_WIDTH 20
-#define BUTTON_HEIGHT 17
-#define PADDING_WIDTH 3
-#define PADDING_HEIGHT 3
-
#define MAXHORIZONTAL 10
// #define MAXVERTICAL 10 // altered BD Nov 07 to make OK in landscape
-#define MAXVERTICAL 9
-#define MAXNUMBERS (MAXVERTICAL*MAXHORIZONTAL)
+//#define MAXVERTICAL 9
+#define MAXNUMBERS (getMaxRows()*MAXHORIZONTAL)
// #define ROW0 15
// #define ROW1 30
@@ -23,8 +18,8 @@
// all uses of ROW1 and ROW2 removed BD Nov 2007 to make buttons fit on landscape
// the message "Select a [whatever]:" does not now display but may not really be important
-// #define LASTROW ROW2+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT)
-#define LASTROW ROW0+MAXVERTICAL*(BUTTON_HEIGHT+PADDING_HEIGHT)
+// #define LASTROW ROW2+getMaxRows()*(BUTTON_HEIGHT+PADDING_HEIGHT)
+#define LASTROW ROW0+getMaxRows()*(BUTTON_HEIGHT+PADDING_HEIGHT)
NavNumbers::NavNumbers(SimpleNavigator* navigator):NavPage(navigator) {
}
@@ -39,6 +34,10 @@
void NavNumbers::paint() {
RECT rt;
memset(&rt,0,sizeof(rt));
+
+ RECT_SCREEN.bottom = GetSystemMetrics(SM_CYSCREEN) - 2*MENU_HEIGHT;
+ RECT_SCREEN.right = GetSystemMetrics(SM_CXSCREEN);
+
rt.right=RECT_SCREEN.right;
// to see if the whole screen gets filled
@@ -71,9 +70,9 @@
while ((current<=maxNumber)&&(current<start+MAXNUMBERS)) {
int colStart=current;
- rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW0;
+ rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH_NM; rt.bottom=ROW0;
// rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH; rt.bottom=ROW2;
- while ((current<=maxNumber)&&(current-colStart<MAXVERTICAL)) {
+ while ((current<=maxNumber)&&(current-colStart<getMaxRows())) {
//padding above button
rt.top=rt.bottom;rt.bottom=rt.top+PADDING_HEIGHT;
clearRect(&rt);
@@ -120,19 +119,19 @@
// y=y-ROW2;
y=y-ROW0;
if (x>0) {
- int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH));
+ int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH_NM));
if (horizontal<MAXHORIZONTAL) {
x=x-horizontal*(PADDING_HEIGHT+BUTTON_HEIGHT);
int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT));
- if (vertical<MAXVERTICAL) {
+ if (vertical<getMaxRows()) {
y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
//button is in bottom right corner
if ((x>=PADDING_WIDTH)&&(y>=PADDING_HEIGHT)) {
- int current=horizontal*MAXVERTICAL+vertical+start;
+ int current=horizontal*getMaxRows()+vertical+start;
if (current<=maxNumber) return current;
}
}
- else if (vertical==MAXVERTICAL) { // The 'more' button is here
+ else if (vertical==getMaxRows()) { // The 'more' button is here
y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT);
if (y>=PADDING_HEIGHT) {
x=x+horizontal*(PADDING_HEIGHT+BUTTON_HEIGHT); //undo
Modified: trunk/src/gui/NavNumbers.h
===================================================================
--- trunk/src/gui/NavNumbers.h 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/NavNumbers.h 2007-12-10 18:18:33 UTC (rev 52)
@@ -7,6 +7,7 @@
#include "utils.h"
#include "NavPage.h"
+#include "ApplicationInterface.h"
class SimpleNavigator;
@@ -21,7 +22,10 @@
void paint();
// signals that the user has tapped somewhere.
// returns: the number that the user has tapped. -1 if no number
- int numberAt(int x, int y);
+ int numberAt(int x, int y);
+ int getMaxRows() {
+ return (GetSystemMetrics(SM_CYSCREEN) - 2*MENU_HEIGHT) / (BUTTON_HEIGHT + PADDING_HEIGHT) - 1;
+ };
protected:
int maxNumber;
UString command;
Modified: trunk/src/gui/NavPage.h
===================================================================
--- trunk/src/gui/NavPage.h 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/NavPage.h 2007-12-10 18:18:33 UTC (rev 52)
@@ -29,7 +29,10 @@
// WS_CHILD | BS_PUSHBUTTON,
// RECT_SCREEN.right-30, RECT_SCREEN.top, 30, 20,
// g_hWnd, registerID(goButtonID), g_hInst, NULL);
- NavPage(SimpleNavigator* navigator) {this->navigator=navigator;};
+ NavPage(SimpleNavigator* navigator) {
+ portrait = inPortraitMode();
+ this->navigator=navigator;
+ };
// Destructor
~NavPage() {};
// In the derived class, show all visual components here using
@@ -57,6 +60,8 @@
virtual void keyDown(WPARAM id, LPARAM lparam) {};
protected:
SimpleNavigator* navigator;
+ // Used to determine if the screen switched from portrait to landscape and visa versa.
+ bool portrait;
};
#endif
Modified: trunk/src/gui/NavRenderText.cpp
===================================================================
--- trunk/src/gui/NavRenderText.cpp 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/NavRenderText.cpp 2007-12-10 18:18:33 UTC (rev 52)
@@ -5,6 +5,7 @@
#include <swordce.h>
NavRenderText::NavRenderText(SimpleNavigator* navigator):NavPage(navigator) {
+
textControl = new VerseTextControl(RECT_SCREEN.left, RECT_SCREEN.top, RECT_SCREEN.right, RECT_SCREEN.bottom);
}
Modified: trunk/src/gui/TextControl.cpp
===================================================================
--- trunk/src/gui/TextControl.cpp 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/TextControl.cpp 2007-12-10 18:18:33 UTC (rev 52)
@@ -56,11 +56,11 @@
int height = GetSystemMetrics(SM_CYSCREEN);
if(width < height && !portrait){
portrait = true;
- MoveWindow(htmlControl,0,0,width,height, TRUE);
+ MoveWindow(htmlControl,0,0,width,height - 2*MENU_HEIGHT, TRUE);
}else if(width > height && portrait){
portrait = false;
- MoveWindow(htmlControl,0,0,width,height, TRUE);
+ MoveWindow(htmlControl,0,0,width,height - 2*MENU_HEIGHT, TRUE);
}
}
Modified: trunk/src/gui/Utils.cpp
===================================================================
--- trunk/src/gui/Utils.cpp 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/Utils.cpp 2007-12-10 18:18:33 UTC (rev 52)
@@ -1,4 +1,5 @@
#include "Utils.h"
+#include "ApplicationInterface.h"
struct CharToUchar {
WCHAR operator()(const char in) const {
@@ -52,3 +53,7 @@
}
return result;
}
+
+bool inPortraitMode(){
+ return GetSystemMetrics(SM_CXSCREEN) <= GetSystemMetrics(SM_CYSCREEN);
+}
\ No newline at end of file
Modified: trunk/src/gui/Utils.h
===================================================================
--- trunk/src/gui/Utils.h 2007-12-10 18:15:51 UTC (rev 51)
+++ trunk/src/gui/Utils.h 2007-12-10 18:18:33 UTC (rev 52)
@@ -25,4 +25,6 @@
UString noMarkup(UString in);
+bool inPortraitMode();
+
#endif
More information about the sword-cvs
mailing list