#include "ApplicationInterface.h" #include "NavBooks.h" #include "SimpleNavigator.h" //RECT RECT_SCREEN = {0,0,240,294}; // #define MAXVERTICAL 10 // altered BD Nov 07 to make OK in landscape //#define MAXVERTICAL 9 //#define MAX_OT_COLS 5 // #define ROW0 15 // #define ROW1 30 // #define ROW2 45 // all uses of ROW1 and ROW2 removed BD Nov 2007 to make buttons fit on landscape // the message "Select a book:" will only show in portrait display as it is now // re-sited below the buttons - but it's not really that important anyway #define ROW0 5 NavBooks::NavBooks(SimpleNavigator* navigator): NavPage(navigator) { this->position=&(navigator->position); this->command = "Select a book from the above:"; this->maxOTNumber=position->otBookCount(); this->maxNumber=position->bookCount(); } NavBooks::~NavBooks() { } 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 = 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 //rt.bottom=RECT_SCREEN.bottom; //setBackground(0x00000000); //drawText(&rt,UString(L"test")); //setBackground(); // below simply padded the top of the screen downwards and displayed the string // rt.bottom=ROW0; // clearRect(&rt); // rt.top=ROW0; rt.bottom=ROW1; // drawText(&rt,command); // rt.top=ROW1; rt.bottom=ROW2; // clearRect(&rt); // all references below changed to ROW0 :some were formerly ROW2 - amended BD Nov 07 setBackground(BUTTON_BACKGROUND); setFont(FONT_NAVIGATION); TCHAR** bookNames=position->getBookNames(); int current=1; int maxTNumber=maxOTNumber; //padding left of books rt.top=rt.bottom; rt.bottom=RECT_SCREEN.bottom; rt.right=PADDING_WIDTH; clearRect(&rt); while (current<=maxNumber) { //Paint one testament while (current<=maxTNumber) { int colStart=current; rt.left=rt.right; rt.right=rt.left+BUTTON_WIDTH_BK; rt.bottom=ROW0; while ((current<=maxTNumber)&&(current-colStart=ROW0)&&(y < ROW0 + getMaxRows()*(PADDING_HEIGHT+BUTTON_HEIGHT))) { y=y-ROW0; if ((x>=PADDING_WIDTH)&&(x=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+totalOTCols*(BUTTON_WIDTH_BK+PADDING_WIDTH)) { x=x-(PADDING_WIDTH+totalOTCols*(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=PADDING_HEIGHT)) { int current=horizontal*getMaxRows()+vertical+maxOTNumber+1; if (current<=maxNumber) return current; } } } } return -1; } void NavBooks::userTap(int x, int y) { int number=numberAt(x,y); if (number>0) { navigator->setBook(number); navigator->setMode(MODE_CHAP); } }