home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Header: wevent.c,v 2.1 89/05/09 14:19:57 billr Exp $
- */
- /*
- * wevent.c
- *
- * Author: Philip Heller, Sun Microsystems. Inc. <terrapin!heller@sun.com>
- *
- * Original source Copyright (C) 1987, Sun Microsystems, Inc.
- * All Rights Reserved
- * Permission is hereby granted to use and modify this program in source
- * or binary form as long as it is not sold for profit and this copyright
- * notice remains intact.
- *
- *
- * Changes/additions by: Bill Randle, Tektronix, Inc. <billr@saab.CNA.TEK.COM>
- *
- * Changes and additions Copyright (C) 1988, 1989 Tektronix, Inc.
- * All Rights Reserved
- * Permission is hereby granted to use and modify the modifications in source
- * or binary form as long as they are not sold for profit and this copyright
- * notice remains intact.
- */
- /********************************************************
- * *
- * Week event routines for main subwindow. *
- * *
- ********************************************************/
-
-
- #include <stdio.h>
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- #include <suntool/panel.h>
- #include "ct.h"
- #include "event.h"
-
- extern Frame prompt_frame;
-
- week_inputevent(canvas, event)
- Canvas canvas;
- Event *event;
- {
- int i = -1;
- int x, y;
- static int day_chosen_from_week;
-
- /* translate coordinates to pixwin space */
- event = canvas_window_event(canvas, event);
- if (event_id(event) != MS_LEFT) /* Ignore kbd events. */
- return;
-
- if (event_is_down(event)) { /* Button down. */
- day_chosen_from_week = -1;
- for (i=0; i<nr_weekdays; i++) {
- x = event_x(event);
- y = event_y(event);
- if (x >= week_boxes[i].wday_pos.left && x <= week_boxes[i].wday_pos.right &&
- y >= week_boxes[i].wday_pos.top && y <= week_boxes[i].wday_pos.bottom) {
- day_chosen_from_week = i;
- pw_write(main_pixwin, week_boxes[i].wday_pos.left+1,
- week_boxes[i].wday_pos.top+1, weekslot_width-2,
- (weekslot_height)*N_SLOTS-2, PIX_NOT(PIX_DST), NULL,0,0);
- return;
- }
- /* is cursor inside a "more" button ? */
- if (x>=week_boxes[i].moreb_pos.left && x<=week_boxes[i].moreb_pos.right &&
- y>=week_boxes[i].moreb_pos.top && y<=week_boxes[i].moreb_pos.bottom) {
- if (week_boxes[i].more) {
- /* "more" button is active */
- day_chosen_from_week = i+10;
- return;
- }
- }
- }
- return; /* Mouse wasn't in any square. */
- } else { /* Button up. */
- if (day_chosen_from_week == -1)
- return;
- if (day_chosen_from_week >= 10) {
- /* more button selected */
- /* print info message */
- do_more_msg(day_chosen_from_week-10);
- return;
- }
- current.tm_mday -= current.tm_wday;
- current.tm_mday += day_chosen_from_week;
- fix_current_day();
- if (nr_weekdays == 5) {
- current.tm_mday++;
- fix_current_day();
- }
- mainsw_state = DISPLAYING_DAY;
- window_set(canvas, WIN_CURSOR, day_cursor, 0);
- draw_day();
- }
- }
-
- /* display more popup message */
- do_more_msg(i)
- int i;
- {
- int width, height, left, bottom;
-
- /* get x,y position of canvas window on the screen so we
- * can center this one in it.
- */
- create_prompt_frame("Select this day to view additional appointments.", FALSE);
- width = (int) window_get(prompt_frame, WIN_WIDTH);
- height = (int) window_get(prompt_frame, WIN_HEIGHT);
- left = (week_boxes[i].wday_pos.right + week_boxes[i].wday_pos.left - width) / 2;
- bottom = (week_boxes[i].wday_pos.top + week_boxes[i].wday_pos.bottom - height) / 2;
- window_set(prompt_frame, WIN_X, left, WIN_Y, bottom, 0);
- (void) window_loop(prompt_frame);
- window_set(prompt_frame, WIN_SHOW, FALSE, 0);
- }
-