Back to index

tetex-bin  3.0
Functions
xaw_menu.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void create_menu_buttons (Widget menu_bar, int *ret_panel_width)
void toggle_menu (int val, XtActionProc proc)
void SubMenuHandleEvent (XtAppContext app, XEvent *event)
void filehist_menu_add_entry (const char *filename)
int get_panel_width (void)
void toggle_tick (Boolean val, Widget w)
void set_button_panel_height (XtArgVal)
void filehist_menu_refresh (void)
void xaw_create_pagelist (void)
void toggle_scrollbars (void)
void toggle_buttons (void)
void scroll_y_panner (int y)
void scroll_x_panner (int x)

Function Documentation

void create_menu_buttons ( Widget  menu_bar,
int ret_panel_width 
)

Definition at line 1040 of file xaw_menu.c.

{
    Dimension max_button_width = 0, curr_width;
    Dimension y_pos;
    struct button_info **bipp;
    struct button_info *bp;
    const char *c_ptr, *e_ptr;
    int max_size;
    int button_number = 0;
    int menu_number = 0; /* number of menus created; passed through to create_pulldown_menu */
    
    /* disable the magnifier in the panel: */
    XtTranslations panel_translations = XtParseTranslationTable("#augment <ButtonPress>:");

    XtAppAddActions(XtWidgetToApplicationContext(form), menu_actions, XtNumber(menu_actions));
    /* add our own popdown-submenus() action to the default translations of this menu */
    menu_accels = XtParseAcceleratorTable("<BtnUp>:MenuPopdown()notify()unhighlight()popdown-submenus()");
    
    line_widget = XtVaCreateWidget("line", widgetClass, form,
                               XtNbackground, (XtArgVal)resource.fore_Pixel,
                               XtNwidth, (XtArgVal) 1,
                               XtNfromHoriz, (XtArgVal)globals.widgets.vport_widget,
                               XtNborderWidth, (XtArgVal)0,
                               XtNtop, (XtArgVal)XtChainTop,
                               XtNbottom, (XtArgVal)XtChainBottom,
                               XtNleft, (XtArgVal)XtChainRight,
                               XtNright, (XtArgVal)XtChainRight,
                               NULL);
    panel_widget = XtVaCreateWidget("panel", compositeWidgetClass, form,
                                XtNborderWidth, (XtArgVal)0,
                                XtNfromHoriz, (XtArgVal)line_widget,
                                XtNtranslations, (XtArgVal)panel_translations,
                                XtNtop, (XtArgVal)XtChainTop,
                                XtNbottom, (XtArgVal)XtChainBottom,
                                XtNleft, (XtArgVal)XtChainRight,
                                XtNright, (XtArgVal)XtChainRight,
                                NULL);
    menu_arrow_bitmap
       = XCreateBitmapFromData(XtDisplay(globals.widgets.top_level),
                            RootWindowOfScreen(XtScreen(globals.widgets.top_level)),
                            (char *)menu_arrow_bits, MENU_ARROW_W, MENU_ARROW_H);
    
    b_head = NULL;
    bipp = &b_head;

    *ret_panel_width = 0;
    y_pos = resource.btn_top_spacing;

#define FREE_LINE_ITEMS do { \
           for (curr = 0; curr < item_count; curr++) { \
               free(line_items[curr]); \
           } \
           free(line_items); \
       } while (0)
    
    for (c_ptr = resource.menu_translations;
        c_ptr != NULL && *c_ptr != '\0';
        c_ptr = e_ptr + 1) {
       e_ptr = strchr(c_ptr, '\n');
       if (e_ptr != NULL) {
           char **line_items = NULL;
           size_t len, curr, item_count = 0;

           if (e_ptr == c_ptr) { /* single '\n' marks additional space between buttons */
              y_pos += resource.btn_between_extra;
              continue;
           }
           len = e_ptr - c_ptr;

           if (++button_number > MAX_BUTTON_NUM) {
              XDVI_WARNING((stderr, "Too many buttons (max=%d), skipping all from:\n\"%.*s\"",
                           MAX_BUTTON_NUM, (int)len, c_ptr));
              break;
           }
           
           line_items = split_line(c_ptr, SEP_CHAR, 0, len, &item_count);
           if (item_count < 3 && !(item_count > 1 && strcmp(line_items[1], "SEP") == 0)) {
              XDVI_WARNING((stderr, "Too few separators \"%c\" in translations line:\n\"%.*s\" (skipping this line).\n",
                           SEP_CHAR, (int)len, c_ptr));
              FREE_LINE_ITEMS;
              continue;
           }
           curr_width = create_button(button_number,
                                   &menu_number,
                                   line_items,
                                   item_count,
                                   panel_widget,
                                   &bipp,
                                   &y_pos,
                                   c_ptr, len);
           if (curr_width == 0) { /* no button created */
              FREE_LINE_ITEMS;
              continue;
           }
           /* adjust max_button_width to this new entry */
           if (curr_width > max_button_width)
              max_button_width = curr_width;

           FREE_LINE_ITEMS;
       }
    }

#undef FREE_LINE_ITEMS
    
    /* null-terminate button info */
    *bipp = NULL;

    max_size = xaw_get_pagelist_size();
    if (max_size > max_button_width) {
       max_button_width = max_size;
    }

    *ret_panel_width = max_button_width + 2 * (resource.btn_side_spacing + resource.btn_border_width);
    TRACE_GUI((stderr, "panel_widget: w: %d", *ret_panel_width));
    XtVaSetValues(panel_widget, XtNwidth, (XtArgVal)*ret_panel_width, NULL);
    ++(*ret_panel_width);
    my_panel_width = *ret_panel_width; /* make it available */

    for (bp = b_head; bp != NULL; bp = bp->next) {
       if (bp->type == MENU_BUTTON || bp->type == COMMAND_BUTTON) {
           TRACE_GUI((stderr, "bp->widget: w: %d", max_button_width));
           XtVaSetValues(bp->widget, XtNwidth, (XtArgVal)max_button_width, NULL);
           XtManageChild(bp->widget);
       }
    }

    my_y_pos = y_pos - resource.btn_between_spacing + resource.btn_top_spacing + 2 * resource.btn_border_width;
    initialize_tick_marks();
#ifdef USE_PANNER
    {
       static Dimension w, h;
       static Arg arg_wh_clip[] = {
           {XtNwidth, (XtArgVal) &w},
           {XtNheight, (XtArgVal) &h},
       };
       XtGetValues(globals.widgets.clip_widget, arg_wh_clip, XtNumber(arg_wh_clip));

       fprintf(stderr, "w: %d, h: %d, globals.page.w: %d, globals.page.h: %d\n",
              w, h, globals.page.w, globals.page.h);
       if (w == 0)
           w = globals.page.w - 2;
       if (h == 0)
           h = globals.page.h - 2;
       panner = XtVaCreateManagedWidget("panner", pannerWidgetClass, panel_widget,
                                    XtNx, resource.btn_side_spacing,
                                    XtNy, my_y_pos,
                                    XtNheight, 60,
                                    XtNwidth, max_button_width,
                                    XtNshadowThickness, 0,
                                    XtNsliderWidth, w,
                                    XtNsliderHeight, h,
                                    XtNcanvasWidth, globals.page.w,
                                    XtNcanvasHeight, globals.page.h,
                                    XtNsliderX, 5,
                                    XtNsliderY, 7,
                                    XtNinternalSpace, 0,
                                    NULL);
    }
    my_y_pos += 60 + resource.btn_top_spacing + 2 * resource.btn_border_width;
    XtAddCallback(panner, XtNreportCallback, panner_cb, (XtPointer)NULL);

#endif /* USE_PANNER */

}

Here is the call graph for this function:

void filehist_menu_add_entry ( const char *  filename)

Definition at line 438 of file xaw_menu.c.

