[sword-svn] r106 - trunk/src/SwordReader_GUI
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Wed Mar 26 20:50:58 MST 2008
Author: dtrotzjr
Date: 2008-03-26 20:50:57 -0700 (Wed, 26 Mar 2008)
New Revision: 106
Added:
trunk/src/SwordReader_GUI/SRWnd.cpp
trunk/src/SwordReader_GUI/SRWnd.h
Modified:
trunk/src/SwordReader_GUI/ApplicationInterface.h
trunk/src/SwordReader_GUI/Main.cpp
trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
Started some framework for the reorganization. This purposely looks like MFC classes, but MFC is not available on eVC 3, yet I need some form of framework, so I will mimic (yet not duplicate) the MFC framework when needed.
Modified: trunk/src/SwordReader_GUI/ApplicationInterface.h
===================================================================
--- trunk/src/SwordReader_GUI/ApplicationInterface.h 2008-03-26 04:18:44 UTC (rev 105)
+++ trunk/src/SwordReader_GUI/ApplicationInterface.h 2008-03-27 03:50:57 UTC (rev 106)
@@ -12,7 +12,7 @@
#include "utils.h"
#include "WCString.h"
#include "swordce.h"
-#include "../simplegui/resource.h"
+#include "resource.h"
#define setMenuSelected(hWndMB, idButton, checked) SendMessage((hWndMB), TB_CHECKBUTTON,\
Modified: trunk/src/SwordReader_GUI/Main.cpp
===================================================================
--- trunk/src/SwordReader_GUI/Main.cpp 2008-03-26 04:18:44 UTC (rev 105)
+++ trunk/src/SwordReader_GUI/Main.cpp 2008-03-27 03:50:57 UTC (rev 106)
@@ -3,20 +3,13 @@
#include "swordce.h"
#include "SwordReaderApp.h"
-#ifdef SIMPLE
- #include "SimpleNavigator.h"
- #define NAVIGATOR SimpleNavigator
- #include "../simplegui/resource.h"
-#else
- #include "Navigator.h"
- #define NAVIGATOR Navigator
- #include "resource.h"
-#endif
+#include "SimpleNavigator.h"
+#include "resource.h"
#include <aygshell.h>
#include <htmlctrl.h>
-NAVIGATOR* g_navigator;
+SimpleNavigator* g_navigator;
SWConfig *g_swordConf;
static SHACTIVATEINFO s_sai;
Added: trunk/src/SwordReader_GUI/SRWnd.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRWnd.cpp (rev 0)
+++ trunk/src/SwordReader_GUI/SRWnd.cpp 2008-03-27 03:50:57 UTC (rev 106)
@@ -0,0 +1,69 @@
+#include "SRWnd.h"
+
+SRWnd::SRWnd(LPCTSTR lpszClassName,
+ LPCTSTR lpszWindowName,
+ DWORD dwStyle,
+ RECT rect,
+ SRWnd* pParentWnd,
+ HMENU hMenu,
+ HINSTANCE hInstance)
+:m_lpszClassName(lpszClassName)
+,m_lpszWindowName(lpszWindowName)
+,m_dwStyle(dwStyle)
+,m_rect(rect)
+,m_pParentWnd(pParentWnd)
+,m_hMenu(hMenu)
+,m_hInstance(hInstance)
+{
+}
+
+SRWnd::~SRWnd(void)
+{
+}
+
+BOOL SRWnd::Create()
+{
+ m_hWnd = CreateWindow(m_lpszClassName, m_lpszWindowName, m_dwStyle,
+ m_rect.left, m_rect.top, m_rect.right - m_rect.left, m_rect.bottom - m_rect.top, m_pParentWnd->m_hWnd, m_hMenu, m_hInstance, this);
+ return 0;
+}
+
+/* Routes the messages to the appropiate WindowProcedure by unwrapping the lParam
+* we associated with this window upon creation.
+*/
+LRESULT CALLBACK SRWnd::MessageRoute(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ SRWnd* wnd = NULL;
+
+ if (message == WM_CREATE) {
+ ::SetWindowLong (hwnd, GWL_USERDATA, long((LPCREATESTRUCT(lParam))->lpCreateParams));
+ }
+
+ wnd = (SRWnd*) (::GetWindowLong (hwnd, GWL_USERDATA));
+
+ if (wnd)
+ return wnd->WndProcBText(hwnd, message, wParam, lParam);
+ return ::DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+void SRWnd::Show()
+{
+ ShowWindow(m_hWnd, SW_SHOW);
+ InvalidateRect(m_hWnd, NULL, TRUE);
+ UpdateWindow(m_hWnd);
+}
+
+void SRWnd::Hide()
+{
+ ShowWindow(m_hWnd, SW_HIDE);
+}
+
+void SRWnd::MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint)
+{
+ ::MoveWindow(m_hWnd, x, y, nWidth, nHeight, bRepaint);
+}
+
+void SRWnd::MoveWindow(LPCRECT lpRect,BOOL bRepaint)
+{
+ MoveWindow(lpRect->left, lpRect->top, lpRect->right - lpRect->left, lpRect->bottom - lpRect->top, bRepaint);
+}
\ No newline at end of file
Added: trunk/src/SwordReader_GUI/SRWnd.h
===================================================================
--- trunk/src/SwordReader_GUI/SRWnd.h (rev 0)
+++ trunk/src/SwordReader_GUI/SRWnd.h 2008-03-27 03:50:57 UTC (rev 106)
@@ -0,0 +1,57 @@
+#pragma once
+#include <windows.h>
+
+class SRWnd
+{
+public:
+ SRWnd( LPCTSTR lpszClassName,
+ LPCTSTR lpszWindowName,
+ DWORD dwStyle,
+ RECT rect,
+ SRWnd* pParentWnd,
+ HMENU hMenu,
+ HINSTANCE hInstance);
+ virtual ~SRWnd(void);
+ virtual BOOL Register() = 0;
+ //! The actual call back function for this window.
+ /*! This only acts as a mediator between the callback function we really
+ want and the call back the Win API is expecting.
+ @param hwnd Handle to the window.
+ @param message Specifies the message.
+ @param wParam Specifies additional message information. The contents
+ of this parameter depend on the value of the message
+ parameter.
+ @param lParam Specifies additional message information. The contents
+ of this parameter depend on the value of the message
+ parameter.
+ */
+ static LRESULT CALLBACK MessageRoute(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
+ //! The expected WinProc callback function.
+ /*! Handles any messages sent to this window.
+ @param hwnd Handle to the window.
+ @param message Specifies the message.
+ @param wParam Specifies additional message information. The contents
+ of this parameter depend on the value of the message
+ parameter.
+ @param lParam Specifies additional message information. The contents
+ of this parameter depend on the value of the message
+ parameter.
+ */
+ virtual LRESULT CALLBACK WndProcBText(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) = 0;
+ void Show();
+ void Hide();
+ void MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE);
+ void MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE);
+protected:
+ HWND m_hWnd;
+ // These typically are set by the subclass' constructor.
+ LPCTSTR m_lpszClassName;
+ LPCTSTR m_lpszWindowName;
+ DWORD m_dwStyle;
+ RECT m_rect;
+ SRWnd* m_pParentWnd;
+ HMENU m_hMenu;
+ HINSTANCE m_hInstance;
+public:
+ BOOL Create();
+};
Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2008-03-26 04:18:44 UTC (rev 105)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2008-03-27 03:50:57 UTC (rev 106)
@@ -686,6 +686,10 @@
>
</File>
<File
+ RelativePath=".\SRWnd.cpp"
+ >
+ </File>
+ <File
RelativePath=".\SwordIndex.cpp"
>
</File>
@@ -763,6 +767,10 @@
>
</File>
<File
+ RelativePath=".\SRWnd.h"
+ >
+ </File>
+ <File
RelativePath=".\SwordIndex.h"
>
</File>
More information about the sword-cvs
mailing list