📄 mywindow.h
字号:
setcolor(LIGHTGRAY);
line(List->right-18,List->top+2,List->right-3,List->top+2);
line(List->right-18,List->top+2,List->right-18,List->top+19);
setfillstyle(1,DARKGRAY);
bar(List->right-17,List->top+3,List->right-4,List->top+18);
bar(List->right-17,List->bottom-18,List->right-4,List->bottom-4);
setcolor(BLACK);
line(List->right-15,List->top+12,List->right-11,List->top+8);
line(List->right-7,List->top+12,List->right-11,List->top+8);
line(List->right-15,List->top+12,List->right-7,List->top+12);
line(List->right-15,List->bottom-13,List->right-11,List->bottom-9);
line(List->right-7,List->bottom-13,List->right-11,List->bottom-9);
line(List->right-15,List->bottom-13,List->right-7,List->bottom-13);
setfillstyle(1,BLACK);
floodfill(List->right-11,List->top+9,BLACK);
floodfill(List->right-11,List->bottom-10,BLACK);
setfillstyle(1,WHITE);
bar(List->left+2,List->top+21,List->right-20,List->bottom-2);
int i,j,Height=22+19,Width=(List->Width-22)/List->kinds;
int canlist;
if (List->Show>List->count) List->Show=List->count;
if (List->Show<1) List->Show=1;
setcolor(DARKGRAY);
for (i=1;Height<=List->Height;i++){
line(List->left+2,List->top+20+i*19,List->right-20,List->top+20+i*19);
Height+=19;
}
List->CanList=canlist=i-1;
j=List->Selected-List->Show+1;
if (j>0 && j<=canlist){
setfillstyle(1,BLUE);
bar(List->left+2,List->top+2+j*19,List->right-20,List->top+19+j*19);
}
for (i=1;i<List->kinds;i++)
line(List->left+2+i*Width,List->top+2,List->left+2+i*Width,List->bottom-2);
for (i=0;i<List->kinds;i++)
WriteText(List->Text[0][i],List->left+4+i*Width,List->top+3,BLACK);
for (i=0;i<canlist && i+List->Show<=List->count;i++)
for (j=0;j<List->kinds;j++){
setviewport(List->left+3+j*Width+father->left,List->top+21+i*19+father->top,List->left+1+j*Width+Width+father->left
,List->top+22+17+i*19+father->top,1);
if (i+List->Show==List->Selected) {
WriteText(List->Text[i+List->Show][j],1,1,WHITE);
} else
WriteText(List->Text[i+List->Show][j],1,1,BLACK);
}
setviewport(0,0,MAXX,MAXY,0);
DrawMouse();
}
/*=================================*/
/* 绘制输入框光标函数定义 */
/*=================================*/
void DrawCur(Hwnd handle){
DestroyMouse();
pEdit Edit=GetEdit(handle);
pWindow father=GetWindow(Edit->father);
setviewport(father->left+Edit->left,father->top+Edit->top,
father->right,father->bottom,1);
int i,Locate=Edit->CurLocate;
Locate*=8;
Locate+=2;
for (i=3;i<19;i++)
putpixel(Locate,i,getpixel(Locate,i)^WHITE);
setviewport(0,0,MAXX,MAXY,0);
DrawMouse();
}
/*=================================*/
/* 绘制编辑框函数定义 */
/*=================================*/
void DrawEdit(Hwnd handle){
if (handle==0) return;
DestroyMouse();
pEdit Edit=GetEdit(handle);
pWindow father=GetWindow(Edit->father);
setviewport(father->left,father->top,
father->right,father->bottom,1);
setcolor(BLACK);
rectangle(Edit->left,Edit->top,Edit->left+Edit->Width,Edit->top+21);
setcolor(DARKGRAY);
line(Edit->left+1,Edit->top+1,Edit->left+Edit->Width-1,Edit->top+1);
line(Edit->left+1,Edit->top+1,Edit->left+1,Edit->top+20);
setcolor(LIGHTGRAY);
line(Edit->left+1,Edit->top+20,Edit->left+Edit->Width-1,Edit->top+20);
line(Edit->left+Edit->Width-1,Edit->top+1,Edit->left+Edit->Width-1,Edit->top+20);
setfillstyle(1,WHITE);
bar(Edit->left+2,Edit->top+2,Edit->left+Edit->Width-2,Edit->top+19);
bool ShowItems=father->ShowItems && father->focus==handle;
if (Edit->Items[0]){
setcolor(BLACK);
rectangle(Edit->left+Edit->Width-3-15,Edit->top+3,Edit->left+Edit->Width-3,Edit->top+18);
if (ShowItems) setcolor(DARKGRAY);
line(Edit->left+Edit->Width-2-15,Edit->top+17,Edit->left+Edit->Width-4,Edit->top+17);
line(Edit->left+Edit->Width-4,Edit->top+4,Edit->left+Edit->Width-4,Edit->top+17);
setcolor(ShowItems?DARKGRAY:LIGHTGRAY);
line(Edit->left+Edit->Width-2-15,Edit->top+4,Edit->left+Edit->Width-2-15,Edit->top+16);
line(Edit->left+Edit->Width-2-15,Edit->top+4,Edit->left+Edit->Width-5,Edit->top+4);
setfillstyle(1,DARKGRAY);
bar(Edit->left+Edit->Width-1-15,Edit->top+5,Edit->left+Edit->Width-5,Edit->top+16);
setcolor(BLACK);
setfillstyle(1,BLACK);
if (ShowItems){
line(Edit->left+Edit->Width-2-15+3,Edit->top+3+5+1,Edit->left+Edit->Width-3-4,Edit->top+3+5+1);
line(Edit->left+Edit->Width-2-15+3,Edit->top+3+5+1,Edit->left+Edit->Width-11,Edit->top+14+1);
line(Edit->left+Edit->Width-3-4,Edit->top+3+5+1,Edit->left+Edit->Width-10,Edit->top+14+1);
floodfill(Edit->left+Edit->Width-2-15+3+2,Edit->top+3+5+2+1,BLACK);
} else {
line(Edit->left+Edit->Width-2-15+3,Edit->top+3+5,Edit->left+Edit->Width-3-4,Edit->top+3+5);
line(Edit->left+Edit->Width-2-15+3,Edit->top+3+5,Edit->left+Edit->Width-11,Edit->top+14);
line(Edit->left+Edit->Width-3-4,Edit->top+3+5,Edit->left+Edit->Width-10,Edit->top+14);
floodfill(Edit->left+Edit->Width-2-15+3+2,Edit->top+3+5+2,BLACK);
}
}
int i,j,k;
char buf[50];
int len=strlen(Edit->Text);
if (father->focus!=handle){
Edit->CurLocate=len<Edit->MaxChars?len:Edit->MaxChars;
Edit->Index=len;
}
if (Edit->Index==len) Edit->CurLocate=len<Edit->MaxChars?len:Edit->MaxChars;
if (Edit->Index>len) Edit->Index=len;
if (Edit->CurLocate>Edit->Index) Edit->CurLocate=Edit->Index;
for (i=0;i<Edit->Index;)
if (Edit->Text[i] & 128) i+=2;
else i++;
if (i!=Edit->Index) {
Edit->Index--;
if (Edit->CurLocate) Edit->CurLocate--;
}
if (len<=Edit->MaxChars) i=0,j=len;
else{
for (i=0;i<len;){
if (Edit->Index-Edit->CurLocate<=i) break;
if (Edit->Text[i] & 128) i+=2;
else i++;
}
for (j=0;j<Edit->MaxChars;){
if (Edit->Text[j+i] & 128)
j+=2;
else
j++;
}
if (j!=Edit->MaxChars) j--;
}
if (Edit->PasswordChar)
memset(buf,Edit->PasswordChar,sizeof buf);
else
strncpy(buf,Edit->Text+i,j);
Edit->CurLocate=Edit->Index-i;
buf[j]=0;
WriteText(buf,Edit->left+3,Edit->top+3,BLACK);
setviewport(0,0,MAXX,MAXY,0);
if (Edit->ShowCur) DrawCur(handle);
DrawMouse();
}
/*=================================*/
/* 绘制图标函数定义 */
/*=================================*/
void ShowIco(Hwnd handle){
if (handle==0) return;
pIco Ico=GetIco(handle);
pWindow father=GetWindow(Ico->father);
setviewport(father->left,father->top,
father->right,father->bottom,1);
DrawIco(Ico->IcoBuf,Ico->left,Ico->top);
setviewport(0,0,MAXX,MAXY,0);
}
/*=================================*/
/* 绘制标签函数定义 */
/*=================================*/
void DrawLabel(Hwnd handle){
if (handle==0) return;
pLabel Label=GetLabel(handle);
pWindow father=GetWindow(Label->father);
setviewport(father->left,father->top,
father->right,father->bottom,1);
WriteText(Label->Caption,Label->left,Label->top,Label->Color);
setviewport(0,0,MAXX,MAXY,0);
}
/*=================================*/
/* 绘制按钮函数定义 */
/*=================================*/
void DrawButton(Hwnd handle,bool checked=false){
if (handle==0) return;
pButton Button=GetButton(handle);
pWindow father=GetWindow(Button->father);
if (Button->Ico==CloseIco) { /*关闭按钮单独处理*/
setviewport(father->left+Button->left,father->top+Button->top,
father->left+Button->right,father->top+Button->bottom,1);
setcolor(WHITE);
line(0,1,0,16);
line(1,0,16,0);
line(17,1,17,16);
line(1,17,16,17);
DrawIco(CloseIco,1,1);
setviewport(0,0,MAXX,MAXY,0);
return;
}
setviewport(father->left,father->top,father->right,father->bottom,1);
setcolor(BLACK);
line(Button->left+3, Button->top, Button->right-3, Button->top);
line(Button->left, Button->top+3, Button->left, Button->bottom-3);
line(Button->left+3, Button->bottom, Button->right-3, Button->bottom);
line(Button->right, Button->top+3, Button->right, Button->bottom-3);
arc(Button->left+3, Button->top+3, 90, 180, 3);
arc(Button->right-3, Button->top+3, 0, 90, 3);
arc(Button->left+3, Button->bottom-3, 180, 270, 3);
arc(Button->right-3, Button->bottom-3, 270, 0, 3);
setcolor(checked?BLACK:WHITE);
line(Button->left+3, Button->top+1, Button->right-3, Button->top+1);
line(Button->left+1, Button->top+3, Button->left+1, Button->bottom-3);
arc(Button->left+3, Button->top+3, 90, 180, 2);
arc(Button->right-3, Button->top+3, 45, 90, 2);
arc(Button->left+3, Button->bottom-3, 180, 225, 2);
setcolor(checked?WHITE:BLACK);
line(Button->left+3, Button->bottom-1, Button->right-3, Button->bottom-1);
line(Button->right-1, Button->top+3, Button->right-1, Button->bottom-3);
arc(Button->left+3, Button->bottom-3, 225, 270, 2);
arc(Button->right-3, Button->bottom-3, 270, 0, 2);
arc(Button->right-3, Button->top+3, 0, 45, 2);
UseColor(LIGHTGRAY);
bar(Button->left+3,Button->top+3,Button->right-3,Button->bottom-3);
setviewport(father->left+Button->left,father->top+Button->top,
father->left+Button->right,father->top+Button->bottom,1);
int middlex=Button->Width/2+checked;
int middley=Button->Height/2+checked;
int len=strlen(Button->Caption)*8;
if (Button->Ico!=NULL){
len+=16;
DrawIco(Button->Ico,middlex-len/2-1,middley-8-1);
WriteText(Button->Caption,middlex-len/2+16,middley-8,BLACK);
} else{
WriteText(Button->Caption,middlex-len/2,middley-8,BLACK);
}
setviewport(0,0,MAXX,MAXY,0);
}
/*=================================*/
/* 绘制窗体函数定义 */
/*=================================*/
void DrawWindow(Hwnd handle){
if (handle==0) return;
DestroyMouse();
pWindow Window=GetWindow(handle);
UseColor(BLUE);
rectangle(Window->left+1, Window->top+4, Window->right-1, Window->bottom-1);
bar(Window->left+4, Window->top, Window->right-4, Window->top+3);
bar(Window->left+1, Window->top+4, Window->right-1, Window->top+21);
pieslice(Window->left+4, Window->top+4, 90, 180, 4);
pieslice(Window->right-4, Window->top+4, 0, 90, 4);
UseColor(Window->Color);
bar(Window->left+3, Window->top+22, Window->right-2, Window->bottom-2);
setcolor(WHITE);
line(Window->left,Window->top+4,Window->left,Window->bottom-1);
line(Window->left+4,Window->top,Window->right-4,Window->top);
arc(Window->left+4, Window->top+4, 90, 180, 4);
setcolor(BLACK);
line(Window->left+1,Window->bottom,Window->right,Window->bottom);
line(Window->right,Window->top+3,Window->right,Window->bottom-1);
setcolor(BLUE);
line(Window->left+2,Window->top+22, Window->left+2,Window->bottom-2);
if (Window->Ico!=NULL)
DrawIco(Window->Ico,Window->left+3,Window->top+3);
WriteText(Window->Caption,Window->left+21, Window->top+3,WHITE);
handle=Window->FirstButton; /*绘制该窗体上所有按钮*/
while (handle){
DrawButton(handle);
handle=NextButton(handle);
}
handle=Window->FirstLabel; /*绘制该窗体上所有标签*/
while (handle){
DrawLabel(handle);
handle=NextLabel(handle);
}
handle=Window->FirstIco; /*绘制该窗体上所有图标*/
while (handle){
ShowIco(handle);
handle=NextIco(handle);
}
if (Window->FirstList)
DrawList(Window->FirstList); /*绘制窗体上的列表框*/
handle=Window->FirstEdit; /*绘制该窗体上所有编辑框*/
while (handle){
DrawEdit(handle);
handle=NextEdit(handle);
}
if (Window->ShowItems) DrawItems();
if (!Window->Drawed) push(Window->handle);
Window->Drawed=true;
DrawMouse();
}
void ShowWindow(Hwnd handle){
if (!handle) return;
if (GetWindow(handle)->Showed) return;
DrawWindow(handle);
GetWindow(handle)->Showed=true;
}
/*=================================*/
/* 隐藏窗体函数定义 */
/*=================================*/
void HideWindow(Hwnd handle,int x1=-1,int y1=0,int x2=0,int y2=0,int p=0){
if (handle==0) { /*最顶层*/
DestroyMouse();
DrawDesktop();
DrawMouse();
return;
}
pWindow Window=GetWindow(handle);
if (x1>=0){
if (x1<Window->left || x2>Window->right
|| y1<Window->top || y2>Window->bottom)
HideWindow(WndStack[p-1],x1,y1,x2,y2,p-1); /*继续递归恢复上级窗体*/
DrawWindow(handle);
} else {
if (!Window->Drawed) return;
HideWindow(WndStack[pStack-2],Window->left,Window->top,Window->right,Window->bottom,pStack-2);
Window->Drawed=false;
pop;
}
}
/*=================================*/
/* 移动窗体函数定义 */
/*=================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -