📄 attribute.cpp
字号:
#include "stdafx.h"
#include "Attribute.h"
Attribute::Attribute(CString n,CString nt,Element* e,int f,int m,int x1,int y1,int x2,int y2,int c,int d)
{
this->mainkey=m;
this->selecting=0;
this->name=n;
this->father=e;
this->flag=f;
this->type=3;
this->e1=*(new CPoint(x1,y1));
this->e2=*(new CPoint(x2,y2));
this->next=NULL;
this->nextelement=NULL;
this->nametype=nt;
this->datelength=d;
this->canempty=c;
this->nextmain=NULL;
if(nametype=="char"||nametype=="varchar")
{
CString s;
s.Format("%d",datelength);
nametype=nametype+"("+s+")";
}
}
int Attribute::isDeleted()
{
return 1;
}
void Attribute::paint(CDC& g)
{
CPen pen0(PS_SOLID,2,RGB(255,0,0));
CPen pen(PS_DOT,2,RGB(255,0,0));
CPen pen1(PS_SOLID,1,RGB(0,0,0));
CPen pen2(PS_DOT,1,RGB(0,0,0));
g.MoveTo((e1.x+e2.x)/2,(e1.y+e2.y)/2);
g.LineTo((this->father->e1.x+this->father->e2.x)/2,
(this->father->e1.y+this->father->e2.y)/2);
if(this->selecting==1)
{
g.SelectObject(pen0);
}
if(this->flag==3)
{
g.SelectObject(pen2);
}
if(this->selecting==1&&this->flag==3)
{
g.SelectObject(pen);
}
g.Ellipse(e1.x,e1.y,e2.x,e2.y);
if(this->flag==2)
{
g.Ellipse(e1.x+5,e1.y+5,e2.x-5,e2.y-5);
}
if(mainkey==1&&flag==1&&this->father->type==1)
{
g.TextOut(e1.x+10,(e1.y+e2.y)/2-10,"*");
}
g.TextOut(e1.x+15,(e1.y+e2.y)/2-10,name);
g.SelectObject(pen1);
this->father->paint(g);
pen.DeleteObject();
pen0.DeleteObject();
pen1.DeleteObject();
pen2.DeleteObject();
}
void Attribute::Delete()
{
this->father->removeAttribute(this);
}
void Attribute::serial(CArchive& ar)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -