?? item.cpp
字號:
#include <assert.h>
#include <conio.h>
#include <graphics.h>
#include <string.h>
#include "item.h"
extern int changeCode(char);
Item *Item::first=0;
Item *Item::end=0;
Item::Item(int tx1,int ty1,int tx2,int ty2,int ttColor,int trColor,int tfColor,char *pText,POINT p)
{
x1=tx1;
x2=tx2;
y1=ty1;
y2=ty2;
fColor=tfColor;
rColor=trColor;
tColor=ttColor;
bkColor=fColor;
text=new char[strlen(pText)+1];
assert(text!=0);
strcpy(text,pText);
word=*pText;
code=changeCode(word);
pointTo=p;
if(first==0)
first=this;
else
end->next=this;
end=this;
end->next=0;
}
Item::~Item()
{
if(first==this)
first=this->next;
else
for(Item *p=first;p;p=p->next)
if(p->next==this) p->next=this->next;
delete text;
}
Item *Item::getNext(){return next;}
POINT Item::getPointTo(){return pointTo;}
Item* Item::search(int key,Item *p,Item *pb)
{
for(;p;p=p->next)
{
if(p->code==key) {pb->resetBK();pb=p;pb->changeBK(7);(pb->pointTo)();break;}
}
return pb;
}
Item *Item::getFirst()
{
Item *p=first;
first=0;
return p;
}
void Item::changeBK(int c)
{
bkColor=c;
drawItem();
};
void Item::resetBK()
{
bkColor=fColor;
drawItem();
};
void Item::drawItem()
{
int midY=(y1+y2)/2;
setcolor(rColor);
rectangle(x1,y1,x2,y2);
setfillstyle(1,bkColor);
floodfill(x1+2,y1+2,rColor);
setcolor(tColor);
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(x1+10,midY,text);
char t[2];
t[0]=word;
t[1]='\0';
setcolor(LIGHTRED);
outtextxy(x1+10,midY,t);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -