static int init_mode(int mode) { int oldcols=vstat.cols; int oldwidth=bitmap_width; int oldheight=bitmap_height; bitmap_init_mode(mode, &bitmap_width, &bitmap_height); /* Deal with 40 col doubling */ if(oldcols != vstat.cols) { if(oldcols == 40) vstat.scaling /= 2; if(vstat.cols == 40) vstat.scaling *= 2; } if(vstat.scaling < 1) vstat.scaling = 1; map_window(); /* Resize window if necessary. */ if((!(bitmap_width == 0 && bitmap_height == 0)) && (oldwidth != bitmap_width || oldheight != bitmap_height)) resize_window(); send_rectangle(0,0,bitmap_width,bitmap_height,TRUE); sem_post(&mode_set); return(0); }
static void handle_resize_event(int width, int height) { int newFSH=1; int newFSW=1; // No change if((width == vstat.charwidth * vstat.cols * vstat.scaling) && (height == vstat.charheight * vstat.rows * vstat.scaling)) return; newFSH=width/bitmap_width; newFSW=height/bitmap_height; if(newFSW<1) newFSW=1; if(newFSH<1) newFSH=1; if(newFSH<newFSW) vstat.scaling=newFSH; else vstat.scaling=newFSW; if(vstat.scaling > 16) vstat.scaling=16; /* * We only need to resize if the width/height are not even multiples * Otherwise, we can simply resend everything */ if((width % (vstat.charwidth * vstat.cols) != 0) || (height % (vstat.charheight * vstat.rows) != 0)) resize_window(); send_rectangle(0,0,bitmap_width,bitmap_height,TRUE); }
/* * Actually maps (shows) the window */ static void map_window() { XSizeHints *sh; sh = x11.XAllocSizeHints(); if (sh == NULL) { fprintf(stderr, "Could not get XSizeHints structure"); exit(1); } sh->base_width = bitmap_width*vstat.scaling; sh->base_height = bitmap_height*vstat.scaling; sh->min_width = sh->width_inc = sh->min_aspect.x = sh->max_aspect.x = bitmap_width; sh->min_height = sh->height_inc = sh->min_aspect.y = sh->max_aspect.y = bitmap_height; sh->flags = USSize | PMinSize | PSize | PResizeInc | PAspect; x11.XSetWMNormalHints(dpy, win, sh); x11.XMapWindow(dpy, win); x11.XFree(sh); send_rectangle(0,0,bitmap_width,bitmap_height,TRUE); return; }
/****************************************************************************** * 函数名:send_h_StepBar * 入口参数: * 出口参数:无 * 返回值:无 * 说明:显示水平进度条 ******************************************************************************/ void send_h_StepBar(unsigned char x, unsigned char y, unsigned char ucWidth,unsigned char BarWidth) { //清空显示区域 // clear_block(x,16,119,63); //显示一个边框 // send_rectangle(x,y,112-x,y+8); send_rectangle(x,y,BarWidth-x,y+7); y += 1; send_line_h(x,y,ucWidth,PIXEL_SET); send_line_h(x,y+1,ucWidth,PIXEL_SET); send_line_h(x,y+2,ucWidth,PIXEL_SET); send_line_h(x,y+3,ucWidth,PIXEL_SET); send_line_h(x,y+4,ucWidth,PIXEL_SET); send_line_h(x,y+5,ucWidth,PIXEL_SET); }
static void expose_rect(x,y,width,height) { int sx,sy,ex,ey; sx=x/vstat.scaling; sy=y/vstat.scaling; ex=x+width-1; ey=y+height-1; if((ex+1)%vstat.scaling) { ex += vstat.scaling-(ex%vstat.scaling); } if((ey+1)%vstat.scaling) { ey += vstat.scaling-(ey%vstat.scaling); } ex=ex/vstat.scaling; ey=ey/vstat.scaling; send_rectangle(sx, sy, ex-sx+1, ey-sy+1, TRUE); }