view xaim/buttons.c @ 0:5242703e91d3 tip

Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author tomwalters
date Fri, 20 May 2011 15:19:45 +0100
parents
children
line wrap: on
line source
/*
    Copyright (c) Applied Psychology Unit, Medical Research Council. 1993
    ===========================================================================

    Permission to use, copy, modify, and distribute this software without fee 
    is hereby granted for research purposes, provided that this copyright 
    notice appears in all copies and in all supporting documentation, and that 
    the software is not redistributed for any fee (except for a nominal 
    shipping charge). Anyone wanting to incorporate all or part of this 
    software in a commercial product must obtain a license from the Medical 
    Research Council.

    The MRC makes no representations about the suitability of this 
    software for any purpose.  It is provided "as is" without express or 
    implied warranty.
 
    THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 
    THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES 
    OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 
    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 
    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 
    SOFTWARE.
*/
/* 
*   buttons.c
*   ---------
*  Defines the size, position, and input-option-possibilites of the buttons
*  that appear on the Controls Window.
*
*  M. Akeroyd.  July 1993. version 1.10
*  Revisions: MAA: Christmas 1993. 
*
*/



#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
#include <stdio.h>

#include "xreview.h"




/* X .......................*/

extern Display *display;
extern int screen_num;
extern Screen *screen_ptr;

extern toplevelWindow control;
extern Pixmap stipple_pixmap;

extern buttonWindow button_quit, button_close;
extern buttonWindow button_animate;
extern buttonWindow button_startf, button_startb, button_stopf, button_stopb;
extern buttonWindow button_skipf, button_skipb, button_faster, button_slower;
extern buttonWindow button_firstframe, button_lastframe, button_middle;
extern buttonWindow button_stepf, button_stepff, button_stepb, button_stepbb;

extern buttonWindow info_speed, info_start, info_stop, info_skip;
extern buttonWindow info_title, info_frame;
extern buttonWindow info_time, info_freq, info_frstep;

extern GC button_gc;
extern XFontStruct *font_info;

extern int button_borderwidth ;


/* Command line .............*/

extern double scale;                /* scale factor of Controls Window size */






/*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/





Window create_button(int x, int y, int width, int height)
{
  return (Window) XCreateSimpleWindow(display, control.win, \
				      x, y, width, height, \
				      button_borderwidth, \
				      BlackPixel(display, screen_num),\
				      WhitePixel(display, screen_num));
}






/*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/





void initialise_buttons()
{
  button_gc = XCreateGC(display, RootWindow(display, screen_num),\
			control.valuemask, &control.values);
  XSetForeground(display, button_gc, BlackPixel(display, screen_num));
  XSetFillStyle(display, button_gc, FillSolid);
  XSetFont(display, button_gc, font_info->fid);

/*------------------------------*/
/* Button Positions: all relative to top-left Controls corner. 
*  All in pixels */

  button_quit.x       =  20 * scale; button_quit.y       = 10 * scale; 
  button_close.x      =  20 * scale; button_close.y      = 44 * scale;

  button_animate.x    = 500 * scale; button_animate.y    = 90 * scale; 
  button_startf.x     =  64 * scale; button_startf.y     = 124 * scale;  
  button_startb.x     =  14 * scale; button_startb.y     = 124 * scale;  
  button_stopf.x      = 184 * scale; button_stopf.y      = 124 * scale;  
  button_stopb.x      = 134 * scale; button_stopb.y      = 124 * scale;  
  button_skipf.x      = 304 * scale; button_skipf.y      = 124 * scale;  
  button_skipb.x      = 254 * scale; button_skipb.y      = 124 * scale;  
  button_faster.x     = 372 * scale; button_faster.y     = 124 * scale; 
  button_slower.x     = 422 * scale; button_slower.y     = 124 * scale; 

  button_firstframe.x =  10 * scale; button_firstframe.y = 174 * scale; 
  button_stepbb.x     =  80 * scale; button_stepbb.y     = 174 * scale; 
  button_stepb.x      = 150 * scale; button_stepb.y      = 174 * scale; 
  button_middle.x     = 220 * scale; button_middle.y     = 174 * scale; 
  button_stepf.x      = 290 * scale; button_stepf.y      = 174 * scale; 
  button_stepff.x     = 360 * scale; button_stepff.y     = 174 * scale; 
  button_lastframe.x  = 430 * scale; button_lastframe.y  = 174 * scale; 

