[sword-svn] r161 - trunk/src/SwordReader_GUI
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Thu Jul 31 20:38:26 MST 2008
Author: dtrotzjr
Date: 2008-07-31 20:38:25 -0700 (Thu, 31 Jul 2008)
New Revision: 161
Modified:
trunk/src/SwordReader_GUI/SRModuleView.cpp
trunk/src/SwordReader_GUI/SRModuleView.h
trunk/src/SwordReader_GUI/SRTextView.cpp
trunk/src/SwordReader_GUI/SwordReaderResource.h
Log:
Progress bar during background loading looks better now and remains while scrolling the text.
Modified: trunk/src/SwordReader_GUI/SRModuleView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleView.cpp 2008-07-31 04:58:30 UTC (rev 160)
+++ trunk/src/SwordReader_GUI/SRModuleView.cpp 2008-08-01 03:38:25 UTC (rev 161)
@@ -11,9 +11,11 @@
view->m_fThreadRunning = TRUE;
view->m_wStatusBarHeight = SR_STATUS_BAR_HEIGHT;
view->LoadTextView(true);
+ view->m_wStatusBarHeight = 0;
+ view->RefreshWindow();
view->m_fThreadRunning = FALSE;
view->m_fAbortThread = FALSE;
- view->m_wStatusBarHeight = 0;
+
return 0;
}
@@ -97,7 +99,6 @@
WCString buf, text, s;
BOOL done = FALSE;
char strNum[10];
- HDC hdc;
INT rc;
if(!m_fSwordInit)
@@ -156,32 +157,7 @@
done = FALSE;
break;
}else if(fInThread){
- TCHAR szStat[64] = {0};
- RECT r = {0};
- r.left = 0;
- r.right = m_rect.right;
- r.top = m_rect.bottom - 12;
- //r.top = 30;
- r.bottom = m_rect.bottom;
- //r.bottom = 60;
- hdc = GetDC(m_hWnd);
- PreRenderBuff(hdc); // Allows the text to show as soon as it is loaded in.
- float percent = 100 * (float)keyCur.Verse()/(float)keyCur.getVerseMax();
- swprintf(szStat, L"Loading... %f%% done", percent);
- INT nLen = wcsnlen(szStat, 12);
- //HBRUSH brushBG = CreateSolidBrush((COLORREF)BUTTON_BACKGROUND);
-
- HBRUSH brushPBAR = CreateSolidBrush((COLORREF)0x00cf8b55);
- //FillRect(hdc, &r, brushBG);
- //Rectangle(hdc, r.left, r.top, r.right, r.bottom);
- r.right = (r.right - r.left) * (percent/100);
- SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
- FillRect(hdc, &r, brushPBAR);
- Rectangle(hdc, r.left, r.top, r.right, r.bottom);
- SetBkColor(hdc, (COLORREF)0x00cf8b55);
-
- DrawText(hdc, &szStat[0], nLen, &r, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
- ReleaseDC(m_hWnd, hdc);
+ DrawLoadingProgress(keyCur);
}
keyCur.increment(1);
}
@@ -200,6 +176,61 @@
}
+VOID SRModuleView::DrawLoadingProgress(const VerseKey& keyCur)
+{
+ const INT BUFSIZE = 64;
+ TCHAR szStat[BUFSIZE] = {0};
+ RECT r = {0};
+ float fpPercent;
+ HBRUSH brushBG, brushPBAR;
+ HGDIOBJ oldBrush, oldFont;
+ LOGFONT lfFont;
+ HFONT font;
+ INT nLen;
+ HDC hdc;
+ COLORREF oldColor;
+
+ r.left = 0;
+ r.right = m_rect.right;
+ r.top = m_rect.bottom - 12;
+ r.bottom = m_rect.bottom;
+
+ hdc = GetDC(m_hWnd);
+ PreRenderBuff(hdc); // Allows the text to show as soon as it is loaded in.
+ fpPercent = 100.f * (float)keyCur.Verse()/(float)keyCur.getVerseMax();
+ swprintf(szStat, L"%2.1f%%", fpPercent);
+ nLen = wcsnlen(szStat, BUFSIZE);
+
+ brushBG = CreateSolidBrush((COLORREF)BUTTON_BACKGROUND);
+ brushPBAR = CreateSolidBrush((COLORREF)PROGRESS_BACKGROUND);
+ // Draw the status bar...
+ oldBrush = SelectObject(hdc, GetStockObject(LTGRAY_BRUSH));
+ Rectangle(hdc, r.left, r.top, r.right, r.bottom);
+ // Draw the progress bar...
+ r.right = (r.right - r.left) * (fpPercent/100.0f);
+ SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
+ FillRect(hdc, &r, brushPBAR);
+ Rectangle(hdc, r.left, r.top, r.right, r.bottom);
+ // Set the font...
+ SetBkColor(hdc, (COLORREF)PROGRESS_BACKGROUND);
+ memset(&lfFont, 0, sizeof(lfFont));
+ lfFont.lfHeight = -9;
+ lfFont.lfWeight = FW_NORMAL;
+ lfFont.lfQuality = CLEARTYPE_QUALITY;
+ font = CreateFontIndirect(&lfFont);
+ oldFont = SelectObject(hdc, font);
+ oldColor = SetTextColor(hdc, (COLORREF)PROGRESS_TEXT_COLOR);
+ // Draw the percent done...
+ DrawText(hdc, &szStat[0], nLen, &r, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
+ // Restore sanity...
+ SelectObject(hdc, oldFont);
+ SetTextColor(hdc, oldColor);
+ SelectObject(hdc, oldBrush);
+ DeleteObject(font);
+
+ ReleaseDC(m_hWnd, hdc);
+}
+
VOID SRModuleView::CreateLoadTextThread()
{
m_hLoadTextThread = CreateThread(NULL, 0, LoadTextThread, (LPVOID) this, 0, &m_dwLoadTextThreadID);
Modified: trunk/src/SwordReader_GUI/SRModuleView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRModuleView.h 2008-07-31 04:58:30 UTC (rev 160)
+++ trunk/src/SwordReader_GUI/SRModuleView.h 2008-08-01 03:38:25 UTC (rev 161)
@@ -34,7 +34,8 @@
VOID LoadTextView(BOOL fInThread = FALSE);
VOID CreateLoadTextThread();
WCString GetVerseHeader(VerseKey key) const;
-
+ VOID DrawLoadingProgress(const VerseKey& keyCur);
+
VerseKey m_verse;
INT m_nLoadedTill;
SWModule *m_pModule;
Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp 2008-07-31 04:58:30 UTC (rev 160)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp 2008-08-01 03:38:25 UTC (rev 161)
@@ -810,6 +810,8 @@
POINT pt;
RECT rectUpdateRect;
INT nDragDist = 0;
+ RECT rectScroll = m_rect;
+ rectScroll.bottom -= m_wStatusBarHeight;
if(m_fDragging){
pt.x = 0;
@@ -828,7 +830,7 @@
m_nTop = -(m_BTLines.m_lpLines[m_BTLines.m_dwLastLine].m_rect.bottom);
}
- ScrollWindowEx(m_hWnd, 0, nDragDist, NULL, NULL, NULL, &rectUpdateRect, NULL);
+ ScrollWindowEx(m_hWnd, 0, nDragDist, &rectScroll, NULL, NULL, &rectUpdateRect, NULL);
// Invalidate the status bar area as well, otherwise it leaves artifacts.
rectUpdateRect.top -= m_wStatusBarHeight;
InvalidateRect(m_hWnd, &rectUpdateRect, TRUE);
@@ -844,6 +846,8 @@
RECT rectUpdateRect;
BOOL fDone = FALSE;
INT nDirection = m_nRollVelocity > 0 ? 1 : -1;
+ RECT rectScroll = m_rect;
+ rectScroll.bottom -= m_wStatusBarHeight;
while(!fDone && nDirection*m_nRollVelocity > 0){
m_nTop += m_nRollVelocity;
@@ -861,7 +865,7 @@
fDone = TRUE;
}
- ScrollWindowEx(m_hWnd, 0, m_nRollVelocity, NULL, NULL, NULL, &rectUpdateRect, NULL);
+ ScrollWindowEx(m_hWnd, 0, m_nRollVelocity, &rectScroll, NULL, NULL, &rectUpdateRect, NULL);
// Invalidate the status bar area as well, otherwise it leaves artifacts.
rectUpdateRect.top -= m_wStatusBarHeight;
InvalidateRect(m_hWnd, &rectUpdateRect, TRUE);
@@ -886,6 +890,8 @@
INT nRollBy = rectClientRect.bottom - rectClientRect.top;
INT nCalcDist = 0;
CONST INT UPPER_SB = 15; // Upper bound on the scrolling per iteration.
+ RECT rectScroll = m_rect;
+ rectScroll.bottom -= m_wStatusBarHeight;
nDirection = (nDirection > 0) ? 1 : -1;
for(INT i = 0;!fDone && i < nRollBy; i+=nCalcDist){
@@ -904,7 +910,7 @@
m_nTop = -(m_BTLines.m_lpLines[m_BTLines.m_dwLastLine].m_rect.bottom);
fDone = TRUE;
}
- ScrollWindowEx(m_hWnd, 0, nDist, NULL, NULL, NULL, &rectUpdateRect, NULL);
+ ScrollWindowEx(m_hWnd, 0, nDist, &rectScroll, NULL, NULL, &rectUpdateRect, NULL);
// Invalidate the status bar area as well, otherwise it leaves artifacts.
rectUpdateRect.top -= m_wStatusBarHeight;
InvalidateRect(m_hWnd, &rectUpdateRect, TRUE);
@@ -918,6 +924,8 @@
POINT pt;
RECT rectUpdateRect;
INT nDragDist = 0;
+ RECT rectScroll = m_rect;
+ rectScroll.bottom -= m_wStatusBarHeight;
if( yPos >= 0){
pt.x = 0;
@@ -925,7 +933,7 @@
nDragDist = m_nTop - pt.y;
m_nTop = -pt.y;
- ScrollWindowEx(m_hWnd, 0, nDragDist, NULL, NULL, NULL, &rectUpdateRect, NULL);
+ ScrollWindowEx(m_hWnd, 0, nDragDist, &rectScroll, NULL, NULL, &rectUpdateRect, NULL);
// Invalidate the status bar area as well, otherwise it leaves artifacts.
rectUpdateRect.top -= m_wStatusBarHeight;
InvalidateRect(m_hWnd, &rectUpdateRect, TRUE);
Modified: trunk/src/SwordReader_GUI/SwordReaderResource.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderResource.h 2008-07-31 04:58:30 UTC (rev 160)
+++ trunk/src/SwordReader_GUI/SwordReaderResource.h 2008-08-01 03:38:25 UTC (rev 161)
@@ -56,8 +56,10 @@
#define SR_MSRC_CHOOSER 0x8000
#define SR_MSRC_TEXT 0x4000
-#define BUTTON_BACKGROUND 0x00b9ccd5
-#define BUTTON_SEL_BACKGROUND 0x00ffffff
+#define BUTTON_BACKGROUND 0x00B9CCD5
+#define BUTTON_SEL_BACKGROUND 0x00FFFFFF
+#define PROGRESS_BACKGROUND 0x00CF8B55
+#define PROGRESS_TEXT_COLOR 0x00FFFFFF
#define BUTTON_WIDTH_MORE 65
#define BUTTON_INTERNAL_PADDING 3
#define BUTTON_PADDING_WIDTH 1
More information about the sword-cvs
mailing list