[sword-svn] r115 - in trunk/src/SwordReader_GUI: . SRFramework
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Sat Apr 12 20:28:57 MST 2008
Author: dtrotzjr
Date: 2008-04-12 20:28:56 -0700 (Sat, 12 Apr 2008)
New Revision: 115
Modified:
trunk/src/SwordReader_GUI/Main.cpp
trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp
trunk/src/SwordReader_GUI/SRFramework/SRApp.h
trunk/src/SwordReader_GUI/SRMainFrame.cpp
trunk/src/SwordReader_GUI/SwordReaderApp.cpp
trunk/src/SwordReader_GUI/SwordReaderApp.h
trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
More Restructuring.
Modified: trunk/src/SwordReader_GUI/Main.cpp
===================================================================
--- trunk/src/SwordReader_GUI/Main.cpp 2008-04-12 23:38:02 UTC (rev 114)
+++ trunk/src/SwordReader_GUI/Main.cpp 2008-04-13 03:28:56 UTC (rev 115)
@@ -10,7 +10,6 @@
int nCmdShow)
{
SwordReaderApp *app = new SwordReaderApp(hInstance);
- MSG msg;
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
if (!app->InitApp(nCmdShow))
Modified: trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp 2008-04-12 23:38:02 UTC (rev 114)
+++ trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp 2008-04-13 03:28:56 UTC (rev 115)
@@ -2,11 +2,15 @@
using namespace SRFramework;
HINSTANCE SRFramework::SRApp::s_hInstance = SR_NON_INSTANCE;
+SHACTIVATEINFO SRFramework::SRApp::s_sai;
+
SRApp::SRApp(HINSTANCE hInstance)
:m_hAccelTable(0)
{
s_hInstance = hInstance;
+ memset(&s_sai, 0, sizeof(s_sai));
+ s_sai.cbSize = sizeof(s_sai);
}
SRApp::~SRApp()
Modified: trunk/src/SwordReader_GUI/SRFramework/SRApp.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRApp.h 2008-04-12 23:38:02 UTC (rev 114)
+++ trunk/src/SwordReader_GUI/SRFramework/SRApp.h 2008-04-13 03:28:56 UTC (rev 115)
@@ -1,5 +1,6 @@
#pragma once
#include <windows.h>
+#include <aygshell.h>
namespace SRFramework{
@@ -15,6 +16,7 @@
protected:
static HINSTANCE s_hInstance;
HACCEL m_hAccelTable;
+ static SHACTIVATEINFO s_sai;
};
}
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-04-12 23:38:02 UTC (rev 114)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp 2008-04-13 03:28:56 UTC (rev 115)
@@ -3,8 +3,7 @@
SRMainFrame::SRMainFrame()
{
m_cmdBar = new SRCommandBar();
- m_cmdBar->Create(this,NULL, SR_COMMAND_BAR_ID);
- m_cmdBar->InsertMenuBar(IDM_MENU,0);
+ m_cmdBar->Create(this,IDM_MENU);
}
SRMainFrame::~SRMainFrame()
Modified: trunk/src/SwordReader_GUI/SwordReaderApp.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderApp.cpp 2008-04-12 23:38:02 UTC (rev 114)
+++ trunk/src/SwordReader_GUI/SwordReaderApp.cpp 2008-04-13 03:28:56 UTC (rev 115)
@@ -1,13 +1,14 @@
#include "SwordReaderApp.h"
+#include "SwordReaderResource.h"
-SHACTIVATEINFO SwordReaderApp::s_sai;
+#include <swordce.h>
+
SwordReaderApp::SwordReaderApp(HINSTANCE hInstance)
: SRFramework::SRApp(hInstance)
-, m_swordConf(NULL)
+, m_confOptions(NULL)
{
- memset(&s_sai, 0, sizeof(s_sai));
- s_sai.cbSize = sizeof(s_sai);
+ m_hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_BIBLEREADER);
}
SwordReaderApp::~SwordReaderApp()
@@ -34,7 +35,7 @@
if((msg.message == WM_LBUTTONDOWN || msg.message == WM_KEYDOWN) && (ignoreMsgs || msg.time < ignoreTill))
continue;
- if (!m_hAccelTable || !TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
+ if (!m_hAccelTable || !TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
@@ -43,332 +44,16 @@
return msg.wParam;
}
-bool SwordReaderApp::InitApp(int nCmdShow)
+BOOL SwordReaderApp::InitApp(int nCmdShow)
{
- WNDCLASS wc;
- TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
- TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name
-
- // Create a general options file for storing options
+ // Create a general options file for storing options
// and navigaiton history
const char *cwd = getWorkingDirectory();
char confFName[MAX_PATH];
_snprintf(confFName, MAX_PATH, "%s\\options.conf", cwd);
- m_swordConf = new SWConfig(confFName);
- m_swordConf->Load();
-
- m_hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_BIBLEREADER);
-
- // Initialize global strings
- LoadString(m_hInst, IDC_BIBLEREADER, szWindowClass, MAX_LOADSTRING);
- LoadString(m_hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+ m_confOptions = new SWConfig(confFName);
+ m_confOptions->Load();
- //If it is already running, then focus on the window
- m_hWnd = FindWindow(szWindowClass, NULL);
- if (m_hWnd)
- {
- // set focus to foremost child window
- // The "| 0x01" is used to bring any owned windows to the foreground and
- // activate them.
- SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
- return FALSE;
- }
-
-
- // Register the main app window class...
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = (WNDPROC) SwordReaderApp::MessageRoute;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = m_hInst;
- wc.hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_BIBLEREADER));
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
- wc.lpszMenuName = 0;
- wc.lpszClassName = szWindowClass;
-
- if(!RegisterClass(&wc)){
- return FALSE;
- }
-
- m_hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, m_hInst, NULL);
-
- if (!m_hWnd){
- return FALSE;
- }
- //When the main window is created using CW_USEDEFAULT the height of the menubar (if one
- // is created is not taken into account). So we resize the window after creating it
- // if a menubar is present
- RECT rc;
- GetWindowRect(m_hWnd, &rc);
- rc.bottom -= MENU_HEIGHT;
- if (m_hwndCB)
- MoveWindow(m_hWnd, rc.left, rc.top, rc.right, rc.bottom, FALSE);
-
- if (!m_navigator->initialized()) {
- // I am not convinced that the statement (LPCTSTR)IDD_ERROR_NOBIBLES is correct. -- REVISIT
- MessageBox(m_hWnd, L"Error: No bibles installed.", L"Error", MB_OK | MB_ICONEXCLAMATION);
- return FALSE;
- }
-
- m_backColor = 0x00FFFFFF;
- m_foreColor = 0x00000000;
-
- m_navigator->updateTitle();
-
- ShowWindow(m_hWnd, nCmdShow);
- m_navigator->setMode(MODE_TEXT);
- SetForegroundWindow((HWND)((ULONG) m_hWnd | 0x00000001));
- UpdateWindow(m_hWnd);
-
return TRUE;
-
-}
-
-/* Routes the messages to the appropiate WindowProcedure by unwrapping the lParam
-* we associated with this window upon creation.
-*/
-LRESULT CALLBACK SwordReaderApp::MessageRoute(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- SwordReaderApp* wnd = NULL;
-
- if (message == WM_CREATE) {
- ::SetWindowLong (hwnd, GWL_USERDATA, long((LPCREATESTRUCT(lParam))->lpCreateParams));
- }
-
- wnd = (SwordReaderApp*) (::GetWindowLong (hwnd, GWL_USERDATA));
-
- if (wnd)
- return wnd->WndProc(hwnd, message, wParam, lParam);
- return ::DefWindowProc(hwnd, message, wParam, lParam);
-}
-
-BOOL SwordReaderApp::OnNotify(WPARAM wParam, LPARAM lParam){
- NMHDR *nm = (NMHDR *)lParam;
-
- switch (nm->code) {
- case NM_HOTSPOT:
- m_navigator->urlClicked(((NM_HTMLVIEW *)lParam)->szTarget);
- return TRUE;
- }
- return FALSE;
-}
-
-BOOL SwordReaderApp::OnLButtonDown(WPARAM wParam, LPARAM lParam)
-{
- m_navigator->mouseDown(LOWORD(lParam),HIWORD(lParam));
- return TRUE;
-}
-
-BOOL SwordReaderApp::OnKeyDown(WPARAM wParam, LPARAM lParam)
-{
- m_navigator->keyDown(wParam, lParam);
- return TRUE;
-}
-
-BOOL SwordReaderApp::OnCommand(UINT message, WPARAM wParam, LPARAM lParam)
-{
- BOOL handled = FALSE;
- INT wmId = LOWORD(wParam);
- INT wmEvent = HIWORD(wParam);
-
- switch (wmId) {
- case IDOK:
- SendMessage(m_hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)m_hWnd);
- SendMessage(m_hWnd, WM_CLOSE, 0, 0);
- handled = TRUE;
- break;
- case MENU_ABOUT:
- MessageBox(0, L"Sword reader program for Pocket PC ver. 1.0.1\n\nsee: http://www.crosswire.org/sword/swordreader/\n\nGUI by Johan Gorter, 2004\nNow being maintained by B. Drake, Robin Randall and David Trotz\nProverbs 16:3", L"About", MB_OK);
- handled = TRUE;
- break;
- case MENU_SHUTDOWN:
- SendMessage(m_hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)m_hWnd);
- SendMessage (m_hWnd, WM_CLOSE, 0, 0);
- handled = TRUE;
- exit(0);
- default:
- if ((wmId>=USERBUTTONS)&&(wmId<USERBUTTONS+1000)) {
- m_navigator->buttonClicked(wmId-USERBUTTONS);
- handled = TRUE;
- break;
- }
- else if (m_navigator->menuClicked(wmId)){
- }else
- return DefWindowProc(m_hWnd, message, wParam, lParam);
- break;
- }
- return handled;
-}
-
-BOOL SwordReaderApp::OnCreate(WPARAM wParam, LPARAM lParam)
-{
- RECT clientRect;
- GetClientRect(m_hWnd,&clientRect);
- clientRect.bottom -= MENU_HEIGHT;
- m_navigator = new SimpleNavigator(&clientRect);
-
- CreateCommandBar();
- setMenuSelected(m_hwndCB,MENU_TEXT,1);
-
- CreateTranslationsMenu();
- CreateGlobalOptionsMenu();
-
- return TRUE;
-}
-
-BOOL SwordReaderApp::CreateCommandBar()
-{
- SHMENUBARINFO mbi;
- memset(&mbi, 0, sizeof(SHMENUBARINFO));
- mbi.cbSize = sizeof(SHMENUBARINFO);
- mbi.hwndParent = m_hWnd;
- mbi.nToolBarId = IDM_MENU;
- mbi.hInstRes = m_hInst;
- mbi.nBmpId = 0;
- mbi.cBmpImages = 0;
-
- if (!SHCreateMenuBar(&mbi))
- return FALSE;
-
- m_hwndCB = mbi.hwndMB;
- return TRUE;
-}
-
-BOOL SwordReaderApp::OnPaint(WPARAM wParam, LPARAM lParam)
-{
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(m_hWnd, &ps);
- SetBkMode(hdc,OPAQUE);
- SetBkColor(hdc,(COLORREF)GetSysColor(COLOR_WINDOW));
- m_navigator->paint();
- EndPaint(m_hWnd, &ps);
- return TRUE;
-}
-
-BOOL SwordReaderApp::OnDestroy(WPARAM wParam, LPARAM lParam)
-{
- CommandBar_Destroy(m_hwndCB);
- delete m_navigator;
- m_swordConf->Save();
- delete m_swordConf;
- PostQuitMessage(0);
- return TRUE;
-}
-
-BOOL SwordReaderApp::OnSize(WPARAM wParam, LPARAM lParam)
-{
- return FALSE;
-}
-
-BOOL SwordReaderApp::OnActivate(WPARAM wParam, LPARAM lParam)
-{
- SHHandleWMActivate(m_hWnd, wParam, lParam, &s_sai, FALSE);
- return TRUE;
-}
-
-BOOL SwordReaderApp::OnSettingChange(WPARAM wParam, LPARAM lParam)
-{
- SHHandleWMSettingChange(m_hWnd, wParam, lParam, &s_sai);
- return TRUE;
-}
-
-LRESULT CALLBACK SwordReaderApp::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- BOOL handled = FALSE;
-
- if(hWnd != m_hWnd)
- return FALSE;
-
- switch (message)
- {
- case WM_NOTIFY:
- handled = OnNotify(wParam, lParam);
- break;
- case WM_LBUTTONDOWN:
- handled = OnLButtonDown(wParam, lParam);
- break;
- case WM_KEYDOWN:
- handled = OnKeyDown(wParam, lParam);
- break;
- case WM_COMMAND:
- handled = OnCommand(message, wParam, lParam);
- break;
- case WM_CREATE:
- handled = OnCreate(wParam, lParam);
- break;
- case WM_PAINT:
- handled = OnPaint(wParam, lParam);
- break;
- case WM_DESTROY:
- handled = OnDestroy(wParam, lParam);
- break;
- case WM_ACTIVATE:
- handled = OnActivate(wParam, lParam);
- break;
- case WM_SETTINGCHANGE:
- handled = OnSettingChange(wParam, lParam);
- break;
- case WM_SIZE:
- handled = OnSize(wParam, lParam);
- break;
- default:
- return DefWindowProc(m_hWnd, message, wParam, lParam);
- }
- return handled;
-}
-
-BOOL SwordReaderApp::CreateTranslationsMenu() {
- if(!m_hwndCB)
- return FALSE;
- HMENU menuMenu = getSubMenu(m_hwndCB,MENU_MENU);
- HMENU menuTranslations = CreatePopupMenu();
-
- InsertMenu(menuMenu,0,MF_BYPOSITION | MF_POPUP,(UINT)menuTranslations,L"Translation");
- m_navigator->fillTranslationsMenu(menuTranslations);
-
- DrawMenuBar(m_hwndCB);
- return TRUE;
-}
-
-BOOL SwordReaderApp::CreateGlobalOptionsMenu() {
- if(!m_hwndCB)
- return FALSE;
-
- HMENU menuMenu = getSubMenu(m_hwndCB,MENU_MENU);
- HMENU menuGlobalOptions = CreatePopupMenu();
-
- InsertMenu(menuMenu,0,MF_BYPOSITION | MF_POPUP,(UINT)menuGlobalOptions,L"Options");
- m_navigator->fillGlobalOptionsMenu(menuGlobalOptions);
- m_navigator->toggleOptionMenu(-1); // get all checked menu choiced correct, but don't change anything
-
- DrawMenuBar(m_hwndCB);
- return TRUE;
-}
-
-void SwordReaderApp::SetTitle(const WCString &title) {
- SetWindowText(m_hWnd,title.w_str());
-}
-
-void SwordReaderApp::RefreshScreen() {
- InvalidateRect(m_hWnd, NULL, TRUE);
- UpdateWindow(NULL);
-}
-
-void SwordReaderApp::SelectMenu(std::map<int,int>& menus, int mode) {
- for (unsigned int i = 0;i < menus.size(); i++) {
- setMenuSelected(m_hwndCB,menus[i],(mode==i));
- }
-}
-
-void SwordReaderApp::AddMenu(HMENU menu,int flags, int id, const WCString &text) {
- AppendMenu(menu,flags,USERBUTTONS+id,text.w_str());
-}
-
-
-
-void SwordReaderApp::SetMenu(HMENU menu, int id, bool checked) {
- CheckMenuItem(menu,USERBUTTONS+id,checked?MF_CHECKED:MF_UNCHECKED);
}
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SwordReaderApp.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderApp.h 2008-04-12 23:38:02 UTC (rev 114)
+++ trunk/src/SwordReader_GUI/SwordReaderApp.h 2008-04-13 03:28:56 UTC (rev 115)
@@ -13,57 +13,10 @@
public:
SwordReaderApp(HINSTANCE hInstance);
virtual ~SwordReaderApp();
- bool InitApp(int nCmdShow);
+ BOOL InitApp(int nCmdShow);
WPARAM Run();
- //! 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.
- */
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
private:
- // Message Handlers...
- BOOL OnNotify(WPARAM wParam, LPARAM lParam);
- BOOL OnLButtonDown(WPARAM wParam, LPARAM lParam);
- BOOL OnKeyDown(WPARAM wParam, LPARAM lParam);
- BOOL OnCommand(UINT message, WPARAM wParam, LPARAM lParam);
- BOOL OnPaint(WPARAM wParam, LPARAM lParam);
- BOOL OnCreate(WPARAM wParam, LPARAM lParam);
- BOOL OnDestroy(WPARAM wParam, LPARAM lParam);
- BOOL OnActivate(WPARAM wParam, LPARAM lParam);
- BOOL OnSettingChange(WPARAM wParam, LPARAM lParam);
- BOOL OnSize(WPARAM wParam, LPARAM lParam);
- // Helpers...
- BOOL CreateCommandBar();
- BOOL CreateTranslationsMenu();
- BOOL CreateGlobalOptionsMenu();
- void SelectMenu(std::map<int,int>& menus, int mode);
- void AddMenu(HMENU menu,int flags, int id, const WCString &text);
- void SetMenu(HMENU menu, int id, bool checked);
-
- // I debate which of these should be cached...
- SimpleNavigator *m_navigator;
- SWConfig *m_swordConf;
+
+ SWConfig *m_confOptions ;
SRMainFrame *m_pMainFrame;
-
- static SHACTIVATEINFO s_sai;
};
Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2008-04-12 23:38:02 UTC (rev 114)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2008-04-13 03:28:56 UTC (rev 115)
@@ -638,73 +638,17 @@
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
- RelativePath=".\ApplicationInterface.cpp"
- >
- </File>
- <File
- RelativePath=".\BTextViewer.cpp"
- >
- </File>
- <File
RelativePath=".\Main.cpp"
>
</File>
<File
- RelativePath=".\NavBooks.cpp"
- >
- </File>
- <File
- RelativePath=".\NavChap.cpp"
- >
- </File>
- <File
- RelativePath=".\NavFind.cpp"
- >
- </File>
- <File
- RelativePath=".\Navigator.cpp"
- >
- </File>
- <File
- RelativePath=".\NavNumbers.cpp"
- >
- </File>
- <File
- RelativePath=".\NavRenderText.cpp"
- >
- </File>
- <File
- RelativePath=".\NavVerse.cpp"
- >
- </File>
- <File
- RelativePath=".\SimpleNavigator.cpp"
- >
- </File>
- <File
RelativePath=".\SRMainFrame.cpp"
>
</File>
<File
- RelativePath=".\SwordIndex.cpp"
- >
- </File>
- <File
RelativePath=".\SwordReaderApp.cpp"
>
</File>
- <File
- RelativePath=".\TextControl.cpp"
- >
- </File>
- <File
- RelativePath=".\Utils.cpp"
- >
- </File>
- <File
- RelativePath=".\VerseTextControl.cpp"
- >
- </File>
<Filter
Name="SRFramework"
>
@@ -743,77 +687,21 @@
Filter="h;hpp;hxx;hm;inl"
>
<File
- RelativePath=".\ApplicationInterface.h"
- >
- </File>
- <File
- RelativePath=".\BTextViewer.h"
- >
- </File>
- <File
- RelativePath=".\NavBooks.h"
- >
- </File>
- <File
- RelativePath=".\NavChap.h"
- >
- </File>
- <File
- RelativePath=".\NavFind.h"
- >
- </File>
- <File
- RelativePath=".\Navigator.h"
- >
- </File>
- <File
- RelativePath=".\NavNumbers.h"
- >
- </File>
- <File
- RelativePath=".\NavPage.h"
- >
- </File>
- <File
- RelativePath=".\NavRenderText.h"
- >
- </File>
- <File
- RelativePath=".\NavVerse.h"
- >
- </File>
- <File
RelativePath=".\resource.h"
>
</File>
<File
- RelativePath=".\SimpleNavigator.h"
- >
- </File>
- <File
RelativePath=".\SRMainFrame.h"
>
</File>
<File
- RelativePath=".\SwordIndex.h"
- >
- </File>
- <File
RelativePath=".\SwordReaderApp.h"
>
</File>
<File
- RelativePath=".\TextControl.h"
+ RelativePath=".\SwordReaderResource.h"
>
</File>
- <File
- RelativePath=".\Utils.h"
- >
- </File>
- <File
- RelativePath=".\VerseTextControl.h"
- >
- </File>
<Filter
Name="SRFramework"
>
More information about the sword-cvs
mailing list