[sword-svn] r173 - trunk/src/SwordReader_GUI/SRFramework
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Fri Sep 5 22:38:45 MST 2008
Author: dtrotzjr
Date: 2008-09-05 22:38:44 -0700 (Fri, 05 Sep 2008)
New Revision: 173
Modified:
trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp
trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.h
Log:
Wrapped the most important parts of the tab control API in the SRTabControl class.
Modified: trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp 2008-09-06 03:37:36 UTC (rev 172)
+++ trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.cpp 2008-09-06 05:38:44 UTC (rev 173)
@@ -32,28 +32,118 @@
return TRUE;
}
-BOOL SRTabCtrl::Register()
+BOOL SRTabCtrl::DeleteAllItems(VOID)
{
- // Register window class...
- WNDCLASS wc;
- if(s_fRegistered)
- return TRUE;
+ return TabCtrl_DeleteAllItems(m_hWnd);
+}
- 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();
+BOOL SRTabCtrl::DeleteItem(int nItem)
+{
+ return TabCtrl_DeleteItem(m_hWnd, nItem);
+}
- if(RegisterClass(&wc) == 0)
- return FALSE;
+BOOL SRTabCtrl::DeselectAll(BOOL fExcludeFocus)
+{
+ TabCtrl_DeselectAll(m_hWnd, fExcludeFocus);
+ return TRUE;
+}
+
+BOOL SRTabCtrl::HighlightItem(int idItem, BOOL fHighlight)
+{
+ return TabCtrl_HighlightItem(m_hWnd, idItem, fHighlight);
+}
+
+INT SRTabCtrl::HitTest(LPTCHITTESTINFO pHitTestInfo) const
+{
+ return TabCtrl_HitTest(m_hWnd, pHitTestInfo);
+}
+
+LONG SRTabCtrl::InsertItem(int nItem, TC_ITEM* pTabCtrlItem)
+{
+ return TabCtrl_InsertItem(m_hWnd, nItem, pTabCtrlItem);
+}
+
+LONG SRTabCtrl::InsertItem(int nItem, WCString wcsItem)
+{
+ return InsertItem(nItem, wcsItem, -1, NULL);
+}
+
+LONG SRTabCtrl::InsertItem(int nItem, WCString wcsItem, int nImage)
+{
+ return InsertItem(nItem, wcsItem, nImage, NULL);
+}
+
+LONG SRTabCtrl::InsertItem(int nItem, WCString wcsItem, int nImage, LPARAM lParam)
+{
+ BOOL retval = FALSE;
+ TC_ITEM item;
+ LPWSTR pszText = (LPWSTR)calloc(wcsItem.length(), sizeof(WCHAR));
+ wcscpy(pszText, wcsItem.w_str());
+ memset(&item, 0, sizeof(TC_ITEM));
- s_fRegistered = TRUE;
+ item.mask = TCIF_TEXT;
+ if(nImage > -1)
+ item.mask |= TCIF_IMAGE;
+ if(lParam != NULL)
+ item.mask |= TCIF_PARAM;
+
+ item.pszText = pszText;
+ item.cchTextMax = wcsItem.length();
+
+ item.iImage = nImage;
+ item.lParam = lParam;
+ retval = TabCtrl_InsertItem(m_hWnd, nItem, &item);
+ delete pszText;
+ return retval;
+}
+
+VOID SRTabCtrl::RemoveImage(int nImage)
+{
+ return TabCtrl_RemoveImage(m_hWnd, nImage);
+}
+
+INT SRTabCtrl::GetCurFocus()
+{
+ return TabCtrl_GetCurFocus(m_hWnd);
+}
+
+INT SRTabCtrl::GetCurSel()
+{
+ return TabCtrl_GetCurSel(m_hWnd);
+}
+
+INT SRTabCtrl::GetItemCount()
+{
+ return TabCtrl_GetItemCount(m_hWnd);
+}
+BOOL SRTabCtrl::GetItemRect(INT nItem, LPRECT lpRect)
+{
+ return TabCtrl_GetItemRect(m_hWnd, nItem, lpRect);
+}
+
+INT SRTabCtrl::GetRowCount()
+{
+ return TabCtrl_GetRowCount(m_hWnd);
+}
+
+BOOL SRTabCtrl::SetCurFocus(INT nItem)
+{
+ return TabCtrl_SetCurFocus(m_hWnd, nItem);
+}
+
+BOOL SRTabCtrl::SetCurSel(INT nItem)
+{
+ return TabCtrl_SetCurSel(m_hWnd, nItem);
+}
+
+INT SRTabCtrl::SetMinTabWidth(INT cx)
+{
+ return TabCtrl_SetMinTabWidth(m_hWnd, cx);
+}
+
+BOOL SRTabCtrl::SetPadding(INT cx, INT cy)
+{
+ TabCtrl_SetPadding(m_hWnd, cx, cy);
return TRUE;
-}
\ No newline at end of file
+}
Modified: trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.h
===================================================================
--- trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.h 2008-09-06 03:37:36 UTC (rev 172)
+++ trunk/src/SwordReader_GUI/SRFramework/SRTabCtrl.h 2008-09-06 05:38:44 UTC (rev 173)
@@ -1,15 +1,35 @@
#pragma once
#include "srwnd.h"
+#include <commctrl.h>
namespace SRFramework{
class SRTabCtrl : public SRFramework::SRWnd
{
public:
- SRTabCtrl(void);
- virtual ~SRTabCtrl(void);
+ SRTabCtrl(VOID);
+ virtual ~SRTabCtrl(VOID);
BOOL Create(SRWnd *pParentWnd, RECT bounds);
- BOOL Register();
+ BOOL DeleteAllItems(VOID);
+ BOOL DeleteItem(int nItem);
+ BOOL DeselectAll(BOOL fExcludeFocus);
+ BOOL HighlightItem(int idItem, BOOL fHighlight = TRUE);
+ INT HitTest(LPTCHITTESTINFO pHitTestInfo) const;
+ LONG InsertItem(int nItem, TC_ITEM* pTabCtrlItem);
+ LONG InsertItem(int nItem, WCString wcsItem);
+ LONG InsertItem(int nItem, WCString wcsItem, int nImage);
+ LONG InsertItem(int nItem, WCString wcsItem, int nImage, LPARAM lParam);
+ VOID RemoveImage(int nImage);
+ INT GetCurFocus();
+ INT GetCurSel();
+ INT GetItemCount();
+ BOOL GetItemRect(INT nItem, LPRECT lpRect);
+ INT GetRowCount();
+ BOOL SetCurFocus(INT nItem);
+ BOOL SetCurSel(INT nItem);
+ INT SetMinTabWidth(INT cx);
+ BOOL SetPadding(INT cx, INT cy);
+
};
More information about the sword-cvs
mailing list