diff xaim/switch_control.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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xaim/switch_control.c	Fri May 20 15:19:45 2011 +0100
@@ -0,0 +1,267 @@
+/*
+    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.
+*/
+
+/* 
+*   switch_control.c
+*   ----------------
+*  the 'switch' for 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"
+
+
+/* General ..................*/
+
+char progname[MAX_STRING_LENGTH];
+
+
+/* X ........................*/
+
+extern Display *display;
+extern int screen_num;
+extern Screen *screen_ptr;
+
+extern toplevelWindow control;
+extern toplevelWindow axes;
+
+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 XFontStruct *font_info;
+extern GC button_gc;
+extern XEvent report;
+
+extern int button_borderwidth;
+
+
+/* .ctn .......................*/
+
+extern int frame;
+extern int no_frames;
+extern double frstep_aid;
+extern double pwidth; 
+extern double nwidth; 
+extern int mincf;
+extern int maxcf;     
+
+extern int waittime_millisecs;
+extern int animate_start;
+extern int animate_stop;
+extern int animate_skip;
+
+
+/* Command line ...............*/
+extern double scale;
+
+
+
+
+
+/*-----------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------*/
+
+
+
+
+void switch_control()
+{
+  char tempstring[MAX_STRING_LENGTH];
+  int whitepixel = WhitePixel(display, screen_num);
+  int blackpixel = BlackPixel(display, screen_num);
+
+  
+  switch(report.type) {
+    
+/*----------------------------------*/
+    
+  case Expose:
+    if (report.xexpose.count != 0)
+      break;
+
+    if ((control.window_size == TOO_SMALL_X) ||
+	(control.window_size == TOO_BIG_X))
+      break;
+
+    XDrawLine(display, control.win, control.gc, \
+	      0, 80*scale, control.width, 80*scale);
+    XDrawLine(display, control.win, control.gc, \
+	      0, 162*scale, control.width, 162*scale);
+    
+    XMapWindow(display, button_quit.win);
+    XMapWindow(display, button_close.win);
+    XMapWindow(display, button_animate.win);
+    XMapWindow(display, button_startf.win);
+    XMapWindow(display, button_startb.win);
+    XMapWindow(display, button_stopf.win);
+    XMapWindow(display, button_stopb.win);
+    XMapWindow(display, button_skipf.win);
+    XMapWindow(display, button_skipb.win);
+    XMapWindow(display, button_faster.win);
+    XMapWindow(display, button_slower.win);
+    XMapWindow(display, button_lastframe.win);
+    XMapWindow(display, button_firstframe.win);
+    XMapWindow(display, button_middle.win);
+    XMapWindow(display, button_stepf.win);
+    XMapWindow(display, button_stepff.win);
+    XMapWindow(display, button_stepb.win);
+    XMapWindow(display, button_stepbb.win);
+
+    drawbutton(control, button_quit, &button_gc, "Quit",\
+	       whitepixel, blackpixel);
+    drawbutton(control, button_close, &button_gc, "Close", \
+	       whitepixel, blackpixel);
+
+    drawbutton(control, button_animate, &button_gc, "Animate", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_startf, &button_gc, "+1", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_startb, &button_gc, "-1", \
+	       whitepixel,  blackpixel);
+    drawbutton(control, button_stopf, &button_gc, "+1", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_stopb, &button_gc, "-1", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_skipf, &button_gc, "+1", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_skipb, &button_gc, "-1", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_faster, &button_gc, "Fast", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_slower, &button_gc, "Slow", \
+	       whitepixel, blackpixel);
+
+    drawbutton(control, button_lastframe, &button_gc, "Last", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_firstframe, &button_gc, "First", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_middle, &button_gc, "Middle", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_stepf, &button_gc, ">", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_stepff, &button_gc, ">>", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_stepb, &button_gc, "<", \
+	       whitepixel, blackpixel);
+    drawbutton(control, button_stepbb, &button_gc, "<<", \
+	       whitepixel, blackpixel);
+    
+
+
+    XMapWindow(display, info_speed.win);
+    sprintf(tempstring, "Speed: %i", waittime_millisecs);
+    drawtext(info_speed, button_gc, font_info, tempstring);
+
+    XMapWindow(display, info_start.win);
+    sprintf(tempstring, "Start: %i", animate_start);
+    drawtext(info_start, button_gc, font_info, tempstring);
+
+    XMapWindow(display, info_stop.win);
+    sprintf(tempstring, "Stop: %i", animate_stop);
+    drawtext(info_stop, button_gc, font_info, tempstring);
+
+    XMapWindow(display, info_skip.win);
+    sprintf(tempstring, "Skip: %i", animate_skip);
+    drawtext(info_skip, button_gc, font_info, tempstring);
+    
+    XMapWindow(display, info_frame.win);
+    sprintf(tempstring, "%i of %i", frame, no_frames);
+    drawtext(info_frame, button_gc, font_info, tempstring);
+    
+    XMapWindow(display, info_title.win);
+    sprintf(tempstring, "%s", axes.window_name);
+    drawtext(info_title, button_gc, font_info, tempstring);
+    
+    XMapWindow(display, info_freq.win);
+    sprintf(tempstring, "Freq %i-%iHz", mincf, maxcf);
+    drawtext(info_freq, button_gc, font_info, tempstring);
+    
+    XMapWindow(display, info_time.win);
+    sprintf(tempstring, "Interval %.1f...%.1fms", pwidth, nwidth);
+    drawtext(info_time, button_gc, font_info, tempstring);
+    
+    XMapWindow(display, info_frstep.win);
+    sprintf(tempstring, "frstep: %.1fms", frstep_aid);
+    drawtext(info_frstep, button_gc, font_info, tempstring);
+    
+    
+    break;
+	
+
+/*--------------------------------------*/	
+
+
+  case ConfigureNotify:
+    if (report.xconfigure.window != control.win)
+      break;
+    
+    control.width = report.xconfigure.width;
+    control.height = report.xconfigure.height;
+    
+    control.window_size = BIG_ENOUGH_X;
+    if ((control.width < control.size_hints.min_width) || \
+	(control.height < control.size_hints.min_height))
+      control.window_size = TOO_SMALL_X;
+    if ((control.width > control.size_hints.max_width) || \
+	(control.height > control.size_hints.max_height))
+      control.window_size = TOO_BIG_X;
+    break;
+
+/*--------------------------------------*/
+
+  default:
+    break;
+
+  } /* switch */
+    
+}
+
+
+
+
+
+
+/* The End */
+/*-------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/