Back to index

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

Go to the source code of this file.

Functions

void printlog_create (const char *title, const char *close_label, void(*close_callback)(Widget w, XtPointer client_data, XtPointer call_data), void(*cancel_callback)(Widget w, XtPointer client_data, XtPointer call_data), void(*destroy_callback)(Widget w, XtPointer client_data, XtPointer call_data), void(*unkeep_callback)(Widget w, XtPointer client_data, XtPointer call_data))
Boolean printlog_raise_active (void)
void printlog_popup (void)
void printlog_reset (void)
void printlog_append (const char *str, size_t len)
void printlog_append_str (const char *str)
void printlog_enable_closebutton (void)
void printlog_popdown (Boolean override_timer)

Function Documentation

void printlog_append ( const char *  str,
size_t  len 
)

Definition at line 407 of file print-log.c.

{
#ifndef MOTIF
    
    static XawTextBlock block = {0, 0, NULL, 0};

    block.ptr = (char *) str;
    block.length = len;
    block.format = XawFmt8Bit;
    while (XawTextReplace(printlog_text, printlog_length, printlog_length, &block)
          != XawEditDone) {
       int length;

       XtVaGetValues(printlog_text, XtNlength, &length, NULL);
       printlog_length = length;
    }
    printlog_length += len;
    XawTextSetInsertionPoint(printlog_text, printlog_length);

#else /* MOTIF */
    
    XmTextInsert(printlog_text, printlog_length, (char *) str);
    printlog_length += len;
    XtVaSetValues(printlog_text, XmNcursorPosition, printlog_length, NULL);
    XmTextShowPosition(printlog_text, printlog_length);
    
#endif /* MOTIF */
}

Here is the caller graph for this function:

void printlog_append_str ( const char *  str)

Definition at line 437 of file print-log.c.

{
    printlog_append(str, strlen(str));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printlog_create ( const char *  title,
const char *  close_label,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  close_callback,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  cancel_callback,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  destroy_callback,
void(*)(Widget w, XtPointer client_data, XtPointer call_data)  unkeep_callback 
)

Definition at line 158 of file print-log.c.

{
    /*
      FIXME BETA: The printlog presents too much detail and is confusing for users.
      Re-implement it using an `printing page n of m' message,
      i.e. according to the spec on:
      http://xdvi.sourceforge.net/gui.html#file-print
      Possible save the detailed log to a different window that can be viewed
      via `File -> logs', as described on:
      http://xdvi.sourceforge.net/gui.html#file-logs
     */
    XtAddActions(printlog_actions, XtNumber(printlog_actions));
    g_destroy_callback = destroy_callback;
    
#ifndef MOTIF
    /* Create popup window */
    if (printlog_shell == NULL) {
       Widget form, box, paned;
/*     int ddist; */
/*     Dimension w0, w1, w2, w3, b; */
       
       XtTranslations wm_translations = XtParseTranslationTable("<Message>WM_PROTOCOLS: WM_destroy()");
       printlog_shell = XtVaCreatePopupShell("printlog",
                                         transientShellWidgetClass, globals.widgets.top_level,
                                         XtNtitle, title,
                                         XtNtransientFor, globals.widgets.top_level,
                                         XtNmappedWhenManaged, False,
                                         XtNtranslations, wm_translations,
                                         XtNtransientFor, globals.widgets.top_level,
                                         NULL);

       WM_DELETE_WINDOW = XInternAtom(XtDisplay(printlog_shell), "WM_DELETE_WINDOW", False);
       
       paned = XtVaCreateManagedWidget("paned", panedWidgetClass, printlog_shell, NULL);
       
       form = XtVaCreateManagedWidget("form", formWidgetClass,
                                 paned,
                                 XtNdefaultDistance, 6,
                                 NULL);
       printlog_text = XtVaCreateManagedWidget("text",
                                          asciiTextWidgetClass, form,
                                          XtNstring, "",
                                          XtNdataCompression, False,
                                          XtNeditType, XawtextAppend,
                                          XtNscrollHorizontal, XawtextScrollAlways,
                                          XtNscrollVertical, XawtextScrollAlways,
                                          XtNwidth, 600,
                                          XtNheight, 400,
                                          XtNleft, XawChainLeft,
                                          XtNright, XawChainRight,
                                          XtNtop, XawChainTop,
                                          XtNbottom, XawChainBottom,
                                          NULL);
       XtOverrideTranslations(printlog_text, XtParseTranslationTable(text_translations));

       printlog_unkeep = XtVaCreateManagedWidget("keep",
#ifdef XAW
                                            radioWidgetClass,
#else
                                            toggleWidgetClass,
#endif
                                            form,
                                            XtNlabel, close_label,
                                            XtNborderWidth, 0,
                                            XtNisRadio, False,
                                            XtNhighlightThickness, 1,
                                            XtNfromVert, printlog_text,
                                            XtNleft, XawChainLeft,
                                            XtNright, XawChainLeft,
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            NULL);
       XtVaSetValues(printlog_unkeep,
                    XtNstate, resource.dvips_hang > 0 && resource.dvips_fail_hang > 0,
                    NULL);
       XtAddCallback(printlog_unkeep, XtNcallback, unkeep_callback, NULL);
       
       /* box for the Close/Cancel button */
       box = XtVaCreateManagedWidget("box", formWidgetClass,
                                  paned,
                                  /* resizing by user isn't needed */
                                  XtNshowGrip, False,
                                  XtNdefaultDistance, 6, /* some padding */
                                  /* resizing the window shouldn't influence this box,
                                   * but  only the pane widget
                                   */
                                  XtNskipAdjust, True,
                                  XtNaccelerators, G_accels_cr,
                                  NULL);
       
       printlog_close = XtVaCreateManagedWidget("close",
                                           commandWidgetClass, box,
                                           XtNlabel, "Close",
                                           XtNsensitive, False,
                                           XtNleft, XawChainLeft,
                                           XtNright, XawChainLeft,
                                           XtNtop, XawChainBottom,
                                           XtNbottom, XawChainBottom,
                                           NULL);
       XtAddCallback(printlog_close, XtNcallback, close_callback, NULL);
       g_close_callback = close_callback;
       
       printlog_cancel = XtVaCreateManagedWidget("cancel",
                                            commandWidgetClass, box,
                                            XtNlabel, "Cancel",
                                            XtNfromHoriz, printlog_unkeep,
                                            XtNleft, XawChainRight,
                                            XtNright, XawChainRight,
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            NULL);
       XtAddCallback(printlog_cancel, XtNcallback, cancel_callback, NULL);
       g_cancel_callback = cancel_callback;
       XtManageChild(printlog_shell);
    }
    else {
       XtSetSensitive(printlog_close, False);
       XtSetSensitive(printlog_cancel, True);
    }
    
#else /* MOTIF */

    /* Create popup window */
    if (printlog_shell == NULL) {
       Widget form, pane, box;
       XmString str;
       Arg args[10];
       int n;
       
       printlog_shell = XtVaCreatePopupShell("printlog",
                                         xmDialogShellWidgetClass, globals.widgets.top_level,
                                         XmNdeleteResponse, XmDO_NOTHING, /* we'll take care of that ourselves */
                                         XmNtitle, title,
                                         XtNmappedWhenManaged, False,
                                         NULL);

       WM_DELETE_WINDOW = XmInternAtom(XtDisplay(printlog_shell), "WM_DELETE_WINDOW", False);
       XmAddWMProtocolCallback(printlog_shell, WM_DELETE_WINDOW, xm_printlog_act_destroy, NULL);

       pane = XtVaCreateWidget("printlog_pane", xmPanedWindowWidgetClass, printlog_shell,
                            /* make sashes invisible */
                            XmNsashWidth, 1,
                            XmNsashHeight, 1,
                            NULL);
       
       form = XtVaCreateWidget("form", xmFormWidgetClass, pane,
                            XmNhorizontalSpacing, DDIST,
                            XmNverticalSpacing, DDIST,
                            XmNautoUnmanage, False,
                            NULL);
       /* force vertical scrollbars. Under Motif 2.x (2.1.0 and 2.2.2 at least),
          XmNeditMode must be set early in order to have an effect. */
       n = 0;
       XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT);      n++;
       XtSetArg(args[n], XmNeditable, False);                  n++;
       XtSetArg(args[n], XmNrows, 24);                         n++;
       XtSetArg(args[n], XmNcolumns, 80);               n++;
       
       printlog_text = XmCreateScrolledText(form, "text", args, n);

       XtVaSetValues(XtParent(printlog_text),
                    XmNtopAttachment, XmATTACH_FORM,
                    XmNleftAttachment, XmATTACH_FORM,
                    XmNrightAttachment, XmATTACH_FORM,
                    NULL);

       XtManageChild(printlog_text);

       str = XmStringCreateLocalized((char *)close_label);
       printlog_unkeep = XtVaCreateManagedWidget("keep",
                                          xmToggleButtonGadgetClass, form,
                                          XmNlabelString, str,
                                          XmNnavigationType, XmTAB_GROUP,
                                          XmNtopAttachment, XmATTACH_WIDGET,
                                          XmNtopWidget, XtParent(printlog_text),
                                          XmNleftAttachment, XmATTACH_FORM,
                                          NULL);
       XmStringFree(str);
       XtAddCallback(printlog_unkeep, XmNvalueChangedCallback, unkeep_callback, NULL);
       XmToggleButtonGadgetSetState(printlog_unkeep, resource.dvips_hang > 0 && resource.dvips_fail_hang > 0, False);

       /* box for Close/Cancel button */
       box = XtVaCreateManagedWidget("box", xmFormWidgetClass,
                                  pane,
                                  NULL);
       
       str = XmStringCreateLocalized("Close");
       printlog_close = XtVaCreateManagedWidget("close",
                                           xmPushButtonWidgetClass, box,
                                           XmNlabelString, str,
                                           XmNshowAsDefault, True,
                                           XmNsensitive, False,
                                           XmNdefaultButtonShadowThickness, 1,
                                           XmNtopAttachment, XmATTACH_FORM,
                                           XmNbottomAttachment, XmATTACH_FORM,
                                           XmNleftAttachment, XmATTACH_FORM,
                                           /* to mimick appearance of native dialog buttons: */
                                           XmNmarginWidth, 6,
                                           XmNmarginHeight, 4,
                                           XmNtopOffset, 10,
                                           XmNbottomOffset, 10,
                                           XmNleftOffset, 10,
                                           NULL);
       XmStringFree(str);
       XtAddCallback(printlog_close, XmNactivateCallback, close_callback, NULL);
       g_close_callback = close_callback;

       str = XmStringCreateLocalized("Cancel");
       printlog_cancel = XtVaCreateManagedWidget("cancel",
                                            xmPushButtonWidgetClass, box,
                                            XmNlabelString, str,
                                            XmNdefaultButtonShadowThickness, 1,
                                            XmNtopAttachment, XmATTACH_FORM,
                                            XmNbottomAttachment, XmATTACH_FORM,
                                            XmNrightAttachment, XmATTACH_FORM,
                                            /* to mimick appearance of native dialog buttons: */
                                            XmNmarginWidth, 6,
                                            XmNmarginHeight, 4,
                                            XmNtopOffset, 10,
                                            XmNbottomOffset, 10,
                                            XmNrightOffset, 10,
                                            NULL);
       XmStringFree(str);
       XtAddCallback(printlog_cancel, XmNactivateCallback, cancel_callback, NULL);
       g_cancel_callback = cancel_callback;

       XtManageChild(box);
       XtManageChild(form);
       XtManageChild(pane);
/*     center_window(printlog_shell, globals.widgets.top_level); */
/*     XtMapWidget(printlog_shell); */
       /* this doesn't help */
       /* XtOverrideTranslations(form, XtParseTranslationTable(text_translations)); */
       /* XtOverrideTranslations(pane, XtParseTranslationTable(text_translations)); */
    }
    else {
       XtSetSensitive(printlog_close, False);
       XtSetSensitive(printlog_cancel, True);
    }
#endif
    adjust_width(printlog_close, printlog_cancel);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 444 of file print-log.c.

{
    XtSetSensitive(printlog_close, True);
    XtSetSensitive(printlog_cancel, False);
#if MOTIF
    XmProcessTraversal(printlog_close, XmTRAVERSE_CURRENT);
#endif
}

Here is the caller graph for this function:

void printlog_popdown ( Boolean  override_timer)

Definition at line 466 of file print-log.c.

{
    if (force) { /* user clicked on `Close' */
       printlog_internal_close();
    }
    else { /* timer elapsed */
#ifndef MOTIF
       Boolean state;
       XtVaGetValues(printlog_unkeep, XtNstate, &state, NULL);
       if (state) {
           printlog_internal_close();
       }
#else
       if (XmToggleButtonGadgetGetState(printlog_unkeep)) {
           printlog_internal_close();
       }
#endif
    }    
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 134 of file print-log.c.

{
    printlog_length = 0;
    center_window(printlog_shell, globals.widgets.top_level);
    XtMapWidget(printlog_shell);
/*     XtPopup(printlog_shell, XtGrabNone); */
    printlog_active = True;
#ifndef MOTIF
    XSetWMProtocols(XtDisplay(printlog_shell), XtWindow(printlog_shell), &WM_DELETE_WINDOW, 1);
#else
    XmProcessTraversal(printlog_cancel, XmTRAVERSE_CURRENT);
    XtOverrideTranslations(printlog_text, XtParseTranslationTable(text_translations));
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 124 of file print-log.c.

{
    if (printlog_active) {
       XRaiseWindow(DISP, XtWindow(printlog_shell));
       return True;
    }
    return False;
}

Here is the caller graph for this function:

Definition at line 150 of file print-log.c.

{
    printlog_length = 0;
}

Here is the caller graph for this function: