⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cgridctrl.h

📁 此次上传的使linux下的文件传输协议
💻 H
📖 第 1 页 / 共 2 页
字号:

    BOOL SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data = 0);

// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CGridCtrl)
	protected:
    virtual void PreSubclassWindow();
	//}}AFX_VIRTUAL
    public:

// Implementation
public:
	BOOL GetItemEnable(int nRow,int nCol);
	void SetItemEnable(int nRow, int nCol, BOOL bEnable);
	int GetItemFontWidth(int nRow, int nCol);
	int GetItemFontWeight(int nRow, int nCol);
	int GetItemFontSize(int nRow, int nCol);
	CString GetItemFontName(int nRow,int nCol);
	void SetItemFontWidth(int nRow, int nCol, int nSize);
	void SetItemFontWeight(int nRow, int nCol, int nSize);
	void SetItemFontSize(int nRow, int nCol, int nSize);
	void SetItemFontName(int nRow, int nCol, CString strFont);
	void SetItemFontItalic(int nRow, int nCol, BOOL bSet);
	void SetItemFontBold(int nRow, int nCol, BOOL bBold);
	BOOL SetItemCtrlTime(int nRow, int nCol);
	BOOL SetItemCtrlDateTime(int nRow, int nCol);
	BOOL SetItemCtrlDate(int nRow, int nCol);
	CCellID GetRadio(int nGroup);
	void DrawText1(CDC* pDC,CString& sText,GridDrawTextTypeEnum nType,CRect& rect);
	CRect DrawTitleInRect(CDC *pDC, CString szString, LPRECT lpRect, long lMode, long lHori, long lVert);
	BOOL Load(LPCTSTR strFile);
	BOOL Save(LPCTSTR strFile);
	BOOL SetItemCtrlComboBox(int nRow, int nCol,CStringArray* pAryData,CStringArray* pAryLsh,BOOL bAutoDelete);
    LRESULT SendMessageToParent(int nRow, int nCol, int nMessage);
	BOOL SetItemCtrlText(int nRow,int nCol);
	BOOL OnCreateCellCtrl(int nRow,int nCol,UINT nChar);
	BOOL SetItemCtrlEdit(int nRow,int nCol);
	void SetItemLine(int nRow,int nCol,BOOL bSet);
	BOOL m_bLineType;
	BOOL GetItemBottomLine(int nRow, int nCol);
	BOOL GetItemRightLine(int nRow, int nCol);
	BOOL GetItemLeftLine(int nRow, int nCol);
	void SetItemBottomLine(int nRow, int nCol, BOOL bSet);
	void SetItemRightLine(int nRow, int nCol, BOOL bSet);
	void SetItemLeftLine(int nRow, int nCol, BOOL bSet);
	BOOL GetItemTopLine(int nRow,int nCol);
	void SetItemTopLine(int nRow,int nCol,BOOL bSet);
	BOOL m_bDblClkSort;
	void DeleteAllRow();
	int AddNewRow();
	double GetRowCountDouble(short nRow);
	BOOL SetItemTextCtrl(int nRow,int nCol);
	BOOL Initialise();
	void SetItemCheck(int nRow,int nCol,BOOL bSet);
	BOOL GetItemCheck(int nRow,int nCol);
	BOOL SetItemCtrlCheckBox(int nRow,int nCol);
	BOOL SetItemCtrlRadio(int nRow,int nCol,int nGroup);
	void SetItemCtrlRadioGroup(int nRow,int nCol,int nGroup);
	BOOL SetRadioCheckImage(CImageList* pImageList);
	int m_nRadioCheckImagePos;
	int AddGridImage(int nPos,CImageList* pImageList);
	void SetRowTextColor(int nRow, COLORREF color);
	long FindString(short nCol, CUIntArray &ua, CStringArray &Dv);
	long FindString(short nCol, CStringArray& Db, CStringArray& Dv);
	void SetRowBkColor(int nRow,COLORREF color);
	double GetColCountDouble(short nCol, CUIntArray& ua, CStringArray& Dv);
	double GetColCountDouble(short nCol,CStringArray& Db,CStringArray& Dv);
	double GetColCountDouble(short nCol);
	void SetDefault(int nType);
	CXpButton m_XpButton;
	GridCtrlTypeEnum GetItemCtrlType(int nRow, int nCol);
	void CopyStruct(CGridCellText *p1, CGridCellText *p2);
	void CopyStruct(CGridCell* p1,CGridCell* p2);
	BOOL SetItemCtrlXpButton(int nRow,int nCol);
	CSize GetCellExtentForJnCtrlImage(CGridCellImage* pCell,int& nRow,int& nCol,CDC* pDC);
	void CopyStruct(CGridCellText* p1,CGridCellImage* p2);
	CSize GetCellExtentForJnCtrlText(CGridCellText* pCell,int& nRow,int& nCol,CDC* pDC);
	void SetCellFromPreCell(CGridCell* pCell,CGridCell* preCell);
	void SetItemCtrlImageSize(int nRow,int nCol,int nWidth,int nHeight);
	void EndSetItemCtrlImage();
	void SendItemImageData(long nSize,const VARIANT FAR& vData);
	BOOL BeginSetItemCtrlImage(int nRow,int nCol,long nSize);
	CCellID m_TempCell,m_CurCell;
	long nImgTempSize;
	long nImgTempPos;
	long EndAddGridImage(long nPos);
	void SendImageData(long nSize, const VARIANT FAR& vData);
	BOOL BeginAddGridImage(long nPos,long nSize);
	void SetFixedCellCombine(int nRow, int nCol, int xNum, int yNum);
	BOOL SetItemCtrlImage(int nRow, int nCol, int nAryPos, int nPos);
	BOOL DeleteGridImage(int nAryPos,int nPos);
	BOOL DeleteImageArray(int nPos);
	int CreateNewImageArray();
	BOOL UndoCellCombine(int nRow, int nCol);
	BOOL SetCellCombine(int nRow, int nCol, int xNum, int yNum);
	BOOL SetItemCtrlImageDrawType(int nRow,int nCol,BOOL bDrawType,JNGRIDIMAGESHOWTYPE nShowType);
	CSize GetCellImageSize(CGridCell* pCell);
	BOOL SetItemCtrlImageNull(int nRow, int nCol);
	BOOL SetItemCtrlImage(int nRow, int nCol, BYTE* lpSrc, DWORD len);
	BOOL SetItemCtrlImage(int nRow, int nCol, UINT nIDRes);
	BOOL SetItemCtrlImage(int nRow, int nCol, IStream* pstm);
	BOOL SetItemCtrlImage(int nRow, int nCol, CArchive &ar);
	BOOL SetItemCtrlImage(int nRow, int nCol, LPCTSTR lpPath);
	BOOL SetItemCtrlImage(int nRow,int nCol,CPicture* pic);

	int AddGridImage(int nPos, BYTE* lpSrc, DWORD len);
	int AddGridImage(int nPos, UINT nIDRes);
	int AddGridImage(int nPos, IStream* pstm);
	int AddGridImage(int nPos, CArchive &ar);
	int AddGridImage(int nPos, LPCTSTR lpPath);
	int AddGridImage(int nPos, CPicture* pic);

	BOOL GetScrollGrid();
	void SetScrollGrid(BOOL bSet);
	BOOL GetGridFocusCell();
	void SetGridFocusCell(BOOL bSet);
	BOOL m_bFocusCell;
	void DrawOrderSign(int nCol, BOOL bOrder,CDC* pDC);
	void DrawOrderSign(int nCol,BOOL bOrder);
	void SortColumn(int nCol);
	GridDataTypeEnum GetColumnType(int nCol);
	BOOL SetColumnType(int nCol, GridDataTypeEnum nType);
	BOOL SetItemDataType(int nRow, int nCol, GridDataTypeEnum nType,int nLenght);
	GridDataTypeEnum GetItemType(int nRow, int nCol);
	long GetDateLong(CString& sDate);
	int DoubleToInt(double d);
	double StrToDouble(CString str);
	CCellID m_PreCell;
	virtual void SortSwapRow(int nLo,int nHi);
	BOOL GetEnableSelection();
	int FindColString(int Row, CString str);
	void SetColTextClor(int nCol, COLORREF color);
	void SetColBkClor(int nCol,COLORREF color);
	BOOL SwapCol(int col1, int col2);
	BOOL MoveColRight();
	BOOL MoveColLeft();
	BOOL GetFontBold();
	BOOL GetFontItalic();
	void SetFontBold(BOOL bBold);
	void SetFontItalic(BOOL bSet);
	int GetFontSize();
	CString GetFontName();
	void SetFontName(const CString &strFont);
	void SetFontSize(int nSize);
	LOGFONT m_lf;
	int FindString(int nCol,CString str);
	BOOL MoveRowDown();
	BOOL MoveRowUp();
	BOOL SwapRow(int row1,int row2);
	BOOL SortNumber(int nCol, BOOL bAscending, int low, int high);
	BOOL SortNumber(int nCol, BOOL bAscending);
	COLORREF m_rgbCellBar2;
	COLORREF m_rgbCellBar1;
//	void DrawGradientFill(CDC* pDC, CRect* prc, int nSegs,COLORREF crStart, COLORREF crEnd, BOOL bSemiFormat, CRect* prcFull);
	BOOL bEnterToKeyDown;
	BOOL IsCellFixed(int nRow, int nCol);
	BOOL GetTextRect(int nRow, int nCol, LPRECT pRect);
	BOOL GetTextRect(const CCellID& cell, LPRECT pRect);
	CGridCell* GetCellP(int nRow, int nCol);
	int GetMargin();
	void SetMargin(int nMargin);
	void SetCurSel();
	void SetFontLog(LOGFONT &lf);
    virtual ~CGridCtrl();
    CCellID SetFocusCell(int nRow, int nCol);
	void ResetScrollBars();

protected:
    BOOL RegisterWindowClass();

    BOOL InvalidateCellRect(const CCellID& cell);
    BOOL InvalidateCellRect(const CCellRange& cellRange);
    void EraseBkgnd(CDC* pDC);

    BOOL GetCellRangeRect(const CCellRange& cellRange, LPRECT lpRect) const;

    CGridCell* GetCell(int nRow, int nCol) const;
    BOOL SetCell(int nRow, int nCol, CGridCell* pCell);

    int  SetMouseMode(int nMode) { int nOldMode = m_MouseMode; m_MouseMode = nMode; return nOldMode; }
    int  GetMouseMode() const    { return m_MouseMode; }

    BOOL MouseOverRowResizeArea(CPoint& point) const;
    BOOL MouseOverColumnResizeArea(CPoint& point) const;

    CCellID GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck = TRUE) const;
    CCellID GetTopleftNonFixedCell() const;
    CCellRange GetUnobstructedNonFixedCellRange() const;
    CCellRange GetVisibleNonFixedCellRange(LPRECT pRect = NULL) const;

    CCellID SetFocusCell(CCellID cell);

    void ResetSelectedRange();
    int  GetScrollPos32(int nBar, BOOL bGetTrackPos = FALSE);
    BOOL SetScrollPos32(int nBar, int nPos, BOOL bRedraw = TRUE);

    BOOL SortTextItems(int nCol, BOOL bAscending, int low, int high);
    BOOL SortDate(int nCol, BOOL bAscending, int low, int high);

    BOOL SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data, 
                   int low, int high);

// Overrrides
protected:
    // Printing    

    // Drag n' drop

    // Mouse Clicks
    virtual void  OnFixedColumnClick(CCellID& cell);
    virtual void  OnFixedRowClick(CCellID& cell);

    // Editing
    virtual CSize GetCellExtent(int nRow, int nCol, CDC* pDC);

    // Drawing
    virtual void  OnDraw(CDC* pDC);
    virtual BOOL  DrawFixedCell(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBk=FALSE);
    virtual BOOL  DrawCell(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBk=FALSE);

    // GridCell Creation and Cleanup
    virtual CGridCell* CreateCell(int nRow, int nCol);
    virtual void EmptyCell(CGridCell* pCell, int nRow, int nCol);

// Attributes
protected:
    // General attributes
    COLORREF    m_crTextColour, m_crTextBkColour, m_crBkColour,   // Grid colours
                m_crFixedTextColour, m_crFixedBkColour, m_crGridColour;
    COLORREF    m_crWindowText, m_crWindowColour, m_cr3DFace,     // System colours
                m_crShadow;    
	unsigned char* pImgTemp;
    int         m_nGridLines;
    BOOL        m_bEditable;
    BOOL        m_bModified;
    BOOL        m_bListMode;
    BOOL        m_bAllowDraw;
    BOOL        m_bEnableSelection;
    BOOL        m_bSortOnClick;
    BOOL        m_bHandleTabKey;
    BOOL        m_bDoubleBuffer;
    // Cell size details
    int         m_nRows, m_nFixedRows, m_nCols, m_nFixedCols;
    CUIntArray  m_arRowHeights;
	//m_arColWidths;
    int         m_nMargin;
    int         m_nDefCellWidth, m_nDefCellHeight;
    int         m_nVScrollMax, m_nHScrollMax;

    // Fonts and images
    LOGFONT     m_Logfont;
    CFont       m_Font;         // for the grid
    // Cell data
    CTypedPtrArray<CObArray, GRID_ROW*> m_RowData;
	CTypedPtrArray<CObArray, CGridColumn*> m_ColData;

	CArray<tagGridRadio*,tagGridRadio*> m_RadioData;
	tagGridRadio* pGridRadio;
	CArray<CGridImage* , CGridImage*> m_ImageData;
	CGridImage* pImageArray;

    // Mouse operations such as cell selection
    int         m_MouseMode;
    CPoint      m_LeftClickDownPoint, m_LastMousePoint;
    CCellID     m_LeftClickDownCell, m_SelectionStartCell;
    CCellID     m_idCurrentCell;
    int         m_nTimerID;
    int         m_nTimerInterval;
    int         m_nResizeCaptureRange;
    BOOL        m_bAllowRowResize, m_bAllowColumnResize;
    int         m_nRowsPerWheelNotch;
    CMap<DWORD,DWORD, CCellID, CCellID&> m_SelectedCellMap, m_PrevSelectedCellMap;

    // Drag and drop
	BOOL		m_bMustUninitOLE;		// Do we need to uninitialise OLE?
    // Printing information
    CSize       m_CharSize;
    int         m_nPageHeight;
    CSize       m_LogicalPageSize,      // Page size in gridctrl units.
                m_PaperSize;            // Page size in device units.

    // sorting
    int         m_bAscending;
    int         m_SortColumn;

protected:
	BOOL m_bScrollGrid;
    void SelectAllCells();
    void SelectColumns(CCellID currentCell);
    void SelectRows(CCellID currentCell);
    void SelectCells(CCellID currentCell);
    void OnSelecting(const CCellID& currentCell);

    // Generated message map functions
    //{{AFX_MSG(CGridCtrl)
    afx_msg void OnPaint();
    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 void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg void OnTimer(UINT nIDEvent);
    afx_msg UINT OnGetDlgCode();
    afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
    afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
    afx_msg void OnSysColorChange();
    afx_msg void OnCaptureChanged(CWnd *pWnd);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	//}}AFX_MSG
#if _MFC_VER >= 0x0421
    afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
#endif
    afx_msg LRESULT OnSetFont(WPARAM hFont, LPARAM lParam);
    afx_msg LRESULT OnGetFont(WPARAM hFont, LPARAM lParam);
    DECLARE_MESSAGE_MAP()

    enum eMouseModes { MOUSE_NOTHING, MOUSE_SELECT_ALL, MOUSE_SELECT_COL, MOUSE_SELECT_ROW,
                       MOUSE_SELECT_CELLS, MOUSE_SCROLLING_CELLS,
                       MOUSE_OVER_ROW_DIVIDE, MOUSE_SIZING_ROW, 
                       MOUSE_OVER_COL_DIVIDE, MOUSE_SIZING_COL,
                       MOUSE_PREPARE_EDIT, MOUSE_PREPARE_DRAG, MOUSE_DRAGGING};
};

inline CGridCell* CGridCtrl::GetCell(int nRow, int nCol) const
{
    if (nRow < 0 || nRow >= m_nRows || nCol < 0 || nCol >= m_nCols) return NULL;

    GRID_ROW* pRow = m_RowData[nRow];
    if (!pRow) return NULL;
    return pRow->GetAt(nCol);
}

inline BOOL CGridCtrl::SetCell(int nRow, int nCol, CGridCell* pCell)
{
    if (nRow < 0 || nRow >= m_nRows || nCol < 0 || nCol >= m_nCols) return FALSE;

    GRID_ROW* pRow = m_RowData[nRow];
    if (!pRow) return FALSE;

    pRow->SetAt(nCol, pCell);
    return TRUE;
}

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_GRIDCTRL_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -