// gives the intersection-point between two lines, returns true, if any // computes the crossing point between the (infinite) lines // defined by the endpoints of the DLines, then checks if it // lies within the two rectangles defined by the DLines endpoints bool DLine::intersection( const DLine &line, DPoint &inter, bool endpoints) const { double ix, iy; //do not return true if parallel edges are encountered if (slope() == line.slope()) return false; //two possible checks: // only check for overlap on endpoints if option parameter set, // compute crossing otherwise // or skip computation if endpoints overlap (can't have "real" crossing) // (currently implemented) //if (endpoints) { if (m_start == line.m_start || m_start == line.m_end) { inter = m_start; if (endpoints) return true; else return false; } if (m_end == line.m_start || m_end == line.m_end) { inter = m_end; if (endpoints) return true; else return false; } //}//if endpoints //if the edge is vertical, we cannot compute the slope if (isVertical()) ix = m_start.m_x; else if (line.isVertical()) ix = line.m_start.m_x; else ix = (line.yAbs() - yAbs())/(slope() - line.slope()); //set iy to the value of the infinite line at xvalue ix //use a non-vertical line (can't be both, otherwise they're parallel) if (isVertical()) iy = line.slope() * ix + line.yAbs(); else iy = slope() * ix + yAbs(); inter = DPoint(ix, iy); //the (infinite) lines cross point DRect tRect(line); DRect mRect(*this); return (tRect.contains(inter) && mRect.contains(inter)); }
//绘画函数 void CShortMessage::OnPaint() { CPaintDC dc(this); //绘画标题 DrawCaption(&dc); CRect ClientRect; GetClientRect(&ClientRect); int nXExcursion=GetXExcursionPos(); int nYExcursion=GetYExcursionPos(); //绘画背景 COLORREF Color = RGB(170,213,244); dc.FillSolidRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,4,Color); dc.FillSolidRect(nXExcursion,ClientRect.Height()-8,ClientRect.Width()-2*nXExcursion,7,Color); dc.FillSolidRect(nXExcursion,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); dc.FillSolidRect(ClientRect.Width()-nXExcursion-12,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); CRect mRect(nXExcursion,190,ClientRect.Width()-2*nXExcursion,ClientRect.Height()); CBrush Brush(Color); dc.FillRect(mRect,&Brush); //创建笔画 CPen BorderPen(PS_SOLID,1,RGB(20,20,20)); CPen * pOldPen=dc.SelectObject(&BorderPen); dc.SelectObject(m_SkinAttribute.m_brBackGround); //绘画内框 CRect rcDrawRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,200); rcDrawRect.DeflateRect(6,4,6,4); dc.RoundRect(&rcDrawRect,CPoint(8,8)); //清理资源 dc.SelectObject(pOldPen); BorderPen.DeleteObject(); //创建笔画 CPen BorderPen1(PS_SOLID,1,m_SkinAttribute.m_crInsideBorder); pOldPen=dc.SelectObject(&BorderPen1); //绘画内框 rcDrawRect.DeflateRect(1,1,1,1); dc.RoundRect(&rcDrawRect,CPoint(8,8)); CRect rcDrawRect1(nXExcursion+9,203,ClientRect.Width()-2*nXExcursion-8,ClientRect.Height()-37); dc.RoundRect(&rcDrawRect1,CPoint(4,4)); //清理资源 dc.SelectObject(pOldPen); BorderPen1.DeleteObject(); return; }
//绘画函数 void CShortMessage::OnPaint() { CPaintDC dc(this); //绘画标题 DrawCaption(&dc); CRect ClientRect; GetClientRect(&ClientRect); int nXExcursion=GetXExcursionPos(); int nYExcursion=GetYExcursionPos(); ///////////////////////////////////////////////////////////////////////////// CRect rcClient1; GetWindowRect(&rcClient1); int nWidth1=rcClient1.Width(); int nHeight1=rcClient1.Height(); //调整判断 if ((nWidth1!=0)&&(nHeight1!=0)) { //框架位置 CRect rcFrame; rcFrame.SetRect(0,0,nWidth1,nHeight1); //窗口区域 CRgn RegionWindow; RegionWindow.CreateRoundRectRgn(rcFrame.left,rcFrame.top,rcFrame.right+1,rcFrame.bottom+1,5,5); //设置区域 SetWindowRgn(RegionWindow,TRUE); } /////////////////////////////////////////////////////////////////////////// //绘画背景 COLORREF Color = RGB(170,213,244); dc.FillSolidRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,4,Color); dc.FillSolidRect(nXExcursion,ClientRect.Height()-8,ClientRect.Width()-2*nXExcursion,7,Color); dc.FillSolidRect(nXExcursion,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); dc.FillSolidRect(ClientRect.Width()-nXExcursion-12,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); CRect mRect(nXExcursion,190,ClientRect.Width()-2*nXExcursion,ClientRect.Height()); CBrush Brush(Color); dc.FillRect(mRect,&Brush); //创建笔画 CPen BorderPen(PS_SOLID,1,RGB(20,20,20)); CPen * pOldPen=dc.SelectObject(&BorderPen); dc.SelectObject(m_SkinAttribute.m_brBackGround); //绘画内框 CRect rcDrawRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,200); rcDrawRect.DeflateRect(6,4,6,4); dc.RoundRect(&rcDrawRect,CPoint(8,8)); //清理资源 dc.SelectObject(pOldPen); BorderPen.DeleteObject(); //创建笔画 CPen BorderPen1(PS_SOLID,1,m_SkinAttribute.m_crInsideBorder); pOldPen=dc.SelectObject(&BorderPen1); //绘画内框 rcDrawRect.DeflateRect(1,1,1,1); dc.RoundRect(&rcDrawRect,CPoint(8,8)); CRect rcDrawRect1(nXExcursion+9,203,ClientRect.Width()-2*nXExcursion-8,ClientRect.Height()-37); dc.RoundRect(&rcDrawRect1,CPoint(4,4)); //清理资源 dc.SelectObject(pOldPen); BorderPen1.DeleteObject(); return; }
CValue CValueControl::Method(int iName,CValue **p) { if(!pWnd) Error("Не было привязки окна CWnd!"); CValue Ret; switch(iName) { case enVisible: { Ret=Visible(); if(p[0]->nType!=TYPE_EMPTY) Visible(p[0]->GetNumber()); break; } case enEnable: { Ret=Enable(); if(p[0]->nType!=TYPE_EMPTY) Enable(p[0]->GetNumber()); break; } case enColor: { Ret=Color(); if(p[0]->nType!=TYPE_EMPTY) Color(p[0]->GetNumber(),p[1]->GetNumber(),p[2]->GetNumber()); break; } case enCaption: { Ret=String(Caption()); if(p[0]->nType!=TYPE_EMPTY) { Caption(p[0]->GetString()); } break; } case enEnableEdit: { Ret=EnableEdit(); if(p[0]->nType!=TYPE_EMPTY) EnableEdit(p[0]->GetNumber()); break; } case enMask: { //Ret=Mask(); if(p[0]->nType!=TYPE_EMPTY) Ret=String(Mask(p[0]->GetString())); break; } case enClose: { Close(); break; } case enModif: { int nSet=-1; if(p[0]->nType!=TYPE_EMPTY) nSet=p[0]->GetNumber(); return Modify(nSet); } case enFocus: { ((CWnd*)pWnd)->SetFocus(); } case enSetControlRect: { int x, y, nWidth, nHeight; x=p[0]->GetNumber(); y=p[1]->GetNumber(); nWidth=p[2]->GetNumber(); nHeight=p[3]->GetNumber(); ASSERT(pWnd); ((CWnd*)pWnd)->MoveWindow(x, y, nWidth, nHeight,1); ((CWnd*)pWnd)->RedrawWindow(); break; } case enGetControlRect: { CRect mRect(0,0,0,0); ASSERT(pWnd); ((CWnd*)pWnd)->GetWindowRect(&mRect); CWnd* pParentWnd=((CWnd*)pWnd)->GetParent(); pParentWnd->ScreenToClient(&mRect); *p[0] = CValue(mRect.left); *p[1] = CValue(mRect.top); *p[2] = CValue(mRect.right - mRect.left); *p[3] = CValue(mRect.bottom - mRect.top); break; } } return Ret; }