SHA256
1
0
forked from pool/xfig
xfig/042708.patch

125 lines
4.6 KiB
Diff

From 042708a455f264e5b78d55f4df51ce3e508cc2ba Mon Sep 17 00:00:00 2001
From: Thomas Loimer <thomas.loimer@tuwien.ac.at>
Date: Mon, 2 Sep 2024 21:01:08 +0200
Subject: [PATCH] Place the dimension line text into the widget, #179
Draw the text that should appear in the example dimension line into
the dimension line widget, not onto the canvas.
---
src/w_indpanel.c | 45 +++++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 16 deletions(-)
diff --git src/w_indpanel.c src/w_indpanel.c
index 95218fd..bde8298 100644
--- src/w_indpanel.c
+++ src/w_indpanel.c
@@ -2499,7 +2499,6 @@ static Widget tick_thick_w;
static Widget box_thick_w, font_size_w, dimline_style_panel;
static Widget left_arrow_type_panel, right_arrow_type_panel;
static Widget font_button;
-static Pixmap dimline_examp_pixmap = (Pixmap) 0;
static Widget exampline;
static Widget fixed_chk, actual_chk;
static Widget dimline_precw;
@@ -2599,15 +2598,7 @@ void popup_dimline_panel(ind_sw_info *isw)
/* make an example line that shows current settings as a label */
- /* make a pixmap to draw it into */
- if (dimline_examp_pixmap == (Pixmap) 0)
- dimline_examp_pixmap = XCreatePixmap(tool_d, canvas_win,
- DIMLINE_PIXMAP_WIDTH, DIMLINE_PIXMAP_HEIGHT, tool_dpth);
- /* clear it */
- XFillRectangle(tool_d, dimline_examp_pixmap, ind_blank_gc, 0, 0,
- DIMLINE_PIXMAP_WIDTH, 30);
-
- /* now make the label widget to display the pixmap */
+ /* make the label widget to display the pixmap */
FirstArg(XtNfromVert, below);
NextArg(XtNborderWidth, 0);
NextArg(XtNwidth, DIMLINE_PIXMAP_WIDTH);
@@ -2619,7 +2610,9 @@ void popup_dimline_panel(ind_sw_info *isw)
NextArg(XtNinternational, False);
exampline = XtCreateManagedWidget("", labelWidgetClass,
form, Args, ArgCount);
- draw_cur_dimline(); /* this draws it into dimline_examp_pixmap */
+
+ /* draws the example dimension line into the label */
+ draw_cur_dimline();
/******************************/
/* frame for Line information */
@@ -3098,6 +3091,7 @@ void draw_cur_dimline(void)
F_compound *dimline_example;
F_point *point;
Boolean save_showlen, save_shownums;
+ static Pixmap dimline_examp_pixmap = (Pixmap)0;
/* make the a dimension line */
line = create_line();
@@ -3114,8 +3108,15 @@ void draw_cur_dimline(void)
/* make it 3-3/4 inches long */
append_point((int)((appres.INCHES? DIMLINE_IP_LENGTH*PIX_PER_INCH:
DIMLINE_SI_LENGTH*PIX_PER_CM)+75), 275, &point);
- /* make a dimension line from that line */
- dimline_example = create_dimension_line(line, False);
+
+ /*
+ * With xfig -debug, create_dimension_line() already draws the bounding
+ * boxes of some elements into the canvas. First create the pixmap to draw
+ * the dimension line into.
+ */
+ if (!dimline_examp_pixmap)
+ dimline_examp_pixmap = XCreatePixmap(tool_d, canvas_win,
+ DIMLINE_PIXMAP_WIDTH, DIMLINE_PIXMAP_HEIGHT, tool_dpth);
/* clear it */
XFillRectangle(tool_d, dimline_examp_pixmap, ind_blank_gc, 0, 0,
@@ -3127,8 +3128,19 @@ void draw_cur_dimline(void)
appres.showlengths = appres.shownums = False;
/* now draw it into our pixmap */
- canvas_win = (Window) dimline_examp_pixmap;
+ canvas_win = (Window)dimline_examp_pixmap;
+ XftDrawChange(canvas_draw, dimline_examp_pixmap);
preview_in_progress = True;
+
+ /* Now create an (empty) dimension line compound, with the side effect that
+ * under appres.DEBUG some boxes are drawn. */
+ if ((dimline_example = create_dimension_line(line, False)) == NULL) {
+ free_linestorage(line);
+ XFreePixmap(tool_d, dimline_examp_pixmap);
+ dimline_examp_pixmap = (Pixmap)0;
+ return;
+ }
+
/* locate the line components of the dimension line */
dimline_components(dimline_example, &line, &tick1, &tick2, &poly);
draw_line(line,PAINT);
@@ -3141,6 +3153,7 @@ void draw_cur_dimline(void)
/* restore the canvas */
canvas_win = main_canvas;
+ XftDrawChange(canvas_draw, main_canvas);
/* and the showlengths and shownums settings */
appres.showlengths = save_showlen;
appres.shownums = save_shownums;
@@ -3148,12 +3161,12 @@ void draw_cur_dimline(void)
/* fool the toolkit... you know the drill by now */
XtUnmanageChild(exampline);
- FirstArg(XtNbitmap, (Pixmap) 0);
+ FirstArg(XtNbitmap, (Pixmap)0);
SetValues(exampline);
FirstArg(XtNbitmap, dimline_examp_pixmap);
SetValues(exampline);
XtManageChild(exampline);
- /* finally, free the dimline */
+ /* finally, free the dimline and the pixmap*/
free_compound(&dimline_example);
}
--
2.35.3