|
/* =============================================================================
* Filename: StateChartView.h
*
* Copyright Inc
* All rights reserved.
* -----------------------------------------------------------------------------
* General description of this file:
*
* The state chart implementation.
* -----------------------------------------------------------------------------
* Revision History
* -----------------------------------------------------------------------------
* Version Date Author Revision Detail
* 1.0.0 2004/12/21 Initial
* ===========================================================================*/
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_STATECHARTVIEW_H__B7BC0C40_1F57_4039_A88A_7403C087923E__INCLUDED_)
#define AFX_STATECHARTVIEW_H__B7BC0C40_1F57_4039_A88A_7403C087923E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//#include "listboxst.h"
#include "stdafx.h"
#include "StateTreeCtrl.h"
#include "Sme_Debug.h"
#include <math.h>
//#include "ParamStore.h"
//#include "TreeFile.h"
//#include "DIB.H"
class CStateChartView : public CScrollView
{
public: // create from serialization only
CStateChartView();
DECLARE_DYNCREATE(CStateChartView)
// Attributes
public:
enum
{
ICON_SIZE = 20, //Length for 16-pixel icon
DRAG_DELAY = 200 // avoid move mouse by mistake
};
typedef struct {
int nStartX;
int nStartY;
int nEndX;
int nEndY;
int nRadius; // radius of line if it is self-transition event
int nSrcState;
int nDestState;
} EVENT_LINE_INFO_T; //State transition line information.
typedef struct {
int nLeft;
int nTop;
int nWidth;
int nHeight;
int nColWidth; // The column width of the state.
int nRowHeight; // The row height of the state.
} STATE_CHART_INFO_T;
// (nWidth,nHeight) the actual size of the state as small as possible.
// (nColWidth, nRowHeight) is to define the state chart position.
// (nLeft, nTop) is to draw state transition arrows
CPtrArray m_StateChartInfoList; // point to the state chart data blocks with type of STATE_CHART_INFO_T
CPtrArray m_EventLineInfoList; // State transition line information. point to the state transition data blocks with type of EVENT_LINE_INFO_T
CStringArray m_ActionNameList;
CStringArray m_EventNameList;
CStringArray m_StateNameList;
int m_EventLineNo;
CStateTreeCtrl* m_pStateTree;
SME_STATE_T m_nSelStateSeqNo; // Selected state to be operated on
BOOL m_bMouseMove;
UINT m_dwDragStart;
HTREEITEM m_hItemDrag;
int m_bSizeChange;
int m_nSavedMaxLevel;
// m_hTopStateItem is the tree item of the top state item to be draw; We have to record down it, because while state chart is open,
// the selected state tree item may be changed.
HTREEITEM m_hTopStateItem;
// CListBoxST m_ListBox;
// CImageList m_ImageList;
// CFont m_Font;
// Operations
public:
void CStateChartView::CalculateStateChartSize(CDC* pDC,
HTREEITEM hSelItem,
HTREEITEM hStart);
void CStateChartView::CalculateColWidthRowHeight(HTREEITEM hItem,
HTREEITEM hStart);
void CStateChartView::DrawStateChart(CDC* pDC,
HTREEITEM hItem,
HTREEITEM hStart,
int nOriginPosX,
int nOriginPosY);
void CStateChartView::DrawArrow(CDC* pDC,
HTREEITEM hSrcItem,
HTREEITEM hSelItem) ;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CStateChartView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
// Implementation
public:
BOOL InitChartInfoList(HTREEITEM hSelector);
void ZeroCharInfoList();
BOOL DestroyChartInfoList();
void InitEventInfoList(HTREEITEM hSrcItem, HTREEITEM hSelItem);
void ZeroEventInfoList();
BOOL DestroyEventInfoList();
void InitEventNameList(HTREEITEM hSrcItem, HTREEITEM hSelItem);
void InitStateNameList(HTREEITEM hItem);
BOOL PointIsOnLine(CPoint point, int nError);
void WriteToBmpFile(CString filename,LPBYTE pBuffer,CSize& size);
int GetStateLevel(HTREEITEM hItem, HTREEITEM hStart);
BOOL GetDestStateItem(HTREEITEM hSelItem, LPCTSTR sDestStateName, HTREEITEM& hDestStateItem);
int GetChartInfoSeqNum(HTREEITEM hItem);
virtual ~CStateChartView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
void SetStatusText(UINT nID);
// Generated message map functions
protected:
//{{AFX_MSG(CStateChartView)
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnAddState();
afx_msg void OnDelApp();
afx_msg void OnAddHandle();
afx_msg void OnDefltChange();
afx_msg void OnDelState();
afx_msg void OnGotoEntry();
afx_msg void OnGotoExit();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnDestroy();
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSaveAsBmp();
afx_msg void OnSaveAsTxt();
//}}AFX_MSG
// afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
afx_msg void OnGotoHdler(UINT nID);
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STATECHARTVIEW_H__B7BC0C40_1F57_4039_A88A_7403C087923E__INCLUDED_)
|
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.