static void insert_layerview_buttons (Widget menu) { int i, s; LayerButtons *lb; num_layer_buttons++; s = num_layer_buttons * sizeof (LayerButtons); if (layer_button_list) layer_button_list = (LayerButtons *) realloc (layer_button_list, s); else layer_button_list = (LayerButtons *) malloc (s); lb = layer_button_list + num_layer_buttons - 1; for (i = 0; i < LB_NUM; i++) { static char namestr[] = "Label "; char *name = namestr; Widget btn; name[5] = 'A' + i; switch (i) { case LB_SILK: name = "Silk"; break; case LB_RATS: name = "Rat Lines"; break; case LB_PINS: name = "Pins/Pads"; break; case LB_VIAS: name = "Vias"; break; case LB_BACK: name = "Far Side"; break; case LB_MASK: name = "Solder Mask"; break; } n = 0; if (i < MAX_LAYER && i < 9) { char buf[20], av[30]; Resource *ar; XmString as; sprintf (buf, "Ctrl-%d", i + 1); as = XmStringCreateLocalized (buf); stdarg (XmNacceleratorText, as); ar = resource_create (0); sprintf (av, "ToggleView(%d)", i + 1); resource_add_val (ar, 0, strdup (av), 0); resource_add_val (ar, 0, strdup (av), 0); ar->flags |= FLAG_V; sprintf (av, "Ctrl<Key>%d", i + 1); note_accelerator (av, ar); stdarg (XmNmnemonic, i + '1'); } btn = XmCreateToggleButton (menu, name, args, n); XtManageChild (btn); XtAddCallback (btn, XmNvalueChangedCallback, (XtCallbackProc) layer_button_callback, (XtPointer) (size_t) i); lb->w[i] = btn; if (i == LB_MASK) note_widget_flag (btn, XmNset, "showmask"); } lb->is_pick = 0; LayersChanged (0, 0, 0, 0); }
static void insert_layerpick_buttons (Widget menu) { int i, s; LayerButtons *lb; num_layer_buttons++; s = num_layer_buttons * sizeof (LayerButtons); if (layer_button_list) layer_button_list = (LayerButtons *) realloc (layer_button_list, s); else layer_button_list = (LayerButtons *) malloc (s); lb = layer_button_list + num_layer_buttons - 1; for (i = 0; i < LB_NUMPICK; i++) { static char namestr[] = "Label "; char *name = namestr; int accel_idx = i; char buf[20], av[30]; Widget btn; name[5] = 'A' + i; switch (i) { case LB_SILK: name = "Silk"; accel_idx = max_copper_layer; strcpy (av, "SelectLayer(Silk)"); break; case LB_RATS: name = "Rat Lines"; accel_idx = max_copper_layer + 1; strcpy (av, "SelectLayer(Rats)"); break; default: sprintf (av, "SelectLayer(%d)", i + 1); break; } n = 0; if (accel_idx < 9) { Resource *ar; XmString as; ar = resource_create (0); resource_add_val (ar, 0, strdup (av), 0); resource_add_val (ar, 0, strdup (av), 0); ar->flags |= FLAG_V; sprintf (buf, "%d", i + 1); as = XmStringCreatePCB (buf); stdarg (XmNacceleratorText, as); sprintf (av, "<Key>%d", accel_idx + 1); note_accelerator (av, ar); stdarg (XmNmnemonic, accel_idx + '1'); } stdarg (XmNindicatorType, XmONE_OF_MANY); btn = XmCreateToggleButton (menu, name, args, n); XtManageChild (btn); XtAddCallback (btn, XmNvalueChangedCallback, (XtCallbackProc) layerpick_button_callback, (XtPointer) (size_t) i); lb->w[i] = btn; } lb->is_pick = 1; LayersChanged (0, 0, 0, 0); }