Back to index

tetex-bin  3.0
Classes | Enumerations | Functions
menu.h File Reference
#include "xdvi-config.h"
#include "events.h"
#include "xdvi.h"
#include "xm_menu.h"
#include "xaw_menu.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  button_elems
struct  button_info

Enumerations

enum  buttonTypeT {
  BT_INVALID = -1, BT_NONE = 0, BT_PUSH, BT_RADIO,
  BT_CHECK, BT_SEP, INVALID, NONE,
  MENU_SEPARATOR, MENU_BUTTON, MENU_ENTRY, COMMAND_BUTTON
}

Functions

void create_menu_buttons (Widget parent, int *ret_panel_width)
void set_menu (void *val, XtActionProc proc, Boolean(*cmp)())

Class Documentation

struct button_elems

Definition at line 45 of file menu.h.

Collaboration diagram for button_elems:
Class Members
char * accelerator
struct xdvi_action * action
char mnemonic
struct button_info * submenu
char * title
buttonTypeT type
Widget widget
struct button_info

Definition at line 55 of file menu.h.

Collaboration diagram for button_info:
Class Members
struct xdvi_action * action
struct button_elems * elems
char * label
struct button_info * next
size_t size
buttonTypeT type
Widget widget

Enumeration Type Documentation

Enumerator:
BT_INVALID 
BT_NONE 
BT_PUSH 
BT_RADIO 
BT_CHECK 
BT_SEP 
INVALID 
NONE 
MENU_SEPARATOR 
MENU_BUTTON 
MENU_ENTRY 
COMMAND_BUTTON 

Definition at line 34 of file menu.h.

             {
    BT_INVALID = -1, /* error code */
    BT_NONE = 0,
    BT_PUSH,  /* pushbutton */
    BT_RADIO, /* radio button (1 of n) */
    BT_CHECK, /* check button (m of n) */
    BT_SEP    /* separator */
} buttonTypeT;

Function Documentation

void create_menu_buttons ( Widget  parent,
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 caller graph for this function:

void set_menu ( void val,
XtActionProc  proc,
Boolean(*)()  cmp 
)

Here is the caller graph for this function: