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

dtrotzjr at www.crosswire.org dtrotzjr at www.crosswire.org
Sun Mar 30 16:06:19 MST 2008


Author: dtrotzjr
Date: 2008-03-30 16:06:18 -0700 (Sun, 30 Mar 2008)
New Revision: 107

Added:
   trunk/src/SwordReader_GUI/SRFramework/
   trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRApp.h
   trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.h
   trunk/src/SwordReader_GUI/SRFramework/SRFrame.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRFrame.h
   trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRMenu.h
   trunk/src/SwordReader_GUI/SRFramework/SRWidget.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRWidget.h
   trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp
   trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
   trunk/src/SwordReader_GUI/SRFramework/WCString.cpp
   trunk/src/SwordReader_GUI/SRFramework/WCString.h
   trunk/src/SwordReader_GUI/SRMainFrame.cpp
   trunk/src/SwordReader_GUI/SRMainFrame.h
Removed:
   trunk/src/SwordReader_GUI/SRWidget.cpp
   trunk/src/SwordReader_GUI/SRWidget.h
   trunk/src/SwordReader_GUI/SRWnd.cpp
   trunk/src/SwordReader_GUI/SRWnd.h
   trunk/src/SwordReader_GUI/WCString.cpp
   trunk/src/SwordReader_GUI/WCString.h
Modified:
   trunk/src/SwordReader_GUI/ApplicationInterface.h
   trunk/src/SwordReader_GUI/Main.cpp
   trunk/src/SwordReader_GUI/SwordReaderApp.cpp
   trunk/src/SwordReader_GUI/SwordReaderApp.h
   trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
More Framework stuff. Still does not build.

Modified: trunk/src/SwordReader_GUI/ApplicationInterface.h
===================================================================
--- trunk/src/SwordReader_GUI/ApplicationInterface.h	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/ApplicationInterface.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -10,13 +10,16 @@
 #include <htmlctrl.h>
 
 #include "utils.h"
-#include "WCString.h"
+#include "SRFramework/WCString.h"
 #include "swordce.h"
 #include "resource.h"
 
 
 #define setMenuSelected(hWndMB, idButton, checked) SendMessage((hWndMB), TB_CHECKBUTTON,\
 	(WPARAM)idButton, (LPARAM)MAKELONG(checked,0));
+
+NMNEWMENU 
+
 #define getMenu(hWndMB)  (HMENU)SendMessage((hWndMB), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0);
 #define getSubMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_GETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU);
 #define setSubMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_SETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU);

Modified: trunk/src/SwordReader_GUI/Main.cpp
===================================================================
--- trunk/src/SwordReader_GUI/Main.cpp	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/Main.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,17 +1,8 @@
-#include "ApplicationInterface.h"
-#include "Main.h"
-#include "swordce.h"
-#include "SwordReaderApp.h"
-
-#include "SimpleNavigator.h"
-#include "resource.h"
-
 #include <aygshell.h>
 #include <htmlctrl.h>
 
-SimpleNavigator* g_navigator;
-SWConfig *g_swordConf;
-static SHACTIVATEINFO s_sai;
+#include "SwordReaderApp.h"
+#include "resource.h"
 
 int WINAPI WinMain(	HINSTANCE hInstance,
 					HINSTANCE hPrevInstance,
@@ -20,43 +11,13 @@
 {
     SwordReaderApp *app = new SwordReaderApp();
 	MSG msg;
-	HACCEL hAccelTable;
-	bool ignoreMsgs = false;
-	DWORD ignoreTill = GetTickCount();
 
-	// Some visual indication things are taking place...
 	HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
-	
-	// Perform application initialization:
 	if (!app->InitApp(hInstance, nCmdShow)) 
 		return FALSE; // Either it failed, or it's already loaded...
-
-	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_BIBLEREADER);
-	
-    // Turn off the wait icon...
 	SetCursor(hOldCursor);
 	
-    // Main message loop:
-	while (GetMessage(&msg, NULL, 0, 0)) 
-	{
-		if(msg.message == WM_TXT_START){ 
-			ignoreMsgs = true;
-		}else if(msg.message == WM_TXT_END){
-			ignoreMsgs = false;
-			ignoreTill = msg.time;
-		}
-		// If we have a button or key event, and we are in the ignore message 
-		// window of time we ignore this message
-		if((msg.message == WM_LBUTTONDOWN || msg.message == WM_KEYDOWN) && (ignoreMsgs || msg.time < ignoreTill))
-			continue;
-
-		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
-		{
-			TranslateMessage(&msg);
-			DispatchMessage(&msg);
-		}
-	}
-	return msg.wParam;
+    return app->Run();
 }
 
 namespace sword {

Added: trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRApp.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,30 @@
+#include "SRApp.h"
+using namespace SRFramework;
+
+HINSTANCE SRFramework::SRApp::s_hInstance = SR_NON_INSTANCE;
+
+SRApp::SRApp(HINSTANCE hInstance)
+:m_hAccelTable(0)
+{
+    s_hInstance = hInstance;
+}
+
+SRApp::~SRApp()
+{
+    
+}
+
+WPARAM SRApp::Run()
+{
+    MSG msg;
+	
+    // Main message loop:
+    while (GetMessage(&msg, NULL, 0, 0)) {
+        if(!m_hAccelTable || !TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg)) {
+	    TranslateMessage(&msg);
+	    DispatchMessage(&msg);
+        }
+    }
+    return msg.wParam;
+}
+

