pcb 4.1.1
An interactive printed circuit board layout editor.

menu.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "xincludes.h"
#include "global.h"
#include "data.h"
#include "error.h"
#include "misc.h"
#include "pcb-printf.h"
#include "hid.h"
#include "../hidint.h"
#include "hid/common/hid_resource.h"
#include "resource.h"
#include "lesstif.h"
#include "mymem.h"
#include "layerflags.h"
#include "pcb-menu.h"
Include dependency graph for menu.c:

Go to the source code of this file.

Data Structures

struct  LayerButtons
struct  WidgetFlagType
struct  ToggleItem
struct  acc_table_t

Defines

#define R_OK   4
#define stdarg(t, v)   XtSetArg(args[n], t, v), n++
#define LB_SILK   (MAX_LAYER + BOTTOM_SILK_LAYER)
#define LB_RATS   (MAX_LAYER + 1)
#define LB_NUMPICK   (LB_RATS+1)
#define LB_PINS   (MAX_ALL_LAYER)
#define LB_VIAS   (MAX_ALL_LAYER + 1)
#define LB_BACK   (MAX_ALL_LAYER + 2)
#define LB_MASK   (MAX_ALL_LAYER + 3)
#define LB_NUM   (MAX_ALL_LAYER + 4)
#define dump_multi(x, a, b, c)
#define KM(m)   ((m) & ~M_Multi)

Typedefs

typedef struct ToggleItem ToggleItem
typedef struct acc_table_t acc_table_t

Functions

static void note_accelerator (char *acc, Resource *node)
static void note_widget_flag (Widget w, char *type, char *name)
static int GetXY (int argc, char **argv, Coord x, Coord y)
 Get a coordinate.
static int Debug (int argc, char **argv, Coord x, Coord y)
static int Return (int argc, char **argv, Coord x, Coord y)
static int DumpKeys (int argc, char **argv, Coord x, Coord y)
static int LayersChanged (int argc, char **argv, Coord x, Coord y)
static void show_one_layer_button (int layer, int set)
static void layer_button_callback (Widget w, int layer, XmPushButtonCallbackStruct *pbcs)
static void layerpick_button_callback (Widget w, int layer, XmPushButtonCallbackStruct *pbcs)
static int SelectLayer (int argc, char **argv, Coord x, Coord y)
static int ToggleView (int argc, char **argv, Coord x, Coord y)
static void insert_layerview_buttons (Widget menu)
static void insert_layerpick_buttons (Widget menu)
void lesstif_update_widget_flags ()
static void radio_callback (Widget toggle, ToggleItem *me, XmToggleButtonCallbackStruct *cbs)
int lesstif_button_event (Widget w, XEvent *e)
void lesstif_get_xy (const char *message)
void lesstif_get_coords (const char *msg, Coord *px, Coord *py)
static void callback (Widget w, Resource *node, XmPushButtonCallbackStruct *pbcs)
static int acc_sort (const void *va, const void *vb)
static int DumpKeys2 ()
static acc_table_tfind_or_create_acc (char mods, char key, KeySym sym, acc_table_t **table, int *n_ents)
static int acc_sort_rev (const void *va, const void *vb)
 
int lesstif_key_event (XKeyEvent *e)
static void add_resource_to_menu (Widget menu, Resource *node, XtCallbackProc callback)
Widget lesstif_menu (Widget parent, char *name, Arg *margs, int mn)
void lesstif_uninit_menu (void)

Variables

static Colormap cmap
static Arg args [30]
static int n
static const char getxy_syntax [] = "GetXY()"
static const char getxy_help [] = "Get a coordinate."
static const char debug_syntax [] = "Debug(...)"
static const char debug_help [] = "Debug action."
static const char debugxy_syntax [] = "DebugXY(...)"
static const char debugxy_help [] = "Debug action, with coordinates"
static const char return_syntax [] = "Return(0|1)"
static const char return_help [] = "Simulate a passing or failing action."
static const char dumpkeys_syntax [] = "DumpKeys()"
static const char dumpkeys_help [] = "Dump Lesstif key bindings."
static int do_dump_keys = 0
static LayerButtonslayer_button_list = 0
static int num_layer_buttons = 0
static int fg_colors [LB_NUM]
static int bg_color
Widget lesstif_m_layer
static const char selectlayer_syntax [] = "SelectLayer(1..MAXLAYER|Silk|Rats)"
static const char selectlayer_help [] = "Select which layer is the current layer."
static const char toggleview_syntax [] = "ToggleView(Silk|Rats|Pins|Vias|Mask|BackSide)"
static const char toggleview_help [] = "Toggle the visibility of the specified layer or layer group."
static WidgetFlagTypewflags = 0
static int n_wflags = 0
static int max_wflags = 0
HID_Action lesstif_menu_action_list []
static ToggleItemtoggle_items = 0
static int need_xy = 0
static int have_xy = 0
static int action_x
static int action_y
static acc_table_tacc_table
static int acc_num = 0
static acc_table_tcur_table = 0
static int cur_ntable = 0
char * lesstif_pcbmenu_path

