? actionlist.c
? gather-actions
? menu.res
? res_lex.l
? res_parse.y
? resmenu.c
? resmenu.h
? resource.h

Index: Makefile.am
===================================================================
RCS file: /cvsroot/pcb/pcb/src/Makefile.am,v
retrieving revision 1.7
diff -p -2 -r1.7 Makefile.am
*** Makefile.am	27 Feb 2004 06:16:48 -0000	1.7
--- Makefile.am	30 Mar 2004 20:42:53 -0000
*************** pcb_bin_SOURCES = \
*** 19,22 ****
--- 19,23 ----
  	action.c \
  	action.h \
+ 	actionlist.c \
  	autoplace.c \
  	autoplace.h \
*************** pcb_bin_SOURCES = \
*** 123,126 ****
--- 124,130 ----
  	report.c \
  	report.h \
+ 	res_parse.y \
+ 	res_lex.l \
+ 	resmenu.c \
  	rotate.c \
  	rotate.h \
*************** AM_YFLAGS=	-d
*** 159,162 ****
--- 163,169 ----
  all-local: pcbtest.sh .test/Pcb
  
+ actionlist.c : ${pcb_bin_SOURCES} gather-actions
+ 	perl ./gather-actions ${pcb_bin_SOURCES}
+ 
  DISTCLEANFILES= pcbtest.sh Pcb .test/Pcb
  
Index: action.h
===================================================================
RCS file: /cvsroot/pcb/pcb/src/action.h,v
retrieving revision 1.4
diff -p -2 -r1.4 action.h
*** action.h	4 Mar 2004 04:38:51 -0000	1.4
--- action.h	30 Mar 2004 20:42:54 -0000
*************** void	ActionButton3(Widget, XEvent *, Str
*** 89,92 ****
--- 89,94 ----
  void	ActionSetSame(Widget, XEvent *, String *, Cardinal *);
  void	ActionRipUp(Widget, XEvent *, String *, Cardinal *);
+ void	ActionGetLocation(Widget, XEvent *, String *, Cardinal *);
+ void	ActionAbout(Widget, XEvent *, String *, Cardinal *);
  void	AdjustAttachedObjects(void);
  void	CallActionProc(Widget, String, XEvent *, String *, Cardinal);
Index: gui.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/gui.c,v
retrieving revision 1.4
diff -p -2 -r1.4 gui.c
*** gui.c	5 Jan 2004 01:40:24 -0000	1.4
--- gui.c	30 Mar 2004 20:42:54 -0000
***************
*** 38,41 ****
--- 38,42 ----
  #include "gui.h"
  #include "misc.h"
+ #include "action.h"
  
  #include <X11/cursorfont.h>
*************** GetLocation (char *MessageText)
*** 176,179 ****
--- 177,190 ----
  }
  
+ /* ---------------------------------------------------------------------------*/
+ 
+ void
+ ActionGetLocation (Widget w, XEvent * e, String * argv, Cardinal * argc)
+ {
+   GetLocation(argv[0]);
+ }
+ 
+ /* ACTION(GetXY,ActionGetLocation) */
+ 
  /* ---------------------------------------------------------------------------
   * sets the X cursor for the output window (uses cursorfont)
Index: main.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/main.c,v
retrieving revision 1.13
diff -p -2 -r1.13 main.c
*** main.c	4 Mar 2004 04:38:51 -0000	1.13
--- main.c	30 Mar 2004 20:42:55 -0000
*************** static char *rcsid = "$Id: main.c,v 1.13
*** 62,65 ****
--- 62,66 ----
  #include "set.h"
  #include "djopt.h"
+ #include "resource.h"
  
  #include <X11/cursorfont.h>
*************** extern void stroke_init (void);
*** 87,90 ****
--- 88,94 ----
  #endif
  
+ extern XtActionsRec ActionList[];
+ extern int ActionListSize;
+ 
  /* ---------------------------------------------------------------------------
   * some local prototypes
*************** static XtActionsRec Actions[] = {
*** 962,966 ****
    {"ToggleVisibility", ActionToggleVisibility},
    {"MoveObject", ActionMoveObject},
!   {"djopt", ActionDJopt}
  };
  
--- 966,971 ----
    {"ToggleVisibility", ActionToggleVisibility},
    {"MoveObject", ActionMoveObject},
!   {"djopt", ActionDJopt},
!   {"GetLoc", ActionGetLocation}
  };
  
*************** InitWidgets (void)
*** 1222,1225 ****
--- 1227,1233 ----
  					       XtNresizable, True, NULL);
  
+   XtAppAddActions (Context, Actions, XtNumber (Actions));
+   XtAppAddActions (Context, ActionList, ActionListSize);
+ 
    /* init all other widgets as childs of the masterform */
    InitMenu (Output.MasterForm, NULL, NULL);
