[sword-svn] r187 - in trunk/src/SwordReader_GUI: . SRFramework
dtrotzjr at crosswire.org
dtrotzjr at crosswire.org
Fri Jan 2 17:04:27 MST 2009
Author: dtrotzjr
Date: 2009-01-02 17:04:27 -0700 (Fri, 02 Jan 2009)
New Revision: 187
Added:
trunk/src/SwordReader_GUI/SRFramework/SRComboBox.cpp
trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h
Modified:
trunk/src/SwordReader_GUI/SRTabbedViews.h
trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
Log:
SRFramework: Added a wrapper for the ComboBox widget.
Added: trunk/src/SwordReader_GUI/SRFramework/SRComboBox.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRComboBox.cpp (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRComboBox.cpp 2009-01-03 00:04:27 UTC (rev 187)
@@ -0,0 +1,73 @@
+#include "SRComboBox.h"
+#include "SRApp.h"
+#include <windows.h>
+
+using namespace SRFramework;
+
+
+SRComboBox::SRComboBox(void)
+{
+ m_hInstance = SRFramework::SRApp::GetInstanceHandle();
+ m_wcsClassName = "combobox";
+ m_wcsWindowName = "";
+}
+
+SRComboBox::~SRComboBox(void)
+{
+
+}
+
+BOOL SRComboBox::Create(SRWnd *pParentWnd, RECT bounds, INT nChildID, DWORD dwStyle)
+{
+ if(!Register())
+ return FALSE;
+ if(!SRWnd::Create(m_wcsClassName,m_wcsWindowName, dwStyle, bounds, pParentWnd, (HMENU)nChildID, m_hInstance))
+ return FALSE;
+
+ return TRUE;
+}
+
+WCString SRComboBox::GetText()
+{
+ TCHAR *strQuery = NULL;
+ INT nQueryLen = ::SendMessage(m_hWnd, WM_GETTEXTLENGTH, NULL, NULL) + 1;
+ strQuery = new TCHAR[nQueryLen];
+ ::SendMessage(m_hWnd,WM_GETTEXT,(WPARAM)nQueryLen,(LPARAM)strQuery);
+ strQuery[nQueryLen - 1] = 0; // in case the buffer was exceeded
+ return strQuery;
+}
+
+VOID SRComboBox::Clear()
+{
+ ::SendMessage (m_hWnd, CB_RESETCONTENT,0,0);
+}
+
+INT SRComboBox::AddItem(const WCString &wcsItem)
+{
+ return ::SendMessage (m_hWnd, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)wcsItem.w_str());
+}
+
+INT SRComboBox::InsertItem(INT nItemIndex, const WCString &wcsItem)
+{
+ return ::SendMessage (m_hWnd, CB_INSERTSTRING, nItemIndex, (LPARAM)(LPCTSTR)wcsItem.w_str());
+}
+
+INT SRComboBox::DeleteItem(INT nItemIndex)
+{
+ return ::SendMessage (m_hWnd, CB_DELETESTRING, nItemIndex, NULL);
+}
+
+INT SRComboBox::FindItem(const WCString &wcsItem)
+{
+ return ::SendMessage (m_hWnd, CB_FINDSTRING, 0, (LPARAM)(LPCTSTR)wcsItem.w_str());
+}
+
+INT SRComboBox::SelectItem(const WCString &wcsItem)
+{
+ return ::SendMessage (m_hWnd, CB_FINDSTRING, 0, (LPARAM)(LPCTSTR)wcsItem.w_str());
+}
+
+INT SRComboBox::GetCurSel()
+{
+ return ::SendMessage (m_hWnd, CB_GETCURSEL, 0,0);
+}
\ No newline at end of file
Added: trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h (rev 0)
+++ trunk/src/SwordReader_GUI/SRFramework/SRComboBox.h 2009-01-03 00:04:27 UTC (rev 187)
@@ -0,0 +1,26 @@
+#pragma once
+#include "SRWnd.h"
+#include <commctrl.h>
+
+namespace SRFramework{
+
+ class SRComboBox : public SRFramework::SRWnd
+ {
+ public:
+ SRComboBox(VOID);
+ virtual ~SRComboBox(VOID);
+ BOOL Create(SRWnd *pParentWnd, RECT bounds, INT nChildID = NULL, DWORD dwStyle = WS_CHILD | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_NOTIFY | WS_BORDER | LBS_NOINTEGRALHEIGHT);
+ // Does not need to be registered the call to InitCommonControlsEx
+ // does that for us.
+ BOOL Register() { return TRUE; }
+ WCString GetText();
+ VOID Clear();
+ INT AddItem(const WCString &wcsItem);
+ INT InsertItem(INT nItemIndex, const WCString &wcsItem);
+ INT DeleteItem(INT nItemIndex);
+ INT FindItem(const WCString &wcsItem);
+ INT SelectItem(const WCString &wcsItem);
+ INT GetCurSel();
+ };
+
+}
\ No newline at end of file
Modified: trunk/src/SwordReader_GUI/SRTabbedViews.h
===================================================================
--- trunk/src/SwordReader_GUI/SRTabbedViews.h 2009-01-02 23:24:28 UTC (rev 186)
+++ trunk/src/SwordReader_GUI/SRTabbedViews.h 2009-01-03 00:04:27 UTC (rev 187)
@@ -18,7 +18,6 @@
public:
SRTabbedViews(void);
virtual ~SRTabbedViews(void);
- SRTabCtrl m_tabs;
BOOL Create(SRWnd *pParentWnd, RECT bounds);
BOOL Register();
BOOL Init();
@@ -60,6 +59,7 @@
BOOL OnNotify(int idCtrl, LPNMHDR pnmh);
INT SwitchToCurrentView();
private:
+ SRTabCtrl m_tabs;
BOOL InitTabs();
BOOL InitViews();
SRTextView *GetCurrentView();
Modified: trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj
===================================================================
--- trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2009-01-02 23:24:28 UTC (rev 186)
+++ trunk/src/SwordReader_GUI/SwordReader_GUI.vcproj 2009-01-03 00:04:27 UTC (rev 187)
@@ -917,6 +917,10 @@
>
</File>
<File
+ RelativePath=".\SRFramework\SRComboBox.cpp"
+ >
+ </File>
+ <File
RelativePath=".\SRFramework\SRCommandBar.cpp"
>
</File>
@@ -1026,6 +1030,10 @@
>
</File>
<File
+ RelativePath=".\SRFramework\SRComboBox.h"
+ >
+ </File>
+ <File
RelativePath=".\SRFramework\SRCommandBar.h"
>
</File>
More information about the sword-cvs
mailing list