|
/**********************************************************************
UML StateWizard provides its software under the LGPL License and
zlib/libpng License.
Email us at info@intelliwizard.com for any information, suggestions and
feature requestions.
Home Page: http://www.intelliwizard.com
*************************************************************************/
// EventChange.cpp : implementation file
/******************************
Choose default child state when a default state moves to another place.
*******************************/
#include "stdafx.h"
#include "StateTree.h"
#include "EventChange.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEventChange dialog
CEventChange::CEventChange(CWnd* pParent /*=NULL*/)
: CDialog(CEventChange::IDD, pParent)
{
//{{AFX_DATA_INIT(CEventChange)
m_selectedStateName = _T("");
//}}AFX_DATA_INIT
}
void CEventChange::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEventChange)
DDX_CBString(pDX, IDC_NON_DEFAULT_STATE_BOX, m_selectedStateName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEventChange, CDialog)
//{{AFX_MSG_MAP(CEventChange)
ON_WM_DESTROY()
ON_CBN_SELCHANGE(IDC_NON_DEFAULT_STATE_BOX, OnSelchangeNonDefaultStateBox)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEventChange message handlers
BOOL CEventChange::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if (m_bIsAfterDel == TRUE)
{
(((CButton*)GetDlgItem(IDOK))->EnableWindow(FALSE));
(((CButton*)GetDlgItem(IDCANCEL))->ShowWindow(FALSE));
}
HTREEITEM hSelector;
HTREEITEM hChild;
HTREEITEM hParent;
hSelector = m_pStateTree->tree.GetSelectedItem();
hParent = m_pStateTree->tree.GetParentItem(hSelector);
hChild = m_pStateTree->tree.GetChildItem(hParent);
while (true)
{
if (NULL == hChild)
break;
DWORD lMask = m_pStateTree->tree.GetItemData(hChild);
if ((lMask & STATE_TREE_STATE_MASK) &&
!(lMask & STATE_TREE_DEFAULT_STATE))
((CComboBox*)GetDlgItem(IDC_NON_DEFAULT_STATE_BOX))->InsertString(-1, m_pStateTree->tree.GetItemText(hChild));//.Mid(13));
hChild = m_pStateTree->tree.GetNextSiblingItem(hChild);
}
((CComboBox*)GetDlgItem(IDC_NON_DEFAULT_STATE_BOX))->EnableWindow(TRUE);
//. SME_TRACE("Create event change dialog!\n");
return TRUE;
// return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEventChange::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
//. SME_TRACE("Destroy event change dialoge!\n");
//. SME_ALLOC_MEM_SIZE();
}
///////////////////////////////////////////////////////////////////////////////////////////
// DESCRIPTION: Response to ok button click
// INPUT: None
// OUTPUT: None
// Note:
///////////////////////////////////////////////////////////////////////////////////////////
void CEventChange::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if (m_selectedStateName.GetLength() == 0)
{
CDialog::OnOK();
return;
}
HTREEITEM hSelector;
HTREEITEM hParent;
HTREEITEM hApp;
CString strDefault = " (default)";
CString sAppName;
CString sParentName;
DWORD lMask;
hSelector = m_pStateTree->tree.GetSelectedItem();
hParent = m_pStateTree->tree.GetParentItem(hSelector);
hApp = m_pStateTree->tree.GetSelectedApp(hSelector);
// Get parent item name
sParentName = m_pStateTree->tree.GetItemText(hParent);
lMask = m_pStateTree->tree.GetItemData(hParent);
if( lMask & STATE_TREE_STATE_MASK )
{
if(lMask & STATE_TREE_DEFAULT_STATE)
{
sParentName.Replace("(default)", NULL);
sParentName.TrimLeft();
sParentName.TrimRight();
}
}
// Get application name containing selected state
sAppName = m_pStateTree->tree.GetItemText(hApp);
// Get application source file path
CStringArray AppPathList;
AppPathList.RemoveAll();
m_pStateTree->GetAppSrcHdrPath(AppPathList, sAppName, hApp);
CString strSrcFullPath = AppPathList.GetAt(1);
//!!! Update Interface
//!!! From CString to BSTR
BSTR bstrSrcFullPath = _com_util::ConvertStringToBSTR(strSrcFullPath.GetBuffer());
BSTR bstrAppName = _com_util::ConvertStringToBSTR(sAppName.GetBuffer());
BSTR bstrParentName = _com_util::ConvertStringToBSTR(sParentName.GetBuffer());
BSTR bstrSelectedStateName = _com_util::ConvertStringToBSTR(m_selectedStateName.GetBuffer());
m_pStateTree->Fire_ChangeDefaultState(bstrSrcFullPath, bstrAppName, bstrParentName, bstrSelectedStateName);
strSrcFullPath.ReleaseBuffer();
sAppName.ReleaseBuffer();
sParentName.ReleaseBuffer();
m_selectedStateName.ReleaseBuffer();
if(m_pStateTree->data.isChangeDefaultStateOk)
m_pStateTree->tree.FindDefaultTreeItem(m_selectedStateName);
CDialog::OnOK();
}
void CEventChange::OnSelchangeNonDefaultStateBox()
{
// TODO: Add your control notification handler code here
if (m_bIsAfterDel == TRUE)
(((CButton*)GetDlgItem(IDOK))->EnableWindow(TRUE));
}
BOOL CEventChange::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==0x100 && pMsg->wParam==27)//Esc
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
void CEventChange::OnCancel()
{
return;
}
BOOL CEventChange::OnHelpInfo(HELPINFO* pHelpInfo)
{
// TODO: Add your message handler code here and/or call default
//DSUtils(m_pStateTree->tree.m_pApp).GotoWinHelp(0x59);
CString sCmdName = GetHelpFileName();
sCmdName+="::/set_as_default_state.htm";
::HtmlHelp(NULL, sCmdName, HH_DISPLAY_TOPIC, 0);
return TRUE;
// return CDialog::OnHelpInfo(pHelpInfo);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.