void CPatchPageDlg::OnPaint() { if (theApp.GetMain()->IsMidiLearn()) { // if learning MIDI assignments CPaintDC dc(this); // device context for painting CWnd *pFocusWnd = GetFocus(); // if focus window is one of our controls if (pFocusWnd != NULL && IsChild(pFocusWnd)) { int iPart; // find MIDI target corresponding to control, if any int iTarget = theApp.GetMain()->GetCtrlMidiTarget(pFocusWnd, iPart); if (iTarget < 0) { // if target not found int nID = pFocusWnd->GetDlgCtrlID(); if (nID == IDC_PART_IN_PORT || nID == IDC_PART_IN_CHAN) iTarget = INT_MAX; // input port/channel are special targets } if (iTarget >= 0) { // if control mapped to MIDI target COLORREF cSel = RGB(0, 255, 0); CRect rSel; GetSelectionRect(pFocusWnd, rSel); dc.FillSolidRect(rSel, cSel); // highlight control } } } else { // not learning MIDI assignments Default(); } }
void FormView::Paint(Draw& w) { if (!IsLayout()) { w.DrawRect(GetRect(), White()); return; } Rect r = Zoom(GetPageRect()); DrawGrid(w); DrawRect(w, r, 1, LtBlue()); w.DrawRect(0, 0, r.left, 3000, White()); w.DrawRect(r.right + 1, 0, 3000, 3000, White()); w.DrawRect(r.left, 0, 5000, r.top, White()); w.DrawRect(r.left, r.bottom + 1, 3000, 3000, White()); // if (_showInfo) // { // r.SetSize( Zoom(Size(804, 604)) ); // DrawRect(w, r.Offseted( Zoom(Size(-2, -2)) ), 1, LtMagenta()); // r = Zoom(GetPageRect()); // } if (GetObjectCount() > 0 && _showInfo == 2) { Rect b = Zoom(GetObjectsRect()).Offseted(1, 1); b.SetSize( b.GetSize() + Size(-2, -2) ); DrawRect(w, b, 1, Yellow()); } Vector<int> sel = GetSelected(); bool coloring = GetBool("View.Coloring"); int ci = 0; if (sel.GetCount() > 0) { if (sel.GetCount() == 1) { for (int i = 0; i < GetObjectCount(); ++i) { if (ci++ == _colors.GetCount() - 1) ci = 0; if (coloring && i != sel[0]) DrawObject(w, i, _colors[ci], false); else DrawObject(w, i, (!coloring && (i == sel[0])) ? _colors[ci] : LtGray(), i == sel[0]); } } else { for (int i = 0; i < GetObjectCount(); ++i) { if (ci++ == _colors.GetCount() - 1) ci = 0; bool found = false; for (int j = 0; j < sel.GetCount(); ++j) if ( i == sel[j]) { found = true; break; } if (coloring && !found) DrawObject(w, i, _colors[ci], false); else DrawObject(w, i, (!coloring && found) ? _colors[ci] : LtGray(), false); } Size g = GetGridSize(); Rect s = GetSelectionRect().Offseted(-g.cx / 2, -g.cy / 2); s.SetSize(s.GetSize() + Size(g.cx, g.cy)); Vector<int> sel = GetSelected(); bool a1 = true; // allow horz align bool a2 = true; // allow vert align dword f1; // first horz align dword f2; // first vert align for (int i = 0; i < sel.GetCount(); ++i) { FormObject *pI = GetObject(sel[i]); if (!pI) continue; if (i == 0) { f1 = pI->GetHAlign(); f2 = pI->GetVAlign(); } if (f1 != pI->GetHAlign()) { a1 = false; } if (f2 != pI->GetVAlign()) { a2 = false; } } DrawSprings(w, Zoom(s), f1, f2, a1, a2, a1, a2, false); DrawRect(w, Zoom(s), 1, LtRed()); s = GetSelectionRect().Offseted(-g.cx, -g.cy); s.SetSize(s.GetSize() + Size(g.cx * 2, g.cy * 2)); DrawGroupTools(w, Zoom(s)); } return; } for (int i = 0; i < GetObjectCount(); ++i) { if (ci++ == _colors.GetCount() - 1) ci = 0; DrawObject(w, i, coloring ? _colors[ci] : LtGray()); } if (sel.GetCount() == 0) w.DrawImage(r.right, r.bottom, FormViewImg::SizerBR()); }
void CPatchPageDlg::UpdateMidiLearn(CWnd *pChild) { CRect rSel; GetSelectionRect(pChild, rSel); InvalidateRect(rSel); }