Define Documentation

#define dump_multi (   x,
  a,
  b,
  c 
)

Definition at line 1107 of file menu.c.

Referenced by lesstif_key_event().

#define KM (   m)    ((m) & ~M_Multi)

Referenced by lesstif_key_event().

#define LB_BACK   (MAX_ALL_LAYER + 2)

Definition at line 191 of file menu.c.

Referenced by insert_layerview_buttons(), layer_button_callback(), LayersChanged(), and ToggleView().

#define LB_MASK   (MAX_ALL_LAYER + 3)

Definition at line 192 of file menu.c.

Referenced by insert_layerview_buttons(), layer_button_callback(), LayersChanged(), and ToggleView().

#define LB_NUM   (MAX_ALL_LAYER + 4)

Definition at line 193 of file menu.c.

Referenced by insert_layerview_buttons(), and LayersChanged().

#define LB_NUMPICK   (LB_RATS+1)

Definition at line 187 of file menu.c.

Referenced by insert_layerpick_buttons(), layerpick_button_callback(), and LayersChanged().

#define LB_PINS   (MAX_ALL_LAYER)

Definition at line 189 of file menu.c.

Referenced by insert_layerview_buttons(), layer_button_callback(), LayersChanged(), and ToggleView().

#define LB_SILK   (MAX_LAYER + BOTTOM_SILK_LAYER)
#define LB_VIAS   (MAX_ALL_LAYER + 1)

Definition at line 190 of file menu.c.

Referenced by insert_layerview_buttons(), layer_button_callback(), LayersChanged(), and ToggleView().

#define R_OK   4

Definition at line 35 of file menu.c.

Referenced by get_menu_filename(), and lesstif_menu().

#define stdarg (   t,
 
)    XtSetArg(args[n], t, v), n++

Typedef Documentation

typedef struct acc_table_t acc_table_t
typedef struct ToggleItem ToggleItem

Function Documentation

static int acc_sort ( const void *  va,
const void *  vb 
) [static]

Definition at line 912 of file menu.c.

References acc_table_t::a, acc_table_t::key_char, M_Multi, acc_table_t::mods, and acc_table_t::u.

Referenced by DumpKeys2().

static int acc_sort_rev ( const void *  va,
const void *  vb 
) [static]

We sort these such that the ones with explicit modifiers come before the ones with implicit modifiers. That way, a Shift<Key>Code gets chosen before a <Key>Code.

Definition at line 1121 of file menu.c.

References acc_table_t::a, acc_table_t::key_char, M_Multi, acc_table_t::mods, and acc_table_t::u.

Referenced by lesstif_key_event().

static int Debug ( int  argc,
char **  argv,
Coord  x,
Coord  y 
) [static]

Definition at line 116 of file menu.c.

References PCBType::Data, DataType::Layer, layertype_to_string(), max_copper_layer, LayerType::Name, PCB, pcb_printf(), SILK_LAYER, and LayerType::Type.

Here is the call graph for this function:

static int DumpKeys ( int  argc,
char **  argv,
Coord  x,
Coord  y 
) [static]

Definition at line 177 of file menu.c.

References do_dump_keys.

static int DumpKeys2 ( ) [static]

Definition at line 925 of file menu.c.

References acc_table_t::a, acc_num, acc_sort(), M_Alt, M_Ctrl, M_Shift, mod(), mods, resource_type, acc_table_t::u, and u().

Referenced by lesstif_menu().

Here is the call graph for this function:

static acc_table_t* find_or_create_acc ( char  mods,
char  key,
KeySym  sym,
acc_table_t **  table,
int *  n_ents 
) [static]

Definition at line 960 of file menu.c.

References acc_table_t::a, acc_table_t::key_char, M_Multi, malloc(), max, mods, acc_table_t::mods, realloc(), and acc_table_t::u.

Referenced by note_accelerator().

Here is the call graph for this function:

static int GetXY ( int  argc,
char **  argv,
Coord  x,
Coord  y 
) [static]

