home *** CD-ROM | disk | FTP | other *** search
- /*
- * FIG : Facility for Interactive Generation of figures
- *
- * panel.c - Button panel
- *
- * Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
- * January 1985.
- * 1st revision : Aug 1985.
- *
- * %W% %G%
- */
- #include "fig.h"
- #include "resources.h"
- #include "const.h"
- #include "font.h"
- #include "func.h"
- #include "object.h"
- #include "paintop.h"
-
- extern null_proc();
- extern read_file();
- extern save_file();
- extern edit_file();
- extern change_directory();
- extern print_wdir();
- extern print_figure();
- extern int line_thickness;
- extern int cur_radius;
- extern int cur_areafill;
- extern int fill_mode;
- extern int foreground_color;
- extern char current_file[];
- extern int print_landscape;
- extern int size_button;
- extern int type_button;
- extern char *printer;
- extern int cur_printer;
- extern char *printer_list[];
- extern TOOL fontmenu; /* popup menu for printer fonts */
- extern appresStruct appres;
- extern int font_button; /* "current" font */
- extern int *font_sel; /* pointer to store font selected from popup */
- extern TOOL image_widget; /* which widget to store image of font in */
-
- /************** local variables and routines **************/
-
- #include "panel.h"
- #include "panel2.h"
- #include "switch.h"
-
- static panel_selected();
- static panel_sighandler();
- static init_switch();
- static F_switch *switch_selected();
- static panel_selected();
- static switch_handler();
- static switch_action();
- static mode_on();
- static mode_off();
- static set_command();
- static set_geometry();
- static set_grid();
- static set_style();
- static dec_thick();
- static inc_thick();
- #ifndef TFX
- static dec_radius();
- static inc_radius();
- #endif TFX
- static darken_fill();
- static lighten_fill();
- extern turn_off();
-
- /* second panel (lower part of window */
- static panel_button();
- static text_just_button();
- static popup_fonts();
- static inc_size_button();
- static dec_size_button();
- static land_button();
-
- static Pixmap Lp_pm; /* pixmaps for print-Landscape/Portrait button */
- static Pixmap lP_pm;
- static Pixmap print_sel_pm; /* pixmap for printer selection widget */
- static Pixmap font_size_pm; /* pixmap for printer selection widget */
- static Pixmap text_just_pm[3]; /* pixmaps for left/center/right just widget */
- static Widget print_sel_widget;
- static Widget font_size_widget;
- static F_switch *text_just_sw; /* text justification button */
- static F_switch *land_port_sw; /* landscape/portrait button */
-
- TOOL ind_box; /* allow main() to access this widget */
-
- #define on_action(z) (z->on_func)(z)
- #define off_action(z) (z->off_func)(z)
-
- static F_switch switches[] = {
- { 0, 0, 0, 0, &cirrad_ic, F_CIRCLE_BY_RAD, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &cirdia_ic, F_CIRCLE_BY_DIA, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &ellrad_ic, F_ELLIPSE_BY_RAD, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &elldia_ic, F_ELLIPSE_BY_DIA, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &c_spl_ic, F_CLOSED_SPLINE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &spl_ic, F_SPLINE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &c_intspl_ic, F_CLOSED_INTSPLINE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &intspl_ic, F_INTSPLINE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &line_ic, F_POLYLINE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &polygon_ic, F_POLYGON, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &box_ic, F_BOX, set_command, null_proc, S_ON, },
- #ifdef TFX
- /* place holders to keep a multiple of 3 buttons */
- /* TFX does not allow arc_boxes */
- { 0, -1, 0, 0, &blank_ic, F_NOP, null_proc, null_proc, S_MOMENT, },
- #else
- { 0, 0, 0, 0, &arc_box_ic, F_ARC_BOX, set_command, null_proc, S_ON, },
- #endif
- { 0, 0, 0, 0, &text_ic, F_TEXT, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &arc_ic, F_CIRCULAR_ARC, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &turn_ic, F_TURN, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &glue_ic, F_GLUE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &break_ic, F_BREAK, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &scale_ic, F_SCALE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &autoarrow_ic, F_AUTOARROW, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &addpt_ic, F_ADD_POINT, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &deletept_ic, F_DELETE_POINT, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &move_ic, F_MOVE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &movept_ic, F_MOVE_POINT, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, ©_ic, F_COPY, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &remove_ic, F_REMOVE, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &flip_x_ic, F_FLIP_XAXIS, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &flip_y_ic, F_FLIP_YAXIS, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &rot90_ic, F_ROTATE90, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &rot270_ic, F_ROTATE270, set_command, null_proc, S_ON, },
- { 0, 0, 0, 0, &change_ic, F_CHANGE, set_command, null_proc, S_ON, },
- { 1, 2, 0, 0, &unconstraint_ic, F_UNCONSTRAINT, set_geometry, null_proc, S_ON, },
- { 0, 2, 0, 0, &latexline_ic, F_LATEX_LINE, set_geometry, null_proc, S_ON, },
- { 0, 2, 0, 0, &latexarrow_ic, F_LATEX_ARROW, set_geometry, null_proc, S_ON, },
- { 0, 2, 0, 0, &mounthattan_ic, F_MOUNTHATTAN, set_geometry, null_proc, S_ON, },
- { 0, 2, 0, 0, &manhattan_ic, F_MANHATTAN, set_geometry, null_proc, S_ON, },
- { 0, 2, 0, 0, &mountain_ic, F_MOUNTAIN, set_geometry, null_proc, S_ON, },
- { 1, 3, 0, 0, &solidline_ic, F_SET_SOLID_LINE, set_style, null_proc, S_ON, },
- { 0, 3, 0, 0, &dashline_ic, F_SET_DASH_LINE, set_style, null_proc, S_ON, },
- { 0, 3, 0, 0, &dottedline_ic, F_SET_DOTTED_LINE, set_style, null_proc, S_ON, },
- { 0, 1, 0, 0, &grid1_ic, F_GRID1, set_grid, set_grid, S_TOG, },
- { 0,-1, 0, 0, &backarrow_ic, F_AUTOB_ARROW, mode_on, mode_off, S_TOG, },
- { 0,-1, 0, 0, &forarrow_ic, F_AUTOF_ARROW, mode_on, mode_off, S_TOG, },
- { 0, 1, 0, 0, &grid2_ic, F_GRID2, set_grid, set_grid, S_TOG, },
- #ifdef TFX
- { 0,-1, 0, 0, &fill_ic, F_FILL, mode_on, mode_off, S_TOG, },
- { 1,-1, 0, 0, &magnet_ic, F_MAGNET, mode_on, mode_off, S_TOG, },
- #else
- { 1,-1, 0, 0, &magnet_ic, F_MAGNET, mode_on, mode_off, S_TOG, },
- { 0,-1, 0, 0, &fill_ic, F_FILL, mode_on, mode_off, S_TOG, },
- #endif
- { 0,-1, 0, 0, &incdec_thick_ic, F_INCDECTHICK, dec_thick, null_proc, S_MOMENT,},
- #ifndef TFX
- { 0,-1, 0, 0, &incdec_radius_ic, F_INCDECRADIUS, dec_radius, null_proc, S_MOMENT,},
- #endif
- { 0,-1, 0, 0, &fill_color_ic, F_FILLCOLOR, lighten_fill, null_proc, S_MOMENT,},
-
- };
-
- #define N_SWITCHES (sizeof(switches) / sizeof(F_switch))
- #define NUM_GROUP 4
- static F_switch *group[NUM_GROUP];
-
- /* second panel of switches below the lower ruler */
- static F_switch switches2[] = {
- { 0, -1, 0, 0, &save_n_exit_ic,F_SAVE_N_EXIT,panel_button,null_proc,S_MOMENT,},
- { 0, -1, 0, 0, &quit_ic, F_QUIT, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &save_ic, F_SAVE, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &save_in_ic, F_SAVE_IN, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &read_ic, F_READ, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &edit_ic, F_EDIT, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &cdir_ic, F_CHDIR, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &pdir_ic, F_PWDIR, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &print_ic, F_PRINT, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &print_sel_ic, F_PRINTSEL, panel_button, null_proc, S_MOMENT,},
- { 0, -1, 0, 0, &font_ic, F_FONT, popup_fonts, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &size_ic, F_SIZE, dec_size_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &textL_ic, F_JUST, text_just_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &land_ic, F_LAND, land_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &undo_ic, F_UNDO, panel_button, null_proc, S_MOMENT, },
- { 0, -1, 0, 0, &redisp_ic, F_REDISPLAY, panel_button, null_proc, S_MOMENT, },
- };
-
- #define N_SWITCHES2 (sizeof(switches2) / sizeof(F_switch))
-
- /*
- * Panel subwindow section
- */
-
- static Arg panel_args[] =
- {
- /* 0 */ { XtNwidth, (XtArgVal) 0 },
- /* 1 */ { XtNhSpace, (XtArgVal)SWITCH_ICON_SPACING },
- /* 2 */ { XtNvSpace, (XtArgVal)SWITCH_ICON_SPACING },
- /* Fix the size of the panel window by chaining both top & bottom
- to the top of the form, and both left & right to the right.
- If RHS_PANEL, then chain left/right to RIGHT of form */
- /* 3 */ { XtNtop, (XtArgVal)XtChainTop },
- /* 4 */ { XtNbottom, (XtArgVal)XtChainTop },
- /* 5 */ { XtNleft, (XtArgVal)XtChainLeft },
- /* 6 */ { XtNright, (XtArgVal)XtChainLeft },
- /* 7 */ { XtNresizable, (XtArgVal) False },
- /* 8 */ { XtNborderWidth, (XtArgVal) 2 },
- /* 9 */ { XtNvertDistance, (XtArgVal) 0 }, /* touching top of form */
- };
-
- static Arg panel2_args[] =
- {
- /* 0 */ { XtNwidth, (XtArgVal)0 },
- /* 1 */ { XtNhSpace, (XtArgVal) 1 },
- /* 2 */ { XtNvSpace, (XtArgVal) 1 },
- /* 3 */ { XtNresizable, (XtArgVal) False },
- /* 4 */ { XtNfromVert, (XtArgVal) NULL }, /* will be from psfont */
- /* 5 */ { XtNvertDistance, (XtArgVal) -1 },
- /* 6 */ { XtNhorizDistance, (XtArgVal) 1 },
- /* Fix the size of the panel window by chaining both top & bottom
- to the top of the form, and both left & right to the right */
- /* 7 */ { XtNtop, (XtArgVal)XtChainBottom },
- /* 8 */ { XtNbottom, (XtArgVal)XtChainBottom },
- /* 9 */ { XtNleft, (XtArgVal)XtChainLeft },
- /* 10 */ { XtNright, (XtArgVal)XtChainLeft },
- };
-
- static Arg ind_box_args[] =
- {
- /* 0 */ { XtNwidth, (XtArgVal) 0 },
- /* 1 */ { XtNhSpace, (XtArgVal)SWITCH_ICON_SPACING },
- /* 2 */ { XtNfromVert, (XtArgVal) NULL }, /* will be from panel_sw */
- /* 3 */ { XtNvertDistance, (XtArgVal) 0 },
- /* 4 */ { XtNborderWidth, (XtArgVal) 2 },
- /* Fix the size of the panel window by chaining both top & bottom
- to the top of the form, and both left & right to the right
- If RHS_PANEL, then chain left/right to RIGHT of form */
- /* 5 */ { XtNtop, (XtArgVal)XtChainTop },
- /* 6 */ { XtNbottom, (XtArgVal)XtChainTop },
- /* 7 */ { XtNleft, (XtArgVal)XtChainLeft },
- /* 8 */ { XtNright, (XtArgVal)XtChainLeft },
- };
-
- /* widget arguments to show the current fill color and line thickness*/
-
- static Arg indicator_panel_args[] =
- {
- /* 0 */ { XtNlabel, (XtArgVal)" " },
- /* 1 */ { XtNwidth, (XtArgVal) SWITCH_ICON_WIDTH },
- /* 2 */ { XtNheight, (XtArgVal) SWITCH_ICON_HEIGHT },
- /* 3 */ { XtNresizable, (XtArgVal) False },
- /* 4 */ { XtNborderWidth, (XtArgVal) 1 },
- /* 5 */ { XtNbackgroundPixmap, (XtArgVal) NULL },
- };
-
- static void button_select();
-
- static Arg button_args[] =
- {
- /* 0 */ { XtNlabel, (XtArgVal)" " },
- /* 1 */ { XtNwidth, (XtArgVal) 0 },
- /* 2 */ { XtNheight, (XtArgVal) 0 },
- /* 3 */ { XtNbackgroundPixmap, (XtArgVal)NULL },
- /* 4 */ { XtNresizable, (XtArgVal) False },
- /* 5 */ { XtNborderWidth, (XtArgVal) 1 },
- /* 6 */ { XtNresize, (XtArgVal) False }, /* this keeps the damned buttons from
- being resized when there are not a
- multiple of three of them */
- };
-
- extern int PANEL_LEFT, PANEL_TOP, PANEL_HEIGHT, PANEL_WID;
- extern int PANEL2_LEFT, PANEL2_TOP, PANEL2_HEIGHT, PANEL2_WID;
- extern int CANVAS_HEIGHT, ICON_COLUMN;
-
- static right_but();
-
- /* button selection event handler */
- static sel_but();
-
- int
- init_panel(tool)
- TOOL tool;
- {
- register int i;
- register F_switch *sw;
-
- /* width */
- panel_args[0].value = PANEL_WID =
- (SWITCH_ICON_WIDTH + 2 + SWITCH_ICON_SPACING) * ICON_COLUMN
- + SWITCH_ICON_SPACING;
- panel_sw = XtCreateWidget("side_panel", boxWidgetClass, tool,
- panel_args, XtNumber(panel_args));
-
- for (i = 0; i < N_SWITCHES; ++i)
- {
- sw = &switches[i];
- button_args[1].value = sw->icon->width; /* button width */
- button_args[2].value = sw->icon->height; /* button height */
- sw->but.widget = XtCreateManagedWidget(
- "button", commandWidgetClass,
- panel_sw, button_args, XtNumber(button_args));
- /* allow left & right buttons (callbacks pass same data for ANY button) */
- XtAddEventHandler(sw->but.widget,ButtonPressMask,(Boolean) 0,
- sel_but, (caddr_t) sw);
- }
-
- return (1);
- }
-
- int /* second panel */
- init_panel2(tool)
- TOOL tool;
- {
- register int i;
- register F_switch *sw;
-
-
- /* panel width */
- panel2_args[0].value = PANEL2_WID = 2 * N_SWITCHES2 *
- (SWITCH_ICON_WIDTH + SWITCH_ICON_SPACING)
- + SWITCH_ICON_SPACING;
- panel2_args[4].value = (XtArgVal) psfont; /* vert offset from font window */
-
- panel2_sw = XtCreateWidget("bottom_panel", boxWidgetClass, tool, panel2_args,
- XtNumber(panel2_args));
- for (i = 0; i < N_SWITCHES2; ++i)
- {
- sw = &switches2[i];
- button_args[1].value = sw->icon->width; /* button width */
- button_args[2].value = sw->icon->height; /* button height */
- sw->but.widget = XtCreateManagedWidget(
- "button", commandWidgetClass,
- panel2_sw, button_args, XtNumber(button_args));
- /* allow left and right buttons (callbacks pass same data for ANY button) */
- XtAddEventHandler(sw->but.widget,ButtonPressMask,(Boolean) 0,
- sel_but, (caddr_t) sw);
- }
- return (1);
- }
-
- #define NUM_IND 3 /* number of indicator widgets */
-
- init_indicator_panel(tool)
- TOOL tool;
- {
- /* width */
- ind_box_args[0].value =
- (SWITCH_ICON_WIDTH + 2 + SWITCH_ICON_SPACING)*NUM_IND
- + SWITCH_ICON_SPACING;
-
- /* put below bottom of panel_sw */
- ind_box_args[2].value = (XtArgVal) panel_sw;
-
- ind_box = XtCreateWidget("indicator", boxWidgetClass, tool, ind_box_args,
- XtNumber(ind_box_args));
-
- indicator_panel_args[5].value = (XtArgVal) ind_fill_pm[0];/* white pixmap */
-
- /* line thickness indicator */
- line_thick_panel = XtCreateManagedWidget( "linewidth_indicator", boxWidgetClass,
- ind_box, indicator_panel_args, XtNumber(indicator_panel_args));
-
- #ifndef TFX
- /* rounded-corner box radius indicator */
- radius_panel = XtCreateManagedWidget( "radius_indicator", boxWidgetClass,
- ind_box, indicator_panel_args, XtNumber(indicator_panel_args));
- #endif TFX
-
- /* fill_area color */
- fill_panel = XtCreateManagedWidget( "fill_indicator", boxWidgetClass,
- ind_box, indicator_panel_args, XtNumber(indicator_panel_args));
- }
-
- static GC button_gc;
-
- /* come here after panel widget is realized to put some bitmaps etc. things in it */
-
- setup_panel()
- {
- register int i;
- register F_switch *sw;
- register Display *d = tool_d;
- register Screen *s = tool_s;
- register Pixmap p;
- Arg tmp_arg[3];
- unsigned long bg, fg;
-
- button_gc = XCreateGC(d, XtWindow(panel_sw), (unsigned long)0, NULL);
- XtSetArg(tmp_arg[0], XtNbackground, &bg);
- XtSetArg(tmp_arg[1], XtNforeground, &fg);
- XtGetValues(switches[0].but.widget, tmp_arg, 2);
- XSetForeground(d, button_gc, fg);
- XSetBackground(d, button_gc, bg);
- XSetFont(d, button_gc, button_font->fid); /* set button font */
-
- for (i = 0; i < N_SWITCHES; ++i)
- {
- sw = &switches[i];
- p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
- sw->icon->data,
- sw->icon->width, sw->icon->height,fg,bg,
- DefaultDepthOfScreen(s));
-
- sw->but.normal = button_args[3].value = (XtArgVal)p;
- XtSetValues(sw->but.widget, &button_args[3], 1);
- }
- /*
- ** Create reversed bitmaps for displaying activated state
- */
- for (i = 0; i < N_SWITCHES; ++i)
- {
- sw = &switches[i];
- p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
- sw->icon->data,
- sw->icon->width, sw->icon->height,bg,fg,
- DefaultDepthOfScreen(s));
-
- sw->but.reverse = (XtArgVal)p;
- }
-
- /*******************************/
- /* now do the same for panel 2 */
- /*******************************/
-
- for (i = 0; i < N_SWITCHES2; ++i)
- {
- sw = &switches2[i];
- p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
- sw->icon->data,
- sw->icon->width, sw->icon->height,fg,bg,
- DefaultDepthOfScreen(s));
- if (sw->value == F_LAND) /* create portrait pixmap for land/portrait button */
- {
- Lp_pm = p; /* save pointer to default */
- lP_pm = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
- port_ic.data,
- port_ic.width, port_ic.height,fg,bg,
- DefaultDepthOfScreen(s));
- if (!appres.landscape) /* use portrait for startup image */
- p = lP_pm;
- land_port_sw = sw; /* save pointer to this switch */
- }
- else if (sw->value == F_SIZE) /* save pointer to pixmap/widget for font size */
- {
- font_size_pm = p;
- font_size_widget = sw->but.widget;
- }
- else if (sw->value == F_JUST) /* save ptr to pixmap/widget for text justification */
- {
- text_just_sw = sw;
- /* create the other bitmaps for Center and Right */
- text_just_pm[T_LEFT_JUSTIFIED] = p; /* left just */
- text_just_pm[T_CENTER_JUSTIFIED] = /* center just */
- XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
- textC_ic.data,
- textC_ic.width, textC_ic.height,fg,bg,
- DefaultDepthOfScreen(s));
- text_just_pm[T_RIGHT_JUSTIFIED] = /* right just */
- XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
- textR_ic.data,
- textR_ic.width, textR_ic.height,fg,bg,
- DefaultDepthOfScreen(s));
- }
- else if (sw->value == F_PRINTSEL) /* save pointer to pixmap for print sel */
- {
- print_sel_pm = p;
- print_sel_widget=sw->but.widget;
- }
-
- sw->but.normal = button_args[3].value = (XtArgVal)p;
- XtSetValues(sw->but.widget, &button_args[3], 1);
- }
- /*
- ** Create reversed bitmaps for displaying activated state
- */
- for (i = 0; i < N_SWITCHES2; ++i)
- {
- sw = &switches2[i];
- p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
- sw->icon->data,
- sw->icon->width, sw->icon->height,fg,bg,
- DefaultDepthOfScreen(s));
- sw->but.reverse = (XtArgVal)p;
- }
-
- init_switch();
- XDefineCursor(d, XtWindow(panel_sw), (Cursor)arrow_cursor.bitmap);
- XDefineCursor(d, XtWindow(panel2_sw), (Cursor)arrow_cursor.bitmap);
-
- }
-
- /* come here when a button is pressed in either of the panels */
-
- static
- sel_but(widget, sw, event)
- Widget widget;
- F_switch *sw;
- XButtonEvent *event;
- {
- if (event->button == Button1) /* left button */
- button_select(widget, sw);
- else if (event->button == Button3) /* right button */
- right_but(widget, sw);
- }
-
- static
- right_but(widget, sw)
- Widget widget;
- F_switch *sw;
- {
- switch (sw->value) /* do the opposite of the function declared in the switch */
- {
- case F_INCDECTHICK:
- inc_thick(sw);
- break;
- case F_FILLCOLOR:
- darken_fill(sw);
- break;
- #ifndef TFX
- case F_INCDECRADIUS:
- inc_radius(sw);
- break;
- #endif
- case F_SIZE:
- inc_size_button(sw);
- break;
- }
- }
-
- static void
- button_select(widget, s)
- TOOL widget;
- F_switch *s;
- {
- switch_action(s);
- }
-
- static
- init_switch()
- {
- extern int manhattan_mode;
- extern int mountain_mode;
- extern int autoforwardarrow_mode;
- extern int autobackwardarrow_mode;
- extern int latexline_mode;
- extern int latexarrow_mode;
- extern int magnet_mode;
- extern int line_style;
- extern float cur_styleval;
- extern float cur_dashlength;
- extern float cur_dotgap;
- int i;
- F_switch *sw;
-
- for (sw = switches, i = 0; i < N_SWITCHES; sw++, i++) {
- sw->x *= SWITCH_ICON_WIDTH;
- sw->y *= SWITCH_ICON_HEIGHT;
- }
- /* don't forget the second panel */
- for (sw = switches2, i = 0; i < N_SWITCHES2; sw++, i++) {
- sw->x *= SWITCH_ICON_WIDTH;
- sw->y *= SWITCH_ICON_HEIGHT;
- }
-
- for (i = 0; i < NUM_GROUP; )
- group[i++] = NULL;
-
- for (sw = switches, i = 0; i < N_SWITCHES; sw++, i++) {
- if (sw->on) {
- /* Only the following switch can be preset */
- switch (sw->value) {
- case F_UNCONSTRAINT :
- manhattan_mode = 0;
- mountain_mode = 0;
- latexline_mode = 0;
- latexarrow_mode = 0;
- group[sw->group] = sw;
- break;
- case F_MOUNTHATTAN :
- manhattan_mode = 1;
- mountain_mode = 1;
- group[sw->group] = sw;
- break;
- case F_MANHATTAN :
- manhattan_mode = 1;
- group[sw->group] = sw;
- break;
- case F_MOUNTAIN :
- mountain_mode = 1;
- group[sw->group] = sw;
- break;
- case F_LATEX_LINE :
- latexline_mode = 1;
- group[sw->group] = sw;
- break;
- case F_LATEX_ARROW :
- latexarrow_mode = 1;
- group[sw->group] = sw;
- break;
- case F_AUTOF_ARROW :
- autoforwardarrow_mode = 1;
- break;
- case F_AUTOB_ARROW :
- autobackwardarrow_mode = 1;
- break;
- case F_SET_SOLID_LINE :
- line_style = SOLID_LINE;
- cur_styleval = 0.0;
- break;
- case F_SET_DASH_LINE :
- line_style = DASH_LINE;
- cur_styleval = cur_dashlength;
- break;
- case F_SET_DOTTED_LINE :
- line_style = DOTTED_LINE;
- cur_styleval = cur_dotgap;
- break;
- case F_MAGNET :
- magnet_mode = 1;
- break;
- default :
- continue;
- }
- turn_on(sw);
- if (sw->group != -1)
- group[sw->group] = sw;
- }
- }
- }
-
- static
- set_command(sw)
- F_switch *sw;
- {
- extern int cur_command;
- extern int rotate_angle;
- extern int flip_axis;
-
- switch (sw->value) {
- case F_CIRCLE_BY_RAD :
- circlebyradius_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("CIRCLE drawing: specify RADIUS");
- break;
- case F_CIRCLE_BY_DIA :
- circlebydiameter_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("CIRCLE drawing: specify DIAMETER");
- break;
- case F_ELLIPSE_BY_RAD :
- ellipsebyradius_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("ELLIPSE drawing: specify RADIUSES");
- break;
- case F_ELLIPSE_BY_DIA :
- ellipsebydiameter_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("ELLIPSE drawing: specify DIAMETERS");
- break;
- case F_BOX :
- box_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("Rectangular BOX drawing");
- break;
- #ifndef TFX
- case F_ARC_BOX :
- arc_box_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("Rectangular BOX drawing with ROUNDED CORNERS");
- break;
- #endif
- case F_POLYGON :
- line_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("POLYGON drawing");
- break;
- case F_POLYLINE :
- line_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("POLYLINE drawing");
- break;
- case F_TEXT :
- text_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("TEXT input (from keyboard)");
- break;
- case F_CIRCULAR_ARC :
- arc_drawing_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("ARC drawing: specify three points on the arc");
- break;
- case F_SPLINE :
- draw_spline_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("SPLINE drawing: specify control points");
- break;
- case F_CLOSED_SPLINE :
- draw_spline_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("CLOSED SPLINE drawing: specify control points");
- break;
- case F_INTSPLINE :
- draw_intspline_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("INTERPOLATED SPLINE drawing");
- break;
- case F_CLOSED_INTSPLINE :
- draw_intspline_selected();
- erase_pointmarker();
- erase_compoundbox();
- put_msg("CLOSED INTERPOLATED SPLINE drawing");
- break;
- case F_GLUE :
- compound_selected();
- erase_pointmarker();
- show_compoundbox();
- put_msg("GLUE objects into COMPOUND object with bounding box");
- break;
- case F_BREAK :
- break_selected();
- erase_pointmarker();
- show_compoundbox();
- put_msg("BREAK COMPOUND object");
- break;
- case F_SCALE :
- scale_compound_selected();
- erase_pointmarker();
- show_compoundbox();
- put_msg("SCALE COMPOUND object");
- break;
- case F_ADD_POINT :
- point_adding_selected();
- show_pointmarker();
- erase_compoundbox();
- put_msg("ADD POINTs (to POLYLINE, POLYGON, CLOSED-SPLINE and SPLINE)");
- break;
- case F_DELETE_POINT :
- delete_point_selected();
- show_pointmarker();
- erase_compoundbox();
- put_msg("DELETE POINTs (from POLYLINE, POLYGON, CLOSED-SPLINE and SPLINE)");
- break;
- case F_MOVE :
- move_selected();
- show_pointmarker();
- show_compoundbox();
- put_msg("MOVE objects");
- break;
- case F_MOVE_POINT :
- move_point_selected();
- show_pointmarker();
- erase_compoundbox();
- put_msg("MOVE POINTs (of POLYLINE, POLYGON, CLOSED-SPLINE, SPLINE and BOX)");
- break;
- case F_REMOVE :
- remove_selected();
- show_pointmarker();
- show_compoundbox();
- put_msg("REMOVE objects");
- break;
- case F_COPY :
- copy_selected();
- show_pointmarker();
- show_compoundbox();
- put_msg("COPY objects");
- break;
- case F_ROTATE270 :
- rotate_selected();
- show_pointmarker();
- show_compoundbox();
- rotate_angle = 270;
- put_msg("ROTATE objects (middle button) or COPY & ROTATE (left button) -90 degree");
- break;
- case F_ROTATE90 :
- rotate_selected();
- show_pointmarker();
- show_compoundbox();
- rotate_angle = 90;
- put_msg("ROTATE objects (middle button) or COPY & ROTATE (left button) 90 degree");
- break;
- case F_FLIP_XAXIS :
- flip_selected();
- show_pointmarker();
- show_compoundbox();
- flip_axis = 1;
- put_msg("FLIP objects (middle button) or COPY & FLIP (left button) up or down");
- break;
- case F_FLIP_YAXIS :
- flip_selected();
- show_pointmarker();
- show_compoundbox();
- flip_axis = 2;
- put_msg("FLIP objects (middle button) or COPY & FLIP (left button) left or right");
- break;
- case F_TURN :
- turn_selected();
- show_pointmarker();
- erase_compoundbox();
- put_msg("Turn POLYGON (POLYLINE) into CLOSED-SPLINE (SPLINE) or vice versa");
- break;
- case F_AUTOARROW :
- arrow_head_selected();
- show_pointmarker();
- erase_compoundbox();
- put_msg("ADD arrow head (left button); DELETE arrow head (middle button)");
- break;
- case F_CHANGE:
- change_item_selected();
- show_pointmarker();
- show_compoundbox();
- put_msg("CHANGE OBJECT");
- break;
-
-
- }
- cur_command = sw->value;
- }
-
- static
- set_geometry(sw)
- F_switch *sw;
- {
- extern int manhattan_mode;
- extern int mountain_mode;
- extern int latexline_mode;
- extern int latexarrow_mode;
-
- switch (sw->value) {
- case F_UNCONSTRAINT :
- manhattan_mode = 0;
- mountain_mode = 0;
- latexline_mode = 0;
- latexarrow_mode = 0;
- put_msg("UNCONSTRAINT geometry (for POLYLINE and SPLINE)");
- break;
- case F_MOUNTHATTAN :
- mountain_mode = 1;
- manhattan_mode = 1;
- latexline_mode = 0;
- latexarrow_mode = 0;
- put_msg("MOUNT-HATTAN geometry (for POLYLINE and SPLINE)");
- break;
- case F_MANHATTAN :
- manhattan_mode = 1;
- mountain_mode = 0;
- latexline_mode = 0;
- latexarrow_mode = 0;
- put_msg("MANHATTAN geometry (for POLYLINE and SPLINE)");
- break;
- case F_MOUNTAIN :
- mountain_mode = 1;
- manhattan_mode = 0;
- latexline_mode = 0;
- latexarrow_mode = 0;
- put_msg("MOUNTAIN geometry (for POLYLINE and SPLINE)");
- break;
- case F_LATEX_LINE :
- latexline_mode = 1;
- manhattan_mode = 0;
- mountain_mode = 0;
- latexarrow_mode = 0;
- put_msg("LATEX LINE geometry: allow only LaTeX line slopes");
- break;
- case F_LATEX_ARROW :
- latexarrow_mode = 1;
- manhattan_mode = 0;
- mountain_mode = 0;
- latexline_mode = 0;
- put_msg("LATEX ARROW geometry: allow only LaTeX arrow slopes");
- break;
- }
- }
-
- static
- set_grid(sw)
- F_switch *sw;
- {
- setup_grid(sw->value);
- }
-
- static
- mode_on(sw)
- F_switch *sw;
- {
- extern int autoforwardarrow_mode;
- extern int autobackwardarrow_mode;
- extern int magnet_mode;
-
- switch (sw->value) {
- case F_AUTOF_ARROW :
- autoforwardarrow_mode = 1;
- put_msg("AUTO FORWARD ARROW (for ARC, POLYLINE and SPLINE)");
- break;
- case F_AUTOB_ARROW :
- autobackwardarrow_mode = 1;
- put_msg("AUTO BACKWARD ARROW (for ARC, POLYLINE and SPLINE)");
- break;
- case F_MAGNET :
- magnet_mode = 1;
- put_msg("MAGNET: round entered points to the nearest %s increment",
- (appres.INCHES? "1/16\"": "2 mm"));
- break;
- case F_FILL :
- fill_mode = 1;
- put_fmsg("FILL MODE (gray level = %.2lf)",
- (double)1.0-(cur_areafill-1.0)/(NUMFILLPATS-1.0));
- break;
- }
- }
-
- static
- mode_off(sw)
- F_switch *sw;
- {
- extern int autoforwardarrow_mode;
- extern int autobackwardarrow_mode;
- extern int magnet_mode;
-
- switch (sw->value) {
- case F_AUTOF_ARROW :
- autoforwardarrow_mode = 0;
- break;
- case F_AUTOB_ARROW :
- autobackwardarrow_mode = 0;
- break;
- case F_MAGNET :
- magnet_mode = 0;
- break;
- case F_FILL :
- fill_mode = 0;
- put_msg("NO-FILL MODE");
- break;
- }
- }
-
- static
- set_style(sw)
- F_switch *sw;
- {
- extern int line_style;
- extern float cur_styleval;
- extern float cur_dashlength;
- extern float cur_dotgap;
-
- switch (sw->value) {
- case F_SET_SOLID_LINE :
- line_style = SOLID_LINE;
- cur_styleval = 0.0;
- put_msg("SOLID LINE STYLE (for BOX, POLYGON and POLYLINE)");
- break;
- case F_SET_DASH_LINE :
- line_style = DASH_LINE;
- cur_styleval = cur_dashlength;
- put_msg("DASH LINE STYLE (for BOX, POLYGON and POLYLINE)");
- break;
- case F_SET_DOTTED_LINE :
- line_style = DOTTED_LINE;
- cur_styleval = cur_dotgap;
- put_msg("DOTTED LINE STYLE (for BOX, POLYGON and POLYLINE)");
- break;
- }
- }
-
-
- static
- dec_thick(sw)
- F_switch *sw;
- {
- if (line_thickness > 0)
- --line_thickness;
- show_line_thickness();
- }
-
- #define MAXLINETHICK 200
-
- static
- inc_thick(sw)
- F_switch *sw;
- {
- if (line_thickness < MAXLINETHICK)
- ++line_thickness;
- show_line_thickness();
- }
-
- static Pixmap line_pm=0;
-
- show_line_thickness()
- {
- if (line_pm == 0)
- line_pm = XCreatePixmap(tool_d, XtWindow(line_thick_panel),
- SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT,
- DefaultDepthOfScreen(tool_s));
- /* erase by drawing wide, inverted (white) line */
- pw_vector(line_pm, 0, SWITCH_ICON_HEIGHT/2,
- SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT/2, ERASE,
- SWITCH_ICON_HEIGHT, SOLID_LINE, 0.0);
- /* draw current line thickness into pixmap */
- if (line_thickness > 0) /* don't draw line for zero-thickness */
- pw_vector(line_pm, 0, SWITCH_ICON_HEIGHT/2,
- SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT/2, PAINT,
- line_thickness, SOLID_LINE, 0.0);
-
- /* Fool the toolkit by changing the background pixmap to 0
- then giving it the modified one again. Otherwise, it sees
- that the pixmap ID is not changed and doesn't actually draw
- it into the widget window */
- indicator_panel_args[5].value = 0;
- XtSetValues(line_thick_panel, &indicator_panel_args[5], 1);
-
- /* put the pixmap in the widget background */
- indicator_panel_args[5].value = line_pm;
- XtSetValues(line_thick_panel, &indicator_panel_args[5], 1);
- put_msg("LINE Thickness = %d",line_thickness);
- }
-
-
- #ifndef TFX
-
- static
- dec_radius(sw)
- F_switch *sw;
- {
- --cur_radius;
- show_radius();
- }
-
- #define MAXRADIUS 30
-
- static
- inc_radius(sw)
- F_switch *sw;
- {
- ++cur_radius;
- show_radius();
- }
-
- static Pixmap radius_pm=0;
-
- show_radius()
- {
- if (cur_radius > MAXRADIUS)
- cur_radius = MAXRADIUS;
- else if (cur_radius < 3)
- cur_radius = 3;
- if (radius_pm == 0)
- radius_pm = XCreatePixmap(tool_d, XtWindow(radius_panel),
- SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT,
- DefaultDepthOfScreen(tool_s));
- /* erase by drawing wide, inverted (white) line */
- pw_vector(radius_pm, 0, SWITCH_ICON_HEIGHT/2,
- SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT/2, ERASE,
- SWITCH_ICON_HEIGHT, SOLID_LINE, 0.0);
- /* draw current radius into pixmap */
- curve(radius_pm, 0, cur_radius, cur_radius, 0, 0,
- cur_radius, cur_radius,
- 1, SWITCH_ICON_HEIGHT-2, foreground_color,
- 1, SOLID_LINE, 0.0, 0);
-
- /* Fool the toolkit by changing the background pixmap to 0
- then giving it the modified one again. Otherwise, it sees
- that the pixmap ID is not changed and doesn't actually draw
- it into the widget window */
- indicator_panel_args[5].value = 0;
- XtSetValues(radius_panel, &indicator_panel_args[5], 1);
-
- /* put the pixmap in the widget background */
- indicator_panel_args[5].value = radius_pm;
- XtSetValues(radius_panel, &indicator_panel_args[5], 1);
- put_msg("ROUNDED-CORNER BOX Radius = %d",cur_radius);
- }
- #endif TFX
-
- static
- darken_fill(sw)
- F_switch *sw;
- {
- if (cur_areafill < NUMFILLPATS)
- ++cur_areafill;
- show_fill_color();
- }
-
- static
- lighten_fill(sw)
- F_switch *sw;
- {
- if (cur_areafill > 1)
- --cur_areafill;
- show_fill_color();
- }
-
- show_fill_color()
- {
- /* put fill pixmap in widget background */
- indicator_panel_args[5].value = ind_fill_pm[cur_areafill-1];
- XtSetValues(fill_panel, &indicator_panel_args[5], 1);
- put_fmsg("FILL GRAY = %.2lf",
- (double)1.0-(cur_areafill-1.0)/(NUMFILLPATS-1.0));
- }
-
- /* Come here when most any lower panel button is pressed */
-
- static
- panel_button(sw)
- F_switch *sw;
- {
- char_handler(CR); /* finish any text in progress */
- switch (sw->value) {
- case F_UNDO :
- undo();
- break;
- case F_READ :
- init_msg_receiving(read_file, "Read file : ");
- break;
- case F_SAVE :
- (void)save_current_file();
- break;
- case F_SAVE_IN :
- if (no_object()) {
- put_msg("No figure to save; ignored");
- break;
- }
- init_msg_receiving(save_file, "Save in file : ");
- break;
- case F_REDISPLAY :
- redisplay_canvas();
- break;
- case F_EDIT :
- edit();
- break;
- case F_PRINT:
- print_figure();
- break;
- case F_PRINTSEL:
- printer_select();
- break;
- case F_CHDIR :
- init_msg_receiving(change_directory, "Directory : ");
- break;
- case F_PWDIR:
- print_directory();
- break;
- case F_SAVE_N_EXIT :
- save_n_exit();
- break;
- case F_QUIT :
- quit();
- break;
- }
- }
-
- printer_select()
- {
- if (*printer != '\0') /* increment printer number if not first time here */
- {
- if (++cur_printer >= MAXPRINTERS)
- cur_printer=0;
- }
- printer=printer_list[cur_printer];
- put_msg("SELECT PRINTER: %s",printer);
-
- /* first erase any existing string in pixmap */
- XDrawImageString(tool_d, print_sel_pm, button_gc,
- 6, 24, " ", 8);
- /* write the printer name in the background pixmap */
- XDrawImageString(tool_d, print_sel_pm, button_gc,
- 6, 24, printer, strlen(printer));
-
- /* Fool the toolkit by changing the background pixmap to 0
- then giving it the modified one again. Otherwise, it sees
- that the pixmap ID is not changed and doesn't actually draw
- it into the widget window */
- button_args[3].value = 0;
- XtSetValues(print_sel_widget, &button_args[3], 1);
-
- /* put the pixmap in the widget background */
- button_args[3].value = print_sel_pm;
- XtSetValues(print_sel_widget, &button_args[3], 1);
- }
-
- /* popup menu of printer fonts */
-
- static
- popup_fonts(sw)
- F_switch *sw;
- {
- font_sel = &font_button; /* store selected font number in font_button */
- image_widget = psfont; /* and image in this widget */
- XtPopup(fontmenu,XtGrabNonexclusive);
- setup_fontmenu_cursor(); /* now define the cursor for the font menu */
- }
-
- /* set text justification to left/center or right */
-
- static
- text_just_button(sw)
- F_switch *sw;
- {
- if (++type_button > T_RIGHT_JUSTIFIED) /* increment to next (L/C/R) */
- type_button = 0;
- /* put the pixmap in the widget background */
- text_just_sw->but.normal = text_just_sw->but.reverse =
- button_args[3].value = (XtArgVal) text_just_pm[type_button];
- XtSetValues(text_just_sw->but.widget, &button_args[3], 1);
- if (type_button==T_LEFT_JUSTIFIED)
- put_msg("Left justify text");
- else if (type_button==T_CENTER_JUSTIFIED)
- put_msg("Center text");
- else
- put_msg("Right justify text");
- }
-
- /* increase font size for print */
-
- static
- inc_size_button(sw)
- F_switch *sw;
- {
- if (size_button >= 100)
- {
- size_button = (size_button/10) * 10; /* round first */
- size_button += 10;
- }
- else if (size_button >= 50)
- {
- size_button = (size_button/5) * 5;
- size_button += 5;
- }
- else if (size_button >= 20)
- {
- size_button = (size_button/2) * 2;
- size_button += 2;
- }
- else
- size_button++;
- show_fontsize();
- }
-
-
- /* decrease font size for print */
-
- static
- dec_size_button(sw)
- F_switch *sw;
- {
- if (size_button > 100)
- {
- size_button = (size_button/10) * 10; /* round first */
- size_button -= 10;
- }
- else if (size_button > 50)
- {
- size_button = (size_button/5) * 5;
- size_button -= 5;
- }
- else if (size_button > 20)
- {
- size_button = (size_button/2) * 2;
- size_button -= 2;
- }
- else if (size_button > 4)
- size_button--;
- show_fontsize();
- }
-
- static char tmpsiz[5];
-
- show_fontsize()
- {
- put_msg("Font size %d",size_button);
- /* write the font size in the background pixmap */
- tmpsiz[0]=tmpsiz[1]=tmpsiz[2]=tmpsiz[3]=tmpsiz[4]='\0';
- sprintf(tmpsiz,"%3d",size_button);
- XDrawImageString(tool_d, font_size_pm, button_gc,
- 31, 12, tmpsiz, strlen(tmpsiz));
-
- /* Fool the toolkit by changing the background pixmap to 0
- then giving it the modified one again. Otherwise, it sees
- that the pixmap ID is not changed and doesn't actually draw
- it into the widget window */
- button_args[3].value = 0;
- XtSetValues(font_size_widget, &button_args[3], 1);
-
- /* put the pixmap in the widget background */
- button_args[3].value = font_size_pm;
- XtSetValues(font_size_widget, &button_args[3], 1);
- }
-
- /* change landscape/portrait flag for print */
-
- static
- land_button(sw)
- F_switch *sw;
- {
- print_landscape = 1-print_landscape;
- land_port(); /* display new state */
- }
-
- /* this is callable from the 'edit' file routine */
-
- land_port()
- {
- land_port_sw->but.normal = land_port_sw->but.reverse =
- button_args[3].value = (XtArgVal) (print_landscape? Lp_pm: lP_pm);
- XtSetValues(land_port_sw->but.widget, &button_args[3], 1);
- put_msg("Print in %s mode",print_landscape? "LANDSCAPE": "PORTRAIT");
- }
-
- /* undo last operation */
-
- static
- undo_button(sw)
- F_switch *sw;
- {
- undo();
- }
-
- /* redisplay */
-
- static
- redisp_button(sw)
- F_switch *sw;
- {
- redisplay_canvas();
- }
-
- turn_on(s)
- F_switch *s;
- {
- s->on = 1;
- button_args[3].value = (XtArgVal)s->but.reverse;
- XtSetValues(s->but.widget, &button_args[3], 1);
- }
-
- turn_off(s)
- F_switch *s;
- {
- s->on = 0;
- button_args[3].value = (XtArgVal)s->but.normal;
- XtSetValues(s->but.widget, &button_args[3], 1);
- }
-
- static
- switch_action(sw)
- F_switch *sw;
- {
- F_switch *old;
-
- if (sw == NULL) return;
-
- if (sw->group == -1) {
- if (sw->on) {
- turn_off(sw);
- off_action(sw);
- }
- else {
- turn_on(sw);
- on_action(sw);
- }
- if (sw->type == S_MOMENT) /* added B.V.Smith */
- {
- turn_off(sw);
- off_action(sw);
- }
- return;
- }
-
- old = group[sw->group];
- if (old == sw) {
- if (old->type != S_ON) {
- turn_off(old);
- off_action(old);
- group[old->group] = NULL;
- }
- return;
- }
- else if (old) {
- turn_off(old);
- off_action(old);
- }
-
- turn_on(sw);
- on_action(sw);
- group[sw->group] = sw;
- if (sw->type == S_MOMENT) /* added B.V.Smith */
- {
- turn_off(sw);
- off_action(sw);
- }
- }
-