#ifndef T2DLL_T2DLGITEMTABLE_H #define T2DLL_T2DLGITEMTABLE_H #include "../common.h" #include "LListener.h" #include "T2DlgItem.h" class AFX_CLASS_EXPORT T2DlgItemTable : public T2DlgItem, public LListener { public: enum ScrollerStyle { ShowIfNeeded, AlwaysHide, AlwaysShow, Attached, AttachedNoUpdates }; T2DlgItemTable(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette); T2DlgItemTable(int rows, int cols, int rowHeight, int colWidth, int cellDataSize, T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette); virtual ~T2DlgItemTable(); virtual BOOL Create(const char* inWindowName, DWORD inStyle, const RECT& inRect, CWnd* inParentWnd, UINT inID); virtual void InsertRows(int, UINT, void*); virtual void InsertCols(int, UINT, void*); virtual void RemoveRows(int, UINT); virtual void RemoveCols(int, UINT); virtual void SetRowHeight(int, unsigned int, unsigned int); virtual void SetColWidth(int, unsigned int, unsigned int); virtual void SetCellData(const TableCellT&, void*); virtual void GetCellData(const TableCellT&, void*); virtual void SelectCell(const TableCellT&); virtual void ToggleCell(const TableCellT&); virtual void ClearSelectedCells(); void GetTableSize(UINT& outRows, UINT& outCols) const; BOOL IsMultiSelectable() const; void EnableMultiSelect(BOOL); BOOL IsValidCell(const TableCellT&) const; BOOL EqualCell(const TableCellT&, const TableCellT&) const; void SetCellDataSize(int); BOOL IsSelected(const TableCellT&) const; void GetSelectedCell(TableCellT&) const; virtual void ListenToMessage(unsigned int, void*); T2DlgItemHScr* GetHScroller() const; T2DlgItemVScr* GetVScroller() const; void AttachHScroller(T2DlgItemHScr* scroller, BOOL flag); void AttachVScroller(T2DlgItemVScr* scroller, BOOL flag); void SetHScrollerStyle(ScrollerStyle style); void SetVScrollerStyle(ScrollerStyle style); protected: virtual BOOL OnCommand(UINT, long); virtual BOOL OnT2DlgItemEraseBkgnd(CDC*); virtual void OnT2DlgItemLButtonDown(UINT, CPoint); virtual void OnT2DlgItemLButtonUp(UINT, CPoint); virtual void OnT2DlgItemMouseMove(UINT, CPoint); virtual BOOL OnT2DlgItemCreate(CREATESTRUCT*); virtual void OnT2Size(unsigned int, int, int); virtual void ClickSelf(const POINT&, UINT nFlags); virtual void HiliteCells(CDC*, LArrayIterator&); virtual void UnhiliteCells(CDC*, LArrayIterator&); virtual void HiliteCell(CDC*, const TableCellT&); virtual void UnhiliteCell(CDC*, const TableCellT&); virtual void ClickCell(const TableCellT&, const POINT&); virtual void DrawCell(CDC*, const TableCellT&); virtual BOOL FetchLocalCellFrame(const TableCellT&, RECT&); virtual void FetchCellHitBy(const POINT&, TableCellT&); int FetchCellDataIndex(const TableCellT&); void InvalidateCell(const TableCellT&); void ViewToClient(POINT*, int); void ClientToView(POINT*, int); void DoScroll(); BOOL IsOwnHScroller() const; BOOL IsOwnVScroller() const; UINT mRows; UINT mCols; int mRowHeight; int mColWidth; LArray *mCellData; TableCellT mClickedCell; TableCellT mSelectedCell; LArray *mMultiSelectedCells; POINT mScrollOffset; T2DlgItemHScr *mHScroller; T2DlgItemVScr *mVScroller; BOOL mShowHScroller; BOOL mShowVScroller; int mResizeCount; ScrollerStyle mVScrollerStyle; ScrollerStyle mHScrollerStyle; private: void InitTable(int rows, int cols, int rowHeight, int colWidth, int cellDataSize); BOOL Resized(); }; class AFX_CLASS_EXPORT TableCellIterator { public: TableCellIterator(const TableCellT& start, const TableCellT& end); BOOL Next(TableCellT& newCurrent); protected: UINT mCurrentRow; UINT mCurrentCol; UINT mLastRow; UINT mFirstCol; UINT mLastCol; }; #endif