diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-02-06 16:04:57 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-02-06 16:04:57 +0100 |
commit | 59dccf358523dfc7679d1d8c120452a71e42243c (patch) | |
tree | f0f3cc006e8157d6bd699bd644b7dd7b35387ac2 /app/bin/misc.c | |
parent | fd6639655b399a79fb72f494786a4f57da9c90e7 (diff) | |
parent | d0ca838c7ab297036b4a7c45351761a48fe05efd (diff) |
Merge branch 'feature/upstrem' into develop
Diffstat (limited to 'app/bin/misc.c')
-rw-r--r-- | app/bin/misc.c | 1270 |
1 files changed, 746 insertions, 524 deletions
diff --git a/app/bin/misc.c b/app/bin/misc.c index 2ac1e2f..e976481 100644 --- a/app/bin/misc.c +++ b/app/bin/misc.c @@ -20,34 +20,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <stdlib.h> -#include <stdio.h> -#ifndef WINDOWS -#include <unistd.h> -#include <dirent.h> -#endif -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif -#include <math.h> -#include <ctype.h> -#include <string.h> -#include <time.h> -#ifdef WINDOWS -#include <io.h> -#include <windows.h> -#include "getopt.h" -#define R_OK (02) -#define access _access -#if _MSC_VER >1300 -#define strdup _strdup -#endif -#else -#include <sys/stat.h> -#endif -#include <locale.h> -#include <stdarg.h> -#include <stdint.h> + #include "cjoin.h" #include "common.h" @@ -57,20 +30,22 @@ #include "custom.h" #include "draw.h" #include "fileio.h" -#include "i18n.h" #include "layout.h" -#include "messages.h" #include "misc.h" #include "param.h" #include "include/paramfilelist.h" #include "paths.h" #include "smalldlg.h" #include "track.h" -#include "utility.h" +#include "common-ui.h" +#include "ctrain.h" + +#include <inttypes.h> + +#include <stdint.h> #define DEFAULT_SCALE ("N") -char *userLocale = NULL; extern wBalloonHelp_t balloonHelp[]; @@ -84,7 +59,6 @@ static wMenuToggle_p magnetsMI; #ifdef CHECK_UNUSED_BALLOONHELP static void ShowUnusedBalloonHelp(void); #endif -void DoCarDlg(void); /**************************************************************************** * @@ -92,6 +66,8 @@ void DoCarDlg(void); * */ +EXPORT int iconSize = 0; + EXPORT int foobar = 0; EXPORT int log_error; @@ -99,8 +75,6 @@ static int log_command; EXPORT wWin_p mainW; -EXPORT wIndex_t changed = 0; - EXPORT char message[STR_HUGE_SIZE]; static char message2[STR_LONG_SIZE]; @@ -119,6 +93,7 @@ EXPORT wButton_p redoB; EXPORT wButton_p zoomUpB; EXPORT wButton_p zoomDownB; +EXPORT wButton_p zoomExtentsB; wButton_p mapShowB; wButton_p magnetsB; wButton_p backgroundB; @@ -143,17 +118,17 @@ EXPORT DIST_T easeR = 0.0; EXPORT DIST_T easeL = 0.0; EXPORT coOrd cmdMenuPos; -EXPORT wPos_t DlgSepLeft = 12; -EXPORT wPos_t DlgSepMid = 18; -EXPORT wPos_t DlgSepRight = 12; -EXPORT wPos_t DlgSepTop = 12; -EXPORT wPos_t DlgSepBottom = 12; -EXPORT wPos_t DlgSepNarrow = 6; -EXPORT wPos_t DlgSepWide = 12; -EXPORT wPos_t DlgSepFrmLeft = 4; -EXPORT wPos_t DlgSepFrmRight = 4; -EXPORT wPos_t DlgSepFrmTop = 4; -EXPORT wPos_t DlgSepFrmBottom = 4; +EXPORT wWinPix_t DlgSepLeft = 12; +EXPORT wWinPix_t DlgSepMid = 18; +EXPORT wWinPix_t DlgSepRight = 12; +EXPORT wWinPix_t DlgSepTop = 12; +EXPORT wWinPix_t DlgSepBottom = 12; +EXPORT wWinPix_t DlgSepNarrow = 6; +EXPORT wWinPix_t DlgSepWide = 12; +EXPORT wWinPix_t DlgSepFrmLeft = 4; +EXPORT wWinPix_t DlgSepFrmRight = 4; +EXPORT wWinPix_t DlgSepFrmTop = 4; +EXPORT wWinPix_t DlgSepFrmBottom = 4; static int verbose = 0; @@ -162,11 +137,11 @@ static BOOL_T inMainW = TRUE; static long stickySet = 0; static long stickyCnt = 0; -static char * stickyLabels[33]; +static const char * stickyLabels[33]; #define TOOLBARSET_INIT (0xFFFF) EXPORT long toolbarSet = TOOLBARSET_INIT; -EXPORT wPos_t toolbarHeight = 0; -static wPos_t toolbarWidth = 0; +EXPORT wWinPix_t toolbarHeight = 0; +static wWinPix_t toolbarWidth = 0; static wMenuList_p messageList_ml; static BOOL_T messageListEmpty = TRUE; @@ -189,53 +164,121 @@ extern wBool_t wDrawDoTempDraw; * */ -EXPORT long totalMallocs = 0; -EXPORT long totalMalloced = 0; -EXPORT long totalRealloced = 0; -EXPORT long totalReallocs = 0; -EXPORT long totalFreeed = 0; -EXPORT long totalFrees = 0; +EXPORT size_t totalMallocs = 0; +EXPORT size_t totalMalloced = 0; +EXPORT size_t totalRealloced = 0; +EXPORT size_t totalReallocs = 0; +EXPORT size_t totalFreeed = 0; +EXPORT size_t totalFrees = 0; + +static void * StorageLog; + +typedef struct slog_t { + void * storage_p; + size_t storage_size; + BOOL_T freed; +} slog_t, * slog_p; + +static int StorageLogCurrent = 0; + + +#define LOG_SIZE 1000000 + static unsigned long guard0 = 0xDEADBEEF; static unsigned long guard1 = 0xAF00BA8A; static int log_malloc; -EXPORT void * MyMalloc(long size) { +static void RecordMalloc(void * p, size_t size) { + + + if (!StorageLog) StorageLog = malloc(sizeof(slog_t)*LOG_SIZE); + slog_p log_p = StorageLog; + if (StorageLogCurrent<LOG_SIZE) { + log_p[StorageLogCurrent].storage_p = p; + log_p[StorageLogCurrent].storage_size = size; + StorageLogCurrent++; + } else { + printf("Storage Log size exceeded, wrapped\n"); + log_p[0].storage_p = p; + log_p[0].storage_size = size; + StorageLogCurrent = 1; + } +} + +static void RecordMyFree(void *p) { + slog_p log_p = StorageLog; + if (log_p) { + for (int i=0;i<StorageLogCurrent;i++) { + if (!log_p[i].freed && log_p[i].storage_p == p) { + log_p[i].freed = TRUE; + } + } + } +} + +#define SLOG_FMT "0x%.12" PRIxPTR + +EXPORT BOOL_T TestMallocs() { + size_t oldSize; + size_t testedMallocs = 0; + void * old; + slog_p log_p = StorageLog; + BOOL_T rc = TRUE; + if (log_p) { + for (int i=0;i<StorageLogCurrent;i++) { + if (log_p[i].freed) continue; + old = log_p[i].storage_p; + oldSize = log_p[i].storage_size; + if (*(unsigned long*) ((char*) old - sizeof(unsigned long)) != guard0) { + LogPrintf("Guard 0 hosed, " SLOG_FMT " size: %llu \n", (uintptr_t)old, oldSize); + rc = FALSE; + } + if (*(unsigned long*) ((char*) old + oldSize) != guard1) { + LogPrintf("Guard 1 hosed, " SLOG_FMT " size: %llu \n", (uintptr_t)old, oldSize); + rc = FALSE; + } + testedMallocs++; + } + } + LogPrintf("Tested: %llu Mallocs: %llu Total Malloced: %llu Freed: %llu Total Freed: %llu \n", + testedMallocs, totalMallocs, totalMalloced, totalFrees, totalFreeed); + return rc; +} + + +EXPORT void * MyMalloc(size_t size) { void * p; totalMallocs++; totalMalloced += size; -#if defined(WINDOWS) && ! defined(WIN32) - if ( size > 65500L ) { - AbortProg( "mallocing > 65500 bytes" ); - } -#endif p = malloc((size_t) size + sizeof(size_t) + 2 * sizeof(unsigned long)); if (p == NULL) AbortProg("No memory"); LOG1(log_malloc, - ( "Malloc(%ld) = %lx (%lx-%lx)\n", size, (long)((char*)p+sizeof (size_t) + sizeof (unsigned long)), (long)p, (long)((char*)p+size+sizeof (size_t) + 2 * sizeof(unsigned long)) )); + ( " Malloc(%ld) = " SLOG_FMT " (" SLOG_FMT "-" SLOG_FMT ")\n", + size, (size_t)((char*)p+sizeof (size_t) + sizeof (unsigned long)), + (size_t)p, + (size_t)((char*)p+size+sizeof (size_t) + 2 * sizeof(unsigned long)))); + *(size_t*) p = (size_t) size; p = (char*) p + sizeof(size_t); *(unsigned long*) p = guard0; p = (char*) p + sizeof(unsigned long); *(unsigned long*) ((char*) p + size) = guard1; memset(p, 0, (size_t )size); + if (extraButtons) + RecordMalloc(p,size); return p; } -EXPORT void * MyRealloc(void * old, long size) { +EXPORT void * MyRealloc(void * old, size_t size) { size_t oldSize; void * new; if (old == NULL) return MyMalloc(size); totalReallocs++; totalRealloced += size; -#if defined(WINDOWS) && ! defined(WIN32) - if ( size > 65500L ) { - AbortProg( "reallocing > 65500 bytes" ); - } -#endif if (*(unsigned long*) ((char*) old - sizeof(unsigned long)) != guard0) { AbortProg("Guard0 is hosed"); } @@ -243,7 +286,9 @@ EXPORT void * MyRealloc(void * old, long size) { if (*(unsigned long*) ((char*) old + oldSize) != guard1) { AbortProg("Guard1 is hosed"); } - LOG1(log_malloc, ("Realloc(%lx,%ld) was %d\n", (long)old, size, oldSize )) + + LOG1(log_malloc, (" Realloc (" SLOG_FMT ",%ld) was %d\n", (size_t)old, size, oldSize )) + if ((long) oldSize == size) { return old; } @@ -271,10 +316,18 @@ EXPORT void MyFree(void * ptr) { if (*(unsigned long*) ((char*) ptr + oldSize) != guard1) { AbortProg("Guard1 is hosed"); } + LOG1(log_malloc, - ("Free %d at %lx (%lx-%lx)\n", oldSize, (long)ptr, (long)((char*)ptr-sizeof *(size_t*)0-sizeof *(long*)0), (long)((char*)ptr+oldSize+sizeof *(long*)0))) + (" Free %d at " SLOG_FMT " (" SLOG_FMT "-" SLOG_FMT ")\n", + oldSize, + (size_t)ptr, + (size_t)((char*)ptr-sizeof *(size_t*)0-sizeof *(long*)0), + (size_t)((char*)ptr+oldSize+sizeof *(long*)0))); + totalFreeed += oldSize; free((char*) ptr - sizeof *(long*) 0 - sizeof *(size_t*) 0); + if (extraButtons) + RecordMyFree(ptr); } } @@ -323,7 +376,7 @@ EXPORT char * ConvertToEscapedText(const char * text) { } text_i++; } - unsigned cnt = strlen(text) + 1 + add; + size_t cnt = strlen(text) + 1 + add; #ifdef WINDOWS cnt *= 2; #endif @@ -364,9 +417,9 @@ EXPORT char * ConvertToEscapedText(const char * text) { text_i++; } cout[cout_i] = '\0'; -#ifdef WINDOWS - wSystemToUTF8(cout, cout, cnt); -#endif // WINDOWS +#ifdef UTFCONVERT + wSystemToUTF8(cout, cout, (unsigned int)cnt); +#endif // UTFCONVERT return cout; } @@ -424,7 +477,7 @@ EXPORT char * ConvertFromEscapedText(const char * text) { return cout; } -EXPORT void AbortProg(char * msg, ...) { +EXPORT void AbortProg(const char * msg, ...) { static BOOL_T abort2 = FALSE; int rc; va_list ap; @@ -437,15 +490,15 @@ EXPORT void AbortProg(char * msg, ...) { strcat(message, _("\nDo you want to save your layout?")); rc = wNoticeEx( NT_ERROR, message, _("Ok"), _("ABORT")); if (rc) { - DoSaveAs((doSaveCallBack_p) abort); + DoSaveAs(abort); } else { abort(); } } } -EXPORT char * Strcpytrimed(char * dst, char * src, BOOL_T double_quotes) { - char * cp; +EXPORT char * Strcpytrimed(char * dst, const char * src, BOOL_T double_quotes) { + const char * cp; while (*src && isspace((unsigned char) *src)) src++; if (!*src) @@ -464,10 +517,6 @@ EXPORT char * Strcpytrimed(char * dst, char * src, BOOL_T double_quotes) { static char * directory; -#ifdef WINDOWS -#define F_OK (0) -#endif - EXPORT wBool_t CheckHelpTopicExists(const char * topic) { char * htmlFile; @@ -501,8 +550,8 @@ EXPORT wBool_t CheckHelpTopicExists(const char * topic) { } -EXPORT char * BuildTrimedTitle(char * cp, char * sep, char * mfg, char * desc, - char * partno) { +EXPORT char * BuildTrimedTitle(char * cp, const char * sep, const char * mfg, const char * desc, + const char * partno) { cp = Strcpytrimed(cp, mfg, FALSE); strcpy(cp, sep); cp += strlen(cp); @@ -529,7 +578,7 @@ static void ShowMessageHelp(int index, const char * label, void * data) { wHelp(msgKey); } -static char * ParseMessage(char *msgSrc) { +static const char * ParseMessage(const char *msgSrc) { char *cp1 = NULL, *cp2 = NULL; static char shortMsg[STR_SIZE]; cp1 = strchr(_(msgSrc), '\t'); @@ -556,11 +605,11 @@ static char * ParseMessage(char *msgSrc) { } } -EXPORT void InfoMessage(char * format, ...) { +EXPORT void InfoMessage(const char * format, ...) { va_list ap; va_start(ap, format); format = ParseMessage(format); - vsprintf(message2, format, ap); + vsnprintf(message2, 1020, format, ap); va_end(ap); /*InfoSubstituteControl( NULL, NULL );*/ if (inError) @@ -568,11 +617,11 @@ EXPORT void InfoMessage(char * format, ...) { SetMessage(message2); } -EXPORT void ErrorMessage(char * format, ...) { +EXPORT void ErrorMessage(const char * format, ...) { va_list ap; va_start(ap, format); format = ParseMessage(format); - vsprintf(message2, format, ap); + vsnprintf(message2, 1020, format, ap); va_end(ap); InfoSubstituteControls( NULL, NULL); SetMessage(message2); @@ -580,37 +629,27 @@ EXPORT void ErrorMessage(char * format, ...) { inError = TRUE; } -EXPORT int NoticeMessage(char * format, char * yes, char * no, ...) { +EXPORT int NoticeMessage(const char * format, const char * yes, const char * no, ...) { va_list ap; va_start(ap, no); format = ParseMessage(format); - vsprintf(message2, format, ap); + vsnprintf(message2, 1020, format, ap); va_end(ap); return wNotice(message2, yes, no); } -EXPORT int NoticeMessage2(int playbackRC, char * format, char * yes, char * no, +EXPORT int NoticeMessage2(int playbackRC, const char * format, const char * yes, const char * no, ...) { va_list ap; if (inPlayback) return playbackRC; va_start(ap, no); format = ParseMessage(format); - vsprintf(message2, format, ap); + vsnprintf(message2, 1020, format, ap); va_end(ap); return wNoticeEx( NT_INFORMATION, message2, yes, no); } -/** -* Set the file's changed flag and update the window title. -*/ - -void -FileIsChanged(void) -{ - changed++; - SetWindowTitle(); -} /***************************************************************************** * @@ -652,16 +691,16 @@ Confirm(char * label2, doSaveCallBack_p after) return(rc != 0); } -static void ChkLoad(void) { +static void ChkLoad(void * unused) { Confirm(_("Load"), DoLoad); } -static void ChkExamples( void ) +static void ChkExamples( void * unused ) { Confirm(_("examples"), DoExamples); } -static void ChkRevert(void) +static void ChkRevert(void * unused) { int rc; @@ -673,7 +712,7 @@ static void ChkRevert(void) if (rc) { /* load the file */ char *filename = GetLayoutFullPath(); - LoadTracks(1, &filename, NULL); + LoadTracks(1, &filename, I2VP(1)); //Keep background } } } @@ -693,15 +732,15 @@ static void ChkFileList(int index, const char * label, void * data) { */ EXPORT void SaveState(void) { - wPos_t width, height; + wWinPix_t width, height; const char * fileName; void * pathName; char file[6]; int inx; wWinGetSize(mainW, &width, &height); - wPrefSetInteger("draw", "mainwidth", width); - wPrefSetInteger("draw", "mainheight", height); + wPrefSetInteger("draw", "mainwidth", (int)width); + wPrefSetInteger("draw", "mainheight", (int)height); SaveParamFileList(); ParamUpdatePrefs(); @@ -720,8 +759,7 @@ EXPORT void SaveState(void) { } } } - wPrefFlush(); - LogClose(); + wPrefFlush(""); } /* @@ -729,16 +767,15 @@ EXPORT void SaveState(void) { */ static void DoQuitAfter(void) { changed = 0; + CleanupFiles(); //Get rid of checkpoint if we quit. SaveState(); - - CleanupFiles(); } /** * Process shutdown request. This function is called when the user requests * to close the application. Before shutting down confirmation is gotten to * prevent data loss. */ -void DoQuit(void) { +void DoQuit(void * unused) { if (Confirm(_("Quit"), DoQuitAfter)) { #ifdef CHECK_UNUSED_BALLOONHELP @@ -765,7 +802,7 @@ static void DoClearAfter(void) { LayoutBackGroundInit(TRUE); } -static void DoClear(void) { +static void DoClear(void * unused) { Confirm(_("Clear"), DoClearAfter); } @@ -773,7 +810,7 @@ static void DoClear(void) { * Toggle visibility state of map window. */ -void MapWindowToggleShow(void) { +void MapWindowToggleShow(void * unused) { MapWindowShow(!mapVisible); } @@ -812,7 +849,7 @@ int MagneticSnap(int state) /** * Toggle magnets on/off */ -void MagneticSnapToggle(void) { +void MagneticSnapToggle(void * unused) { MagneticSnap(!magneticSnap); } @@ -860,6 +897,7 @@ EXPORT void wHide(wWin_p win) { if (inMainW && win == aboutW) return; wMenuListDelete(winList_mi, wWinGetTitle(win)); + ParamResetInvalid( win ); if (inPlayback) for (inx = 0; inx < demoWindows_da.cnt; inx++) if ( demoWindows(inx) == win) @@ -890,7 +928,7 @@ EXPORT void DefaultProc(wWin_p win, winProcEvent e, void * data) { static void NextWindow(void) { } -EXPORT void SelectFont(void) { +EXPORT void SelectFont(void * unused) { wSelectFont(_("XTrackCAD Font")); } @@ -900,14 +938,14 @@ EXPORT void SelectFont(void) { * */ -#define COMMAND_MAX (170) -#define BUTTON_MAX (170) +#define COMMAND_MAX (180) +#define BUTTON_MAX (180) #define NUM_CMDMENUS (4) static struct { wControl_p control; wBool_t enabled; - wPos_t x, y; + wWinPix_t x, y; long options; int group; wIndex_t cmdInx; @@ -934,7 +972,7 @@ static int commandCnt = 0; int * balloonHelpCnts; #endif -EXPORT const char * GetBalloonHelpStr(char * helpKey) { +EXPORT const char * GetBalloonHelpStr(const char * helpKey) { wBalloonHelp_t * bh; #ifdef CHECK_UNUSED_BALLOONHELP if ( balloonHelpCnts == NULL ) { @@ -1032,6 +1070,26 @@ EXPORT wIndex_t GetCurrentCommand() { static wIndex_t autosave_count = 0; +EXPORT void TryCheckPoint() { + if (checkPtInterval > 0 + && changed >= checkPtMark + (wIndex_t) checkPtInterval + && !inPlayback) { + DoCheckPoint(); + checkPtMark = changed; + + autosave_count++; + + if ((autosaveChkPoints>0) && (autosave_count>=autosaveChkPoints)) { + if ( bReadOnly || *(GetLayoutFilename()) == '\0') { + SetAutoSave(); + } else + DoSave(NULL); + InfoMessage(_("File AutoSaved")); + autosave_count = 0; + } + } +} + EXPORT void Reset(void) { if (recordF) { fprintf(recordF, "RESET\n"); @@ -1052,22 +1110,8 @@ EXPORT void Reset(void) { (wButton_p) buttonList[commandList[curCommand].buttInx].control, TRUE); tempSegs_da.cnt = 0; - if (checkPtInterval > 0 - && changed >= checkPtMark + (wIndex_t) checkPtInterval - && !inPlayback) { - DoCheckPoint(); - checkPtMark = changed; - - autosave_count++; - - if ((autosaveChkPoints>0) && (autosave_count>=autosaveChkPoints)) { - DoSave(NULL); - InfoMessage(_("File AutoSaved")); - autosave_count = 0; - } - } - + TryCheckPoint(); ClrAllTrkBits( TB_UNDRAWN ); DoRedraw(); // Reset @@ -1238,8 +1282,11 @@ EXPORT wBool_t DoCurCommand(wAction_t action, coOrd pos) { if (commandList[curCommand].options & IC_NORESTART) { return C_CONTINUE; } + //Make sure we checkpoint even sticky commands + TryCheckPoint(); LOG(log_command, 1, ( "COMMAND START %s\n", commandList[curCommand].helpKey )) + wSetCursor(mainD.d,defaultCursor); rc = commandList[curCommand].cmdProc( C_START, pos); LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) switch (rc) { @@ -1261,9 +1308,12 @@ EXPORT wBool_t DoCurCommand(wAction_t action, coOrd pos) { return rc; } -EXPORT void ConfirmReset(BOOL_T retry) { +/* + * \parm reset says if the user used Esc rather than undo/redo + */ +EXPORT int ConfirmReset(BOOL_T retry) { wAction_t rc; - if (curCommand != describeCmdInx && curCommand != selectCmdInx) { + if (curCommand != describeCmdInx) { LOG(log_command, 3, ( "COMMAND CONFIRM %s\n", commandList[curCommand].helpKey )) rc = commandList[curCommand].cmdProc( C_CONFIRM, zero); @@ -1274,25 +1324,25 @@ EXPORT void ConfirmReset(BOOL_T retry) { wNotice3( _( "Cancelling the current command will undo the changes\n" - "you are currently making. Do you want to update?"), + "you are currently making. Do you want to do the update instead?"), _("Yes"), _("No"), _("Cancel")); else rc = wNoticeEx( NT_WARNING, _( "Cancelling the current command will undo the changes\n" - "you are currently making. Do you want to update?"), + "you are currently making. Do you want to do the update instead?"), _("Yes"), _("No")); if (rc == 1) { LOG(log_command, 3, ( "COMMAND OK %s\n", commandList[curCommand].helpKey )) commandList[curCommand].cmdProc( C_OK, zero); - return; + return C_OK; } else if (rc == -1) { - return; + return C_CANCEL; } } else if (rc == C_TERMINATE) { - return; + return C_TERMINATE; } } if (retry) { @@ -1303,6 +1353,7 @@ EXPORT void ConfirmReset(BOOL_T retry) { LOG(log_command, 1, ( "COMMAND RESET %s\n", commandList[curCommand].helpKey )) commandList[curCommand].cmdProc( C_START, zero); + return C_CONTINUE; } EXPORT BOOL_T IsCurCommandSticky(void) { @@ -1319,7 +1370,7 @@ EXPORT void ResetIfNotSticky(void) { } EXPORT void DoCommandB(void * data) { - wIndex_t inx = (wIndex_t) (long) data; + wIndex_t inx = (wIndex_t)VP2L(data); STATUS_T rc; static coOrd pos = { 0, 0 }; static int inDoCommandB = FALSE; @@ -1365,6 +1416,10 @@ EXPORT void DoCommandB(void * data) { ( "COMMAND CANCEL %s\n", commandList[curCommand].helpKey )) commandList[curCommand].cmdProc( C_CANCEL, pos); tempSegs_da.cnt = 0; + } else { + LOG(log_command, 3, + ( "COMMAND FINISH %s\n", commandList[curCommand].helpKey )) + rc = commandList[curCommand].cmdProc( C_FINISH, zero); } if (commandList[curCommand].buttInx >= 0) wButtonSetBusy( @@ -1385,7 +1440,7 @@ EXPORT void DoCommandB(void * data) { wControlSetHelp(buttonList[buttInx].control, GetBalloonHelpStr(commandList[curCommand].helpKey)); wControlSetContext(buttonList[buttInx].control, - (void*) (intptr_t) curCommand); + I2VP(curCommand)); buttonList[buttInx].cmdInx = curCommand; } wButtonSetBusy( @@ -1394,6 +1449,7 @@ EXPORT void DoCommandB(void * data) { } LOG(log_command, 1, ( "COMMAND START %s\n", commandList[curCommand].helpKey )) + wSetCursor(mainD.d,defaultCursor); rc = commandList[curCommand].cmdProc( C_START, pos); LOG(log_command, 4, ( " COMMAND returns %d\n", rc )) TempRedraw(); // DoCommandB @@ -1419,16 +1475,17 @@ EXPORT void DoCommandB(void * data) { static void DoCommandBIndirect(void * cmdInxP) { wIndex_t cmdInx; cmdInx = *(wIndex_t*) cmdInxP; - DoCommandB((void*) (intptr_t) cmdInx); + DoCommandB(I2VP(cmdInx)); } EXPORT void LayoutSetPos(wIndex_t inx) { - wPos_t w, h, offset; - static wPos_t toolbarRowHeight = 0; - static wPos_t width; + wWinPix_t w, h, offset; + static wWinPix_t toolbarRowHeight = 0; + static wWinPix_t width; static int lastGroup; - static wPos_t gap; + static wWinPix_t gap; static int layerButtCnt; + static int layerButtNumber; int currGroup; if (inx == 0) { @@ -1437,6 +1494,7 @@ EXPORT void LayoutSetPos(wIndex_t inx) { gap = 5; toolbarWidth = width - 20 + 5; layerButtCnt = 0; + layerButtNumber = 0; toolbarHeight = 0; } @@ -1455,7 +1513,7 @@ EXPORT void LayoutSetPos(wIndex_t inx) { && (programMode == MODE_TRAIN || (buttonList[inx].options & IC_MODETRAIN_ONLY) == 0) && ((buttonList[inx].group & ~BG_BIGGAP) != BG_LAYER - || layerButtCnt++ <= layerCount)) { + || layerButtCnt < layerCount)) { if (currGroup != lastGroup) { toolbarWidth += gap; lastGroup = currGroup; @@ -1473,12 +1531,21 @@ EXPORT void LayoutSetPos(wIndex_t inx) { toolbarWidth = 0; toolbarHeight += h + 5; } - wControlSetPos(buttonList[inx].control, toolbarWidth, + if ((currGroup == BG_LAYER) && layerButtNumber>1 && GetLayerHidden(layerButtNumber-2) ) { + wControlShow(buttonList[inx].control, FALSE); + layerButtNumber++; + } else { + if (currGroup == BG_LAYER ) { + if (layerButtNumber>1) layerButtCnt++; // Ignore List and Background + layerButtNumber++; + } + wControlSetPos(buttonList[inx].control, toolbarWidth, toolbarHeight - (h + 5 +offset)); - buttonList[inx].x = toolbarWidth; - buttonList[inx].y = toolbarHeight - (h + 5 + offset); - toolbarWidth += wControlGetWidth(buttonList[inx].control); - wControlShow(buttonList[inx].control, TRUE); + buttonList[inx].x = toolbarWidth; + buttonList[inx].y = toolbarHeight - (h + 5 + offset); + toolbarWidth += wControlGetWidth(buttonList[inx].control); + wControlShow(buttonList[inx].control, TRUE); + } } else { wControlShow(buttonList[inx].control, FALSE); } @@ -1518,8 +1585,8 @@ EXPORT BOOL_T CommandEnabled(wIndex_t cmdInx) { return commandList[cmdInx].enabled; } -static wIndex_t AddCommand(procCommand_t cmdProc, char * helpKey, - char * nameStr, wIcon_p icon, int reqLevel, long options, long acclKey, +static wIndex_t AddCommand(procCommand_t cmdProc, const char * helpKey, + const char * nameStr, wIcon_p icon, int reqLevel, long options, long acclKey, void * context) { if (commandCnt >= COMMAND_MAX - 1) { AbortProg("addCommand: too many commands"); @@ -1557,7 +1624,7 @@ EXPORT void AddToolbarControl(wControl_p control, long options) { buttonCnt++; } -EXPORT wButton_p AddToolbarButton(char * helpStr, wIcon_p icon, long options, +EXPORT wButton_p AddToolbarButton(const char * helpStr, wIcon_p icon, long options, wButtonCallBack_p action, void * context) { wButton_p bb; wIndex_t inx; @@ -1565,10 +1632,10 @@ EXPORT wButton_p AddToolbarButton(char * helpStr, wIcon_p icon, long options, GetBalloonHelpStr(helpStr); if (context == NULL) { for (inx = 0; inx < menuPG.paramCnt; inx++) { - if (action != DoCommandB && menuPLs[inx].valueP == (void*) action) { + if (action != DoCommandB && menuPLs[inx].valueP == I2VP(action)) { context = &menuPLs[inx]; action = ParamMenuPush; - menuPLs[inx].context = (void*) (intptr_t) buttonCnt; + menuPLs[inx].context = I2VP(buttonCnt); menuPLs[inx].option |= IC_PLAYBACK_PUSH; break; } @@ -1581,7 +1648,8 @@ EXPORT wButton_p AddToolbarButton(char * helpStr, wIcon_p icon, long options, } EXPORT void PlaybackButtonMouse(wIndex_t buttInx) { - wPos_t cmdX, cmdY; + wWinPix_t cmdX, cmdY; + coOrd pos; if (buttInx < 0 || buttInx >= buttonCnt) return; @@ -1589,9 +1657,10 @@ EXPORT void PlaybackButtonMouse(wIndex_t buttInx) { return; cmdX = buttonList[buttInx].x + 17; cmdY = toolbarHeight - (buttonList[buttInx].y + 17) - + (wPos_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; + + (wWinPix_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; - MovePlaybackCursor(&mainD, cmdX, cmdY,TRUE,buttonList[buttInx].control); + mainD.Pix2CoOrd( &mainD, cmdX, cmdY, &pos ); + MovePlaybackCursor(&mainD, pos, TRUE, buttonList[buttInx].control); if (playbackTimer == 0) { wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); wFlush(); @@ -1601,14 +1670,14 @@ EXPORT void PlaybackButtonMouse(wIndex_t buttInx) { } } -#include "bitmaps/openbutt.xpm" -static char * buttonGroupMenuTitle; -static char * buttonGroupHelpKey; -static char * buttonGroupStickyLabel; +#include "bitmaps/down.xpm" +static const char * buttonGroupMenuTitle; +static const char * buttonGroupHelpKey; +static const char * buttonGroupStickyLabel; static wMenu_p buttonGroupPopupM; -EXPORT void ButtonGroupBegin(char * menuTitle, char * helpKey, - char * stickyLabel) { +EXPORT void ButtonGroupBegin(const char * menuTitle, const char * helpKey, + const char * stickyLabel) { buttonGroupMenuTitle = menuTitle; buttonGroupHelpKey = helpKey; buttonGroupStickyLabel = stickyLabel; @@ -1622,7 +1691,7 @@ EXPORT void ButtonGroupEnd(void) { } EXPORT wIndex_t AddMenuButton(wMenu_p menu, procCommand_t command, - char * helpKey, char * nameStr, wIcon_p icon, int reqLevel, + const char * helpKey, const char * nameStr, wIcon_p icon, int reqLevel, long options, long acclKey, void * context) { wIndex_t buttInx = -1; wIndex_t cmdInx; @@ -1639,17 +1708,17 @@ EXPORT wIndex_t AddMenuButton(wMenu_p menu, procCommand_t command, } else { buttInx = buttonCnt; AddToolbarButton(helpKey, icon, options, - (wButtonCallBack_p) DoCommandB, - (void*) (intptr_t) commandCnt); + DoCommandB, + I2VP(commandCnt)); buttonList[buttInx].cmdInx = commandCnt; } if (buttonGroupMenuTitle != NULL && buttonGroupPopupM == NULL) { if (openbuttIcon == NULL) - openbuttIcon = wIconCreatePixMap(openbutt_xpm); + openbuttIcon = wIconCreatePixMap(down_xpm[iconSize]); buttonGroupPopupM = wMenuPopupCreate(mainW, buttonGroupMenuTitle); AddToolbarButton(buttonGroupHelpKey, openbuttIcon, IC_ABUT, (wButtonCallBack_p) wMenuPopupShow, - (void*) buttonGroupPopupM); + buttonGroupPopupM); newButtonGroup = TRUE; commandsSubmenu = wMenuMenuCreate(menu, "", buttonGroupMenuTitle); if (options & IC_POPUP2) { @@ -1690,7 +1759,7 @@ EXPORT wIndex_t AddMenuButton(wMenu_p menu, procCommand_t command, if (buttonGroupPopupM) { commandList[cmdInx].menu[0] = wMenuPushCreate(buttonGroupPopupM, helpKey, GetBalloonHelpStr(helpKey), 0, DoCommandB, - (void*) (intptr_t) cmdInx); + I2VP(cmdInx)); tm = commandsSubmenu; p1m = popup1Submenu; p2m = popup2Submenu; @@ -1700,21 +1769,21 @@ EXPORT wIndex_t AddMenuButton(wMenu_p menu, procCommand_t command, p2m = (options & IC_POPUP2) ? popup2aM : (options & IC_POPUP3) ? popup2mM : popup2M; } commandList[cmdInx].menu[1] = wMenuPushCreate(tm, helpKey, nameStr, acclKey, - DoCommandB, (void*) (intptr_t) cmdInx); + DoCommandB, I2VP(cmdInx)); if ((options & (IC_POPUP | IC_POPUP2 | IC_POPUP3))) { if (!(options & IC_SELECTED)) { commandList[cmdInx].menu[2] = wMenuPushCreate(p1m, helpKey, nameStr, - 0, DoCommandB, (void*) (intptr_t) cmdInx); + 0, DoCommandB, I2VP(cmdInx)); } commandList[cmdInx].menu[3] = wMenuPushCreate(p2m, helpKey, nameStr, 0, - DoCommandB, (void*) (intptr_t) cmdInx); + DoCommandB, I2VP(cmdInx)); } return cmdInx; } -EXPORT wIndex_t InitCommand(wMenu_p menu, procCommand_t command, char * nameStr, - char * bits, int reqLevel, long options, long acclKey) { +EXPORT wIndex_t InitCommand(wMenu_p menu, procCommand_t command, const char * nameStr, + const char * bits, int reqLevel, long options, long acclKey) { char helpKey[STR_SHORT_SIZE]; wIcon_p icon = NULL; if (bits) @@ -1727,10 +1796,10 @@ EXPORT wIndex_t InitCommand(wMenu_p menu, procCommand_t command, char * nameStr, /*--------------------------------------------------------------------*/ -EXPORT void PlaybackCommand(char * line, wIndex_t lineNum) { - wIndex_t inx; +EXPORT void PlaybackCommand(const char * line, wIndex_t lineNum) { + size_t inx; wIndex_t buttInx; - int len1, len2; + size_t len1, len2; len1 = strlen(line + 8); for (inx = 0; inx < commandCnt; inx++) { len2 = strlen(commandList[inx].helpKey + 3); @@ -1743,12 +1812,14 @@ EXPORT void PlaybackCommand(char * line, wIndex_t lineNum) { fprintf(stderr, "Unknown playback COMMAND command %d : %s\n", lineNum, line); } else { - wPos_t cmdX, cmdY; + wWinPix_t cmdX, cmdY; + coOrd pos; if ((buttInx = commandList[inx].buttInx) >= 0) { cmdX = buttonList[buttInx].x + 17; cmdY = toolbarHeight - (buttonList[buttInx].y + 17) - + (wPos_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; - MovePlaybackCursor(&mainD, cmdX, cmdY,TRUE,buttonList[buttInx].control); + + (wWinPix_t) (mainD.size.y / mainD.scale * mainD.dpi) + 30; + mainD.Pix2CoOrd( &mainD, cmdX, cmdY, &pos ); + MovePlaybackCursor(&mainD, pos,TRUE,buttonList[buttInx].control); } if (strcmp(line + 8, "Undo") == 0) { if (buttInx > 0 && playbackTimer == 0) { @@ -1758,7 +1829,7 @@ EXPORT void PlaybackCommand(char * line, wIndex_t lineNum) { wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); wFlush(); } - UndoUndo(); + UndoUndo(NULL); } else if (strcmp(line + 8, "Redo") == 0) { if (buttInx >= 0 && playbackTimer == 0) { wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); @@ -1767,7 +1838,7 @@ EXPORT void PlaybackCommand(char * line, wIndex_t lineNum) { wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); wFlush(); } - UndoRedo(); + UndoRedo(NULL); } else { if (buttInx >= 0 && playbackTimer == 0) { wButtonSetBusy((wButton_p) buttonList[buttInx].control, TRUE); @@ -1776,7 +1847,7 @@ EXPORT void PlaybackCommand(char * line, wIndex_t lineNum) { wButtonSetBusy((wButton_p) buttonList[buttInx].control, FALSE); wFlush(); } - DoCommandB((void*) (intptr_t) inx); + DoCommandB(I2VP(inx)); } } } @@ -1798,7 +1869,7 @@ static void DoMenuTrace(wMenu_p menu, const char * label, void * data) { } } -EXPORT wMenu_p MenuRegister(char * label) { +EXPORT wMenu_p MenuRegister(const char * label) { wMenu_p m; menuTrace_p mt; m = wMenuPopupCreate(mainW, label); @@ -1813,15 +1884,13 @@ EXPORT wMenu_p MenuRegister(char * label) { void MenuPlayback(char * line) { char * menuName, *itemName; coOrd pos; - wPos_t x, y; menuTrace_p mt; if (!GetArgs(line, "pqq", &pos, &menuName, &itemName)) return; for (mt = &menuTrace(0); mt < &menuTrace(menuTrace_da.cnt); mt++) { if (strcmp(mt->label, menuName) == 0) { - mainD.CoOrd2Pix(&mainD, pos, &x, &y); - MovePlaybackCursor(&mainD, x, y, FALSE, NULL); + MovePlaybackCursor(&mainD, pos, FALSE, NULL); oldMarker = cmdMenuPos = pos; wMenuAction(mt->menu, _(itemName)); return; @@ -1833,17 +1902,17 @@ void MenuPlayback(char * line) { static wWin_p stickyW; -static void StickyOk(void *); +static void StickyOk(void * unused); static paramData_t stickyPLs[] = { { PD_TOGGLE, &stickySet, "set", 0, stickyLabels } }; static paramGroup_t stickyPG = { "sticky", PGO_RECORD, stickyPLs, - sizeof stickyPLs / sizeof stickyPLs[0] }; + COUNT( stickyPLs ) }; -static void StickyOk(void * junk) { +static void StickyOk(void * unused) { wHide(stickyW); } -static void DoSticky(void) { +static void DoSticky(void * unused) { if (!stickyW) stickyW = ParamCreateDialog(&stickyPG, MakeWindowTitle(_("Sticky Commands")), _("Ok"), StickyOk, wHide, @@ -1859,21 +1928,26 @@ static void DoSticky(void) { * specified in the following array. * Note: text and choices must be given in the same order. */ -static char *AllToolbarLabels[] = { N_("File Buttons"), N_("Import/Export Buttons"), N_("Zoom Buttons"), N_( - "Undo Buttons"), N_("Easement Button"), N_("SnapGrid Buttons"), N_( - "Create Track Buttons"), N_("Layout Control Elements"), N_( - "Modify Track Buttons"), N_("Properties/Select"), N_( - "Track Group Buttons"), N_("Train Group Buttons"), N_( - "Create Misc Buttons"), N_("Ruler Button"), N_("Layer Buttons"), N_( - "Hot Bar"), +static char *AllToolbarLabels[] = { N_("File Buttons"), N_("Print Buttons"), N_("Import/Export Buttons"), + N_("Zoom Buttons"), N_("Undo Buttons"), N_("Easement Button"), N_("SnapGrid Buttons"), + N_("Create Track Buttons"), N_("Layout Control Elements"), + N_("Modify Track Buttons"), N_("Properties/Select"), + N_("Track Group Buttons"), N_("Train Group Buttons"), + N_("Create Misc Buttons"), N_("Ruler Button"), + N_("Layer Buttons"), N_("Hot Bar"), NULL }; -static long AllToolbarMasks[] = { 1 << BG_FILE, 1<< BG_EXPORTIMPORT, 1 << BG_ZOOM, 1 << BG_UNDO, 1 - << BG_EASE, 1 << BG_SNAP, 1 << BG_TRKCRT, 1 << BG_CONTROL, 1 - << BG_TRKMOD, 1 << BG_SELECT, 1 << BG_TRKGRP, 1 << BG_TRAIN, 1 - << BG_MISCCRT, 1 << BG_RULER, 1 << BG_LAYER, 1 << BG_HOTBAR }; - -static void ToolbarAction(wBool_t set, void * data) { - long mask = (long) data; +static long AllToolbarMasks[] = { 1 << BG_FILE, 1<< BG_PRINT, 1<< BG_EXPORTIMPORT, + 1<< BG_ZOOM, 1<< BG_UNDO, 1<< BG_EASE, 1 << BG_SNAP, 1 << BG_TRKCRT, + 1<< BG_CONTROL, 1<< BG_TRKMOD, 1 << BG_SELECT, 1 << BG_TRKGRP, 1 << BG_TRAIN, + 1<< BG_MISCCRT, 1<< BG_RULER, 1 << BG_LAYER, 1 << BG_HOTBAR }; + +static wMenuToggle_p AllToolbarMI[ COUNT( AllToolbarMasks ) ]; + +static void ToolbarAction(void * data) { + int inx = (int)VP2L(data); + ASSERT( inx >=0 && inx < COUNT( AllToolbarMasks ) ); + wBool_t set = wMenuToggleGet( AllToolbarMI[inx] ); + long mask = AllToolbarMasks[inx]; if (set) toolbarSet |= mask; else @@ -1898,13 +1972,13 @@ static void CreateToolbarM(wMenu_p toolbarM) { char **labels; wBool_t set; - cnt = sizeof(AllToolbarMasks) / sizeof(AllToolbarMasks[0]); + cnt = COUNT(AllToolbarMasks); masks = AllToolbarMasks; labels = AllToolbarLabels; for (inx = 0; inx < cnt; inx++, masks++, labels++) { set = (toolbarSet & *masks) != 0; - wMenuToggleCreate(toolbarM, "toolbarM", _(*labels), 0, set, - ToolbarAction, (void*) *masks); + AllToolbarMI[inx] = wMenuToggleCreate(toolbarM, "toolbarM", _(*labels), 0, set, + ToolbarAction, I2VP(inx)); } } @@ -1913,21 +1987,20 @@ static void CreateToolbarM(wMenu_p toolbarM) { static wWin_p addElevW; #define addElevF (wFloat_p)addElevPD.control EXPORT DIST_T addElevValueV; -static void DoAddElev(void *); +static void DoAddElev(void * unused); static paramFloatRange_t rn1000_1000 = { -1000.0, 1000.0 }; static paramData_t addElevPLs[] = { { PD_FLOAT, &addElevValueV, "value", - PDO_DIM, &rn1000_1000, NULL, 0 } }; -static paramGroup_t addElevPG = { "addElev", 0, addElevPLs, sizeof addElevPLs - / sizeof addElevPLs[0] }; + PDO_NOPREF|PDO_DIM, &rn1000_1000, NULL, 0 } }; +static paramGroup_t addElevPG = { "addElev", 0, addElevPLs, COUNT( addElevPLs ) }; -static void DoAddElev(void * junk) { +static void DoAddElev(void * unused) { ParamLoadData(&addElevPG); AddElevations(addElevValueV); wHide(addElevW); } -static void ShowAddElevations(void) { +static void ShowAddElevations(void * unused) { if (selectedTrackCount <= 0) { ErrorMessage(MSG_NO_SELECTED_TRK); return; @@ -1942,29 +2015,36 @@ static void ShowAddElevations(void) { /*--------------------------------------------------------------------*/ static wWin_p rotateW; +static wWin_p indexW; static wWin_p moveW; static double rotateValue; +static char trackIndex[STR_LONG_SIZE]; static coOrd moveValue; static rotateDialogCallBack_t rotateDialogCallBack; +static indexDialogCallBack_t indexDialogCallBack; static moveDialogCallBack_t moveDialogCallBack; -static void RotateEnterOk(void *); +static void RotateEnterOk(void * unused); + +static paramFloatRange_t rn360_360 = { -360.0, 360.0, 80 }; +static paramData_t rotatePLs[] = { { PD_FLOAT, &rotateValue, "rotate", PDO_NOPREF|PDO_ANGLE|PDO_NORECORD, &rn360_360, N_("Angle:") } }; +static paramGroup_t rotatePG = { "rotate", 0, rotatePLs, COUNT( rotatePLs ) }; -static paramFloatRange_t rn360_360 = { -360.0, 360.0, 80.0 }; -static paramData_t rotatePLs[] = { { PD_FLOAT, &rotateValue, "rotate", PDO_ANGLE, - &rn360_360, N_("Angle:") } }; -static paramGroup_t rotatePG = { "rotate", 0, rotatePLs, sizeof rotatePLs - / sizeof rotatePLs[0] }; +static void IndexEnterOk(void * unused); +static paramData_t indexPLs[] = { + { PD_STRING, &trackIndex, "select", PDO_NOPREF|PDO_NORECORD|PDO_STRINGLIMITLENGTH, I2VP(STR_SIZE-1), N_("Indexes:"), 0, 0, sizeof(trackIndex) } }; +static paramGroup_t indexPG = { "index", 0, indexPLs, COUNT( indexPLs ) }; 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) { +static void MoveEnterOk(void * unused); +static paramData_t movePLs[] = { + { PD_FLOAT, &moveValue.x, "moveX", PDO_NOPREF|PDO_DIM|PDO_NORECORD, &r_1000_1000, N_("Move X:") }, + { PD_FLOAT, &moveValue.y, "moveY", PDO_NOPREF|PDO_DIM|PDO_NORECORD, &r_1000_1000, N_("Move Y:") } }; +static paramGroup_t movePG = { "move", 0, movePLs, COUNT( movePLs ) }; + +static void StartRotateDialog(void * funcVP) +{ + rotateDialogCallBack_t func = funcVP; if (rotateW == NULL) rotateW = ParamCreateDialog(&rotatePG, MakeWindowTitle(_("Rotate")), _("Ok"), RotateEnterOk, wHide, FALSE, NULL, 0, NULL); @@ -1973,7 +2053,21 @@ EXPORT void StartRotateDialog(rotateDialogCallBack_t func) { wShow(rotateW); } -EXPORT void StartMoveDialog(moveDialogCallBack_t func) { +static void StartIndexDialog(void * funcVP) +{ + indexDialogCallBack_t func = funcVP; + if (indexW == NULL) + indexW = ParamCreateDialog(&indexPG, MakeWindowTitle(_("Select Index")), + _("Ok"), IndexEnterOk, wHide, FALSE, NULL, 0, NULL); + ParamLoadControls(&indexPG); + indexDialogCallBack = func; + trackIndex[0] = '\0'; + wShow(indexW); +} + +static void StartMoveDialog(void * funcVP) +{ + moveDialogCallBack_t func = funcVP; if (moveW == NULL) moveW = ParamCreateDialog(&movePG, MakeWindowTitle(_("Move")), _("Ok"), MoveEnterOk, wHide, FALSE, NULL, 0, NULL); @@ -1983,18 +2077,24 @@ EXPORT void StartMoveDialog(moveDialogCallBack_t func) { wShow(moveW); } -static void MoveEnterOk(void * junk) { +static void MoveEnterOk(void * unused) { ParamLoadData(&movePG); - moveDialogCallBack((void*) &moveValue); + moveDialogCallBack(&moveValue); wHide(moveW); } -static void RotateEnterOk(void * junk) { +static void IndexEnterOk(void * unused) { + ParamLoadData(&indexPG); + indexDialogCallBack(trackIndex); + wHide(indexW); +} + +static void RotateEnterOk(void * unused) { ParamLoadData(&rotatePG); if (angleSystem == ANGLE_POLAR) - rotateDialogCallBack((void*) (long)(rotateValue*1000)); + rotateDialogCallBack(I2VP(rotateValue * 1000)); else - rotateDialogCallBack((void*) (long)(-rotateValue*1000)); + rotateDialogCallBack(I2VP(rotateValue * 1000)); wHide(rotateW); } @@ -2006,24 +2106,33 @@ static void MoveDialogInit(void) { ParamRegister(&movePG); } +static void IndexDialogInit(void) { + ParamRegister(&indexPG); +} + EXPORT void AddMoveMenu(wMenu_p m, moveDialogCallBack_t func) { wMenuPushCreate(m, "", _("Enter Move ..."), 0, - (wMenuCallBack_p) StartMoveDialog, (void*) func); + StartMoveDialog, func); +} + +EXPORT void AddIndexMenu(wMenu_p m, indexDialogCallBack_t func) { + wMenuPushCreate(m, "cmdSelectIndex", _("Select Track Index ..."), 0, + StartIndexDialog, func); } //All values multipled by 100 to support decimal points from PD_FLOAT EXPORT void AddRotateMenu(wMenu_p m, rotateDialogCallBack_t func) { - wMenuPushCreate(m, "", _("180 "), 0, func, (void*) 180000); - wMenuPushCreate(m, "", _("90 CW"), 0, func, (void*) (long) (90000)); - wMenuPushCreate(m, "", _("45 CW"), 0, func, (void*) (long) (45000)); - wMenuPushCreate(m, "", _("30 CW"), 0, func, (void*) (long) (30000)); - wMenuPushCreate(m, "", _("15 CW"), 0, func, (void*) (long) (15000)); - wMenuPushCreate(m, "", _("15 CCW"), 0, func, (void*) (long) (360000 - 15000)); - wMenuPushCreate(m, "", _("30 CCW"), 0, func, (void*) (long) (360000 - 30000)); - wMenuPushCreate(m, "", _("45 CCW"), 0, func, (void*) (long) (360000 - 45000)); - wMenuPushCreate(m, "", _("90 CCW"), 0, func, (void*) (long) (360000 - 90000)); + wMenuPushCreate(m, "", _("180 "), 0, func, I2VP(180000)); + wMenuPushCreate(m, "", _("90 CW"), 0, func, I2VP(90000)); + wMenuPushCreate(m, "", _("45 CW"), 0, func, I2VP(45000)); + wMenuPushCreate(m, "", _("30 CW"), 0, func, I2VP(30000)); + wMenuPushCreate(m, "", _("15 CW"), 0, func, I2VP(15000)); + wMenuPushCreate(m, "", _("15 CCW"), 0, func, I2VP(360000 - 15000)); + wMenuPushCreate(m, "", _("30 CCW"), 0, func, I2VP(360000 - 30000)); + wMenuPushCreate(m, "", _("45 CCW"), 0, func, I2VP(360000 - 45000)); + wMenuPushCreate(m, "", _("90 CCW"), 0, func, I2VP(360000 - 90000)); wMenuPushCreate(m, "", _("Enter Angle ..."), 0, - (wMenuCallBack_p) StartRotateDialog, (void*) func); + StartRotateDialog, func); } /***************************************************************************** @@ -2036,14 +2145,17 @@ static wWin_p debugW; static int debugCnt = 0; static paramIntegerRange_t r0_100 = { 0, 100, 80 }; -static void DebugOk(void * junk); +static void DebugOk(void * unused); static paramData_t debugPLs[30]; +static paramData_t p0[] = { + { PD_BUTTON, TestMallocs, "test", PDO_DLGHORZ, NULL, N_("Test Mallocs") } + }; static long debug_values[30]; static int debug_index[30]; static paramGroup_t debugPG = { "debug", 0, debugPLs, 0 }; -static void DebugOk(void * junk) { +static void DebugOk(void * unused) { for (int i = 0; i<debugCnt;i++) { logTable(debug_index[i]).level = debug_values[i]; } @@ -2051,16 +2163,17 @@ static void DebugOk(void * junk) { } static void CreateDebugW(void) { - debugPG.paramCnt = debugCnt; + debugPG.paramCnt = debugCnt+1; ParamRegister(&debugPG); debugW = ParamCreateDialog(&debugPG, MakeWindowTitle(_("Debug")), _("Ok"), DebugOk, wHide, FALSE, NULL, 0, NULL); wHide(debugW); } -EXPORT void DebugInit(void) { +EXPORT void DebugInit(void * unused) { if (!debugW) { + debugPLs[0] = p0[0]; BOOL_T default_line = FALSE; debugCnt = 0; //Reset to start building the dynamic dialog over again int i = 0; @@ -2080,6 +2193,7 @@ EXPORT void DebugInit(void) { } } } + //ParamCreateControls( &debugPG, NULL ); CreateDebugW(); } @@ -2088,22 +2202,22 @@ EXPORT void DebugInit(void) { } -EXPORT void InitDebug(char * label, long * valueP) { - if (debugCnt >= sizeof debugPLs / sizeof debugPLs[0]) +EXPORT void InitDebug(const char * label, long * valueP) { + if (debugCnt+1 >= COUNT( debugPLs ) ) AbortProg("Too many debug flags"); - memset(&debugPLs[debugCnt], 0, sizeof debugPLs[debugCnt]); - debugPLs[debugCnt].type = PD_LONG; - debugPLs[debugCnt].valueP = valueP; - debugPLs[debugCnt].nameStr = label; - debugPLs[debugCnt].winData = &r0_100; - debugPLs[debugCnt].winLabel = label; + memset(&debugPLs[debugCnt+1], 0, sizeof debugPLs[debugCnt]); + debugPLs[debugCnt+1].type = PD_LONG; + debugPLs[debugCnt+1].valueP = valueP; + debugPLs[debugCnt+1].nameStr = label; + debugPLs[debugCnt+1].winData = &r0_100; + debugPLs[debugCnt+1].winLabel = label; debugCnt++; } -void RecomputeElevations(void); +void RecomputeElevations(void * unused ); -static void MiscMenuItemCreate(wMenu_p m1, wMenu_p m2, char * name, - char * label, long acclKey, void * func, long option, void * context) { +static void MiscMenuItemCreate(wMenu_p m1, wMenu_p m2, const char * name, + const char * label, long acclKey, void * func, long option, void * context) { wMenuPush_p mp; mp = wMenuPushCreate(m1, name, label, acclKey, ParamMenuPush, &menuPLs[menuPG.paramCnt]); @@ -2122,67 +2236,157 @@ static void MiscMenuItemCreate(wMenu_p m1, wMenu_p m2, char * name, menuPG.paramCnt++; } + +/***************************************************************************** + * + * ACCEL KEY + * + */ + +enum eAccelAction_t { EA_ZOOMUP, EA_ZOOMDOWN, EA_REDRAW, EA_DELETE, EA_UNDO, EA_COPY, EA_PASTE, EA_CUT, EA_NEXT, EA_HELP }; +struct accelKey_s { + const char * sPrefName; + wAccelKey_e eKey; + int iMode; + enum eAccelAction_t iAction; + int iContext; } aAccelKeys[] = { + { "zoomUp", wAccelKey_Pgdn, 0, EA_ZOOMUP, 1 }, + { "zoomDown", wAccelKey_Pgup, 0, EA_ZOOMDOWN, 1 }, + { "redraw", wAccelKey_F5, 0, EA_REDRAW, 0 }, +#ifdef WINDOWS + { "delete", wAccelKey_Del, 0, EA_DELETE, 0 }, +#endif + { "undo", wAccelKey_Back, WKEY_SHIFT, EA_UNDO, 0 }, + { "copy", wAccelKey_Ins, WKEY_CTRL, EA_COPY, 0 }, + { "paste", wAccelKey_Ins, WKEY_SHIFT, EA_PASTE, 0 }, + { "cut", wAccelKey_Del, WKEY_SHIFT, EA_CUT, 0 }, + { "nextWindow", wAccelKey_F6, 0, EA_NEXT, 0 }, + { "zoomUp", wAccelKey_Numpad_Add, WKEY_CTRL, EA_ZOOMUP, 1 }, + { "zoomDown", wAccelKey_Numpad_Subtract, WKEY_CTRL, EA_ZOOMDOWN, 1 }, + { "help", wAccelKey_F1, WKEY_SHIFT, EA_HELP, 1 }, + { "help-context", wAccelKey_F1, 0, EA_HELP, 3 } }; + +static void AccelKeyDispatch( wAccelKey_e key, void * accelKeyIndexVP ) +{ + int iAccelKeyIndex = (int)VP2L(accelKeyIndexVP); + switch( aAccelKeys[iAccelKeyIndex].iAction ) { + case EA_ZOOMUP: + DoZoomUp( I2VP(aAccelKeys[iAccelKeyIndex].iContext) ); + break; + case EA_ZOOMDOWN: + DoZoomDown( I2VP(aAccelKeys[iAccelKeyIndex].iContext) ); + break; + case EA_REDRAW: + MainRedraw(); + break; + case EA_DELETE: + TrySelectDelete(); + break; + case EA_UNDO: + UndoUndo(NULL); + break; + case EA_COPY: + EditCopy(NULL); + break; + case EA_PASTE: + EditPaste(NULL); + break; + case EA_CUT: + EditCut(NULL); + break; + case EA_NEXT: + NextWindow(); + break; + case EA_HELP: + wDoAccelHelp(key, I2VP(aAccelKeys[iAccelKeyIndex].iContext)); + break; + default: + abort(); + } +} + static char * accelKeyNames[] = { "Del", "Ins", "Home", "End", "Pgup", "Pgdn", "Up", "Down", "Right", "Left", "Back", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "NumpadAdd", "NumpadSub" }; -static void SetAccelKey(char * prefName, wAccelKey_e key, int mode, - wAccelKeyCallBack_p func, void * context) { - int mode1 = 0; - int inx; - const char * prefValue = wPrefGetString("accelKey", prefName); - if (prefValue != NULL) { - while (prefValue[1] == '-') { - switch (prefValue[0]) { - case 'S': - mode1 |= WKEY_SHIFT; - break; - case 'C': - mode1 |= WKEY_CTRL; - break; - case 'A': - mode1 |= WKEY_ALT; - break; - default: - ; +static void SetAccelKeys() +{ + for ( int iAccelKey = 0; iAccelKey < COUNT( aAccelKeys ); iAccelKey++ ) + { + struct accelKey_s * akP = &aAccelKeys[iAccelKey]; + int eKey = akP->eKey; + int iMode = akP->iMode; + const char * sPrefValue = wPrefGetString("accelKey", akP->sPrefName); + if (sPrefValue != NULL) { + int iMode1 = 0; + while (sPrefValue[1] == '-') { + switch (sPrefValue[0]) { + case 'S': + iMode1 |= WKEY_SHIFT; + break; + case 'C': + iMode1 |= WKEY_CTRL; + break; + case 'A': + iMode1 |= WKEY_ALT; + break; + default: + ; + } + sPrefValue += 2; } - prefValue += 2; - } - for (inx = 0; inx < sizeof accelKeyNames / sizeof accelKeyNames[0]; - inx++) { - if (strcmp(prefValue, accelKeyNames[inx]) == 0) { - key = inx + 1; - mode = mode1; - break; + for (int inx = 0; inx < COUNT( accelKeyNames ); inx++) { + if (strcmp(sPrefValue, accelKeyNames[inx]) == 0) { + eKey = inx + 1; + iMode = iMode1; + break; + } } } + wAttachAccelKey(eKey, iMode, AccelKeyDispatch, I2VP(iAccelKey)); } - wAttachAccelKey(key, mode, func, context); -} - -#include "bitmaps/zoomin.xpm" -#include "bitmaps/zoom.xpm" -#include "bitmaps/zoomout.xpm" -#include "bitmaps/edit-undo.xpm" -#include "bitmaps/edit-redo.xpm" -#include "bitmaps/partlist.xpm" -#include "bitmaps/document-export.xpm" -#include "bitmaps/document-exportdxf.xpm" -#include "bitmaps/document-import.xpm" -#include "bitmaps/document-importmod.xpm" -#include "bitmaps/document-new.xpm" -#include "bitmaps/document-save.xpm" -#include "bitmaps/document-open.xpm" -#include "bitmaps/document-print.xpm" +} + + +/***************************************************************************** + * + * MENUS + * + */ + + +#include "bitmaps/zoom-in.xpm" +#include "bitmaps/zoom-choose.xpm" +#include "bitmaps/zoom-out.xpm" +#include "bitmaps/zoom-extent.xpm" +#include "bitmaps/undo.xpm" +#include "bitmaps/redo.xpm" +#include "bitmaps/partlist.xpm" // unused icon +#include "bitmaps/doc-export.xpm" +#include "bitmaps/doc-export-dxf.xpm" +#include "bitmaps/doc-export-bmap.xpm" +#include "bitmaps/doc-import.xpm" +#include "bitmaps/doc-import-xtc.xpm" +#include "bitmaps/doc-new.xpm" +#include "bitmaps/doc-save.xpm" +#include "bitmaps/doc-open.xpm" +#include "bitmaps/doc-print.xpm" +#include "bitmaps/doc-setup.xpm" +#include "bitmaps/parameter.xpm" #include "bitmaps/map.xpm" #include "bitmaps/magnet.xpm" +static wMenu_p toolbarM; +static addButtonCallBack_t paramFilesCallback; + static void CreateMenus(void) { wMenu_p fileM, editM, viewM, optionM, windowM, macroM, helpM, toolbarM, messageListM, manageM, addM, changeM, drawM; wMenu_p zoomM, zoomSubM; - wMenuPush_p zoomInM, zoomOutM; + wMenuPush_p zoomInM, zoomOutM, zoomExtentsM; + + wPrefGetInteger("DialogItem", "pref-iconsize", (long *) &iconSize, 0); fileM = wMenuBarAdd(mainW, "menuFile", _("&File")); editM = wMenuBarAdd(mainW, "menuEdit", _("&Edit")); @@ -2233,57 +2437,65 @@ static void CreateMenus(void) { popup1M = wMenuPopupCreate(mainW, _("Context Commands")); popup2M = wMenuPopupCreate(mainW, _("Shift Context Commands")); MiscMenuItemCreate(popup1M, popup2M, "cmdUndo", _("Undo"), 0, - (void*) (wMenuCallBack_p) UndoUndo, 0, (void *) 0); + UndoUndo, 0, NULL); MiscMenuItemCreate(popup1M, popup2M, "cmdRedo", _("Redo"), 0, - (void*) (wMenuCallBack_p) UndoRedo, 0, (void *) 0); + UndoRedo, 0, NULL); /* Zoom */ wMenuPushCreate(popup1M, "cmdZoomIn", _("Zoom In"), 0, - (wMenuCallBack_p) DoZoomUp, (void*) 1); + DoZoomUp, I2VP(1)); wMenuPushCreate(popup2M, "cmdZoomIn", _("Zoom In"), 0, - (wMenuCallBack_p) DoZoomUp, (void*) 1); + DoZoomUp, I2VP(1)); wMenuPushCreate(popup1M, "cmdZoomOut", _("Zoom Out"), 0, - (wMenuCallBack_p) DoZoomDown, (void*) 1); + DoZoomDown, I2VP(1)); wMenuPushCreate(popup2M, "cmdZoomOut", _("Zoom Out"), 0, - (wMenuCallBack_p) DoZoomDown, (void*) 1); - /* Display */ + DoZoomDown, I2VP(1)); + wMenuPushCreate(popup1M, "cmdZoomExtents", _("Zoom Extents"), 0, + DoZoomExtents, I2VP(1)); + wMenuPushCreate(popup2M, "cmdZoomExtents", _("Zoom Extents"), 0, + DoZoomExtents, I2VP(1)); + /* Display */ MiscMenuItemCreate(popup1M, popup2M, "cmdGridEnable", _("Enable SnapGrid"), - 0, (void*) (wMenuCallBack_p) SnapGridEnable, 0, (void *) 0); + 0, SnapGridEnable, 0, NULL); MiscMenuItemCreate(popup1M, popup2M, "cmdGridShow", _("SnapGrid Show"), 0, - (void*) (wMenuCallBack_p) SnapGridShow, 0, (void *) 0); + SnapGridShow, 0, NULL); MiscMenuItemCreate(popup1M, popup2M, "cmdMagneticSnap", _(" Enable Magnetic Snap"), 0, - (void*) (wMenuCallBack_p) MagneticSnapToggle, 0, (void *) 0); + MagneticSnapToggle, 0, NULL); MiscMenuItemCreate(popup1M, popup2M, "cmdMapShow", _("Show/Hide Map"), 0, - (void*) (wMenuCallBack_p) MapWindowToggleShow, 0, (void *) 0); + MapWindowToggleShow, 0, NULL); MiscMenuItemCreate(popup1M, popup2M, "cmdBackgroundShow", _("Show/Hide Background"), 0, - (void*) (wMenuCallBack_p) BackgroundToggleShow, 0, (void *) 0); + BackgroundToggleShow, 0, NULL); wMenuSeparatorCreate(popup1M); wMenuSeparatorCreate(popup2M); /* Copy/Paste */ MiscMenuItemCreate(popup2M, NULL, "cmdCut", _("Cut"), 0, - (void*) (wMenuCallBack_p) EditCut, 0, (void *) 0); + EditCut, 0, NULL); MiscMenuItemCreate(popup2M, NULL, "cmdCopy", _("Copy"), 0, - (void*) (wMenuCallBack_p) EditCopy, 0, (void *) 0); + EditCopy, 0, NULL); MiscMenuItemCreate(popup1M, popup2M, "cmdPaste", _("Paste"), 0, - (void*) (wMenuCallBack_p) EditPaste, 0, (void *) 0); + EditPaste, 0, NULL); MiscMenuItemCreate(popup2M, NULL, "cmdClone", _("Clone"), 0, - (void*) (wMenuCallBack_p) EditClone, 0, (void *) 0); + EditClone, 0, NULL); /*Select*/ MiscMenuItemCreate(popup1M, popup2M, "cmdSelectAll", _("Select All"), 0, - (void*) (wMenuCallBack_p) SetAllTrackSelect, 0, (void *) 1); + (wMenuCallBack_p) SetAllTrackSelect, 0, I2VP(1)); MiscMenuItemCreate(popup1M, popup2M, "cmdSelectCurrentLayer", _("Select Current Layer"), 0, - (void*) (wMenuCallBack_p) SelectCurrentLayer, 0, (void *) 0); + SelectCurrentLayer, 0, NULL); MiscMenuItemCreate(popup2M, NULL, "cmdDeselectAll", _("Deselect All"), 0, - (void*) (wMenuCallBack_p) SetAllTrackSelect, 0, (void *) 0); + (wMenuCallBack_p) SetAllTrackSelect, 0, I2VP(FALSE)); + wMenuPushCreate(popup1M, "cmdSelectIndex", _("Select Track Index..."), 0, + StartIndexDialog, &SelectByIndex); + wMenuPushCreate(popup2M, "cmdSelectIndex", _("Select Track Index..."), 0, + StartIndexDialog, &SelectByIndex); /* Modify */ wMenuPushCreate(popup2M, "cmdMove", _("Move"), 0, - (wMenuCallBack_p) DoCommandBIndirect, &moveCmdInx); + DoCommandBIndirect, &moveCmdInx); wMenuPushCreate(popup2M, "cmdRotate", _("Rotate"), 0, - (wMenuCallBack_p) DoCommandBIndirect, &rotateCmdInx); + DoCommandBIndirect, &rotateCmdInx); wMenuSeparatorCreate(popup1M); wMenuSeparatorCreate(popup2M); MiscMenuItemCreate(popup2M, NULL, "cmdDelete", _("Delete"), 0, - (void*) (wMenuCallBack_p) SelectDelete, 0, (void *) 0); + (wMenuCallBack_p) SelectDelete, 0, NULL); wMenuSeparatorCreate(popup2M); popup1aM = wMenuMenuCreate(popup1M, "", _("Add...")); popup2aM = wMenuMenuCreate(popup2M, "", _("Add...")); @@ -2292,139 +2504,158 @@ static void CreateMenus(void) { popup1mM = wMenuMenuCreate(popup1M, "", _("More...")); popup2mM = wMenuMenuCreate(popup2M, "", _("More...")); - cmdGroup = BG_FILE; - 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); - - InitCmdExport(); - - cmdGroup = BG_ZOOM; - zoomUpB = AddToolbarButton("cmdZoomIn", wIconCreatePixMap(zoomin_xpm), - IC_MODETRAIN_TOO, (addButtonCallBack_t) DoZoomUp, NULL); - - zoomM = wMenuPopupCreate(mainW, ""); - AddToolbarButton("cmdZoom", wIconCreatePixMap(zoom_xpm), IC_MODETRAIN_TOO, - (wButtonCallBack_p) wMenuPopupShow, zoomM); - - zoomDownB = AddToolbarButton("cmdZoomOut", wIconCreatePixMap(zoomout_xpm), - IC_MODETRAIN_TOO, (addButtonCallBack_t) DoZoomDown, NULL); - - cmdGroup = BG_UNDO; - undoB = AddToolbarButton("cmdUndo", wIconCreatePixMap(edit_undo), 0, - (addButtonCallBack_t) UndoUndo, NULL); - redoB = AddToolbarButton("cmdRedo", wIconCreatePixMap(edit_redo), 0, - (addButtonCallBack_t) UndoRedo, NULL); - - wControlActive((wControl_p) undoB, FALSE); - wControlActive((wControl_p) redoB, FALSE); - /* * FILE MENU */ MiscMenuItemCreate(fileM, NULL, "menuFile-clear", _("&New ..."), ACCL_NEW, - (void*) (wMenuCallBack_p) DoClear, 0, (void *) 0); + DoClear, 0, NULL); wMenuPushCreate(fileM, "menuFile-load", _("&Open ..."), ACCL_OPEN, - (wMenuCallBack_p) ChkLoad, NULL); + ChkLoad, NULL); wMenuSeparatorCreate(fileM); wMenuPushCreate(fileM, "menuFile-save", _("&Save"), ACCL_SAVE, - (wMenuCallBack_p) DoSave, NULL); + DoSave, NULL); wMenuPushCreate(fileM, "menuFile-saveAs", _("Save &As ..."), ACCL_SAVEAS, - (wMenuCallBack_p) DoSaveAs, NULL); + DoSaveAs, NULL); wMenuPushCreate(fileM, "menuFile-revert", _("Revert"), ACCL_REVERT, - (wMenuCallBack_p) ChkRevert, NULL); + ChkRevert, NULL); wMenuSeparatorCreate(fileM); + + cmdGroup = BG_FILE; + AddToolbarButton("menuFile-clear", wIconCreatePixMap(doc_new_xpm[iconSize]), + IC_MODETRAIN_TOO, DoClear, NULL); + AddToolbarButton("menuFile-load", wIconCreatePixMap(doc_open_xpm[iconSize]), + IC_MODETRAIN_TOO, ChkLoad, NULL); + AddToolbarButton("menuFile-save", wIconCreatePixMap(doc_save_xpm[iconSize]), + IC_MODETRAIN_TOO, DoSave, NULL); + + cmdGroup = BG_PRINT; MiscMenuItemCreate(fileM, NULL, "printSetup", _("P&rint Setup ..."), - ACCL_PRINTSETUP, (void*) (wMenuCallBack_p) wPrintSetup, 0, - (void *) 0); + ACCL_PRINTSETUP, (wMenuCallBack_p) wPrintSetup, 0, + I2VP(0)); printCmdInx = InitCmdPrint(fileM); + AddToolbarButton("menuFile-setup", wIconCreatePixMap(doc_setup_xpm[iconSize]), + IC_MODETRAIN_TOO, (wMenuCallBack_p) wPrintSetup, I2VP(0)); + wMenuSeparatorCreate(fileM); MiscMenuItemCreate(fileM, NULL, "cmdImport", _("&Import"), ACCL_IMPORT, - (void*) (wMenuCallBack_p) DoImport, 0, (void *) 0); + DoImport, 0, I2VP(0)); MiscMenuItemCreate(fileM, NULL, "cmdImportModule", _("Import &Module"), ACCL_IMPORT_MOD, - (void*) (wMenuCallBack_p) DoImport, 0, (void *) 1); + DoImport, 0, I2VP(1)); MiscMenuItemCreate(fileM, NULL, "cmdOutputbitmap", _("Export to &Bitmap"), - ACCL_PRINTBM, (void*) (wMenuCallBack_p) OutputBitMapInit(), 0, - (void *) 0); + ACCL_PRINTBM, OutputBitMapInit(), 0, + NULL); MiscMenuItemCreate(fileM, NULL, "cmdExport", _("E&xport"), ACCL_EXPORT, - (void*) (wMenuCallBack_p) DoExport, IC_SELECTED, (void *) 0); + DoExport, IC_SELECTED, NULL); MiscMenuItemCreate(fileM, NULL, "cmdExportDXF", _("Export D&XF"), - ACCL_EXPORTDXF, (void*) (wMenuCallBack_p) DoExportDXF, IC_SELECTED, - (void *) 0); + ACCL_EXPORTDXF, DoExportDXF, IC_SELECTED, + NULL); +#if XTRKCAD_CREATE_SVG + MiscMenuItemCreate( fileM, NULL, "cmdExportSVG", _("Export S&VG"), ACCL_EXPORTDXF, + DoExportSVG, IC_SELECTED, NULL); +#endif wMenuSeparatorCreate(fileM); + paramFilesCallback = ParamFilesInit(); MiscMenuItemCreate(fileM, NULL, "cmdPrmfile", _("Parameter &Files ..."), - ACCL_PARAMFILES, (void*) ParamFilesInit(), 0, (void *) 0); + ACCL_PARAMFILES, paramFilesCallback, 0, NULL); MiscMenuItemCreate(fileM, NULL, "cmdFileNote", _("No&tes ..."), ACCL_NOTES, - (void*) (wMenuCallBack_p) DoNote, 0, (void *) 0); + DoNote, 0, NULL); wMenuSeparatorCreate(fileM); fileList_ml = wMenuListCreate(fileM, "menuFileList", NUM_FILELIST, ChkFileList); wMenuSeparatorCreate(fileM); wMenuPushCreate(fileM, "menuFile-quit", _("E&xit"), 0, - (wMenuCallBack_p) DoQuit, NULL); + DoQuit, NULL); + + InitCmdExport(); + + AddToolbarButton("menuFile-parameter", wIconCreatePixMap(parameter_xpm[iconSize]), + IC_MODETRAIN_TOO, paramFilesCallback, NULL); + + cmdGroup = BG_ZOOM; + zoomUpB = AddToolbarButton("cmdZoomIn", wIconCreatePixMap(zoom_in_xpm[iconSize]), + IC_MODETRAIN_TOO, DoZoomUp, NULL); + zoomM = wMenuPopupCreate(mainW, ""); + AddToolbarButton("cmdZoom", wIconCreatePixMap(zoom_choose_xpm[iconSize]), IC_MODETRAIN_TOO, + (wButtonCallBack_p) wMenuPopupShow, zoomM); + zoomDownB = AddToolbarButton("cmdZoomOut", wIconCreatePixMap(zoom_out_xpm[iconSize]), + IC_MODETRAIN_TOO, DoZoomDown, NULL); + zoomExtentsB = AddToolbarButton("cmdZoomExtent", wIconCreatePixMap(zoom_extent_xpm[iconSize]), + IC_MODETRAIN_TOO, DoZoomExtents, NULL); + + cmdGroup = BG_UNDO; + undoB = AddToolbarButton("cmdUndo", wIconCreatePixMap(undo_xpm[iconSize]), 0, + UndoUndo, NULL); + redoB = AddToolbarButton("cmdRedo", wIconCreatePixMap(redo_xpm[iconSize]), 0, + UndoRedo, NULL); + + wControlActive((wControl_p) undoB, FALSE); + wControlActive((wControl_p) redoB, FALSE); + InitCmdUndo(); /* * EDIT MENU */ MiscMenuItemCreate(editM, NULL, "cmdUndo", _("&Undo"), ACCL_UNDO, - (void*) (wMenuCallBack_p) UndoUndo, 0, (void *) 0); + UndoUndo, 0, NULL); MiscMenuItemCreate(editM, NULL, "cmdRedo", _("R&edo"), ACCL_REDO, - (void*) (wMenuCallBack_p) UndoRedo, 0, (void *) 0); + UndoRedo, 0, NULL); wMenuSeparatorCreate(editM); MiscMenuItemCreate(editM, NULL, "cmdCut", _("Cu&t"), ACCL_CUT, - (void*) (wMenuCallBack_p) EditCut, IC_SELECTED, (void *) 0); + EditCut, IC_SELECTED, NULL); MiscMenuItemCreate(editM, NULL, "cmdCopy", _("&Copy"), ACCL_COPY, - (void*) (wMenuCallBack_p) EditCopy, IC_SELECTED, (void *) 0); + EditCopy, IC_SELECTED, NULL); MiscMenuItemCreate(editM, NULL, "cmdPaste", _("&Paste"), ACCL_PASTE, - (void*) (wMenuCallBack_p) EditPaste, 0, (void *) 0); + EditPaste, 0, NULL); MiscMenuItemCreate(editM, NULL, "cmdClone", _("C&lone"), ACCL_CLONE, - (void*) (wMenuCallBack_p) EditClone, 0, (void *) 0); + EditClone, 0, NULL); MiscMenuItemCreate(editM, NULL, "cmdDelete", _("De&lete"), ACCL_DELETE, - (void*) (wMenuCallBack_p) SelectDelete, IC_SELECTED, (void *) 0); + (wMenuCallBack_p) SelectDelete, IC_SELECTED, NULL); MiscMenuItemCreate(editM, NULL, "cmdMoveToCurrentLayer", _("Move To Current Layer"), ACCL_MOVCURLAYER, - (void*) (wMenuCallBack_p) MoveSelectedTracksToCurrentLayer, - IC_SELECTED, (void *) 0); + MoveSelectedTracksToCurrentLayer, + IC_SELECTED, NULL); wMenuSeparatorCreate( editM ); - menuPLs[menuPG.paramCnt].context = (void*)1; - MiscMenuItemCreate( editM, NULL, "cmdSelectAll", _("Select &All"), ACCL_SELECTALL, (void*)(wMenuCallBack_p)SetAllTrackSelect, 0, (void *)1 ); - MiscMenuItemCreate( editM, NULL, "cmdSelectCurrentLayer", _("Select Current Layer"), ACCL_SETCURLAYER, (void*)(wMenuCallBack_p)SelectCurrentLayer, 0, (void *)0 ); - MiscMenuItemCreate( editM, NULL, "cmdDeselectAll", _("&Deselect All"), ACCL_DESELECTALL, (void*)(wMenuCallBack_p)SetAllTrackSelect, 0, (void *)0 ); - MiscMenuItemCreate( editM, NULL, "cmdSelectInvert", _("&Invert Selection"), 0L, (void*)(wMenuCallBack_p)InvertTrackSelect, 0, (void *)0 ); - MiscMenuItemCreate( editM, NULL, "cmdSelectOrphaned", _("Select Stranded Track"), 0L, (void*)(wMenuCallBack_p)OrphanedTrackSelect, 0, (void *)0 ); + menuPLs[menuPG.paramCnt].context = I2VP(1); + MiscMenuItemCreate( editM, NULL, "cmdSelectAll", _("Select &All"), ACCL_SELECTALL, (wMenuCallBack_p)SetAllTrackSelect, 0, I2VP(TRUE) ); + MiscMenuItemCreate( editM, NULL, "cmdSelectCurrentLayer", _("Select Current Layer"), ACCL_SETCURLAYER, SelectCurrentLayer, 0, NULL); + MiscMenuItemCreate( editM, NULL, "cmdSelectByIndex", _("Select By Index"), 0L, StartIndexDialog, 0, &SelectByIndex ); + MiscMenuItemCreate( editM, NULL, "cmdDeselectAll", _("&Deselect All"), ACCL_DESELECTALL, (wMenuCallBack_p)SetAllTrackSelect, 0, I2VP(FALSE) ); + MiscMenuItemCreate( editM, NULL, "cmdSelectInvert", _("&Invert Selection"), 0L, InvertTrackSelect, 0, NULL); + MiscMenuItemCreate( editM, NULL, "cmdSelectOrphaned", _("Select Stranded Track"), 0L, OrphanedTrackSelect, 0, NULL); wMenuSeparatorCreate( editM ); - MiscMenuItemCreate( editM, NULL, "cmdTunnel", _("Tu&nnel"), ACCL_TUNNEL, (void*)(wMenuCallBack_p)SelectTunnel, IC_SELECTED, (void *)0 ); - MiscMenuItemCreate( editM, NULL, "cmdBridge", _("B&ridge"), ACCL_BRIDGE, (void*)(wMenuCallBack_p)SelectBridge, IC_SELECTED, (void *)0); - MiscMenuItemCreate( editM, NULL, "cmdTies", _("Ties/NoTies"), ACCL_TIES, (void*)(wMenuCallBack_p)SelectTies, IC_SELECTED, (void *)0); - MiscMenuItemCreate( editM, NULL, "cmdAbove", _("Move to &Front"), ACCL_ABOVE, (void*)(wMenuCallBack_p)SelectAbove, IC_SELECTED, (void *)0 ); - MiscMenuItemCreate( editM, NULL, "cmdBelow", _("Move to &Back"), ACCL_BELOW, (void*)(wMenuCallBack_p)SelectBelow, IC_SELECTED, (void *)0 ); + MiscMenuItemCreate( editM, NULL, "cmdTunnel", _("Tu&nnel"), ACCL_TUNNEL, SelectTunnel, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdBridge", _("B&ridge"), ACCL_BRIDGE, SelectBridge, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdTies", _("Ties/NoTies"), ACCL_TIES, SelectTies, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdAbove", _("Move to &Front"), ACCL_ABOVE, SelectAbove, IC_SELECTED, NULL); + MiscMenuItemCreate( editM, NULL, "cmdBelow", _("Move to &Back"), ACCL_BELOW, SelectBelow, IC_SELECTED, NULL); wMenuSeparatorCreate( editM ); - MiscMenuItemCreate( editM, NULL, "cmdWidth0", _("Thin Tracks"), ACCL_THIN, (void*)(wMenuCallBack_p)SelectTrackWidth, IC_SELECTED, (void *)0 ); - MiscMenuItemCreate( editM, NULL, "cmdWidth2", _("Medium Tracks"), ACCL_MEDIUM, (void*)(wMenuCallBack_p)SelectTrackWidth, IC_SELECTED, (void *)2 ); - MiscMenuItemCreate( editM, NULL, "cmdWidth3", _("Thick Tracks"), ACCL_THICK, (void*)(wMenuCallBack_p)SelectTrackWidth, IC_SELECTED, (void *)3 ); + MiscMenuItemCreate( editM, NULL, "cmdWidth0", _("Thin Tracks"), ACCL_THIN, SelectTrackWidth, IC_SELECTED, I2VP(0) ); + MiscMenuItemCreate( editM, NULL, "cmdWidth2", _("Medium Tracks"), ACCL_MEDIUM, SelectTrackWidth, IC_SELECTED, I2VP(2) ); + MiscMenuItemCreate( editM, NULL, "cmdWidth3", _("Thick Tracks"), ACCL_THICK, SelectTrackWidth, IC_SELECTED, I2VP(3) ); /* * VIEW MENU */ + zoomInM = wMenuPushCreate(viewM, "menuEdit-zoomIn", _("Zoom &In"), - ACCL_ZOOMIN, (wMenuCallBack_p) DoZoomUp, (void*) 1); + ACCL_ZOOMIN, DoZoomUp, I2VP(1)); zoomSubM = wMenuMenuCreate(viewM, "menuEdit-zoomTo", _("&Zoom")); zoomOutM = wMenuPushCreate(viewM, "menuEdit-zoomOut", _("Zoom &Out"), - ACCL_ZOOMOUT, (wMenuCallBack_p) DoZoomDown, (void*) 1); - wMenuSeparatorCreate(viewM); + ACCL_ZOOMOUT, DoZoomDown, I2VP(1)); + zoomExtentsM = wMenuPushCreate(viewM, "menuEdit-zoomExtents", _("Zoom &Extents"), + 0, DoZoomExtents, I2VP(0)); + wMenuSeparatorCreate(viewM); InitCmdZoom(zoomM, zoomSubM, NULL, NULL); /* these menu choices and toolbar buttons are synonymous and should be treated as such */ wControlLinkedSet((wControl_p) zoomInM, (wControl_p) zoomUpB); wControlLinkedSet((wControl_p) zoomOutM, (wControl_p) zoomDownB); + wControlLinkedSet((wControl_p) zoomExtentsM, (wControl_p) zoomExtentsB); wMenuPushCreate(viewM, "menuEdit-redraw", _("&Redraw"), ACCL_REDRAW, (wMenuCallBack_p) MainRedraw, NULL); @@ -2434,20 +2665,20 @@ static void CreateMenus(void) { snapGridEnableMI = wMenuToggleCreate(viewM, "cmdGridEnable", _("Enable SnapGrid"), ACCL_SNAPENABLE, 0, - (wMenuToggleCallBack_p) SnapGridEnable, NULL); + SnapGridEnable, NULL); snapGridShowMI = wMenuToggleCreate(viewM, "cmdGridShow", _("Show SnapGrid"), ACCL_SNAPSHOW, - FALSE, (wMenuToggleCallBack_p) SnapGridShow, NULL); + FALSE, SnapGridShow, NULL); gridCmdInx = InitGrid(viewM); // visibility toggle for anchors // get the start value long anchors_long; - wPrefGetInteger("misc", "anchors", (long *)&anchors_long, 1); + wPrefGetInteger("misc", "anchors", &anchors_long, 1); magneticSnap = anchors_long ? TRUE : FALSE; magnetsMI = wMenuToggleCreate(viewM, "cmdMagneticSnap", _("Enable Magnetic Snap"), 0, magneticSnap, - (wMenuToggleCallBack_p)MagneticSnapToggle, NULL); + MagneticSnapToggle, NULL); // visibility toggle for map window // get the start value @@ -2456,7 +2687,7 @@ static void CreateMenus(void) { mapVisible = mapVisible_long ? TRUE : FALSE; mapShowMI = wMenuToggleCreate(viewM, "cmdMapShow", _("Show/Hide Map"), ACCL_MAPSHOW, mapVisible, - (wMenuToggleCallBack_p) MapWindowToggleShow, NULL); + MapWindowToggleShow, NULL); wMenuSeparatorCreate(viewM); @@ -2468,13 +2699,13 @@ static void CreateMenus(void) { cmdGroup = BG_SNAP; InitSnapGridButtons(); - magnetsB = AddToolbarButton("cmdMagneticSnap", wIconCreatePixMap(magnet_xpm), - IC_MODETRAIN_TOO, (addButtonCallBack_t) MagneticSnapToggle, NULL); + magnetsB = AddToolbarButton("cmdMagneticSnap", wIconCreatePixMap(magnet_xpm[iconSize]), + IC_MODETRAIN_TOO, MagneticSnapToggle, NULL); wControlLinkedSet((wControl_p) magnetsMI, (wControl_p) magnetsB); wButtonSetBusy(magnetsB, (wBool_t) magneticSnap); - mapShowB = AddToolbarButton("cmdMapShow", wIconCreatePixMap(map_xpm), - IC_MODETRAIN_TOO, (addButtonCallBack_t) MapWindowToggleShow, NULL); + mapShowB = AddToolbarButton("cmdMapShow", wIconCreatePixMap(map_xpm[iconSize]), + IC_MODETRAIN_TOO, MapWindowToggleShow, NULL); wControlLinkedSet((wControl_p) mapShowMI, (wControl_p) mapShowB); wButtonSetBusy(mapShowB, (wBool_t) mapVisible); @@ -2507,51 +2738,55 @@ static void CreateMenus(void) { cmdGroup = BG_SELECT; InitCmdDescribe(changeM); InitCmdSelect(changeM); - InitCmdPan(changeM); + InitCmdPan(viewM); + wMenuSeparatorCreate(changeM); cmdGroup = BG_TRKGRP; InitCmdMove(changeM); + InitCmdMoveDescription(changeM); InitCmdDelete(); InitCmdTunnel(); InitCmdBridge(); InitCmdAboveBelow(); cmdGroup = BG_TRKMOD; - if (extraButtons) - MiscMenuItemCreate(changeM, NULL, "loosen", _("&Loosen Tracks"), - ACCL_LOOSEN, (void*) (wMenuCallBack_p) LoosenTracks, - IC_SELECTED, (void *) 0); - InitCmdModify(changeM); + InitCmdCornu(changeM); + + MiscMenuItemCreate(changeM, NULL, "cmdRescale", _("Change Scale"), 0, + DoRescale, IC_SELECTED, NULL); + + + wMenuSeparatorCreate(changeM); + InitCmdJoin(changeM); - InitCmdPull(changeM); InitCmdSplit(changeM); - InitCmdMoveDescription(changeM); + + wMenuSeparatorCreate(changeM); + + InitCmdPull(changeM); + if (extraButtons) + MiscMenuItemCreate(changeM, NULL, "loosen", _("&Loosen Tracks"), + ACCL_LOOSEN, LoosenTracks, + IC_SELECTED, NULL); + wMenuSeparatorCreate(changeM); MiscMenuItemCreate(changeM, NULL, "cmdAddElevations", _("Raise/Lower Elevations"), ACCL_CHGELEV, - (void*) (wMenuCallBack_p) ShowAddElevations, IC_SELECTED, - (void *) 0); + ShowAddElevations, IC_SELECTED, + NULL); InitCmdElevation(changeM); InitCmdProfile(changeM); MiscMenuItemCreate(changeM, NULL, "cmdClearElevations", _("Clear Elevations"), ACCL_CLRELEV, - (void*) (wMenuCallBack_p) ClearElevations, IC_SELECTED, (void *) 0); + ClearElevations, IC_SELECTED, NULL); MiscMenuItemCreate(changeM, NULL, "cmdElevation", _("Recompute Elevations"), - 0, (void*) (wMenuCallBack_p) RecomputeElevations, 0, (void *) 0); + 0, RecomputeElevations, 0, NULL); ParamRegister(&addElevPG); - wMenuSeparatorCreate(changeM); - MiscMenuItemCreate(changeM, NULL, "cmdRescale", _("Change Scale"), 0, - (void*) (wMenuCallBack_p) DoRescale, IC_SELECTED, (void *) 0); - - wMenuSeparatorCreate(changeM); - - InitCmdCornu(changeM); - /* * DRAW MENU */ @@ -2567,28 +2802,28 @@ static void CreateMenus(void) { * OPTION MENU */ MiscMenuItemCreate(optionM, NULL, "cmdLayout", _("L&ayout ..."), - ACCL_LAYOUTW, (void*) LayoutInit(), IC_MODETRAIN_TOO, (void *) 0); + ACCL_LAYOUTW, LayoutInit(), IC_MODETRAIN_TOO, NULL); MiscMenuItemCreate(optionM, NULL, "cmdDisplay", _("&Display ..."), - ACCL_DISPLAYW, (void*) DisplayInit(), IC_MODETRAIN_TOO, (void *) 0); + ACCL_DISPLAYW, DisplayInit(), IC_MODETRAIN_TOO, NULL); MiscMenuItemCreate(optionM, NULL, "cmdCmdopt", _("Co&mmand ..."), - ACCL_CMDOPTW, (void*) CmdoptInit(), IC_MODETRAIN_TOO, (void *) 0); + ACCL_CMDOPTW, CmdoptInit(), IC_MODETRAIN_TOO, NULL); MiscMenuItemCreate(optionM, NULL, "cmdEasement", _("&Easements ..."), - ACCL_EASEW, (void*) (wMenuCallBack_p) DoEasementRedir, - IC_MODETRAIN_TOO, (void *) 0); + ACCL_EASEW, DoEasementRedir, + IC_MODETRAIN_TOO, NULL); MiscMenuItemCreate(optionM, NULL, "fontSelW", _("&Fonts ..."), ACCL_FONTW, - (void*) (wMenuCallBack_p) SelectFont, IC_MODETRAIN_TOO, (void *) 0); + SelectFont, IC_MODETRAIN_TOO, NULL); MiscMenuItemCreate(optionM, NULL, "cmdSticky", _("Stic&ky ..."), - ACCL_STICKY, (void*) (wMenuCallBack_p) DoSticky, IC_MODETRAIN_TOO, - (void *) 0); + ACCL_STICKY, DoSticky, IC_MODETRAIN_TOO, + NULL); if (extraButtons) { menuPLs[menuPG.paramCnt].context = debugW; MiscMenuItemCreate(optionM, NULL, "cmdDebug", _("&Debug ..."), 0, - (void*) (wMenuCallBack_p) DebugInit, IC_MODETRAIN_TOO, (void *) 0); + DebugInit, IC_MODETRAIN_TOO, NULL); } MiscMenuItemCreate(optionM, NULL, "cmdPref", _("&Preferences ..."), - ACCL_PREFERENCES, (void*) PrefInit(), IC_MODETRAIN_TOO, (void *) 0); + ACCL_PREFERENCES, PrefInit(), IC_MODETRAIN_TOO, NULL); MiscMenuItemCreate(optionM, NULL, "cmdColor", _("&Colors ..."), ACCL_COLORW, - (void*) ColorInit(), IC_MODETRAIN_TOO, (void *) 0); + ColorInit(), IC_MODETRAIN_TOO, NULL); /* * MACRO MENU @@ -2622,14 +2857,14 @@ static void CreateMenus(void) { /* tip of the day */ wMenuSeparatorCreate( helpM ); - wMenuPushCreate( helpM, "cmdTip", _("Tip of the Day..."), 0, (wMenuCallBack_p)ShowTip, (void *)(SHOWTIP_FORCESHOW | SHOWTIP_NEXTTIP)); + wMenuPushCreate( helpM, "cmdTip", _("Tip of the Day..."), 0, ShowTip, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_NEXTTIP)); demoM = wMenuMenuCreate( helpM, "cmdDemo", _("&Demos") ); - wMenuPushCreate( helpM, "cmdExamples", _("Examples..."), 0, (wMenuCallBack_p)ChkExamples, (void *)0); + wMenuPushCreate( helpM, "cmdExamples", _("Examples..."), 0, ChkExamples, NULL); /* about window */ wMenuSeparatorCreate(helpM); wMenuPushCreate(helpM, "about", _("About"), 0, - (wMenuCallBack_p) CreateAboutW, NULL); + CreateAboutW, NULL); /* * MANAGE MENU @@ -2645,34 +2880,34 @@ static void CreateMenus(void) { MiscMenuItemCreate(manageM, NULL, "cmdContmgm", _("Layout &Control Elements"), ACCL_CONTMGM, - (void*) ControlMgrInit(), 0, (void*) 0); + ControlMgrInit(), 0, NULL); MiscMenuItemCreate(manageM, NULL, "cmdGroup", _("&Group"), ACCL_GROUP, - (void*) (wMenuCallBack_p) DoGroup, IC_SELECTED, (void *) 0); + DoGroup, IC_SELECTED, NULL); MiscMenuItemCreate(manageM, NULL, "cmdUngroup", _("&Ungroup"), ACCL_UNGROUP, - (void*) (wMenuCallBack_p) DoUngroup, IC_SELECTED, (void *) 0); + DoUngroup, IC_SELECTED, NULL); MiscMenuItemCreate(manageM, NULL, "cmdCustmgm", - _("Custom defined parts..."), ACCL_CUSTMGM, (void*) CustomMgrInit(), - 0, (void *) 0); + _("Custom defined parts..."), ACCL_CUSTMGM, CustomMgrInit(), + 0, NULL); MiscMenuItemCreate(manageM, NULL, "cmdRefreshCompound", _("Update Turnouts and Structures"), 0, - (void*) (wMenuCallBack_p) DoRefreshCompound, 0, (void *) 0); + DoRefreshCompound, 0, NULL); MiscMenuItemCreate(manageM, NULL, "cmdCarInventory", _("Car Inventory"), - ACCL_CARINV, (void*) (wMenuCallBack_p) DoCarDlg, IC_MODETRAIN_TOO, - (void *) 0); + ACCL_CARINV, DoCarDlg, IC_MODETRAIN_TOO, + NULL); wMenuSeparatorCreate(manageM); MiscMenuItemCreate(manageM, NULL, "cmdLayer", _("Layers ..."), ACCL_LAYERS, - (void*) InitLayersDialog(), 0, (void *) 0); + InitLayersDialog(), 0, NULL); wMenuSeparatorCreate(manageM); MiscMenuItemCreate(manageM, NULL, "cmdEnumerate", _("Parts &List ..."), - ACCL_PARTSLIST, (void*) (wMenuCallBack_p) EnumerateTracks, 0, - (void *) 0); + ACCL_PARTSLIST, EnumerateTracks, 0, + NULL); MiscMenuItemCreate(manageM, NULL, "cmdPricelist", _("Price List..."), - ACCL_PRICELIST, (void*) PriceListInit(), 0, (void *) 0); + ACCL_PRICELIST, PriceListInit(), 0, NULL); cmdGroup = BG_LAYER | BG_BIGGAP; @@ -2685,44 +2920,7 @@ static void CreateMenus(void) { cmdGroup = BG_HOTBAR; InitHotBar(); -#ifdef LATER -#ifdef WINDOWS - wAttachAccelKey( wAccelKey_Pgdn, 0, (wAccelKeyCallBack_p)DoZoomUp, (void*)1 ); - wAttachAccelKey( wAccelKey_Pgup, 0, (wAccelKeyCallBack_p)DoZoomDown, (void*)1 ); - wAttachAccelKey( wAccelKey_F5, 0, (wAccelKeyCallBack_p)MainRedraw, (void*)1 ); -#endif - wAttachAccelKey( wAccelKey_Ins, WKEY_CTRL, (wAccelKeyCallBack_p)EditCopy, 0 ); - wAttachAccelKey( wAccelKey_Ins, WKEY_SHIFT, (wAccelKeyCallBack_p)EditPaste, 0 ); - wAttachAccelKey( wAccelKey_Back, WKEY_SHIFT, (wAccelKeyCallBack_p)UndoUndo, 0 ); - wAttachAccelKey( wAccelKey_Del, WKEY_SHIFT, (wAccelKeyCallBack_p)EditCut, 0 ); - wAttachAccelKey( wAccelKey_F6, 0, (wAccelKeyCallBack_p)NextWindow, 0 ); -#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("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); - SetAccelKey("help", wAccelKey_F1, WKEY_SHIFT, - (wAccelKeyCallBack_p) wDoAccelHelp, (void*) 1); - SetAccelKey("help-context", wAccelKey_F1, 0, - (wAccelKeyCallBack_p) wDoAccelHelp, (void*) 3); + SetAccelKeys(); InitBenchDialog(); wPrefGetInteger( "DialogItem", "sticky-set", &stickySet, stickySet ); @@ -2748,21 +2946,23 @@ static void LoadFileList(void) { EXPORT void InitCmdEnumerate(void) { AddToolbarButton("cmdEnumerate", wIconCreatePixMap(partlist_xpm), - IC_SELECTED | IC_ACCLKEY, (addButtonCallBack_t) EnumerateTracks, + IC_SELECTED | IC_ACCLKEY, EnumerateTracks, NULL); } EXPORT void InitCmdExport(void) { ButtonGroupBegin( _("Import/Export"), "cmdExportImportSetCmd", _("Import/Export") ); cmdGroup = BG_EXPORTIMPORT; - AddToolbarButton("cmdExport", wIconCreatePixMap(export_xpm), - IC_SELECTED | IC_ACCLKEY, (addButtonCallBack_t) DoExport, NULL); - AddToolbarButton("cmdExportDXF", wIconCreatePixMap(export_dxf_xpm), IC_SELECTED | IC_ACCLKEY, - (addButtonCallBack_t)DoExportDXF, (void*)1); - AddToolbarButton("cmdImport", wIconCreatePixMap(import_xpm), IC_ACCLKEY, - (addButtonCallBack_t) DoImport, (void*)0); - AddToolbarButton("cmdImportModule", wIconCreatePixMap(importmod_xpm), IC_ACCLKEY, - (addButtonCallBack_t) DoImport, (void*)1); + AddToolbarButton("cmdExport", wIconCreatePixMap(doc_export_xpm[iconSize]), + IC_SELECTED | IC_ACCLKEY, DoExport, NULL); + AddToolbarButton("cmdExportDXF", wIconCreatePixMap(doc_export_dxf_xpm[iconSize]), IC_SELECTED | IC_ACCLKEY, + DoExportDXF, I2VP(1)); + AddToolbarButton("cmdExportBmap", wIconCreatePixMap(doc_export_bmap_xpm[iconSize]), IC_ACCLKEY, + OutputBitMapInit(), NULL); + AddToolbarButton("cmdImport", wIconCreatePixMap(doc_import_xpm[iconSize]), IC_ACCLKEY, + DoImport, I2VP(0)); + AddToolbarButton("cmdImportModule", wIconCreatePixMap(doc_import_xtc_xpm[iconSize]), IC_ACCLKEY, + DoImport, I2VP(1)); ButtonGroupEnd(); } @@ -2813,11 +3013,10 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { long oldToolbarMax; long newToolbarMax; char *cp; - char *oldLocale = NULL; char buffer[STR_SIZE]; unsigned int i; - wPos_t displayWidth; - wPos_t displayHeight; + wWinPix_t displayWidth; + wWinPix_t displayHeight; strcpy(buffer, sProdNameLower); @@ -2828,17 +3027,17 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { InitGettext(); /* Save user locale */ - oldLocale = setlocale(LC_ALL, NULL); - if (oldLocale) - userLocale = strdup(oldLocale); + SetCLocale(); + SetUserLocale(); /* * ARGUMENTS */ opterr = 0; + LogSet("dummy",0); - while ((c = getopt(argc, argv, "vl:d:c:m")) != -1) + while ((c = getopt(argc, argv, "vl:d:c:mV")) != -1) switch (c) { case 'c': /* configuration name */ /* test for valid filename */ @@ -2883,6 +3082,10 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { argv[optind - 1]); exit(1); break; + case 'V': // display version + printf("Version: %s\n",XTRKCAD_VERSION); + exit(0); + break; default: abort(); } @@ -2989,6 +3192,7 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { RotateDialogInit(); MoveDialogInit(); + IndexDialogInit(); wSetSplashInfo(_("Initializing commands")); LOG1(log_init, ( "paramInit\n" )) @@ -3028,7 +3232,8 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { if (toolbarSet&(1<<BG_HOTBAR)) { LayoutHotBar( NULL ); } else { - HideHotBar(); + LayoutHotBar( NULL ); /* Must run once to set it up */ + HideHotBar(); /* Then hide */ } LOG1(log_init, ( "drawInit\n" )) DrawInit(initialZoom); @@ -3041,6 +3246,7 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { if (!ParamFileListInit()) return NULL; + // LOG1(log_init, ("!ParamFileListInit()\n")) curCommand = describeCmdInx; LOG1(log_init, ( "Reset\n" )) @@ -3082,13 +3288,27 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { /* this has to be called before ShowTip() */ InitSmallDlg(); - ShowTip(SHOWTIP_NEXTTIP); + /* Compare the program version and display Beta warning if appropriate */ + pref = wPrefGetString("misc", "version"); + if((!pref) || (strcmp(pref,XTRKCAD_VERSION) != 0)) + { + if(strstr(XTRKCAD_VERSION,"Beta") != NULL) + { + NoticeMessage(MSG_BETA_NOTICE, _("Ok"),NULL, XTRKCAD_VERSION); + } + //else { + // NoticeMessage(_("New version welcome..."),_("Ok"),NULL); + //} + wPrefSetString("misc", "version", XTRKCAD_VERSION); + } + else { + ShowTip(SHOWTIP_NEXTTIP); + } /* check for existing checkpoint file */ resumeWork = FALSE; if (ExistsCheckpoint()) { resumeWork = OfferCheckpoint(); - MainRedraw(); } if (!resumeWork) { @@ -3099,15 +3319,17 @@ EXPORT wWin_p wMain(int argc, char * argv[]) { wPrefGetInteger("misc", "lastlayoutexample", &iExample, 0); bExample = (iExample == 1); } - if (initialFile && strlen(initialFile)) { - DoFileList(0, NULL, initialFile); //Will load Background values, if archive + DoFileList(0, "1", initialFile); //Will load Background values, if archive, leave if (onStartup == 1) LayoutBackGroundInit(TRUE); //Wipe Out Prior Background else LayoutBackGroundInit(FALSE); //Get Prior BackGround - } + } else + LayoutBackGroundInit(TRUE); // If onStartup==1 and no initial file - Wipe Out Prior Background + } + MainRedraw(); inMainW = FALSE; return mainW; } |