void CStyleDlgFonts::OnButtonFont() { CFontDialog dlg (m_stcFont.GetLogfont (), CF_EFFECTS | CF_BOTH, NULL, this); dlg.m_cf.rgbColors = m_stcFont.GetColor (); if (dlg.DoModal () == IDOK) { m_stcFont.SetPreviewFont (&dlg.m_cf); memcpy (&m_pStyle->m_lfTitle[m_RenderType], dlg.m_cf.lpLogFont, sizeof (LOGFONT)); if (dlg.m_cf.rgbColors) m_pStyle->m_crTitle[m_RenderType] = dlg.m_cf.rgbColors; CMDIChildWnd* pChild = ((CMDIFrameWnd*) AfxGetMainWnd ())->MDIGetActive (); if (pChild != NULL) { CCdCoverCreator2Doc* pDoc = (CCdCoverCreator2Doc*) pChild->GetActiveDocument (); if (pDoc != NULL) { // pDoc->m_pTracks->SetRTFTitle ("", m_RenderType); pDoc->ApplyStyleToRTFTitles (m_pStyle, m_RenderType); pDoc->UpdateAllViews (NULL); pDoc->CheckPoint (); } } } }
void CFileView::OnProperties() { CMDIFrameWnd *pMain = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *)pMain->GetActiveFrame(); CDocument* pDoc = NULL; pDoc = pChild->GetActiveDocument(); //9-8添加判断,如果不判断,都关闭后再点击项目管理项,程序会崩溃 if( pDoc!= NULL) { CString filePath=pDoc->GetPathName(); filePath.Trim(); filePath.MakeLower(); CString fileEx=filePath.Right(2); if(fileEx==_T(".t")) { int iLength = lstrlen(filePath) ; int iIndex = filePath.ReverseFind(L'\\') ; CString fileName = filePath.Right(iLength - iIndex - 1); ((CMainFrame*)AfxGetApp()->m_pMainWnd)->SetProjProperty(fileName,filePath); } else { ((CMainFrame*)AfxGetApp()->m_pMainWnd)->SetProjProperty(_T(""),_T("")); } } }
void CMDIFrameWnd::OnUpdateFrameTitle(BOOL bAddToTitle) { if ((GetStyle() & FWS_ADDTOTITLE) == 0) return; // leave it alone! #ifndef _AFX_NO_OLE_SUPPORT // allow hook to set the title (used for OLE support) if (m_pNotifyHook != NULL && m_pNotifyHook->OnUpdateFrameTitle()) return; #endif CMDIChildWnd* pActiveChild = NULL; CDocument* pDocument = GetActiveDocument(); if (bAddToTitle && (pActiveChild = MDIGetActive()) != NULL && (pActiveChild->GetStyle() & WS_MAXIMIZE) == 0 && (pDocument != NULL || (pDocument = pActiveChild->GetActiveDocument()) != NULL)) UpdateFrameTitleForDocument(pDocument->GetTitle()); else { LPCTSTR lpstrTitle = NULL; CString strTitle; if (pActiveChild != NULL && (pActiveChild->GetStyle() & WS_MAXIMIZE) == 0) { strTitle = pActiveChild->GetTitle(); if (!strTitle.IsEmpty()) lpstrTitle = strTitle; } UpdateFrameTitleForDocument(lpstrTitle); } }
void CMainFrame::OnWindowNew3d() { CMDIChildWnd* pActiveChild = MDIGetActive(); CDocument* pDocument; if ( pActiveChild == NULL || ( pDocument = pActiveChild->GetActiveDocument() ) == NULL ) { TRACE("Warning: No active document for WindowNew command\n"); AfxMessageBox(AFX_IDP_COMMAND_FAILURE); return; // Command failed } // Otherwise, we have a new frame! CDocTemplate* pTemplate = ((CDemoApp*)AfxGetApp())->m_pTemplate3dView; ASSERT_VALID( pTemplate ); CFrameWnd* pFrame = pTemplate->CreateNewFrame( pDocument, pActiveChild ); if (pFrame == NULL) { TRACE( "Warning: failed to create new frame\n" ); AfxMessageBox( AFX_IDP_COMMAND_FAILURE ); return; // Command failed } pTemplate->InitialUpdateFrame( pFrame, pDocument ); ((CDemoDoc*)pDocument)->turnOnComputePoints(); }
CManageTagsDlg::CManageTagsDlg(CWnd* pParent /*=NULL*/) : CDialog(CManageTagsDlg::IDD, pParent) { CMDIChildWnd * pChild = ((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive(); CLibraryDoc* pDoc = DYNAMIC_DOWNCAST(CLibraryDoc, pChild->GetActiveDocument ()); m_pParamCDB = pDoc->m_pParamCDB; }
void CSideBar::OnPopupSidebarAttrUpdate() { // NB! This needs some work! CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } if (m_popup_attribute == -1) { AfxMessageBox(_T("Cannot replace values for the reference number column")); return; } MetaGraph *graph = m_treeDoc->m_meta_graph; PointMap *pointmap = NULL; ShapeMap *shapemap = NULL; // Need to check what this does GetItemMap(graph,pointmap,shapemap); if (m_treeDoc->ReplaceColumnContents(pointmap, shapemap, m_popup_attribute)) { graph->setDisplayedAttribute(m_popup_attribute); m_treeDoc->SetUpdateFlag(CGraphDoc::NEW_DATA); m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_DATA ); } SwitchFocusBack(); }
//@doc SECEditView //@mfunc Finds the active Document so we can decide whether or // not to draw the selection //@rdesc CDocument* Pointer to CDocument if found, NULL if not. CDocument* SECEditView::GetActiveDoc() { CMDIChildWnd* pChild = ((CMDIFrameWnd*)AfxGetMainWnd())->MDIGetActive(); if (!pChild) return ((CFrameWnd*)AfxGetMainWnd())->GetActiveDocument(); else return pChild->GetActiveDocument(); }
// The code fragment below sets the last active page (i.e. the // active page when the propertysheet was closed) to be the first // visible page when the propertysheet is shown. The last active // page was saved in m_LastActivePage, (a member variable of // CDocument-derived class) when OK was selected from the // propertysheet. CMyPropertySheet is a CPropertySheet-derived class. BOOL CMyPropertySheet::OnInitDialog() { BOOL bResult = CPropertySheet::OnInitDialog(); CMDIFrameWnd* pframe = (CMDIFrameWnd*) AfxGetMainWnd(); CMDIChildWnd* pchild = pframe->MDIGetActive(); CPSheetDoc* doc = (CPSheetDoc*) pchild->GetActiveDocument(); SetActivePage(doc->m_LastActivePage); return bResult; }
void CModuleWnd::OnAddForm() { CMDIFrameWnd* pParentFrame = (CMDIFrameWnd*)AfxGetMainWnd(); CMDIChildWnd* pMDIActive = pParentFrame->MDIGetActive(); if (pMDIActive != NULL) { CFormDoc* pActiveDoc = (CFormDoc *)pMDIActive->GetActiveDocument(); OnLibCopy(); pActiveDoc->m_pDocument->DoPasteSubDocument(NULL); } }
BOOL CMyPropertySheet::OnCommand(WPARAM wParam, LPARAM lParam) { if (LOWORD(wParam) == IDOK) { CMDIFrameWnd* pframe = (CMDIFrameWnd*) AfxGetMainWnd(); CMDIChildWnd* pchild = pframe->MDIGetActive(); CPSheetDoc* doc = (CPSheetDoc*) pchild->GetActiveDocument(); doc->m_LastActivePage = GetPageIndex(GetActivePage()); // or GetActiveIndex() } return CPropertySheet::OnCommand(wParam, lParam); }
LRESULT CPIMDIFrameWndEx::OnGetActiveDocument(WPARAM wParam, LPARAM lParam) { CDocument** pActiveDoc = (CDocument**)wParam; // Get the active MDI child window CMDIChildWnd* pActiveChild = MDIGetActive(); if (pActiveChild) { *pActiveDoc = pActiveChild->GetActiveDocument(); } return 0; }
void CMainFrmDlgBar::OnSelchangeComboStyle () { CComboBox* pCombo = (CComboBox*) GetDlgItem (IDC_COMBO_MFR_STYLE); CString s; pCombo->GetLBText (pCombo->GetCurSel (), s); CMDIChildWnd* pChild = ((CMDIFrameWnd*) AfxGetMainWnd ())->MDIGetActive (); if (pChild != NULL) { CCdCoverCreator2Doc* pDoc = (CCdCoverCreator2Doc*) pChild->GetActiveDocument (); if (pDoc != NULL) pDoc->SetStyle (s); } }
LRESULT CStyleDlgFonts::OnButtonColor (WPARAM wParam, LPARAM lParam) { bool bResetRTF = false; switch (lParam) { case IDC_BUTTON_COLOR: m_pStyle->m_crTitle[m_RenderType] = m_btnColor.GetColour (); bResetRTF = true; break; case IDC_BUTTON_TRACKTITLE_COLOR: m_pStyle->m_crTrackTitle = m_btnColTrkTitle.GetColour (); break; case IDC_BUTTON_TRACKREMARKS_COLOR: m_pStyle->m_crTrackRemarks = m_btnColTrkRemarks.GetColour (); break; case IDC_BUTTON_TRACKNUM_COLOR: m_pStyle->m_crTrackNum = m_btnColTrkNum.GetColour (); break; case IDC_BUTTON_TRACKLENGTH_COLOR: m_pStyle->m_crTrackLength = m_btnColTrkLength.GetColour (); break; case IDC_BUTTON_TRACKGROUPINGTITLE_COLOR: m_pStyle->m_crTrackGroupingTitle = m_btnColTrkGrpTitle.GetColour (); break; case IDC_BUTTON_TRACKGROUPINGREMARKS_COLOR: m_pStyle->m_crTrackGroupingRemarks = m_btnColTrkGrpRemarks.GetColour (); break; } CMDIChildWnd* pChild = ((CMDIFrameWnd*) AfxGetMainWnd ())->MDIGetActive (); if (pChild != NULL) { CCdCoverCreator2Doc* pDoc = (CCdCoverCreator2Doc*) pChild->GetActiveDocument (); if (pDoc != NULL) { if (bResetRTF) { // pDoc->m_pTracks->SetRTFTitle ("", m_RenderType); pDoc->ApplyStyleToRTFTitles (m_pStyle, m_RenderType); } pDoc->UpdateAllViews (NULL); pDoc->CheckPoint (); } } return S_OK; }
void CModuleWnd::OnAddSubmodule() { CMDIFrameWnd* pParentFrame = (CMDIFrameWnd*)AfxGetMainWnd(); CMDIChildWnd* pMDIActive = pParentFrame->MDIGetActive(); if (pMDIActive != NULL) { CFormDoc* pActiveDoc = (CFormDoc *)pMDIActive->GetActiveDocument(); if (pActiveDoc == NULL) return; CLayoutView* pView = pActiveDoc->GetLayoutView(); if (pView == NULL) return; OnLibCopy(); pView->DoPasteSubmodule(NULL, NULL); } }
void CSideBar::OnPopupSidebarAttrDelete() { CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; if (graph->viewingProcessed()) { AttributeTable& table = graph->getAttributeTable(); if (table.isColumnLocked(m_popup_attribute)) { AfxMessageBox(_T("Cannot remove locked column")); } else if (IDYES == AfxMessageBox(CString("Are you sure you want to delete the ") + table.getColumnName(m_popup_attribute).c_str() + CString(" column?"), MB_YESNO)) { bool displayed = graph->getDisplayedAttribute() == m_popup_attribute; // note this -1 simply means shift back one if (displayed) { // note, cannot delete the ref column, so minimum is display -1 graph->setDisplayedAttribute(m_popup_attribute - 1); } int view_class = graph->getViewClass() & (MetaGraph::VIEWVGA | MetaGraph::VIEWAXIAL | MetaGraph::VIEWDATA); switch (view_class) { case MetaGraph::VIEWVGA: case MetaGraph::VIEWBACKVGA: graph->PointMaps::getDisplayedPointMap().removeAttribute(m_popup_attribute); break; case MetaGraph::VIEWAXIAL: case MetaGraph::VIEWBACKAXIAL: graph->getShapeGraphs().getDisplayedMap().removeAttribute(m_popup_attribute); break; case MetaGraph::VIEWDATA: case MetaGraph::VIEWBACKDATA: graph->getDataMaps().getDisplayedMap().removeAttribute(m_popup_attribute); break; } m_treeDoc->SetUpdateFlag(CGraphDoc::NEW_DATA); // some views need to react to this for their column titles: m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_COLUMN ); } } SwitchFocusBack(); }
DviDoc * DviDoc::GetActiveDocument () { ASSERT_VALID (AfxGetApp()); MainFrame * pMain = reinterpret_cast<MainFrame*>((AfxGetApp())->m_pMainWnd); ASSERT_VALID (pMain); MIKTEX_ASSERT (pMain->IsKindOf(RUNTIME_CLASS(MainFrame))); CMDIChildWnd * pChild = pMain->MDIGetActive(); ASSERT_VALID (pChild); DviDoc * pDviDoc = reinterpret_cast<DviDoc*>(pChild->GetActiveDocument()); if (pDviDoc == 0) { pDviDoc = pLastDoc; } MIKTEX_ASSERT (pDviDoc != 0); MIKTEX_ASSERT (pDviDoc->IsKindOf(RUNTIME_CLASS(DviDoc))); return (pDviDoc); }
void CSideBar::OnPopupSidebarAttrRename() { CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; bool displayed = (graph->getDisplayedAttribute() == m_popup_attribute); AttributeTable *tab = NULL; int view_class = graph->getViewClass() & (MetaGraph::VIEWVGA | MetaGraph::VIEWAXIAL | MetaGraph::VIEWDATA); switch (view_class) { case MetaGraph::VIEWVGA: case MetaGraph::VIEWBACKVGA: tab = &(graph->PointMaps::getDisplayedPointMap().getAttributeTable()); break; case MetaGraph::VIEWAXIAL: case MetaGraph::VIEWBACKAXIAL: tab = &(graph->getShapeGraphs().getDisplayedMap().getAttributeTable()); break; case MetaGraph::VIEWDATA: case MetaGraph::VIEWBACKDATA: tab = &(graph->getDataMaps().getDisplayedMap().getAttributeTable()); break; } if (tab != NULL) { int newcol = m_treeDoc->RenameColumn(tab, m_popup_attribute); if (newcol != -1) { m_treeDoc->SetUpdateFlag(CGraphDoc::NEW_DATA); graph->setDisplayedAttribute(newcol); m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_COLUMN ); } } SwitchFocusBack(); }
void CSideBar::OnPopupSidebarAttrProperties() { CTreeCtrl& tree = GetTreeCtrl(); // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; if (graph->viewingProcessed()) { AttributeTable& table = graph->getAttributeTable(); CColumnPropertiesDlg dlg(&table, m_popup_attribute); dlg.DoModal(); } SwitchFocusBack(); }
// --------------------------------------------------------------------------- void CGeorgesImpl::LineDown () { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); CMDIChildWnd *pChild = pWnd->MDIGetActive (); if (pChild == NULL) return; // Get active document CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument (); if (doc) { // Get the left view CLeftView* pView = doc->getLeftView (); // Check type CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); if (subDoc) { // Get the node const CFormDfn *parentDfn; uint indexDfn; const CFormDfn *nodeDfn; const CType *nodeType; CFormElm *node; UFormDfn::TEntryType type; bool array; bool parentVDfnArray; CForm *form=doc->getFormPtr (); CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); // Is a type entry ? if ( (type == UFormDfn::EntryType) && !array ) { // Select next if ((subDoc->getIdInParent ()+1) < subDoc->getParent ()->getChildrenCount ()) doc->changeSubSelection (subDoc->getParent ()->getChild (subDoc->getIdInParent ()+1), pView); } } } }
void CMainFrame::OnWindowShowestimationview() { CMDIChildWnd* pActiveChild = MDIGetActive(); CDocument* pDocument; if (pActiveChild == NULL || (pDocument = pActiveChild->GetActiveDocument()) == NULL) { TRACE("Warning: No active document for WindowNew command\n"); AfxMessageBox(AFX_IDP_COMMAND_FAILURE); return; // Command failed } // Otherwise, we have a new frame! //CDocTemplate* pTemplate = ((CTLiteApp*) AfxGetApp())->m_pTemplateGLView; //ASSERT_VALID(pTemplate); //CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, pActiveChild); //if (pFrame == NULL) //{ // TRACE("Warning: failed to create new frame\n"); // AfxMessageBox(AFX_IDP_COMMAND_FAILURE); // return; // Command failed // // make it visisable //} //pTemplate->InitialUpdateFrame(pFrame, pDocument); }
void CMDIFrameWnd::OnWindowNew() { CMDIChildWnd* pActiveChild = MDIGetActive(); CDocument* pDocument; if (pActiveChild == NULL || (pDocument = pActiveChild->GetActiveDocument()) == NULL) { TRACE(traceAppMsg, 0, "Warning: No active document for WindowNew command.\n"); AfxMessageBox(AFX_IDP_COMMAND_FAILURE); return; // command failed } // otherwise we have a new frame ! CDocTemplate* pTemplate = pDocument->GetDocTemplate(); ASSERT_VALID(pTemplate); CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, pActiveChild); if (pFrame == NULL) { TRACE(traceAppMsg, 0, "Warning: failed to create new frame.\n"); return; // command failed } pTemplate->InitialUpdateFrame(pFrame, pDocument); }
void CLeftPanelDlgBar::OnPaint() { CPaintDC dc (this); // device context for painting CDC dcMem; dcMem.CreateCompatibleDC (&dc); CBrush brush (::GetSysColor (COLOR_3DFACE)); CMDIChildWnd* pChild = ((CMDIFrameWnd*) AfxGetMainWnd ())->MDIGetActive (); CRect r; GetClientRect (&r); if (pChild == NULL) { dc.FillRect (&r, &brush); goto __end; } CCdCoverCreator2Doc* pDoc = (CCdCoverCreator2Doc*) pChild->GetActiveDocument (); if (pDoc == NULL) { // look whether the last doc is still valid POSITION pos = AfxGetApp ()->GetFirstDocTemplatePosition (); CDocTemplate* pDocTmpl = AfxGetApp ()->GetNextDocTemplate (pos); bool bIsValid = false; for (pos = pDocTmpl->GetFirstDocPosition (); pos; ) if (pDocTmpl->GetNextDoc (pos) == m_pLastDoc) { bIsValid = true; break; } if (bIsValid) pDoc = m_pLastDoc; else m_pLastDoc = NULL; } else m_pLastDoc = pDoc; if (pDoc == NULL) { dc.FillRect (&r, &brush); goto __end; } CRect rect; GetClientRect (rect); rect.DeflateRect (5, 5, 5, 5); if (pDoc->m_pStyle != NULL) { CCdCoverCreator2View* pView = (CCdCoverCreator2View*) pChild->GetActiveView (); if (pView == NULL) goto __end; int nHeight = (rect.Width () / 5) * 4; CRenderDC rdc (&dc, nHeight, pView->GetDocument ()->m_pStyle); m_y[Cover] = 5; m_y[Back] = m_y[Cover] + rdc.GetHeight (Cover) + 10; m_y[Inlay] = m_y[Back] + rdc.GetHeight (Back) + 10; m_y[Label] = m_y[Inlay] + rdc.GetHeight (Inlay) + 10; m_y[Booklet] = m_y[Label] + rdc.GetHeight (Label) + 10; if (m_bRedraw) { CLabelRenderer renderer (pDoc->m_pTracks, pDoc->m_pDataCDInfo, reinterpret_cast<CBackgroundInfo**> (&(pDoc->m_pBackground)), pDoc->m_listFloatingObjects, *(pDoc->m_pStyle)); for (int i = 0; i < NUM_RENDER_TYPES - 1; i++) { if ((RenderType) i == Booklet) continue; CRect rectBmp (0, 0, rdc.GetWidth ((RenderType) i) + 5, /*nHeight*/(m_y[i + 1] - m_y[i]) + 5); m_Bitmap[i].DeleteObject (); m_Bitmap[i].CreateCompatibleBitmap (&dc, rectBmp.right, rectBmp.bottom); // render dcMem.SelectObject (&m_Bitmap[i]); dcMem.FillRect (rectBmp, &brush); renderer.Render (CRenderDC (&dcMem, nHeight, pDoc->m_pStyle), (RenderType) i, true); } m_bRedraw = false; } // draw the bitmaps int x[] = { (rect.Width () - rdc.GetWidth (Cover)) / 2 + 5, (rect.Width () - rdc.GetWidth (Back)) / 2 + 5, (rect.Width () - rdc.GetWidth (Inlay)) / 2 + 5, (rect.Width () - rdc.GetWidth (Label)) / 2 + 5, (rect.Width () - rdc.GetWidth (Cover)) / 2 + 5 }; dc.SetViewportOrg (x[Booklet], m_y[Booklet]); DrawBooklet (&dc, rdc.GetWidth (Cover), rdc.GetWidth (Cover) / 2, pDoc, pView->GetRenderType ()); dc.SetViewportOrg (0, 0); CBrush* pOldBrush = dc.GetCurrentBrush (); for (int i = 0; i < NUM_RENDER_TYPES; i++) { CRect rectArea (rect.left, m_y[i], rect.right, m_y[i] + ((RenderType) i == Booklet ? rdc.GetWidth (Cover) / 2 : rdc.GetHeight ((RenderType) i))); if ((RenderType) i != Booklet) { dcMem.SelectObject (m_Bitmap[i]); if (pDoc->m_pStyle->m_bHasRenderType[i]) dc.SelectStockObject (WHITE_BRUSH); else { dc.SetTextColor (RGB (0xff, 0xff, 0xff)); dc.SetBkColor (RGB (0x7f, 0x7f, 0x7f)); dc.SelectObject (dc.GetHalftoneBrush ()); } //dc.BitBlt (x[i], m_y[i], rdc.GetWidth ((RenderType) i) + 5, /*nHeight*/(m_y[i + 1] - m_y[i]) + 5, &dcMem, 0, 0, MERGECOPY); dc.BitBlt (x[i], m_y[i], rectArea.Width (), rectArea.Height () + 4, &dcMem, 0, 0, MERGECOPY); } // marker Mark (&dc, rectArea, pView->GetRenderType () != (RenderType) i); } dc.SelectObject (pOldBrush); } __end: #ifdef PEROUTKA_FEDORISIN CBitmap* pOldBmp = (CBitmap*) dcMem.SelectObject (m_bmpLogo); dc.FillSolidRect (0, r.bottom - 32, 148, 32, RGB (0xff, 0xff, 0xff)); dc.BitBlt ((148 - 80) / 2, r.bottom - 32, 80, 32, &dcMem, 0, 0, SRCCOPY); // dcMem.SelectObject (pOldBmp); #endif dcMem.DeleteDC (); brush.DeleteObject (); }
void CLeftPanelDlgBar::OnLButtonDown(UINT nFlags, CPoint point) { CMDIChildWnd* pChild = ((CMDIFrameWnd*) AfxGetMainWnd ())->MDIGetActive (); if (pChild == NULL) return; CCdCoverCreator2View* pView = NULL; CCdCoverCreator2Doc* pDoc = (CCdCoverCreator2Doc*) pChild->GetActiveDocument (); if (pDoc == NULL) { if (IsLastDocValid ()) { // if the last doc is valid, get its view and activate it for (POSITION pos = m_pLastDoc->GetFirstViewPosition (); pos != NULL; ) { CView* pV = m_pLastDoc->GetNextView (pos); if (pV != NULL) if (pV->IsKindOf (RUNTIME_CLASS (CCdCoverCreator2View))) { pView = (CCdCoverCreator2View*) pV; break; } } if (pView != NULL) ((CMDIChildWnd*) pView->GetParent ())->MDIActivate (); } } else { CView* pV = pChild->GetActiveView (); if (pV != NULL) if (pV->IsKindOf (RUNTIME_CLASS (CCdCoverCreator2View))) pView = (CCdCoverCreator2View*) pV; m_pLastDoc = pDoc; } if (pView == NULL) return; CRect rect; GetClientRect (rect); rect.DeflateRect (5, 5, 5, 5); CWindowDC dc (this); CRenderDC rdc (&dc, rect.Width (), pView->GetDocument ()->m_pStyle); bool bShow = false; if (CRect (rect.left, m_y[Cover], rect.right, m_y[Cover] + rdc.GetHeight (Cover)).PtInRect (point)) pView->OnShowcover (), bShow = true; else if (CRect (rect.left, m_y[Back], rect.right, m_y[Back] + rdc.GetHeight (Back)).PtInRect (point)) pView->OnShowback (), bShow = true; else if (CRect (rect.left, m_y[Inlay], rect.right, m_y[Inlay] + rdc.GetHeight (Inlay)).PtInRect (point)) pView->OnShowinlay (), bShow = true; else if (CRect (rect.left, m_y[Label], rect.right, m_y[Label] + rdc.GetHeight (Label)).PtInRect (point)) pView->OnShowlabel (), bShow = true; else if (CRect (rect.left, m_y[Booklet], rect.right, m_y[Booklet] + rdc.GetWidth (Cover) / 2).PtInRect (point)) pView->OnShowbooklet (), bShow = true; if (bShow) InvalidateRect (NULL, false); else CDialogBar::OnLButtonDown(nFlags, point); }
BOOL CExtMdiWindowsListDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { if( nCode == CN_COMMAND ) { bool bNeedToUpdateButtons = false; int nCount = m_ListWindows.GetCount(); HWND hWnd = (HWND)m_ListWindows.GetItemData( m_ListWindows.GetCurSel() ); WINDOWPLACEMENT wp; if(hWnd != (HWND)LB_ERR) { switch(nID) { case IDC_EXT_TILEVERT: if( nCount != LB_ERR && nCount > 0 ) { for(int nItem = nCount-1; nItem >= 0; nItem-- ) { HWND hWnd=(HWND)m_ListWindows.GetItemData(nItem); if( m_ListWindows.GetSel(nItem) > 0 ) ::ShowWindow(hWnd, SW_RESTORE); else ::ShowWindow(hWnd, SW_MINIMIZE); } // for(int nItem = nCount-1; nItem >= 0; nItem-- ) ::SendMessage(m_hWndMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0); } // if( nCount != LB_ERR && nCount > 0 ) bNeedToUpdateButtons = true; break; case IDC_EXT_TILEHORZ: if( nCount != LB_ERR && nCount > 0 ) { for(int nItem = nCount-1; nItem >= 0; nItem-- ) { HWND hWnd=(HWND)m_ListWindows.GetItemData(nItem); if( m_ListWindows.GetSel(nItem) > 0 ) ::ShowWindow(hWnd, SW_RESTORE); else ::ShowWindow(hWnd, SW_MINIMIZE); } // for(int nItem = nCount-1; nItem >= 0; nItem-- ) ::SendMessage(m_hWndMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0); } // if( nCount != LB_ERR && nCount > 0 ) bNeedToUpdateButtons = true; break; case IDC_EXT_SAVE: if( nCount != LB_ERR && nCount > 0 ) { for( int nItem = 0; nItem < nCount; nItem++ ) { if( m_ListWindows.GetSel(nItem) > 0 ) { HWND hWnd = (HWND)m_ListWindows.GetItemData(nItem); if( hWnd != NULL ) { CMDIChildWnd* pMDIChildWnd = (CMDIChildWnd*)CWnd::FromHandle(hWnd); if (!pMDIChildWnd) continue; CDocument *pDocument = pMDIChildWnd->GetActiveDocument(); if(pDocument != NULL) pDocument->SaveModified(); } // if( hWnd != NULL ) } // if( m_ListWindows.GetSel(nItem) > 0 ) } // for( int nItem = 0; nItem < nCount; nItem++ ) } // if( nCount != LB_ERR && nCount > 0 ) _FillMDIWindowList(); _SelectMDIActive(); bNeedToUpdateButtons = true; break; case IDC_EXT_MINIMIZE: if( nCount != LB_ERR && nCount > 0 ) { for(int nItem = nCount-1; nItem >= 0; nItem-- ) { HWND hWnd=(HWND)m_ListWindows.GetItemData(nItem); if( m_ListWindows.GetSel(nItem) > 0 ) ::ShowWindow(hWnd, SW_MINIMIZE); } // for(int nItem = nCount-1; nItem >= 0; nItem-- ) ::SendMessage(m_hWndMDIClient, WM_MDICASCADE, 0, 0); } // if( nCount != LB_ERR && nCount > 0 ) bNeedToUpdateButtons = true; break; case IDC_EXT_ACTIVATE: ::GetWindowPlacement(hWnd, &wp); if( wp.showCmd == SW_SHOWMINIMIZED ) ::ShowWindow( hWnd, SW_RESTORE ); ::SendMessage( m_hWndMDIClient, WM_MDIACTIVATE, (WPARAM)hWnd, 0 ); CExtResizableDialog::OnOK(); break; case IDC_EXT_CLOSEWINDOWS: if( nCount != LB_ERR && nCount > 0 ) { for( int nItem = 0; nItem < nCount; nItem++ ) { if( m_ListWindows.GetSel(nItem) > 0 ) { HWND hWnd = (HWND)m_ListWindows.GetItemData(nItem); if( hWnd != NULL ) ::SendMessage(hWnd, WM_CLOSE, 0,0); } // if( m_ListWindows.GetSel(nItem) > 0 ) } // for( int nItem = 0; nItem < nCount; nItem++ ) } // if( nCount != LB_ERR && nCount > 0 ) _FillMDIWindowList(); _SelectMDIActive(); bNeedToUpdateButtons = true; break; case IDC_EXT_CASCADE: if( nCount != LB_ERR && nCount > 0 ) { for(int nItem = nCount-1; nItem >= 0; nItem-- ) { HWND hWnd=(HWND)m_ListWindows.GetItemData(nItem); if( m_ListWindows.GetSel(nItem) > 0 ) ::ShowWindow(hWnd, SW_RESTORE); else ::ShowWindow(hWnd, SW_MINIMIZE); } // for(int nItem = nCount-1; nItem >= 0; nItem-- ) ::SendMessage(m_hWndMDIClient, WM_MDICASCADE, 0, 0); } // if( nCount != LB_ERR && nCount > 0 ) bNeedToUpdateButtons = true; break; } if( bNeedToUpdateButtons ) OnUpdateButtons(); } // if(hWnd != (HWND)LB_ERR) } // if( nCode == CN_COMMAND ) return CExtResizableDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
void CSideBar::OnSelchangingSidebarTree(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; switch (pNMTreeView->action) { case TVC_UNKNOWN: case TVC_BYMOUSE: case TVC_BYKEYBOARD: break; default: // shouldn't have received this, ignore completely: *pResult = TRUE; return; } CTreeCtrl& tree = GetTreeCtrl(); HTREEITEM hItem = pNMTreeView->itemNew.hItem; // since this may happen at any time, should really check for anything going badly wrong, // e.g., no current graph document: CMDIFrameWnd *pFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CDocument *pDoc = pChild->GetActiveDocument(); if (pDoc != m_treeDoc) { return; } MetaGraph *graph = m_treeDoc->m_meta_graph; // look it up in the table to see what to do: size_t n = m_treegraphmap.searchindex(hItem); if (n != paftl::npos) { CTreeEntry entry = m_treegraphmap.value(n); bool remenu = false; if (entry.m_cat != -1) { if (entry.m_subcat == -1) { switch (entry.m_type) { case 0: if (graph->getViewClass() & MetaGraph::VIEWVGA) { if (graph->getDisplayedPointMapRef() == entry.m_cat) { graph->setViewClass(MetaGraph::SHOWHIDEVGA); } else { graph->setDisplayedPointMapRef(entry.m_cat); } } else { graph->setDisplayedPointMapRef(entry.m_cat); graph->setViewClass(MetaGraph::SHOWVGATOP); } remenu = true; break; case 1: if (graph->getViewClass() & MetaGraph::VIEWAXIAL) { if (graph->getShapeGraphs().getDisplayedMapRef() == entry.m_cat) { graph->setViewClass(MetaGraph::SHOWHIDEAXIAL); } else { graph->getShapeGraphs().setDisplayedMapRef(entry.m_cat); } } else { graph->getShapeGraphs().setDisplayedMapRef(entry.m_cat); graph->setViewClass(MetaGraph::SHOWAXIALTOP); } remenu = true; break; case 2: if (graph->getViewClass() & MetaGraph::VIEWDATA) { if (graph->getDataMaps().getDisplayedMapRef() == entry.m_cat) { graph->setViewClass(MetaGraph::SHOWHIDESHAPE); } else { graph->getDataMaps().setDisplayedMapRef(entry.m_cat); } } else { graph->getDataMaps().setDisplayedMapRef(entry.m_cat); graph->setViewClass(MetaGraph::SHOWSHAPETOP); } remenu = true; break; case 4: // slightly different for this one break; } if (remenu) { SetGraphTreeChecks(); m_treeDoc->SetRemenuFlag(CGraphDoc::VIEW_ALL, true); GetApp()->GetMainWnd()->PostMessage( WM_DMP_FOCUS_GRAPH, (WPARAM) m_treeDoc, CGraphDoc::CONTROLS_CHANGEATTRIBUTE ); } m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_TABLE ); } else if (entry.m_subcat == -2) { // hit editable box if (SetEditable(entry)) { // update required (but probably not a redraw of the views) SetGraphTreeChecks(); } } else { // They've clicked on the displayed layers bool update = false; if (entry.m_type == 1) { bool show = graph->getShapeGraphs().getMap(entry.m_cat).isLayerVisible(entry.m_subcat); graph->getShapeGraphs().getMap(entry.m_cat).setLayerVisible(entry.m_subcat, !show); update = true; } else if (entry.m_type == 2) { bool show = graph->getDataMaps().getMap(entry.m_cat).isLayerVisible(entry.m_subcat); graph->getDataMaps().getMap(entry.m_cat).setLayerVisible(entry.m_subcat, !show); update = true; } if (update) { // Update required for the check boxes SetGraphTreeChecks(); // Depending on if the map is displayed you may have to redraw -- I'm just going to redraw *anyway* // (it may be worth switching it to topmost when they do click here) m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_TABLE ); } } } } else { size_t n = m_treedrawingmap.searchindex(hItem); if (n != paftl::npos) { CTreeEntry entry = m_treedrawingmap.value(n); if (entry.m_subcat != -1) { if (graph->getLineLayer(entry.m_cat,entry.m_subcat).isShown()) { graph->getLineLayer(entry.m_cat,entry.m_subcat).setShow(false); graph->PointMaps::redoBlockLines(); graph->resetBSPtree(); tree.SetItemImage(hItem,13,13); } else { graph->getLineLayer(entry.m_cat,entry.m_subcat).setShow(true); graph->PointMaps::redoBlockLines(); graph->resetBSPtree(); tree.SetItemImage(hItem,12,12); } } m_treeDoc->SetRedrawFlag(CGraphDoc::VIEW_ALL, CGraphDoc::REDRAW_GRAPH, CGraphDoc::NEW_LINESET ); } } // this doesn't appear to work (at least not always)... SwitchFocusBack(); // we handled it... don't let it select: *pResult = TRUE; }
void CFontPreviewWnd::OnPaint() { CPaintDC dc(this); // device context for painting // Draw the background CRect rct; GetClientRect(rct); dc.FillSolidRect(&rct, RGB(255, 255, 255)); // Get the active view CMDIFrameWnd *pFrame = (CMDIFrameWnd*)GET_PMWAPP()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CPmwView *pView = (CPmwView *)pChild->GetActiveView(); // Find the current document CPmwDoc* pDoc = (CPmwDoc*)(pChild->GetActiveDocument()); ASSERT(pDoc != NULL); // Get the database PMGDatabasePtr database = pDoc->get_database(); // Get the current style CTextStyle Style(database); CTxp* pTxp = pView->GetTxp(); Style = pTxp->Style(); // If text color is white, make it black so we can see it FillFormatV1& Fill = Style.Fill(); if (Fill.m_ForegroundColor == COLOR_WHITE) { Fill.m_ForegroundColor = COLOR_BLACK; } // Get the entry for this face. FaceEntry* entry; int face_to_use = m_nFontID; int font_number = -1; if ((entry = typeface_server.face_list.get_face(face_to_use)) != NULL) { int nVariation = 0; if (Style.Bold()) { nVariation |= FONT_STYLE_Bold; } if (Style.Italic()) { nVariation |= FONT_STYLE_Italic; } VARIATION_TYPE vtype = entry->get_variation_type(nVariation); if (vtype == VARIATION_TYPE_VIRTUAL || vtype == VARIATION_TYPE_REGISTRATION) { // We want to use the preview font for "virtual" (PMW.FFL) fonts. Check if // the font has an entry in the preview font. font_number = entry->get_preview_font_number(nVariation); if (font_number != -1) { // Set the font number back to -1 in case we fail. It will // be reloaded if we can sucessfully use the preview font. font_number = -1; // We want to use the font preview. Try to switch to the preview font. PCSTR pn = typeface_server.preview_face_name(); if (pn != NULL) { int found_face; if ((found_face = typeface_server.find_face(pn, FALSE)) != -1) { face_to_use = found_face; font_number = entry->get_preview_font_number(nVariation); } } } } } // Get a database record for this face. // This will be a 'temporary' reference which we must free. PMGFontServer *pFontServer = (PMGFontServer*)pDoc->get_font_server(); DB_RECORD_NUMBER f_record = pFontServer->font_face_to_record(face_to_use); // Set the face in the style. The style gets its own reference. Style.Font(f_record); // Default to 36 point. Style.BaseSize(MakeFixed(36)); Style.Size(Style.BaseSize()); Style.UpdateFontMetrics(); // Free our temp reference. database->free_font_record(f_record, TRUE); // Build the redisplay context. RedisplayContext rc; rc.destination_hdc = dc.m_hDC; rc.hwnd = m_hWnd; rc.scaled_source_x0 = rc.scaled_source_y0 = 0; rc.destination_rect = rct; rc.destination_x0 = 0; rc.destination_y0 = 0; rc.x_resolution = GetDeviceCaps(dc.m_hDC, LOGPIXELSX); rc.y_resolution = GetDeviceCaps(dc.m_hDC, LOGPIXELSY); //rc.outline_gamma_curve = rc.bitmap_gamma_curve = screen_gamma_curve; //rc.set_check_interrupt(standard_check_interrupt, (void*)&rc); rc.terminate_interrupts = TRUE; rc.clip_rect = rct; // Initialize the redisplay context so we can use it rc.set_info(dc.m_hDC); rc.screen_to_pbox(&rct, &rc.source_pbox); // Create the frame object now. FRAMEOBJ_CREATE_STRUCT fcs; fcs.alignment = ALIGN_center; fcs.vert_alignment = ALIGN_middle; fcs.bound = rc.source_pbox; CFrameObject* pObject; if ((pObject = database->create_frame_object(&fcs)) != NULL) { // This object is not on the page! pObject->OnPage(FALSE); // Nor is it selected! pObject->remove_select_flags(SELECT_FLAG_boundary); // Prepare to add some text. CTxp Txp(database); CHARACTER Text[4]; if (font_number == -1) { Text[0] = 'T'; Text[1] = 'y'; Text[2] = 'p'; Text[3] = 'e'; } else { // We substituted the preview font int ch_base = font_number*4 + '!'; Text[0] = ch_base++; Text[1] = ch_base++; Text[2] = ch_base++; Text[3] = ch_base++; } // Stick in some text Txp.Init(pObject, 0); Txp.SetHorizontalAlignment(ALIGN_center); Txp.Style(Style); Txp.InsertText(Text, 4); // Select our palette in. CPalette* pOldPalette = dc.SelectPalette(pOurPal, FALSE); if (pOldPalette != NULL) { dc.RealizePalette(); } // And draw the object! UpdateStatePtr ustate; if ((ustate = pObject->update(&rc, &fcs.bound, &rct, NULL, REFRESH_ALL)) != NULL) { // See what happened switch (ustate->type) { case UPDATE_TYPE_Interrupted: { // This should not happen delete ustate; // Fall through to... } case UPDATE_TYPE_Terminated: { // Try again later InvalidateRect(&rct, FALSE); break; } default: { break; } } } pObject->destroy(); // Remove from the document. delete pObject; // Select our palette back out. if (pOldPalette != NULL) { dc.SelectPalette(pOldPalette, FALSE); } } // Do not call CBarMRUCombo::OnPaint() for painting messages }