diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-02-06 16:04:24 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-02-06 16:04:24 +0100 |
commit | 5d2c2b27a6323e2666378b986129b2a7c2c39e5c (patch) | |
tree | ce8982b6c0111f79791068de2c2d4c6ce3138a49 /app/bin/cprint.c | |
parent | b623f5953691b2a0614e6f1f4def86bdbb9a4113 (diff) |
New upstream version 5.2.2GAupstream/5.2.2GA
Diffstat (limited to 'app/bin/cprint.c')
-rw-r--r-- | app/bin/cprint.c | 251 |
1 files changed, 133 insertions, 118 deletions
diff --git a/app/bin/cprint.c b/app/bin/cprint.c index 066e649..a8ae0c1 100644 --- a/app/bin/cprint.c +++ b/app/bin/cprint.c @@ -20,22 +20,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <sys/types.h> -#include <time.h> -#include <string.h> -#include <ctype.h> -#include <math.h> -#include <stdbool.h> - #include "custom.h" #include "dynstring.h" #include "fileio.h" -#include "i18n.h" #include "layout.h" -#include "messages.h" #include "param.h" #include "track.h" -#include "utility.h" +#include "common-ui.h" #define PRINT_GAUDY (0) #define PRINT_PLAIN (1) @@ -57,13 +48,20 @@ static bitmap_t bm, bm0; #define BITMAP( BM, X, Y ) \ (BM).bm[ (X)-(BM).x0 + ((Y)-(BM).y0) * ((BM).x1-(BM).x0) ] -struct { +static struct { coOrd size; coOrd orig; ANGLE_T angle; } currPrintGrid, newPrintGrid; +EXPORT coOrd GetPrintOrig() { + return currPrintGrid.orig; +} + +EXPORT ANGLE_T GetPrintAngle() { + return currPrintGrid.angle; +} /* * GUI VARS */ @@ -104,7 +102,7 @@ static void PrintClear( void ); static void PrintMaxPageSize( void ); static void SelectAllPages(void); static void DoPrintMargin(void); -static bool PrintPageNumber( wPos_t x, wPos_t y, DIST_T width, DIST_T height ); +static bool PrintPageNumber( int x, int y, DIST_T width, DIST_T height ); static bool PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH); static char * printFormatLabels[] = { N_("Portrait"), N_("Landscape"), NULL }; @@ -114,25 +112,26 @@ static char * printRegistrationMarksLabels[] = { N_("Registration Marks (in 1:1 static char * printPageNumberLabels[] = { N_("Page Numbers"), NULL }; static char * printPhysSizeLabels[] = { N_("Ignore Page Margins"), NULL }; static char * printGridLabels[] = { N_("Snap Grid"), NULL }; -static char * printRulerLabels[] = { N_("Rulers"), NULL }; +static char * printRulerLabels[] = { N_("Layout Edge"), N_("Every Page"), N_("None"), NULL }; static char * printRoadbedLabels[] = { N_("Roadbed Outline"), NULL }; static char * printCenterLineLabels[] = { N_("Centerline below Scale 1:1"), NULL }; static paramIntegerRange_t rminScale_999 = { 1, 999, 0, PDO_NORANGECHECK_HIGH }; static paramFloatRange_t r0_ = { 0, 0, 0, PDO_NORANGECHECK_HIGH }; -static paramFloatRange_t r1_ = { 1, 0, 0, PDO_NORANGECHECK_HIGH }; -static paramFloatRange_t r_10_99999 = { -10, 99999, 0, PDO_NORANGECHECK_HIGH }; +static paramFloatRange_t r1_pgsz_x = { 1, 0, 0, 0 }; +static paramFloatRange_t r1_pgsz_y = { 1, 0, 0, 0 }; +static paramFloatRange_t r_100_99999 = { -100, 99999, 0, PDO_NORANGECHECK_HIGH }; static paramFloatRange_t r0_360 = { 0, 360 }; static paramData_t printPLs[] = { -/*0*/ { PD_LONG, &iPrintScale, "scale", 0, &rminScale_999, N_("Print Scale"), 0, (void*)1 }, -/*1*/ { PD_FLOAT, &newPrintGrid.size.x, "pagew", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_, N_("Page Width"), 0, (void*)2 }, -/*2*/ { PD_BUTTON, (void*)PrintMaxPageSize, "max", PDO_DLGHORZ, NULL, N_("Max") }, -/*3*/ { PD_FLOAT, &newPrintGrid.size.y, "pageh", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_, N_("Height"), 0, (void*)2 }, -/*4*/ { PD_BUTTON, (void*)PrintSnapShot, "snapshot", PDO_DLGHORZ, NULL, N_("Snap Shot") }, -/*5*/ { PD_RADIO, &printFormat, "format", 0, printFormatLabels, N_("Page Format"), BC_HORZ|BC_NOBORDER, (void*)1 }, +/*0*/ { PD_LONG, &iPrintScale, "scale", 0, &rminScale_999, N_("Print Scale"), 0, I2VP(1) }, +/*1*/ { PD_FLOAT, &newPrintGrid.size.x, "pagew", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_pgsz_x, N_("Page Width"), 0, I2VP(2) }, +/*2*/ { PD_BUTTON, PrintMaxPageSize, "max", PDO_DLGHORZ, NULL, N_("Max") }, +/*3*/ { PD_FLOAT, &newPrintGrid.size.y, "pageh", PDO_DIM|PDO_SMALLDIM|PDO_NORECORD|PDO_NOPREF, &r1_pgsz_y, N_("Height"), 0, I2VP(2) }, +/*4*/ { PD_BUTTON, PrintSnapShot, "snapshot", PDO_DLGHORZ, NULL, N_("Snap Shot") }, +/*5*/ { PD_RADIO, &printFormat, "format", 0, printFormatLabels, N_("Page Format"), BC_HORZ|BC_NOBORDER, I2VP(1) }, /*6*/ { PD_RADIO, &printOrder, "order", PDO_DLGBOXEND, printOrderLabels, N_("Print Order"), BC_HORZ|BC_NOBORDER }, -/*7*/ { PD_MESSAGE, N_("Print "), NULL, PDO_DLGRESETMARGIN| PDO_DLGNOLABELALIGN, (void*)0 }, -/*8*/ { PD_TOGGLE, &printGaudy, "style", PDO_DLGNOLABELALIGN, printGaudyLabels, NULL, BC_HORZ|BC_NOBORDER, (void*)1 }, +/*7*/ { PD_MESSAGE, N_("Print "), NULL, PDO_DLGRESETMARGIN| PDO_DLGNOLABELALIGN, I2VP(0) }, +/*8*/ { PD_TOGGLE, &printGaudy, "style", PDO_DLGNOLABELALIGN, printGaudyLabels, NULL, BC_HORZ|BC_NOBORDER, I2VP(1) }, #define I_REGMARKS (9) /*9*/ { PD_TOGGLE, &printRegistrationMarks, "registrationMarks", PDO_DLGNOLABELALIGN, printRegistrationMarksLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_PAGENUMBERS (10) @@ -140,28 +139,28 @@ static paramData_t printPLs[] = { #define I_GRID (11) /*11*/ { PD_TOGGLE, &printGrid, "grid", PDO_DLGNOLABELALIGN, printGridLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_RULER (12) -/*12*/ { PD_TOGGLE, &printRuler, "ruler", PDO_DLGNOLABELALIGN, printRulerLabels, NULL, BC_HORZ|BC_NOBORDER }, +/*12*/ { PD_RADIO, &printRuler, "ruler", 0, printRulerLabels, N_("Rulers:"), BC_HORZ|BC_NOBORDER }, #define I_CENTERLINE (13) /*13*/ { PD_TOGGLE, &printCenterLine, "centerLine", PDO_DLGNOLABELALIGN, printCenterLineLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_ROADBED (14) /*14*/{ PD_TOGGLE, &printRoadbed, "roadbed", PDO_DLGNOLABELALIGN, printRoadbedLabels, NULL, BC_HORZ|BC_NOBORDER }, #define I_ROADBEDWIDTH (15) /*15*/{ PD_FLOAT, &printRoadbedWidth, "roadbedWidth", PDO_DIM , &r0_, N_(" Width") }, -/*16*/ { PD_TOGGLE, &printPhysSize, "physsize", PDO_DLGNOLABELALIGN, printPhysSizeLabels, NULL, BC_HORZ | BC_NOBORDER, (void*)1 }, -/*17*/ { PD_BUTTON, (void*)DoPrintMargin, "margin", PDO_DLGHORZ|PDO_DLGBOXEND, NULL, N_("Margins") }, -/*18*/{ PD_FLOAT, &newPrintGrid.orig.x, "origx", PDO_DIM|PDO_DLGRESETMARGIN, &r_10_99999, N_("Origin: X"), 0, (void*)2 }, -/*19*/ { PD_FLOAT, &newPrintGrid.orig.y, "origy", PDO_DIM, &r_10_99999, N_("Y"), 0, (void*)2 }, -/*20*/ { PD_BUTTON, (void*)DoResetGrid, "reset", PDO_DLGHORZ, NULL, N_("Reset") }, -/*21*/ { PD_FLOAT, &newPrintGrid.angle, "origa", PDO_ANGLE|PDO_DLGBOXEND, &r0_360, N_("Angle"), 0, (void*)2 }, -/*22*/ { PD_BUTTON, (void*)DoPrintSetup, "setup", PDO_DLGCMDBUTTON, NULL, N_("Setup") }, -/*23*/ { PD_BUTTON, (void*)SelectAllPages, "selall", 0, NULL, N_("Select All") }, -/*24*/ { PD_BUTTON, (void*)PrintClear, "clear", 0, NULL, N_("Clear") }, +/*16*/ { PD_TOGGLE, &printPhysSize, "physsize", PDO_DLGNOLABELALIGN, printPhysSizeLabels, NULL, BC_HORZ | BC_NOBORDER, I2VP(1) }, +/*17*/ { PD_BUTTON, DoPrintMargin, "margin", PDO_DLGHORZ|PDO_DLGBOXEND, NULL, N_("Margins") }, +/*18*/{ PD_FLOAT, &newPrintGrid.orig.x, "origx", PDO_DIM|PDO_DLGRESETMARGIN, &r_100_99999, N_("Origin: X"), 0, I2VP(2) }, +/*19*/ { PD_FLOAT, &newPrintGrid.orig.y, "origy", PDO_DIM, &r_100_99999, N_("Y"), 0, I2VP(2) }, +/*20*/ { PD_BUTTON, DoResetGrid, "reset", PDO_DLGHORZ, NULL, N_("Reset") }, +/*21*/ { PD_FLOAT, &newPrintGrid.angle, "origa", PDO_ANGLE|PDO_DLGBOXEND, &r0_360, N_("Angle"), 0, I2VP(2) }, +/*22*/ { PD_BUTTON, DoPrintSetup, "setup", PDO_DLGCMDBUTTON, NULL, N_("Setup") }, +/*23*/ { PD_BUTTON, SelectAllPages, "selall", 0, NULL, N_("Select All") }, +/*24*/ { PD_BUTTON, PrintClear, "clear", 0, NULL, N_("Clear") }, #define I_PAGECNT (25) -/*25*/ { PD_MESSAGE, N_("0 pages"), NULL, 0, (void*)80 }, -/*26*/ { PD_MESSAGE, N_("selected"), NULL, 0, (void*)80 } +/*25*/ { PD_MESSAGE, N_("0 pages"), NULL, 0, I2VP(80) }, +/*26*/ { PD_MESSAGE, N_("selected"), NULL, 0, I2VP(80) } }; -static paramGroup_t printPG = { "print", PGO_PREFMISCGROUP, printPLs, sizeof printPLs/sizeof printPLs[0] }; +static paramGroup_t printPG = { "print", PGO_PREFMISCGROUP, printPLs, COUNT( printPLs ) }; static struct { double top, right, bottom, left; @@ -416,8 +415,8 @@ static void PrintGaudyBox( static void PrintPlainBox( - wPos_t x, - wPos_t y, + int x, + int y, coOrd *corners ) { coOrd p00, p01, p10, p11; @@ -507,11 +506,6 @@ static void PrintUpdate( int inx0 ) ParamLoadData( &printPG ); - if (newPrintGrid.size.x > maxPageSize.x+0.01 || - newPrintGrid.size.y > maxPageSize.y+0.01) { - NoticeMessage( MSG_PRINT_MAX_SIZE, _("Ok"), NULL, - FormatSmallDistance(maxPageSize.x), FormatSmallDistance(maxPageSize.y) ); - } if (newPrintGrid.size.x > maxPageSize.x) { newPrintGrid.size.x = maxPageSize.x; ParamLoadControl( &printPG, 1 ); @@ -521,8 +515,8 @@ static void PrintUpdate( int inx0 ) ParamLoadControl( &printPG, 3 ); } currPrintGrid = newPrintGrid; - for ( inx = 0; inx < sizeof printPLs/sizeof printPLs[0]; inx++ ) { - if ( inx != inx0 && printPLs[inx].context == (void*)2 ) + for ( inx = 0; inx < COUNT( printPLs ); inx++ ) { + if ( inx != inx0 && printPLs[inx].context == I2VP(2) ) ParamLoadControl( &printPG, inx ); } ChangeDim(); @@ -554,6 +548,8 @@ static void SetPageSize( BOOL_T doScale ) maxPageSize.x *= printScale; maxPageSize.y *= printScale; } + r1_pgsz_x.high = maxPageSize.x+0.0001; + r1_pgsz_y.high = maxPageSize.y+0.0001; } /** @@ -617,8 +613,8 @@ static paramData_t printMarginPLs[] = { #define I_PM_MESSAGE (4) { PD_MESSAGE, NULL, NULL, 0, NULL }, #define I_PM_RESET (5) - { PD_BUTTON, (void*) PrintMarginReset, "marginReset", PDO_DLGCMDBUTTON, NULL, N_("Reset") } }; -static paramGroup_t printMarginPG = { "printMargin", PGO_PREFMISCGROUP|PGO_NODEFAULTPROC, printMarginPLs, sizeof printMarginPLs/sizeof printMarginPLs[0] }; + { PD_BUTTON, PrintMarginReset, "marginReset", PDO_DLGCMDBUTTON, NULL, N_("Reset") } }; +static paramGroup_t printMarginPG = { "printMargin", PGO_PREFMISCGROUP|PGO_NODEFAULTPROC, printMarginPLs, COUNT( printMarginPLs ) }; static wLines_t aPmLines[] = { { 1, 25, 11, 94, 11 }, @@ -631,9 +627,9 @@ static int pmyoff=5; static void PrintMarginLayout( paramData_t * pd, int index, - wPos_t colX, - wPos_t * w, - wPos_t * h ) + wWinPix_t colX, + wWinPix_t * w, + wWinPix_t * h ) { if ( index < I_PM_FIRST || index > (I_PM_MESSAGE) ) return; @@ -641,7 +637,7 @@ static void PrintMarginLayout( *h = wControlGetPosY( printMarginPLs[I_PM_FIRST+2].control ) + wControlGetHeight( printMarginPLs[I_PM_FIRST+2].control ); return; } - wPos_t x0, y0; + wWinPix_t x0, y0; x0 = (aPmLines[index-I_PM_FIRST].x0+aPmLines[index-I_PM_FIRST].x1)/2; y0 = (aPmLines[index-I_PM_FIRST].y0+aPmLines[index-I_PM_FIRST].y1)/2; x0 -= pmxoff; @@ -690,8 +686,8 @@ static void DoPrintMarginOk( void * context ) sprintf( message, "%s-marginL", sPrinterName ); wPrefSetFloat( "printer", message, printMargin.left ); SetPageSize( TRUE ); - for ( int inx = 0; inx < sizeof printPLs/sizeof printPLs[0]; inx++ ) { - if ( printPLs[inx].context == (void*)2 ) + for ( int inx = 0; inx < COUNT( printPLs ); inx++ ) { + if ( printPLs[inx].context == I2VP(2) ) ParamLoadControl( &printPG, inx ); } DoPrintScale(); @@ -719,17 +715,17 @@ static void DoPrintMargin( void ) DoPrintSetup(); } if ( printMarginWin == NULL ) { - wPos_t x=10, y=10; + int x=10, y=10; printMarginWin = ParamCreateDialog( &printMarginPG, MakeWindowTitle(_("Print Margins")), _("Ok"), DoPrintMarginOk, NULL, TRUE, PrintMarginLayout, F_BLOCK, PrintMarginDlgUpdate ); if ( printMarginWin == NULL ) return; - for ( int i=0; i<sizeof aPmLines / sizeof aPmLines[0]; i++ ) { + for ( int i=0; i<COUNT( aPmLines ); i++ ) { aPmLines[i].x0 += x; aPmLines[i].x1 += x; aPmLines[i].y0 += y; aPmLines[i].y1 += y; } - wLineCreate( printMarginWin, NULL, sizeof aPmLines / sizeof aPmLines[0], aPmLines ); + wLineCreate( printMarginWin, NULL, COUNT( aPmLines ), aPmLines ); } wMessageSetValue( (wMessage_p)printMarginPLs[I_PM_MESSAGE].control, sPrinterName ); // Enable Reset button if we've changed anything @@ -794,8 +790,8 @@ static void PrintSnapShot( void ) scaleH = 1; for (i=0;i<3;i++) { size = mapD.size; - size.x += 0.75*scaleH; - size.y += 0.75*scaleH; + size.x += 2*0.5*scaleH; + size.y += 2*0.5*scaleH; if (printGaudy) size.y += 1.0*scaleH; scaleX = size.x/pageSize.x; @@ -806,8 +802,8 @@ static void PrintSnapShot( void ) scaleV = 1; for (i=0;i<3;i++) { size = mapD.size; - size.x += 0.75*scaleV; - size.y += 0.75*scaleV; + size.x += 2*0.5*scaleV; + size.y += 2*0.5*scaleV; if (printGaudy) size.y += 1.0*scaleV; scaleX = size.x/pageSize.y; @@ -830,8 +826,8 @@ static void PrintSnapShot( void ) currPrintGrid.orig.y = maxPageSize.x-0.5*printScale; currPrintGrid.angle = 90.0; } else {*/ - currPrintGrid.orig.x = -0.5*printScale; - currPrintGrid.orig.y = -0.5*printScale; + currPrintGrid.orig.x = -0.5*printScale; //Bigger rulers + currPrintGrid.orig.y = -0.5*printScale; //Bigger rules currPrintGrid.angle = 0.0; /* }*/ currPrintGrid.size = maxPageSize; @@ -854,7 +850,7 @@ static void DrawRegistrationMarks( drawCmd_p d ) long x, y, delta, divisor; coOrd p0, p1, qq, q0, q1; POS_T len; - char msg[10]; + char msg[STR_SIZE]; wFont_p fp; wFontSize_t fs; fp = wStandardFont( F_TIMES, FALSE, FALSE ); @@ -921,7 +917,9 @@ FormatPageNumber(int x, int y) char *result; DynStringMalloc(&formatted, 16); - if (x > 0 && x <= bm.x1 && y > 0 && y <= bm.y1) { + x -= bm.x0-1; + y -= bm.y0-1; + if (x > 0 && x <= bm.x1-bm.x0 && y > 0 && y <= bm.y1-bm.y0) { DynStringPrintf(&formatted, "(%d/%d)", x, y); } else { DynStringCatCStr(&formatted, "(-/-)"); @@ -944,7 +942,7 @@ FormatPageNumber(int x, int y) */ static bool -PrintPageNumber(wPos_t x, wPos_t y, DIST_T width, DIST_T height) +PrintPageNumber(int x, int y, DIST_T width, DIST_T height) { coOrd printPosition; coOrd textSize; @@ -953,23 +951,26 @@ PrintPageNumber(wPos_t x, wPos_t y, DIST_T width, DIST_T height) wFont_p fp = wStandardFont(F_HELV, TRUE, FALSE); wFontSize_t fs = 64.0; - positionText = FormatPageNumber(x + 1, y + 1); + positionText = FormatPageNumber(x, y); - // even though we're printing into page_d, mainD must be used here - DrawTextSize(&mainD, positionText, fp, fs, TRUE, &textSize); + if (strcmp(positionText,"(-/-)") != 0) { + // even though we're printing into page_d, mainD must be used here + DrawTextSize(&mainD, positionText, fp, fs, TRUE, &textSize); - if (printFormat == PORTRAIT) { - printPosition.x = (width - textSize.x) / 2; - printPosition.y = (height - textSize.y) / 2; - } else { - printPosition.x = (height - textSize.x) / 2; - printPosition.y = (width - textSize.y) / 2; - } + if (printFormat == PORTRAIT) { + printPosition.x = (width - textSize.x) / 2; + printPosition.y = (height - textSize.y) / 2; + } else { + printPosition.x = (height - textSize.x) / 2; + printPosition.y = (width - textSize.y) / 2; + } - page_d.funcs->options |= wDrawOutlineFont; - DrawString(&page_d, printPosition, 0.0, positionText, fp, fs, - wDrawColorGray(70)); - page_d.funcs->options &= ~wDrawOutlineFont; + unsigned long options = page_d.options; + page_d.options |= DC_OUTLINE; + DrawString(&page_d, printPosition, 0.0, positionText, fp, fs, + wDrawColorGray(70)); + page_d.options = options; + } free(positionText); @@ -992,7 +993,9 @@ PrintNextPageNumberAt(int x, int y, coOrd position) wFontSize_t fs = 8.0; pageNumber = FormatPageNumber(x, y); - DrawString(&page_d, position, 0.0, pageNumber, fp, fs, wDrawColorBlack); + //Suppress garbage page numbers + if (strcmp(pageNumber,"(-/-)") != 0) + DrawString(&page_d, position, 0.0, pageNumber, fp, fs, wDrawColorBlack); free(pageNumber); } @@ -1020,7 +1023,7 @@ PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) p00.x = pageH / 2.0 - 20.0 / 72.0; p00.y = pageW - 10.0 / 72.0; } - PrintNextPageNumberAt(x + 1, y + 2, p00); + PrintNextPageNumberAt(x, y + 1, p00); // below if (printFormat == PORTRAIT) { @@ -1028,7 +1031,7 @@ PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) } else { p00.y = 10.0 / 72.0; } - PrintNextPageNumberAt(x + 1, y, p00); + PrintNextPageNumberAt(x, y-1, p00); // right if (printFormat == PORTRAIT) { @@ -1038,7 +1041,7 @@ PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) p00.y = pageW / 2 + 10.0 / 72.0; p00.x = pageH - 20.0 / 72.0; } - PrintNextPageNumberAt(x + 2, y + 1, p00); + PrintNextPageNumberAt(x+1, y, p00); // left if (printFormat == PORTRAIT) { @@ -1046,7 +1049,7 @@ PrintNextPageNumbers(int x, int y, DIST_T pageW, DIST_T pageH) } else { p00.x = 10.0 / 72.0; } - PrintNextPageNumberAt(x, y + 1, p00); + PrintNextPageNumberAt(x-1, y, p00); return (TRUE); } @@ -1142,22 +1145,31 @@ static BOOL_T PrintPage( } } if (printRotate) { - wPrintClip( (wPos_t)(clipOrig.y*print_d.dpi), (wPos_t)(clipOrig.x*print_d.dpi), - (wPos_t)(clipSize.y*print_d.dpi), (wPos_t)(clipSize.x*print_d.dpi) ); + wPrintClip( (clipOrig.y*print_d.dpi), (clipOrig.x*print_d.dpi), + (clipSize.y*print_d.dpi), (clipSize.x*print_d.dpi) ); } else { - wPrintClip( (wPos_t)(clipOrig.x*print_d.dpi), (wPos_t)(clipOrig.y*print_d.dpi), - (wPos_t)(clipSize.x*print_d.dpi), (wPos_t)(clipSize.y*print_d.dpi) ); + wPrintClip( (clipOrig.x*print_d.dpi), (clipOrig.y*print_d.dpi), + (clipSize.x*print_d.dpi), (clipSize.y*print_d.dpi) ); } p[0].x = p[3].x = 0.0; p[1].x = p[2].x = roomSize.x; p[0].y = p[1].y = 0.0; p[2].y = p[3].y = roomSize.y; - DrawRuler( &print_d, p[0], p[1], 0.0, TRUE, FALSE, wDrawColorBlack ); - DrawRuler( &print_d, p[0], p[3], 0.0, TRUE, TRUE, wDrawColorBlack ); - DrawRuler( &print_d, p[1], p[2], 0.0, FALSE, FALSE, wDrawColorBlack ); - DrawRuler( &print_d, p[3], p[2], 0.0, FALSE, TRUE, wDrawColorBlack ); - if ( printRuler && currPrintGrid.angle == 0 ) { + BOOL_T left_clear = FALSE, right_clear = FALSE, base_clear = FALSE, top_clear = FALSE; + + if (currPrintGrid.orig.x <= -0.5*printScale) left_clear = TRUE; + if (currPrintGrid.orig.y <= -0.5*printScale) base_clear = TRUE; + if (clipOrig.x + clipSize.x > roomSize.x + 0.5*printScale) right_clear = TRUE; + if (clipOrig.y + clipSize.y > roomSize.y + 0.5*printScale) top_clear = TRUE; + + if (printRuler != 2) { /* Not None so Edge or Every */ + DrawRuler( &print_d, p[0], p[1], 0.0, TRUE, !base_clear, wDrawColorBlack ); + DrawRuler( &print_d, p[0], p[3], 0.0, TRUE, left_clear, wDrawColorBlack ); + DrawRuler( &print_d, p[1], p[2], 0.0, TRUE, right_clear, wDrawColorBlack ); + DrawRuler( &print_d, p[3], p[2], 0.0, TRUE, !top_clear, wDrawColorBlack ); + } + if ( printRuler==1 && currPrintGrid.angle == 0 ) { /* Every Page and not rotated origin */ if ( !printRotate ) { p[2] = p[3] = print_d.orig; p[3].x += print_d.size.x; @@ -1174,47 +1186,51 @@ static BOOL_T PrintPage( p[3].y = print_d.orig.y; } if ( p[2].x > 0 ) - minP.x = p[2].x + 0.4 * print_d.scale; + minP.x = p[2].x + 0.5 * print_d.scale; else minP.x = 0.0; if ( p[3].x < roomSize.x ) - maxP.x = p[3].x - 0.2 * print_d.scale; + maxP.x = p[3].x - 0.5 * print_d.scale; else maxP.x = roomSize.x; - if ( p[2].y > 0 ) - minP.y = p[2].y + 0.4 * print_d.scale; + if ( p[2].y > 0 ) + minP.y = p[2].y + 0.5 * print_d.scale; else minP.y = 0.0; if ( p[3].y < roomSize.y ) - maxP.y = p[3].y - 0.2 * print_d.scale; + maxP.y = p[3].y - 0.5 * print_d.scale; else maxP.y = roomSize.y; p[0].y = 0.0; p[1].y = maxP.y - minP.y; - if ( p[2].x > 0 ) { - p[0].x = p[1].x = p[2].x + 0.4 * print_d.scale; + if ( p[2].x > 0.5* print_d.scale ) { + p[0].x = p[1].x = p[2].x + 0.5* print_d.scale; DrawRuler( &print_d, p[0], p[1], minP.y, TRUE, TRUE, wDrawColorBlack ); } - if ( p[3].x < roomSize.x ) { - p[0].x = p[1].x = p[3].x - 0.2 * print_d.scale; - DrawRuler( &print_d, p[0], p[1], minP.y, FALSE, FALSE, wDrawColorBlack ); + if ( p[3].x < roomSize.x - 0.5 * print_d.scale ) { + p[0].x = p[1].x = p[3].x - 0.5 * print_d.scale; + DrawRuler( &print_d, p[0], p[1], minP.y, TRUE, FALSE, wDrawColorBlack ); } p[0].x = 0; p[1].x = maxP.x - minP.x; - if ( p[2].y > 0 ) { - p[0].y = p[1].y = p[2].y + 0.4 * print_d.scale; + if ( p[2].y > 0.5 * print_d.scale ) { + p[0].y = p[1].y = p[2].y + 0.5 * print_d.scale; DrawRuler( &print_d, p[0], p[1], minP.x, TRUE, FALSE, wDrawColorBlack ); } - if ( p[3].y < roomSize.y ) { - p[0].y = p[1].y = p[3].y - 0.2 * print_d.scale; - DrawRuler( &print_d, p[0], p[1], minP.x, FALSE, TRUE, wDrawColorBlack ); + if ( p[3].y < roomSize.y - 0.5 * print_d.scale) { + p[0].y = p[1].y = p[3].y - 0.5 * print_d.scale; + DrawRuler( &print_d, p[0], p[1], minP.x, TRUE, TRUE, wDrawColorBlack ); } } if (printGrid) DrawSnapGrid( &print_d, mapD.size, FALSE ); roadbedWidth = printRoadbed?printRoadbedWidth:0.0; - printCenterLines = printCenterLine; + if (printCenterLine) { + print_d.options |= DC_CENTERLINE; + } else { + print_d.options &= ~DC_CENTERLINE; + } DrawTracks( &print_d, print_d.scale, minP, maxP ); if (printRegistrationMarks && printScale == 1) DrawRegistrationMarks( &print_d ); @@ -1296,7 +1312,7 @@ static void DoResetGrid( void ) static void PrintGridRotate( void * pangle ) { - ANGLE_T angle = (ANGLE_T)(long)pangle; + ANGLE_T angle = (ANGLE_T)VP2L(pangle); currPrintGrid.orig = cmdMenuPos; currPrintGrid.angle += angle/1000; newPrintGrid = currPrintGrid; @@ -1330,9 +1346,9 @@ static void PrintDlgUpdate( void * valueP ) { if ( inx < 0 ) return; - if ( pg->paramPtr[inx].context == (void*)1 ) + if ( pg->paramPtr[inx].context == I2VP(1) ) DoPrintScale(); - else if ( pg->paramPtr[inx].context == (void*)2 ) + else if ( pg->paramPtr[inx].context == I2VP(2) ) PrintUpdate( inx ); ParamControlActive( &printPG, I_RULER, currPrintGrid.angle == 0 ); TempRedraw(); // PrintDlgUpdate @@ -1474,6 +1490,9 @@ LOG( log_print, 2, ( "Page size = %0.3f %0.3f\n", currPrintGrid.size.x, currPrin } } + +#include "bitmaps/doc-print.xpm" + EXPORT wIndex_t InitCmdPrint( wMenu_p menu ) { ParamRegister( &printPG ); @@ -1483,7 +1502,7 @@ EXPORT wIndex_t InitCmdPrint( wMenu_p menu ) printGridPopupM = MenuRegister( "Print Grid Rotate" ); AddRotateMenu( printGridPopupM, PrintGridRotate ); ParamRegister( &printMarginPG ); - return InitCommand( menu, CmdPrint, N_("Print..."), NULL, LEVEL0, IC_LCLICK|IC_POPUP3|IC_CMDMENU, ACCL_PRINT ); + return AddMenuButton( menu, CmdPrint, "cmdPrint", N_("Print..."), wIconCreatePixMap(doc_print_xpm[iconSize]), LEVEL0, IC_LCLICK|IC_POPUP3|IC_CMDMENU, ACCL_PRINT, NULL ); } /***************************************************************************** @@ -1495,10 +1514,6 @@ EXPORT wIndex_t InitCmdPrint( wMenu_p menu ) wDrawable_t printD, mainD; -void wDrawHilight( void * d, coOrd orig, coOrd size ) -{ - lprintf( "wDrawHilight (%0.3f %0.3f) (%0.3f %0.3f)\n", orig.x, orig.y, size.x, size.y ); -} void PrintPage( void * d, wIndex_t mode , wIndex_t x, wIndex_t y ) { lprintf( "printPage %dx%d at (%0.3f %0.3f)\n", x, y, orig.x, orig.y ); @@ -1563,7 +1578,7 @@ main( INT_T argc, char * argv[] ) mapD.size.x = 4*12; mapD.size.y = 3*12; printD.scale = 1.0; - for (i=0; i<(sizeof cmds)/(sizeof cmds[0]); i++) { + for (i=0; i<COUNT( cmds ); i++) { switch (cmds[i].cmd) { case C_START: CmdPrint( cmds[i].cmd ); |