summaryrefslogtreecommitdiff
path: root/app/bin/misc.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/misc.c
parent16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff)
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/bin/misc.c')
-rw-r--r--app/bin/misc.c375
1 files changed, 227 insertions, 148 deletions
diff --git a/app/bin/misc.c b/app/bin/misc.c
index b506f98..0422631 100644
--- a/app/bin/misc.c
+++ b/app/bin/misc.c
@@ -45,20 +45,27 @@
#else
#include <sys/stat.h>
#endif
+#include <locale.h>
#include <stdarg.h>
-
#include <stdint.h>
-#include "track.h"
+#include "cjoin.h"
#include "common.h"
-#include "utility.h"
+#include "compound.h"
+#include "cselect.h"
+#include "cundo.h"
+#include "custom.h"
#include "draw.h"
+#include "fileio.h"
+#include "i18n.h"
+#include "layout.h"
+#include "messages.h"
#include "misc.h"
-#include "cjoin.h"
-#include "compound.h"
+#include "param.h"
+#include "paths.h"
#include "smalldlg.h"
-#include "i18n.h"
-#include <locale.h>
+#include "track.h"
+#include "utility.h"
#define DEFAULT_SCALE ("N")
@@ -89,7 +96,7 @@ EXPORT wWin_p mainW;
EXPORT wIndex_t changed = 0;
-EXPORT char FAR message[STR_LONG_SIZE];
+EXPORT char message[STR_LONG_SIZE];
static char message2[STR_LONG_SIZE];
EXPORT REGION_T curRegion = 0;
@@ -107,6 +114,7 @@ EXPORT wButton_p redoB;
EXPORT wButton_p zoomUpB;
EXPORT wButton_p zoomDownB;
+wButton_p mapShowB;
EXPORT wIndex_t checkPtMark = 0;
@@ -286,6 +294,95 @@ EXPORT char * MyStrdup( const char * str )
return ret;
}
+/*
+ * Convert Text into the equivalent form that can be written to a file or put in a text box by adding escape characters
+ *
+ * The following special characters are produced -
+ * \n for LineFeed 0x0A
+ * \t for Tab 0x09
+ * "" for " This is so that a CSV conformant type program can interpret the file output
+ *
+ */
+EXPORT char * ConvertToEscapedText(const char * text) {
+ int text_i=0;
+ int add = 0; //extra chars for escape
+ while(text[text_i]) {
+ switch (text[text_i]) {
+ case '\n': add++; break;
+ case '\t': add++; break;
+ case '\\': add++; break;
+ case '\"': add++; break;
+ }
+ text_i++;
+ }
+ char * cout = MyMalloc(strlen(text)+1+add);
+ int cout_i = 0;
+ text_i = 0;
+ while(text[text_i]) {
+ char c = text[text_i];
+ switch (c) {
+ case '\n': cout[cout_i] = '\\'; cout_i++; cout[cout_i] = 'n'; cout_i++; break; // Line Feed
+ case '\t': cout[cout_i] = '\\'; cout_i++; cout[cout_i] = 't'; cout_i++; break; // Tab
+ case '\\': cout[cout_i] = '\\'; cout_i++; cout[cout_i] = '\\'; cout_i++; break; // BackSlash
+ case '\"': cout[cout_i] = '\"'; cout_i++; cout[cout_i] = '\"'; cout_i++; break; // Double Quotes
+ default: cout[cout_i] = c; cout_i++;
+ }
+ text_i++;
+ }
+ cout[cout_i] = '\0';
+ return cout;
+}
+
+/*
+ * Convert Text that has embedded escape characters into the equivalent form that can be shown on the screen
+ *
+ * The following special characters are supported -
+ * \n = LineFeed 0x0A
+ * \t = Tab 0x09
+ * \\ = \ The way to still produce backslash
+ * "" = " Take out quotes included so that other (CSV-like) programs could read the files
+ *
+ */
+EXPORT char * ConvertFromEscapedText(const char * text) {
+ enum { CHARACTER, ESCAPE, QUOTE } state = CHARACTER;
+ char * cout = MyMalloc(strlen(text)+1); //always equal to or shorter than
+ int text_i = 0;
+ int cout_i = 0;
+ int c;
+ while (text[text_i]) {
+ c = text[text_i];
+ switch (state) {
+ case CHARACTER:
+ if (c == '\\') {
+ state = ESCAPE;
+ } else if (c == '\"') {
+ state = QUOTE;
+ } else {
+ cout[cout_i] = c;
+ cout_i++;
+ }
+ break;
+
+ case ESCAPE:
+ switch (c) {
+ case '\\': cout[cout_i] = '\\'; cout_i++; break; // "\\" = "\"
+ case 'n': cout[cout_i] = '\n'; cout_i++; break; // LF
+ case 't': cout[cout_i] = '\t'; cout_i++; break; // TAB
+ }
+ state = CHARACTER;
+ break;
+ case QUOTE:
+ switch(c) {
+ case '\"': cout[cout_i] = c; cout_i++; break; //One quote = NULL, Two quotes = 1 quote
+ }
+ state = CHARACTER;
+ }
+ text_i++;
+ }
+ cout[cout_i] = '\0';
+ return cout;
+}
+
EXPORT void AbortProg(
char * msg,
@@ -482,7 +579,8 @@ static void ChkRevert( void )
_("&Revert"), _("&Cancel") );
if( rc ) {
/* load the file */
- LoadTracks( 1, &curFileName, NULL );
+ char *filename = GetLayoutFullPath();
+ LoadTracks( 1, &filename, NULL );
}
}
}
@@ -518,7 +616,7 @@ EXPORT void SaveState( void )
RememberParamFiles();
ParamUpdatePrefs();
- wPrefSetString( "misc", "lastlayout", curPathName );
+ wPrefSetString( "misc", "lastlayout", GetLayoutFullPath());
if ( fileList_ml ) {
strcpy( file, "file" );
@@ -537,17 +635,14 @@ EXPORT void SaveState( void )
}
/*
- * Clean up befor quitting
+ * Clean up before quitting
*/
-static int quitting;
static void DoQuitAfter( void )
{
changed = 0;
SaveState();
CleanupFiles();
-
- quitting = TRUE;
}
/**
* Process shutdown request. This function is called when the user requests
@@ -557,28 +652,26 @@ static void DoQuitAfter( void )
void DoQuit( void )
{
Confirm(_("Quit"), DoQuitAfter );
- if ( quitting ) {
#ifdef CHECK_UNUSED_BALLOONHELP
- ShowUnusedBalloonHelp();
+ ShowUnusedBalloonHelp();
#endif
- LogClose();
- wExit(0);
- }
+ LogClose();
+ wExit(0);
}
static void DoClearAfter( void )
{
+
ClearTracks();
/* set all layers to their default properties and set current layer to 0 */
DefaultLayerProperties();
-
+ DoLayout(NULL);
checkPtMark = 0;
Reset();
DoChangeNotification( CHANGE_MAIN|CHANGE_MAP );
EnableCommands();
- curPathName[0] = '\0';
- curFileName = curPathName;
+ SetLayoutFullPath("");
SetWindowTitle();
}
@@ -591,24 +684,29 @@ static void DoClear( void )
* Toggle visibility state of map window.
*/
-void MapWindowToggleShow( void )
+void MapWindowToggleShow(void)
{
- MapWindowShow( !mapVisible );
+ MapWindowShow(!mapVisible);
}
/**
* Set visibility state of map window.
+ *
+ * \param state IN TRUE if visible, FALSE if hidden
*/
-void MapWindowShow( int state )
+void MapWindowShow(int state)
{
- mapVisible = state;
- wPrefSetInteger( "misc", "mapVisible", mapVisible );
- wMenuToggleSet( mapShowMI, mapVisible );
- if( mapVisible )
- DoChangeNotification( CHANGE_MAP );
+ mapVisible = state;
+ wPrefSetInteger("misc", "mapVisible", mapVisible);
+ wMenuToggleSet(mapShowMI, mapVisible);
- wWinShow( mapW, mapVisible );
+ if (mapVisible) {
+ DoChangeNotification(CHANGE_MAP);
+ }
+
+ wWinShow(mapW, mapVisible);
+ wButtonSetBusy(mapShowB, (wBool_t)mapVisible);
}
static void DoShowWindow(
@@ -619,6 +717,7 @@ static void DoShowWindow(
if (data == mapW) {
if (mapVisible == FALSE) {
MapWindowShow( TRUE );
+ return;
}
}
wWinShow( (wWin_p)data, TRUE );
@@ -717,25 +816,6 @@ EXPORT void SelectFont( void )
#define BUTTON_MAX (170)
#define NUM_CMDMENUS (4)
-#ifdef LATER
-static struct {
- addButtonCallBack_t actionProc;
- procCommand_t cmdProc;
- char * helpStr;
- wControl_p control;
- char * labelStr;
- int reqLevel;
- wBool_t enabled;
- wPos_t x, y;
- long options;
- long stickyMask;
- int group;
- long acclKey;
- wMenuPush_p menu[NUM_CMDMENUS];
- void * context;
- } commandList[COMMAND_MAX];
-#endif
-
static struct {
wControl_p control;
wBool_t enabled;
@@ -873,6 +953,7 @@ LOG( log_command, 2, ( "COMMAND CANCEL %s\n", commandList[curCommand].helpKey )
checkPtMark = changed;
}
MainRedraw();
+ MapRedraw();
EnableCommands();
ResetMouseState();
LOG( log_command, 1, ( "COMMAND RESET %s\n", commandList[curCommand].helpKey ) )
@@ -1011,7 +1092,10 @@ LOG( log_command, 4, ( " COMMAND returns %d\n", rc ) )
(commandList[curCommand].stickyMask & stickySet) ) {
tempSegs_da.cnt = 0;
UpdateAllElevations();
- MainRedraw();
+ if (action != C_REDRAW) {
+ MainRedraw();
+ MapRedraw();
+ }
if (commandList[curCommand].options & IC_NORESTART) {
return C_CONTINUE;
}
@@ -1197,7 +1281,7 @@ EXPORT void LayoutSetPos(
lastGroup = 0;
wWinGetSize( mainW, &width, &h );
gap = 5;
- toolbarWidth = width+5;
+ toolbarWidth = width-20+5;
layerButtCnt = 0;
toolbarHeight = 0;
}
@@ -1224,7 +1308,7 @@ EXPORT void LayoutSetPos(
h = wControlGetHeight( buttonList[inx].control );
if ( inx<buttonCnt-1 && (buttonList[inx+1].options&IC_ABUT) )
w += wControlGetWidth( buttonList[inx+1].control );
- if (toolbarWidth+w>width) {
+ if (toolbarWidth+w>width-20) {
toolbarWidth = 0;
toolbarHeight += h + 5;
}
@@ -1405,74 +1489,6 @@ EXPORT void ButtonGroupEnd( void )
}
-#ifdef LATER
-EXPORT wIndex_t AddCommandControl(
- procCommand_t command,
- char * helpKey,
- char * nameStr,
- wControl_p control,
- int reqLevel,
- long options,
- long acclKey,
- void * context )
-{
- wIndex_t buttInx = -1;
- wIndex_t cmdInx;
- BOOL_T newButtonGroup = FALSE;
- wMenu_p tm, p1m, p2m;
- static wIcon_p openbuttIcon = NULL;
- static wMenu_p commandsSubmenu;
- static wMenu_p popup1Submenu;
- static wMenu_p popup2Submenu;
-
- AddToolbarControl( control, options );
-
- buttonList[buttInx].cmdInx = commandCnt;
- cmdInx = AddCommand( command, helpKey, nameStr, NULL, reqLevel, options, acclKey, context );
- commandList[cmdInx].buttInx = buttInx;
- if (nameStr[0] == '\0')
- return cmdInx;
- if (commandList[cmdInx].options&IC_STICKY) {
- if ( buttonGroupPopupM==NULL || newButtonGroup ) {
- if ( stickyCnt > 32 )
- AbortProg( "stickyCnt>32" );
- stickyCnt++;
- }
- if ( buttonGroupPopupM==NULL) {
- stickyLabels[stickyCnt-1] = nameStr;
- } else {
- stickyLabels[stickyCnt-1] = buttonGroupStickyLabel;
- }
- stickyLabels[stickyCnt] = NULL;
- commandList[cmdInx].stickyMask = 1L<<(stickyCnt-1);
- }
- if ( buttonGroupPopupM ) {
- commandList[cmdInx].menu[0] =
- wMenuPushCreate( buttonGroupPopupM, helpKey, GetBalloonHelpStr(helpKey), 0, DoCommandB, (void*)cmdInx );
- tm = commandsSubmenu;
- p1m = popup1Submenu;
- p2m = popup2Submenu;
- } else {
- tm = commandsM;
- p1m = (options&IC_POPUP2)?popup1aM:popup1M;
- p2m = (options&IC_POPUP2)?popup2aM:popup2M;
- }
- commandList[cmdInx].menu[1] =
- wMenuPushCreate( tm, helpKey, nameStr, acclKey, DoCommandB, (void*)cmdInx );
- if ( (options & (IC_POPUP|IC_POPUP2)) ) {
- if ( !(options & IC_SELECTED) ) {
- commandList[cmdInx].menu[2] =
- wMenuPushCreate( p1m, helpKey, nameStr, 0, DoCommandB, (void*)cmdInx );
- }
- commandList[cmdInx].menu[3] =
- wMenuPushCreate( p2m, helpKey, nameStr, 0, DoCommandB, (void*)cmdInx );
- }
-
- return cmdInx;
-}
-#endif
-
-
EXPORT wIndex_t AddMenuButton(
wMenu_p menu,
procCommand_t command,
@@ -1730,7 +1746,7 @@ static char *AllToolbarLabels[] = {
N_("Create Track Buttons"),
N_("Layout Control Elements"),
N_("Modify Track Buttons"),
- N_("Describe/Select"),
+ N_("Properties/Select"),
N_("Track Group Buttons"),
N_("Train Group Buttons"),
N_("Create Misc Buttons"),
@@ -1826,15 +1842,26 @@ static void ShowAddElevations( void )
/*--------------------------------------------------------------------*/
static wWin_p rotateW;
+static wWin_p moveW;
static long rotateValue;
+static coOrd moveValue;
static rotateDialogCallBack_t rotateDialogCallBack;
+static moveDialogCallBack_t moveDialogCallBack;
static void RotateEnterOk( void * );
+
static paramIntegerRange_t rn360_360 = { -360, 360, 80 };
static paramData_t rotatePLs[] = {
{ PD_LONG, &rotateValue, "rotate", PDO_ANGLE, &rn360_360, N_("Angle:") } };
static paramGroup_t rotatePG = { "rotate", 0, rotatePLs, sizeof rotatePLs/sizeof rotatePLs[0] };
+static paramFloatRange_t r_1000_1000 = { -1000.0, 1000.0, 80 };
+static void MoveEnterOk( void * );
+static paramData_t movePLs[] = {
+ { PD_FLOAT, &moveValue.x, "moveX", PDO_DIM, &r_1000_1000, N_("Move X:") },
+ { PD_FLOAT, &moveValue.y, "moveY", PDO_DIM, &r_1000_1000, N_("Move Y:") } };
+static paramGroup_t movePG = { "move", 0, movePLs, sizeof movePLs/sizeof movePLs[0] };
+
EXPORT void StartRotateDialog( rotateDialogCallBack_t func )
{
@@ -1845,6 +1872,22 @@ EXPORT void StartRotateDialog( rotateDialogCallBack_t func )
wShow( rotateW );
}
+EXPORT void StartMoveDialog( moveDialogCallBack_t func )
+{
+ if ( moveW == NULL )
+ moveW = ParamCreateDialog( &movePG, MakeWindowTitle(_("Move")), _("Ok"), MoveEnterOk, wHide, FALSE, NULL, 0, NULL );
+ ParamLoadControls( &movePG );
+ moveDialogCallBack = func;
+ moveValue = zero;
+ wShow( moveW );
+}
+
+static void MoveEnterOk( void * junk )
+{
+ ParamLoadData( &movePG );
+ moveDialogCallBack( (void*) &moveValue );
+ wHide( moveW );
+}
static void RotateEnterOk( void * junk )
{
@@ -1862,6 +1905,17 @@ static void RotateDialogInit( void )
ParamRegister( &rotatePG );
}
+static void MoveDialogInit (void)
+{
+ ParamRegister( &movePG );
+}
+
+
+EXPORT void AddMoveMenu(
+ wMenu_p m,
+ moveDialogCallBack_t func ) {
+ wMenuPushCreate( m, "", _("Enter Move ..."), 0, (wMenuCallBack_p)StartMoveDialog, (void*)func );
+}
EXPORT void AddRotateMenu(
wMenu_p m,
@@ -1904,6 +1958,7 @@ static void CreateDebugW( void )
debugPG.paramCnt = debugCnt;
ParamRegister( &debugPG );
debugW = ParamCreateDialog( &debugPG, MakeWindowTitle(_("Debug")), _("Ok"), DebugOk, NULL, FALSE, NULL, 0, NULL );
+ wHide(debugW);
}
@@ -1974,7 +2029,9 @@ static char * accelKeyNames[] = {
"F9",
"F10",
"F11",
- "F12" };
+ "F12",
+ "NumpadAdd",
+ "NumpadSub"};
static void SetAccelKey(
char * prefName,
@@ -2020,12 +2077,12 @@ static void SetAccelKey(
#include "bitmaps/document-save.xpm"
#include "bitmaps/document-open.xpm"
#include "bitmaps/document-print.xpm"
+#include "bitmaps/map.xpm"
static void CreateMenus( void )
{
wMenu_p fileM, editM, viewM, optionM, windowM, macroM, helpM, toolbarM, messageListM, manageM, addM, changeM, drawM;
wMenu_p zoomM, zoomSubM;
-// wIcon_p bm_p;
wMenuPush_p zoomInM, zoomOutM;
@@ -2055,10 +2112,13 @@ static void CreateMenus( void )
wMenuPushCreate( popup2M, "cmdZoomOut", _("Zoom Out"), 0, (wMenuCallBack_p)DoZoomDown, (void*)1 );
MiscMenuItemCreate( popup1M, popup2M, "cmdGridEnable", _("SnapGrid Enable"), 0, (void*)(wMenuCallBack_p)SnapGridEnable, 0, (void *)0 );
MiscMenuItemCreate( popup1M, popup2M, "cmdGridShow", _("SnapGrid Show"), 0, (void*)(wMenuCallBack_p)SnapGridShow, 0, (void *)0 );
+ MiscMenuItemCreate( popup1M, popup2M, "cmdMapShow", _("Show/Hide Map"), 0, (void*)(wMenuCallBack_p)MapWindowToggleShow, 0, (void *)0);
wMenuSeparatorCreate( popup1M );
wMenuSeparatorCreate( popup2M );
MiscMenuItemCreate( popup2M, NULL, "cmdCopy", _("Copy"), 0, (void*)(wMenuCallBack_p)EditCopy, 0, (void *)0 );
MiscMenuItemCreate( popup1M, popup2M, "cmdPaste", _("Paste"), 0, (void*)(wMenuCallBack_p)EditPaste, 0, (void *)0 );
+ MiscMenuItemCreate( popup1M, popup2M, "cmdSelectAll", _("Select All"), 0, (void*)(wMenuCallBack_p)SetAllTrackSelect, 0, (void *)1 );
+ MiscMenuItemCreate( popup1M, popup2M, "cmdSelectCurrentLayer", _("Select Current Layer"), 0, (void*)(wMenuCallBack_p)SelectCurrentLayer, 0, (void *)0 );
MiscMenuItemCreate( popup2M, NULL, "cmdDeselectAll", _("Deselect All"), 0, (void*)(wMenuCallBack_p)SetAllTrackSelect, 0, (void *)0 );
wMenuPushCreate( popup2M, "cmdMove", _("Move"), 0, (wMenuCallBack_p)DoCommandBIndirect, &moveCmdInx );
wMenuPushCreate( popup2M, "cmdRotate", _("Rotate"), 0, (wMenuCallBack_p)DoCommandBIndirect, &rotateCmdInx );
@@ -2074,7 +2134,6 @@ static void CreateMenus( void )
AddToolbarButton( "menuFile-clear", wIconCreatePixMap(document_new), IC_MODETRAIN_TOO, (addButtonCallBack_t)DoClear, NULL );
AddToolbarButton( "menuFile-load", wIconCreatePixMap(document_open), IC_MODETRAIN_TOO, (addButtonCallBack_t)ChkLoad, NULL );
AddToolbarButton( "menuFile-save", wIconCreatePixMap(document_save), IC_MODETRAIN_TOO, (addButtonCallBack_t)DoSave, NULL );
-// AddToolbarButton( "menuFile-print", wIconCreatePixMap(document_print_xpm), IC_MODETRAIN_TOO, (addButtonCallBack_t)DoPrint, NULL );
cmdGroup = BG_ZOOM;
zoomUpB = AddToolbarButton( "cmdZoomIn", wIconCreatePixMap(zoomin_xpm), IC_MODETRAIN_TOO,
@@ -2097,7 +2156,7 @@ static void CreateMenus( void )
/*
* FILE MENU
*/
- MiscMenuItemCreate( fileM, NULL, "menuFile-clear", _("&New"), ACCL_NEW, (void*)(wMenuCallBack_p)DoClear, 0, (void *)0 );
+ MiscMenuItemCreate( fileM, NULL, "menuFile-clear", _("&New ..."), ACCL_NEW, (void*)(wMenuCallBack_p)DoClear, 0, (void *)0 );
wMenuPushCreate( fileM, "menuFile-load", _("&Open ..."), ACCL_OPEN, (wMenuCallBack_p)ChkLoad, NULL );
wMenuSeparatorCreate( fileM );
@@ -2179,8 +2238,10 @@ static void CreateMenus( void )
// visibility toggle for map window
// get the start value
- wPrefGetInteger( "misc", "mapVisible", (long *)&mapVisible, 1 );
- mapShowMI = wMenuToggleCreate( viewM, "cmdMapShow", _("Show Map"), ACCL_MAPSHOW,
+ long mapVisible_long;
+ wPrefGetInteger( "misc", "mapVisible", (long *)&mapVisible_long, 1 );
+ mapVisible = mapVisible_long?TRUE:FALSE;
+ mapShowMI = wMenuToggleCreate( viewM, "cmdMapShow", _("Show/Hide Map"), ACCL_MAPSHOW,
mapVisible, (wMenuToggleCallBack_p)MapWindowToggleShow, NULL );
wMenuSeparatorCreate( viewM );
@@ -2193,6 +2254,10 @@ static void CreateMenus( void )
cmdGroup = BG_SNAP;
InitSnapGridButtons();
+ mapShowB = AddToolbarButton("cmdMapShow", wIconCreatePixMap(map_xpm), IC_MODETRAIN_TOO,
+ (addButtonCallBack_t)MapWindowToggleShow, NULL);
+ wControlLinkedSet((wControl_p)mapShowMI, (wControl_p)mapShowB);
+ wButtonSetBusy(mapShowB, (wBool_t)mapVisible);
/*
* ADD MENU
@@ -2221,6 +2286,7 @@ static void CreateMenus( void )
cmdGroup = BG_SELECT;
InitCmdDescribe( changeM );
InitCmdSelect( changeM );
+ InitCmdPan( changeM );
wMenuSeparatorCreate( changeM );
cmdGroup = BG_TRKGRP;
@@ -2324,7 +2390,7 @@ static void CreateMenus( void )
InitNewTurn( wMenuMenuCreate( manageM, "cmdTurnoutNew", _("Tur&nout Designer...") ) );
- MiscMenuItemCreate( manageM, NULL, "smdContmgm", _("Layout &Control Elements"), ACCL_CONTMGM,(void*)ControlMgrInit(),0,(void*) 0);
+ MiscMenuItemCreate( manageM, NULL, "cmdContmgm", _("Layout &Control Elements"), ACCL_CONTMGM,(void*)ControlMgrInit(),0,(void*) 0);
MiscMenuItemCreate( manageM, NULL, "cmdGroup", _("&Group"), ACCL_GROUP, (void*)(wMenuCallBack_p)DoGroup, IC_SELECTED, (void *)0 );
MiscMenuItemCreate( manageM, NULL, "cmdUngroup", _("&Ungroup"), ACCL_UNGROUP, (void*)(wMenuCallBack_p)DoUngroup, IC_SELECTED, (void *)0 );
@@ -2361,13 +2427,15 @@ static void CreateMenus( void )
#endif
SetAccelKey( "zoomUp", wAccelKey_Pgdn, 0, (wAccelKeyCallBack_p)DoZoomUp, (void*)1 );
SetAccelKey( "zoomDown", wAccelKey_Pgup, 0, (wAccelKeyCallBack_p)DoZoomDown, (void*)1 );
- SetAccelKey( "redraw", wAccelKey_F5, 0, (wAccelKeyCallBack_p)MainRedraw, (void*)1 );
+ SetAccelKey( "redraw", wAccelKey_F5, 0, (wAccelKeyCallBack_p)MainRedraw, (void*)1 );
SetAccelKey( "delete", wAccelKey_Del, 0, (wAccelKeyCallBack_p)SelectDelete, (void*)1 );
SetAccelKey( "copy", wAccelKey_Ins, WKEY_CTRL, (wAccelKeyCallBack_p)EditCopy, 0 );
SetAccelKey( "paste", wAccelKey_Ins, WKEY_SHIFT, (wAccelKeyCallBack_p)EditPaste, 0 );
SetAccelKey( "undo", wAccelKey_Back, WKEY_SHIFT, (wAccelKeyCallBack_p)UndoUndo, 0 );
SetAccelKey( "cut", wAccelKey_Del, WKEY_SHIFT, (wAccelKeyCallBack_p)EditCut, 0 );
SetAccelKey( "nextWindow", wAccelKey_F6, 0, (wAccelKeyCallBack_p)NextWindow, 0 );
+ SetAccelKey( "zoomUp", wAccelKey_Numpad_Add, WKEY_CTRL, (wAccelKeyCallBack_p)DoZoomUp, (void*)1 );
+ SetAccelKey( "zoomDown", wAccelKey_Numpad_Subtract, WKEY_CTRL, (wAccelKeyCallBack_p)DoZoomDown, (void*)1 );
InitBenchDialog();
}
@@ -2386,9 +2454,9 @@ static void LoadFileList( void )
if (!cp)
continue;
pathName = MyStrdup(cp);
- fileName = strrchr( pathName, FILE_SEP_CHAR[0] );
+ fileName = FindFilename((char *)pathName);
if (fileName)
- wMenuListAdd( fileList_ml, 0, fileName+1, pathName );
+ wMenuListAdd( fileList_ml, 0, fileName, pathName );
}
}
@@ -2408,13 +2476,13 @@ EXPORT void InitCmdExport( void )
* the option to load the checkpoint file to continue working after a crash.
*
* \param none
- * \return none
+ * \return TRUE for resume, FALSE otherwise
*
*/
-static void OfferCheckpoint( void )
+static int OfferCheckpoint( void )
{
- int ret;
+ int ret = FALSE;
/* sProdName */
ret = wNoticeEx( NT_INFORMATION,
@@ -2423,8 +2491,9 @@ static void OfferCheckpoint( void )
if( ret ) {
/* load the checkpoint file */
LoadCheckpoint();
+ ret = TRUE;
}
-
+ return ret;
}
@@ -2433,6 +2502,7 @@ EXPORT wWin_p wMain(
char * argv[] )
{
int c;
+ int resumeWork;
char * logFileName = NULL;
int log_init = 0;
int initialZoom = 0;
@@ -2445,6 +2515,8 @@ EXPORT wWin_p wMain(
char *oldLocale = NULL;
char buffer[ STR_SIZE ];
unsigned int i;
+ wPos_t displayWidth;
+ wPos_t displayHeight;
strcpy( buffer, sProdNameLower );
@@ -2527,15 +2599,19 @@ LOG1( log_init, ( "initCustom\n" ) )
* MAIN WINDOW
*/
LOG1( log_init, ( "create main window\n" ) )
- strcpy( Title1, sProdName );
+ SetLayoutTitle( sProdName );
sprintf( message, _("Unnamed Trackplan - %s(%s)"), sProdName, sVersion );
wSetBalloonHelp( balloonHelp );
- mainW = wWinMainCreate( buffer, 600, 350, "xtrkcadW", message, "main",
+
+ wGetDisplaySize(&displayWidth, &displayHeight);
+ mainW = wWinMainCreate( buffer, (displayWidth*2)/3, (displayHeight*2)/3, "xtrkcadW", message, "main",
F_RESIZE|F_MENUBAR|F_NOTAB|F_RECALLPOS|F_HIDE,
MainProc, NULL );
if ( mainW == NULL )
return NULL;
+ InitAppDefaults();
+
drawColorBlack = wDrawFindColor( wRGB( 0, 0, 0) );
drawColorWhite = wDrawFindColor( wRGB(255,255,255) );
drawColorRed = wDrawFindColor( wRGB(255, 0, 0) );
@@ -2593,6 +2669,7 @@ LOG1( log_init, ( "misc2Init\n" ) )
Misc2Init();
RotateDialogInit();
+ MoveDialogInit();
wSetSplashInfo( _("Initializing commands") );
LOG1( log_init, ( "paramInit\n" ) )
@@ -2687,19 +2764,21 @@ LOG1( log_init, ( "Initialization complete\n" ) )
ShowTip(SHOWTIP_NEXTTIP);
- /* if work is to be resumed and no filename was given on startup, load last layout */
- if( (onStartup == 0) && (!initialFile || !strlen(initialFile))) {
- initialFile = (char*)wPrefGetString( "misc", "lastlayout" );
- }
-
- if (initialFile && strlen(initialFile)) {
- DoFileList( 0, NULL, initialFile );
- }
-
/* check for existing checkpoint file */
+ resumeWork = FALSE;
if (ExistsCheckpoint())
- OfferCheckpoint();
+ resumeWork = OfferCheckpoint();
+ if (!resumeWork) {
+ /* if work is to be resumed and no filename was given on startup, load last layout */
+ if ((onStartup == 0) && (!initialFile || !strlen(initialFile))) {
+ initialFile = (char*)wPrefGetString("misc", "lastlayout");
+ }
+
+ if (initialFile && strlen(initialFile)) {
+ DoFileList(0, NULL, initialFile);
+ }
+ }
inMainW = FALSE;
return mainW;
}