Exemple #1
0
static int
LesstifNetlistShow (int argc, char **argv, Coord x, Coord y)
{
  if (build_netlist_dialog ())
    return 0;

  if (argc == 1)
    {
      LibraryMenuTypePtr net;

      net = netnode_to_netname(argv[0]);
      if (net)
	{
	  XmString item;
	  int vis = 0;

	  /* Select net first, 'True' causes pick_net() to be invoked */
	  item = XmStringCreatePCB (net->Name);
	  XmListSelectItem (netlist_list, item, True);
	  XmListSetItem (netlist_list, item);
	  XmStringFree (item);

	  /* Now the netnode_list has the right contents */
	  item = XmStringCreatePCB (argv[0]);
	  XmListSelectItem (netnode_list, item, False);

	  /*
	   * Only force the item to the top if there are enough to scroll.
	   * A bug (?) in lesstif will cause the window to get ever wider
	   * if an XmList that doesn't require a scrollbar is forced to
	   * have one (when the top item is not the first item).
	   */
	  n = 0;
	  stdarg (XmNvisibleItemCount, &vis);
	  XtGetValues (netnode_list, args, n);
	  if (n_netnode_strings > vis)
	    {
	      XmListSetItem (netnode_list, item);
	    }
	  XmStringFree (item);
	}
      else
	{
	  /* Try the argument as a netname */
	  net = netname_to_netname(argv[0]);
	  if (net)
	    {
	      XmString item;

	      item = XmStringCreatePCB (net->Name);
	      XmListSetItem (netlist_list, item);
	      XmListSelectItem (netlist_list, item, True);
	      XmStringFree (item);
	    }
	}
    }
  return 0;
}
Exemple #2
0
static Widget
netlist_button (Widget parent, char *name, char *string,
		Widget top, Widget bottom, Widget left, Widget right,
		XtCallbackProc callback, void *user_data)
{
  Widget rv;
  XmString str;

#define NLB_W(w) if (w == NLB_FORM) { stdarg(XmN ## w ## Attachment, XmATTACH_FORM); } \
  else if (w) { stdarg(XmN ## w ## Attachment, XmATTACH_WIDGET); \
    stdarg (XmN ## w ## Widget, w); }

  NLB_W (top);
  NLB_W (bottom);
  NLB_W (left);
  NLB_W (right);
  str = XmStringCreatePCB (string);
  stdarg(XmNlabelString, str);
  rv = XmCreatePushButton (parent, name, args, n);
  XtManageChild (rv);
  if (callback)
    XtAddCallback (rv, XmNactivateCallback, callback, (XtPointer)user_data);
  XmStringFree(str);
  return rv;
}
Exemple #3
0
void
lesstif_insert_style_buttons (Widget menu)
{
  StyleButtons *sb;
  int s, i;

  num_style_buttons++;
  s = num_style_buttons * sizeof (StyleButtons);
  style_button_list = (StyleButtons *) realloc (style_button_list, s);
  sb = style_button_list + num_style_buttons - 1;

  for (i = 0; i < NUM_STYLES; i++)
    {
      Widget btn;
      n = 0;
      stdarg (XmNindicatorType, XmONE_OF_MANY);
      stdarg (XmNlabelString,
	      XmStringCreatePCB (PCB->RouteStyle[i].Name));
      btn = XmCreateToggleButton (menu, "style", args, n);
      XtManageChild (btn);
      XtAddCallback (btn, XmNvalueChangedCallback,
		     (XtCallbackProc) style_selected, (XtPointer) (size_t) i);
      sb->w[i] = btn;
    }
  update_style_buttons ();
}
Exemple #4
0
static int
RouteStylesChanged (int argc, char **argv, Coord x, Coord y)
{
  int i, j, h;
  if (!PCB || !PCB->RouteStyle[0].Name)
    return 0;
  update_style_buttons ();
  if (!style_dialog)
    return 0;
  for (j = 0; j < NUM_STYLES; j++)
    {
      h = hash (PCB->RouteStyle[j].Name);
      if (name_hashes[j] == h)
	continue;
      name_hashes[j] = h;
      n = 0;
      stdarg (XmNlabelString,
	      XmStringCreatePCB (PCB->RouteStyle[j].Name));
      if (style_dialog)
	XtSetValues (style_pb[j], args, n);
      for (i = 0; i < num_style_buttons; i++)
	XtSetValues (style_button_list[i].w[j], args, n);
    }
  update_values ();
  return 0;
}
Exemple #5
0
static void
nbcb_rat_off (LibraryMenuTypePtr net, int pos)
{
  XmString str;
  char *name = net->Name;
  name[0] = '*';
  net->flag = 0;
  str = XmStringCreatePCB (name);
  XmListReplaceItemsPos (netlist_list, &str, 1, pos);
  XmStringFree (str);
}
Exemple #6
0
static Widget
style_button (int i)
{
  Widget pb, set;

  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_WIDGET);
  stdarg (XmNtopWidget, i ? style_pb[i - 1] : value_form);
  stdarg (XmNleftAttachment, XmATTACH_FORM);
  stdarg (XmNlabelString, XmStringCreatePCB ("Name"));
  set = XmCreatePushButton (style_dialog, "style", args, n);
  XtManageChild (set);
  XtAddCallback (set, XmNactivateCallback,
		 (XtCallbackProc) style_name_cb, (XtPointer) (size_t) i);

  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_WIDGET);
  stdarg (XmNtopWidget, i ? style_pb[i - 1] : value_form);
  stdarg (XmNleftAttachment, XmATTACH_WIDGET);
  stdarg (XmNleftWidget, set);
  stdarg (XmNlabelString, XmStringCreatePCB ("Set"));
  set = XmCreatePushButton (style_dialog, "style", args, n);
  XtManageChild (set);
  XtAddCallback (set, XmNactivateCallback,
		 (XtCallbackProc) style_set_cb, (XtPointer) (size_t) i);

  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_WIDGET);
  stdarg (XmNtopWidget, i ? style_pb[i - 1] : value_form);
  stdarg (XmNrightAttachment, XmATTACH_FORM);
  stdarg (XmNleftAttachment, XmATTACH_WIDGET);
  stdarg (XmNleftWidget, set);
  stdarg (XmNlabelString, XmStringCreatePCB (PCB->RouteStyle[i].Name));
  stdarg (XmNindicatorType, XmONE_OF_MANY);
  stdarg (XmNalignment, XmALIGNMENT_BEGINNING);
  pb = XmCreateToggleButton (style_dialog, "style", args, n);
  XtManageChild (pb);
  XtAddCallback (pb, XmNvalueChangedCallback,
		 (XtCallbackProc) style_selected, (XtPointer) (size_t) i);
  return pb;
}
Exemple #7
0
static void
pick_net (int pick)
{
  LibraryMenuType *menu = Library.Menu + pick;
  int i;

  if (pick == last_pick)
    return;
  last_pick = pick;

  if (libnode_strings)
    free (libnode_strings);
  libnode_strings = (XmString *) malloc (menu->EntryN * sizeof (XmString));
  for (i = 0; i < menu->EntryN; i++)
    libnode_strings[i] = XmStringCreatePCB (menu->Entry[i].ListEntry);
  n = 0;
  stdarg (XmNitems, libnode_strings);
  stdarg (XmNitemCount, menu->EntryN);
  XtSetValues (libnode_list, args, n);
}
Exemple #8
0
static void
pick_net (int pick)
{
  LibraryMenuType *menu = PCB->NetlistLib.Menu + pick;
  int i;

  if (pick == last_pick)
    return;
  last_pick = pick;

  if (netnode_strings)
    free (netnode_strings);	/* XXX leaked all XmStrings??? */
  n_netnode_strings = menu->EntryN;
  netnode_strings = (XmString *) malloc (menu->EntryN * sizeof (XmString));
  for (i = 0; i < menu->EntryN; i++)
    netnode_strings[i] = XmStringCreatePCB (menu->Entry[i].ListEntry);
  n = 0;
  stdarg (XmNitems, netnode_strings);
  stdarg (XmNitemCount, menu->EntryN);
  XtSetValues (netnode_list, args, n);
}
Exemple #9
0
static int
LibraryChanged (int argc, char **argv, Coord x, Coord y)
{
  int i;
  if (!Library.MenuN)
    return 0;
  if (build_library_dialog ())
    return 0;
  last_pick = -1;
  if (library_strings)
    free (library_strings);
  library_strings = (XmString *) malloc (Library.MenuN * sizeof (XmString));
  for (i = 0; i < Library.MenuN; i++)
    library_strings[i] = XmStringCreatePCB (Library.Menu[i].Name);
  n = 0;
  stdarg (XmNitems, library_strings);
  stdarg (XmNitemCount, Library.MenuN);
  XtSetValues (library_list, args, n);
  pick_net (0);
  return 0;
}
Exemple #10
0
void
lesstif_get_xy (const char *message)
{
  XmString ls = XmStringCreatePCB ((char *)message);

  XtManageChild (m_click);
  n = 0;
  stdarg (XmNlabelString, ls);
  XtSetValues (m_click, args, n);
  //printf("need xy: msg `%s'\n", msg);
  need_xy = 1;
  XBell (display, 100);
  while (!have_xy)
    {
      XEvent e;
      XtAppNextEvent (app_context, &e);
      XtDispatchEvent (&e);
    }
  need_xy = 0;
  have_xy = 1;
  XtUnmanageChild (m_click);
}
Exemple #11
0
static void
netlist_select (Widget w, void *v, XmListCallbackStruct * cbs)
{
  XmString str;
  int pos = cbs->item_position;
  LibraryMenuTypePtr net = & (PCB->NetlistLib.Menu[pos - 1]);
  char *name = net->Name;
  if (name[0] == ' ')
    {
      name[0] = '*';
      net->flag = 0;
    }
  else
    {
      name[0] = ' ';
      net->flag = 1;
    }

  str = XmStringCreatePCB (name);
  XmListReplaceItemsPos (netlist_list, &str, 1, pos);
  XmStringFree (str);
  XmListSelectPos (netlist_list, pos, False);
}
Exemple #12
0
static int
LesstifNetlistChanged (int argc, char **argv, Coord x, Coord y)
{
  int i;
  if (!PCB->NetlistLib.MenuN)
    return 0;
  if (build_netlist_dialog ())
    return 0;
  last_pick = -1;
  if (netlist_strings)
    free (netlist_strings);
  netlist_strings =
    (XmString *) malloc (PCB->NetlistLib.MenuN * sizeof (XmString));
  for (i = 0; i < PCB->NetlistLib.MenuN; i++)
    netlist_strings[i] =
      XmStringCreatePCB (PCB->NetlistLib.Menu[i].Name);
  n = 0;
  stdarg (XmNitems, netlist_strings);
  stdarg (XmNitemCount, PCB->NetlistLib.MenuN);
  XtSetValues (netlist_list, args, n);
  pick_net (0);
  return 0;
}
Exemple #13
0
static void
layerpick_button_callback (Widget w, int layer,
			   XmPushButtonCallbackStruct * pbcs)
{
  int l, i;
  char *name;
  PCB->RatDraw = (layer == LB_RATS);
  PCB->SilkActive = (layer == LB_SILK);
  if (layer < max_copper_layer)
    ChangeGroupVisibility (layer, 1, 1);
  for (l = 0; l < num_layer_buttons; l++)
    {
      LayerButtons *lb = layer_button_list + l;
      if (!lb->is_pick)
	continue;
      for (i = 0; i < LB_NUMPICK; i++)
	XmToggleButtonSetState (lb->w[i], layer == i, False);
    }
  switch (layer)
    {
    case LB_RATS:
      name = "Rats";
      break;
    case LB_SILK:
      name = "Silk";
      break;
    default:
      name = PCB->Data->Layer[layer].Name;
      break;
    }
  n = 0;
  stdarg (XmNbackground, fg_colors[layer]);
  stdarg (XmNforeground, bg_color);
  stdarg (XmNlabelString, XmStringCreatePCB (name));
  XtSetValues (lesstif_m_layer, args, n);
  lesstif_invalidate_all ();
}
Exemple #14
0
static void
add_resource_to_menu (Widget menu, Resource * node, XtCallbackProc callback)
{
  int i, j;
  char *v;
  Widget sub, btn;
  Resource *r;

  for (i = 0; i < node->c; i++)
    switch (resource_type (node->v[i]))
      {
      case 101:		/* named subnode */
	n = 0;
	stdarg (XmNtearOffModel, XmTEAR_OFF_ENABLED);
	sub = XmCreatePulldownMenu (menu, node->v[i].name, args, n);
	XtSetValues (sub, args, n);
	n = 0;
	stdarg (XmNsubMenuId, sub);
	btn = XmCreateCascadeButton (menu, node->v[i].name, args, n);
	XtManageChild (btn);
	add_resource_to_menu (sub, node->v[i].subres, callback);
	break;

      case 1:			/* unnamed subres */
	n = 0;
#if 0
	if ((v = resource_value (node->v[i].subres, "fg")))
	  {
	    do_color (v, XmNforeground);
	  }
	if ((v = resource_value (node->v[i].subres, "bg")))
	  {
	    do_color (v, XmNbackground);
	  }
	if ((v = resource_value (node->v[i].subres, "font")))
	  {
	    XFontStruct *fs = XLoadQueryFont (display, v);
	    if (fs)
	      {
		XmFontList fl =
		  XmFontListCreate (fs, XmSTRING_DEFAULT_CHARSET);
		stdarg (XmNfontList, fl);
	      }
	  }
#endif
	if ((v = resource_value (node->v[i].subres, "m")))
	  {
	    stdarg (XmNmnemonic, v);
	  }
	if ((r = resource_subres (node->v[i].subres, "a")))
	  {
	    XmString as = XmStringCreatePCB (r->v[0].value);
	    stdarg (XmNacceleratorText, as);
	    //stdarg(XmNaccelerator, r->v[1].value);
	    note_accelerator (r->v[1].value, node->v[i].subres);
	  }
	v = "button";
	for (j = 0; j < node->v[i].subres->c; j++)
	  if (resource_type (node->v[i].subres->v[j]) == 10)
	    {
	      v = node->v[i].subres->v[j].value;
	      break;
	    }
	stdarg (XmNlabelString, XmStringCreatePCB (v));
	if (node->v[i].subres->flags & FLAG_S)
	  {
	    int nn = n;
	    stdarg (XmNtearOffModel, XmTEAR_OFF_ENABLED);
	    sub = XmCreatePulldownMenu (menu, v, args + nn, n - nn);
	    n = nn;
	    stdarg (XmNsubMenuId, sub);
	    btn = XmCreateCascadeButton (menu, "menubutton", args, n);
	    XtManageChild (btn);
	    add_resource_to_menu (sub, node->v[i].subres, callback);
	  }
	else
	  {
	    Resource *radio = resource_subres (node->v[i].subres, "radio");
	    char *checked = resource_value (node->v[i].subres, "checked");
	    char *label = resource_value (node->v[i].subres, "sensitive");
	    if (radio)
	      {
		ToggleItem *ti = (ToggleItem *) malloc (sizeof (ToggleItem));
		ti->next = toggle_items;
		ti->group = radio->v[0].value;
		ti->item = radio->v[1].value;
		ti->callback = callback;
		ti->node = node->v[i].subres;
		toggle_items = ti;

		if (resource_value (node->v[i].subres, "set"))
		  {
		    stdarg (XmNset, True);
		  }
		stdarg (XmNindicatorType, XmONE_OF_MANY);
		btn = XmCreateToggleButton (menu, "menubutton", args, n);
		ti->w = btn;
		XtAddCallback (btn, XmNvalueChangedCallback,
			       (XtCallbackProc) radio_callback,
			       (XtPointer) ti);
	      }
	    else if (checked)
	      {
		if (strchr (checked, ','))
		  stdarg (XmNindicatorType, XmONE_OF_MANY);
		else
		  stdarg (XmNindicatorType, XmN_OF_MANY);
		btn = XmCreateToggleButton (menu, "menubutton", args, n);
		XtAddCallback (btn, XmNvalueChangedCallback,
			       callback, (XtPointer) node->v[i].subres);
	      }
	    else if (label && strcmp (label, "false") == 0)
	      {
		stdarg (XmNalignment, XmALIGNMENT_BEGINNING);
		btn = XmCreateLabel (menu, "menulabel", args, n);
	      }
	    else
	      {
		btn = XmCreatePushButton (menu, "menubutton", args, n);
		XtAddCallback (btn, XmNactivateCallback,
			       callback, (XtPointer) node->v[i].subres);
	      }

	    for (j = 0; j < node->v[i].subres->c; j++)
	      switch (resource_type (node->v[i].subres->v[j]))
		{
		case 110:	/* named value = X resource */
		  {
		    char *n = node->v[i].subres->v[j].name;
		    if (strcmp (n, "fg") == 0)
		      n = "foreground";
		    if (strcmp (n, "bg") == 0)
		      n = "background";
		    if (strcmp (n, "m") == 0
			|| strcmp (n, "a") == 0
			|| strcmp (n, "sensitive") == 0)
		      break;
		    if (strcmp (n, "checked") == 0)
		      {
			note_widget_flag (btn, XmNset,
					  node->v[i].subres->v[j].value);
			break;
		      }
		    if (strcmp (n, "active") == 0)
		      {
			note_widget_flag (btn, XmNsensitive,
					  node->v[i].subres->v[j].value);
			break;
		      }
		    XtVaSetValues (btn, XtVaTypedArg,
				   n,
				   XtRString,
				   node->v[i].subres->v[j].value,
				   strlen (node->v[i].subres->v[j].value) + 1,
				   NULL);
		  }
		  break;
		}

	    XtManageChild (btn);
	  }
	break;

      case 10:			/* unnamed value */
	n = 0;
	if (node->v[i].value[0] == '@')
	  {
	    if (strcmp (node->v[i].value, "@layerview") == 0)
	      insert_layerview_buttons (menu);
	    if (strcmp (node->v[i].value, "@layerpick") == 0)
	      insert_layerpick_buttons (menu);
	    if (strcmp (node->v[i].value, "@routestyles") == 0)
	      lesstif_insert_style_buttons (menu);
	  }
	else if (strcmp (node->v[i].value, "-") == 0)
	  {
	    btn = XmCreateSeparator (menu, "sep", args, n);
	    XtManageChild (btn);
	  }
	else if (i > 0)
	  {
	    btn = XmCreatePushButton (menu, node->v[i].value, args, n);
	    XtManageChild (btn);
	  }
	break;
      }
}
Exemple #15
0
static int
build_netlist_dialog ()
{
  Widget b_sel, b_unsel, b_find, b_ripup, b_rat_on, b_rat_off, l_ops;
  XmString ops_str;

  if (!mainwind)
    return 1;
  if (netlist_dialog)
    return 0;

  n = 0;
  stdarg (XmNresizePolicy, XmRESIZE_GROW);
  stdarg (XmNtitle, "Netlists");
  stdarg (XmNautoUnmanage, False);
  netlist_dialog = XmCreateFormDialog (mainwind, "netlist", args, n);

  n = 0;
  b_rat_on = netlist_button (netlist_dialog, "rat_on", "Enable for rats",
			     0, NLB_FORM, NLB_FORM, 0,
			     (XtCallbackProc)nbcb_std_callback, (void *)nbcb_rat_on);

  n = 0;
  b_rat_off = netlist_button (netlist_dialog, "rat_off", "Disable for rats",
			      0, NLB_FORM, b_rat_on, 0,
			      (XtCallbackProc)nbcb_std_callback, (void *)nbcb_rat_off);

  n = 0;
  b_sel = netlist_button (netlist_dialog, "select", "Select",
			  0, b_rat_on, NLB_FORM, 0, 
			      (XtCallbackProc)nbcb_std_callback, (void *)nbcb_select);

  n = 0;
  b_unsel = netlist_button (netlist_dialog, "deselect", "Deselect",
			    0, b_rat_on, b_sel, 0, 
			      (XtCallbackProc)nbcb_std_callback, (void *)nbcb_deselect);

  n = 0;
  b_find = netlist_button (netlist_dialog, "find", "Find",
			   0, b_rat_on, b_unsel, 0,
			   (XtCallbackProc)nbcb_std_callback, (void *)nbcb_find);


  n = 0;
  b_ripup = netlist_button (netlist_dialog, "ripup", "Rip Up",
			    0, b_rat_on, b_find, 0,
			    (XtCallbackProc)nbcb_ripup, 0);

  n = 0;
  stdarg (XmNbottomAttachment, XmATTACH_WIDGET);
  stdarg (XmNbottomWidget, b_sel);
  stdarg (XmNleftAttachment, XmATTACH_FORM);
  ops_str = XmStringCreatePCB ("Operations on selected net names:");
  stdarg (XmNlabelString, ops_str);
  l_ops = XmCreateLabel (netlist_dialog, "ops", args, n);
  XtManageChild (l_ops);

  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_FORM);
  stdarg (XmNbottomAttachment, XmATTACH_WIDGET);
  stdarg (XmNbottomWidget, l_ops);
  stdarg (XmNleftAttachment, XmATTACH_FORM);
  stdarg (XmNrightAttachment, XmATTACH_POSITION);
  stdarg (XmNrightPosition, 50);
  stdarg (XmNvisibleItemCount, 10);
  stdarg (XmNselectionPolicy, XmEXTENDED_SELECT);
  netlist_list = XmCreateScrolledList (netlist_dialog, "nets", args, n);
  XtManageChild (netlist_list);
  XtAddCallback (netlist_list, XmNdefaultActionCallback, (XtCallbackProc)netlist_select, 0);
  XtAddCallback (netlist_list, XmNextendedSelectionCallback, (XtCallbackProc)netlist_extend, 0);

  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_FORM);
  stdarg (XmNbottomAttachment, XmATTACH_WIDGET);
  stdarg (XmNbottomWidget, l_ops);
  stdarg (XmNrightAttachment, XmATTACH_FORM);
  stdarg (XmNleftAttachment, XmATTACH_POSITION);
  stdarg (XmNleftPosition, 50);
  netnode_list = XmCreateScrolledList (netlist_dialog, "nodes", args, n);
  XtManageChild (netnode_list);
  XtAddCallback (netnode_list, XmNbrowseSelectionCallback, (XtCallbackProc)netnode_browse, 0);

  return 0;
}
Exemple #16
0
static int
LayersChanged (int argc, char **argv, Coord x, Coord y)
{
  int l, i, set;
  char *name;
  int current_layer;

  if (!layer_button_list)
    return 0;
  if (PCB && PCB->Data)
    {
      DataType *d = PCB->Data;
      for (i = 0; i < MAX_LAYER; i++)
	fg_colors[i] = lesstif_parse_color (d->Layer[i].Color);
      fg_colors[LB_SILK] = lesstif_parse_color (PCB->ElementColor);
      fg_colors[LB_RATS] = lesstif_parse_color (PCB->RatColor);
      fg_colors[LB_PINS] = lesstif_parse_color (PCB->PinColor);
      fg_colors[LB_VIAS] = lesstif_parse_color (PCB->ViaColor);
      fg_colors[LB_BACK] =
	lesstif_parse_color (PCB->InvisibleObjectsColor);
      fg_colors[LB_MASK] = lesstif_parse_color (PCB->MaskColor);
      bg_color = lesstif_parse_color (Settings.BackgroundColor);
    }
  else
    {
      for (i = 0; i < MAX_LAYER; i++)
	fg_colors[i] = lesstif_parse_color (Settings.LayerColor[i]);
      fg_colors[LB_SILK] = lesstif_parse_color (Settings.ElementColor);
      fg_colors[LB_RATS] = lesstif_parse_color (Settings.RatColor);
      fg_colors[LB_PINS] = lesstif_parse_color (Settings.PinColor);
      fg_colors[LB_VIAS] = lesstif_parse_color (Settings.ViaColor);
      fg_colors[LB_BACK] =
	lesstif_parse_color (Settings.InvisibleObjectsColor);
      fg_colors[LB_MASK] = lesstif_parse_color (Settings.MaskColor);
      bg_color = lesstif_parse_color (Settings.BackgroundColor);
    }

  if (PCB->RatDraw)
    current_layer = LB_RATS;
  else if (PCB->SilkActive)
    current_layer = LB_SILK;
  else
    current_layer = LayerStack[0];

  for (l = 0; l < num_layer_buttons; l++)
    {
      LayerButtons *lb = layer_button_list + l;
      for (i = 0; i < (lb->is_pick ? LB_NUMPICK : LB_NUM); i++)
	{
	  switch (i)
	    {
	    case LB_SILK:
	      set = PCB->ElementOn;
	      break;
	    case LB_RATS:
	      set = PCB->RatOn;
	      break;
	    case LB_PINS:
	      set = PCB->PinOn;
	      break;
	    case LB_VIAS:
	      set = PCB->ViaOn;
	      break;
	    case LB_BACK:
	      set = PCB->InvisibleObjectsOn;
	      break;
	    case LB_MASK:
	      set = TEST_FLAG (SHOWMASKFLAG, PCB);
	      break;
	    default:		/* layers */
	      set = PCB->Data->Layer[i].On;
	      break;
	    }

	  n = 0;
	  if (i < MAX_LAYER && PCB->Data->Layer[i].Name)
	    {
	      XmString s = XmStringCreatePCB (PCB->Data->Layer[i].Name);
	      stdarg (XmNlabelString, s);
	    }
	  if (!lb->is_pick)
	    {
	      if (set)
		{
		  stdarg (XmNforeground, bg_color);
		  stdarg (XmNbackground, fg_colors[i]);
		}
	      else
		{
		  stdarg (XmNforeground, fg_colors[i]);
		  stdarg (XmNbackground, bg_color);
		}
	      stdarg (XmNset, set);
	    }
	  else
	    {
	      stdarg (XmNforeground, bg_color);
	      stdarg (XmNbackground, fg_colors[i]);
	      stdarg (XmNset, current_layer == i ? True : False);
	    }
	  XtSetValues (lb->w[i], args, n);

	  if (i >= max_copper_layer && i < MAX_LAYER)
	    XtUnmanageChild(lb->w[i]);
	  else
	    XtManageChild(lb->w[i]);
	}
    }
  if (lesstif_m_layer)
    {
      switch (current_layer)
	{
	case LB_RATS:
	  name = "Rats";
	  break;
	case LB_SILK:
	  name = "Silk";
	  break;
	default:
	  name = PCB->Data->Layer[current_layer].Name;
	  break;
	}
      n = 0;
      stdarg (XmNbackground, fg_colors[current_layer]);
      stdarg (XmNforeground, bg_color);
      stdarg (XmNlabelString, XmStringCreatePCB (name));
      XtSetValues (lesstif_m_layer, args, n);
    }

  lesstif_update_layer_groups ();

  return 0;
}
Exemple #17
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);
}
Exemple #18
0
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;
      int accel_idx = i;
      Widget btn;
      name[5] = 'A' + i;
      switch (i)
	{
	case LB_SILK:
	  name = "Silk";
          accel_idx = max_copper_layer;
	  break;
	case LB_RATS:
	  name = "Rat Lines";
          accel_idx = max_copper_layer + 1;
	  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 (accel_idx < 9)
	{
	  char buf[20], av[30];
	  Resource *ar;
	  XmString as;
	  sprintf (buf, "Ctrl-%d", accel_idx + 1);
	  as = XmStringCreatePCB (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", accel_idx + 1);
	  note_accelerator (av, ar);
	  stdarg (XmNmnemonic, accel_idx + '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);
}