/******************************** icons.c ****************************/ #include "sdi.h" /* * Copyright 1987 by Mark Weiser. * Permission to reproduce and use in any manner whatsoever on Suns is granted * so long as this copyright and other identifying marks of authorship * in the code and the game remain intact and visible. Use of this code * in other products is reserved to me--I'm working on Mac and IBM versions. */ /* * This file contains the code and data to keep the icon busy. */ #define MARKS_OWN_DEFINE_ICON_FROM_IMAGE(name, image) \ mpr_static(name, ICON_DEFAULT_WIDTH, ICON_DEFAULT_HEIGHT, 1, image) static short icon1_image[] = { #include "city_icon1.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon1, icon1_image); static short icon2_image[] = { #include "city_icon2.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon2, icon2_image); static short icon3_image[] = { #include "city_icon3.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon3, icon3_image); static short icon4_image[] = { #include "city_icon4.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon4, icon4_image); static short icon5_image[] = { #include "city_icon5.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon5, icon5_image); static short icon6_image[] = { #include "city_icon6.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon6, icon6_image); static short icon7_image[] = { #include "city_icon7.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon7, icon7_image); static short icon8_image[] = { #include "city_icon8.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(icon8, icon8_image); static short fancy_icon1_image[] = { #include "fancy_icon1.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon1, fancy_icon1_image); static short fancy_icon2_image[] = { #include "fancy_icon2.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon2, fancy_icon2_image); static short fancy_icon3_image[] = { #include "fancy_icon3.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon3, fancy_icon3_image); static short fancy_icon4_image[] = { #include "fancy_icon4.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon4, fancy_icon4_image); static short fancy_icon5_image[] = { #include "fancy_icon5.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon5, fancy_icon5_image); static short fancy_icon6_image[] = { #include "fancy_icon6.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon6, fancy_icon6_image); static short fancy_icon7_image[] = { #include "fancy_icon7.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon7, fancy_icon7_image); static short fancy_icon8_image[] = { #include "fancy_icon8.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon8, fancy_icon8_image); static short fancy_icon9_image[] = { #include "fancy_icon9.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon9, fancy_icon9_image); static short fancy_icon10_image[] = { #include "fancy_icon10.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon10, fancy_icon10_image); static short fancy_icon11_image[] = { #include "fancy_icon11.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon11, fancy_icon11_image); static short fancy_icon12_image[] = { #include "fancy_icon12.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon12, fancy_icon12_image); static short fancy_icon13_image[] = { #include "fancy_icon13.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon13, fancy_icon13_image); static short fancy_icon14_image[] = { #include "fancy_icon14.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon14, fancy_icon14_image); static short fancy_icon15_image[] = { #include "fancy_icon15.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon15, fancy_icon15_image); static short fancy_icon16_image[] = { #include "fancy_icon16.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon16, fancy_icon16_image); static short fancy_icon17_image[] = { #include "fancy_icon17.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon17, fancy_icon17_image); static short fancy_icon18_image[] = { #include "fancy_icon18.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon18, fancy_icon18_image); static short fancy_icon19_image[] = { #include "fancy_icon19.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon19, fancy_icon19_image); static short fancy_icon20_image[] = { #include "fancy_icon20.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon20, fancy_icon20_image); static short fancy_icon21_image[] = { #include "fancy_icon21.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon21, fancy_icon21_image); static short fancy_icon22_image[] = { #include "fancy_icon22.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon22, fancy_icon22_image); static short fancy_icon23_image[] = { #include "fancy_icon23.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon23, fancy_icon23_image); static short fancy_icon24_image[] = { #include "fancy_icon24.h" }; MARKS_OWN_DEFINE_ICON_FROM_IMAGE(fancy_icon24, fancy_icon24_image); #define MAX_FANCY_ICON 24 Icon fancy_icon_list[24]; #define MAX_ICON 8 Icon icon_list[MAX_ICON]; static int ICON_USECS = 500000; static int ICON_SECS = 0; static int icon_update_time = 5; static int icon_update_type = 1; static int icon_no = 0; init_icons() { extern int starting_icon; extern int starting_icon_time; #define CREATE_ICON(x) icon_list[x-1] = xv_create(NULL, ICON, ICON_IMAGE, icon/**/x/**/, 0); CREATE_ICON(1); CREATE_ICON(2); CREATE_ICON(3); CREATE_ICON(4); CREATE_ICON(5); CREATE_ICON(6); CREATE_ICON(7); CREATE_ICON(8); #undef CREATE_ICON #define CREATE_ICON(x) fancy_icon_list[x-1] = xv_create(NULL, ICON, ICON_IMAGE, fancy_icon/**/x/**/, 0); CREATE_ICON(1); CREATE_ICON(2); CREATE_ICON(3); CREATE_ICON(4); CREATE_ICON(5); CREATE_ICON(6); CREATE_ICON(7); CREATE_ICON(8); CREATE_ICON(9); CREATE_ICON(10); CREATE_ICON(11); CREATE_ICON(12); CREATE_ICON(13); CREATE_ICON(14); CREATE_ICON(15); CREATE_ICON(16); CREATE_ICON(17); CREATE_ICON(18); CREATE_ICON(19); CREATE_ICON(20); CREATE_ICON(21); CREATE_ICON(22); CREATE_ICON(23); CREATE_ICON(24); icon_update_type = starting_icon; icon_update_time = starting_icon_time; } /* * Update the icon through a rotating list of possible pixrects. * Started from within the file main.c when a window close event * is detected. */ Notify_value update_icon() { extern int running_icon_pictures; switch (icon_update_type) { case 0: break; case 1: { icon_no = (icon_no + 1) % MAX_ICON; xv_set(controlframe, FRAME_ICON, icon_list[icon_no], 0); break; } case 2: { icon_no = (icon_no + 1) % MAX_FANCY_ICON; xv_set(controlframe, FRAME_ICON, fancy_icon_list[icon_no], 0); break; } } if (running_icon_pictures) { ICON_SECS = icon_update_time / 10; ICON_USECS = (icon_update_time % 10) * 100000; do_with_delay((void (*)())update_icon, ICON_SECS, ICON_USECS); } return NOTIFY_DONE; } static Frame icon_option_frame; icon_option_done() { xv_set(icon_option_frame, FRAME_NO_CONFIRM, TRUE, 0); /* XView CONVERSION - If this is being called from within an event/notify call-back proc, call func xv_destroy_safe instead */xv_destroy(icon_option_frame); icon_option_frame = 0; resume_proc(); } icon_update_time_proc(item, value, event) Panel_item item; int value; Event *event; { icon_update_time = value; } icon_update_type_proc(item, value, event) Panel_item item; int value; Event *event; { icon_update_type = value; if (icon_update_type == 0) { xv_set(controlframe, FRAME_ICON, icon_list[0], 0); } } /* * Called as a notify proc from the main control panel. */ void icon_option_proc() { extern int starting_icon; extern struct pixfont *buttonfont; /* use 'struct pixfont' for 3.0 compatiblity */ Panel panel, make_popup_panel(); if ((panel = make_popup_panel(" SDI Icon Options", NULL)) == NULL) { return; } (void) xv_create(panel, PANEL_CYCLE, PANEL_LABEL_STRING, " Icon:", PANEL_CHOICE_STRINGS, "Plain", "Subtle", "Wild", 0, PANEL_VALUE, icon_update_type, PANEL_NOTIFY_PROC, icon_update_type_proc, 0); (void) xv_create(panel, PANEL_SLIDER, PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_NOTIFY_PROC, icon_update_time_proc, PANEL_LABEL_STRING, "Icon update (tenths of secs): ", PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_SLIDER_WIDTH, 100, PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 50, PANEL_SHOW_RANGE, FALSE, PANEL_SHOW_VALUE, TRUE, PANEL_VALUE, icon_update_time, XV_SHOW, TRUE, 0); display_popup_panel(panel); }