Back to index

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

Go to the source code of this file.

Defines

#define MAGBORD   1 /* border size for magnifier */

Functions

void show_distance_from_ruler (XEvent *event, Boolean to_stdout)
void drag_ruler_motion (XEvent *event)
void drag_ruler_release (XEvent *event)
void clear_ruler (void)
void show_ruler (XEvent *event)
void redraw_ruler (void)
void ruler_snap_origin (XEvent *event)
void mag_release (XEvent *event)
void move_magnifier (void)
void create_magnifier (void)

Define Documentation

#define MAGBORD   1 /* border size for magnifier */

Definition at line 30 of file mag.h.


Function Documentation

Definition at line 570 of file mag.c.

{
    /* maybe we should do this only for mouse-1? */
    clearexpose(&mane, 0, g_ruler_pos_y,
              ROUNDUP(pageinfo_get_page_width(current_page), currwin.shrinkfactor) + 2, 1);
    clearexpose(&mane, g_ruler_pos_x, 0,
              1, ROUNDUP(pageinfo_get_page_height(current_page), currwin.shrinkfactor) + 2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 857 of file mag.c.

{
    XtAppAddActions(app, mag_actions, XtNumber(mag_actions));
}

Here is the caller graph for this function:

void drag_ruler_motion ( XEvent *  event)

Definition at line 630 of file mag.c.

{
    int loc_x, loc_y;
    if (event == NULL) { /* toggled via menu */
       /* hack to avoid redrawing ruler at last g_* positions when mode is
          toggled on via menu, then off via keystroke */
       g_ruler_pos_x = g_ruler_pos_y = 0;
       return;
    }
    
    loc_x = event->xbutton.x;
    loc_y = event->xbutton.y;

    if (event->xbutton.window != mane.win) {
       Window dummy;
       (void)XTranslateCoordinates(DISP,
                                RootWindowOfScreen(SCRN), mane.win,
                                event->xbutton.x_root,
                                event->xbutton.y_root,
                                &loc_x,
                                &loc_y,
                                &dummy);
    }

    /* map everything below 0 to the origin */
    if (loc_x < 0)
       loc_x = 0;
    if (loc_y < 0)
       loc_y = 0;
    
    clear_ruler();
    draw_ruler(loc_x, loc_y);
    g_ruler_pos_x = loc_x;
    g_ruler_pos_y = loc_y;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void drag_ruler_release ( XEvent *  event)

Definition at line 667 of file mag.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void mag_release ( XEvent *  event)

Definition at line 108 of file mag.c.

{
    UNUSED(event);
    if (magnifier.win != (Window) 0) {
       if (magnifier_stat) {
           magnifier_stat = -1;    /* destroy upon expose */
       }
       else {
           XDestroyWindow(DISP, magnifier.win);
           if (drawing_mag) {
              globals.ev.flags |= EV_MAG_GONE;
           }
           magnifier.win = (Window) 0;
           mouse_motion = mouse_release = null_mouse;
           globals.ev.flags &= ~EV_MAG_MOVE;
           globals.cursor.flags &= ~CURSOR_MAG;
           globals.ev.flags |= EV_CURSOR;
           can_exposures(&magnifier);
           /*
             Workaround for bug #703304:
             For obscure reasons, XFree 3.3.5 (and apparently also Solaris 8)
             doesn't generate an expose event after the magnifier has beed
             destroyed. But only a redraw() event caused by expose would reset
             currwin.win back to mane.win, which is needed e.g. for getting the
             hyperlink info updated (otherwise, the mouse will not become active
             over a hyperlink).

             Forcing a redraw with
                redraw(&mane);
             may cause a `BadDrawable' X error with color material (e.g. from #702288),
             or a `draw_part: shouldn't happen: POST encountered' error. Neither do
             the following work:
                globals.ev.flags |= EV_EXPOSE;          (doesn't fix the bug)
               draw_page();               (same effect as redraw(&mane))
               globals.ev.flags |= EV_NEWPAGE;   (works, but is crude and causes flicker)
               
             So I decided to use expose() for the time being, which 
             sets mane.min_x to the current x point (which doesn't happen
             with EV_EXPOSE; this causes the test for `mane.min_x < MAXDIM'
             to fail in events.c; look for `see comment in mag.c').
           */
/*         fprintf(stderr, "========triggering expose!\n"); */
           expose(&mane, event->xbutton.x_root, event->xbutton.y_root, 10, 10);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 515 of file mag.c.

{
    if (magnifier.win == (Window) 0)
       globals.ev.flags &= ~EV_MAG_MOVE;
    else if (abs(new_mag_x - mag_x) > 2 * abs(new_mag_y - mag_y))
       do_movemag(new_mag_x, mag_y);
    else if (abs(new_mag_y - mag_y) > 2 * abs(new_mag_x - mag_x))
       do_movemag(mag_x, new_mag_y);
    else
       do_movemag(new_mag_x, new_mag_y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 624 of file mag.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void ruler_snap_origin ( XEvent *  event)

Definition at line 613 of file mag.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void show_distance_from_ruler ( XEvent *  event,
Boolean  to_stdout 
)

Definition at line 405 of file mag.c.

{
    int loc_x, loc_y;
    int precision = 2;
    double factor;

    if (event == NULL) /* when option is toggled */
       return;

    loc_x = event->xbutton.x;
    loc_y = event->xbutton.y;
    if (event->xbutton.window != mane.win) {
       Window ww;
       (void)XTranslateCoordinates(DISP,
                                RootWindowOfScreen(SCRN), mane.win,
                                event->xbutton.x_root,
                                event->xbutton.y_root,
                                &loc_x,
                                &loc_y,
                                &ww);     /* throw away last argument */
    }

    /* map everything below 0 to the origin */
    if (loc_x < 0)
       loc_x = 0;
    if (loc_y < 0)
       loc_y = 0;

    if (strcmp(resource.tick_units, "pt") == 0) {
       factor = 72.27 * currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    else if (strcmp(resource.tick_units, "bp") == 0) {
       factor = 72.0 * currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    else if (strcmp(resource.tick_units, "in") == 0) {
       factor = currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    else if (strcmp(resource.tick_units, "cm") == 0) {
       factor = 2.54 * currwin.shrinkfactor / (double)resource.pixels_per_inch;
       precision = 3;
    }
    else if (strcmp(resource.tick_units, "mm") == 0) {
       factor = 25.4 * currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    else if (strcmp(resource.tick_units, "dd") == 0) {
       factor = 72.27 / (1238.0 / 1157.0) * currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    else if (strcmp(resource.tick_units, "cc") == 0) {
       factor = 72.27 / (12.0 * (1238.0 / 1157.0)) * currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    else if (strcmp(resource.tick_units, "pc") == 0) {
       factor = 72.27 / 12.0 * currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    else if (strcmp(resource.tick_units, "sp") == 0) {
       factor = 65536.0 * 72.27 * currwin.shrinkfactor / (double)resource.pixels_per_inch;
       precision = 1;
    }
    else if (strcmp(resource.tick_units, "px") == 0) { /* pixel units */
       factor = 1;
    }
    else {
       XDVI_WARNING((stderr, "Unrecognized tickUnits [%s]: defaulting to TeX points [pt]",
                    resource.tick_units));
       resource.tick_units = "pt";
       factor = 72.27 * currwin.shrinkfactor / (double)resource.pixels_per_inch;
    }
    
    if (mouse_release != null_mouse) {
       if (to_stdout) {
           XDVI_INFO((stdout, "Ruler/Point: %d,%d, dx: %.*f %s, dy: %.*f %s, dr: %.*f %s",
                     loc_x, loc_y,
                     precision, 0.000, resource.tick_units,
                     precision, 0.000, resource.tick_units,
                     precision, 0.000, resource.tick_units));
       }
       else {
           statusline_print(STATUS_FOREVER,
                          "Ruler/Point: %d,%d, dx: %.*f %s, dy: %.*f %s, dt: %.*f %s",
                          loc_x, loc_y,
                          precision, 0.000, resource.tick_units,
                          precision, 0.000, resource.tick_units,
                          precision, 0.000, resource.tick_units);
       }
    }
    else {
       int d_x = loc_x - g_ruler_pos_x;
       int d_y = loc_y - g_ruler_pos_y;
       double d_z = sqrt((double)d_x * d_x + (double)d_y * d_y);
       double unit_x = (double)d_x * factor;
       double unit_y = (double)d_y * factor;
       double unit_z = d_z * factor;
       if (to_stdout) {
           XDVI_INFO((stdout, "Ruler: %d,%d, Point: %d,%d, dx: %.*f %s, dy: %.*f %s, dr: %.*f %s",
                     g_ruler_pos_x, g_ruler_pos_y, loc_x, loc_y,
                     precision, unit_x, resource.tick_units,
                     precision, unit_y, resource.tick_units,
                     precision, unit_z, resource.tick_units));
       }
       else {
           statusline_print(STATUS_FOREVER,
                          "Ruler: %d,%d, Point: %d,%d, dx: %.*f %s, dy: %.*f %s, dr: %.*f %s",
                          g_ruler_pos_x, g_ruler_pos_y, loc_x, loc_y,
                          precision, unit_x, resource.tick_units,
                          precision, unit_y, resource.tick_units,
                          precision, unit_z, resource.tick_units);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void show_ruler ( XEvent *  event)

Definition at line 580 of file mag.c.

Here is the call graph for this function:

Here is the caller graph for this function: