splitex.h

来源:互联网 发布:数据采集与处理投稿 编辑:程序博客网 时间:2024/05/19 23:17
  1. // splitex.h
  2. // (c) 1997, Oleg G. Galkin
  3. classCSplitterWndEx :public CSplitterWnd
  4. {
  5. protected:
  6.    int m_nHidedCol;   // hide column number, -1 if all columns
  7.                       // are shown
  8. public:
  9.    CSplitterWndEx();
  10.    voidShowColumn();
  11.    voidHideColumn(int colHide);
  12. // ClassWizard generated virtual function overrides
  13.    //{{AFX_VIRTUAL(CSplitterWndEx)
  14.    //}}AFX_VIRTUAL
  15. // Generated message map functions
  16. protected:
  17.    //{{AFX_MSG(CSplitterWndEx)
  18.       // NOTE - the ClassWizard will add and remove member
  19.       //        functions here.
  20.       //}}AFX_MSG
  21.     DECLARE_MESSAGE_MAP()
  22. };
  23. //////////////////////////////////////////////////////////////////
  24. //
  25. // splitex.cpp
  26. // (c) 1997, Oleg G. Galkin
  27. #include"stdafx.h"
  28. #include"splitex.h"
  29. #ifdef _DEBUG
  30. #definenew DEBUG_NEW
  31. #undef THIS_FILE
  32. staticchar THIS_FILE[]= __FILE__;
  33. #endif
  34. //////////////////////////////////////////////////////////////////
  35. /
  36. // CSplitterWndEx
  37. CSplitterWndEx::CSplitterWndEx():
  38.     m_nHidedCol(-1)
  39. {
  40. }
  41. voidCSplitterWndEx::ShowColumn()
  42. {
  43.    ASSERT_VALID(this);
  44.    ASSERT(m_nCols< m_nMaxCols);
  45.    ASSERT(m_nHidedCol!= -1);
  46.    int colNew= m_nHidedCol;
  47.    m_nHidedCol = -1;
  48.    int cxNew= m_pColInfo[m_nCols].nCurSize;
  49.    m_nCols++;   // add a column
  50.    ASSERT(m_nCols== m_nMaxCols);
  51.    // fill the hidden column
  52.    int col;
  53.    for(int row= 0; row< m_nRows; row++)
  54.    {
  55.       CWnd* pPaneShow= GetDlgItem(
  56.          AFX_IDW_PANE_FIRST+ row *16 + m_nCols);
  57.       ASSERT(pPaneShow!= NULL);
  58.       pPaneShow->ShowWindow(SW_SHOWNA);
  59.       for(col = m_nCols- 2; col>= colNew; col--)
  60.       {
  61.          CWnd* pPane= GetPane(row, col);
  62.          ASSERT(pPane!= NULL);
  63.          pPane->SetDlgCtrlID(IdFromRowCol(row, col + 1));
  64.       }
  65.       pPaneShow->SetDlgCtrlID(IdFromRowCol(row, colNew));
  66.    }
  67.    // new panes have been created -- recalculate layout
  68.    for(col = colNew+ 1; col< m_nCols; col++)
  69.       m_pColInfo[col].nIdealSize= m_pColInfo[col- 1].nCurSize;
  70.    m_pColInfo[colNew].nIdealSize= cxNew;
  71.    RecalcLayout();
  72. }
  73. voidCSplitterWndEx::HideColumn(int colHide)
  74. {
  75.    ASSERT_VALID(this);
  76.    ASSERT(m_nCols> 1);
  77.    ASSERT(colHide< m_nCols);
  78.    ASSERT(m_nHidedCol== -1);
  79.    m_nHidedCol = colHide;
  80.    // if the column has an active window -- change it
  81.    int rowActive, colActive;
  82.    if(GetActivePane(&rowActive,&colActive)!= NULL &&
  83.        colActive == colHide)
  84.    {
  85.       if(++colActive >= m_nCols)
  86.          colActive = 0;
  87.       SetActivePane(rowActive, colActive);
  88.    }
  89.    // hide all column panes
  90.    for(int row= 0; row< m_nRows; row++)
  91.    {
  92.       CWnd* pPaneHide= GetPane(row, colHide);
  93.       ASSERT(pPaneHide!= NULL);
  94.       pPaneHide->ShowWindow(SW_HIDE);
  95.       pPaneHide->SetDlgCtrlID(
  96.          AFX_IDW_PANE_FIRST+ row *16 + m_nCols);
  97.       for(int col= colHide +1; col< m_nCols; col++)
  98.       {
  99.          CWnd* pPane= GetPane(row, col);
  100.          ASSERT(pPane!= NULL);
  101.          pPane->SetDlgCtrlID(IdFromRowCol(row, col - 1));
  102.       }
  103.    }
  104.    m_nCols--;
  105.    m_pColInfo[m_nCols].nCurSize= m_pColInfo[colHide].nCurSize;
  106.     RecalcLayout();
  107. }
  108. BEGIN_MESSAGE_MAP(CSplitterWndEx,CSplitterWnd)
  109. //{{AFX_MSG_MAP(CSplitterWndEx)
  110.    // NOTE - the ClassWizard will add and remove mapping macros here.
  111. //}}AFX_MSG_MAP
  112. END_MESSAGE_MAP()
原创粉丝点击