home *** CD-ROM | disk | FTP | other *** search
- // -------------------------------------------------------------------------
- // Copyright @ 1997 TCK Software, Incorporated
- // All Rights Reserved
- // -------------------------------------------------------------------------
- #ifndef __VROW_H__
- #define __VROW_H__
-
- #ifdef VF_STATIC
- #undef AFX_EXT_CLASS
- #define AFX_EXT_CLASS
- #endif
-
- #include "VCtl.h"
- #include "VEdit.h"
- #include "afxtempl.h"
- #include "VfUtil.h"
- #include "VBitmap.h"
-
- #define VROW_BG_DEFAULT 0
- #define VROW_BG_PAPER 1
- #define VROW_BG_FLAT 2
- #define VROW_BG_GREENBAR 3
- #define VROW_BG_BMP 4
-
- #define ROW_CTRLID_OFFSET 100
- #define VROW_COLOR_BACKGROUND 1
- #define VROW_COLOR_HIGHLIGHT 2
- #define VROW_COLOR_HIDDEN 3
-
- typedef CArray<VCtl *, VCtl *> VCtlPtrArray;
-
- class VForm;
- class VMaskEdit;
- class VEdit;
-
- // -------------------------------------------------------------------------
- // Base class for control containers: VHeader, VRow, VFooter
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VCtlContainer
- {
- protected:
- VCtlPtrArray m_ctl; // Array of pointers to controls
- int m_nCtls; // how many controls
- BOOL m_bDeleteByForm; // True if form should delete this row
- BOOL m_bChanged; // True if some data on the row changed
- VForm* m_pForm; // pointer to the form
- VColor m_vclrBack; // Background Color
- VColor m_vclrHighlight; // Highlight Color
- VColor m_vclrHidden; // Hidden Color
-
- public:
- VCtlContainer(); // Constructor
- ~VCtlContainer(); // Destructor
-
- VForm* Form() { return m_pForm; }
- void SetForm(VForm* x) { m_pForm = x; }
- void SetCustomColor(int nVRowClrIdx, COLORREF clr);
- void SetColor(int nVRowClrIdx, int nIndex);
- int GetColorIndex(int nVRowClrIdx);
- COLORREF GetColor(int nVRowClrIdx);
-
- void BackColor(VColor &vclr) { m_vclrBack = vclr; }
- void HighlightColor(VColor &vclr) { m_vclrHighlight = vclr; }
- void HiddenColor(VColor &vclr) { m_vclrHidden = vclr; }
- VColor& BackVColor() { return m_vclrBack; }
- VColor& HighlightVColor() { return m_vclrHighlight; }
- VColor& HiddenVColor() { return m_vclrHidden; }
-
-
- void AddCtl(VCtl *pCtl); // Adds a control to the container
- VCtl* AddNamedCtl(VCtl *pCtl); // Adds a named control to the container
- void RemoveAllCtls(); // Removes (& deletes) all controls
- void ResetAllCtls(); // Resets (& deletes) the controls
- int CtlCount() { return m_nCtls; }
-
- void DeleteByForm(BOOL bFlag) { m_bDeleteByForm = bFlag; }
- BOOL DeleteByForm() { return m_bDeleteByForm; }
-
- void Changed() { m_bChanged = TRUE; }
- void Unchanged() { m_bChanged = FALSE; }
- BOOL IsChanged() { return m_bChanged; }
-
- int GetCtlIdxById(int nId); // Retrieve idx of needed control
- int GetCtlIdxByName(LPCTSTR szName);
- int GetCtlIdx(VCtl *pCtl); // Retrieve idx of needed control
- int GetClosestCtlIdx(int idx); // Retrieve closest control
- int GetCtlIdx(CPoint xPoint, BOOL bMustBeLive);
-
- int GetNextLiveCtlIdx(int nStartIdx=0); // Retrieve idx of next live control
- int GetPrevLiveCtlIdx(int nStartIdx); // Retrieve idx of prev live control
- int GetFirstLiveCtlIdx() { return GetNextLiveCtlIdx(0); }
- int GetLastLiveCtlIdx() { return GetPrevLiveCtlIdx(m_nCtls - 1); }
-
- VCtl* GetCtlPtrById(int nId); // Retrieve pointer to needed control
- VCtl* GetCtlPtrByName(LPCTSTR szName);
- VCtl* GetCtlPtr(int idx); // Retrieve pointer to needed control
- VCtl* GetClosestCtlPtr(int nId); // Retrieve closest control
- VCtl* GetCtlPtr(CPoint xPoint, BOOL bMustBeLive);
-
- VCtl* GetNextLiveCtlPtr(int nStartIdx=0); // Retrieve pointer to needed control
- VCtl* GetPrevLiveCtlPtr(int nStartIdx); // Retrieve pointer to needed control
- VCtl* GetNextLiveCtlPtr(VCtl *pOldCtl);
- VCtl* GetPrevLiveCtlPtr(VCtl *pOldCtl);
- VCtl* GetFirstLiveCtlPtr() { return GetNextLiveCtlPtr(0); }
- VCtl* GetLastLiveCtlPtr() { return GetPrevLiveCtlPtr(m_nCtls - 1); }
-
- // --- We dont need any virtual functions, since derived classes are
- // --- always called from that level (we never use a pointer to a VCtlContainer)
- // --- - otherwise, we would make these functions virtual
- void OnTimer(); // On Timer Events
- void OnSysColorChange();
-
- // --- Virtual Functions ---
- // virtual long RowId() { return -1; }
- // virtual BOOL HasFocus() { return FALSE; }
- // virtual BOOL IsSelected() { return FALSE; }
- // virtual BOOL IsHidden() { return FALSE; }
- // virtual void Draw(BOOL bToScreen=TRUE) {};
-
- // ------- Drawing Routines -----------------
- // virtual void OnDraw(CDC *pDC) {}; // Draws the Container
- // virtual void OnTimer(); // On Timer Events
- // virtual void OnDrawBackground(CDC *pDC, CRect &rect) {};
- // virtual void OnDrawCtlBackground(CDC *pDC, CRect &rect) {};
- // virtual void OnDrawHiddenBk(CDC *pDC, CRect &rect) {};
- };
-
- // -------------------------------------------------------------------------
- // Row Class
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VRow : public VCtlContainer
- {
- protected:
- int m_nHeight; // Height of row
- long m_nRow; // row id
-
- int m_nBackStyle; // Background Style
- HICON m_hIcon; // Icon Handle
- int m_nIconX, m_nIconY; // Icon Position
- VBitmap m_vbitmap; // For use with bitmap background
- BOOL m_bBmpLoaded; // TRUE if BMP file has been loaded
-
- public:
- VRow(); // Constructor
- virtual ~VRow(); // Destructor
-
- long RowId() { return m_nRow; }
- void RowId(long nRowId) { m_nRow = nRowId; }
-
- int Height() { return m_nHeight; }
- void Height(int nHeight) { m_nHeight = nHeight; }
-
- BOOL HasFocus();
- BOOL IsSelected();
- BOOL IsHidden();
- void Draw(BOOL bToScreen=TRUE);
-
- // ------ Drawing Settings -----
- void SetStyle(int nBackStyle) { m_nBackStyle = nBackStyle;}
- int GetStyle() { return m_nBackStyle; }
-
- void SetIcon(HICON hIcon) { m_hIcon = hIcon;}
- HICON GetIcon() { return m_hIcon; }
- void SetIconPosition(int x, int y) { m_nIconX = x; m_nIconY = y; }
-
- // If using BMP, derived class must override GetBackBmp or call LoadBitmap
- virtual BOOL LoadBitmap(LPCTSTR szBmpFile);
- virtual BOOL LoadBitmapRes(LPCTSTR szBmpResource);
- virtual BOOL LoadBitmapRes(UINT uID);
- virtual HBITMAP GetBackBmp();
- virtual CPalette* GetBackPalette();
- virtual HPALETTE GetBackPaletteHandle();
-
- void ResetCtl(VCtl &ctl, BOOL bTp, BOOL bNib, COLORREF clr);
-
- // ------- RowType used for cursor placement with multiple row types -----
- virtual int RowType() { return 0; }
-
- // ------- Drawing Routines -----------------
- virtual void OnDraw(CDC *pDC, CRect &rect); // Draws the row control
- virtual void OnDraw(CDC *pDC, CRect &rect, CRect& rectClip);
- virtual void OnTimer() { VCtlContainer::OnTimer(); }
- virtual void OnDrawBackground(CDC *pDC, CRect &rect, int nSelWidth=0);
- virtual void OnDrawCtlBackground(CDC *pDC, CRect &rect);
- virtual void OnDrawHiddenBk(CDC *pDC, CRect &rect);
-
- virtual void OnRptDraw(CDC *pDC, CRect &rect);
- virtual void OnRptDrawBackground(CDC *pDC, CRect &rect);
- virtual void SetRptFields(CPrintInfo *pInfo);
-
- virtual void DrawNormalBG(CDC *pDC, CRect &rect, BOOL bDrawFocus, int nSelWidth);
- virtual void DrawFlatBG(CDC *pDC, CRect &rect, BOOL bDrawFocus, int nSelWidth);
- virtual void DrawGreenBarBG(CDC *pDC, CRect &rect, BOOL bDrawFocus, int nSelWidth);
- virtual void DrawPaperBG(CDC *pDC, CRect &rect, BOOL bDrawFocus, int nSelWidth);
- virtual void DrawBmpBG(CDC *pDC, CRect &rect, BOOL bDrawFocus, int nSelWidth);
-
- // ------- Miscellaneous -----------------
- virtual COLORREF CurBackColor();
- };
-
- // -------------------------------------------------------------------------
- // Header AND Footer Class
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VHeader : public VRow
- {
- protected:
- BOOL m_bHighlight; // Is header Highlighted
-
- public:
- VHeader(); // Constructor
- virtual ~VHeader() {}; // Destructor
-
- BOOL IsHighlighted() { return m_bHighlight; }
-
- void Highlight(BOOL x) { m_bHighlight = x; }
-
- // ------- Drawing Routines -----------------
- virtual void OnDraw(CDC *pDC, CRect &rect); // Draws the row control
- virtual void OnDraw(CDC *pDC, CRect &rect, CRect& rectClip);
- virtual void OnDrawBackground(CDC *pDC, CRect &rect, int nSelWidth);
-
- // ------- Miscellaneous -----------------
- virtual COLORREF CurBackColor();
- };
-
-
- #endif