Added: trunk/src/SwordReader_GUI/SRFramework/SRApp.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRApp.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRApp.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,20 @@
+#pragma once
+#include <windows.h>
+
+
+namespace SRFramework{
+#define SR_NON_INSTANCE 0
+
+    class SRApp
+    {
+    public:
+        SRApp(HINSTANCE hInstance);
+        virtual ~SRApp();
+        virtual WPARAM Run();
+        static HINSTANCE GetInstanceHandle() { return s_hInstance; }
+    protected:
+        static HINSTANCE s_hInstance;
+        HACCEL           m_hAccelTable;
+    };
+
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,29 @@
+#include "SRCommandBar.h"
+using namespace SRFramework;
+
+SRCommandBar::SRCommandBar(void)
+{
+}
+
+SRCommandBar::~SRCommandBar(void)
+{
+    if(m_menu)
+        delete m_menu;
+}
+
+BOOL SRCommandBar::Create(SRWnd* pWndParent, DWORD dwStyle, UINT nBarID)
+{
+    m_hWndCB = CommandBar_Create(SRApp::GetInstanceHandle(), pWndParent->GetWindowHandle(), nBarID);
+    return m_hWndCB != NULL;
+}
+BOOL SRCommandBar::InsertMenuBar(WORD wMenuID, WORD wButton)
+{
+    return ::CommandBar_InsertMenubar(m_hWndCB, SRApp::GetInstanceHandle(),wMenuID, wButton);
+}
+
+INT SRCommandBar::Height()
+{
+    RECT MenuBarRect;
+    GetWindowRect(m_hWndCB, &MenuBarRect);
+    return MenuBarRect.bottom - MenuBarRect.top;
+}

Added: trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRCommandBar.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,24 @@
+#pragma once
+#include <windows.h>
+#include <aygshell.h>
+#include "SRWnd.h"
+#include "SRApp.h"
+#include "SRMenu.h"
+
+namespace SRFramework
+{
+
+    class SRCommandBar
+    {
+    public:
+        SRCommandBar(void);
+        virtual ~SRCommandBar(void);
+        INT Height();
+        BOOL Create(SRWnd* pWndParent, DWORD dwStyle, UINT nBarID);
+        BOOL InsertMenuBar(WORD wMenuID, WORD wButton);
+    protected:
+        HWND m_hWndCB;
+        SRMenu *m_menu;
+    };
+
+}

Added: trunk/src/SwordReader_GUI/SRFramework/SRFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRFrame.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRFrame.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,28 @@
+#include "SRFrame.h"
+
+using namespace SRFramework;
+
+SRFrame::SRFrame()
+{
+}
+
+SRFrame::~SRFrame()
+{
+}
+
+BOOL SRFrame::Create(const WCString	&wcsClassName,
+                     const WCString &wcsWindowName,
+                     DWORD		    dwStyle,
+                     RECT		    rect,
+                     SRWnd*		    pParentWnd,
+                     HMENU		    hMenu,
+                     HINSTANCE	    hInstance)
+{
+    return SRWnd::Create(wcsClassName, wcsWindowName, dwStyle, rect, pParentWnd, hMenu, hInstance);
+}
+
+BOOL SRFrame::SetTitle(const WCString & wcsTitle)
+{
+    m_wcsTitle = wcsTitle;
+    return ::SetWindowText(m_hWnd, m_wcsTitle.w_str());
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/SRFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRFrame.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRFrame.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,23 @@
+#pragma once
+#include <windows.h>
+#include "SRWnd.h"
+
+namespace SRFramework
+{
+    class SRFrame : public SRWnd
+    {
+    public:
+        SRFrame();
+        virtual ~SRFrame();
+        virtual BOOL Create(const WCString	&wcsClassName,
+              const WCString    &wcsWindowName,
+              DWORD		    dwStyle,
+              RECT		    rect,
+              SRWnd*		pParentWnd,
+              HMENU		    hMenu,
+              HINSTANCE	    hInstance);
+        BOOL SetTitle(const WCString &wcsTitle);
+    protected:
+        WCString    m_wcsTitle;
+    };
+}

Added: trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRMenu.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,42 @@
+#include "SRMenu.h"
+using namespace SRFramework;
+
+
+SRMenu::SRMenu()
+{
+}
+
+SRMenu::SRMenu(HMENU hMenu)
+{
+    m_hMenu = hMenu;
+}
+
+void SRMenu::DestroyMenu()
+{
+    if(m_hMenu)
+        ::DestroyMenu(m_hMenu);
+}
+
+SRMenu::~SRMenu()
+{
+    DestroyMenu();
+}
+
+BOOL SRMenu::CreateMenu()
+{
+    DestroyMenu();
+    m_hMenu = ::CreateMenu();
+    return m_hMenu != NULL;
+}
+
+BOOL SRMenu::AppendMenu(UINT nFlags, UINT_PTR nIDNewItem, const WCString &wcsNewItem)
+{
+    return ::AppendMenu(m_hMenu, nFlags, nIDNewItem, wcsNewItem.w_str());
+}
+
+BOOL SRMenu::CreatePopupMenu()
+{
+    DestroyMenu();
+    m_hMenu = ::CreatePopupMenu();
+    return m_hMenu != NULL;
+}

Added: trunk/src/SwordReader_GUI/SRFramework/SRMenu.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRMenu.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRMenu.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,24 @@
+#pragma once
+#include <windows.h>
+#include "WCString.h"
+
+namespace SRFramework
+{
+
+    class SRMenu
+    {
+    public:
+        SRMenu();
+        SRMenu(HMENU hMenu);
+        virtual ~SRMenu();
+
+    protected:
+        HMENU m_hMenu;
+    public:
+        BOOL CreateMenu();
+        BOOL CreatePopupMenu();
+        void DestroyMenu();
+        BOOL AppendMenu(UINT nFlags, UINT_PTR nIDNewItem,const WCString &wcsNewItem);
+    };
+
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/SRWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWidget.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWidget.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,23 @@
+#include "SRWidget.h"
+
+SRWidget::SRWidget(void)
+{
+}
+
+SRWidget::~SRWidget(void)
+{
+}
+
+COLORREF SRWidget::setBackColor(HDC hdc, COLORREF  color)
+{
+    m_backColor = color;
+    return SetBkColor(hdc, m_backColor);
+}
+
+COLORREF SRWidget::setForeColor(HDC hdc, COLORREF  color)
+{
+    m_foreColor = color;
+    return SetTextColor(hdc, m_foreColor);
+}
+
+void SRWidget::SetFont(HFONT font) { /*TODO*/ }
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/SRWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWidget.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWidget.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,25 @@
+#pragma once
+#include <windows.h>
+namespace SRFramework
+{
+
+    class SRWidget
+    {
+    public:
+        SRWidget(void);
+        virtual ~SRWidget(void);
+    protected:
+        // We may not want to cache the color. 
+        // One reason we may is to track the preferred
+        // back color compared to say the color of a rectangle.
+        COLORREF    m_backColor;
+        COLORREF    m_foreColor;
+        HFONT       m_curFont;
+        HFONT       m_oldFont;
+    public:
+        COLORREF setBackColor(HDC hdc, COLORREF color);
+        COLORREF setForeColor(HDC hdc, COLORREF color);
+        void SetFont(HFONT font);
+    };
+
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWnd.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,73 @@
+#include "SRWnd.h"
+using namespace SRFramework;
+
+SRWnd::SRWnd()
+{
+}
+
+SRWnd::~SRWnd(void)
+{
+}
+
+BOOL SRWnd::Create(const WCString	&wcsClassName,
+             const WCString &wcsWindowName,
+			 DWORD			dwStyle,
+			 RECT			rect,
+			 SRWnd*			pParentWnd,
+			 HMENU			hMenu,
+			 HINSTANCE		hInstance)
+{
+    m_rect = rect;
+    m_pParentWnd = pParentWnd;
+    HWND parent = m_pParentWnd ? m_pParentWnd->m_hWnd : NULL;
+    m_hMenu = hMenu;
+    m_hInstance = hInstance;
+
+    m_hWnd = CreateWindow(wcsClassName.w_str(), wcsWindowName.w_str(), 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 m_hWnd != NULL;
+}
+
+/* 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);
+}
+HWND SRWnd::GetWindowHandle() const
+{
+    return m_hWnd;
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/SRWnd.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRWnd.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRWnd.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,65 @@
+#pragma once
+#include <windows.h>
+#include "WCString.h"
+
+namespace SRFramework
+{
+
+    class SRWnd
+    {
+    public:
+        SRWnd();
+        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.
+        WCString	m_wcsClassName;
+        WCString	m_wcsWindowName;
+        DWORD		m_dwStyle;
+        RECT		m_rect;
+        SRWnd*		m_pParentWnd;
+        HMENU		m_hMenu;
+        HINSTANCE	m_hInstance;
+    public:
+        virtual BOOL Create(const WCString	&wcsClassName,
+              const WCString    &wcsWindowName,
+              DWORD		    dwStyle,
+              RECT		    rect,
+              SRWnd*		pParentWnd,
+              HMENU		    hMenu,
+              HINSTANCE	    hInstance);
+        HWND GetWindowHandle() const;
+
+    };
+
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/WCString.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/WCString.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/WCString.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,238 @@
+#include "WCString.h"
+#include <string.h>
+using namespace SRFramework;
+
+WCString::WCString(void)
+: char_copy(NULL)
+, data(L" ")
+{
+
+}
+
+WCString::~WCString(void)
+{
+    if(char_copy)
+        delete [] char_copy;
+}
+
+WCString::WCString(const char * rhs)
+: char_copy(NULL)
+{
+    unsigned int len = strlen(rhs);
+    unsigned int i = 0;
+    if(data.size() < len)
+        data.resize(len);
+
+    for(i = 0; i < len; i++){
+        data[i] = (wchar_t)rhs[i];
+    }
+}
+
+WCString::WCString(const WCString &rhs)
+: data(rhs.data)
+, char_copy(NULL)
+{
+
+}
+
+WCString::WCString(const wchar_t * rhs)
+: char_copy(NULL)
+{
+    unsigned int len = 0;
+    unsigned int i = 0;
+
+    // This is so dangerous...
+    while(rhs[len]) len++;
+    
+    if(data.size() < len)
+        data.resize(len);
+
+    for(i = 0; i < len; i++){
+        data[i] = rhs[i];
+    }
+}
+
+WCString::WCString(const std::string &rhs)
+: char_copy(NULL)
+{
+    unsigned int len = rhs.length();
+    unsigned int i = 0;
+    if(data.size() < len)
+        data.resize(len);
+
+    for(i = 0; i < len; i++){
+        data[i] = (wchar_t)rhs[i];
+    }
+}
+
+std::string WCString::to_string()
+{
+    unsigned int i = 0;
+    std::string retval;
+    retval.resize(data.length());
+    for(i = 0; i < data.length(); i++)
+        retval[i] = (char)data[i];
+    retval[i] = 0;
+    return retval;
+}
+
+WCString &WCString::operator=(const WCString &rhs)
+{
+    if(this != &rhs)
+        data = rhs.data;
+
+    return *this;
+}
+
+const wchar_t *WCString::w_str() const
+{
+    return data.c_str();
+}
+
+const char *WCString::c_str() const
+{
+    unsigned int i = 0;
+    if(char_copy)
+        delete [] char_copy;
+    char_copy = new char[data.length() + 1];
+    for(i = 0; i < data.length(); i++)
+        char_copy[i] = (char)data[i];
+    char_copy[i] = 0;
+
+    return char_copy;
+}
+WCString &WCString::operator=(const std::string &rhs)
+{
+    unsigned int i = 0;
+    if(rhs.length() > data.size())
+        data.resize(rhs.length());
+    for(i = 0; i < rhs.length(); i++)
+        data[i] = (wchar_t)rhs[i];
+
+    return *this;
+}
+
+WCString &WCString::operator=(const wchar_t *rhs)
+{
+    unsigned int i = 0;
+    unsigned int len = 0;
+    // This is so dangerous...
+    while(rhs[len]) len++;
+
+    if(len > data.size())
+        data.resize(len);
+    for(i = 0; i < len; i++)
+        data[i] = rhs[i];
+    
+    return *this;
+}
+
+WCString &WCString::operator=(const char *rhs)
+{
+    unsigned int i = 0;
+    unsigned int len = 0;
+    // This is so dangerous...
+    while(rhs[len]) len++;
+
+    if(len > data.size())
+        data.resize(len);
+    for(i = 0; i < len; i++)
+        data[i] = (wchar_t)rhs[i];
+
+    return *this;
+}
+
+WCString &WCString::operator+=(const WCString &rhs)
+{
+    unsigned int i = 0;
+    unsigned int di = data.length();
+    unsigned int ri = rhs.length();
+
+    if(this == &rhs)
+        return *this;
+    if(data.size() < rhs.length() + di)
+        data.resize(rhs.length() + di);
+
+    for(i = 0; i < rhs.length(); i++){
+        data[di + i] = rhs.data[i];
+    }
+
+    return *this;
+}
+
+WCString &WCString::operator+=(const std::string &rhs)
+{
+    unsigned int i = 0;
+    unsigned int di = data.length();
+    if(rhs.length() + di > data.size())
+        data.resize(rhs.length() + di);
+    for(i = 0; i < rhs.length(); i++)
+        data[di + i] = (wchar_t)rhs[i];
+    return *this;
+}
+
+WCString &WCString::operator+=(const wchar_t *rhs)
+{
+    unsigned int i = 0;
+    unsigned int len = 0;
+    unsigned int di = data.length();
+    // This is so dangerous...
+    while(rhs[len]) len++;
+
+    if(len + di > data.size())
+        data.resize(len + di);
+    for(i = 0; i < len; i++)
+        data[di + i] = rhs[i];
+    //data[di + i] = 0;
+    return *this;
+}
+
+WCString &WCString::operator+=(const char *rhs)
+{
+    unsigned int i = 0;
+    unsigned int len = 0;
+    unsigned int di = data.length();
+    
+    // This is so dangerous...
+    while(rhs[len]) len++;
+
+    if(len + di > data.size())
+        data.resize(len + di);
+    for(i = 0; i < len; i++) 
+        data[di + i] = (wchar_t)rhs[i];
+
+    return *this;
+}
+
+
+WCString WCString::operator+(const WCString &rhs)
+{
+    WCString retval = *this;
+    retval += rhs;
+
+    return retval;
+}
+
+WCString WCString::operator+(const std::string &rhs)
+{   
+    WCString retval = *this;
+    retval += rhs;
+
+    return retval;
+}
+
+WCString WCString::operator+(const wchar_t *rhs)
+{
+    WCString retval = *this;
+    retval += rhs;
+
+    return retval;
+}
+
+WCString WCString::operator+(const char *rhs)
+{
+    WCString retval = *this;
+    retval += rhs;
+
+    return retval;
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRFramework/WCString.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/WCString.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/WCString.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <string>
+namespace SRFramework
+{
+    class WCString
+    {
+    public:
+        WCString(void);
+        WCString(const char *rhs);
+        WCString(const wchar_t *rhs);
+        WCString(const std::string &rhs);
+        WCString(const WCString &rhs);
+
+        ~WCString(void);
+
+        std::string to_string();
+        const wchar_t *w_str() const;
+        const char *c_str() const;
+
+        unsigned int length() const 
+        { return data.length(); }
+        void clear() { data.clear(); }
+
+        WCString &operator=(const WCString &rhs);
+        WCString &operator=(const std::string &rhs);
+        WCString &operator=(const wchar_t *rhs);
+        WCString &operator=(const char *rhs);
+
+        WCString &operator+=(const WCString &rhs);
+        WCString &operator+=(const std::string &rhs);
+        WCString &operator+=(const wchar_t *rhs);
+        WCString &operator+=(const char *rhs);
+
+        WCString operator+(const WCString &rhs);
+        WCString operator+(const std::string &rhs);
+        WCString operator+(const wchar_t *rhs);
+        WCString operator+(const char *rhs);
+
+    protected:
+        std::basic_string<wchar_t> data;
+        mutable char *char_copy;
+    };
+}
\ No newline at end of file

Added: trunk/src/SwordReader_GUI/SRMainFrame.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.cpp	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRMainFrame.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,13 @@
+#include "SRMainFrame.h"
+
+SRMainFrame::SRMainFrame()
+{
+    m_cmdBar = new SRCommandBar();
+    m_cmdBar->Create(this,NULL, SR_COMMAND_BAR_ID);
+    m_cmdBar->InsertMenuBar(IDM_MENU,0);
+}
+
+SRMainFrame::~SRMainFrame()
+{
+}
+

Added: trunk/src/SwordReader_GUI/SRMainFrame.h
===================================================================
--- trunk/src/SwordReader_GUI/SRMainFrame.h	                        (rev 0)
+++ trunk/src/SwordReader_GUI/SRMainFrame.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -0,0 +1,19 @@
+#pragma once
+#include "resource.h"
+#include "SRFramework/SRFrame.h"
+#include "SRFramework/SRCommandBar.h"
+#include "SRFramework/SRCommandBar.h"
+
+// The one and only command bar.
+#define SR_COMMAND_BAR_ID 0x0001
+
+using namespace SRFramework;
+
+class SRMainFrame : public SRFrame
+{
+public:
+    SRMainFrame();
+    virtual ~SRMainFrame();
+private:
+    SRCommandBar *m_cmdBar;
+};

Deleted: trunk/src/SwordReader_GUI/SRWidget.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRWidget.cpp	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/SRWidget.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,23 +0,0 @@
-#include "SRWidget.h"
-
-SRWidget::SRWidget(void)
-{
-}
-
-SRWidget::~SRWidget(void)
-{
-}
-
-COLORREF SRWidget::setBackColor(HDC hdc, COLORREF  color)
-{
-    m_backColor = color;
-    return SetBkColor(hdc, m_backColor);
-}
-
-COLORREF SRWidget::setForeColor(HDC hdc, COLORREF  color)
-{
-    m_foreColor = color;
-    return SetTextColor(hdc, m_foreColor);
-}
-
-void SRWidget::SetFont(HFONT font) { /*TODO*/ }
\ No newline at end of file

Deleted: trunk/src/SwordReader_GUI/SRWidget.h
===================================================================
--- trunk/src/SwordReader_GUI/SRWidget.h	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/SRWidget.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,21 +0,0 @@
-#pragma once
-#include <windows.h>
-
-class SRWidget
-{
-public:
-    SRWidget(void);
-    virtual ~SRWidget(void);
-protected:
-    // We may not want to cache the color. 
-    // One reason we may is to track the preferred
-    // back color compared to say the color of a rectangle.
-    COLORREF    m_backColor;
-    COLORREF    m_foreColor;
-    HFONT       m_curFont;
-    HFONT       m_oldFont;
-public:
-    COLORREF setBackColor(HDC hdc, COLORREF color);
-    COLORREF setForeColor(HDC hdc, COLORREF color);
-    void SetFont(HFONT font);
-};

Deleted: trunk/src/SwordReader_GUI/SRWnd.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRWnd.cpp	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/SRWnd.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,69 +0,0 @@
-#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

Deleted: trunk/src/SwordReader_GUI/SRWnd.h
===================================================================
--- trunk/src/SwordReader_GUI/SRWnd.h	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/SRWnd.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,57 +0,0 @@
-#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/SwordReaderApp.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderApp.cpp	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/SwordReaderApp.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -2,12 +2,9 @@
 
 SHACTIVATEINFO SwordReaderApp::s_sai;
 
-SwordReaderApp::SwordReaderApp()
-: m_navigator(NULL)
+SwordReaderApp::SwordReaderApp(HINSTANCE hInstance)
+: SRFramework::SRApp(hInstance)
 , m_swordConf(NULL)
-, m_dwAppThreadID(0)
-, m_hInst(0)
-, m_hWnd(0)
 {
     memset(&s_sai, 0, sizeof(s_sai));
     s_sai.cbSize = sizeof(s_sai);
@@ -17,15 +14,41 @@
 {
 }
 
-bool SwordReaderApp::InitApp(HINSTANCE hInstance, int nCmdShow)
+WPARAM SwordReaderApp::Run()
 {
+	MSG msg;
+	bool ignoreMsgs = false;
+	DWORD ignoreTill = GetTickCount();
+
+    // Main message loop:
+	while (GetMessage(&msg, NULL, 0, 0)) 
+	{
+		if(msg.message == WM_TXT_START){ 
+			ignoreMsgs = true;
+		}else if(msg.message == WM_TXT_END){
+			ignoreMsgs = false;
+			ignoreTill = msg.time;
+		}
+		// If we have a button or key event, and we are in the ignore message 
+		// window of time we ignore this message
+		if((msg.message == WM_LBUTTONDOWN || msg.message == WM_KEYDOWN) && (ignoreMsgs || msg.time < ignoreTill))
+			continue;
+
+		if (!m_hAccelTable || !TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
+		{
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
+	}
+	return msg.wParam;
+}
+
+bool SwordReaderApp::InitApp(int nCmdShow)
+{
     WNDCLASS	wc;
 	TCHAR	szTitle[MAX_LOADSTRING];			// The title bar text
 	TCHAR	szWindowClass[MAX_LOADSTRING];		// The window class name
-    
-    m_dwAppThreadID = GetCurrentThreadId();
-	m_hInst = hInstance;
-	
+   
 	// Create a general options file for storing options 
 	// and navigaiton history
 	const char *cwd = getWorkingDirectory();
@@ -34,8 +57,10 @@
 
 	m_swordConf = new SWConfig(confFName);
 	m_swordConf->Load();
-
-	// Initialize global strings
+    
+    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);
 

Modified: trunk/src/SwordReader_GUI/SwordReaderApp.h
===================================================================
--- trunk/src/SwordReader_GUI/SwordReaderApp.h	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/SwordReaderApp.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,17 +1,20 @@
 #pragma once
 #include <swconfig.h>
 #include "SimpleNavigator.h"
-#include "SRWidget.h"
+#include "SRFramework/SRApp.h"
+#include "SRMainFrame.h"
 #include "ApplicationInterface.h"
 
 //#include "swordce.h"
+using namespace SRFramework;
 
-class SwordReaderApp : SRWidget
+class SwordReaderApp : SRApp
 {
 public:
-    SwordReaderApp();
+    SwordReaderApp(HINSTANCE hInstance);
     virtual ~SwordReaderApp();
-    bool InitApp(HINSTANCE hInstance, 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.
@@ -37,8 +40,6 @@
                         parameter. 
      */
     LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-    void SetTitle(const WCString &title);
-    void RefreshScreen();
 private:
     // Message Handlers...
     BOOL OnNotify(WPARAM wParam, LPARAM lParam);
@@ -62,9 +63,7 @@
     // I debate which of these should be cached...
     SimpleNavigator     *m_navigator;
     SWConfig            *m_swordConf;
-    DWORD               m_dwAppThreadID;
-    HINSTANCE	        m_hInst;
-    HWND			    m_hWnd;
-    HWND			    m_hwndCB;
+    SRMainFrame         *m_pMainFrame;
+    
     static SHACTIVATEINFO s_sai;
 };

Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj	2008-03-30 23:06:18 UTC (rev 107)
@@ -682,14 +682,10 @@
 				>
 			</File>
 			<File
-				RelativePath=".\SRWidget.cpp"
+				RelativePath=".\SRMainFrame.cpp"
 				>
 			</File>
 			<File
-				RelativePath=".\SRWnd.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\SwordIndex.cpp"
 				>
 			</File>
@@ -709,10 +705,38 @@
 				RelativePath=".\VerseTextControl.cpp"
 				>
 			</File>
-			<File
-				RelativePath=".\WCString.cpp"
+			<Filter
+				Name="SRFramework"
 				>
-			</File>
+				<File
+					RelativePath=".\SRFramework\SRApp.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRCommandBar.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRFrame.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRMenu.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRWidget.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRWnd.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\WCString.cpp"
+					>
+				</File>
+			</Filter>
 		</Filter>
 		<Filter
 			Name="Header Files"
@@ -763,14 +787,10 @@
 				>
 			</File>
 			<File
-				RelativePath=".\SRWidget.h"
+				RelativePath=".\SRMainFrame.h"
 				>
 			</File>
 			<File
-				RelativePath=".\SRWnd.h"
-				>
-			</File>
-			<File
 				RelativePath=".\SwordIndex.h"
 				>
 			</File>
@@ -790,10 +810,38 @@
 				RelativePath=".\VerseTextControl.h"
 				>
 			</File>
-			<File
-				RelativePath=".\WCString.h"
+			<Filter
+				Name="SRFramework"
 				>
-			</File>
+				<File
+					RelativePath=".\SRFramework\SRApp.h"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRCommandBar.h"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRFrame.h"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRMenu.h"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRWidget.h"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\SRWnd.h"
+					>
+				</File>
+				<File
+					RelativePath=".\SRFramework\WCString.h"
+					>
+				</File>
+			</Filter>
 		</Filter>
 		<Filter
 			Name="Resource Files"

Deleted: trunk/src/SwordReader_GUI/WCString.cpp
===================================================================
--- trunk/src/SwordReader_GUI/WCString.cpp	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/WCString.cpp	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,237 +0,0 @@
-#include "WCString.h"
-#include <string.h>
-
-WCString::WCString(void)
-: char_copy(NULL)
-, data(L" ")
-{
-
-}
-
-WCString::~WCString(void)
-{
-    if(char_copy)
-        delete [] char_copy;
-}
-
-WCString::WCString(const char * rhs)
-: char_copy(NULL)
-{
-    unsigned int len = strlen(rhs);
-    unsigned int i = 0;
-    if(data.size() < len)
-        data.resize(len);
-
-    for(i = 0; i < len; i++){
-        data[i] = (wchar_t)rhs[i];
-    }
-}
-
-WCString::WCString(const WCString &rhs)
-: data(rhs.data)
-, char_copy(NULL)
-{
-
-}
-
-WCString::WCString(const wchar_t * rhs)
-: char_copy(NULL)
-{
-    unsigned int len = 0;
-    unsigned int i = 0;
-
-    // This is so dangerous...
-    while(rhs[len]) len++;
-    
-    if(data.size() < len)
-        data.resize(len);
-
-    for(i = 0; i < len; i++){
-        data[i] = rhs[i];
-    }
-}
-
-WCString::WCString(const std::string &rhs)
-: char_copy(NULL)
-{
-    unsigned int len = rhs.length();
-    unsigned int i = 0;
-    if(data.size() < len)
-        data.resize(len);
-
-    for(i = 0; i < len; i++){
-        data[i] = (wchar_t)rhs[i];
-    }
-}
-
-std::string WCString::to_string()
-{
-    unsigned int i = 0;
-    std::string retval;
-    retval.resize(data.length());
-    for(i = 0; i < data.length(); i++)
-        retval[i] = (char)data[i];
-    retval[i] = 0;
-    return retval;
-}
-
-WCString &WCString::operator=(const WCString &rhs)
-{
-    if(this != &rhs)
-        data = rhs.data;
-
-    return *this;
-}
-
-const wchar_t *WCString::w_str() const
-{
-    return data.c_str();
-}
-
-const char *WCString::c_str() const
-{
-    unsigned int i = 0;
-    if(char_copy)
-        delete [] char_copy;
-    char_copy = new char[data.length() + 1];
-    for(i = 0; i < data.length(); i++)
-        char_copy[i] = (char)data[i];
-    char_copy[i] = 0;
-
-    return char_copy;
-}
-WCString &WCString::operator=(const std::string &rhs)
-{
-    unsigned int i = 0;
-    if(rhs.length() > data.size())
-        data.resize(rhs.length());
-    for(i = 0; i < rhs.length(); i++)
-        data[i] = (wchar_t)rhs[i];
-
-    return *this;
-}
-
-WCString &WCString::operator=(const wchar_t *rhs)
-{
-    unsigned int i = 0;
-    unsigned int len = 0;
-    // This is so dangerous...
-    while(rhs[len]) len++;
-
-    if(len > data.size())
-        data.resize(len);
-    for(i = 0; i < len; i++)
-        data[i] = rhs[i];
-    
-    return *this;
-}
-
-WCString &WCString::operator=(const char *rhs)
-{
-    unsigned int i = 0;
-    unsigned int len = 0;
-    // This is so dangerous...
-    while(rhs[len]) len++;
-
-    if(len > data.size())
-        data.resize(len);
-    for(i = 0; i < len; i++)
-        data[i] = (wchar_t)rhs[i];
-
-    return *this;
-}
-
-WCString &WCString::operator+=(const WCString &rhs)
-{
-    unsigned int i = 0;
-    unsigned int di = data.length();
-    unsigned int ri = rhs.length();
-
-    if(this == &rhs)
-        return *this;
-    if(data.size() < rhs.length() + di)
-        data.resize(rhs.length() + di);
-
-    for(i = 0; i < rhs.length(); i++){
-        data[di + i] = rhs.data[i];
-    }
-
-    return *this;
-}
-
-WCString &WCString::operator+=(const std::string &rhs)
-{
-    unsigned int i = 0;
-    unsigned int di = data.length();
-    if(rhs.length() + di > data.size())
-        data.resize(rhs.length() + di);
-    for(i = 0; i < rhs.length(); i++)
-        data[di + i] = (wchar_t)rhs[i];
-    return *this;
-}
-
-WCString &WCString::operator+=(const wchar_t *rhs)
-{
-    unsigned int i = 0;
-    unsigned int len = 0;
-    unsigned int di = data.length();
-    // This is so dangerous...
-    while(rhs[len]) len++;
-
-    if(len + di > data.size())
-        data.resize(len + di);
-    for(i = 0; i < len; i++)
-        data[di + i] = rhs[i];
-    //data[di + i] = 0;
-    return *this;
-}
-
-WCString &WCString::operator+=(const char *rhs)
-{
-    unsigned int i = 0;
-    unsigned int len = 0;
-    unsigned int di = data.length();
-    
-    // This is so dangerous...
-    while(rhs[len]) len++;
-
-    if(len + di > data.size())
-        data.resize(len + di);
-    for(i = 0; i < len; i++) 
-        data[di + i] = (wchar_t)rhs[i];
-
-    return *this;
-}
-
-
-WCString WCString::operator+(const WCString &rhs)
-{
-    WCString retval = *this;
-    retval += rhs;
-
-    return retval;
-}
-
-WCString WCString::operator+(const std::string &rhs)
-{   
-    WCString retval = *this;
-    retval += rhs;
-
-    return retval;
-}
-
-WCString WCString::operator+(const wchar_t *rhs)
-{
-    WCString retval = *this;
-    retval += rhs;
-
-    return retval;
-}
-
-WCString WCString::operator+(const char *rhs)
-{
-    WCString retval = *this;
-    retval += rhs;
-
-    return retval;
-}
\ No newline at end of file

Deleted: trunk/src/SwordReader_GUI/WCString.h
===================================================================
--- trunk/src/SwordReader_GUI/WCString.h	2008-03-27 03:50:57 UTC (rev 106)
+++ trunk/src/SwordReader_GUI/WCString.h	2008-03-30 23:06:18 UTC (rev 107)
@@ -1,42 +0,0 @@
-#pragma once
-
-#include <string>
-
-class WCString
-{
-public:
-    WCString(void);
-    WCString(const char *rhs);
-    WCString(const wchar_t *rhs);
-    WCString(const std::string &rhs);
-    WCString(const WCString &rhs);
-
-    ~WCString(void);
-
-    std::string to_string();
-    const wchar_t *w_str() const;
-    const char *c_str() const;
-
-    unsigned int length() const 
-        { return data.length(); }
-    void clear() { data.clear(); }
-
-    WCString &operator=(const WCString &rhs);
-    WCString &operator=(const std::string &rhs);
-    WCString &operator=(const wchar_t *rhs);
-    WCString &operator=(const char *rhs);
-
-    WCString &operator+=(const WCString &rhs);
-    WCString &operator+=(const std::string &rhs);
-    WCString &operator+=(const wchar_t *rhs);
-    WCString &operator+=(const char *rhs);
-
-    WCString operator+(const WCString &rhs);
-    WCString operator+(const std::string &rhs);
-    WCString operator+(const wchar_t *rhs);
-    WCString operator+(const char *rhs);
-    
-protected:
-    std::basic_string<wchar_t> data;
-    mutable char *char_copy;
-};




More information about the sword-cvs mailing list