Get a coordinate.

Each action is registered with a flag for the core ("need_coord_msg") that says whether it requires an X,Y location from the user, and if so, provides a prompt for that X,Y location.

The GUIs display that prompt while waiting for the user to click.

GetXY() is a "filler" action which exists *only* to request an X,Y click from the user, for actions that don't (or optionally) need coords, or don't have a message appropriate for the case being issued (i.e. if there are multiple actions to be executed, the GetXY() might be appropriate for the *group* results, not the first action that happens to need a coordinate).

The catch is that the core asks for the X,Y click *before* the action is called, so there's no way for any argument to GetXY() to have any effect.

The string "printed" is the empty one in the struct where GetXY() is registered.

Definition at line 83 of file menu.c.

static void insert_layerpick_buttons ( Widget  menu) [static]
static void insert_layerview_buttons ( Widget  menu) [static]
static void layer_button_callback ( Widget  w,
int  layer,
XmPushButtonCallbackStruct *  pbcs 
) [static]
static void layerpick_button_callback ( Widget  w,
int  layer,
XmPushButtonCallbackStruct *  pbcs 
) [static]
int lesstif_button_event ( Widget  w,
XEvent *  e 
)

Definition at line 806 of file menu.c.

References action_x, have_xy, and work_area.

Referenced by work_area_input().

void lesstif_get_coords ( const char *  msg,
Coord px,
Coord py 
)

Definition at line 842 of file menu.c.

References action_x, have_xy, lesstif_coords_to_pcb(), and lesstif_get_xy().

Referenced by hid_lesstif_init().

Here is the call graph for this function:

void lesstif_get_xy ( const char *  message)

Definition at line 819 of file menu.c.

References app_context, args, display, have_xy, m_click, n, stdarg, and XmStringCreatePCB().

Referenced by lesstif_get_coords().

Here is the call graph for this function:

int lesstif_key_event ( XKeyEvent *  e)
Widget lesstif_menu ( Widget  parent,
char *  name,
Arg *  margs,
int  mn 
)
void lesstif_uninit_menu ( void  )

Todo:
XtDestroyWidget (...);

Definition at line 1523 of file menu.c.

Referenced by lesstif_uninit().

void lesstif_update_widget_flags ( void  )

Definition at line 722 of file menu.c.

References args, hid_get_flag(), n_wflags, and WidgetFlagType::oldval.

Referenced by idle_proc().

Here is the call graph for this function:

static void note_accelerator ( char *  acc,
Resource node 
) [static]

Definition at line 996 of file menu.c.

References acc_table_t::a, acc_num, acc_table, acc_table_t::c, find_or_create_acc(), M_Alt, M_Ctrl, M_Multi, M_Shift, mods, node, and acc_table_t::u.

Referenced by add_resource_to_menu(), insert_layerpick_buttons(), and insert_layerview_buttons().

Here is the call graph for this function:

static void note_widget_flag ( Widget  w,
char *  type,
char *  name 
) [static]

Definition at line 707 of file menu.c.

References WidgetFlagType::flagname, max_wflags, n_wflags, WidgetFlagType::oldval, realloc(), WidgetFlagType::w, and WidgetFlagType::xres.

Referenced by add_resource_to_menu(), and insert_layerview_buttons().

Here is the call graph for this function:

static void radio_callback ( Widget  toggle,
ToggleItem me,
XmToggleButtonCallbackStruct *  cbs 
) [static]
static int Return ( int  argc,
char **  argv,
Coord  x,
Coord  y 
) [static]

Definition at line 147 of file menu.c.

static int SelectLayer ( int  argc,
char **  argv,
Coord  x,
Coord  y 
) [static]

Definition at line 469 of file menu.c.

References PCBType::Data, DataType::Layer, layerpick_button_callback(), LB_RATS, LB_SILK, max_copper_layer, LayerType::Name, and PCB.

Here is the call graph for this function:

static void show_one_layer_button ( int  layer,
int  set 
) [static]

Definition at line 343 of file menu.c.

References args, bg_color, fg_colors, LayerButtons::is_pick, n, num_layer_buttons, stdarg, and LayerButtons::w.

Referenced by layer_button_callback().

static int ToggleView ( int  argc,
char **  argv,
Coord  x,
Coord  y 
) [static]

Definition at line 512 of file menu.c.

References PCBType::Data, DataType::Layer, layer_button_callback(), LB_BACK, LB_MASK, LB_PINS, LB_RATS, LB_SILK, LB_VIAS, max_copper_layer, LayerType::Name, PCB, and SILK_LAYER.

