⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buttons.c

📁 linux下将各类格式图片转换工具
💻 C
📖 第 1 页 / 共 2 页
字号:
            if (XCheckMaskEvent (xinfo->display, EVENT_MASK, &event))      {	 switch (event.type)	 {	    case ButtonPress:	       wait_release = NO;	       if (!(binfo->pressed [RECORD_BUTTON] &&		     !binfo->record_is_rewind))		  for (button = 0; button < NO_BUTTON; button++)		  {		     int x0, y0, x1, y1; /* button coordinates */		  		     x0 = button * (binfo->width / NO_BUTTON);		     y0 = binfo->progbar_height;		     x1 = x0 + binfo->width / NO_BUTTON;		     y1 = y0 + binfo->height - binfo->progbar_height - 1;		     if (event.xbutton.x > x0 && event.xbutton.x < x1			 && event.xbutton.y > y0 && event.xbutton.y < y1) 		     {			draw_button (xinfo, binfo, button,				     !binfo->pressed [button]);			wait_release = YES;			break;		     }		  }	       break;	    case ButtonRelease:	       wait_release = NO;	       break;	    default:	       wait_release = NO;	       draw_control_panel (xinfo, binfo, n, n_frames);	       display_image (0, 0, xinfo);	       break;	 }	 leave_eventloop = !wait_release			   && (binfo->pressed [PLAY_BUTTON]			       || binfo->pressed [STOP_BUTTON]			       || binfo->pressed [RECORD_BUTTON]			       || binfo->pressed [QUIT_BUTTON]);      }   } while (!leave_eventloop);   if ((binfo->pressed [RECORD_BUTTON] && !binfo->record_is_rewind)       && n == n_frames - 1)   {      binfo->record_is_rewind = YES;      draw_button (xinfo, binfo, RECORD_BUTTON, NO);   }}/*****************************************************************************				private code  *****************************************************************************/static voiddraw_control_panel (x11_info_t *xinfo, binfo_t *binfo,		    unsigned n, unsigned n_frames)/* *  Draw control panel 'binfo' with all buttons and progressbar in *  the given 'window'. *  'n' gives the current frame, 'whereas' n_frames is the total number of *  frames of the video stream. * *  No return value. */{   buttons_t button;      XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],		   0, 0, binfo->width, binfo->height);   draw_progress_bar (xinfo, binfo, n, n_frames);   for (button = 0; button < NO_BUTTON; button++)      draw_button (xinfo, binfo, button, binfo->pressed [button]);}static voiddraw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n,		   unsigned n_frames)/* *  Draw progressbar of control panel 'binfo' in the given 'window'. *  'n' gives the current frame, whereas 'n_frames' is the total number of *  frames of the video stream. * *  No return value. */{   unsigned x, y, width, height;   x 	  = 2;   y 	  = 1;   width  = binfo->width - 5;   height = binfo->progbar_height - 3;      XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY],	      x, y, x + width, y);   XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY],	      x, y, x, y + height - 1);   XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY],	      x + width, y + 1, x + width, y + height);   XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY],	      x, y + height, x + width, y + height);   x++; y++; width  -= 2; height -= 2;   XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],		   x, y, width, height);   XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],		   x + n * max (1, width / n_frames), y,		   max (1, width / n_frames), height);}static voiddraw_button (x11_info_t *xinfo, binfo_t *binfo,	     buttons_t button, bool_t pressed)/* *  Draw 'button' of control panel 'binfo' in the given 'window'. *  'pressed' indicates whether the button is pressed or not. * *  No return value. */{   grayscale_t top, bottom;		/* index of GC */   unsigned    x, y, width, height;	/* coordinates of button */      x 	  = button * (binfo->width / NO_BUTTON);   y 	  = binfo->progbar_height;   width  = binfo->width / NO_BUTTON;   height = binfo->height - binfo->progbar_height - 1;      if (width < 4 || height < 4)      return;      if (pressed)   {      top    = DGRAY;      bottom = LGRAY;   }   else   {      top    = LGRAY;      bottom = DGRAY;   }   x 	 += 2;   width -= 4;      XDrawLine (xinfo->display, binfo->window, binfo->gc [top],	      x, y, x + width, y);   XDrawLine (xinfo->display, binfo->window, binfo->gc [top],	      x, y, x, y + height - 1);   XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom],	      x + width, y + 1, x + width, y + height);   XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom],	      x, y + height, x + width, y + height);   x++; y++; width  -= 2; height -= 2;   XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY],		   x, y, width, height);   switch (button)   {      case STOP_BUTTON:	 XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],			 x + width / 2 - 6, y + height / 2 - 4, 11, 11);	 if (pressed && !binfo->pressed [STOP_BUTTON])	 {	    draw_button (xinfo, binfo, PLAY_BUTTON, NO);	    draw_button (xinfo, binfo, PAUSE_BUTTON, NO); 	    draw_button (xinfo, binfo, RECORD_BUTTON, NO); 	 }	 break;      case PAUSE_BUTTON:	 XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],			 x + width / 2 - 6, y + height / 2 - 4, 5, 11);	 XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],			 x + width / 2 + 1, y + height / 2 - 4, 5, 11);	 break;      case PLAY_BUTTON:	 {	    XPoint triangle [3];	    triangle [0].x = x + width / 2 - 5;	    triangle [0].y = y + height / 2 - 5;	    triangle [1].x = 10;	    triangle [1].y = 6;	    triangle [2].x = -10;	    triangle [2].y = 6;	    XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],			  triangle, 3, Convex, CoordModePrevious);	    if (pressed && !binfo->pressed [PLAY_BUTTON]		&& binfo->pressed [RECORD_BUTTON])	       draw_button (xinfo, binfo, RECORD_BUTTON, NO);	 }	 break;      case RECORD_BUTTON:	 if (!binfo->record_is_rewind)	 {	    XFillArc (xinfo->display, binfo->window, binfo->gc [RED],		      x + width / 2 - 5, y + height / 2 - 5, 11, 11, 0,		      360 * 64);	    if (pressed && !binfo->pressed [RECORD_BUTTON])	    {	       draw_button (xinfo, binfo, STOP_BUTTON, YES);	       draw_button (xinfo, binfo, PLAY_BUTTON, NO);	       draw_button (xinfo, binfo, PAUSE_BUTTON, NO); 	    }	 }	 else	 {	    XPoint triangle [3];	    triangle [0].x = x + width / 2 + 5;	    triangle [0].y = y + height / 2 - 5;	    triangle [1].x = -10;	    triangle [1].y = 6;	    triangle [2].x = 10;	    triangle [2].y = 6;	    XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],			  triangle, 3, Convex, CoordModePrevious);	    if (pressed && !binfo->pressed [RECORD_BUTTON]		&& binfo->pressed [PLAY_BUTTON])	       draw_button (xinfo, binfo, PLAY_BUTTON, NO);	 }	 break;      case QUIT_BUTTON:	 {	    XPoint triangle [3];	    triangle [0].x = x + width / 2 - 6;	    triangle [0].y = y + height / 2 + 2;	    triangle [1].x = 6;	    triangle [1].y = -7;	    triangle [2].x = 6;	    triangle [2].y = 7;	    XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK],			  triangle, 3, Convex, CoordModePrevious);	    XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK],			    x + width / 2 - 5, y + height / 2 + 4, 11, 3);	 }	 break;      default:	 break;   }   binfo->pressed [button] = pressed;}#endif /* not X_DISPLAY_MISSING */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -