summaryrefslogtreecommitdiff
path: root/app/bin/doption.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
commitd1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch)
tree326578f0505cbed07cfe60de530022822dc237ac /app/bin/doption.c
parent16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff)
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/bin/doption.c')
-rw-r--r--app/bin/doption.c221
1 files changed, 78 insertions, 143 deletions
diff --git a/app/bin/doption.c b/app/bin/doption.c
index b1533c9..ae36d21 100644
--- a/app/bin/doption.c
+++ b/app/bin/doption.c
@@ -21,9 +21,14 @@
*/
#include <ctype.h>
-#include "track.h"
+
#include "ccurve.h"
+#include "cselect.h"
+#include "custom.h"
#include "i18n.h"
+#include "messages.h"
+#include "param.h"
+#include "track.h"
static paramIntegerRange_t i0_64 = { 0, 64 };
static paramIntegerRange_t i1_64 = { 1, 64 };
@@ -36,17 +41,16 @@ static paramIntegerRange_t i10_100 = { 10, 100 };
static paramFloatRange_t r0o1_1 = { 0.1, 1 };
static paramFloatRange_t r1_10 = { 1, 10 };
static paramFloatRange_t r1_1000 = { 1, 1000 };
-static paramFloatRange_t r1_10000 = { 1, 10000 };
-static paramFloatRange_t r0_90 = { 0, 90 };
static paramFloatRange_t r0_180 = { 0, 180 };
-static paramFloatRange_t r1_9999999 = { 1, 9999999 };
static void UpdatePrefD( void );
+static void UpdateMeasureFmt(void);
+
+static wIndex_t distanceFormatInx;
EXPORT long enableBalloonHelp = 1;
-static long GetChanges(
- paramGroup_p pg )
+long GetChanges( paramGroup_p pg )
{
long changes;
long changed;
@@ -73,8 +77,13 @@ static void OptionDlgUpdate(
quickMove = *(long*)valueP;
UpdateQuickMove(NULL);
quickMove = quickMoveOld;
- } else if ( pg->paramPtr[inx].valueP == &units ) {
- UpdatePrefD();
+ } else {
+ if (pg->paramPtr[inx].valueP == &units) {
+ UpdatePrefD();
+ }
+ if (pg->paramPtr[inx].valueP == &distanceFormatInx) {
+ UpdateMeasureFmt();
+ }
}
}
@@ -86,121 +95,6 @@ static void OptionDlgCancel(
wHide( win );
}
-/****************************************************************************
- *
- * Layout Dialog
- *
- */
-
-static wWin_p layoutW;
-static coOrd newSize;
-
-static paramData_t layoutPLs[] = {
- { PD_FLOAT, &newSize.x, "roomsizeX", PDO_NOPREF|PDO_DIM|PDO_NOPSHUPD|PDO_DRAW, &r1_9999999, N_("Room Width"), 0, (void*)(CHANGE_MAIN|CHANGE_MAP) },
- { PD_FLOAT, &newSize.y, "roomsizeY", PDO_NOPREF|PDO_DIM|PDO_NOPSHUPD|PDO_DRAW|PDO_DLGHORZ, &r1_9999999, N_(" Height"), 0, (void*)(CHANGE_MAIN|CHANGE_MAP) },
- { PD_STRING, &Title1, "title1", PDO_NOPSHUPD, NULL, N_("Layout Title") },
- { PD_STRING, &Title2, "title2", PDO_NOPSHUPD, NULL, N_("Subtitle") },
- { PD_DROPLIST, &curScaleDescInx, "scale", PDO_NOPREF|PDO_NOPSHUPD|PDO_NORECORD|PDO_NOUPDACT, (void *)120, N_("Scale"), 0, (void*)(CHANGE_SCALE) },
- { PD_DROPLIST, &curGaugeInx, "gauge", PDO_NOPREF |PDO_NOPSHUPD|PDO_NORECORD|PDO_NOUPDACT|PDO_DLGHORZ, (void *)120, N_(" Gauge"), 0, (void *)(CHANGE_SCALE) },
- { PD_FLOAT, &minTrackRadius, "mintrackradius", PDO_DIM|PDO_NOPSHUPD|PDO_NOPREF, &r1_10000, N_("Min Track Radius"), 0, (void*)(CHANGE_MAIN|CHANGE_LIMITS) },
- { PD_FLOAT, &maxTrackGrade, "maxtrackgrade", PDO_NOPSHUPD|PDO_DLGHORZ, &r0_90 , N_(" Max Track Grade"), 0, (void*)(CHANGE_MAIN) }
- };
-
-
-static paramGroup_t layoutPG = { "layout", PGO_RECORD|PGO_PREFMISC, layoutPLs, sizeof layoutPLs/sizeof layoutPLs[0] };
-
-static void LayoutDlgUpdate( paramGroup_p pg, int inx, void * valueP );
-
-
-static void LayoutOk( void * junk )
-{
- long changes;
- char prefString[ 30 ];
-
- changes = GetChanges( &layoutPG );
-
- /* [mf Nov. 15, 2005] Get the gauge/scale settings */
- if (changes & CHANGE_SCALE) {
- SetScaleGauge( curScaleDescInx, curGaugeInx );
- }
- /* [mf Nov. 15, 2005] end */
-
- if (changes & CHANGE_MAP) {
- SetRoomSize( newSize );
- }
-
- wHide( layoutW );
- DoChangeNotification(changes);
-
- if( changes & CHANGE_LIMITS ) {
- // now set the minimum track radius
- sprintf( prefString, "minTrackRadius-%s", curScaleName );
- wPrefSetFloat( "misc", prefString, minTrackRadius );
- }
-}
-
-
-static void LayoutChange( long changes )
-{
- if (changes & (CHANGE_SCALE|CHANGE_UNITS))
- if (layoutW != NULL && wWinIsVisible(layoutW) )
- ParamLoadControls( &layoutPG );
-}
-
-
-static void DoLayout( void * junk )
-{
- newSize = mapD.size;
- if (layoutW == NULL) {
- layoutW = ParamCreateDialog( &layoutPG, MakeWindowTitle(_("Layout Options")), _("Ok"), LayoutOk, wHide, TRUE, NULL, 0, LayoutDlgUpdate );
- LoadScaleList( (wList_p)layoutPLs[4].control );
- }
- LoadGaugeList( (wList_p)layoutPLs[5].control, curScaleDescInx ); /* set correct gauge list here */
- ParamLoadControls( &layoutPG );
- wShow( layoutW );
-}
-
-
-
-EXPORT addButtonCallBack_t LayoutInit( void )
-{
- ParamRegister( &layoutPG );
- RegisterChangeNotification( LayoutChange );
- return &DoLayout;
-}
-
-/* [mf Nov. 15, 2005] Catch changes done in the LayoutDialog */
-static void
-LayoutDlgUpdate(
- paramGroup_p pg,
- int inx,
- void * valueP )
-{
- char prefString[ 100 ];
- char scaleDesc[ 100 ];
-
- /* did the scale change ? */
- if( inx == 4 ) {
- LoadGaugeList( (wList_p)layoutPLs[5].control, *((int *)valueP) );
- // set the first entry as default, usually the standard gauge for a scale
- wListSetIndex( (wList_p)layoutPLs[5].control, 0 );
-
- // get the minimum radius
- // get the selected scale first
- wListGetValues((wList_p)layoutPLs[4].control, scaleDesc, 99, NULL, NULL );
- // split of the name from the scale
- strtok( scaleDesc, " " );
-
- // now get the minimum track radius
- sprintf( prefString, "minTrackRadius-%s", scaleDesc );
- wPrefGetFloat( "misc", prefString, &minTrackRadius, 0.0 );
-
- // put the scale's minimum value into the dialog
- wStringSetValue( (wString_p)layoutPLs[6].control, FormatDistance( minTrackRadius ) );
- }
-}
-
-/* [mf Nov. 15, 2005] end */
/****************************************************************************
*
@@ -213,6 +107,7 @@ static wWin_p displayW;
static char * autoPanLabels[] = { N_("Auto Pan"), NULL };
static char * drawTunnelLabels[] = { N_("Hide"), N_("Dash"), N_("Normal"), NULL };
static char * drawEndPtLabels3[] = { N_("None"), N_("Turnouts"), N_("All"), NULL };
+static char * drawEndPtUnconnectedSize[] = { N_("Normal"), N_("Thick"), N_("Exception"), NULL };
static char * tiedrawLabels[] = { N_("None"), N_("Outline"), N_("Solid"), NULL };
static char * drawCenterCircle[] = { N_("Off"), N_("On"), NULL };
static char * labelEnableLabels[] = { N_("Track Descriptions"), N_("Lengths"), N_("EndPt Elevations"), N_("Track Elevations"), N_("Cars"), NULL };
@@ -221,6 +116,7 @@ static char * listLabelsLabels[] = { N_("Manuf"), N_("Part No"), N_("Descr"), NU
static char * colorLayersLabels[] = { N_("Tracks"), N_("Other"), NULL };
static char * liveMapLabels[] = { N_("Live Map"), NULL };
static char * hideTrainsInTunnelsLabels[] = { N_("Hide Trains On Hidden Track"), NULL };
+static char * zoomCornerLabels[] = {N_("Zoom keeps lower corner in view"), NULL};
extern long trainPause;
@@ -228,10 +124,12 @@ static paramData_t displayPLs[] = {
{ PD_TOGGLE, &colorLayers, "color-layers", PDO_NOPSHUPD|PDO_DRAW, colorLayersLabels, N_("Color Layers"), BC_HORZ, (void*)(CHANGE_MAIN) },
{ PD_RADIO, &drawTunnel, "tunnels", PDO_NOPSHUPD|PDO_DRAW, drawTunnelLabels, N_("Draw Tunnel"), BC_HORZ, (void*)(CHANGE_MAIN) },
{ PD_RADIO, &drawEndPtV, "endpt", PDO_NOPSHUPD|PDO_DRAW, drawEndPtLabels3, N_("Draw EndPts"), BC_HORZ, (void*)(CHANGE_MAIN) },
+ { PD_RADIO, &drawUnconnectedEndPt, "unconnected-endpt", PDO_NOPSHUPD|PDO_DRAW, drawEndPtUnconnectedSize, N_("Draw Unconnected EndPts"), BC_HORZ, (void*)(CHANGE_MAIN) },
{ PD_RADIO, &tieDrawMode, "tiedraw", PDO_NOPSHUPD|PDO_DRAW, tiedrawLabels, N_("Draw Ties"), BC_HORZ, (void*)(CHANGE_MAIN) },
{ PD_RADIO, &centerDrawMode, "centerdraw", PDO_NOPSHUPD|PDO_DRAW, drawCenterCircle, N_("Draw Centers"), BC_HORZ, (void*)(CHANGE_MAIN | CHANGE_MAP) },
{ PD_LONG, &twoRailScale, "tworailscale", PDO_NOPSHUPD, &i1_64, N_("Two Rail Scale"), 0, (void*)(CHANGE_MAIN) },
{ PD_LONG, &mapScale, "mapscale", PDO_NOPSHUPD, &i1_256, N_("Map Scale"), 0, (void*)(CHANGE_MAP) },
+ { PD_TOGGLE, &zoomCorner, "zoom-corner", PDO_NOPSHUPD, zoomCornerLabels, "", BC_HORZ },
{ PD_TOGGLE, &liveMap, "livemap", PDO_NOPSHUPD, liveMapLabels, "", BC_HORZ },
{ PD_TOGGLE, &autoPan, "autoPan", PDO_NOPSHUPD, autoPanLabels, "", BC_HORZ },
{ PD_TOGGLE, &labelEnable, "labelenable", PDO_NOPSHUPD, labelEnableLabels, N_("Label Enable"), 0, (void*)(CHANGE_MAIN) },
@@ -241,7 +139,7 @@ static paramData_t displayPLs[] = {
{ PD_TOGGLE, &layoutLabels, "layoutlabels", PDO_NOPSHUPD, listLabelsLabels, N_("Layout Labels"), BC_HORZ, (void*)(CHANGE_MAIN) },
{ PD_TOGGLE, &listLabels, "listlabels", PDO_NOPSHUPD, listLabelsLabels, N_("List Labels"), BC_HORZ, (void*)(CHANGE_PARAMS) },
/* ATTENTION: update the define below if you add entries above */
-#define I_HOTBARLABELS (15)
+#define I_HOTBARLABELS (17)
{ PD_DROPLIST, &carHotbarModeInx, "carhotbarlabels", PDO_NOPSHUPD|PDO_DLGUNDERCMDBUTT|PDO_LISTINDEX, (void*)250, N_("Car Labels"), 0, (void*)CHANGE_SCALE },
{ PD_LONG, &trainPause, "trainpause", PDO_NOPSHUPD, &i10_1000 , N_("Train Update Delay"), 0, 0 },
{ PD_TOGGLE, &hideTrainsInTunnels, "hideTrainsInTunnels", PDO_NOPSHUPD, hideTrainsInTunnelsLabels, "", BC_HORZ }
@@ -312,7 +210,7 @@ static char * moveQlabels[] = {
N_("End-Points"),
NULL };
-static char * preSelectLabels[] = { N_("Describe"), N_("Select"), NULL };
+static char * preSelectLabels[] = { N_("Properties"), N_("Select"), NULL };
#ifdef HIDESELECTIONWINDOW
static char * hideSelectionWindowLabels[] = { N_("Hide"), NULL };
@@ -374,7 +272,6 @@ EXPORT addButtonCallBack_t CmdoptInit( void )
static wWin_p prefW;
static long displayUnits;
-static wIndex_t distanceFormatInx;
static char * unitsLabels[] = { N_("English"), N_("Metric"), NULL };
static char * angleSystemLabels[] = { N_("Polar"), N_("Cartesian"), NULL };
static char * enableBalloonHelpLabels[] = { N_("Balloon Help"), NULL };
@@ -384,14 +281,14 @@ static paramData_t prefPLs[] = {
{ PD_RADIO, &angleSystem, "anglesystem", PDO_NOPSHUPD, angleSystemLabels, N_("Angles"), BC_HORZ },
{ PD_RADIO, &units, "units", PDO_NOPSHUPD|PDO_NOUPDACT, unitsLabels, N_("Units"), BC_HORZ, (void*)(CHANGE_MAIN|CHANGE_UNITS) },
#define I_DSTFMT (2)
- { PD_DROPLIST, &distanceFormatInx, "dstfmt", PDO_NOPSHUPD|PDO_LISTINDEX, (void*)150, N_("Length Format"), 0, (void*)(CHANGE_MAIN|CHANGE_UNITS) },
+ { PD_DROPLIST, &distanceFormatInx, "dstfmt", PDO_DIM|PDO_NOPSHUPD|PDO_LISTINDEX, (void*)150, N_("Length Format"), 0, (void*)(CHANGE_MAIN|CHANGE_UNITS) },
{ PD_FLOAT, &minLength, "minlength", PDO_DIM|PDO_SMALLDIM|PDO_NOPSHUPD, &r0o1_1, N_("Min Track Length") },
{ PD_FLOAT, &connectDistance, "connectdistance", PDO_DIM|PDO_SMALLDIM|PDO_NOPSHUPD, &r0o1_1, N_("Connection Distance"), },
{ PD_FLOAT, &connectAngle, "connectangle", PDO_NOPSHUPD, &r1_10, N_("Connection Angle") },
{ PD_FLOAT, &turntableAngle, "turntable-angle", PDO_NOPSHUPD, &r0_180, N_("Turntable Angle") },
{ PD_LONG, &maxCouplingSpeed, "coupling-speed-max", PDO_NOPSHUPD, &i10_100, N_("Max Coupling Speed"), 0 },
{ PD_TOGGLE, &enableBalloonHelp, "balloonhelp", PDO_NOPSHUPD, enableBalloonHelpLabels, "", BC_HORZ },
- { PD_LONG, &dragPixels, "dragpixels", PDO_NOPSHUPD|PDO_DRAW, &r1_1000, N_("Drag Distance") },
+ { PD_LONG, &dragPixels, "dragpixels", PDO_NOPSHUPD|PDO_DRAW, &i1_1000, N_("Drag Distance") },
{ PD_LONG, &dragTimeout, "dragtimeout", PDO_NOPSHUPD|PDO_DRAW, &i1_1000, N_("Drag Timeout") },
{ PD_LONG, &minGridSpacing, "mingridspacing", PDO_NOPSHUPD|PDO_DRAW, &i1_100, N_("Min Grid Spacing"), 0, 0 },
{ PD_LONG, &checkPtInterval, "checkpoint", PDO_NOPSHUPD|PDO_FILE, &i0_10000, N_("Check Point") },
@@ -458,6 +355,10 @@ static void LoadDstFmtList( void )
wListAddValue( (wList_p)prefPLs[I_DSTFMT].control, _(dstFmts[units][inx].name), NULL, (void*)dstFmts[units][inx].fmt );
}
+/**
+* Handle changing of measurement system. The list of number formats is loaded
+* and the first entry is selected as default value.
+*/
static void UpdatePrefD( void )
{
@@ -467,41 +368,75 @@ static void UpdatePrefD( void )
if ( prefW==NULL || (!wWinIsVisible(prefW)) || prefPLs[1].control==NULL )
return;
newUnits = wRadioGetValue( (wChoice_p)prefPLs[1].control );
- if ( newUnits == displayUnits )
- return;
- oldUnits = units;
- units = newUnits;
- for ( inx = 0; inx<sizeof prefPLs/sizeof prefPLs[0]; inx++ ) {
- if ( (prefPLs[inx].option&PDO_DIM) ) {
- ParamLoadControl( &prefPG, inx );
+ if (newUnits != displayUnits) {
+ oldUnits = units;
+ units = newUnits;
+ LoadDstFmtList();
+ distanceFormatInx = 0;
+
+ for (inx = 0; inx < sizeof prefPLs / sizeof prefPLs[0]; inx++) {
+ if ((prefPLs[inx].option&PDO_DIM)) {
+ ParamLoadControl(&prefPG, inx);
+ }
}
+
+ units = oldUnits;
+ displayUnits = newUnits;
}
- LoadDstFmtList();
- units = oldUnits;
- displayUnits = newUnits;
+ return;
}
+/**
+ * Handle changes of the measurement format.
+ */
+
+static void UpdateMeasureFmt()
+{
+ int inx;
+
+ distanceFormatInx = wListGetIndex((wList_p)prefPLs[I_DSTFMT].control);
+ units = wRadioGetValue((wChoice_p)prefPLs[1].control);
+
+ for (inx = 0; inx < sizeof prefPLs / sizeof prefPLs[0]; inx++) {
+ if ((prefPLs[inx].option&PDO_DIM)) {
+ ParamLoadControl(&prefPG, inx);
+ }
+ }
+}
static void PrefOk( void * junk )
{
- wBool_t resetValues = FALSE;
+ wBool_t resetValuesLow = FALSE, resetValuesHigh = FALSE;
long changes;
changes = GetChanges( &prefPG );
if (connectAngle < 1.0) {
connectAngle = 1.0;
- resetValues = TRUE;
+ resetValuesLow = TRUE;
+ } else if (connectAngle > 10.0) {
+ connectAngle = 10.0;
+ resetValuesHigh = TRUE;
}
if (connectDistance < 0.1) {
connectDistance = 0.1;
- resetValues = TRUE;
+ resetValuesLow = TRUE;
+ } else if (connectDistance > 1.0) {
+ connectDistance = 1.0;
+ resetValuesHigh = TRUE;
}
if (minLength < 0.1) {
minLength = 0.1;
- resetValues = TRUE;
+ resetValuesLow = TRUE;
+ } else if (minLength > 1.0) {
+ minLength = 1.0;
+ resetValuesHigh = TRUE;
}
- if ( resetValues ) {
+ if ( resetValuesLow ) {
NoticeMessage2( 0, MSG_CONN_PARAMS_TOO_SMALL, _("Ok"), NULL ) ;
}
+ if ( resetValuesHigh ) {
+ NoticeMessage2( 0, MSG_CONN_PARAMS_TOO_BIG, _("Ok"), NULL ) ;
+ }
+
wHide( prefW );
DoChangeNotification(changes);