{
    static char *buf = NULL;
    static size_t buf_len = 0;
    size_t new_len = LENGTH_OF_INT + strlen(filename) + 1;
    
    Widget menu;
    /* Don't report an error here, since "filehist_pullright" is only created on-demand
       when user clicks on menu, but this may be called before from the event loop.
       (The menu will still contain this entry when it's created later.) */
    if (get_widget_by_name(&menu, globals.widgets.top_level, "filehist_pullright", False)) {
       int num_children;
       Widget w;

       if (new_len > buf_len) {
           buf = xrealloc(buf, new_len);
           buf_len = new_len;
       }
       
       XtVaGetValues(menu, XtNnumChildren, &num_children, NULL);
       sprintf(buf, "%d %s", num_children + 1, filename);
       
       w = XtVaCreateManagedWidget("_filehist", smeBSBObjectClass, menu,
                                XtNlabel, buf,
                                XtNleftMargin, 10,
                                NULL);
       XtAddCallback(w, XtNcallback, filehist_select_cb, NULL);
       update_menu_labels(menu);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 470 of file xaw_menu.c.

{
    Widget menu;

    /* Don't report an error here, since "filehist_pullright" is only created on-demand
       when user clicks on menu, but this may be called before from the event loop.
       (The menu will still contain this entry when it's created later.) */
    if (get_widget_by_name(&menu, globals.widgets.top_level, "filehist_pullright", False)) {
       update_menu_labels(menu);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 84 of file xaw_menu.c.

{
    int retval = 0;
    if (resource.expert_mode & XPRT_SHOW_BUTTONS)
       retval = my_panel_width;
    TRACE_GUI((stderr, "get_panel_width: %d", retval));
    return retval;
}

Here is the caller graph for this function:

Definition at line 985 of file xaw_menu.c.

{
    static int old_x = 0;
    if (panner != 0 && ABS(x - old_x) > 8) {
       XtVaSetValues(panner, XtNsliderX, x, NULL);
       old_x = x;
    }
}

Here is the caller graph for this function:

Definition at line 995 of file xaw_menu.c.

{
    static int old_y = 0;
    if (panner != 0 && ABS(y - old_y) > 8) {
       XtVaSetValues(panner, XtNsliderY, y, NULL);
       old_y = y;
    }
}

Here is the caller graph for this function:

void set_button_panel_height ( XtArgVal  )

Definition at line 1208 of file xaw_menu.c.

{
    TRACE_GUI((stderr, "line_widget: h %d", (int)h));
    XtVaSetValues(line_widget, XtNheight, h, NULL);
    XtManageChild(line_widget);

    XtVaSetValues(panel_widget, XtNheight, h, NULL);
    XtManageChild(panel_widget);
}

Here is the caller graph for this function:

void SubMenuHandleEvent ( XtAppContext  app,
XEvent *  event 
)

Definition at line 587 of file xaw_menu.c.

{
    static int flag = 0;
    static struct pullright_position_info info = { -1, 0, 0, 0, NULL };
    
    UNUSED(app);

    if (m_submenu == NULL)
       return;
    
    if (event->type == EnterNotify
       || event->type == MotionNotify
       || event->type == LeaveNotify
       || event->type == ButtonPress) {

/*     fprintf(stderr, "SubMenuHandleEvent: 0x%lx, 0x%lx\n", event->xany.window, XtWindow(m_submenu)); */
       
       /* Could also loop through a list of windows here ...
          We need to check for the parent of the menu item, since smeBSBObject is not
          a real window, and then manually check whether the pointer is inside the menu
          item.
        */
       if (XtParent(m_submenu) != NULL &&
           event->xany.window == XtWindow(XtParent(m_submenu))) {
           /* don't need to check for x coordinates since we already
              know that pointer is inside the parent */
           if (info.y == -1) { /* initialize info */
              XtVaGetValues(m_submenu,
                           XtNy, &(info.y),
                           XtNwidth, &(info.w),
                           XtNheight, &(info.h),
                           NULL);
              XtVaGetValues(XtParent(m_submenu),
                           XtNborderWidth, &(info.border_width),
                           NULL);

              info.menu = m_submenu;
           }
           if (info.y < event->xbutton.y && info.y + info.h > event->xbutton.y) {
              if (flag == 0) {
                  /* Create a timeout of 200ms to pop up the menu, so that it doesn't
                     pop up always when the cursor is only moved over the pulldown menu.
                     I think this is about the same delay as the one used by Motif.
                   */
                  flag = 1;
                  TRACE_GUI((stderr, "ENTER: %d, %d, %d; %d, %d",
                            info.y, info.w, info.h, event->xbutton.x, event->xbutton.y));
                  m_timeout = XtAppAddTimeOut(app, 200, popup_pullright, &info);
                  return;
              }
           }
           else if (flag == 1) {
              flag = 0;
              TRACE_GUI((stderr, "LEAVE!"));
              if (m_timeout != 0)
                  XtRemoveTimeOut(m_timeout);
              m_timeout = 0;
              if (m_active_submenu != NULL)
                  XtPopdown(m_active_submenu);
              m_active_submenu = NULL;
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1365 of file xaw_menu.c.

{
    static Boolean buttons_active = False;
    static Boolean initialized = False;
    Dimension window_w, window_h;


    Boolean make_buttons_visible = False;
    Boolean make_buttons_invisible = False;

    int panel_width;
    
    if (!initialized) {
       buttons_active = (resource.expert_mode & XPRT_SHOW_BUTTONS) != 0;
       initialized = True;
    }

    if ((resource.expert_mode & XPRT_SHOW_BUTTONS) == 0) {
       if (buttons_active)
           make_buttons_invisible = True;
    }
    else {
       if (!buttons_active)
           make_buttons_visible = True;
    }
           
    if (make_buttons_visible) {
       if (destroy_count != 0) {
           return;
       }

       create_menu_buttons(globals.widgets.form_widget, &panel_width);
       XtVaGetValues(globals.widgets.form_widget,
                    XtNwidth, &window_w,
                    XtNheight, &window_h,
                    NULL);
       XtVaSetValues(globals.widgets.vport_widget, XtNresizable, (XtArgVal)True, NULL);
       window_w -= panel_width;
       TRACE_GUI((stderr, "globals.widgets.vport_widget: w: %d, h: %d", window_w, window_h));
       XtVaSetValues(globals.widgets.vport_widget, XtNwidth, window_w, XtNheight, window_h, NULL);
       set_button_panel_height((XtArgVal) window_h);
       buttons_active = True;
    }
    else if (make_buttons_invisible) {
       if (destroy_count != 0) {
           return;
       }
       /* this counts the callback calls; 1 for the panel, 1 for the line */
       destroy_count = 2;

       XtAddCallback(panel_widget, XtNdestroyCallback,
                    handle_destroy_buttons, (XtPointer)0);
       XtAddCallback(panel_widget, XtNdestroyCallback,
                    handle_destroy_pagelist, (XtPointer)0);
       XtAddCallback(line_widget, XtNdestroyCallback,
                    handle_destroy_buttons, (XtPointer)0);
       XtDestroyWidget(panel_widget);
       XtDestroyWidget(line_widget);
       buttons_active = False;
/*     window_w += get_panel_width(); */

       while (b_head != NULL) {
           struct button_info *bp = b_head;
           struct xdvi_action *action;

           b_head = bp->next;
           free(bp->label);
           /* free bp->action */
           for (action = bp->action; action != NULL;) {
              struct xdvi_action *act2 = action;
              action = act2->next;
              if (act2->num_params > 0) {
                  free(act2->param);
              }
              free(act2);
           }
           free(bp);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void toggle_menu ( int  val,
XtActionProc  proc 
)

Definition at line 242 of file xaw_menu.c.

{
    struct button_info *bp;

    for (bp = b_head; bp != NULL; bp = bp->next) {
       if (bp->action != NULL && bp->action->proc == proc && bp->action->param != NULL) {
           TRACE_GUI((stderr, "found proc; param: |%s|", bp->action->param));
           if (strcmp(bp->action->param, "toggle") == 0) {
              if (val != 0)
                  toggle_tick(True, bp->widget);
              else
                  toggle_tick(False, bp->widget);
           }
           else if (strcmp(bp->action->param, "a") == 0) {
              if (val == shrink_to_fit())
                  toggle_tick(True, bp->widget);
              else
                  toggle_tick(False, bp->widget);
           }
           else {
              int testval = strtoul(bp->action->param, (char **)NULL, 10);
              if (testval == val) {
                  TRACE_GUI((stderr, "enabling param |%s|", bp->action->param));
                  toggle_tick(True, bp->widget);
              }
              else
                  toggle_tick(False, bp->widget);
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1278 of file xaw_menu.c.

{
    Widget v_bar = XtNameToWidget(globals.widgets.vport_widget, "vertical");
    Widget h_bar = XtNameToWidget(globals.widgets.vport_widget, "horizontal");
    static Dimension bar_thick;
    static Boolean v_bar_mapped = False, h_bar_mapped = False;
    static Boolean initialized = False;

    Boolean make_v_bar_visible = False;
    Boolean make_v_bar_invisible = False;
    
    Boolean make_h_bar_visible = False;
    Boolean make_h_bar_invisible = False;

    if (v_bar != 0) {
       int test_v = 0;
       XtVaGetValues(v_bar, XtNwidth, &test_v, NULL);
       if (test_v > 1)
           v_bar_mapped = True;
    }
    if (h_bar != 0) {
       int test_h = 0;
       XtVaGetValues(h_bar, XtNheight, &test_h, NULL);
       if (test_h > 1)
           h_bar_mapped = True;
    }
    
    if (!initialized) {
       v_bar_mapped = h_bar_mapped = (resource.expert_mode & XPRT_SHOW_SCROLLBARS) != 0;
       initialized = True;
       if (v_bar != 0)
           XtVaGetValues(v_bar, XtNwidth, &bar_thick, NULL);
       else if (h_bar != 0)
           XtVaGetValues(h_bar, XtNheight, &bar_thick, NULL);
       else
           bar_thick = 15; /* FIXME */
    }

    if ((resource.expert_mode & XPRT_SHOW_SCROLLBARS) == 0) {
       if (v_bar_mapped)
           make_v_bar_invisible = True;
       if (h_bar_mapped)
           make_h_bar_invisible = True;
    }
    else {
       if (!v_bar_mapped)
           make_v_bar_visible = True;
       if (!h_bar_mapped)
           make_h_bar_visible = True;
    }

    if (make_h_bar_visible || make_v_bar_visible) {
       if (make_h_bar_visible && h_bar != 0) {
           TRACE_GUI((stderr, "h_bar: h %d", bar_thick));
           XtVaSetValues(h_bar, XtNheight, bar_thick, XtNx, bar_thick, XtNy, 0, XtNborderWidth, 1, NULL);
           XtManageChild(h_bar);
           h_bar_mapped = True;
       }
       if (make_v_bar_visible && v_bar != 0) {
           TRACE_GUI((stderr, "v_bar: w %d", bar_thick));
           XtVaSetValues(v_bar, XtNwidth, bar_thick, XtNx, 0, XtNy, bar_thick, XtNborderWidth, 1, NULL);
           XtManageChild(v_bar);
           v_bar_mapped = True;
       }
       if (h_bar != 0 || v_bar != 0) { /* need to reconfigure screen */
           reconfig_window();
       }
    }
    else if (make_h_bar_invisible || make_v_bar_invisible) {
       if (make_h_bar_invisible && h_bar != 0) {
           XtUnmanageChild(h_bar);
           XtVaSetValues(h_bar, XtNheight, 1, XtNx, 0, XtNy, 0, XtNborderWidth, 0, NULL);
           h_bar_mapped = False;
       }
       if (make_v_bar_invisible && v_bar != 0) {
           XtUnmanageChild(v_bar);
           XtVaSetValues(v_bar, XtNwidth, 1, XtNy, 0, XtNy, 0, XtNborderWidth, 0, NULL);
           v_bar_mapped = False;
       }
       if (h_bar != 0 || v_bar != 0) { /* need to reconfigure screen */
           reconfig_window();
       }
    }
    
}

Here is the call graph for this function:

Here is the caller graph for this function:

void toggle_tick ( Boolean  val,
Widget  w 
)

Definition at line 231 of file xaw_menu.c.

{
    static Arg args = { XtNleftBitmap, (XtArgVal) 0 };
    if (val)
       args.value = (XtArgVal) menu_check_bitmap;
    else
       args.value = None;
    XtSetValues(w, &args, 1);
}

Here is the caller graph for this function:

Definition at line 320 of file xaw_menu.c.

{
    Dimension height, width;
    int button_width = get_panel_width() - 2 * (resource.btn_side_spacing + resource.btn_border_width);
    
    XtVaGetValues(globals.widgets.clip_widget, XtNheight, &height, NULL);
    width = MAX(button_width, xaw_get_pagelist_size());
    height -= resource.btn_top_spacing + resource.btn_border_width + my_y_pos;
    xaw_create_pagelist_widgets(height, width, my_y_pos, panel_widget);
}

Here is the call graph for this function:

Here is the caller graph for this function: