// NavBooks.cpp: implementation of the NavBooks class. // ////////////////////////////////////////////////////////////////////// #include "ApplicationInterface.h" #include "NavBooks.h" #include "Navigator.h" //RECT RECT_SCREEN = {0,0,240,294}; #define BUTTON_WIDTH 26 #define BUTTON_HEIGHT 17 #define PADDING_WIDTH 3 #define PADDING_HEIGHT 3 #define MAXHORIZONTAL 8 #define ROW0 15 #define ROW1 30 #define ROW2 45 #define STARTNTROW 160 #define LASTROW 240 ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// NavBooks::NavBooks(Navigator* navigator) { this->navigator=navigator; this->position=&(navigator->position); this->command=UString(L"Select a book:"); this->maxOTNumber=position->otBookCount(); this->maxNumber=position->bookCount(); } NavBooks::~NavBooks() { } void NavBooks::paint() { RECT rt; memset(&rt,0,sizeof(rt)); 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(); // rt.bottom=ROW0; clearRect(&rt); rt.top=ROW0; rt.bottom=ROW1; drawText(&rt,command); rt.top=ROW1; rt.bottom=ROW2; clearRect(&rt); //TCHAR buttonText[4]; //buttonText[3]=L'\0'; setBackground(BUTTON_BACKGROUND); setFont(FONT_NAVIGATION); TCHAR** bookNames=position->getBookNames(); int current=1; int maxTNumber=maxOTNumber; while (current<=maxNumber) { //Paint one testament while (current<=maxTNumber) { int rowStart=current; rt.top=rt.bottom; rt.bottom=rt.top+BUTTON_HEIGHT; rt.right=0; while ((current<=maxTNumber)&&(current-rowStartbookName(current)).c_str(),3); drawText(&rt,bookNames[current-1],3); current++; } //padding right of buttons rt.left=rt.right;rt.right=RECT_SCREEN.right; clearRect(&rt); //padding below buttons rt.left=0; rt.top=rt.bottom; rt.bottom=rt.top+PADDING_HEIGHT; clearRect(&rt); } if (current=ROW2)&&(y=PADDING_WIDTH)&&(y<=BUTTON_HEIGHT)) { int current=vertical*MAXHORIZONTAL+horizontal+1; if (current<=maxOTNumber) return current; } } } else if (y>=STARTNTROW) { y=y-STARTNTROW; int vertical=(y/(PADDING_HEIGHT+BUTTON_HEIGHT)); y=y-vertical*(PADDING_HEIGHT+BUTTON_HEIGHT); int horizontal=(x/(PADDING_WIDTH+BUTTON_WIDTH)); if (horizontal=PADDING_WIDTH)&&(y<=BUTTON_HEIGHT)) { int current=vertical*MAXHORIZONTAL+horizontal+maxOTNumber+1; if (current<=maxNumber) return current; } } } return -1; }