📄 mapp.cpp
字号:
#include"\sunshine\include\app.h"
#include"\sunshine\include\mapp.h"
#include"\sunshine\include\mbar.h"
#include"\sunshine\include\mlistite.h"
#include"\sunshine\include\define.h"
#include<stdlib.h>
#include<new.h>
void error()
{
closegraph();
cout<<"\a"<<"\a"<<"Sorry,a memory allocation failed\n";
while(!bioskey(1));bioskey(0);
exit(1);
}
MApp::MApp(int gd) : MWindowObj(0,0,getmaxx()+1,getmaxy()+1,"APP")
{
int gm;
REGS regs;
isok=SUCC;
initgraph(&gd,&gm,"");
if(graphresult()<0)
{
closegraph();
puts("Initalize graphics drivers failure!");
isok=FAIL;
exit(1) ;
}
regs.x.ax=0;
int86(0x33,®s,®s);
if(!regs.x.ax)
{
closegraph();
puts("Mouse driver is not installed!");
isok=FAIL;
exit(1) ;
}
if(!HZ)
{
closegraph();
puts("Open Chinese font library Error!");
isok=FAIL;
exit(1) ;
}
Application=this;
Mes=1;
set_new_handler(error); //set eroor handler
setrgbpalette(LIGHTGRAY,49,49,49); //set lightgray color
}
MApp::~MApp()
{
Add(*new MLast());
}
void MApp::Paint(char *topic)
{
Mouse am;
Add(*new MStatus(0,getmaxy()-20,getmaxx()+1,21));
setfillstyle(SOLID_FILL,WHITE);
bar(0,0,getmaxx(),getmaxy());
if(!topic) {am.MouseOn();return ;}
setcolor(BLACK);
rectangle(0,0,getmaxx(),19);
setfillstyle(SOLID_FILL,BLUE);
bar(1,1,getmaxx()-1,18);
if(topic) Write(topic,(getmaxx()+1)/2-Length(topic)/2,1,WHITE);
MApp::Application->Add(*new MKey(0,0,20,20,"KEY"));
am.MouseOn();
return ;
//other fillstyles
}
int MApp::Process()
{
int value;
int i=0;
char *tempidname;
for(;;)
{
tempidname=winobj[i]->GetId();
if(winobj[i]->GetMes()==NOPRO)
{
i++;i=(i>=number?0:i);
continue;
}
value=winobj[i]->Process();
if(value==DEL) {Del(tempidname);}
if(value==EXITCODE) break;
if(Mes==CLOSE) break; // received the exit code;
i++;i=(i>=number?0:i);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -