Back to index

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

Go to the source code of this file.

Functions

void refresh_pagelist (int newsize, int newpage)
void maybe_scroll_pagelist (int newpage, Boolean force_recenter)
void create_pagelist (void)
void list_toggle_current (int arg)
void list_toggle_marks (int arg)
int xaw_get_pagelist_size (void)
void xaw_create_pagelist_widgets (Dimension height, Dimension width, Position y, Widget parent)
void handle_destroy_pagelist (Widget w, XtPointer client_data, XtPointer call_data)
void handle_pagelist_resize (void)
long pageinfo_get_offset (int page)
int pageinfo_get_number (int page)
int pageinfo_get_index_of_number (int number)
unsigned int pageinfo_get_page_width (int page)
unsigned int pageinfo_get_page_height (int page)
unsigned int pageinfo_get_window_width (int page)
unsigned int pageinfo_get_window_height (int page)
void pageinfo_set_page_width (int page, unsigned int width)
void pageinfo_set_page_height (int page, unsigned int height)
void pageinfo_set_window_width (int page, unsigned int width)
void pageinfo_set_window_height (int page, unsigned int height)
void pageinfo_set_offset (int index, long offset)
void pageinfo_set_number (int index, int number)
void pageinfo_allocate (int total_pages)
void pageinfo_deallocate (void)
Boolean pageinfo_is_marked (int i)
Boolean pageinfo_have_marked_pages (void)

Function Documentation

Definition at line 1232 of file pagesel.c.

{
    Pixel background, foreground;
#ifdef MOTIF
    
/*     items = xrealloc(items, sizeof *items * (total_pages + 2)); */
    init_pagelabels(0, total_pages);
    xm_set_page_labels();
    if (!PagelistInitialized) {
       XtAppContext app;

       XtVaGetValues(LIST_WIDGET, XmNforeground, &foreground, XmNbackground, &background, NULL);
       m_page_gc.back = set_or_make_gc(NULL, GXcopy, background, foreground);
       m_page_gc.fore = set_or_make_gc(NULL, GXcopy, foreground, background);
       XtManageChild(LIST_WIDGET);

       XtAddCallback(LIST_WIDGET, XmNbrowseSelectionCallback, select_page_callback, NULL);
#if !defined(LESSTIF_VERSION)
       /*
         Don't use the highlighting hack with LessTif, since its XmListPosToBounds()
         is too broken to be usable (as of 0.93.36):
         - it returns generally too low values, apparently it doesn't take
           XmNlistSpacing into account;
         - it doesn't take scrollbar position into account.
       */
       if (resource.pagelist_highlight_current)
           XtAddEventHandler(LIST_WIDGET,
                           ButtonPressMask | ButtonReleaseMask | PointerMotionMask | LeaveWindowMask,
                           False, highlight_page_callback, (XtPointer)NULL);
#endif /* !defined(LESSTIF_VERSION) */
       XtAddEventHandler(LIST_WIDGET, ButtonPressMask | ButtonReleaseMask,
                       False, wheel_scroll_list_callback, (XtPointer)NULL);
       
       app = XtWidgetToApplicationContext(globals.widgets.top_level);
       XtAppAddActions(app, CustomListActions, XtNumber(CustomListActions));
       XtOverrideTranslations(LIST_WIDGET, XtParseTranslationTable(motif_custom_translations));
       PagelistInitialized = True;
    }
#else /* MOTIF */
    if ((resource.expert_mode & XPRT_SHOW_BUTTONS) == 0) {
       PagelistInitialized = False; /* might need to re-create widgets in this case */
       return;
    }

    if (globals.debug & DBG_GUI)
       fprintf(stderr, "allocating list with %d pages\n", total_pages);

    init_pagelabels(0, total_pages);
    if (!PagelistInitialized) {
       xaw_create_pagelist();
       XtVaGetValues(LIST_WIDGET, XtNforeground, &foreground, XtNbackground, &background, NULL);
       m_page_gc.back = set_or_make_gc(NULL, GXcopy, background, foreground);
       m_page_gc.fore = set_or_make_gc(NULL, GXcopy, foreground, background);
       PagelistInitialized = True;
    }
#endif /* MOTIF */
    /* scroll to the current page if needed */
    maybe_scroll_pagelist(current_page, False);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void handle_destroy_pagelist ( Widget  w,
XtPointer  client_data,
XtPointer  call_data 
)

Definition at line 1216 of file pagesel.c.

{
    UNUSED(w);
    UNUSED(client_data);
    UNUSED(call_data);
    
    if (viewport != NULL) {
       XtDestroyWidget(viewport);
       viewport = NULL;
       LIST_WIDGET = NULL;
    }
    PagelistInitialized = False;
}

Here is the caller graph for this function:

Definition at line 1193 of file pagesel.c.

{
    /* TODO: the following will mess up the geometry of the list
       (doesn't increase height, and incrementally decreases width):
    if (list_widget) {
       Dimension height;
       --- without the (un)manage, I get an X Error:
       XtMakeGeometryRequest - parent has no geometry manager
       ---
       XtUnmanageChild(viewport);
       XtUnmanageChild(LIST_WIDGET);
       XtVaGetValues(globals.widgets.clip_widget, XtNheight, &height, NULL);
       height -= resource.btn_top_spacing + resource.btn_border_width + global_y_pos;
       XtVaSetValues(viewport, XtNheight, height, NULL);
       XtManageChild(LIST_WIDGET);
        XtManageChild(viewport);
    }
    ... so we use brute force instead: */
    handle_destroy_pagelist(LIST_WIDGET, NULL, NULL);
    create_pagelist();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1535 of file pagesel.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1151 of file pagesel.c.

{
    
    int i;

    if (arg < 0) { /* mark all */
       for (i = 0; i < total_pages; i++) {
           ASSERT(i < (int)page_info.index_size, "");
/*         ensure_labelinfo_size(i); */
           if (!page_info.index[i].marked) {
              toggle_label(LIST_WIDGET, i, False);
           }
       }
    }
    else if (arg == 0) { /* unmark all */
       for (i = 0; i < total_pages; i++) {
           ASSERT(i < (int)page_info.index_size, "");
/*         ensure_labelinfo_size(i); */
           if (page_info.index[i].marked) {
              toggle_label(LIST_WIDGET, i, False);
           }
       }
    }
    else { /* toggle odd/even */
       if (arg == 2) /* toggle even */
           arg = 0;
       for (i = 0; i < total_pages; i++) {
           if ((i + 1) % 2 == arg) {
              toggle_label(LIST_WIDGET, i, False);
           }
       }
    }
    /* TODO: update widget once for Motif as well! */
#ifndef MOTIF
    xaw_update_list();
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void maybe_scroll_pagelist ( int  newpage,
Boolean  force_recenter 
)

Definition at line 1343 of file pagesel.c.

{
#ifdef MOTIF
    int top_visible, bot_visible;
    UNUSED(force_recenter);
#endif

    if (
#ifndef MOTIF
       (resource.expert_mode & XPRT_SHOW_BUTTONS) == 0 ||
#endif
       !XtIsRealized(globals.widgets.top_level))
       return;

#ifdef MOTIF
    XmListSelectPos(LIST_WIDGET, newpage + MOTIF_IDX_OFFSET, False);

    top_visible = xm_get_top_visible(1);
    bot_visible = xm_get_bottom_visible(top_visible);

    xm_maybe_scroll_pagelist(newpage, CLICK, &top_visible, &bot_visible);
#if HAVE_XPM
    tb_check_navigation_sensitivity(current_page);
#endif
#else

    if (LIST_WIDGET == NULL)
       return;
    
    (void)xaw_maybe_scroll_pagelist(newpage + 1, force_recenter, 0);

    XawListHighlight(LIST_WIDGET, newpage);
#if REDRAW_CURRENT_MARKER_HACK
    /* if the XawListHighlight happens adjacent to the page that was
       last highlighted with our home-made `current selected'
       rectangle, it might overdraw that rectangle. In this case,
       restore it:
     */
    xaw_maybe_redraw_current_marker(newpage);
#endif
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pageinfo_allocate ( int  total_pages)

Definition at line 358 of file pagesel.c.

{
    int i;
    page_info.index = xmalloc(total_pages * sizeof *(page_info.index));
    for (i = 0; i < total_pages; i++) {
       page_info.index[i].marked = False;
    }
    /* following initializations are handled by the respective Motif/Xaw functions */
    page_info.page_labels = NULL;
    page_info.index_size = total_pages;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 376 of file pagesel.c.

{
    free(page_info.index);
    page_info.index_size = 0;
    page_info.index = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 333 of file pagesel.c.

{
    size_t i;
    for (i = 0; i < page_info.index_size - 1; i++) {
       if (number == page_info.index[i].number)
           return i;
    }
    return -1;
}

Here is the caller graph for this function:

Definition at line 325 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    return page_info.index[page].number;
}

Here is the caller graph for this function:

long pageinfo_get_offset ( int  page)

Definition at line 260 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
/*      fprintf(stderr, "offset for page %d is %ld\n", page, page_info.index[page].offset); */
    return page_info.index[page].offset;
}

Here is the caller graph for this function:

unsigned int pageinfo_get_page_height ( int  page)

Definition at line 276 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    return page_info.index[page].ph;
}

Here is the caller graph for this function:

unsigned int pageinfo_get_page_width ( int  page)

Definition at line 269 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    return page_info.index[page].pw;
}

Here is the caller graph for this function:

unsigned int pageinfo_get_window_height ( int  page)

Definition at line 290 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    return page_info.index[page].wh;
}

Here is the caller graph for this function:

unsigned int pageinfo_get_window_width ( int  page)

Definition at line 283 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    return page_info.index[page].ww;
}