Here is the call graph for this function:


Variable Documentation

int acc_num = 0 [static]

Definition at line 909 of file menu.c.

Referenced by DumpKeys2(), lesstif_key_event(), and note_accelerator().

Definition at line 908 of file menu.c.

Referenced by lesstif_key_event(), and note_accelerator().

int action_x

Definition at line 782 of file menu.c.

Referenced by callback(), lesstif_button_event(), lesstif_get_coords(), and lesstif_key_event().

int action_y

Definition at line 782 of file menu.c.

int bg_color [static]

Definition at line 204 of file menu.c.

Referenced by layerpick_button_callback(), LayersChanged(), and show_one_layer_button().

Colormap cmap [static]

Definition at line 38 of file menu.c.

Referenced by lesstif_menu().

int cur_ntable = 0 [static]

Definition at line 1111 of file menu.c.

Referenced by lesstif_key_event().

acc_table_t* cur_table = 0 [static]

Definition at line 1110 of file menu.c.

Referenced by lesstif_key_event().

const char debug_help[] = "Debug action." [static]

Definition at line 91 of file menu.c.

const char debug_syntax[] = "Debug(...)" [static]

Definition at line 88 of file menu.c.

const char debugxy_help[] = "Debug action, with coordinates" [static]

Definition at line 104 of file menu.c.

const char debugxy_syntax[] = "DebugXY(...)" [static]

Definition at line 101 of file menu.c.

int do_dump_keys = 0 [static]

Definition at line 175 of file menu.c.

Referenced by DumpKeys(), and lesstif_menu().

const char dumpkeys_help[] = "Dump Lesstif key bindings." [static]

Definition at line 160 of file menu.c.

const char dumpkeys_syntax[] = "DumpKeys()" [static]

Definition at line 157 of file menu.c.

int fg_colors[LB_NUM] [static]

Definition at line 203 of file menu.c.

Referenced by layerpick_button_callback(), LayersChanged(), and show_one_layer_button().

const char getxy_help[] = "Get a coordinate." [static]

Definition at line 50 of file menu.c.

const char getxy_syntax[] = "GetXY()" [static]

Definition at line 47 of file menu.c.

Definition at line 201 of file menu.c.

Initial value:
 {
  {"DumpKeys", 0, DumpKeys,
   dumpkeys_help, dumpkeys_syntax},
  {"Debug", 0, Debug,
   debug_help, debug_syntax},
  {"DebugXY", "Click X,Y for Debug", Debug,
   debugxy_help, debugxy_syntax},
  {"GetXY", "", GetXY,
   getxy_help, getxy_syntax},
  {"Return", 0, Return,
   return_help, return_syntax},
  {"LayersChanged", 0, LayersChanged,
   layerschanged_help, layerschanged_syntax},
  {"ToggleView", 0, ToggleView,
   toggleview_help, toggleview_syntax},
  {"SelectLayer", 0, SelectLayer,
   selectlayer_help, selectlayer_syntax}
}

Definition at line 738 of file menu.c.

Definition at line 231 of file hid/lesstif/main.c.

Referenced by lesstif_menu().

int max_wflags = 0 [static]

Definition at line 704 of file menu.c.

Referenced by note_widget_flag().

int n_wflags = 0 [static]

Definition at line 703 of file menu.c.

Referenced by lesstif_update_widget_flags(), and note_widget_flag().

int need_xy = 0 [static]

Definition at line 782 of file menu.c.

const char return_help[] = "Simulate a passing or failing action." [static]

Definition at line 136 of file menu.c.

const char return_syntax[] = "Return(0|1)" [static]

Definition at line 133 of file menu.c.

const char selectlayer_help[] = "Select which layer is the current layer." [static]

Definition at line 458 of file menu.c.

const char selectlayer_syntax[] = "SelectLayer(1..MAXLAYER|Silk|Rats)" [static]

Definition at line 455 of file menu.c.

ToggleItem* toggle_items = 0 [static]

Definition at line 780 of file menu.c.

Referenced by add_resource_to_menu().

const char toggleview_help[] = "Toggle the visibility of the specified layer or layer group." [static]

Definition at line 495 of file menu.c.

const char toggleview_syntax[] = "ToggleView(Silk|Rats|Pins|Vias|Mask|BackSide)" [static]

Definition at line 490 of file menu.c.

WidgetFlagType* wflags = 0 [static]

Definition at line 702 of file menu.c.