📄 imagecamview.cpp
字号:
{
HPALETTE hPalette = (HPALETTE)m_pDib->m_pPalette->GetSafeHandle();
if (hPalette != NULL)
{
PALETTEENTRY pe;
GetPaletteEntries(hPalette, nID-IDC_COLORTABLE_BASE, 1, &pe);
CMainFrame* pAppFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
ASSERT_KINDOF(CMainFrame, pAppFrame);
if (pAppFrame->m_wndPaintParamBar.m_nSelectColorMode == PP_FILL_COLOR)
{
m_crFillColor = RGB(pe.peRed, pe.peGreen, pe.peBlue);
ShowFillColor();
}
else if (pAppFrame->m_wndPaintParamBar.m_nSelectColorMode == PP_PEN_COLOR)
{
m_crPenColor = RGB(pe.peRed, pe.peGreen, pe.peBlue);
ShowPenColor();
}
}
}
void CimageCAMView::OnFillcolor1()
{
CMainFrame* pAppFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
ASSERT_KINDOF(CMainFrame, pAppFrame);
if (pAppFrame->m_wndPaintParamBar.m_nSelectColorMode == PP_FILL_COLOR)
OnFillcolor();
else
pAppFrame->m_wndPaintParamBar.SetSelectColorMode(PP_FILL_COLOR);
}
void CimageCAMView::OnPencolor1()
{
CMainFrame* pAppFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
ASSERT_KINDOF(CMainFrame, pAppFrame);
if (pAppFrame->m_wndPaintParamBar.m_nSelectColorMode == PP_PEN_COLOR)
OnPencolor();
else
pAppFrame->m_wndPaintParamBar.SetSelectColorMode(PP_PEN_COLOR);
}
void CimageCAMView::OnPencolor()
{
// TODO: Add your command handler code here
CColorDialog dlgColor(m_crPenColor);
if (dlgColor.DoModal() == IDOK)
{
m_crPenColor = dlgColor.GetColor();
ShowPenColor();
}
}
void CimageCAMView::OnFillcolor()
{
// TODO: Add your command handler code here
CColorDialog dlgColor(m_crFillColor);
if (dlgColor.DoModal() == IDOK)
{
m_crFillColor = dlgColor.GetColor();
ShowFillColor();
}
}
void CimageCAMView::OnRealizePal(WPARAM wParam, LPARAM lParam)
{
ASSERT(wParam != NULL);
if (m_pDib->IsEmpty())
return; // must be a new document
CPalette* pPal = m_pDib->GetPalette();
if (pPal != NULL)
{
CWnd* pAppFrame = AfxGetApp()->m_pMainWnd;
CClientDC appDC(pAppFrame);
// All views but one should be a background palette.
// wParam contains a handle to the active view, so the SelectPalette
// bForceBackground flag is FALSE only if wParam == m_hWnd (this view)
CPalette* oldPalette = appDC.SelectPalette(pPal, ((HWND)wParam) != m_hWnd);
if (oldPalette != NULL)
{
UINT nColorsChanged = appDC.RealizePalette();
if (nColorsChanged > 0)
GetDocument()->UpdateAllViews(NULL);
appDC.SelectPalette(oldPalette, TRUE);
}
else
{
TRACE0("\tSelectPalette failed in CImageBoardView::OnPaletteChanged\n");
}
}
}
void CimageCAMView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
CSize sizeTotal(m_pDib->ratio*m_pDib->GetWidth(), m_pDib->ratio*m_pDib->GetHeight());
SetStatusBarImageSize(sizeTotal);
SetStatusBarBitCount(m_pDib->GetBitCount());
ShowColorGrid();
// re paint the entire client area
Invalidate();
}
void CimageCAMView::OnSelect()
{
// TODO: Add your command handler code here
SetDrawType(DT_SELECT);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateSelect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_SELECT == m_nDrawType);
}
void CimageCAMView::OnPicker()
{
// TODO: Add your command handler code here
SetDrawType(DT_PICKER);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{
m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdatePicker(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_PICKER == m_nDrawType);
}
void CimageCAMView::OnEraser()
{
// TODO: Add your command handler code here
SetDrawType(DT_ERASER);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{
m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateEraser(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_ERASER == m_nDrawType);
}
void CimageCAMView::OnFreeline()
{
// TODO: Add your command handler code here
SetDrawType(DT_FREELINE);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{
m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateFreeline(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_FREELINE == m_nDrawType);
}
void CimageCAMView::OnLine()
{
// TODO: Add your command handler code here
SetDrawType(DT_LINE);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateLine(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_LINE == m_nDrawType);
}
void CimageCAMView::OnCurve()
{
// TODO: Add your command handler code here
SetDrawType(DT_CURVE);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateCurve(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_CURVE==m_nDrawType );
}
void CimageCAMView::OnRectH()
{
// TODO: Add your command handler code here
SetDrawType(DT_RECT_H);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{
m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateRectH(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_RECT_H == m_nDrawType);
}
void CimageCAMView::OnRectF()
{
// TODO: Add your command handler code here
SetDrawType(DT_RECT_F);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateRectF(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_RECT_F == m_nDrawType);
}
void CimageCAMView::OnRoundrectH()
{
// TODO: Add your command handler code here
SetDrawType(DT_ROUNDRECT_H);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateRoundrectH(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_ROUNDRECT_H == m_nDrawType);
}
void CimageCAMView::OnRoundrectF()
{
// TODO: Add your command handler code here
SetDrawType(DT_ROUNDRECT_F);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateRoundrectF(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_ROUNDRECT_F == m_nDrawType);
}
void CimageCAMView::OnEllipseH()
{
// TODO: Add your command handler code here
SetDrawType(DT_ELLIP_H);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateEllipseH(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_ELLIP_H == m_nDrawType);
}
void CimageCAMView::OnEllipseF()
{
// TODO: Add your command handler code here
SetDrawType(DT_ELLIP_F);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateEllipseF(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_ELLIP_F == m_nDrawType);
}
void CimageCAMView::OnFill()
{
// TODO: Add your command handler code here
SetDrawType(DT_FILL);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateFill(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_FILL == m_nDrawType);
}
void CimageCAMView::OnText()
{
// TODO: Add your command handler code here
SetDrawType(DT_TEXT);
CimageCAMDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDib = pDoc->m_pDib;
if(m_pDib->ratio!=1.0)
{ m_pDib->ratio=1.0;
pDoc->SetModifiedFlag(TRUE);
pDoc->UpdateAllViews(NULL);
CSize sizeTotal(m_pDib->GetWidth(),m_pDib->GetHeight());
SetScrollSizes(MM_TEXT, sizeTotal);
};
}
void CimageCAMView::OnUpdateText(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(DT_TEXT== m_nDrawType);
}
void CimageCAMView::OnSolid()
{
// TODO: Add your command handler code here
SetPenStyle(PS_SOLID);
ShowPenStyle();
}
void CimageCAMView::OnUpdateSolid(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(PS_SOLID == m_nPenStyle);
}
void CimageCAMView::OnDash()
{
// TODO: Add your command handler code here
SetPenStyle(PS_DASH);
ShowPenStyle();
}
void CimageCAMView::OnUpdateDash(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(PS_DASH == m_nPenStyle);
}
void CimageCAMView::OnDot()
{
// TODO: Add your command handler code here
SetPenStyle(PS_DOT);
ShowPenStyle();
}
void CimageCAMView::OnUpdateDot(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(PS_DOT == m_nPenStyle);
}
void CimageCAMView::OnPw1()
{
// TODO: Add your command handler code here
SetPenWidth(1);
ShowPenWidth();
}
void CimageCAMView::OnUpdatePw1(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(1 == m_nPenWidth);
}
void CimageCAMView::OnPw2()
{
// TODO: Add your command handler code here
SetPenWidth(2);
ShowPenWidth();
}
void CimageCAMView::OnUpdatePw2(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(2 == m_nPenWidth);
}
void CimageCAMView::OnPw3()
{
// TODO: Add your command handler code here
SetPenWidth(3);
ShowPenWidth();
}
void CimageCAMView::OnUpdatePw3(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(3 == m_nPenWidth);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -