diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
commit | df5520aa2dae5b3ce7abf8733dcdd152898af163 (patch) | |
tree | 00d3047bfb14f682bfb5a21010c731ed649bfed7 /app/bin/smalldlg.c | |
parent | df247efec654e512242e4f4f1b0212034f9e01fe (diff) | |
parent | ec3c0f6f6e7153fa797dc57a0e95779cbc63a23b (diff) |
Merge branch 'release/debian/1_5.3.0GA-1'debian/1_5.3.0GA-1
Diffstat (limited to 'app/bin/smalldlg.c')
-rw-r--r-- | app/bin/smalldlg.c | 199 |
1 files changed, 104 insertions, 95 deletions
diff --git a/app/bin/smalldlg.c b/app/bin/smalldlg.c index 1fb5965..1dde15e 100644 --- a/app/bin/smalldlg.c +++ b/app/bin/smalldlg.c @@ -1,5 +1,5 @@ /** \file smalldlg.c - * Several simple and smaller dialogs. + * Several simple and smaller dialogs. */ /* XTrkCad - Model Railroad CAD @@ -18,42 +18,23 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdio.h> -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif -#include <ctype.h> -#include <string.h> -#include <stdlib.h> - -#ifndef WINDOWS -#include <unistd.h> -#include <dirent.h> -#endif -#ifdef WINDOWS -#include <io.h> -#include <windows.h> -#include <FreeImage.h> -#else -#include <sys/stat.h> -#endif - #include "common.h" #include "custom.h" #include "draw.h" #include "fileio.h" -#include "i18n.h" #include "misc.h" #include "paths.h" #include "param.h" #include "smalldlg.h" -#include "wlib.h" -extern char *sTipF; -wWin_p aboutW; +#ifdef WINDOWS +#include <FreeImage.h> +#endif + +EXPORT wWin_p aboutW; static wWin_p tipW; /**< window handle for tip dialog */ static long showTipAtStart = 1; /**< flag for visibility */ @@ -68,16 +49,17 @@ static paramData_t tipPLs[] = { #define I_TIPTEXT (1) #define tipT ((wText_p)tipPLs[I_TIPTEXT].control) { PD_MESSAGE, N_("Did you know..."), NULL, 0, NULL, NULL, BM_LARGE }, - { PD_TEXT, NULL, "text", 0, &tipTextData, NULL, BO_READONLY|BT_TOP|BT_CHARUNITS }, - { PD_BUTTON, (void*)ShowTip, "prev", PDO_DLGRESETMARGIN, NULL, N_("Previous Tip"), 0L, (void *)(SHOWTIP_FORCESHOW | SHOWTIP_PREVTIP) }, - { PD_BUTTON, (void*)ShowTip, "next", PDO_DLGHORZ, NULL, N_("Next Tip"), 0L, (void *)(SHOWTIP_FORCESHOW | SHOWTIP_NEXTTIP) }, - { PD_TOGGLE, &showTipAtStart, "showatstart", PDO_DLGCMDBUTTON, tipLabels, NULL, BC_NOBORDER }}; + { PD_TEXT, NULL, "text", PDO_DLGRESIZE, &tipTextData, NULL, BO_READONLY|BT_TOP|BT_CHARUNITS }, + { PD_BUTTON, ShowTip, "prev", PDO_DLGRESETMARGIN, NULL, N_("Previous Tip"), 0L, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_PREVTIP) }, + { PD_BUTTON, ShowTip, "next", PDO_DLGHORZ, NULL, N_("Next Tip"), 0L, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_NEXTTIP) }, + { PD_TOGGLE, &showTipAtStart, "showatstart", PDO_DLGCMDBUTTON, tipLabels, NULL, BC_NOBORDER } +}; -static paramGroup_t tipPG = { "tip", 0, tipPLs, sizeof tipPLs/sizeof tipPLs[0] }; +static paramGroup_t tipPG = { "tip", 0, tipPLs, COUNT( tipPLs ) }; /** * Create and initialize the tip of the day window. The dialog box is created and the list of tips is loaded - * into memory. + * into memory. */ static void CreateTipW( void ) @@ -87,35 +69,38 @@ static void CreateTipW( void ) char *filename; char * cp; - tipW = ParamCreateDialog( &tipPG, MakeWindowTitle(_("Tip of the Day")), _("Ok"), (paramActionOkProc)wHide, wHide, FALSE, NULL, F_RESIZE|F_CENTER, NULL ); + tipW = ParamCreateDialog( &tipPG, MakeWindowTitle(_("Tip of the Day")), NULL, + NULL, wHide, FALSE, NULL, F_RESIZE|F_CENTER|PD_F_ALT_CANCELLABEL, NULL ); /* open the tip file */ MakeFullpath(&filename, libDir, sTipF, NULL); tipF = fopen( filename, "r" ); - + /* if tip file could not be opened, the only tip is an error message for the situation */ if (tipF == NULL) { DYNARR_APPEND( char *, tips_da, 1 ); tips(0) = N_("No tips are available"); -/* TODO: enable buttons only if tips are available - wControlActive( prev, FALSE ); - wControlActive( next, FALSE ); */ + /* TODO: enable buttons only if tips are available + wControlActive( prev, FALSE ); + wControlActive( next, FALSE ); */ } else { /* read all the tips from the file */ while (fgets( buff, sizeof buff, tipF )) { /* lines starting with hash sign are ignored (comments) */ - if (buff[0] == '#') + if (buff[0] == '#') { continue; - - /* remove CRs and LFs at end of line */ + } + + /* remove CRs and LFs at end of line */ cp = buff+strlen(buff)-1; - if (*cp=='\n') cp--; - if (*cp=='\r') cp--; - + if (*cp=='\n') { cp--; } + if (*cp=='\r') { cp--; } + /* get next line if the line was empty */ - if (cp < buff) + if (cp < buff) { continue; + } cp[1] = 0; @@ -123,23 +108,24 @@ static void CreateTipW( void ) while (*cp=='\\') { /* put LF at end */ *cp++ = '\n'; - - /* read a line */ - if (!fgets( cp, (sizeof buff) - (cp-buff), tipF )) { + + /* read a line */ + if (!fgets( cp, (int)((sizeof buff) - (cp-buff)), tipF )) { return; } - + /* lines starting with hash sign are ignored (comments) */ - if (*cp=='#') + if (*cp=='#') { continue; + } - /* remove CRs and LFs at end of line */ + /* remove CRs and LFs at end of line */ cp += strlen(cp)-1; - if (*cp=='\n') cp--; - if (*cp=='\r') cp--; + if (*cp=='\n') { cp--; } + if (*cp=='\r') { cp--; } cp[1] = 0; } - + /* allocate memory for the tip and store pointer in dynamic array */ DYNARR_APPEND( char *, tips_da, 10 ); tips(tips_da.cnt-1) = strdup( buff ); @@ -150,19 +136,19 @@ static void CreateTipW( void ) /** * Show tip of the day. As far as necessary, the dialog is created. The index of - * the last tip shown is retrieved from the preferences and the next tip is + * the last tip shown is retrieved from the preferences and the next tip is * selected. At the end, the index of the shown tip is saved into the preferences. * * \param IN flags see definitions in smalldlg.h for possible values * */ -void ShowTip( long flags ) +void ShowTip( void * flagsVP ) { + long flags = VP2L(flagsVP); long tipNum; - - if (showTipAtStart || (flags & SHOWTIP_FORCESHOW)) - { + + if (showTipAtStart || (flags & SHOWTIP_FORCESHOW)) { if (tipW == NULL) { CreateTipW(); } @@ -170,24 +156,26 @@ void ShowTip( long flags ) wTextClear( tipT ); /* initial value is -1 which gets incremented 0 below */ wPrefGetInteger( "misc", "tip-number", &tipNum, -1 ); - + if( flags & SHOWTIP_PREVTIP ) { - if(tipNum == 0 ) + if(tipNum == 0 ) { tipNum = tips_da.cnt - 1; - else - tipNum--; + } else { + tipNum--; + } } else { - if (tipNum >= tips_da.cnt - 1) + if (tipNum >= tips_da.cnt - 1) { tipNum = 0; - else - tipNum++; - } + } else { + tipNum++; + } + } wTextAppend( tipT, _(tips(tipNum)) ); wPrefSetInteger( "misc", "tip-number", tipNum ); wShow( tipW ); - } + } } /*--------------------------------------------------------------------*/ @@ -206,47 +194,68 @@ static paramData_t aboutPLs[] = { #define COPYRIGHT_T ((wText_p)aboutPLs[I_COPYRIGHT].control) { PD_TEXT, NULL, NULL, PDO_DLGRESIZE, &aboutTextData, NULL, BO_READONLY|BT_TOP|BT_CHARUNITS } }; -static paramGroup_t aboutPG = { "about", 0, aboutPLs, sizeof aboutPLs/sizeof aboutPLs[0] }; +static paramGroup_t aboutPG = { "about", 0, aboutPLs, COUNT( aboutPLs ) }; -/** +/** * Create and show the About window. */ -void CreateAboutW( void *ptr ) +void CreateAboutW(void *ptr) { - char *copyright = sAboutProd; - - if( !aboutW ) { - aboutPLs[I_ABOUTDRAW].winData = wIconCreatePixMap( xtc_xpm ); - ParamRegister( &aboutPG ); - aboutW = ParamCreateDialog( &aboutPG, MakeWindowTitle(_("About")), _("Ok"), (paramActionOkProc)wHide, wHide, FALSE, NULL, F_TOP|F_CENTER, NULL ); - ParamLoadMessage( &aboutPG, I_ABOUTVERSION, sAboutProd ); - wTextAppend( COPYRIGHT_T, DESCRIPTION ); - wTextAppend( COPYRIGHT_T, "\n\nXTrackCAD is Copyright 2003 by Sillub Technology and 2017 by Bob Blackwell, Martin Fischer and Adam Richards." ); - wTextAppend( COPYRIGHT_T, "\nIcons by: Tango Desktop Project (http://tango.freedesktop.org)"); - wTextAppend(COPYRIGHT_T, "\nSome icons by Yusuke Kamiyamane. Licensed under a Creative Commons Attribution 3.0 License."); - wTextAppend( COPYRIGHT_T, "\nContributions by: Robert Heller, Mikko Nissinen, Timothy M. Shead, Daniel Luis Spagnol" ); - wTextAppend( COPYRIGHT_T, "\nParameter Files by: Ralph Boyd, Dwayne Ward" ); +// char *copyright = sAboutProd; + + if (!aboutW) { + aboutPLs[I_ABOUTDRAW].winData = wIconCreatePixMap(xtc_xpm); + ParamRegister(&aboutPG); + aboutW = ParamCreateDialog(&aboutPG, MakeWindowTitle(_("About")), NULL, NULL, + wHide, FALSE, NULL, F_TOP | F_CENTER| PD_F_ALT_CANCELLABEL, NULL); + ParamLoadMessage(&aboutPG, I_ABOUTVERSION, sAboutProd); + wTextAppend(COPYRIGHT_T, DESCRIPTION); + wTextAppend(COPYRIGHT_T, + "\n\nXTrackCAD is Copyright 2003 by Sillub Technology and 2017 by Bob Blackwell, Martin Fischer and Adam Richards.\n"); + wTextAppend(COPYRIGHT_T, + "\nIcons by: Tango Desktop Project (http://tango.freedesktop.org)\n"); + wTextAppend(COPYRIGHT_T, + "\nSome icons by Yusuke Kamiyamane. Licensed under a Creative Commons Attribution 3.0 License.\n"); + wTextAppend(COPYRIGHT_T, + "\nContributions by: Robert Heller, Mikko Nissinen, Timothy M. Shead, Russell Shilling, Daniel Luis Spagnol"); + wTextAppend(COPYRIGHT_T, "\nParameter Files by: Ralph Boyd, Dwayne Ward\n"); + + wTextAppend(COPYRIGHT_T, + "\nThe following software is distributed with XTrackCAD\n\n"); #ifdef WINDOWS - wTextAppend(COPYRIGHT_T, "\n"); wTextAppend(COPYRIGHT_T, FreeImage_GetCopyrightMessage()); + wTextAppend(COPYRIGHT_T, "\n\n"); #endif - wTextAppend( COPYRIGHT_T, "\nCornu Algorithm and Implementation by: Raph Levien"); - wTextAppend( COPYRIGHT_T, "\nuthash Copyright notice:" ); - wTextAppend( COPYRIGHT_T, "\nCopyright (c) 2005-2015, Troy D. Hanson http://troydhanson.github.com/uthash/"); - wTextAppend( COPYRIGHT_T, "\nAll rights reserved."); - } - - wShow( aboutW ); -} + wTextAppend(COPYRIGHT_T, "Cornu Algorithm and Implementation by: Raph Levien"); + wTextAppend(COPYRIGHT_T, "\n\nuthash, utlist Copyright notice:"); + wTextAppend(COPYRIGHT_T, + "\nCopyright (c) 2005-2015, Troy D. Hanson http://troydhanson.github.com/uthash/"); + wTextAppend(COPYRIGHT_T, "\nAll rights reserved."); + + wTextAppend(COPYRIGHT_T, + "\n\ncJSON: Copyright (c) 2009-2017 Dave Gamble and cJSON contributors"); + wTextAppend(COPYRIGHT_T, + "\n\nlibzip: Copyright(C) 1999 - 2019 Dieter Baron and Thomas Klausner\n" \ + "The authors can be contacted at libzip@nih.at"); + + wTextAppend(COPYRIGHT_T, + "\n\nMiniXML: Copyright (c) 2003-2019 by Michael R Sweet.\n" \ + "The Mini - XML library is licensed under the Apache License Version 2.0 with an\n" + \ + "exception to allow linking against GPL2 / LGPL2 - only software."); + } + + wShow(aboutW); +} /*--------------------------------------------------------------------*/ /** * Initialize the functions for small dialogs. */ - + void InitSmallDlg( void ) { - ParamRegister( &tipPG ); -} + ParamRegister( &tipPG ); +} |