/* Button sizes: also in pixels */

  button_quit.width       =  60 * scale; button_quit.height      = 25 * scale; 
  button_close.width      =  60 * scale; button_close.height     = 25 * scale;
  button_animate.width    = 100 * scale; button_animate.height   = 60 * scale; 
  button_startf.width     =  40 * scale; button_startf.height    = 25 * scale; 
  button_startb.width     =  40 * scale; button_startb.height    = 25 * scale; 
  button_stopf.width      =  40 * scale; button_stopf.height     = 25 * scale; 
  button_stopb.width      =  40 * scale; button_stopb.height     = 25 * scale; 
  button_skipf.width      =  40 * scale; button_skipf.height     = 25 * scale; 
  button_skipb.width      =  40 * scale; button_skipb.height     = 25 * scale;
  button_faster.width     = 45 * scale; button_faster.height     = 25 * scale;
  button_slower.width     = 45 * scale; button_slower.height     = 25 * scale; 
  button_lastframe.width  = 60 * scale; button_lastframe.height  = 25 *scale; 
  button_firstframe.width = 60 * scale; button_firstframe.height = 25 *scale; 
  button_middle.width     = 60 * scale; button_middle.height     = 25 * scale; 
  button_stepf.width      = 60 * scale; button_stepf.height      = 25 * scale; 
  button_stepff.width     = 60 * scale; button_stepff.height     = 25 * scale; 
  button_stepb.width      = 60 * scale; button_stepb.height      = 25 * scale; 
  button_stepbb.width     = 60 * scale; button_stepbb.height     = 25 * scale; 

/*------------------------------*/
/* make the things */

  button_quit.win = create_button(button_quit.x, button_quit.y, \
				  button_quit.width, button_quit.height);
  button_close.win = create_button(button_close.x, button_close.y, \
				   button_close.width, button_close.height);
  button_animate.win = create_button(button_animate.x, button_animate.y, \
			         button_animate.width, button_animate.height);
  button_startf.win = create_button(button_startf.x, button_startf.y, \
             		         button_startf.width, button_startf.height);
  button_startb.win = create_button(button_startb.x, button_startb.y, \
				 button_startb.width, button_startb.height);
  button_stopf.win = create_button(button_stopf.x, button_stopf.y, \
				   button_stopf.width, button_stopf.height);
  button_stopb.win = create_button(button_stopb.x, button_stopb.y, \
				   button_stopb.width, button_stopb.height);
  button_skipf.win = create_button(button_skipf.x, button_skipf.y, \
				   button_skipf.width, button_skipf.height);
  button_skipb.win = create_button(button_skipb.x, button_skipb.y, \
				   button_skipb.width, button_skipb.height);
  button_faster.win = create_button(button_faster.x, button_faster.y, \
				  button_faster.width, button_faster.height);
  button_slower.win = create_button(button_slower.x, button_slower.y, \
				  button_slower.width, button_slower.height);
  button_lastframe.win =create_button(button_lastframe.x, button_lastframe.y,\
		             button_lastframe.width, button_lastframe.height);
  button_firstframe.win=create_button(button_firstframe.x,button_firstframe.y,\
			   button_firstframe.width, button_firstframe.height);
  button_middle.win =create_button(button_middle.x, button_middle.y, \
		             button_middle.width, button_middle.height);
  button_stepf.win = create_button(button_stepf.x, button_stepf.y, \
				   button_stepf.width, button_stepf.height);
  button_stepff.win = create_button(button_stepff.x, button_stepff.y, \
				   button_stepff.width, button_stepff.height);
  button_stepb.win = create_button(button_stepb.x, button_stepb.y, \
				   button_stepb.width, button_stepb.height);
  button_stepbb.win = create_button(button_stepbb.x, button_stepbb.y, \
				   button_stepbb.width, button_stepbb.height);