Here is the caller graph for this function:

Definition at line 429 of file pagesel.c.

{
    int i;
    for (i = 0; i < total_pages; i++) {
       if (page_info.index[i].marked) {
           return True;
       }
    }
    return False;
}

Here is the caller graph for this function:

Definition at line 443 of file pagesel.c.

{
    ASSERT(i <= (int)page_info.index_size, "");
    return page_info.index[i].marked;
}

Here is the caller graph for this function:

void pageinfo_set_number ( int  index,
int  number 
)

Definition at line 351 of file pagesel.c.

{
    ASSERT(index >= 0 && index < (int)page_info.index_size, "");
    page_info.index[index].number = number;
}

Here is the caller graph for this function:

void pageinfo_set_offset ( int  index,
long  offset 
)

Definition at line 344 of file pagesel.c.

{
    ASSERT(index >= 0 && index < (int)page_info.index_size, "");
    page_info.index[index].offset = offset;
}

Here is the caller graph for this function:

void pageinfo_set_page_height ( int  page,
unsigned int  height 
)

Definition at line 304 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    page_info.index[page].ph = height;
}

Here is the caller graph for this function:

void pageinfo_set_page_width ( int  page,
unsigned int  width 
)

Definition at line 297 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    page_info.index[page].pw = width;
}

Here is the caller graph for this function:

void pageinfo_set_window_height ( int  page,
unsigned int  height 
)

Definition at line 318 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    page_info.index[page].wh = height;
}

Here is the caller graph for this function:

void pageinfo_set_window_width ( int  page,
unsigned int  width 
)

Definition at line 311 of file pagesel.c.

{
    ASSERT(page >= 0 && page < (int)page_info.index_size, "Page number out of range");
    page_info.index[page].ww = width;
}

Here is the caller graph for this function:

void refresh_pagelist ( int  newsize,
int  newpage 
)

Definition at line 1307 of file pagesel.c.

{
    if (
#ifndef MOTIF
       (resource.expert_mode & XPRT_SHOW_BUTTONS) == 0 ||
#endif
       !XtIsRealized(globals.widgets.top_level))
       return;

#ifdef DEBUG
    fprintf(stderr, "=== refresh_pagelist: newsize %d, newpage %d\n", newsize, newpage);
#endif
#ifdef MOTIF
/*     items = xrealloc(items, sizeof *items * (newsize + 2)); */
    init_pagelabels(0, newsize);
    xm_set_page_labels();
#else /* MOTIF */
    if ((resource.expert_mode & XPRT_SHOW_BUTTONS) == 0)
       return;

    /* FIXME - is this really neccessary?? The alternative:
          XawListChange(LIST_WIDGET, page_info.page_labels, newsize, 0, True);
       has problems when freeing the page labels afterwards.
    */
    handle_destroy_pagelist(LIST_WIDGET, NULL, NULL);

    free_pagelabels();
    init_pagelabels(0, newsize);

    xaw_create_pagelist();
#endif /* MOTIF */
    /* `True' since the pagelist is newly created */
    maybe_scroll_pagelist(newpage, True);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void xaw_create_pagelist_widgets ( Dimension  height,
Dimension  width,
Position  y,
Widget  parent 
)

Definition at line 1001 of file pagesel.c.

{
    viewport = XtVaCreateWidget("viewport",
                            viewportWidgetClass, parent,
                            XtNallowVert, True,
                            /* this is not related to the scroll bar: */
                            /* XtNforceBars, True, */
                            XtNx, resource.btn_side_spacing,
                            XtNy, y,
                            XtNheight, height,
                            XtNwidth, width,
                            NULL);
    LIST_WIDGET = XtVaCreateWidget("list",
                               listWidgetClass, viewport,
                               XtNlist, page_info.page_labels,
                               XtNdefaultColumns, 1,
                               XtNforceColumns, True,
                               XtNx, 10,
                               XtNy, 10,
                               XtNheight, height,
                               XtNwidth, width - 10,
                               XtNlongest, LONGESTPAGENUM,
                               XtNverticalList, True,
                               NULL);
    XtManageChild(LIST_WIDGET);
    XtManageChild(viewport);
    XtAddCallback(LIST_WIDGET, XtNcallback, select_page_callback,
                (XtPointer) NULL);
    /* for scrolling the list */
    XtAddCallback(viewport, XtNreportCallback, xaw_SendReportProc,
                (XtPointer) NULL);
    XtAddEventHandler(LIST_WIDGET,
                    ButtonPressMask | ButtonReleaseMask | Button2MotionMask,
                    False, mark_page_callback, (XtPointer)NULL);

    if (resource.pagelist_highlight_current)
       XtAddEventHandler(LIST_WIDGET,
                       ButtonPressMask | ButtonReleaseMask | PointerMotionMask | LeaveWindowMask,
                       False, highlight_page_callback, (XtPointer)NULL);

    
    XtAddEventHandler(LIST_WIDGET, ButtonPressMask | ButtonReleaseMask,
                    False, wheel_scroll_list_callback, (XtPointer)NULL);
    
    
    XtAddEventHandler(LIST_WIDGET,
                    /* FIXME: We should add PointerMotionMask here, but handling PointerMotionMask
                      currently doesn't work with the Xaw list widget: the auto-scrolling code doesn't
                      realize when the mouse direction of the pointer movement changes, and continues
                      to scroll into the same direction. This will be rather annoying for users, so
                      we disabled PointerMotionMask for the time being.
                    */
                    ButtonReleaseMask /* | PointerMotionMask */ | Button1MotionMask,
                    False, xaw_drag_page_callback, (XtPointer)NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 577 of file pagesel.c.

{
    Widget w;
    XFontStruct *font;

    w = XtVaCreateWidget("list", listWidgetClass, globals.widgets.top_level, NULL);
    XtVaGetValues(w, XtNfont, &font, NULL);
    XtDestroyWidget(w);

    /* have space for max. pageno + space + current-marker,
       plus a few pixels for right margin */
    return (get_page_size() + 2) * get_avg_font_width(font) + 6;
}

Here is the call graph for this function:

Here is the caller graph for this function: