home *** CD-ROM | disk | FTP | other *** search
- // -------------------------------------------------------------------------
- // Copyright @ 1997 TCK Software, Incorporated
- // All Rights Reserved
- // -------------------------------------------------------------------------
- #ifndef __VFORM_H__
- #define __VFORM_H__
-
- #ifdef VF_STATIC
- #undef AFX_EXT_CLASS
- #define AFX_EXT_CLASS
- #endif
-
- #include "VRow.h"
- #include "afxtempl.h"
- // #include "CircTpl.h"
- #include "NumList.h"
- #include "VCtlHelp.h"
- #include "VfUtil.h"
- #include "VfScrollTip.h"
-
- // #ifdef VF_DRAGDROP
- #include "VfOleDropTarget.h"
- // #endif
-
- #define VFR_SCREEN 1
- #define VFR_MEMORY 2
- #define VFR_BOTH 3
- #define VFRS_NORMALROW 0
- #define VFRS_FOCUSROW 1
- #define VFRS_ADDROW 2
- #define VFCTL_FIRST 0
- #define VFCTL_SAME 1
- #define VFCTL_LAST 2
- #define VFCTL_SECT 3
-
- #define VFSECT_HDR 0x01
- #define VFSECT_DTL 0x02
- #define VFSECT_FTR 0x04
-
- #define VFMOUSE_IDLE 0
- #define VFMOUSE_COL_SELECTING 1
- #define VFMOUSE_COL_SIZING 2
- #define VFMOUSE_COL_MOVING 3
- #define VFMOUSE_ROW_SIZING 4
-
- #define VFPRINT_SCREEN 0
- #define VFPRINT_ALL 1
- #define VFPRINT_SELECTED 2
-
- #define VFGRID_FLAT 0
- #define VFGRID_SUNKEN 1
- #define VFGRID_RAISED 2
- #define VFGRID_NOLINES 3
- #define VFGRID_VERTLINES 4
- #define VFGRID_HORZLINES 5
- #define VFGRID_ALTERNATING 6
-
- #define VFORM_CLASSNAME _T("VFormControl")
-
- #define VMAX_HELPER_CTLS 10
-
- #define IDC_VFORM_LIST 300
-
- // This setting always displays a vertical scrollbar
- // - but its position is always 100% accurate
- // #define VF_VERTSCROLL_MAX m_nRows + m_nRowsPerScreen - 2
-
- // This setting will hide the vertical scrollbar if its not needed
- // - but there will be a "jump" if using the scrollbar after manually
- // scrolling the last row past the bottom of the screen
- // - this is because the actual row position is > the max scroll position
- #define VF_VERTSCROLL_MAX m_nRows - 1
-
- // --- Forward Declarations ---
- class CVfBldrDoc;
- class CVfbSection;
- class VfbCtl;
-
- // -------------------------------------------------------------------------
- // VFormRegistrar
- // - Registers VFormControl - using a global instance of this class
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VFormRegistrar
- {
- protected:
- static BOOL m_bRegistered;
- public:
- VFormRegistrar(); // Ensures VForm WndClass is registered
- static BOOL IsRegistered() { return m_bRegistered; }
- };
-
- // -------------------------------------------------------------------------
- // VfGridCol
- // - VForm grid column
- // -------------------------------------------------------------------------
- class VfGridCol
- {
- protected:
- VCtl* m_pCtl; // Active Control
- VCtl* m_pTmpCtl; // Temporary Control
- int m_nWidth; // Width of the column
- public:
- VfGridCol() {};
-
- void Ctl(VCtl *pCtl) { m_pCtl = pCtl; }
- void TmpCtl(VCtl *pCtl) { m_pTmpCtl = pCtl; }
- void Width(int nWidth) { m_nWidth = nWidth; }
-
- VCtl* Ctl() { return m_pCtl; }
- VCtl* TmpCtl() { return m_pTmpCtl; }
- int Width() { return m_nWidth; }
- };
-
- typedef CArray<VfGridCol, VfGridCol&> VfGridColArray;
-
- // -------------------------------------------------------------------------
- // VForm
- // - uses mapping modes to let rows draw themselves (always at same offsets)
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VForm : public CWnd
- {
- protected:
- // Base Data Members
- CBitmap m_bmMem; // Memory Bitmap of screen
- VCtlHelper* m_ctlHelper[VMAX_HELPER_CTLS]; // helper controls
- int m_nHelperId; // Index of current helper control
- CListBox m_ctlList; // ListBox Control
- VfScrollTip m_ctlScrollTip; // Scroll tip control
- VNumList m_selectedList; // List of selected Row Ids
-
- // Section Info - Header, Detail, Footer
- int m_nSection; // Which section is current
- VHeader* m_pHeader; // Pointer to Header Row
- VHeader* m_pFooter; // Pointer to Footer Row
- VRow* m_pDtlRow; // Current Edit Row
- VRow* m_pTmpRow; // Temporary Row
- int m_nHdrCtl; // Current Header Control Index
- int m_nFtrCtl; // Current Footer Control Index
- int m_nDtlCtl; // Current Detail Control Index
- int m_nFormHdrHeight; // height of the form header
- int m_nHeaderHeight; // height of the header
- int m_nFooterHeight; // height of the footer
-
- // State Info
- BOOL m_bAdding; // Adding a row currently?
- BOOL m_bListBoxOpen; // Are we using the listbox
- BOOL m_bSelecting; // In the middle of a selection?
- BOOL m_bSelectPrimed; // Was last action for selection?
- long m_nSelStartRowId; // Starting Row for selecting
- BOOL m_bCaptureOn; // Are we capturing mouse input
- BOOL m_bShiftKey; // Is Shift key down
- BOOL m_bCtlKey; // Is Control key down
- BOOL m_bScrolling; // Are we scrolling
- int m_nScrollCnt; // How many lines/pages we have scrolled
- BOOL m_bHelperSaved; // Has helper ctl been saved?
- // - used during scrolling
-
- long m_nTopRowId; // Row Id of Top Row
- long m_nCurRowId; // Current Row Id
-
- CSize m_size; // size of the screen
- SCROLLINFO m_si; // keep the scrolling info
- SCROLLINFO m_siHorz; // the horizontal scrolling info
- long m_nRows; // number of rows in the data
- int m_nRowsPerScreen; // number of rows visible on one screen
-
- // Settings
- CFont* m_pFont; // Default font
- int m_nRowHeight; // height of one row
- int m_nFormRowHeight; // height of one row when in Form Mode
- int m_nRowWidth; // width of one row
- BOOL m_bReadOnly; // Is Entire VForm Read Only
- BOOL m_bAllowAdd; // Allow adding of rows
- BOOL m_bSnapResize; // TRUE to resize to a row boundary when resizing
- BOOL m_bAllowRowSizing; // Allow Row Sizing
- BOOL m_bLiveAdjust; // TRUE for Live Adjustments
- BOOL m_bMultiColSelect; // Allow multiple column select (grid mode)
- BOOL m_bAutoSelect; // TRUE for automatic selecting behavior
- BOOL m_bUseSelectors; // TRUE to use selector tabs
- BOOL m_bDrawSelectRows; // TRUE to redraw entire row when selected
- int m_nSelectorWidth; // Width of one selector
- int m_nCurSelWidth; // Current selector width
-
- // ---- Drag & Drop ----
- VfOleDropTarget m_dropTarget; // Our Ole Drop Target
- BOOL m_bUseAsDropTarget; // TRUE if we are a drop target
- long m_nDropRowId; // Drop row id
-
- // ---- Printing/Reports ----
- int m_nRowsPerPage; // Number of detail lines per page
- int m_nPrintStyle; // What we should print
- int m_nPageHeight; // Height of the report page
- int m_nPageWidth; // Width of the report page
- BOOL m_bUseRptForm; // Use a custom report form for printing
- VRow* m_pRptHdr; // Custom Report Header
- VRow* m_pRptDtl; // Custom Report Detail
- VRow* m_pRptFtr; // Custom Report Footer
-
- // ---- Grid Mode ----
- BOOL m_bGridMode; // TRUE when in grid mode
- BOOL m_bGridColsSizable; // TRUE if grid columns are sizable
- BOOL m_bGridColsMoveable; // TRUE if grid columns are moveable
- int m_nGridHdrHeight; // height of the grid header
- int m_nGridRowHeight; // height of one row when using Grid View
- int m_nGridCol; // current grid column - when sizing
- int m_nGridCol1; // Anchor when selecting columns
- int m_nGridCol2; // Non-Anchor when selecting multiple columns
- int m_nGridFrozenCols; // No of frozen columns on the grid
- VfGridColArray m_gridCtl; // Array of controls in grid
- BOOL m_bInGridHeading; // Is control in the Grid Column Headings?
- BOOL m_bColsSelected; // Did user just select multiple columns?
- int m_nMouseState; // Mouse state
- VColor m_vclrHidden; // Hidden area color
- VColor m_vclrGridBack; // Grid background color
- VColor m_vclrGridLine; // Grid line color
- int m_nGridStyle; // Grid Style
- int m_nAdjustX; // X position used when column sizing
- int m_nBaseY; // Base Y position used when row sizing
- int m_nAdjustY; // Y position used when row sizing
-
- // ---- Context Menu Support ----
- // you can additionally override OnContextMenu
- UINT m_nGridHdrContextMenu; // Context menu for the Grid Header
- CPoint m_ptContextMenu; // point where context menu click occured
-
- // ---- Static Members ----
- static VFonts m_fonts; // Static list of fonts
-
- public:
- VForm(); // Constructor
- virtual ~VForm(); // Destructor
-
- // --------------- Initialization Functions ------------
- BOOL Create(LPCTSTR lpszWindowName, const RECT& rect, CWnd* pParentWnd,
- UINT nID, DWORD dwStyle=0, DWORD dwExStyle=0);
- int Init();
-
- // ---- Settings ----
- BOOL ReadOnly() { return m_bReadOnly; }
- void ReadOnly(BOOL bFlag) { m_bReadOnly = bFlag; }
- BOOL AllowAdd() { return m_bAllowAdd; }
- void AllowAdd(BOOL bFlag) { m_bAllowAdd = bFlag; }
- void LiveAdjust(BOOL bFlag) { m_bLiveAdjust = bFlag; }
- BOOL LiveAdjust() { return m_bLiveAdjust; }
- void AllowRowSizing(BOOL bFlag) { m_bAllowRowSizing = bFlag; }
- BOOL AllowRowSizing() { return m_bAllowRowSizing; }
- BOOL SnapResize() { return m_bSnapResize; }
- void SnapResize(BOOL bFlag) { m_bSnapResize = bFlag; }
- BOOL UseSelectors() { return m_bUseSelectors; }
- void UseSelectors(BOOL bFlag);
- BOOL ScrollTips() { return m_ctlScrollTip.IsOn(); }
- void ScrollTips(BOOL bFlag) { m_ctlScrollTip.IsOn(bFlag); }
- void HiddenColor(COLORREF clr) { m_vclrHidden.CustomRGB(clr); }
- void HiddenColor(VColor &vclr) { m_vclrHidden = vclr; }
- COLORREF HiddenColor() { return m_vclrHidden.GetRGB(); }
-
- // ---- Print Settings ----
- int PrintStyle() { return m_nPrintStyle; }
- void PrintStyle(int nStyle) { m_nPrintStyle = nStyle; }
- BOOL UseRptForm() { return m_bUseRptForm; }
- void UseRptForm(BOOL bFlag) { m_bUseRptForm = bFlag; }
-
- // ---- VForm Builder .vfb load Functions ----
- BOOL LoadVfbFile(LPCTSTR szVfbFile, CVfBldrDoc *pVfbDoc=NULL,
- BOOL bRptLoad=FALSE);
- BOOL LoadRptVfbFile(LPCTSTR szVfbFile, CVfBldrDoc *pVfbDoc=NULL);
- void LoadVfbData(CVfBldrDoc *pVfbDoc);
- void LoadRptVfbData(CVfBldrDoc *pVfbDoc);
- void CopyBasicVfbAttribs(VCtl *p, VfbCtl *pCtl, VRow *pRow);
- void CreateCtlsFromVfb(VRow *pRow, CVfbSection *pSect);
-
- // ---- Drag & Drop functions ----
- BOOL UseAsDropTarget() { return m_bUseAsDropTarget; }
- BOOL UseAsDropTarget(BOOL bFlag);
- virtual void SelectDropTarget(long nRowId=-1);
- virtual DROPEFFECT OnDragEnter(CWnd *pWnd, COleDataObject* pDataObject,
- DWORD dwKeyState, CPoint point);
- virtual void OnDragLeave(CWnd *pWnd);
- virtual DROPEFFECT OnDragOver(CWnd *pWnd, COleDataObject* pDataObject,
- DWORD dwKeyState, CPoint point);
- virtual DROPEFFECT OnDropEx(CWnd *pWnd, COleDataObject* pDataObject,
- DROPEFFECT dropDefault,
- DROPEFFECT dropList, CPoint point);
- virtual BOOL OnDrop(CWnd *pWnd, COleDataObject* pDataObject,
- DROPEFFECT dropEffect, CPoint point);
- virtual DROPEFFECT OnDragScroll(CWnd *pWnd, DWORD dwKeyState, CPoint point);
- virtual BOOL OnDrop(long nRowId, COleDataObject* pDataObject,
- DROPEFFECT dropEffect);
- virtual BOOL OnBeginDrag(long nRowId) { return FALSE; }
-
- // ---- Grid Mode ----
- BOOL GridMode() { return m_bGridMode; }
- void GridMode(BOOL bMode); // Turn Grid Mode On/Off
- void CreateGrid();
-
- CString GetGridSettings();
- void SetGridSettings(LPCTSTR szSettings, BOOL bSetHeight=TRUE, BOOL bSetWidths=TRUE);
-
- int GridStyle() { return m_nGridStyle; }
- void GridStyle(int nStyle) { m_nGridStyle = nStyle; }
- void GridBackColor(COLORREF clr) { m_vclrGridBack.UseCustomRGB(clr); }
- void GridBackColor(VColor &vclr) { m_vclrGridBack = vclr; }
- COLORREF GridBackColor() { return m_vclrGridBack.GetRGB(); }
- void GridLineColor(COLORREF clr) { m_vclrGridLine.CustomRGB(clr); }
- void GridLineColor(VColor &vclr) { m_vclrGridLine = vclr; }
- COLORREF GridLineColor() { return m_vclrGridLine.GetRGB(); }
-
- BOOL GridColsSizable() { return m_bGridColsSizable; }
- void GridColsSizable(BOOL bFlag){ m_bGridColsSizable = bFlag; }
- BOOL GridColsMoveable() { return m_bGridColsMoveable; }
- void GridColsMoveable(BOOL bFlag){ m_bGridColsMoveable = bFlag; }
- int GridHdrHeight() { return m_nGridHdrHeight; }
- void GridHdrHeight(int nHeight); // Sets the Grid header height
- int GridRowHeight() { return m_nGridRowHeight; }
- void GridRowHeight(int nHeight) { m_nGridRowHeight = nHeight; }
-
- int GridCol() { return m_nGridCol; }
- int GridFirstCol() { return m_siHorz.nPos; }
- int GridColCount() { return m_gridCtl.GetSize(); }
- int GridFrozenColCount() { return m_nGridFrozenCols; }
- void GridFrozenColCount(int nCount) { m_nGridFrozenCols = nCount; }
- int GridWidth(); // Returns width of grid columns
- int GridWidthVisCols(CRect rect); // Returns width of visible columns
-
- void MultiColSelect(BOOL bFlag) { m_bMultiColSelect = bFlag; }
- BOOL MultiColSelect() { return m_bMultiColSelect; }
- void ColsSelected(BOOL bFlag) { m_bColsSelected = bFlag; }
- BOOL ColsSelected() { return m_bColsSelected; }
- BOOL InGridHeading() { return m_bInGridHeading; }
-
- void GridHdrContextMenu(UINT nMenuID) { m_nGridHdrContextMenu = nMenuID; }
- UINT GridHdrContextMenu() { return m_nGridHdrContextMenu; }
- CPoint GetContextMenuPoint() { return m_ptContextMenu; }
-
- // ---- Grid Mode Internal ----
- int GridPageLeft(); // Returns column to make first
- int GridPageRight(); // Returns column to make first
- int GridLastVisCol(BOOL &bPartial); // Returns the last visible column
- int GridFirstColForVisLast(); // First column to make last visible
- int GetGridColToSize(CPoint pt);// Checks point position
- int GetGridRowToSize(CPoint pt);// Checks point position
-
- void DrawGridHeader(CDC *pDC, CRect rect); // Draws the grid header
- void DrawGridRow(CDC *pDC, CRect rect, VRow *pRow); // Draws a grid row
- void DrawGridCtl(CDC *pDC, VCtl *pCtl); // Draws a grid Control
- void DrawGridCell(CDC *pDC, VCtl *pCtl, CRect rectCell, // Draws a Grid Cell
- CBrush &brBack, CPen &penLine);
- void Draw3dCell(CDC *pDC, CRect rect, CBrush &brBack, BOOL bIn=TRUE);
- CRect GridRect(int nCtlIdx); // Rect of specified cell
- void GetGridFirstLastX(int& nFirstX, int& nLastX);
- void GetGridLeftRightSelCols(int &nLeftCol, int &nRightCol);
- CRect GridHelperRect(int nCtlIdx); // Rect of control in cell
- int GetGridCtlIdx(CPoint pt); // Gets index of specified control
- int GetGridCtlIdx(int nCtlPos, int nCurCtl); // Gets index of specified control
- int GetGridCtlIdx(VCtl *pCtl); // Gets index of specified control
- int GetGridCtlIdx(LPCTSTR szCtlName); // Gets index of specified control
- void ProcessGridTab(); // Called when tab key is pressed
-
- void ColSelecting(CPoint point); // Called when selecting columns
- void LiveColMoving(CPoint point); // Called when moving a column
- void NonLiveColMoving(CPoint point); // Called when moving a column
-
- // ----------- Printing Functions -------------------
- void DoPrepareDC(CDC* pDC, CPrintInfo* pInfo);
- BOOL DoPreparePrinting(CView *pView, CPrintInfo* pInfo);
- void CalcPageInfo(CDC* pDC, CPrintInfo* pInfo);
- void DoPrint(CDC* pDC, CPrintInfo* pInfo);
- void DoPrintScreen(CDC *pDC, CPrintInfo* pInfo=0);
- void DoPrintAll(CDC *pDC, CPrintInfo* pInfo);
- void DoPrintSelected(CDC *pDC, CPrintInfo* pInfo);
- void DoPrintScreenAsReport(CDC *pDC, CPrintInfo* pInfo=0);
- void DoPrintAllAsReport(CDC *pDC, CPrintInfo* pInfo);
- void DoPrintSelectedAsReport(CDC *pDC, CPrintInfo* pInfo);
-
- VRow* GetRptHdr() { return m_pRptHdr; }
- VRow* GetRptDtl() { return m_pRptDtl; }
- VRow* GetRptFtr() { return m_pRptFtr; }
- void SetRptHdr(VRow* pRow); // Sets the Report Header
- void SetRptDtl(VRow* pRow); // Sets the Report Detail
- void SetRptFtr(VRow* pRow); // Sets the Report Footer
-
- // -------------- Primary Functions --------------
- void ResetNumRows(long xNumRows, long nRowId=-1); // Resets the window
- void ResizeToParent(); // Resize window to parents size
-
- // ----------- Reset/Set Section/Control Functions ---------
- BOOL GoToRow(long nRowId);
- BOOL GoToRowOld(long nRowId); // Older simpler version
- BOOL CycleSection(BOOL bRepaint); // Changes to next section
- BOOL ChangeSection(int nSection, int nCtlPos, BOOL bRepaint);
- BOOL ChangeSectionAndCtl(int nSection, int nCtl, BOOL bRepaint);
- BOOL SetCurRow(long nRowId, int nCtlPos, BOOL bRepaint=TRUE);
- BOOL SetCurRowAndCtl(long nRowId, long nCtl=-1, BOOL bRepaint=TRUE);
- BOOL SetCurRowAndCtl(long nRowId, CPoint point, BOOL bRepaint=TRUE);
- void ResetSelectors(long nRowId, BOOL bCtlKey, BOOL bShiftKey);
- void ResetVertScroll(BOOL bRedraw=TRUE); // Reset Vertical Scroll settings
- void ResetHorzScroll(BOOL bRedraw=TRUE); // Reset Horizontal Scroll settings
- BOOL SaveCurRow(BOOL bCancelAdd=FALSE, BOOL bChangeRow=TRUE);
- void SetCurCtlOnSameRow(int nCtl, BOOL bToScreen=TRUE,
- BOOL bActivateHelper=TRUE);
- void SaveCurCtl();
-
- BOOL StartAddRow(); // Starts Adding a row
- void CancelAdd(); // Cancel Add Mode
-
- // -------- Header/Footer/Detail Section and Control Functions ------
- VHeader* Header() { return m_pHeader; }
- VHeader* Footer() { return m_pFooter; }
- void SetHeader(VHeader* pHeader, BOOL bRedraw);
- void SetDetailRows(VRow *pDtlRow, VRow *pTmpRow, BOOL bRedraw);
- void SetFooter(VHeader* pFooter, BOOL bRedraw);
- VRow* ActiveSection();
- VRow* DtlRow() { return m_pDtlRow; }
- VCtl* DtlCtl() { return m_pDtlRow->GetCtlPtr(m_nDtlCtl); }
- VCtl* DtlCtl(int nCtl){ return m_pDtlRow->GetCtlPtr(nCtl); }
- int DtlCtlIdx() { return m_nDtlCtl; }
- int ActiveCtlIdx(); // Returns idx of active control
- void ActiveCtlIdx(int nCtl); // Sets Idx of active control
- VCtl* ActiveCtl(); // Returns active control Ptr
- VCtl* ActiveCtl(int nCtl); // Returns pointer to specified ctl
- BOOL IsActiveCtlAMultiLineEdit(); // check for a multi-line edit ctl
- BOOL IsDtlRow(VRow *pRow); // Returns TRUE if row is a Dtl Row
-
- // --------------- Static Members/Functions --------------
- static BOOL IsRegistered() { return VFormRegistrar::IsRegistered(); }
- afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam);
-
- // DECLARE_DYNCREATE(VForm)
-
- // ----------- Row State Functions -------------------
- BOOL IsRowSelected(long nRowId);
- BOOL IsRowHidden(long nRowId){ return (nRowId >= m_nRows); }
- BOOL IsFocusRow(long nRowId) { return (nRowId == CurRowId()); }
- BOOL IsRowVisible(long x)
- { return (x >= m_nTopRowId && x < m_nTopRowId + m_nRowsPerScreen); }
- BOOL IsAnyPartOfRowVisible(long x)
- { return (x >= m_nTopRowId && x <= m_nTopRowId + m_nRowsPerScreen); }
- BOOL IsRowPartiallyVisible(long x)
- { return x == m_nTopRowId + m_nRowsPerScreen; }
- BOOL GetRowRect(VRow *pRow, CRect &rectRow, CRect &rectClip);
-
- // ----------- Selector Tab Functions -------------------
- BOOL AutoSelect() { return m_bAutoSelect; }
- void AutoSelect(BOOL bFlag) { m_bAutoSelect = bFlag; }
- BOOL DrawSelectRows() { return m_bDrawSelectRows; }
- void DrawSelectRows(BOOL bFlag) { m_bDrawSelectRows = bFlag; }
- int SelectorWidth() { return m_nSelectorWidth; }
- void SelectorWidth(int nWidth)
- { m_nSelectorWidth = nWidth;
- if(m_bUseSelectors) m_nCurSelWidth = m_nSelectorWidth;
- ResetHorzScroll(); }
- int CurSelectorWidth() { return m_nCurSelWidth; }
-
- long FirstSelected() { return m_selectedList.First(); }
- long LastSelected() { return m_selectedList.Last(); }
- long NextSelected() { return m_selectedList.Next(); }
- long PrevSelected() { return m_selectedList.Prev(); }
- long SelectedCount() { return m_selectedList.Count(); }
-
- // ----------- Simple Values -------------------
- BOOL IsEmpty() { return (m_nRows == 0); }
- long BtmVisibleRowId(); // Last Visible Row on the screen
- long TopRowId() { return m_nTopRowId; }
- long BtmRowId() { return m_nTopRowId + m_nRowsPerScreen - 1; }
- long CurRowId() { return m_nCurRowId; }
- long LastRowId() { return m_nRows - 1; }
- long AddRowId() { return m_bAdding ? m_nRows - 1 : m_nRows; }
- long RowCount() { return m_nRows; }
- static VFonts* GetFonts() { return &m_fonts; }
-
- // ----------- Get/Set Attributes --------------------
- void Font(CFont *pFont) { m_pFont = pFont; }
- CFont* Font() { return m_pFont; }
- int RowHeight() { return m_nRowHeight; }
- void RowHeight(int nHeight) { m_nRowHeight = nHeight; }
- int RowWidth() { return m_nRowWidth; }
- void RowWidth(int nWidth) { m_nRowWidth = nWidth; ResetHorzScroll(); }
- int RowWidthMax()
- { return max(m_nRowWidth, (m_size.cx - m_nCurSelWidth)); }
- int FormHdrHeight() { return m_nFormHdrHeight; }
- void FormHdrHeight(int nHeight); // Sets the Form header height
- int FormRowHeight() { return m_nFormRowHeight; }
- void FormRowHeight(int nHeight) { m_nFormRowHeight = nHeight; }
- int HeaderHeight() { return m_nHeaderHeight; }
- int FooterHeight() { return m_nFooterHeight; }
- int TopOfFooter() { return m_size.cy - m_nFooterHeight; }
-
- // ---------------------------------------------------------------------
- // ----------- Internal Utility Functions used by VForm ------
- // ---------------------------------------------------------------------
-
- // ----------- Functions to get Detail Controls/Indexes ------
- int GetNextDtlIdx(int nIdx);
- int GetPrevDtlIdx(int nIdx);
- int GetFirstDtlIdx();
- int GetLastDtlIdx();
- int GetDtlCtlIdx(CPoint pt, BOOL bMustBeLive=TRUE);
- VCtl* GetDtlCtlPtr(CPoint pt, BOOL bMustBeLive=TRUE);
-
- // ----------- Slot Functions - Used Internally -------------------
- int TopSlot() { return 0; } // Always 0
- int BtmSlot() { return m_nRowsPerScreen - 1; }
- int BtmVisibleSlot(); // Last Visible slot on the screen
- BOOL IsSlotVisible(int x) { return (x >= 0 && x <= BtmSlot()+1); }
- int CurSlot() { return (m_nCurRowId - m_nTopRowId); }
-
- // ----------- Conversion Utility Functions - Used Internally ---------------
- int PointToSection(CPoint point);
- int PointToSlot(CPoint point);
- long GetRowId(CPoint point);
- long SlotToRow(int nSlot) { return (nSlot + m_nTopRowId); }
- long RowToSlot(long nRow) { return (nRow - m_nTopRowId); }
- CRect GetCtlRect(VCtl *pCtl);
-
- // ------------ Offset Rect - Used Internally -----------------
- void OffsetHdrToScreen(CRect &rect)
- { rect.OffsetRect((m_nCurSelWidth - m_siHorz.nPos), 0); }
- void OffsetFtrToScreen(CRect &rect)
- { rect.OffsetRect((m_nCurSelWidth - m_siHorz.nPos),
- m_size.cy - m_nFooterHeight);
- }
- void OffsetRowToScreen(CRect &rect, int nSlot)
- { if(GridMode())
- rect.OffsetRect(m_nCurSelWidth,
- (nSlot * m_nRowHeight)+m_nHeaderHeight);
- else
- rect.OffsetRect((m_nCurSelWidth - m_siHorz.nPos),
- (nSlot * m_nRowHeight)+m_nHeaderHeight);
- }
- void OffsetScreenToRow(CRect &rect, int nSlot)
- { if(GridMode())
- rect.OffsetRect(m_nCurSelWidth * -1,
- ((nSlot * m_nRowHeight)+m_nHeaderHeight) * -1);
- else
- rect.OffsetRect((m_siHorz.nPos - m_nCurSelWidth),
- ((nSlot * m_nRowHeight)+m_nHeaderHeight) * -1);
- }
-
- // ------------------ Offset Point -----------------
- void OffsetScreenToHdr(CPoint &pt)
- { pt.x -= (m_nCurSelWidth - m_siHorz.nPos); }
- void OffsetScreenToFtr(CPoint &pt)
- { pt.x -= (m_nCurSelWidth - m_siHorz.nPos);
- pt.y -= (m_size.cy - m_nFooterHeight);
- }
- void OffsetRowToScreen(CPoint &pt, int nSlot)
- { if(GridMode()) pt.x += (m_nCurSelWidth);
- else pt.x += (m_nCurSelWidth - m_siHorz.nPos);
- pt.y += ((nSlot * m_nRowHeight) + m_nHeaderHeight);
- }
- void OffsetScreenToRow(CPoint &pt, int nSlot)
- { if(GridMode()) pt.x -= (m_nCurSelWidth);
- else pt.x -= (m_nCurSelWidth - m_siHorz.nPos);
- pt.y -= ((nSlot * m_nRowHeight) + m_nHeaderHeight);
- }
-
- // ------------------ Offset Value (X or Y) -----------------
- int OffsetRowToScreenY(int nSlot)
- { return ((nSlot * m_nRowHeight) + m_nHeaderHeight); }
- int OffsetScreenToRowY(int nSlot)
- { return (-((nSlot * m_nRowHeight) + m_nHeaderHeight)); }
- int OffsetRowToScreenX()
- { if (GridMode()) return m_nCurSelWidth;
- return (m_nCurSelWidth - m_siHorz.nPos); }
- int OffsetScreenToRowX()
- { if (GridMode()) return (m_nCurSelWidth * -1);
- return (m_siHorz.nPos - m_nCurSelWidth); }
-
- // ------------ Helper Control Functions -------------------
- BOOL UseHelperForCurCtl()
- { VCtl *pCtl = ActiveCtl(); if(!pCtl) return FALSE;
- return pCtl->UseHelper(); }
- VCtlHelper* GetHelperCtl(); // Returns NULL or helper pointer
- VCtlHelper* GetOrCreateHelperCtl(VCtl *pCtl);
- void HideHelperCtl(); // Hides active helper (if any)
- void ActivateHelperCtl(); // Activates helper control
- void MoveHelperCtl(); // Moves helper control
- void ActivateListCtl(); // Activates list control
- void MoveListCtl(); // Moves the list control
- void CloseListCtl(); // Closes the list control
-
- // ------------------ Focus Functions ------------
- // OnSetFocus();
- // OnKillFocus();
-
- // ----------- Drawing Functions -------------------
- void ResetPalette(CDC *pDC); // Resets the palette
-
- // void OnPaint(); // Handled by Map
- void RefreshData();
- void RefreshScreen(int nRefreshType,
- int nSectionFlags=VFSECT_HDR | VFSECT_DTL | VFSECT_FTR);
- void ShiftRowsUp(BOOL bToScreen, int nNumRowsToShift=1);
- void ShiftRowsDown(BOOL bToScreen, int nNumRowsToShift=1);
- void DrawRow(long nRowId, BOOL bToScreen); // Draws row (by Row Id)
- void DrawRow(VRow *pRow, BOOL bToScreen); // Draws a row on memdc
- void DrawSelector(long nRowId, BOOL bToScreen); // Draws sel (by Row Id)
- void DrawSelector(VRow *pRow, BOOL bToScreen); // Draws a sel on memdc
- void DrawCtl(VCtl *pCtl, BOOL bToScreen); // Draws a control on memdc
- void RefreshSelectors(int nRefreshType); // Refreshes all selectors
-
- // --------------------------------------------------------------------
- // ----------- FOLLOWING ARE IN vFrmScroll.cpp ------------------------
- // --------------------------------------------------------------------
- // ----------- Scrolling/Movement -------------------
- void ScrollStart(); // Must be called when scrolling starts
- void ScrollStop(); // Must be called when scrolling stops
-
- BOOL ScrollUpOnePage(BOOL bChgCurRow=TRUE);
- BOOL ScrollDownOnePage(BOOL bChgCurRow=TRUE);
-
- BOOL ScrollUpOneLine(BOOL bChgCurRow=TRUE, int nCtlPos=VFCTL_SAME);
- BOOL ScrollDownOneLine(BOOL bChgCurRow=TRUE, int nCtlPos=VFCTL_SAME);
- BOOL MoveUpOneLine(int nCtlPos=VFCTL_SAME);
- BOOL MoveDownOneLine(int nCtlPos=VFCTL_SAME);
-
- BOOL ScrollHome(BOOL bMaxTop=FALSE);
- BOOL ScrollEnd(BOOL bMaxBtm=FALSE);
- BOOL ScrollToTop(long newTop, BOOL bChgCurRow=TRUE);
-
- // ------------------ Mouse/Keyboard Functions -------------
- // OnLButtonDown();
- BOOL OnLButtonDownDtl(UINT nFlags, CPoint point);
- void OnLButtonDownGridHdr(UINT nFlags, CPoint point);
- // OnLButtonUp();
- // OnKeyDown();
- // OnKeyUp();
- // PreTranslateMessage(); // Grabs Arrow/Tab key Msgs
- void ProcessTab(); // Process a tab key message
-
-
- protected:
- // ------------------- Virtual Functions ---------------------------
- virtual VRow* InitRow()=0; // Create a new detail row
- virtual VRow* InitRptRow() { return InitRow(); } // Create a new report detail row
-
- // --- the following functions deal with the Data ---
- virtual BOOL OnGetRow(VRow* pRow)=0; // Gets row for screen
- // virtual BOOL OnGetRptRow(VRow* pRow) { return TRUE; }
- virtual BOOL OnGetRptRow(VRow* pRow) { return OnGetRow(pRow); }
- virtual BOOL OnSaveRow(VRow* pRow)=0; // Save row from screen
- virtual BOOL OnAddRow(VRow* pRow)=0; // Add a data row
- virtual BOOL OkToAdd(long nRowId) { return TRUE; }
- virtual void OnStartAdd(VRow* pRow) {}
- virtual void OnCurrent(VRow* pRow) {}
- virtual void OnCurrentCtl(VCtl* pCtl) {}
- virtual BOOL OnDelete(){ return FALSE; } // Delete row(s)
- virtual BOOL OnBeginHelper(VCtl* pCtl, VCtlHelper* pHelper) { return TRUE; }
- virtual BOOL OnEndHelper(VCtl* pCtl, VCtlHelper* pHelper) { return TRUE; }
- virtual BOOL OnBeginList(VCtl* pCtl, CListBox* pLB) { return TRUE; }
- virtual BOOL OnEndList(VCtl* pCtl, CListBox* pLB) { return TRUE; }
- virtual void OnDrawSelector(CDC *pDC, CRect rect, long nRowId);
- virtual BOOL OnSelectorClick(long nRowId);
- virtual BOOL OnGridRowColor(VRow* pRow, COLORREF &clrRow) { return FALSE; }
- virtual CPalette* GetPalette() { return NULL; }
-
- public:
- virtual void OnClick(VRow* pRow, int nId) {}; // Button clicked
- virtual BOOL OnDblClkHeader(UINT nFlags, CPoint point) { return FALSE; }
- virtual BOOL OnDblClkFooter(UINT nFlags, CPoint point) { return FALSE; }
- virtual BOOL OnDblClkDetail(UINT nFlags, CPoint point) { return FALSE; }
- virtual BOOL OnDblClkRow(long nRowId, UINT nFlags, CPoint point) { return FALSE; }
-
- // Operations
- public:
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(VForm)
- public:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- //}}AFX_VIRTUAL
-
- // Generated message map functions
- protected:
- //{{AFX_MSG(VForm)
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
- afx_msg void OnPaint();
- afx_msg void OnSetFocus(CWnd *pOldWnd);
- afx_msg void OnKillFocus(CWnd *pNewWnd);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnCaptureChanged(CWnd* pWnd);
- afx_msg void OnListDblClick();
- afx_msg void OnListSelChange();
- afx_msg int OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex);
- afx_msg void OnTimer(UINT nIDEvent);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnSysColorChange();
- afx_msg void OnContextMenu(CWnd*, CPoint point);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- #endif
-