[sword-svn] r195 - in trunk/src/SwordReader_GUI: . SRFramework
dtrotzjr at crosswire.org
dtrotzjr at crosswire.org
Mon Jan 5 21:34:02 MST 2009
Author: dtrotzjr
Date: 2009-01-05 21:34:01 -0700 (Mon, 05 Jan 2009)
New Revision: 195
Added:
trunk/src/SwordReader_GUI/SRSubWindow.cpp
trunk/src/SwordReader_GUI/SRSubWindow.h
Modified:
trunk/src/SwordReader_GUI/SRBibleWidget.cpp
trunk/src/SwordReader_GUI/SRBibleWidget.h
trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
trunk/src/SwordReader_GUI/SRTextView.cpp
trunk/src/SwordReader_GUI/SRTextView.h
trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
Added SRSubWindow class to better handle pop-up windows. This commit does not run.
Modified: trunk/src/SwordReader_GUI/SRBibleWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRBibleWidget.cpp 2009-01-05 04:18:08 UTC (rev 194)
+++ trunk/src/SwordReader_GUI/SRBibleWidget.cpp 2009-01-06 04:34:01 UTC (rev 195)
@@ -182,12 +182,18 @@
return FALSE;
m_viewLexi = new SRLexiView(TRUE);
- if(!m_viewLexi || !m_viewLexi->Create(this, lexiRect))
+ if(!m_viewLexi) // Create is handled in the sub-window
return FALSE;
+ m_subWndLexi = new SRSubWindow(m_viewLexi);
+ if(!m_subWndLexi || !m_subWndLexi->Create(this, lexiRect))
+ return FALSE;
m_viewNote = new SRTextView(TRUE);
- if(!m_viewNote || !m_viewNote->Create(this, notesRect))
+ if(!m_viewNote) // Create is handled in the sub-window
return FALSE;
+ m_subWndNote = new SRSubWindow(m_viewNote);
+ if(!m_subWndNote || !m_subWndNote->Create(this, notesRect))
+ return FALSE;
return TRUE;
}
@@ -229,7 +235,7 @@
VOID SRBibleWidget::ShowLexiSubWindow()
{
RECT clientRect;
- RECT mainRect, subRect;
+ RECT mainRect, subRect, nullRect = {0,0,0,0};
int i,j,tmp;
if(!m_viewLexi || !m_viewBible)
return;
@@ -239,11 +245,12 @@
subRect = clientRect;
if(m_fNoteVisible){
- m_viewNote->Hide();
+ m_subWndNote->Hide();
m_fNoteVisible = FALSE;
}
- m_viewLexi->Show();
+ m_subWndLexi->MoveWindow(&nullRect);
+ m_subWndLexi->Show();
for(i = 0, j = 1; i < 80;){
Sleep(5);
tmp = 20 - j++;
@@ -251,9 +258,9 @@
mainRect.bottom -= tmp;
subRect.top = mainRect.bottom;
m_viewBible->MoveWindow(&mainRect);
- m_viewLexi->MoveWindow(&subRect);
+ m_subWndLexi->MoveWindow(&subRect);
m_viewBible->RefreshWindow();
- m_viewLexi->RefreshWindow();
+ m_subWndLexi->RefreshWindow();
}
m_fLexiVisible = TRUE;
}
@@ -261,7 +268,7 @@
VOID SRBibleWidget::ShowNoteSubWindow()
{
RECT clientRect;
- RECT mainRect, subRect;
+ RECT mainRect, subRect, nullRect = {0,0,0,0};
int i,j,tmp;
if(!m_viewNote || !m_viewBible)
return;
@@ -271,11 +278,12 @@
subRect = clientRect;
if(m_fLexiVisible){
- m_viewLexi->Hide();
+ m_subWndLexi->Hide();
m_fLexiVisible = FALSE;
}
- m_viewNote->Show();
+ m_subWndNote->MoveWindow(&nullRect);
+ m_subWndNote->Show();
for(i = 0, j = 1; i < 80;){
Sleep(5);
tmp = 20 - j++;
@@ -283,9 +291,9 @@
mainRect.bottom -= tmp;
subRect.top = mainRect.bottom;
m_viewBible->MoveWindow(&mainRect);
- m_viewNote->MoveWindow(&subRect);
+ m_subWndNote->MoveWindow(&subRect);
m_viewBible->RefreshWindow();
- m_viewNote->RefreshWindow();
+ m_subWndNote->RefreshWindow();
}
m_fNoteVisible = TRUE;
}
Modified: trunk/src/SwordReader_GUI/SRBibleWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRBibleWidget.h 2009-01-05 04:18:08 UTC (rev 194)
+++ trunk/src/SwordReader_GUI/SRBibleWidget.h 2009-01-06 04:34:01 UTC (rev 195)
@@ -1,6 +1,7 @@
#pragma once
#include "SRModuleView.h"
#include "SRModuleHolder.h"
+#include "SRSubWindow.h"
#include "SRLexiView.h"
#include "swmodule.h"
#include "versekey.h"
@@ -50,7 +51,9 @@
static BOOL s_fRegistered;
SRModuleView *m_viewBible;
SRLexiView *m_viewLexi;
+ SRSubWindow *m_subWndLexi;
SRTextView *m_viewNote;
+ SRSubWindow *m_subWndNote;
SWModule *m_modGreekDef;
SWModule *m_modGreekMorph;
SWModule *m_modHebrewMorph;
Modified: trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWnd.h 2009-01-05 04:18:08 UTC (rev 194)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWnd.h 2009-01-06 04:34:01 UTC (rev 195)
@@ -210,6 +210,7 @@
SRWnd* pParentWnd,
HMENU hMenu,
HINSTANCE hInstance);
+ virtual BOOL Create(SRWnd *pParentWnd, RECT rect) { return FALSE; };
HWND GetWindowHandle() const;
}; // END OF SRWnd Class...
Added: trunk/src/SwordReader_GUI/SRSubWindow.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRSubWindow.cpp (rev 0)
+++ trunk/src/SwordReader_GUI/SRSubWindow.cpp 2009-01-06 04:34:01 UTC (rev 195)
@@ -0,0 +1,99 @@
+#include "SRFramework\SRApp.h"
+#include "SRSubWindow.h"
+#include "resource.h"
+
+using namespace SRFramework;
+
+BOOL SRSubWindow::s_fRegistered = false;
+
+SRSubWindow::SRSubWindow(SRWnd *pwndSub)
+:m_wndSub(pwndSub)
+{
+ m_wcsClassName = "SRSubWindow";
+ m_wcsWindowName = "";
+ m_hInstance = SRFramework::SRApp::GetInstanceHandle();
+}
+
+SRSubWindow::~SRSubWindow()
+{
+
+}
+
+
+BOOL SRSubWindow::Create(SRWnd *pParentWnd, RECT bounds)
+{
+ RECT rectSub = bounds;
+ rectSub.top += 20;
+ rectSub.left += 2;
+ rectSub.right -= 2;
+ rectSub.bottom -= 2;
+
+ if(!Register())
+ return FALSE;
+
+ if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName,WS_CHILD | WS_VISIBLE, bounds, pParentWnd, NULL, m_hInstance))
+ return FALSE;
+
+ if(!m_wndSub || !m_wndSub->Create(this, rectSub))
+ return FALSE;
+ m_wndSub->Show();
+
+ return TRUE;
+}
+
+BOOL SRSubWindow::Register()
+{
+ // Register window class...
+ WNDCLASS wc;
+ if(s_fRegistered)
+ return TRUE;
+
+ wc.style = CS_HREDRAW | CS_VREDRAW | CS_PARENTDC;
+ wc.lpfnWndProc = (WNDPROC) MessageRoute;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = m_hInstance;
+ wc.hIcon = NULL;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = 0;
+ wc.lpszClassName = m_wcsClassName.w_str();
+
+ if(RegisterClass(&wc) == 0)
+ return FALSE;
+
+ s_fRegistered = TRUE;
+
+ return TRUE;
+}
+
+
+BOOL SRSubWindow::OnPaint()
+{
+ RECT clientRect;
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(m_hWnd, &ps);
+ INT nSavedDC = SaveDC(hdc);
+
+ GetClientRect(m_hWnd, &clientRect);
+
+ HICON icoCl = LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_CLOSE));
+ DrawIcon(hdc, clientRect.right - 18, 2, icoCl);
+
+ RestoreDC(hdc, nSavedDC);
+ EndPaint(m_hWnd, &ps);
+
+ return TRUE;
+}
+
+void SRSubWindow::MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint)
+{
+ MoveWindow(x,y,nWidth, nHeight, bRepaint);
+ m_wndSub->MoveWindow(2,2,nWidth - 4, nHeight - 4,bRepaint);
+}
+
+void SRSubWindow::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
+{
+ INT x = lpRect->left, y = lpRect->top, nWidth = lpRect->right - lpRect->left, nHeight = lpRect->bottom - lpRect->top;
+ MoveWindow(x,y,nWidth, nHeight, bRepaint);
+}
\ No newline at end of file
Added: trunk/src/SwordReader_GUI/SRSubWindow.h
===================================================================
--- trunk/src/SwordReader_GUI/SRSubWindow.h (rev 0)
+++ trunk/src/SwordReader_GUI/SRSubWindow.h 2009-01-06 04:34:01 UTC (rev 195)
@@ -0,0 +1,23 @@
+#pragma once
+#include "SRFramework\SRWnd.h"
+
+class SRSubWindow : public SRFramework::SRWnd
+{
+public:
+ SRSubWindow(SRFramework::SRWnd *pwndSub);
+ ~SRSubWindow();
+
+
+ BOOL Register();
+ BOOL Create(SRFramework::SRWnd *pParentWnd, RECT bounds);
+
+ BOOL OnPaint();
+ void MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE);
+ void MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
+
+ SRFramework::SRWnd *GetSubWnd() { return m_wndSub; }
+
+private:
+ SRFramework::SRWnd *m_wndSub;
+ static BOOL s_fRegistered;
+};
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRTextView.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.cpp 2009-01-05 04:18:08 UTC (rev 194)
+++ trunk/src/SwordReader_GUI/SRTextView.cpp 2009-01-06 04:34:01 UTC (rev 195)
@@ -23,7 +23,6 @@
*/
#include "SRTextView.h"
#include "SRFramework/SRApp.h"
-#include "resource.h"
#include <Wingdi.h>
using namespace SRFramework;
@@ -56,7 +55,6 @@
, m_nLineY(0)
, m_dwLineNum(0)
, m_wStatusBarHeight(0)
-,m_fIsSubWindow(fSubWindow)
{
m_wcsClassName = "SRTextView";
m_wcsWindowName = "SwordReader";
@@ -99,7 +97,7 @@
if(!Register())
return FALSE;
- if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName,WS_CHILD | (m_fIsSubWindow ? WS_BORDER : 0), bounds, pParentWnd, NULL, m_hInstance))
+ if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName,WS_CHILD, bounds, pParentWnd, NULL, m_hInstance))
return FALSE;
return TRUE;
@@ -755,10 +753,6 @@
}
}
- if(m_fIsSubWindow){
- HICON icoCl = LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_CLOSE));
- DrawIcon(hdc, clientRect.right - 18, m_nTop + 2, icoCl);
- }
SetTextColor(hdc, crOldColor);
ClearFontCache(hdc);
Modified: trunk/src/SwordReader_GUI/SRTextView.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTextView.h 2009-01-05 04:18:08 UTC (rev 194)
+++ trunk/src/SwordReader_GUI/SRTextView.h 2009-01-06 04:34:01 UTC (rev 195)
@@ -763,10 +763,6 @@
we can redraw over it while scrolling.
*/
WORD m_wStatusBarHeight;
- /*! If set indicates this window is a subwindow and some extra drawing
- and event handling is required
- */
- BOOL m_fIsSubWindow;
//CRITICAL_SECTION m_csLoadText;
Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2009-01-05 04:18:08 UTC (rev 194)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2009-01-06 04:34:01 UTC (rev 195)
@@ -906,6 +906,10 @@
>
</File>
<File
+ RelativePath=".\SRSubWindow.cpp"
+ >
+ </File>
+ <File
RelativePath=".\SRTabbedViews.cpp"
>
</File>
@@ -1031,6 +1035,10 @@
>
</File>
<File
+ RelativePath=".\SRSubWindow.h"
+ >
+ </File>
+ <File
RelativePath=".\SRTabbedViews.h"
>
</File>
@@ -1112,11 +1120,11 @@
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
<File
- RelativePath=".\BibleReader.ICO"
+ RelativePath="..\gui\BibleReader.ICO"
>
</File>
<File
- RelativePath="..\gui\BibleReader.ICO"
+ RelativePath=".\BibleReader.ICO"
>
</File>
<File
More information about the sword-cvs
mailing list