[sword-svn] r122 - in trunk/src/SwordReader_GUI: . SRFramework

dtrotzjr at www.crosswire.org dtrotzjr at www.crosswire.org
Tue Apr 22 20:26:55 MST 2008


Author: dtrotzjr
Date: 2008-04-22 20:26:54 -0700 (Tue, 22 Apr 2008)
New Revision: 122

Modified:
   trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
   trunk/src/SwordReader_GUI/SRNumberChooser.cpp
   trunk/src/SwordReader_GUI/SwordReaderResource.h
Log:
Number chooser More button added.

Modified: trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp	2008-04-21 01:35:12 UTC (rev 121)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp	2008-04-23 03:26:54 UTC (rev 122)
@@ -66,16 +66,22 @@
 
 void SRWnd::Show()
 {
-	ShowWindow(m_hWnd, SW_SHOW);
-    InvalidateRect(m_hWnd, NULL, TRUE);
-    UpdateWindow(m_hWnd);
+    ::ShowWindow(m_hWnd, SW_SHOW);
+    ::InvalidateRect(m_hWnd, NULL, TRUE);
+    ::UpdateWindow(m_hWnd);
 }
 
 void SRWnd::Hide()
 {
-	ShowWindow(m_hWnd, SW_HIDE);
+    ::ShowWindow(m_hWnd, SW_HIDE);
 }
 
+void SRWnd::RefreshWindow()
+{
+    ::InvalidateRect(m_hWnd, NULL, TRUE);
+    ::UpdateWindow(m_hWnd);
+}
+
 void SRWnd::MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint)
 {
 	::MoveWindow(m_hWnd, x, y, nWidth, nHeight, bRepaint); 

Modified: trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWnd.h	2008-04-21 01:35:12 UTC (rev 121)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWnd.h	2008-04-23 03:26:54 UTC (rev 122)
@@ -44,6 +44,7 @@
 
         virtual void Show();
         virtual void Hide();
+        virtual void RefreshWindow();
         virtual void MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE);
         virtual void MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
 

Modified: trunk/src/SwordReader_GUI/SRNumberChooser.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRNumberChooser.cpp	2008-04-21 01:35:12 UTC (rev 121)
+++ trunk/src/SwordReader_GUI/SRNumberChooser.cpp	2008-04-23 03:26:54 UTC (rev 122)
@@ -12,7 +12,7 @@
 ,m_nSelectedNumber(0)
 ,m_nStartAt(1)
 {   
-    m_nEndNumber = 0xFFFF; // REMOVE ME!!!!!!
+    m_nEndNumber = 0xAA; // REMOVE ME!!!!!!
     m_wcsClassName = "SRNumberChooser";
     m_wcsWindowName = "Number Chooser";
     m_wcsPrompt = "Choose a number:";
@@ -118,6 +118,13 @@
         buttonRect.top += BUTTON_HEIGHT + BUTTON_PADDING_HEIGHT;
         buttonRect.bottom = buttonRect.top + BUTTON_HEIGHT;
     }
+    // If we didn't reach the end we need to draw the More button...
+    if(nCurrent < m_nEndNumber){
+        buttonRect.left = (clientRect.right - clientRect.left)/2 - BUTTON_WIDTH_MORE/2;
+        buttonRect.right = buttonRect.left + BUTTON_WIDTH_MORE;
+        FillRect(hdc, &buttonRect, brushBG); 
+        DrawText(hdc, L"More...", -1, &buttonRect, DT_CENTER | DT_VCENTER);  
+    }
     //Clean up.
     DeleteObject(brushBG);
     EndPaint(m_hWnd,&ps);
@@ -126,9 +133,18 @@
 
 INT SRNumberChooser::NumberAt(int x, int y) 
 {
-    INT nCol = (x - BUTTON_PADDING_WIDTH) / (BUTTON_WIDTH_NUMBER + BUTTON_PADDING_WIDTH);
-    INT nRow = (y - BUTTON_PADDING_HEIGHT)/ (BUTTON_HEIGHT + BUTTON_PADDING_HEIGHT);
-    INT nNumber = m_nStartAt + (nRow * GetMaxCols()) + nCol;
+    RECT clientRect;
+    INT nCols = (x - BUTTON_PADDING_WIDTH) / (BUTTON_WIDTH_NUMBER + BUTTON_PADDING_WIDTH);
+    INT nRows = (y - BUTTON_PADDING_HEIGHT)/ (BUTTON_HEIGHT + BUTTON_PADDING_HEIGHT);
+    // I ignore the minimal amount of white space between the buttons.
+    INT nNumber = m_nStartAt + (nRows * GetMaxCols()) + nCols; 
+    if(nNumber < m_nStartAt + GetMaxNumbersPerScreen()){
+        GetClientRect(m_hWnd, &clientRect);
+        if((x > ((clientRect.right - clientRect.left)/2 - BUTTON_WIDTH_MORE/2)) &&
+            (x < ((clientRect.right - clientRect.left)/2 - BUTTON_WIDTH_MORE/2) + BUTTON_WIDTH_MORE)){
+            return 0;
+        }
+    }
     if( (nNumber > m_nEndNumber) || (nNumber >= (m_nStartAt + GetMaxNumbersPerScreen())) )
         return -1;
     return nNumber;
@@ -138,10 +154,15 @@
 {
     TCHAR buf[16] = {0};
     INT found = NumberAt(xPos, yPos);
-    if(found < 0)
+    if(found == 0 && (m_nStartAt + GetMaxNumbersPerScreen() <= m_nEndNumber) ){
+        m_nStartAt += GetMaxNumbersPerScreen();
+        RefreshWindow();
+    }else if(found < 0){
         return TRUE;
-    _itow(found, buf, 10);
-    MessageBox(m_hWnd, buf, L"Found", MB_OK);
+    }else{
+        _itow(found, buf, 10);
+        MessageBox(m_hWnd, buf, L"Found", MB_OK);
+    }
     return TRUE;
 }
 void SRNumberChooser::SetSelectedNumber(INT nSelectedNumber)

Modified: trunk/src/SwordReader_GUI/SwordReaderResource.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderResource.h	2008-04-21 01:35:12 UTC (rev 121)
+++ trunk/src/SwordReader_GUI/SwordReaderResource.h	2008-04-23 03:26:54 UTC (rev 122)
@@ -18,11 +18,12 @@
 #define WM_TXT_START WM_USER + 0x00F1
 #define WM_TXT_END   WM_USER + 0x00F2
 
-#define BUTTON_BACKGROUND 0x00b9ccd5
-#define BUTTON_WIDTH_BOOK 26
-#define BUTTON_WIDTH_NUMBER 20
-#define BUTTON_HEIGHT 17
-#define BUTTON_PADDING_WIDTH 3
-#define BUTTON_PADDING_HEIGHT 3
+#define BUTTON_BACKGROUND       0x00b9ccd5
+#define BUTTON_WIDTH_BOOK       26
+#define BUTTON_WIDTH_NUMBER     20
+#define BUTTON_WIDTH_MORE       60
+#define BUTTON_HEIGHT           17
+#define BUTTON_PADDING_WIDTH    3
+#define BUTTON_PADDING_HEIGHT   3
 
 #endif
\ No newline at end of file




More information about the sword-cvs mailing list