diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2025-09-20 19:19:34 +0200 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2025-09-20 19:19:34 +0200 |
| commit | e7d20cf352688bf717a01f4e6d9e6f497c2bea4c (patch) | |
| tree | cfd2ef9b569f49af985a6f1ec44f2614f63c8e78 /app/bin/draw.c | |
| parent | a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (diff) | |
New upstream version 5.3.1Beta2upstream/5.3.1Beta2
Diffstat (limited to 'app/bin/draw.c')
| -rw-r--r-- | app/bin/draw.c | 201 |
1 files changed, 105 insertions, 96 deletions
diff --git a/app/bin/draw.c b/app/bin/draw.c index d833a7b..2d3d2fd 100644 --- a/app/bin/draw.c +++ b/app/bin/draw.c @@ -29,6 +29,7 @@ #include "track.h" #include "layout.h" #include "common-ui.h" +#include "include/toolbar.h" EXPORT wIndex_t panCmdInx; @@ -785,7 +786,7 @@ EXPORT void DrawBoxedString( ANGLE_T a) { coOrd size, p[4], p0 = pos, p1, p2; - static int bw = 2, bh = 2, br = 1, bb = 1; + static int br = 0, bl = 1, bt = 2, bb = -1; static double arrowScale = 0.5; POS_T descent, ascent; if (fs < 2 * d->scale) { @@ -804,21 +805,22 @@ EXPORT void DrawBoxedString( #endif DrawTextSize2(&mainD, text, fp, fs, TRUE, &size, &descent, &ascent); - p0.x -= size.x / 2.0; - p0.y -= size.y / 2.0; + if ( (style & BOX_POS_BOTTOM_LEFT) == 0 ) { + // p0 was pos of center, shift to bottom left corner + p0.x -= size.x / 2.0; + p0.y -= size.y / 2.0; + } + style &= ~BOX_POS_BOTTOM_LEFT; + if (style == BOX_NONE || d == &mapD) { DrawString(d, p0, 0.0, text, fp, fs, color); return; } - size.x += bw * d->scale / d->dpi; - size.y += bh * d->scale / d->dpi; - p[0] = p0; - p[0].x -= br * d->scale / d->dpi; //Top of box - p[0].y += (bb * d->scale / d->dpi + ascent); - p[1].y = p[0].y; - p[2].y = p[3].y = p[0].y - size.y - descent; //Bottom of box - p[1].x = p[2].x = p[0].x + size.x; - p[3].x = p[0].x; + p[0].x = p[3].x = p0.x - bl*d->scale/d->dpi; + p[2].x = p[1].x = p0.x + br*d->scale/d->dpi + size.x; + p[0].y = p[1].y = p0.y + bt*d->scale/d->dpi + ascent; + p[3].y = p[2].y = p0.y - bb*d->scale/d->dpi - descent; + d->options &= ~DC_DASH; switch (style) { case BOX_ARROW: @@ -1432,69 +1434,6 @@ EXPORT void SetMessage( char * msg ) * */ -/* - * Set mapW size to fit the rescaled map - * - * \param reset IN - */ -static int mapBorderH = 24; -static int mapBorderW = 24; -static void ChangeMapScale() -{ - wWinPix_t w, h; - FLOAT_T fw, fh; - - // Restrict map size to 1/2 of screen - FLOAT_T fScaleW = mapD.size.x / ( displayWidth * 0.5 / mapD.dpi ); - FLOAT_T fScaleH = mapD.size.y / ( displayHeight * 0.5 / mapD.dpi ); - FLOAT_T fScale = ceil( max( fScaleW, fScaleH ) ); - if ( fScale > mapD.scale ) { - LOG( log_mapsize, 2, ( " ChangeMapScale incr scale from %0.3f to %0.3f\n", - mapD.scale, fScale ) ); - mapD.scale = fScale; - } - - fw = (((mapD.size.x/mapD.scale)*mapD.dpi) + 0.5)+2; - fh = (((mapD.size.y/mapD.scale)*mapD.dpi) + 0.5)+2; - - w = (wWinPix_t)fw; - h = (wWinPix_t)fh; - LOG( log_mapsize, 2, ( " ChangeMapScale mapD.scale=%0.3f w=%ld h=%ld\n", - mapD.scale, w, h ) ); - wWinSetSize( mapW, w+mapBorderW, h+mapBorderH ); - // This should be done by wWinSetSize - wDrawSetSize( mapD.d, w, h, NULL ); -} - - -EXPORT BOOL_T SetRoomSize( coOrd size ) -{ - LOG( log_mapsize, 2, ( "SetRoomSize NEW:%0.3fx%0.3f OLD:%0.3fx%0.3f\n", size.x, - size.y, mapD.size.x, mapD.size.y ) ); - SetLayoutRoomSize(size); - if (size.x < 1.0) { - size.x = 1.0; - } - if (size.y < 1.0) { - size.y = 1.0; - } - if ( mapD.size.x == size.x && - mapD.size.y == size.y ) { - return TRUE; - } - mapD.size = size; - SetLayoutRoomSize(size); - wPrefSetFloat( "draw", "roomsizeX", mapD.size.x ); - wPrefSetFloat( "draw", "roomsizeY", mapD.size.y ); - if ( mapW == NULL) { - return TRUE; - } - ChangeMapScale(); - return TRUE; -} - - - /** * Redraw the Map window using the Scale derived from the Window size and Room size * \param bd [inout] Map canvas - not used @@ -1570,6 +1509,70 @@ static void MapRedraw( } +/* + * Set mapW size to fit the rescaled map + * + * \param reset IN + */ +static int mapBorderH = 24; +static int mapBorderW = 24; +static void ChangeMapScale() +{ + wWinPix_t w, h; + FLOAT_T fw, fh; + + // Restrict map size to 1/2 of screen + FLOAT_T fScaleW = mapD.size.x / ( displayWidth * 0.5 / mapD.dpi ); + FLOAT_T fScaleH = mapD.size.y / ( displayHeight * 0.5 / mapD.dpi ); + FLOAT_T fScale = ceil( max( fScaleW, fScaleH ) ); + if ( fScale > mapD.scale ) { + LOG( log_mapsize, 2, ( " ChangeMapScale incr scale from %0.3f to %0.3f\n", + mapD.scale, fScale ) ); + mapD.scale = fScale; + } + + fw = (((mapD.size.x/mapD.scale)*mapD.dpi) + 0.5)+2; + fh = (((mapD.size.y/mapD.scale)*mapD.dpi) + 0.5)+2; + + w = (wWinPix_t)fw; + h = (wWinPix_t)fh; + LOG( log_mapsize, 2, ( " ChangeMapScale mapD.scale=%0.3f w=%ld h=%ld\n", + mapD.scale, w, h ) ); + wWinSetSize( mapW, w+mapBorderW, h+mapBorderH ); + // This should be done by wWinSetSize + wDrawSetSize( mapD.d, w, h, NULL ); + MapRedraw( mapD.d, NULL, 0, 0 ); +} + + +EXPORT BOOL_T SetRoomSize( coOrd size ) +{ + LOG( log_mapsize, 2, ( "SetRoomSize NEW:%0.3fx%0.3f OLD:%0.3fx%0.3f\n", size.x, + size.y, mapD.size.x, mapD.size.y ) ); + SetLayoutRoomSize(size); + if (size.x < 1.0) { + size.x = 1.0; + } + if (size.y < 1.0) { + size.y = 1.0; + } + if ( mapD.size.x == size.x && + mapD.size.y == size.y ) { + return TRUE; + } + mapD.size = size; + SetLayoutRoomSize(size); + wPrefSetFloat( "draw", "roomsizeX", mapD.size.x ); + wPrefSetFloat( "draw", "roomsizeY", mapD.size.y ); + if ( mapW == NULL) { + return TRUE; + } + ChangeMapScale(); + return TRUE; +} + + + EXPORT void SetMainSize( void ) { wWinPix_t ww, hh; @@ -1598,8 +1601,8 @@ EXPORT void TempRedraw( void ) } else { wDrawDelayUpdate( tempD.d, TRUE ); wDrawSetTempMode( tempD.d, TRUE ); - DrawMarkers(); DoCurCommand( C_REDRAW, zero ); + DrawMarkers(); RulerRedraw( FALSE ); RedrawPlaybackCursor(); //If in playback wDrawSetTempMode( tempD.d, FALSE ); @@ -1694,8 +1697,8 @@ EXPORT void MainRedraw( void ) wGetTimer()-time0 ) ); // The remainder is from TempRedraw wDrawSetTempMode( tempD.d, TRUE ); - DrawMarkers(); DoCurCommand( C_REDRAW, zero ); + DrawMarkers(); RulerRedraw( FALSE ); RedrawPlaybackCursor(); //If in playback wDrawSetTempMode( tempD.d, FALSE ); @@ -1796,15 +1799,15 @@ void MainProc( wWin_p win, winProcEvent e, void * refresh, void * data ) wWinGetSize( mainW, &width, &height ); LOG( log_redraw, 1, ( "MainProc/Resize: %d %s %ld %ld\n", cMP++, refresh==NULL?"RDW":"---", width, height ) ); - LayoutToolBar(refresh); - height -= (toolbarHeight+max(infoHeight,textHeight)+10); + ToolbarLayout(refresh); + height -= (ToolbarGetHeight() +max(infoHeight,textHeight)+10); if (height >= 0) { wBool_t bTemp = wDrawSetTempMode(mainD.d, FALSE ); if ( bTemp ) { printf( "MainProc TempMode\n" ); } wDrawSetSize( mainD.d, width-20, height, refresh ); - wControlSetPos( (wControl_p)mainD.d, 0, toolbarHeight ); + wControlSetPos( (wControl_p)mainD.d, 0, ToolbarGetHeight()); SetMainSize(); SetInfoBar(); panCenter.x = mainD.orig.x + mainD.size.x/2.0; @@ -1837,7 +1840,6 @@ EXPORT void DoRedraw( void ) { LOG( log_mapsize, 2, ( "DoRedraw\n" ) ); ChangeMapScale(); - MapRedraw( mapD.d, NULL, 0, 0 ); MainRedraw(); // DoRedraw } @@ -1875,10 +1877,12 @@ static void DrawMarkers( void ) p0.x = p1.x = oldMarker.x; p0.y = mainD.orig.y; p1.y = mainD.orig.y-BBORDER*mainD.scale/mainD.dpi; + DrawLine( &tempD, p0, p1, 3, wDrawColorWhite ); DrawLine( &tempD, p0, p1, 0, markerColor ); p0.y = p1.y = oldMarker.y; p0.x = mainD.orig.x; p1.x = mainD.orig.x-LBORDER*mainD.scale/mainD.dpi; + DrawLine( &tempD, p0, p1, 3, wDrawColorWhite ); DrawLine( &tempD, p0, p1, 0, markerColor ); } @@ -1900,7 +1904,7 @@ EXPORT void DrawRuler( long inch, lastInch; DIST_T len; int digit; - char quote; + char quote = ' '; char message[STR_SHORT_SIZE]; coOrd d_orig, d_size; wFontSize_t fs; @@ -1936,6 +1940,7 @@ EXPORT void DrawRuler( } end = FindDistance( orig, pos1 ); + DrawLine( d, pos0, pos1, 3, wDrawColorWhite ); DrawLine( d, pos0, pos1, 0, color ); if (units == UNITS_METRIC) { @@ -1969,6 +1974,7 @@ EXPORT void DrawRuler( if (power==1000 || mm%(power*10) != 0) { Translate( &p0, orig, a, mm/25.4 ); Translate( &p1, p0, aa, len*d->scale/mainD.dpi ); + DrawLine( d, p0, p1, 3, wDrawColorWhite ); DrawLine( d, p0, p1, 0, color ); if (!number || (d->scale > 40 && mm % skip != 0.0)) { continue; @@ -1991,7 +1997,9 @@ EXPORT void DrawRuler( //p0.x = p0.x+((-(LBORDER-2)/2)+((LBORDER-2)/2+2)*sin_aa)*d->scale/mainD.dpi; //p0.y = p1.y+dyn*d->scale/mainD.dpi; } - DrawString( d, p0, 0.0, message, rulerFp, fs*d->scale, color ); + DrawBoxedString( BOX_BACKGROUND|BOX_POS_BOTTOM_LEFT, + d, p0, message, rulerFp, fs*d->scale, + color, 0 ); } } } @@ -2058,6 +2066,7 @@ EXPORT void DrawRuler( if(!skip) { Translate( &p0, orig, a, inch+fraction/16.0 ); Translate( &p1, p0, aa, lengths[fraction]*d->scale/mainD.dpi ); + DrawLine( d, p0, p1, 3, wDrawColorWhite ); DrawLine( d, p0, p1, 0, color ); } if (fraction == 0) { @@ -2078,7 +2087,9 @@ EXPORT void DrawRuler( Translate( &p0, p0, aa, majorLength*d->scale/mainD.dpi ); Translate( &p0, p0, 225, fs*d->scale/mainD.dpi ); sprintf(message, "%d%c", digit, quote ); - DrawString( d, p0, 0.0, message, rulerFp, fs*d->scale, color ); + DrawBoxedString( BOX_BACKGROUND|BOX_POS_BOTTOM_LEFT, + d, p0, message, rulerFp, fs*d->scale, + color, 0 ); } } } @@ -2426,7 +2437,7 @@ EXPORT void DoZoomExtents( void * mode) return; } track_p trk = NULL; - coOrd bot, top; + coOrd bot = {0.0, 0.0}, top = {0.0, 0.0}; BOOL_T first = TRUE; while ( TrackIterate( &trk ) ) { if(GetTrkSelected(trk)) { @@ -2839,7 +2850,7 @@ coOrd minIncrementSizes() static void DoMouse( wAction_t action, coOrd pos ) { - BOOL_T rc; + int rc; wDrawPix_t x, y; static BOOL_T ignoreCommands; // Middle button pan state @@ -2958,7 +2969,7 @@ static void DoMouse( wAction_t action, coOrd pos ) action = C_TEXT+((int)(0x0A<<8)); break; } - int rc = DoPanKeyAction(action); + rc = DoPanKeyAction(action); if (rc!=1) { return; } break; case C_TEXT: @@ -3047,9 +3058,6 @@ static void DoMouse( wAction_t action, coOrd pos ) Reset(); DoCurCommand( C_START, zero ); break; - case C_INFO: - Reset(); - break; } } @@ -3283,11 +3291,11 @@ EXPORT void DrawInit( int initialZoom ) // InitColor(); wWinGetSize( mainW, &w, &h ); - /*LayoutToolBar();*/ - h = h - (toolbarHeight+max(textHeight,infoHeight)+10); + + h = h - (ToolbarGetHeight() +max(textHeight,infoHeight)+10); if ( w <= 0 ) { w = 1; } if ( h <= 0 ) { h = 1; } - tempD.d = mainD.d = wDrawCreate( mainW, 0, toolbarHeight, "", + tempD.d = mainD.d = wDrawCreate( mainW, 0, ToolbarGetHeight(), "", BD_TICKS|BD_MODKEYS, w, h, &mainD, MainLayoutCB, DoMousew ); @@ -3320,7 +3328,8 @@ EXPORT void DrawInit( int initialZoom ) /*h = (wWinPix_t)((mapD.size.y/mapD.scale)*mainD.dpi + 0.5)+2;*/ ParamRegister( &mapPG ); LOG( log_mapsize, 2, ( "DrawInit/ParamCreateDialog(&mapPG\n" ) ); - mapW = ParamCreateDialog( &mapPG, MakeWindowTitle(_("Map")), NULL, NULL, NULL, + mapW = ParamCreateDialog( &mapPG, MakeWindowTitle(_("Map")), NULL, NULL, + ParamCancel_Null, FALSE, NULL, F_RESIZE, NULL ); ChangeMapScale(); @@ -3336,7 +3345,7 @@ EXPORT void DrawInit( int initialZoom ) RegisterChangeNotification( DrawChange ); } -#include "bitmaps/pan-zoom.xpm3" +#include "bitmaps/pan-zoom.image3" static wMenu_p panPopupM; @@ -3526,7 +3535,7 @@ EXPORT void PanMenuEnter( void * keyVP ) EXPORT void InitCmdPan( wMenu_p menu ) { panCmdInx = AddMenuButton( menu, CmdPan, "cmdPan", _("Pan/Zoom"), - wIconCreatePixMap(pan_zoom_xpm3[iconSize]), + wIconCreatePixMap(pan_zoom_image3[iconSize]), LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU, ACCL_PAN, NULL ); } EXPORT void InitCmdPan2( wMenu_p menu ) |
