home *** CD-ROM | disk | FTP | other *** search
- // testvvw.cpp : implementation of the CTestvbxView class
- //
-
- #include "stdafx.h"
- #include "testvbx.h"
-
- #include "testvdoc.h"
- #include "testvvw.h"
- #include "mainfrm.h"
- #include "outline.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CTestvbxView
-
- IMPLEMENT_DYNCREATE(CTestvbxView, CFormView)
-
- BEGIN_MESSAGE_MAP(CTestvbxView, CFormView)
- //{{AFX_MSG_MAP(CTestvbxView)
- ON_VBXEVENT(VBN_ADDNODE, IDC_OL_VBX1, OnAddnodeOlVbx1)
- ON_VBXEVENT(VBN_CHANGENODE, IDC_OL_VBX1, OnChangenodeOlVbx1)
- ON_VBXEVENT(VBN_INSERTNODE, IDC_OL_VBX1, OnInsertnodeOlVbx1)
- ON_VBXEVENT(VBN_CHANGESELECTION, IDC_OL_VBX1, OnChangeselectionOlVbx1)
- ON_VBXEVENT(VBN_DELETENODE, IDC_OL_VBX1, OnDeletenodeOlVbx1)
- ON_VBXEVENT(VBN_INDENTNODE, IDC_OL_VBX1, OnIndentnodeOlVbx1)
- ON_VBXEVENT(VBN_KILLFOCUS, IDC_OL_VBX1, OnKillfocusOlVbx1)
- ON_VBXEVENT(VBN_LEFTBUTTONCLICK, IDC_OL_VBX1, OnLeftbuttonclickOlVbx1)
- ON_VBXEVENT(VBN_MIDDLEBUTTONCLICK, IDC_OL_VBX1, OnMiddlebuttonclickOlVbx1)
- ON_VBXEVENT(VBN_RIGHTBUTTONCLICK, IDC_OL_VBX1, OnRightbuttonclickOlVbx1)
- ON_VBXEVENT(VBN_SETFOCUS, IDC_OL_VBX1, OnSetfocusOlVbx1)
- ON_VBXEVENT(VBN_VERTICALSCROLL, IDC_OL_VBX1, OnVerticalscrollOlVbx1)
- ON_BN_CLICKED(OKBUTTON, OnOKBUTTON)
- ON_BN_CLICKED(IDC_ADDNODE, OnAddnode)
- ON_BN_CLICKED(IDC_ALLOWAPPEND, OnAllowappend)
- ON_BN_CLICKED(IDC_ALLOWDELETE, OnAllowdelete)
- ON_BN_CLICKED(IDC_ALLOWEDIT, OnAllowedit)
- ON_BN_CLICKED(IDC_ALLOWINSERT, OnAllowinsert)
- ON_BN_CLICKED(IDC_ALLOWREDRAW, OnAllowredraw)
- ON_EN_KILLFOCUS(IDC_CURRENTNODE, OnKillfocusCurrentnode)
- ON_BN_CLICKED(IDC_DELNODE, OnDelnode)
- ON_BN_CLICKED(IDC_FLUSH, OnFlush)
- ON_EN_KILLFOCUS(IDC_INDENTLEVEL, OnKillfocusIndentlevel)
- ON_EN_KILLFOCUS(IDC_MAXINDENT, OnKillfocusMaxindent)
- ON_BN_CLICKED(IDC_NUMBERING, OnNumbering)
- ON_WM_GETDLGCODE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CTestvbxView construction/destruction
-
- CTestvbxView::CTestvbxView()
- : CFormView(CTestvbxView::IDD)
- {
- //{{AFX_DATA_INIT(CTestvbxView)
- pOutline1 = NULL;
- nNumNodes = 0;
- nMaxIndent = 7;
- nIndentLevel = 0;
- nCurrentNode = 0;
- bAllowAppend = TRUE;
- bAllowDelete = TRUE;
- bAllowEdit = TRUE;
- bAllowInsert = TRUE;
- bAllowRedraw = TRUE;
- bNumbering = TRUE;
- //}}AFX_DATA_INIT
- }
-
- CTestvbxView::~CTestvbxView()
- {
- }
-
- void CTestvbxView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CTestvbxView)
- DDX_VBControl(pDX, IDC_OL_VBX1, pOutline1);
- DDX_Text(pDX, IDC_NUMNODES, nNumNodes);
- DDX_Text(pDX, IDC_MAXINDENT, nMaxIndent);
- DDX_Text(pDX, IDC_INDENTLEVEL, nIndentLevel);
- DDX_Text(pDX, IDC_CURRENTNODE, nCurrentNode);
- DDX_Check(pDX, IDC_ALLOWAPPEND, bAllowAppend);
- DDX_Check(pDX, IDC_ALLOWDELETE, bAllowDelete);
- DDX_Check(pDX, IDC_ALLOWEDIT, bAllowEdit);
- DDX_Check(pDX, IDC_ALLOWINSERT, bAllowInsert);
- DDX_Check(pDX, IDC_ALLOWREDRAW, bAllowRedraw);
- DDX_Check(pDX, IDC_NUMBERING, bNumbering);
- //}}AFX_DATA_MAP
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CTestvbxView diagnostics
-
- #ifdef _DEBUG
- void CTestvbxView::AssertValid() const
- {
- CFormView::AssertValid();
- }
-
- void CTestvbxView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
-
- CTestvbxDoc* CTestvbxView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestvbxDoc)));
- return (CTestvbxDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CTestvbxView message handlers
-
- BOOL CTestvbxView::UpdateData(BOOL bSaveAndValidate)
- {
- if (bSaveAndValidate == TRUE)
- {
- // Update the member variable from the screen
- CFormView::UpdateData(bSaveAndValidate);
-
- // Update the outline values from the member variables
- pOutline1->SetNumProperty("AllowAppend", bAllowAppend);
- pOutline1->SetNumProperty("AllowDelete", bAllowDelete);
- pOutline1->SetNumProperty("AllowEdit", bAllowEdit);
- pOutline1->SetNumProperty("AllowInsert", bAllowInsert);
- pOutline1->SetNumProperty("Redraw", bAllowRedraw);
-
- pOutline1->SetNumProperty("MaximumIndent", nMaxIndent);
- pOutline1->SetNumProperty("Numbering", bNumbering);
-
- // Only set the current node if it has changed. This will stop alot
- // of redrawing and flicker
- if (nCurrentNode != (UINT) pOutline1->GetNumProperty("Position"))
- pOutline1->SetNumProperty("Position", nCurrentNode);
- }
- else
- {
- // Update the member variables from the outline control
- bAllowAppend = (BOOL) pOutline1->GetNumProperty("AllowAppend");
- bAllowDelete = (BOOL) pOutline1->GetNumProperty("AllowDelete");
- bAllowEdit = (BOOL) pOutline1->GetNumProperty("AllowEdit");
- bAllowInsert = (BOOL) pOutline1->GetNumProperty("AllowInsert");
- bAllowRedraw = (BOOL) pOutline1->GetNumProperty("Redraw");
-
- nNumNodes = (UINT) pOutline1->GetNumProperty("Count");
- // nIndentLevel = (UINT) pOutline1->GetNumProperty("Indent");
- nMaxIndent = (UINT) pOutline1->GetNumProperty("MaximumIndent");
- bNumbering = (UINT) pOutline1->GetNumProperty("Numbering");
- nCurrentNode = (UINT) pOutline1->GetNumProperty("Position");
-
- // Update the screen from the member variables
- CFormView::UpdateData(bSaveAndValidate);
- }
- return TRUE;
- }
-
- void CTestvbxView::OnAddnodeOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- // Update the screen
- UpdateData(FALSE);
-
- pFrame->setStatusText("VBX1 - AddNode");
- }
-
- void CTestvbxView::OnChangenodeOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- pFrame->setStatusText("VBX1 - ChangeNode");
- }
-
- void CTestvbxView::OnInsertnodeOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- // Update the screen
- UpdateData(FALSE);
-
- pFrame->setStatusText("VBX1 - InsertNode");
- }
-
- void CTestvbxView::OnChangeselectionOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- // Update the screen
- UpdateData(FALSE);
-
- pFrame->setStatusText("VBX1 - Change node selection");
- }
-
- void CTestvbxView::OnDeletenodeOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- // Update the screen
- UpdateData(FALSE);
-
- pFrame->setStatusText("VBX1 - Delete node");
- }
-
- void CTestvbxView::OnIndentnodeOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- // Update the screen
- UpdateData(FALSE);
-
- pFrame->setStatusText("VBX1 - Indent node");
- }
-
- void CTestvbxView::OnKillfocusOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- pFrame->setStatusText("VBX1 - Kill focus");
- }
-
- void CTestvbxView::OnLeftbuttonclickOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- pFrame->setStatusText("VBX1 - Left button click");
- }
-
- void CTestvbxView::OnMiddlebuttonclickOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- pFrame->setStatusText("VBX1 - Middle button click");
- }
-
- void CTestvbxView::OnRightbuttonclickOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- pFrame->setStatusText("VBX1 - Right button click");
- }
-
- void CTestvbxView::OnSetfocusOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- pFrame->setStatusText("VBX1 - Set focus");
- }
-
- void CTestvbxView::OnVerticalscrollOlVbx1(UINT, int, CWnd*, LPVOID)
- {
- pFrame->setStatusText("VBX1 - Vertical scroll");
- }
-
- void CTestvbxView::OnOKBUTTON()
- {
- PostMessage(WM_COMMAND, ID_FILE_CLOSE);
- }
-
-
- void CTestvbxView::OnAddnode()
- {
- // Update the data in the member variables first
- UpdateData(TRUE);
-
- // The outline AddItem function is different than the standard AddItem.
- // The second argument takes the indent level, not the index to place
- // the item at.
- pOutline1->AddItem("This is a test node", nIndentLevel);
- }
-
- void CTestvbxView::OnAllowappend()
- {
- UpdateData(TRUE);
- }
-
- void CTestvbxView::OnAllowdelete()
- {
- UpdateData(TRUE);
- }
-
- void CTestvbxView::OnAllowedit()
- {
- UpdateData(TRUE);
- }
-
- void CTestvbxView::OnAllowinsert()
- {
- UpdateData(TRUE);
- }
-
- void CTestvbxView::OnAllowredraw()
- {
- UpdateData(TRUE);
- }
-
- void CTestvbxView::OnKillfocusCurrentnode()
- {
- UpdateData(TRUE);
- }
-
- void CTestvbxView::OnDelnode()
- {
- // Update the data in the member variables first
- UpdateData(TRUE);
-
- pOutline1->RemoveItem(nCurrentNode);
- }
-
- void CTestvbxView::OnFlush()
- {
- pOutline1->SendMessage(OL_FLUSH, 0, 0L);
- UpdateData(TRUE);
-
- }
-
- void CTestvbxView::OnKillfocusIndentlevel()
- {
- UpdateData(TRUE);
-
- pOutline1->SetNumProperty("Indent", nIndentLevel);
- }
-
- void CTestvbxView::OnKillfocusMaxindent()
- {
- UpdateData(TRUE);
- }
-
- void CTestvbxView::OnNumbering()
- {
- UpdateData(TRUE);
- }
-
- UINT CTestvbxView::OnGetDlgCode()
- {
- return DLGC_WANTALLKEYS | DLGC_WANTARROWS | DLGC_WANTCHARS | DLGC_HASSETSEL | DLGC_WANTTAB;
- }
-