📄 mdocwin.cpp
字号:
#include"\sunshine\include\mdocwin.h"
#include<string.h>
#include<alloc.h>
#include<string.h>
#include<fstream.h>
#define ALT_F4 0x6b00
MWindow::MWindow(int x1,int y1,int w1,int h1,char *top,char *idname)
: MWindowObj(x1,y1,w1,h1,idname)
{
topic=new char[strlen(top)+1];
strcpy(topic,top);
Add(*new MKey(x()+1,y()+1,20,20,*this));
bkcolor=WHITE;
ClientName="MCLIENT";
SetAc(0);
saveflag=0;
}
MWindow::~MWindow()
{
delete topic;
Restore();
}
STATE MWindow::Save()
{
Mouse am(1);
long size=imagesize(x(),y(),x()+w()-1,y()+h()-1);
rscreen=farmalloc(size);
if(rscreen) getimage(x(),y(),x()+w()-1,y()+h()-1,rscreen);
return SUCC;
}
void MWindow::Restore()
{
Mouse am(1);
if(rscreen) putimage(x(),y(),rscreen,COPY_PUT);
if(rscreen) farfree(rscreen);
}
void MWindow::Cls()
{
Mouse am(1);
setfillstyle(SOLID_FILL,bkcolor);
bar(x()+1,y()+21,x()+w()-2,y()+h()-2);
}
void MWindow::UnFocus()
{
Mouse am(1);
setcolor(BLACK);
rectangle(x(),y(),x()+w()-1,y()+h()-1);
if(GetAc()) Cls();
LightTopic();
}
void MWindow::LightTopic()
{
if(GetAc()) setfillstyle(SOLID_FILL,BLUE);
else setfillstyle(SOLID_FILL,DARKGRAY);
bar(x()+21,y()+1,x()+w()-2,y()+20);
if(topic) Write(topic,x()+w()/2-Length(topic)/2,y()+2,WHITE);
}
void MWindow::GetFocus()
{
int num=GetNumber();
int i;
UnFocus();
Cls();
for(i=0;i<num;i++)
GetObj(i).SetFirst();
}
void MWindow::SetPos(int xx,int yy)
{
int num=GetNumber();
int i;
Mouse am(1);
Restore();
for(i=0;i<num;i++)
{
GetObj(i).x(xx+GetObj(i).x()-x());
GetObj(i).y(yy+GetObj(i).y()-y());
}
x(xx);y(yy);
Save();
GetFocus();
}
void MWindow::SetAc(int acti)
{
ac=acti;
}
int MWindow::Process()
{
Mouse am;
int key;
int value;
char *tempname;
if(firstrun){
firstrun=0;
Save();
UnFocus();
Cls();
for(int i=0;i<GetNumber();i++)
GetObj(i).Process();
return 1;
}
//////////////////////////////////////////////////////////
//The top window in stack is always activating ////////
//firstly judge the moovable possiblity /////////
//////////////////////////////////////////////////////////
if(!GetAc()) return 1;
if(am.x()>(x()+21)&& am.y()>(y()+1)&&am.x()<(x()+w()-2)
&& am.y()<(y()+20))
{
while(am.lp()){ Move();return 1;}
}
key=bioskey(1);
if(key)
{
switch(key){
case ALT_F4: bioskey(0);
return DEL; //eaten the key
}
}
for(int i=0;i<GetNumber();i++)
{
tempname=winobj[i]->GetId();
value=winobj[i]->Process();
if(value==1) continue;
if(value==DEL) return DEL;
if(value==DIALOG_DEL) Del(tempname);
if(Mes==CLOSE) return DEL;
}
return 1;
}
void MWindow::Move()
{
int ox,oy,nx,ny,sx,sy,pw=0,ph=0;
int fir=1;
Mouse am;
sx=ox=nx=am.x();sy=oy=ny=am.y();
setwritemode(XOR_PUT);
setcolor(WHITE);
while(am.lp())
{
if(fir){ am.MouseOff();
rectangle(x(),y(),x()+w()-1,y()+h()-1);
am.MouseOn();
fir=0;am.Reset();continue;
}
nx=am.x();ny=am.y();
if(nx!=ox||ny!=oy)
{
am.MouseOff();
rectangle(x()+pw,y()+ph,
x()+pw+w()-1,y()+ph+h()-1);
pw=nx-sx;ph=ny-sy;
rectangle(x()+pw,y()+ph,
x()+pw+w()-1,y()+ph+h()-1);
am.MouseOn();
ox=nx;oy=ny;
}
am.Reset();
}
am.MouseOff();
rectangle(x()+pw,y()+ph,
x()+pw+w()-1,y()+ph+h()-1);
setwritemode(COPY_PUT);
am.MouseOn();
MObj &ac=MApp::Application->GetObj(ClientName);
if(x()+pw<ac.x()) return ;
if(y()+ph<ac.y()) return ;
if(x()+pw+w()-1>ac.x()+ac.w()-1) return ;
if(y()+ph+h()-1>ac.y()+ac.h()-1) return ;
SetPos(x()+pw,y()+ph);
}
void MWindow::Redraw()
{
int j;
UnFocus();
Cls();
for(j=0;j<GetNumber();j++) GetObj(j).SetFirst(1);
for(j=0;j<GetNumber();j++) GetObj(j).Process();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -