home *** CD-ROM | disk | FTP | other *** search
Wrap
/******************************************************************/ /* */ /* TurboCAD for Windows */ /* Copyright (c) 1993 - 2001 */ /* International Microcomputer Software, Inc. */ /* (IMSI) */ /* All rights reserved. */ /* */ /******************************************************************/ // ToolList.cpp : implementation file // #include "stdafx.h" #include "InsTool.h" #include "ToolList.h" #include "TDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // ToolList CSymbolsList::CSymbolsList() { } CSymbolsList::~CSymbolsList() { } void CSymbolsList::OnFinalRelease() { CListBox::OnFinalRelease(); } BEGIN_MESSAGE_MAP(CSymbolsList, CListBox) //{{AFX_MSG_MAP(CToolList) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_MOUSEMOVE() ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ToolList message handlers void CSymbolsList::RefreshFileList(CString path) { struct _finddata_t c_file; long hFile; hFile = 0; int i = _chdir(path); // the directory that contains symbols. ResetContent(); m_cstrCurSelected = ""; /* Find first .c file in current directory */ if (i == 0) { // We allows here only tcw files as files that contains symbols // add any file extension (that TurboCad supports) here if( (hFile = _findfirst( "*.tcw", &c_file )) != -1L )//# Non-localizable string# { /* Find the rest of the .c files */ AddString(c_file.name); //add first file to the list while( _findnext( hFile, &c_file ) == 0 ) { AddString(c_file.name); } _findclose( hFile ); } } } void CSymbolsList::OnLButtonDown(UINT nFlags, CPoint point) { CListBox::OnLButtonDown(nFlags, point); BOOL bRet; m_LB_DOWNpoint.x = point.x; m_LB_DOWNpoint.y = point.y; CString cstrSelected = ""; CListBox *pSymbolsList = (CListBox *) (GetParent()->GetDlgItem(IDC_SYMBOLSLIST)); UINT index = ItemFromPoint(point, bRet); if (bRet == FALSE) { m_bDrag = TRUE; GetText(index, cstrSelected); } if (m_cstrCurSelected != cstrSelected && cstrSelected != "") // check if the current selection is changed { BeginWaitCursor(); CPreviewWnd *pViewWnd = (CPreviewWnd *) (((CTDialog*)GetParent())->GetDlgItem(IDC_PREVIEW)); pViewWnd->ClearAll(); int index = pSymbolsList->GetCurSel(); bRet = FALSE; bRet = pViewWnd->CreatePreview(); if(bRet == FALSE) return; bRet = FALSE; bRet = pViewWnd->DoPreview(); if (bRet == FALSE) { CString szMess; CString szCap; szMess.LoadString(IDS_STRING105); szCap.LoadString(IDS_STRERROR); MessageBox(LPCTSTR(szMess),LPCTSTR(szCap), MB_OK); pSymbolsList->DeleteString(index); } m_cstrCurSelected = cstrSelected; pViewWnd->Invalidate(); EndWaitCursor(); } } void CSymbolsList::OnLButtonUp(UINT nFlags, CPoint point) { CListBox::OnLButtonUp(nFlags, point); m_bDrag = FALSE; CPoint Pt = point; ClientToScreen(&Pt); CWnd *pClickWNd = WindowFromPoint(Pt); if(pClickWNd && pClickWNd != this) { pClickWNd->ScreenToClient(&Pt); pClickWNd->PostMessage(WM_LBUTTONUP, nFlags, MAKELONG(Pt.x, Pt.y)); SetCursor(m_OldCursor); ShowCursor(TRUE); return; } else { SetCursor(m_OldCursor); ShowCursor(TRUE); } } void CSymbolsList::OnMouseMove(UINT nFlags, CPoint point) { if(nFlags & MK_LBUTTON) { int dx = m_LB_DOWNpoint.x - point.x; int dy = m_LB_DOWNpoint.y - point.y; CPoint Pt = point; if((abs(dx) > 1 || abs(dy) > 1) && m_bDrag) { // if dragging if (((CTDialog*)GetParent())->m_dwEventConnection == 0) { ((CTDialog*)GetParent())->ConnectEvents(); } m_OldCursor = GetCursor(); m_DragCursor = LoadCursor(AfxGetInstanceHandle( ), MAKEINTRESOURCE(IDC_CURSOR1)); SetCursor(m_DragCursor); ShowCursor(TRUE); m_bDrag = FALSE; m_LB_DOWNpoint.x = -1; m_LB_DOWNpoint.y = -1; ((CTDialog*)GetParent())->m_FirstClick = TRUE; return; } ClientToScreen(&Pt); CWnd *pClickWNd = WindowFromPoint(Pt); if(pClickWNd && pClickWNd != this) { pClickWNd->ScreenToClient(&Pt); pClickWNd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(Pt.x, Pt.y)); } } } void CSymbolsList::OnSelchange() { CString cstrSelected; BOOL bRet = FALSE; CListBox *pSymbolsList = (CListBox *) (GetParent()->GetDlgItem(IDC_SYMBOLSLIST)); int index = pSymbolsList->GetCurSel(); HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT)); pSymbolsList->GetText(index, cstrSelected); if (m_cstrCurSelected != cstrSelected && cstrSelected != "") { CPreviewWnd *pViewWnd = (CPreviewWnd *) (((CTDialog*)GetParent())->GetDlgItem(IDC_PREVIEW)); pViewWnd->ClearAll(); bRet = pViewWnd->CreatePreview(); if(bRet == FALSE) return; bRet = FALSE; bRet = pViewWnd->DoPreview(); if (bRet == FALSE) { CString szMess; CString szCap; szMess.LoadString(IDS_STRING105); szCap.LoadString(IDS_STRERROR); //MessageBox("The drawing have Brush styles or Line styles different from default. This sample can't work with such files", "ERROR!", MB_OK);//# Localizable string# MessageBox(LPCTSTR(szMess),LPCTSTR(szCap), MB_OK); pSymbolsList->DeleteString(index); } m_cstrCurSelected = cstrSelected; } ::SetCursor(hOC); }