*************** InitWidgets (void)
*** 1233,1237 ****
     * for XawPositionSimpleMenu() to be available
     */
-   XtAppAddActions (Context, Actions, XtNumber (Actions));
    XtAugmentTranslations (Output.Toplevel,
  			 XtParseTranslationTable (DefaultTranslations));
--- 1241,1244 ----
Index: menu.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/menu.c,v
retrieving revision 1.27
diff -p -2 -r1.27 menu.c
*** menu.c	28 Mar 2004 17:45:16 -0000	1.27
--- menu.c	30 Mar 2004 20:42:55 -0000
*************** static char *rcsid = "$Id: menu.c,v 1.27
*** 54,57 ****
--- 54,59 ----
  #include "output.h"
  #include "sizedialog.h"
+ #include "resource.h"
+ #include "resmenu.h"
  
  #include <X11/cursorfont.h>
*************** UpdateSizesMenu (void)
*** 592,599 ****
--- 594,663 ----
    int i;
  
+ #if 0
    FillSizesMenu ();
    for (i = 0; i < 2 * NUM_STYLES + 1; i++)
      XtVaSetValues (SizesMenuEntries[i].W, XtNlabel, SizesMenuEntries[i].Label,
  		   NULL);
+ #endif
+ }
+ 
+ /* FLAG(style,FlagCurrentStyle) */
+ int
+ FlagCurrentStyle()
+ {
+   STYLE_LOOP (PCB, 
+     {
+       if (style->Thick == Settings.LineThickness &&
+ 	  style->Diameter == Settings.ViaThickness &&
+ 	  style->Hole == Settings.ViaDrillingHole)
+ 	return n+1;
+     }
+   );
+   return 0;
+ }
+ 
+ /* MENU(sizes,SizesMenuInclude) */
+ void
+ SizesMenuInclude(Resource *menu)
+ {
+   char tmp[64];
+   int i;
+ 
+   for (i = 0; i <  NUM_STYLES; i++)
+     {
+       Resource *sub = resource_create(menu);
+       resource_add_val (sub, 0, PCB->RouteStyle[i].Name, 0);
+       sprintf(tmp, "SizesLabel(%d,use)", i);
+       resource_add_val (sub, 0, MyStrdup(tmp, __FUNCTION__), 0);
+       sprintf(tmp, "RouteStyle(%d)", i+1);
+       resource_add_val (sub, 0, MyStrdup(tmp, __FUNCTION__), 0);
+       sprintf(tmp, "CheckWhen(style,%d)", i+1);
+       resource_add_val (sub, 0, MyStrdup(tmp, __FUNCTION__), 0);
+       resource_add_val (menu, 0, 0, sub);
+     }
+   for (i = 0; i <  NUM_STYLES; i++)
+     {
+       Resource *sub = resource_create(menu);
+       resource_add_val (sub, 0, PCB->RouteStyle[i].Name, 0);
+       sprintf(tmp, "SizesLabel(%d,set)", i);
+       resource_add_val (sub, 0, MyStrdup(tmp, __FUNCTION__), 0);
+       sprintf(tmp, "AdjustStyle(%d)", i+1);
+       resource_add_val (sub, 0, MyStrdup(tmp, __FUNCTION__), 0);
+       resource_add_val (menu, 0, 0, sub);
+     }
+ }
+ 
+ /* ACTION(SizesLabel,ActionSizesLabel) POPUP */
+ void
+ ActionSizesLabel (Widget w, XEvent * e, String * argv, Cardinal * argc)
+ {
+   char tmp[64];
+   int i = atoi(argv[0]);
+ 
+   if (strcmp(argv[1], "use") == 0)
+     sprintf(tmp, "Use '%s' routing style", PCB->RouteStyle[i].Name);
+   else
+     sprintf(tmp, "Adjust '%s' sizes ...", PCB->RouteStyle[i].Name);
+   XtVaSetValues (w, XtNlabel, tmp, NULL);
  }
  
*************** DoWindows (Widget W, XtPointer ClientDat
*** 635,638 ****
--- 699,708 ----
  }
  
+ /* ACTION(DoWindows,ActionDoWindows) */
+ void
+ ActionDoWindows (Widget w, XEvent * e, String * argv, Cardinal * argc)
+ {
+   DoWindows(w, argv[0], 0);
+ }
  
  /* ----------------------------------------------------------------------
*************** CBPOPUP_Display (Widget W, XtPointer Cli
*** 819,822 ****
--- 889,971 ----
  }
  
+ /* FLAG(grid,FlagGrid) */
+ int
+ FlagGrid()
+ {
+   return (int)PCB->Grid;
+ }
+ 
+ /* FLAG(zoom,FlagZoom) */
+ int
+ FlagZoom()
+ {
+   int zoom = (int)(PCB->Zoom + (PCB->Zoom < 0 ? -0.5 : 0.5));
+   if (abs(PCB->Zoom - zoom) > 0.1)
+     zoom = -8; /* not close enough to integer value */
+   return zoom;
+ }
+ 
+ /* FLAG(elementname,FlagElementName) */
+ int
+ FlagElementName()
+ {
+   if (TEST_FLAG (NAMEONPCBFLAG, PCB))
+     return 2;
+   if (TEST_FLAG (DESCRIPTIONFLAG, PCB))
+     return 1;
+   return 3;
+ }
+ 
+ /* FLAG(gridfactor,FlagGridFactor) */
+ int
+ FlagGridFactor()
+ {
+   return GetGridFactor() != 0;
+ }
+ 
+ /* FLAG(shownumber,FlagTESTFLAG,SHOWNUMBERFLAG) */
+ /* FLAG(localref,FlagTESTFLAG,LOCALREFFLAG) */
+ /* FLAG(checkplanes,FlagTESTFLAG,CHECKPLANESFLAG) */
+ /* FLAG(showdrc,FlagTESTFLAG,SHOWDRCFLAG) */
+ /* FLAG(rubberband,FlagTESTFLAG,RUBBERBANDFLAG) */
+ /* FLAG(description,FlagTESTFLAG,DESCRIPTIONFLAG) */
+ /* FLAG(nameonpcb,FlagTESTFLAG,NAMEONPCBFLAG) */
+ /* FLAG(autodrc,FlagTESTFLAG,AUTODRCFLAG) */
+ /* FLAG(alldirection,FlagTESTFLAG,ALLDIRECTIONFLAG) */
+ /* FLAG(swapstartdir,FlagTESTFLAG,SWAPSTARTDIRFLAG) */
+ /* FLAG(uniquename,FlagTESTFLAG,UNIQUENAMEFLAG) */
+ /* FLAG(clearnew,FlagTESTFLAG,CLEARNEWFLAG) */
+ /* FLAG(snappin,FlagTESTFLAG,SNAPPINFLAG) */
+ /* FLAG(showmask,FlagTESTFLAG,SHOWMASKFLAG) */
+ /* FLAG(thindraw,FlagTESTFLAG,THINDRAWFLAG) */
+ /* FLAG(orthomove,FlagTESTFLAG,ORTHOMOVEFLAG) */
+ int
+ FlagTESTFLAG(int bit)
+ {
+   return TEST_FLAG(bit, PCB) ? 1 : 0;
+ }
+ 
+ /* FLAG(clearline,FlagSETTINGS,XtOffsetOf(SettingType,ClearLine)) */
+ /* FLAG(uniquenames,FlagSETTINGS,XtOffsetOf(SettingType,UniqueNames)) */
+ /* FLAG(uselogwindow,FlagSETTINGS,XtOffsetOf(SettingType,UseLogWindow)) */
+ /* FLAG(raiselogwindow,FlagSETTINGS,XtOffsetOf(SettingType,RaiseLogWindow)) */
+ /* FLAG(showsolderside,FlagSETTINGS,XtOffsetOf(SettingType,ShowSolderSide)) */
+ /* FLAG(savelastcommand,FlagSETTINGS,XtOffsetOf(SettingType,SaveLastCommand)) */
+ /* FLAG(saveintmp,FlagSETTINGS,XtOffsetOf(SettingType,SaveInTMP)) */
+ /* FLAG(drawgrid,FlagSETTINGS,XtOffsetOf(SettingType,DrawGrid)) */
+ /* FLAG(ratwarn,FlagSETTINGS,XtOffsetOf(SettingType,RatWarn)) */
+ /* FLAG(stipplepolygons,FlagSETTINGS,XtOffsetOf(SettingType,StipplePolygons)) */
+ /* FLAG(alldirectionlines,FlagSETTINGS,XtOffsetOf(SettingType,AllDirectionLines)) */
+ /* FLAG(rubberbandmode,FlagSETTINGS,XtOffsetOf(SettingType,RubberBandMode)) */
+ /* FLAG(swapstartdirection,FlagSETTINGS,XtOffsetOf(SettingType,SwapStartDirection)) */
+ /* FLAG(showdrc,FlagSETTINGS,XtOffsetOf(SettingType,ShowDRC)) */
+ /* FLAG(resetafterelement,FlagSETTINGS,XtOffsetOf(SettingType,ResetAfterElement)) */
+ /* FLAG(ringbellwhenfinished,FlagSETTINGS,XtOffsetOf(SettingType,RingBellWhenFinished)) */
+ int
+ FlagSETTINGS(int ofs)
+ {
+   return *(Boolean *)((char *)(&Settings) + ofs);
+ }
+ 
  /* ---------------------------------------------------------------------- 
   * called before settings menu is popped up
*************** CBPOPUP_Buffer (Widget W, XtPointer Clie
*** 880,883 ****
--- 1029,1039 ----
  }
  
+ /* FLAG(buffer,FlagBuffer) */
+ int
+ FlagBuffer()
+ {
+   return Settings.BufferNumber + 1;
+ }
+ 
  /* ---------------------------------------------------------------------- 
   * called before window menu is popped up
*************** CBPOPUP_Window (Widget W, XtPointer Clie
*** 893,896 ****
--- 1049,1058 ----
  }
  
+ /* FLAG(netlist,FlagNetlist) */
+ int
+ FlagNetlist()
+ {
+   return PCB->NetlistLib.Wind != 0;
+ }
  
  /* ---------------------------------------------------------------------- 
*************** CB_About (Widget W, XtPointer ClientData
*** 903,906 ****
--- 1065,1070 ----
  }
  
+ /* ACTION(About,AboutDialog) */
+ 
  /* ---------------------------------------------------------------------------
   * remove all 'check' symbols from menu entries
*************** InitMenu (Widget Parent, Widget Top, Wid
*** 1034,1039 ****
  {
    Widget last;
  
!   last = InitMenuButton (Parent, &FileMenuButton, Top, Left);
    last = InitMenuButton (Parent, &EditMenuButton, Top, last);
    last = InitMenuButton (Parent, &DisplayMenuButton, Top, last);
--- 1198,1210 ----
  {
    Widget last;
+   Resource *res;
+ 
+   res = resource_parse("menu.res", 0);
+   if (!res)
+     return;
+   last = MenuCreateFromResource (Parent, res, Top, Left, 1);
  
! #if 0
!   last = InitMenuButton (Parent, &FileMenuButton, Top, last);
    last = InitMenuButton (Parent, &EditMenuButton, Top, last);
    last = InitMenuButton (Parent, &DisplayMenuButton, Top, last);
*************** InitMenu (Widget Parent, Widget Top, Wid
*** 1045,1048 ****
--- 1216,1221 ----
    last = InitMenuButton (Parent, &ReportMenuButton, Top, last);
    last = InitMenuButton (Parent, &WindowMenuButton, Top, last);
+ #endif
+ 
    InitPopupMenu (Parent, &pMenu);
    InitPopupMenu (Parent, &p2Menu);
Index: misc.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/misc.c,v
retrieving revision 1.21
diff -p -2 -r1.21 misc.c
*** misc.c	20 Mar 2004 23:01:33 -0000	1.21
--- misc.c	30 Mar 2004 20:42:58 -0000
*************** static char *rcsid = "$Id: misc.c,v 1.21
*** 69,72 ****
--- 69,73 ----
  #include "search.h"
  #include "set.h"
+ #include "action.h"
  
  #ifdef HAVE_LIBDMALLOC
*************** IsDataEmpty (DataTypePtr Data)
*** 514,517 ****
--- 515,528 ----
  }
  
+ int
+ FlagIsDataEmpty(int parm)
+ {
+   int i = IsDataEmpty(PCB->Data);
+   return parm ? !i : i;
+ }
+ 
+ /* FLAG(DataEmpty,FlagIsDataEmpty,0) */
+ /* FLAG(DataNonEmpty,FlagIsDataEmpty,1) */
+ 
  /* ---------------------------------------------------------------------------
   * gets minimum and maximum coordinates
