#ifndef __CeTab_h__
#define __CeTab_h__
#include <commctrl.h>
#include "CeWnd.h"
#include "CeDialog.h"
#include "CeMisc.h"
#include "CeArray.h"
///////////////////////////////////////////////////////////////////////////////
//
// Wrapper around a dialog imbedded in a tab control
//
class CeTabPage: public CeScrollDialog
{
private:
WCHAR m_szPage[32];
public:
CeTabPage(UINT nDlgID = 0, LPCTSTR lpszLabel = NULL):
CeScrollDialog(nDlgID)
{
if (lpszLabel)
_tcsncpy(m_szPage, lpszLabel, 32);
else
*m_szPage = 0;
}
virtual ~CeTabPage()
{}
// need to be available BEFORE the dialog is created, used to create it
// and it's tab
virtual LPCTSTR GetTabTitle()
{ return m_szPage; }
virtual LPCTSTR GetID()
{ return m_lpTemplateName; }
virtual BOOL OnSetActive()
{ return TRUE; }
virtual BOOL OnKillActive()
{ return TRUE; }
virtual void OnApply()
{ }
virtual void OnReset()
{ }
};
///////////////////////////////////////////////////////////////////////////////
//
// Wrapper around a Tab Control
//
class CeTabCtrl: public CeWnd
{
// Constructors
public:
CeTabCtrl();
virtual BOOL Create(DWORD dwStyle, const RECT& rect, HWND hWndParent, UINT nID, HINSTANCE hInst);
// Attributes
int GetItemCount() const;
BOOL GetItem(int nItem, TCITEM* pTabCtrlItem) const;
BOOL SetItem(int nItem, TCITEM* pTabCtrlItem);
BOOL SetItemExtra(int nBytes);
BOOL GetItemRect(int nItem, LPRECT lpRect) const;
int GetCurSel() const;
int SetCurSel(int nItem);
void SetCurFocus(int nItem);
//CeSize SetItemSize(CeSize size);
void SetPadding(const SIZE& size);
int GetRowCount() const;
int GetCurFocus() const;
int SetMinTabWidth(int cx);
DWORD GetExtendedStyle();
DWORD SetExtendedStyle(DWORD dwNewStyle, DWORD dwExMask = 0);
DWORD GetItemState(int nItem, DWORD dwMask) const;
BOOL SetItemState(int nItem, DWORD dwMask, DWORD dwState);
// Operations
BOOL InsertItem(int nItem, TCITEM* pTabCtrlItem);
BOOL InsertItem(int nItem, LPCTSTR lpszItem);
BOOL InsertItem(int nItem, LPCTSTR lpszItem, int nImage);
BOOL InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem,
int nImage, LPARAM lParam);
BOOL InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem,
int nImage, LPARAM lParam, DWORD dwState, DWORD dwStateMask);
BOOL DeleteItem(int nItem);
BOOL DeleteAllItems();
void AdjustRect(BOOL bLarger, LPRECT lpRect);
void RemoveImage(int nImage);
int HitTest(TCHITTESTINFO* pHitTestInfo) const;
void DeselectAll(BOOL fExcludeFocus);
BOOL HighlightItem(int idItem, BOOL fHighlight = TRUE);
HIMAGELIST SetImageList(HIMAGELIST hImageList);
HIMAGELIST GetImageList() const;
// Implementation
public:
virtual ~CeTabCtrl();
protected:
// virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
// virtual void OnDestroy();
};
#include "CeTab.inl"
/////////////////////////////////////////////////////////////////////////////
// CeTabSheet window
//
// A control reponsible for creating, holding and displaying embedded
// tab pages (dialogs). The pages will be sized with the control
// so that the control can be embedded in any application window
// and not worry about it's children
//
class CeTabSheet : public CeWnd
{
private:
void FindSizeOfTabWindow(HWND hWndPage, LPRECT pRect);
int FindPage(CeTabPage *pPage) const;
HINSTANCE m_hInst;
CeTabCtrl m_tabCtrl;
CeArray<CeTabPage*> m_arPages;
int m_nActivePage;
DWORD m_dwTabStyle;
// Construction
public:
CeTabSheet();
virtual BOOL Create(DWORD dwStyle, const RECT& rect, HWND hWndParent, UINT nID, HINSTANCE hInst = NULL);
// Attributes
public:
int GetPageIndex(CeTabPage* pPage) const { return FindPage(pPage); }
int GetPageCount() const { return m_arPages.GetSize(); }
CeTabPage* GetPage(int nPage) const { return (nPage < 0) ? NULL: (CeTabPage*)m_arPages[nPage]; }
int GetActiveIndex() const { return m_nActivePage; }
CeTabPage* GetActivePage() const { return GetPage(m_nActivePage); }
void GetPageRect(LPRECT rectWnd);
// Operations
public:
BOOL SetActivePage(int nPage);
BOOL SetActivePage(CeTabPage* pPage);
// BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
void AddPage(CeTabPage* pPage, int nBitmap=-1);
void RemovePage(CeTabPage* Page);
void RemovePage(int nPage);
void Apply();
void Reset();
void RemoveImage(int nImage)
{ ASSERT(::IsWindow(m_tabCtrl.m_hWnd)); m_tabCtrl.RemoveImage(nImage); }
HIMAGELIST SetImageList(HIMAGELIST hImageList)
{ ASSERT(::IsWindow(m_tabCtrl.m_hWnd)); return m_tabCtrl.SetImageList(hImageList); }
HIMAGELIST GetImageList() const
{ ASSERT(::IsWindow(m_tabCtrl.m_hWnd)); return m_tabCtrl.GetImageList(); }
// Overrides
virtual LRESULT OnNotifyTabChanged();
virtual LRESULT OnNotifyTabChanging();
// Implementation
public:
virtual ~CeTabSheet();
protected:
virtual int OnCreate( LPCREATESTRUCT lpCS, bool& bHandled );
virtual void OnPaint( bool& bHandled );
virtual void OnSize( UINT nType, int cx, int cy, bool& bHandled );
virtual LRESULT OnNotify(int nCtrlId, LPNMHDR pNMH, bool& bHandled);
virtual LRESULT OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
};
#endif // __CeTab_h__