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

📄 buttons.c

📁 linux下将各类格式图片转换工具
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  buttons.c:		Draw MWFA player buttons in X11 window	 * *  Written by:		Ullrich Hafner *		 *  This file is part of FIASCO (獸籸actal 獻籱age 獳籲d 玈籩quence 獵O籨ec) *  Copyright (C) 1994-2000 Ullrich Hafner <hafner@bigfoot.de> *//* *  $Date: 2000/06/15 17:23:11 $ *  $Author: hafner $ *  $Revision: 5.2 $ *  $State: Exp $ */#include "config.h"#ifndef X_DISPLAY_MISSING#include <X11/Xlib.h>#include <X11/Intrinsic.h>#include <X11/StringDefs.h>#if STDC_HEADERS#	include <stdlib.h>#endif /* not STDC_HEADERS */#include "types.h"#include "macros.h"#include "display.h"#include "binerror.h"#include "buttons.h"/*****************************************************************************			     local variables  *****************************************************************************/static const int EVENT_MASK = (KeyPressMask | ButtonPressMask |			       ButtonReleaseMask | ExposureMask);/*****************************************************************************				prototypes  *****************************************************************************/static voiddraw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n,		   unsigned n_frames);static voiddraw_button (x11_info_t *xinfo, binfo_t *binfo,	     buttons_t button, bool_t pressed);static voiddraw_control_panel (x11_info_t *xinfo, binfo_t *binfo,		    unsigned n, unsigned n_frames);/*****************************************************************************				public code  *****************************************************************************/binfo_t * init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames,	      unsigned buttons_height, unsigned progbar_height)/* *  Initialize a toolbar with the typical collection of video player *  buttons (pause, play, record, next, etc.) in the window given by 'xinfo'. *  'n' gives the current frame, 'whereas' n_frames is the total number of *  frames of the video stream. *  The size of the button toolbar is given by 'buttons_height', *  the size of the progressbar is given by 'progbar_height'. * *  Return value: *	struct managing the toolbar and progressbar information */{   XGCValues  values;   XEvent     event;   Colormap   cmap;   XColor     gray, dgray, lgray, red;   XColor     graye, dgraye, lgraye, rede;   buttons_t  button;			/* counter */   binfo_t   *binfo = calloc (1, sizeof (binfo_t));   if (!binfo)      error ("Out of memory.");      binfo->width            = xinfo->ximage->width;   binfo->height           = buttons_height;   binfo->progbar_height   = progbar_height;   binfo->record_is_rewind = NO;   /*    *  Generate sub-window for control panel    */   binfo->window = XCreateSimpleWindow (xinfo->display, xinfo->window,					0, xinfo->ximage->height,					binfo->width, binfo->height, 0,					BlackPixel (xinfo->display,						    xinfo->screen),					WhitePixel (xinfo->display,						    xinfo->screen));   XSelectInput(xinfo->display, binfo->window, StructureNotifyMask);   XMapWindow (xinfo->display, binfo->window);   do   {      XNextEvent (xinfo->display, &event);   }   while (event.type != MapNotify || event.xmap.event != binfo->window);   XSelectInput (xinfo->display, binfo->window, EVENT_MASK);   /*    *  Generate graphic contexts for different colors.    */   cmap = DefaultColormap (xinfo->display, xinfo->screen);   XAllocNamedColor (xinfo->display, cmap, "#404040", &dgray, &dgraye);   XAllocNamedColor (xinfo->display, cmap, "white", &lgray, &lgraye);   XAllocNamedColor (xinfo->display, cmap, "#a8a8a8", &gray, &graye);   XAllocNamedColor (xinfo->display, cmap, "red", &red, &rede);      values.foreground = BlackPixel (xinfo->display, xinfo->screen);   values.background = WhitePixel (xinfo->display, xinfo->screen);   binfo->gc [BLACK] = XCreateGC (xinfo->display,				  RootWindow (xinfo->display, xinfo->screen),				  (GCForeground | GCBackground), &values);   values.foreground = BlackPixel (xinfo->display, xinfo->screen);   values.background = WhitePixel (xinfo->display, xinfo->screen);   values.line_width = 3;   values.join_style = JoinRound;   binfo->gc [THICKBLACK] = XCreateGC (xinfo->display,				       RootWindow (xinfo->display,						   xinfo->screen),				       (GCForeground | GCBackground					| GCLineWidth | GCJoinStyle), &values);   values.foreground = gray.pixel;   values.background = WhitePixel (xinfo->display, xinfo->screen);   binfo->gc [NGRAY] = XCreateGC (xinfo->display,				  RootWindow (xinfo->display, xinfo->screen),				  (GCForeground | GCBackground), &values);   values.foreground = lgray.pixel;   values.background = WhitePixel (xinfo->display, xinfo->screen);   binfo->gc [LGRAY] = XCreateGC (xinfo->display,				  RootWindow (xinfo->display, xinfo->screen),				  (GCForeground | GCBackground), &values);   values.foreground = dgray.pixel;   values.background = WhitePixel (xinfo->display, xinfo->screen);   binfo->gc [DGRAY] = XCreateGC (xinfo->display,				  RootWindow (xinfo->display, xinfo->screen),				  (GCForeground | GCBackground), &values);   values.foreground = red.pixel;   values.background = WhitePixel (xinfo->display, xinfo->screen);   binfo->gc [RED]   = XCreateGC (xinfo->display,				  RootWindow (xinfo->display, xinfo->screen),				  (GCForeground | GCBackground), &values);   for (button = 0; button < NO_BUTTON; button++)      binfo->pressed [button] = NO;   draw_control_panel (xinfo, binfo, n, n_frames);       return binfo;}voidwait_for_input (x11_info_t *xinfo)/* *  Wait for key press or mouse click in window 'xinfo'. *  Redraw 'image' if event other then ButtonPress or KeyPress occurs. *  Enlarge or reduce size of image by factor 2^'enlarge_factor'. * *  No return value. * *  Side effect: *	program is terminated after key press or mouse click. */{   bool_t leave_loop = NO;      XSelectInput (xinfo->display, xinfo->window, EVENT_MASK);   while (!leave_loop)   {      XEvent event;      XMaskEvent (xinfo->display, EVENT_MASK, &event);      switch (event.type)      {	 case ButtonPress:	 case KeyPress:	    leave_loop = YES;	    break;	 default:	    display_image (0, 0, xinfo);	    break;      }   }}voidcheck_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames)/* *  Check the X11 event loop. If the PAUSE buttonin the of panel 'binfo' *  is activated wait until next event occurs. *  Redraw 'image' if event other then ButtonPress or ButtonRelease occurs. *  Enlarge or reduce size of image by factor 2^'enlarge_factor'. *  'n' gives the current frame, 'whereas' n_frames is the total number of *  frames of the video stream. * *  No return values. * *  Side effects: *	status of buttons (binfo->pressed [button]) is changed accordingly. */{   bool_t leave_eventloop;   leave_eventloop = (!binfo->pressed [PAUSE_BUTTON]		      && binfo->pressed [PLAY_BUTTON])		     || (!binfo->pressed [PAUSE_BUTTON]			 && binfo->record_is_rewind			 && binfo->pressed [RECORD_BUTTON])		     || binfo->pressed [RECORD_BUTTON];   draw_progress_bar (xinfo, binfo, n, n_frames);   if (binfo->pressed [PAUSE_BUTTON] && binfo->pressed [PLAY_BUTTON])   {      XFlush (xinfo->display);      draw_button (xinfo, binfo, PLAY_BUTTON, NO); /* clear PLAY mode */      XFlush (xinfo->display);   }   if (binfo->pressed [PAUSE_BUTTON]       && binfo->record_is_rewind && binfo->pressed [RECORD_BUTTON])   {      XFlush (xinfo->display);      draw_button (xinfo, binfo, RECORD_BUTTON, NO); /* clear PLAY mode */      XFlush (xinfo->display);   }   if (binfo->pressed [STOP_BUTTON])   {      XFlush (xinfo->display);      draw_button (xinfo, binfo, STOP_BUTTON, NO); /* clear STOP button */      XFlush (xinfo->display);   }   do   {      XEvent event;      int    button;      bool_t wait_release = NO;	 

⌨️ 快捷键说明

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