home *** CD-ROM | disk | FTP | other *** search
- // gridsvw8.cpp : implementation of the CGridSample8View class
- //
-
- // This is a part of the Objective Grid C++ Library.
- // Copyright (C) 1995,1996 ClassWorks, Stefan Hoenig.
- // All rights reserved.
- //
- // This source code is only intended as a supplement to
- // the Objective Grid Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding
- // the Objective Grid product.
- //
-
- #include "stdafx.h"
- #include "gridapp.h"
-
- #include "gridsdoc.h"
- #include "gridsvw8.h"
- #include "dlguser.h"
- #include "mainfrm.h"
- #include "gridfrms.h"
-
- // ScrollTips
- #include "gxscrltp.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- //
- // CGridSample8View can be used as standalone, splitter or worksheet gridview
- // as you have already seen with CGridSampleView
- //
- // CGridSample8View illustrates how to apply pushbuttons for headers
- // and registering this header control (the skeletton for the control
- // is simply copied from the CSimpleButton class in CGridSample5View).
- //
- // CGridSample8View also illustrates how to select cells with the
- //
-
- IMPLEMENT_DYNCREATE(CGridSample8View, CMyGridView)
-
- static TCHAR BASED_CODE szInstruct[] =
- _T("This view shows you some of the new control types in Version 1.2. ");
-
- #define new DEBUG_NEW
-
- const UINT NIDTIMER = 101;
-
- /////////////////////////////////////////////////////////////////////////////
- // CGridSample8CheckBox
-
- // see the bitmap IDS_CHECK_SAMPLE8 how to draw your own
- // checkboxes. You should supply 5 bitmaps. All bitmaps
- // should have the same size (e.g. m_nCheckBoxSize = 16)
-
- // the checkboxes are arranged as follows in the bitmap:
- // 0) unchecked
- // 1) checked
- // 2) unchecked with scope (grey backgorund)
- // 3) checked with scope (grey backgorund)
- // 4) indetermined
-
- CGridSample8CheckBox::CGridSample8CheckBox(CGXGridCore* pGrid)
- : CGXCheckBox(pGrid, TRUE, IDB_CHECK_SAMPLE8, IDB_CHECK_SAMPLE8)
- {
- // size of a checkbox
- m_nCheckBoxSize = 16;
- }
-
- // override GetColorValue to ajust colors in the bitmap
- // with system colors
-
- COLORREF CGridSample8CheckBox::GetColorValue(COLORREF rgb, BOOL bPrint)
- {
- switch (rgb)
- {
- // Replace the white color in the bitmap with
- // the background color of the window
- case RGB(255, 255, 255):
- return bPrint ? RGB(255, 255, 255) : GetSysColor(COLOR_WINDOW);
-
- default:
- return rgb;
- }
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CGridSample8View
-
- BEGIN_MESSAGE_MAP(CGridSample8View, CMyGridView)
- //{{AFX_MSG_MAP(CGridSample8View)
- ON_COMMAND(ID_VIEW_USERACTIONS, OnViewUseractions)
- ON_COMMAND(ID_VIEW_SPLITTERVIEW, OnViewSplitterview)
- ON_WM_TIMER()
- ON_WM_VSCROLL()
- ON_WM_HSCROLL()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CGridSample8View construction/destruction
-
- CGridSample8View::CGridSample8View()
- {
- nValue1 = 50;
- nValue2 = 50;
- nValue2 = 50;
- m_bTimerRunning = FALSE;
-
- m_nProgBarRow = 22;
- m_nProgBarCol = 3;
-
- // ScrollTips
- #if _MFC_VER >= 0x0400
- if (GXGetAppData()->bWin31)
- m_pScrollTip = NULL; // not supported under Win32s
- else
- m_pScrollTip = new CGXScrollTip;
- #endif
- }
-
- CGridSample8View::~CGridSample8View()
- {
- #if _MFC_VER >= 0x0400
- delete m_pScrollTip;
- #endif
- }
-
- BOOL CGridSample8View::ConnectParam()
- {
- // Note: this method is copied from CGridSampleView
- //
-
- BOOL bNew = FALSE;
-
- // Retrive the zero-based worksheet-id if used as worksheet
- if (GetParentTabWnd(this, TRUE))
- m_nViewID = GetParentTabViewID(this);
-
- // check if it is a new pane in a splitter window
- CSplitterWnd* pSplitterWnd = GetParentDynamicSplitter(this, TRUE);
- if (pSplitterWnd != NULL)
- {
- CGXGridView *pView = (CGXGridView *) pSplitterWnd->GetPane(0, 0);
- if (pView != this)
- m_nViewID = pView->GetViewID();
- }
-
- // check if parameter-object exist (in document)
- if (GetDocument()->GetParam(m_nViewID) == NULL)
- {
- // create a parameter-object on the heap
- GetDocument()->SetParam(m_nViewID, new CGXGridParam);
-
- bNew = TRUE; // this view needs initializing
- }
-
- // connect parameter-object with grid
- SetParam((CGXGridParam*) GetDocument()->GetParam(m_nViewID), FALSE);
-
- return bNew;
- }
-
- void CGridSample8View::SetupControls()
- {
- // Register all controls for the view
-
- // owner drawn checkbox
- RegisterControl(GX_IDS_CTRL_CHECKBOX, new CGridSample8CheckBox(this));
-
- // progress bar
- CGXProgressCtrl* pProgressCtrl = new CGXProgressCtrl(this);
- RegisterControl(GX_IDS_CTRL_PROGRESS, pProgressCtrl);
-
- // password control
- CGXPasswordControl* pPwdControl = new CGXPasswordControl(this, GX_IDS_CTRL_PASSWORD);
- pPwdControl->m_chPasswordChar = _T('*'); // use * as password char
- RegisterControl(GX_IDS_CTRL_PASSWORD, pPwdControl);
-
- // user attributes
- CGXProgressCtrl::AddUserAttributes(GetParam()->GetStylesMap());
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CGridSample8View drawing
-
- void CGridSample8View::OnInitialUpdate()
- {
- BOOL bNew = ConnectParam();
-
- CMyGridView::OnInitialUpdate(); // Creates all objects and links them to the grid
-
- // Register all controls for the view
- SetupControls();
-
- if (bNew)
- {
- // Don't create undo-information for the following commands
- GetParam()->EnableUndo(FALSE);
- // (at the end of this procedure, I will reenable it)
-
- SetRowCount(50);
- SetColCount(20);
-
- // Instructions
- SetCoveredCellsRowCol(1, 1, 3, 4);
- SetStyleRange(CGXRange(1,1),
- CGXStyle()
- .SetWrapText(TRUE)
- .SetEnabled(FALSE)
- .SetFont(CGXFont().SetFaceName(_T("Times New Roman")))
- .SetInterior(RGB(255,251,240)) // Off-white
- .SetHorizontalAlignment(DT_CENTER)
- .SetVerticalAlignment(DT_VCENTER)
- .SetControl(GX_IDS_CTRL_STATIC)
- .SetBorders(gxBorderAll, CGXPen().SetWidth(2))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Title"))
- .SetValue(szInstruct));
-
- ROWCOL nRow = 5, nCol = 2;
-
- StandardStyle()
- .SetUserAttribute(GX_IDS_UA_INPUTPROMPT, _T("_"))
- .SetVerticalAlignment(DT_VCENTER)
- ;
-
- // if you want that the mask is shown only for filled
- // controls, you should comment out the following three lines:
- CGXMaskControl* pMaskControl =
- (CGXMaskControl*) GetRegisteredControl(GX_IDS_CTRL_MASKEDIT);
- pMaskControl->m_bDisplayEmpty = TRUE;
-
- // Thick border
- SetStyleRange(CGXRange().SetRows(nRow),
- CGXStyle()
- .SetBorders(gxBorderTop, CGXPen().SetWidth(2))
- );
-
- // New Masked Edit Title
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+1);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetValue("New Masked Edit Control")
- .SetFont(CGXFont().SetBold(TRUE).SetSize(14))
- );
-
- nRow++;
- nRow++;
-
- // Time: ##:## UU , Example: 12:20 AM
- SetValueRange(CGXRange(nRow, nCol), "Time");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+2),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_MASKEDIT)
- .SetUserAttribute(GX_IDS_UA_INPUTMASK, _T("##:## UU"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Press Insert to toggle Insert Mode"))
- );
- SetValueRange(CGXRange(nRow, nCol+1), _T("1220AM"));
- nRow++;
-
- // Date: ##/##/## , Example: 12/23/95
- SetValueRange(CGXRange(nRow, nCol), "Date");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+2),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_MASKEDIT)
- .SetUserAttribute(GX_IDS_UA_INPUTMASK, _T("##/##/##"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Press Insert to toggle Insert Mode"))
- );
- SetValueRange(CGXRange(nRow, nCol+1), _T("122395"));
- nRow++;
-
- // SSN: ###-##-####, Example: 148-92-1531
- SetValueRange(CGXRange(nRow, nCol), "SSN");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+2),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_MASKEDIT)
- .SetUserAttribute(GX_IDS_UA_INPUTMASK, _T("###-##-####"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Press Insert to toggle Insert Mode"))
- );
- SetValueRange(CGXRange(nRow, nCol+1), _T("148921531"));
- nRow++;
-
- // Phone: (###) ###-#### Ext: #### Example: (800) 924-4223 Ext: 0007
- SetValueRange(CGXRange(nRow, nCol), "Phone");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+2),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_MASKEDIT)
- .SetUserAttribute(GX_IDS_UA_INPUTMASK, _T("(###) ###-#### Ext: ####"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Press Insert to toggle Insert Mode"))
- );
- SetValueRange(CGXRange(nRow, nCol+1), _T("80092442230007"));
- nRow++;
-
- // Zip: #####, Example: 27858
- SetValueRange(CGXRange(nRow, nCol), "Zip");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+2),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_MASKEDIT)
- .SetUserAttribute(GX_IDS_UA_INPUTMASK, _T("#####"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Press Insert to toggle Insert Mode"))
- );
- SetValueRange(CGXRange(nRow, nCol+1), _T("27858"));
- nRow++;
-
- // Zip+4: #####-####, Example: 27858-1234
- SetValueRange(CGXRange(nRow, nCol), "Zip+4");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+2),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_MASKEDIT)
- .SetUserAttribute(GX_IDS_UA_INPUTMASK, _T("#####-####"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Press Insert to toggle Insert Mode"))
- );
- SetValueRange(CGXRange(nRow, nCol+1), _T("278581234"));
- nRow++;
-
- // Name: &&&&&&&&&&&&&&&&&&&&&&&, Example: Stingray Software
- SetValueRange(CGXRange(nRow, nCol), "Name");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+2),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_MASKEDIT)
- .SetUserAttribute(GX_IDS_UA_INPUTMASK, _T("&&&&&&&&&&&&&&&&&&&&&&&"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Press Insert to toggle Insert Mode"))
- );
- SetValueRange(CGXRange(nRow, nCol+1), _T("Stingray Software"));
- nRow++;
-
- // Thick border
- SetStyleRange(CGXRange().SetRows(nRow),
- CGXStyle()
- .SetBorders(gxBorderTop, CGXPen().SetWidth(2))
- );
-
- // Password Control Title
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+1);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetValue("Password Control")
- .SetFont(CGXFont().SetBold(TRUE).SetSize(14))
- );
-
- nRow++;
- nRow++;
-
- // Password
- SetValueRange(CGXRange(nRow, nCol), "Password");
- SetStyleRange(CGXRange(nRow, nCol+1),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_PASSWORD)
- .SetInterior(RGB(192,192,192)) // grey
- .SetDraw3dFrame(gxFrameInset)
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("CGXPasswordControl"))
- );
-
- // Thick border
- nRow++;
- SetStyleRange(CGXRange().SetRows(nRow),
- CGXStyle()
- .SetBorders(gxBorderTop, CGXPen().SetWidth(2))
- );
-
- // Ownerdrawn checkbox Title
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+1);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetValue("Ownerdrawn Checkboxes")
- .SetFont(CGXFont().SetBold(TRUE).SetSize(14))
- );
-
- nRow++;
- nRow++;
-
- // Ownerdrawn checkbox
- SetValueRange(CGXRange(nRow, nCol), "Ownerdrawn Checkbox");
- SetStyleRange(CGXRange(nRow, nCol+1),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_CHECKBOX)
- .SetValue(0L)
- .SetChoiceList(_T("Show Progress"))
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Click checkbox to stop or start running the progressbars"))
- .SetVerticalAlignment(DT_VCENTER));
- nRow++;
- // Thick border
-
- SetStyleRange(CGXRange().SetRows(nRow),
- CGXStyle()
- .SetBorders(gxBorderTop, CGXPen().SetWidth(2))
- );
-
- // Progress Bars Title
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+1);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetValue("Progress Bars")
- .SetFont(CGXFont().SetBold(TRUE).SetSize(14))
- );
-
- nRow++;
- nRow++;
-
- // Progress Bars
- SetValueRange(CGXRange(nRow, nCol), "Progress Bars");
- SetStyleRange(CGXRange(nRow, nCol+1, nRow, nCol+3),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_PROGRESS)
- .SetValue(50L)
- .SetUserAttribute(GX_IDS_UA_PROGRESS_MIN, _T("0"))
- .SetUserAttribute(GX_IDS_UA_PROGRESS_MAX, _T("100"))
- .SetUserAttribute(GX_IDS_UA_PROGRESS_CAPTIONMASK, _T("%ld %%")) // sprintf formatting for value
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Click checkbox to stop or start running the progressbars"))
- .SetTextColor(RGB(0, 0, 255)) // blue progress bar
- .SetInterior(RGB(255, 255, 255)) // on white background
- .SetDraw3dFrame(gxFrameRaised)
- );
- nRow++;
- nRow++;
-
- // Thick border
-
- SetStyleRange(CGXRange().SetRows(nRow),
- CGXStyle()
- .SetBorders(gxBorderTop, CGXPen().SetWidth(2))
- );
-
- #if _MFC_VER >= 0x0400
- // Rich Text will not work with UNICODE with MFC 4.2.
- // If you need RichText functionality for your UNICODE
- // builds, you should use MFC 4.1 or contact MS for
- // the MFC 4.2b patch.
- // Rich Edit Title
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+1);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetValue("Rich Text Formatting")
- .SetFont(CGXFont().SetBold(TRUE).SetSize(14))
- );
-
- nRow++;
- nRow++;
-
- // Rich Edit
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+3);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_RICHEDIT)
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("CGXRichEditCtrl"))
- .SetValue(
- // * Change the font and color for individual characters
- // * Copy/Paste from / to Wordpard
- // * Enlarge cell while entering text
- _T("{")
- _T("\\rtf1\\ansi\\deff0\\deftab720")
- _T("{")
- _T("\\fonttbl")
- _T("{\\f0\\fswiss MS Sans Serif;}")
- _T("{\\f1\\froman\\fcharset2 Symbol;}")
- _T("{\\f2\\fswiss\\fprq2 System;}")
- _T("{\\f3\\fswiss\\fprq2 Arial;}")
- _T("{\\f4\\froman Bookman Old Style;}")
- _T("}")
- _T("{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;}")
- _T("\\deflang1033\\pard\\plain\\f3\\fs16\\cf0 * Change the ")
- _T("\\plain\\f4\\fs24\\cf0\\b\\i\\ul font \\plain\\f3\\fs16\\cf0 or ")
- _T("\\plain\\f4\\fs24\\cf1\\b\\ul color\\plain\\f3\\fs16\\cf0 ")
- _T("for individual characters.\\par ")
- _T("* \\plain\\f3\\fs16\\cf0\\b Copy/Paste ")
- _T("\\plain\\f3\\fs16\\cf0 from / to Wordpad ")
- _T("with RTF formattting\\par ")
- _T("* \\plain\\f3\\fs16\\cf0\\b Enlarge cell ")
- _T("\\plain\\f3\\fs16\\cf0 while entering text. \\par")
- _T("* Select some characters in this cell and open Format|Cells to change them!\\par }")
- )
- .SetAutoSize(TRUE)
- .SetWrapText(TRUE)
- .SetAllowEnter(TRUE)
- );
- nRow++;
-
- // This is the sample from the CGXRichEditCtrl class
- // reference.
-
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+3);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetControl(GX_IDS_CTRL_RICHEDIT)
- .SetAutoSize(TRUE)
- .SetWrapText(TRUE)
- .SetAllowEnter(TRUE)
- );
-
- SetValueRange(CGXRange(nRow, nCol),
- _T("{\\rtf1\\ansi")
- // font table
- _T("{\\fonttbl")
- _T("\\f0\\froman Times New Roman; ")
- _T("\\f1\\fdecor Courier New; ")
- _T("\\f2\\fswiss Arial;} ")
- _T("\\deff0 ")
- // color table
- _T("{\\colortbl")
- _T("\\red0\\green0\\blue0; ")
- _T("\\red255\\green0\\blue0; ")
- _T("\\red0\\green128\\blue0; ")
- _T("\\red0\\green0\\blue255;} ")
- // first line
- _T("\\qc\\cf1\\f0\\fs20 10 point, Times New Roman, ")
- _T("red, centered\\plain\\par")
- // second line
- _T("\\ql\\cf3\\f1\\fs28 14 point, Courier New, blue, ")
- _T("left aligned\\plain\\par")
- // third line
- _T("\\qr\\cf0\\f2\\fs36 18 point, Arial, black, ")
- _T("right aligned\\plain\\par")
- // fourth line
- _T("\\qc Default font and color, \\b Bold\\plain , \\ul Underline\\plain , \\i Italic \\plain\\par")
- // closing bracket
- _T("}")
- );
- nRow++;
-
- // Thick border
-
- SetStyleRange(CGXRange().SetRows(nRow),
- CGXStyle()
- .SetBorders(gxBorderTop, CGXPen().SetWidth(2))
- );
-
- #endif
-
- // Other New Features
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+1);
- SetStyleRange(CGXRange(nRow, nCol),
- CGXStyle()
- .SetValue("Other New Features")
- .SetFont(CGXFont().SetBold(TRUE).SetSize(14))
- );
-
- nRow++;
- nRow++;
-
- // List of other features
- #if _MFC_VER >= 0x0400
- // Rich Text will not work with UNICODE with MFC 4.2
- // Please contact MS for the MFC 4.2b patch if you
- // need RichText functionality under UNICODE (or use
- // MFC 4.1)
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+2);
- SetValueRange(CGXRange(nRow, nCol), _T("* OLE Drag and Drop\r\n")
- _T(" Switch to another sheet, select a range of cells\r\n")
- _T(" and click on the edge of the inverted area and drag\r\n")
- _T(" the cells to different views or applications. You might\r\n")
- _T(" also select text in an edit control and drag this text\r\n")
- _T(" to another cell or another application.")
- );
- nRow++;
-
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+2);
- SetValueRange(CGXRange(nRow, nCol), _T("* Tooltips for cells"));
- nRow++;
-
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+2);
- SetValueRange(CGXRange(nRow, nCol), _T("* Scrolltips while dragging the scrollthumb"));
- nRow++;
- #endif
-
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+2);
- SetValueRange(CGXRange(nRow, nCol), _T("* Colors and Scrollbars support changing\r\n desktop appearance on the fly"));
- nRow++;
-
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+2);
- SetValueRange(CGXRange(nRow, nCol), _T("* Smooth tracking of row/column size.\r\n Try to resize a row or column in this sample view!"));
- nRow++;
-
- SetCoveredCellsRowCol(nRow, nCol, nRow, nCol+2);
- SetValueRange(CGXRange(nRow, nCol), _T("* Check out the release notes for even more new features."));
- nRow++;
-
-
- // Thick border
- SetStyleRange(CGXRange().SetRows(nRow),
- CGXStyle()
- .SetBorders(gxBorderTop, CGXPen().SetWidth(2))
- );
-
- ResizeColWidthsToFit(CGXRange().SetRows(5, nRow));
- ResizeRowHeightsToFit(CGXRange().SetRows(5, nRow));
-
-
- // Enable creation of undo-information for user interactions
- GetParam()->EnableUndo(TRUE);
-
- // enable selecting cells only (not complete rows or columns)
- GetParam()->EnableSelection(GX_SELCELL|GX_SELSHIFT|GX_SELKEYBOARD);
- GetParam()->EnableThumbTrack(FALSE);
- GetParam()->EnableMoveCols(FALSE);
- GetParam()->EnableMoveRows(FALSE);
-
- // smooth tracking
- GetParam()->EnableTrackRowHeight(
- GX_TRACK_INDIVIDUAL
- | GX_TRACK_SMOOTHCELLS
- | GX_TRACK_NOPRESSEDHEADER
- | GX_TRACK_NOMARKTRACKLINE);
- }
-
- // Position the current cell
-
- SetCurrentCell(4, 1, FALSE /* avoid immediate updating */);
-
- // Limit Copy/Paste and Drag&Drop to Text Only. This makes
- // sure that when the user cuts or drags cells, the cell
- // style will not be cleared out (with all its formattings
- // and control information).
-
- #if _MFC_VER >= 0x0400 && !defined(_AFX_NO_OLE_SUPPORT)
- EnableOleDataSource(GX_DNDTEXT|GX_DNDMULTI);
- #endif
- m_nClipboardFlags = GX_DNDTEXT|GX_DNDMULTI;
-
- // Enable Update-Hint-Mechanism
-
- EnableHints();
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CGridSample8View diagnostics
-
- #ifdef _DEBUG
- void CGridSample8View::AssertValid() const
- {
- CMyGridView::AssertValid();
- }
-
- void CGridSample8View::Dump(CDumpContext& dc) const
- {
- CMyGridView::Dump(dc);
- }
-
- CGridSampleDoc* CGridSample8View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGridSampleDoc)));
- return (CGridSampleDoc*) m_pDocument;
- }
-
- #endif //_DEBUG
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CGridSample8View message handlers
-
- // Menu handler for View->Splitter View
-
- void CGridSample8View::OnViewSplitterview()
- {
- CDocument* pDoc = GetDocument();
-
- CMyMultiDocTemplate* pTemplate
- = (CMyMultiDocTemplate*) ((CGridSampleApp*) AfxGetApp())->m_pSplitterTemplate;
-
- pTemplate->SetViewClass(GetRuntimeClass());
-
- CMDIChildWnd* pNewFrame
- = (CMDIChildWnd*) pTemplate->CreateNewFrame(GetDocument(), NULL);
-
- if (pNewFrame == NULL)
- return; // not created
-
- ASSERT(pNewFrame->IsKindOf(RUNTIME_CLASS(CSplitterMDIChildWnd)));
-
- CSplitterWnd& splitter = (CSplitterWnd&)
- ((CSplitterMDIChildWnd *) pNewFrame)->m_wndSplitter;
-
- CGridSample8View* pView = (CGridSample8View*)
- splitter.GetPane(0, 0);
-
- // Set view id to active tab view id
- pView->m_nViewID = m_nViewID;
-
- pTemplate->InitialUpdateFrame(pNewFrame, pDoc);
-
- pNewFrame->GetActiveView();
- ASSERT(pView);
- }
-
- // Menu handler for View->User Actions...
-
- void CGridSample8View::OnViewUseractions()
- {
- // Note: this method is copied from CGridSampleView
- //
- // Shows a dialog with some attributes of the parameter-object
- // where you can experiment with some attributes
- // such as allowing the user to track columns, select cells
- // or use the grid as a listbox.
-
- // Transfer Current Cell's Data to grid
- if (!TransferCurrentCell())
- return;
-
- CUserActionsDialog dlg(GetParam());
-
- if (dlg.DoModal() == IDOK)
- {
- // Redraw the grid
- Redraw();
- }
- }
-
- void CGridSample8View::UpdateProgressDisplay()
- {
- BOOL bUndo = GetParam()->IsEnableUndo();
- GetParam()->EnableUndo(FALSE);
-
- CGXProgressCtrl::SetProgressValue(this, m_nProgBarRow, m_nProgBarCol, nValue1);
- CGXProgressCtrl::SetProgressValue(this, m_nProgBarRow, m_nProgBarCol+1, nValue2);
- CGXProgressCtrl::SetProgressValue(this, m_nProgBarRow, m_nProgBarCol+2, nValue3);
-
- GetParam()->EnableUndo(bUndo);
- }
-
- void CGridSample8View::OnTimer(UINT nIDEvent)
- {
- if (nIDEvent == NIDTIMER)
- {
- nValue1 = (nValue1+1)%100;
- nValue2 = (nValue2+2)%100;
- nValue3 = (nValue3+4)%100;
- UpdateProgressDisplay();
- }
-
- CMyGridView::OnTimer(nIDEvent);
- }
-
- void CGridSample8View::OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView )
- {
- if (!bActivate)
- {
- KillTimer(NIDTIMER);
- m_bTimerRunning = FALSE;
- }
-
- CMyGridView::OnActivateView(bActivate, pActivateView, pDeactiveView);
- }
-
- BOOL CGridSample8View::CanActivateGrid(BOOL bActivate)
- {
- if (!bActivate)
- {
- KillTimer(NIDTIMER);
- m_bTimerRunning = FALSE;
- }
-
- return CMyGridView::CanActivateGrid(bActivate);
- }
-
- void CGridSample8View::OnClickedButtonRowCol(ROWCOL nRow, ROWCOL nCol)
- {
- nRow, nCol; // Unused
-
- m_bTimerRunning = !m_bTimerRunning;
-
- if (!m_bTimerRunning)
- KillTimer(NIDTIMER);
- else
- SetTimer(NIDTIMER, 100, NULL);
- }
-
- void CGridSample8View::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- #if _MFC_VER >= 0x0400
- if (!GXGetAppData()->bWin31)
- {
- // ScrollTips
- ROWCOL nRow = nPos, nCol = 0;
- TCHAR szText[256];
- wsprintf(szText, _T("Row: %s"), GetValueRowCol(nRow, nCol));
- m_pScrollTip->HandleScrollMessage(this, nSBCode, SB_VERT, szText, pScrollBar);
- }
- #endif
-
- CMyGridView::OnVScroll(nSBCode, nPos, pScrollBar);
- }
-
- void CGridSample8View::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- #if _MFC_VER >= 0x0400
- if (!GXGetAppData()->bWin31)
- {
- // ScrollTips
- ROWCOL nRow = 0, nCol = nPos;
- TCHAR szText[256];
- wsprintf(szText, _T("Column: %s"), GetValueRowCol(nRow, nCol));
- m_pScrollTip->HandleScrollMessage(this, nSBCode, SB_HORZ, szText, pScrollBar);
- }
- #endif
-
- CMyGridView::OnHScroll(nSBCode, nPos, pScrollBar);
- }
-
-