[sword-svn] r149 - trunk/src/SwordReader_GUI
alsites at www.crosswire.org
alsites at www.crosswire.org
Sat Jul 12 11:05:26 MST 2008
Author: alsites
Date: 2008-07-12 11:05:26 -0700 (Sat, 12 Jul 2008)
New Revision: 149
Modified:
trunk/src/SwordReader_GUI/SRBookChooser.cpp
trunk/src/SwordReader_GUI/SRBookChooser.h
trunk/src/SwordReader_GUI/SRNumberChooser.cpp
trunk/src/SwordReader_GUI/SRNumberChooser.h
trunk/src/SwordReader_GUI/SwordReaderResource.h
Log:
Finished adding the paging for SmartPhones into the number chooser. Corrected some variable naming. And, adjusted some button sizes as necessary for my Motorola Q9m. If these sizes are too large for some platforms, we may need to use some compile time switches.
Modified: trunk/src/SwordReader_GUI/SRBookChooser.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRBookChooser.cpp 2008-07-12 15:19:33 UTC (rev 148)
+++ trunk/src/SwordReader_GUI/SRBookChooser.cpp 2008-07-12 18:05:26 UTC (rev 149)
@@ -106,7 +106,7 @@
HDC hdc = BeginPaint(m_hWnd, &ps);
- if (m_nSelectedBook < 1 || m_nSelectedBook > 66)
+ if (m_nSelectedBook < 1 || m_nSelectedBook > m_nEndBook)
m_nSelectedBook = 1;
GetClientRect(m_hWnd, &clientRect);
@@ -232,27 +232,27 @@
BOOL SRBookChooser::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){
if(nChar == VK_RIGHT){
- lastChar = VK_RIGHT;
+ m_nLastChar = VK_RIGHT;
MoveRight();
RefreshWindow();
} else if(nChar == VK_DOWN){
- lastChar = VK_DOWN;
+ m_nLastChar = VK_DOWN;
MoveDown();
RefreshWindow();
} else if(nChar == VK_LEFT){
- lastChar = VK_LEFT;
+ m_nLastChar = VK_LEFT;
MoveLeft();
RefreshWindow();
} else if(nChar == VK_UP){
- lastChar = VK_UP;
+ m_nLastChar = VK_UP;
MoveUp();
RefreshWindow();
} else if (nChar == VK_ROCKER) {
- if (lastChar == VK_UP) {
+ if (m_nLastChar == VK_UP) {
MoveDown();
MoveLeft();
RefreshWindow();
- } else if (lastChar == VK_DOWN) {
+ } else if (m_nLastChar == VK_DOWN) {
MoveUp();
MoveRight();
RefreshWindow();
@@ -306,7 +306,7 @@
INT curTrueRow = m_nSelectedBook / nMaxCols;
INT curCol = m_nSelectedBook - (nMaxCols * (curTrueRow - 1));
- if (m_nSelectedBook != m_nEndBook) { //sizeof(m_wcsBookNames)/sizeof(m_wcsBookNames[0])) {
+ if (m_nSelectedBook != m_nEndBook) {
if ((curRow == nMaxRows) && (curCol == nMaxCols)) {
m_nStartAt += nMaxCols;
}
Modified: trunk/src/SwordReader_GUI/SRBookChooser.h
===================================================================
--- trunk/src/SwordReader_GUI/SRBookChooser.h 2008-07-12 15:19:33 UTC (rev 148)
+++ trunk/src/SwordReader_GUI/SRBookChooser.h 2008-07-12 18:05:26 UTC (rev 149)
@@ -34,13 +34,11 @@
INT m_nEndBook;
INT m_nStartAt;
INT m_nSelectedBook;
-// INT selCol;
-// INT selRow;
WORD m_wNextMenuID;
WCString m_wcsPrompt;
WCString *m_wcsBookNames;
static BOOL s_fRegistered;
- UINT lastChar;
+ UINT m_nLastChar;
};
#endif
Modified: trunk/src/SwordReader_GUI/SRNumberChooser.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRNumberChooser.cpp 2008-07-12 15:19:33 UTC (rev 148)
+++ trunk/src/SwordReader_GUI/SRNumberChooser.cpp 2008-07-12 18:05:26 UTC (rev 149)
@@ -1,5 +1,6 @@
#include "SRNumberChooser.h"
#include "SwordReaderResource.h"
+#include <winuserm.h>
BOOL SRNumberChooser::s_fRegistered = false;
@@ -104,12 +105,9 @@
INT nMaxCols = MaxCols();
INT nMaxRows = MaxRows();
- if (selCol < 0 || selCol >= MaxCols())
- selCol = 0;
+ if (m_nSelectedNumber < 1 || m_nSelectedNumber > m_nEndNumber)
+ m_nSelectedNumber = 1;
- if (selRow < 0 || selRow >= MaxRows())
- selRow = 0;
-
HDC hdc = BeginPaint(m_hWnd, &ps);
HBRUSH brushBG = CreateSolidBrush((COLORREF)BUTTON_BACKGROUND);
@@ -136,8 +134,7 @@
nCurrent = m_nStartAt + (nRow * nMaxCols) + nCol;
_itow(nCurrent, buttonText, 10);
- if(nCol == selCol && nRow == selRow) {
- //if(nCurrent == nSelectedBook) {
+ if(nCurrent == m_nSelectedNumber) {
SetBkColor(hdc, BUTTON_SEL_BACKGROUND);
FillRect(hdc, &buttonRect, brushBG);
Rectangle(hdc, buttonRect.left, buttonRect.top, buttonRect.right, buttonRect.bottom);
@@ -225,42 +222,102 @@
BOOL SRNumberChooser::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){
if(nChar == VK_RIGHT){
- INT tempNumber = (MaxCols() * selRow) + selCol + 1;
- if (tempNumber == m_nEndNumber) {
- selCol = 0;
- selRow = 0;
- } else if (selCol == (MaxCols() - 1)) {
- selCol = 0;
- selRow++;
- } else {
- selCol++;
- }
+ m_nLastChar = VK_RIGHT;
+ MoveRight();
RefreshWindow();
} else if(nChar == VK_DOWN){
- selRow++;
- if(selRow >= MaxRows())
- selRow = 0;
+ m_nLastChar = VK_DOWN;
+ MoveDown();
RefreshWindow();
} else if(nChar == VK_LEFT){
- if(selCol <= 0)
- selCol = MaxCols() - 1;
- else
- selCol--;
+ m_nLastChar = VK_LEFT;
+ MoveLeft();
RefreshWindow();
} else if(nChar == VK_UP){
- if(selRow <= 0)
- selRow = MaxRows() - 1;
- else
- selRow--;
+ m_nLastChar = VK_UP;
+ MoveUp();
RefreshWindow();
+ } else if (nChar == VK_ROCKER) {
+ if (m_nLastChar == VK_UP) {
+ MoveDown();
+ MoveLeft();
+ RefreshWindow();
+ } else if (m_nLastChar == VK_DOWN) {
+ MoveUp();
+ MoveRight();
+ RefreshWindow();
+ }
} else if(nChar == VK_RETURN){
- INT number = (selRow * MaxCols()) + selCol + 1;
- ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND,(SR_MSRC_CHOOSER << 16) | (m_type == CHAPTER ? SR_SETCHAPTER : SR_SETVERSE), number);
- ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND,m_wNextMenuID, number);
+ ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND,(SR_MSRC_CHOOSER << 16) | (m_type == CHAPTER ? SR_SETCHAPTER : SR_SETVERSE), m_nSelectedNumber);
+ ::SendMessage(m_pParentWnd->GetWindowHandle(),WM_COMMAND,m_wNextMenuID, m_nSelectedNumber);
}
return true;
}
+void SRNumberChooser::MoveDown()
+{
+ INT nMaxCols = MaxCols();
+ INT nMaxRows = MaxRows();
+ INT curRow = (m_nSelectedNumber - m_nStartAt + 1) / nMaxCols;
+ INT curTrueRow = m_nSelectedNumber / nMaxCols;
+ INT curCol = m_nSelectedNumber - (nMaxCols * curTrueRow);
+
+ if (curCol != nMaxCols)
+ curRow++;
+
+ if ((m_nSelectedNumber + nMaxCols) > m_nEndNumber) {
+ if ((curRow == nMaxRows) && (((nMaxCols - curCol) + m_nSelectedNumber) < m_nEndNumber))
+ m_nStartAt += nMaxCols;
+ m_nSelectedNumber = m_nEndNumber;
+ } else {
+ if (curRow == nMaxRows)
+ m_nStartAt += nMaxCols;
+ m_nSelectedNumber += nMaxCols;
+ }
+}
+
+void SRNumberChooser::MoveLeft()
+{
+ if (m_nSelectedNumber == m_nStartAt) {
+ if (m_nStartAt != 1) {
+ m_nSelectedNumber--;
+ m_nStartAt -= MaxCols();
+ }
+ } else {
+ m_nSelectedNumber--;
+ }
+}
+
+void SRNumberChooser::MoveRight()
+{
+ INT nMaxCols = MaxCols();
+ INT nMaxRows = MaxRows();
+ INT curRow = (m_nSelectedNumber - m_nStartAt + 1) / nMaxCols;
+ INT curTrueRow = m_nSelectedNumber / nMaxCols;
+ INT curCol = m_nSelectedNumber - (nMaxCols * (curTrueRow - 1));
+
+ if (m_nSelectedNumber != m_nEndNumber) {
+ if ((curRow == nMaxRows) && (curCol == nMaxCols)) {
+ m_nStartAt += nMaxCols;
+ }
+ m_nSelectedNumber++;
+ }
+}
+
+void SRNumberChooser::MoveUp()
+{
+ INT nMaxCols = MaxCols();
+
+ if ((m_nSelectedNumber - nMaxCols) < m_nStartAt) {
+ if (!((m_nSelectedNumber - nMaxCols) < 1)) {
+ m_nSelectedNumber -= nMaxCols;
+ m_nStartAt -= nMaxCols;
+ }
+ } else {
+ m_nSelectedNumber -= nMaxCols;
+ }
+}
+
BOOL SRNumberChooser::OnLButtonUp(WORD fwKeys, INT xPos, INT yPos)
{
TCHAR buf[16] = {0};
Modified: trunk/src/SwordReader_GUI/SRNumberChooser.h
===================================================================
--- trunk/src/SwordReader_GUI/SRNumberChooser.h 2008-07-12 15:19:33 UTC (rev 148)
+++ trunk/src/SwordReader_GUI/SRNumberChooser.h 2008-07-12 18:05:26 UTC (rev 149)
@@ -21,11 +21,15 @@
BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
BOOL OnLButtonUp(WORD fwKeys, INT xPos, INT yPos);
protected:
- INT NumberAt(int x, int y);
- INT LeftEdge();
- INT MaxRows();
- INT MaxCols();
- INT MaxNumbersPerScreen();
+ INT NumberAt(int x, int y);
+ INT LeftEdge();
+ INT MaxRows();
+ INT MaxCols();
+ INT MaxNumbersPerScreen();
+ void MoveDown();
+ void MoveLeft();
+ void MoveRight();
+ void MoveUp();
INT m_nEndNumber;
INT m_nStartAt;
@@ -34,8 +38,7 @@
ChooserType m_type;
WCString m_wcsPrompt;
static BOOL s_fRegistered;
- INT selCol;
- INT selRow;
+ UINT m_nLastChar;
};
#endif
Modified: trunk/src/SwordReader_GUI/SwordReaderResource.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderResource.h 2008-07-12 15:19:33 UTC (rev 148)
+++ trunk/src/SwordReader_GUI/SwordReaderResource.h 2008-07-12 18:05:26 UTC (rev 149)
@@ -56,10 +56,10 @@
#define BUTTON_BACKGROUND 0x00b9ccd5
#define BUTTON_SEL_BACKGROUND 0x00ffffff
-#define BUTTON_WIDTH_BOOK 30
-#define BUTTON_WIDTH_NUMBER 20
+#define BUTTON_WIDTH_BOOK 33
+#define BUTTON_WIDTH_NUMBER 28
#define BUTTON_WIDTH_MORE 60
-#define BUTTON_HEIGHT 21
+#define BUTTON_HEIGHT 23
#define BUTTON_PADDING_WIDTH 1
#define BUTTON_PADDING_HEIGHT 1
#define BUTTON_FOREGROUND 0x00000000
More information about the sword-cvs
mailing list