/*---------------------------*/
/* Info positions and sizes. */

  info_speed.x  = 370 * scale; info_speed.y  = 94 * scale;
  info_start.x  =  10 * scale; info_start.y  = 94 * scale;
  info_stop.x   = 130 * scale; info_stop.y   = 94 * scale;
  info_skip.x   = 250 * scale; info_skip.y   = 94 * scale;
  info_frame.x  = 500 * scale; info_frame.y  = 174 * scale;
  info_title.x  = 100 * scale; info_title.y  = 10 * scale;
  info_freq.x   = 100 * scale; info_freq.y   = 44 * scale;
  info_time.x   = 275 * scale; info_time.y   = 44 * scale;
  info_frstep.x = 475 * scale; info_frstep.y = 44 * scale;

  info_speed.width  = 100 * scale; info_speed.height  = 25 * scale;
  info_start.width  = 100 * scale; info_start.height  = 25 * scale;
  info_stop.width   = 100 * scale; info_stop.height   = 25 * scale;
  info_skip.width   = 100 * scale; info_skip.height   = 25 * scale;
  info_frame.width  = 100 * scale; info_frame.height  = 25 * scale;
  info_title.width  = 500 * scale; info_title.height  = 25 * scale;
  info_freq.width   = 175 * scale; info_freq.height   = 25 * scale;
  info_time.width   = 175 * scale; info_time.height   = 25 * scale;
  info_frstep.width = 115 * scale; info_frstep.height = 25 * scale;

  info_speed.win = create_button(info_speed.x, info_speed.y, \
				 info_speed.width, info_speed.height);
  info_start.win = create_button(info_start.x, info_start.y, \
				 info_start.width, info_start.height);
  info_stop.win = create_button(info_stop.x, info_stop.y, \
				info_stop.width, info_stop.height);
  info_skip.win = create_button(info_skip.x, info_skip.y, \
				info_skip.width, info_skip.height);
  info_frame.win = create_button(info_frame.x, info_frame.y, \
				 info_frame.width, info_frame.height);
  info_title.win = create_button(info_title.x, info_title.y, \
				 info_title.width, info_title.height);
  info_freq.win = create_button(info_freq.x, info_freq.y, \
				info_freq.width, info_freq.height);
  info_time.win = create_button(info_time.x, info_time.y, \
				info_time.width, info_time.height);
  info_frstep.win = create_button(info_frstep.x, info_frstep.y, \
				  info_frstep.width, info_frstep.height);
  
  
/*------------------------------*/
/* Define the allowed inputs to the buttons.
*/
  XSelectInput(display, button_quit.win, ButtonPressMask );
  XSelectInput(display, button_close.win, ButtonPressMask );
  XSelectInput(display, button_animate.win, ButtonPressMask );
  XSelectInput(display, button_startf.win, ButtonPressMask );
  XSelectInput(display, button_startb.win, ButtonPressMask );
  XSelectInput(display, button_stopf.win, ButtonPressMask );
  XSelectInput(display, button_stopb.win, ButtonPressMask );
  XSelectInput(display, button_skipf.win, ButtonPressMask );
  XSelectInput(display, button_skipb.win, ButtonPressMask );
  XSelectInput(display, button_faster.win, ButtonPressMask );
  XSelectInput(display, button_slower.win, ButtonPressMask );
  XSelectInput(display, button_lastframe.win, ButtonPressMask );
  XSelectInput(display, button_firstframe.win, ButtonPressMask );
  XSelectInput(display, button_middle.win, ButtonPressMask );
  XSelectInput(display, button_stepf.win, ButtonPressMask );
  XSelectInput(display, button_stepff.win, ButtonPressMask );
  XSelectInput(display, button_stepb.win, ButtonPressMask );
  XSelectInput(display, button_stepbb.win, ButtonPressMask );

  XSelectInput(display, info_speed.win, ButtonPressMask);
  XSelectInput(display, info_start.win, ButtonPressMask);
  XSelectInput(display, info_stop.win, ButtonPressMask);
  XSelectInput(display, info_skip.win, ButtonPressMask);
  XSelectInput(display, info_frame.win, ButtonPressMask);
  XSelectInput(display, info_title.win, ButtonPressMask);
  XSelectInput(display, info_freq.win, ButtonPressMask);
  XSelectInput(display, info_time.win, ButtonPressMask);
  XSelectInput(display, info_frstep.win, ButtonPressMask);

/* Define the backgrounds. */

  XSetWindowBackgroundPixmap(display, button_quit.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_close.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_animate.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_startf.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_startb.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_stopf.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_stopb.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_skipf.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_skipb.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_faster.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_slower.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_lastframe.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_firstframe.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_middle.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_stepf.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_stepff.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_stepb.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, button_stepbb.win, stipple_pixmap);

  XSetWindowBackgroundPixmap(display, info_speed.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_start.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_stop.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_skip.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_frame.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_title.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_freq.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_time.win, stipple_pixmap);
  XSetWindowBackgroundPixmap(display, info_frstep.win, stipple_pixmap);
}




/* The End */
/*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------*/