void CProjectDoc::SetProject() // Change application settings based on current project. { GetProjectView()->UpdateData(); CString dir = GetProjectView()->m_directory; if (dir.IsEmpty()) return; if (FALSE == SetCurrentDirectory(dir)) AfxMessageBox(_T("Unable to change to directory,\nmaybe missing drive specification.")); }
ButcherProjectFile *ButcherView::GetProjectFile() { if (!GetProjectView()) return NULL; if ((!filealternate_) || (filealternateid_<0) || (filealternateid_>BUTCHERCONST_VIEW_MAXALTERNATE-1) || (GetProjectView()->GetFileAlternate(filealternateid_)) == NULL) return GetProjectView()->GetFile(); else return GetProjectView()->GetFileAlternate(filealternateid_); }
CString CProjectDoc::GetFile(int i) { CString sFile; // Consider file -1 a special case for getting the opdefs file if (i == -1) sFile = GetProjectView()->m_opdefs; else { CListBox* pLB = (CListBox*)GetProjectView()->GetDlgItem(IDP_FILELIST); pLB->GetText(i, sFile); } return sFile; }
CString CProjectDoc::GetLib(int i) { CString sLib; CListBox* pLB = (CListBox*)GetProjectView()->GetDlgItem(IDP_LIBLIST); pLB->GetText(i, sLib); return sLib; }
void ButcherView::SetFileAlternate(bool s, bool refresh) { filealternate_=s; if (filealternate_ && GetProjectView() && GetProjectView()->GetFileAlternate(filealternateid_)==NULL) { // find first alternate file filealternateid_=-1; for (int i=0; i<BUTCHERCONST_VIEW_MAXALTERNATE; i++) { if (GetProjectView()->GetFileAlternate(i)) { filealternateid_=i; break; } } } if (refresh) Refresh(); }
void CProjectDoc::Serialize(CArchive& ar) { CProjectView* pview = GetProjectView(); int i, l; if (ar.IsStoring()) { // Output #ifdef _UNICODE _TCHAR uniflag = 0xfeff; // written as fffe, which is right for PC unicode ar.Write(&uniflag, 2); #endif pview->UpdateData(TRUE); ar.WriteString(_T("amzirel=4")); // so we can check for valid ppj files ar.WriteString(CRLF); ar.WriteString(_T("xplfile=")); ar.WriteString(pview->m_xplfile); ar.WriteString(CRLF); ar.WriteString(_T("directory=")); ar.WriteString(pview->m_directory); ar.WriteString(CRLF); ar.WriteString(_T("opdefs=")); ar.WriteString(pview->m_opdefs); ar.WriteString(CRLF); CListBox* pLB; CString s; pLB = (CListBox*)(pview->GetDlgItem(IDP_FILELIST)); l = pLB->GetCount(); for (i=0; i<l; i++) { pLB->GetText(i, s); ar.WriteString(_T("file=")); ar.WriteString(s); ar.WriteString(CRLF); } pLB = (CListBox*)(pview->GetDlgItem(IDP_LIBLIST)); l = pLB->GetCount(); for (i=0; i<l; i++) { pLB->GetText(i, s); ar.WriteString(_T("library=")); ar.WriteString(s); ar.WriteString(CRLF); } SaveOpenFiles(ar); } else { // Input ReadArchive(ar); } }
void ButcherView::OnDrawDocument(ButcherDocumentDrawEvent& event) { if (GetProjectView()!=NULL) { // draw image if (!GetShowPreview()) // if preview, imagens will be drawn per area { ButcherProjectFile *fl=GetProjectFile(); if (fl->GetImage()) { wxRect rc(0, 0, (int)(fl->GetImage()->GetWidth()*event.GetDocument()->GetView()->GetPixelSize()), (int)(fl->GetImage()->GetHeight()*event.GetDocument()->GetView()->GetPixelSize()) ); fl->GetImage()->Draw(*event.GetDC(), rc); } } else { GetProjectView()->DrawPreview(this, event.GetDC()); GetProjectView()->GetMask()->DrawPreview(this, event.GetDC(), ButcherView_AreaSelect(GetAreaViewCurrent()), GetProjectView()); } // Draw grid if (GetShowGrid()) event.GetDocument()->DrawGrid(event.GetDC()); // draw mask if (GetShowBordersCurrent()) GetProjectView()->GetMask()->Draw(this, event.GetDC(), ButcherView_AreaSelect(GetAreaViewCurrent()), GetProjectView(), ButcherProjectMask::DM_DEFAULT, selection_); } DoAfterDraw(event); event.Skip(); }
void CProjectDoc::ReadArchive(CArchive &ar) { CProjectView* pview = GetProjectView(); CString s; unsigned short first; BOOL is_unicode; int ibufsize = 512; pview->UpdateData(FALSE); // Read first two bytes to check for Unicode, // now we can't undo with archive, so this presents // a problem when reading the first line and there // wasn't a unicode flag. The answer is in ProcessLine // which accepts 'zirel' as well as 'amzirel' for the // first line attribute. ar.Read(&first, 2); if (first == 0xfeff) is_unicode = TRUE; else is_unicode = FALSE; #ifdef _UNICODE // if unicode, just read it straight if (is_unicode) { while (ar.ReadString(s)) ProcessLine(s, pview); } // if not unicode, read into an ascii buffer // and call mbstowcs(). else { char* buf = new char[ibufsize+1]; _TCHAR* sbuf = new _TCHAR[ibufsize+1]; while (ReadLineA(buf, ar, ibufsize)) { mbstowcs(sbuf, buf, ibufsize); s = sbuf; ProcessLine(s, pview); } delete[] buf; delete[] sbuf; } #else // if not unicode, read it straight if (!is_unicode) { while (ar.ReadString(s)) ProcessLine(s, pview); } // if unicode, get ReadLineW to read and // translate. else { wchar_t* buf = new wchar_t[ibufsize+1]; _TCHAR* sbuf = new _TCHAR[ibufsize+1]; while (ReadLineW(buf, ar, ibufsize)) { wcstombs(sbuf, buf, ibufsize); s = buf; ProcessLine(s, pview); } delete[] buf; delete[] sbuf; } #endif if (! m_amzirel == CString(_T("4"))) AfxMessageBox(_T("Not a valid Amzi! project for this environment,\n please recreate.")); return; }
CString CProjectDoc::GetOpDefsFile() { return GetProjectView()->m_opdefs; }
CString CProjectDoc::GetXPLFile() { return GetProjectView()->m_xplfile; }
int CProjectDoc::GetLibCount() { CListBox* pLB = (CListBox*)GetProjectView()->GetDlgItem(IDP_LIBLIST); return pLB->GetCount(); }
int CProjectDoc::GetFileCount() { CListBox* pLB = (CListBox*)GetProjectView()->GetDlgItem(IDP_FILELIST); return pLB->GetCount(); }
CProjectFrame* CProjectDoc::GetProjectFrame() { return (CProjectFrame*)(GetProjectView()->GetParent()); }