summaryrefslogtreecommitdiff
path: root/app/bin/smalldlg.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/bin/smalldlg.c')
-rw-r--r--app/bin/smalldlg.c134
1 files changed, 75 insertions, 59 deletions
diff --git a/app/bin/smalldlg.c b/app/bin/smalldlg.c
index 3d45809..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,7 +18,7 @@
*
* 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 "common.h"
@@ -34,7 +34,6 @@
#include <FreeImage.h>
#endif
-extern char *sTipF;
EXPORT wWin_p aboutW;
static wWin_p tipW; /**< window handle for tip dialog */
@@ -50,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, ShowTip, "prev", PDO_DLGRESETMARGIN, NULL, N_("Previous Tip"), 0L, I2VP(SHOWTIP_FORCESHOW | SHOWTIP_PREVTIP) },
+ { 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 }};
+ { PD_TOGGLE, &showTipAtStart, "showatstart", PDO_DLGCMDBUTTON, tipLabels, NULL, BC_NOBORDER }
+};
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 )
@@ -69,35 +69,38 @@ static void CreateTipW( void )
char *filename;
char * cp;
- tipW = ParamCreateDialog( &tipPG, MakeWindowTitle(_("Tip of the Day")), NULL, NULL, wHide, FALSE, NULL, F_RESIZE|F_CENTER|PD_F_ALT_CANCELLABEL, 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;
@@ -105,23 +108,24 @@ static void CreateTipW( void )
while (*cp=='\\') {
/* put LF at end */
*cp++ = '\n';
-
- /* read a line */
+
+ /* 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 );
@@ -132,7 +136,7 @@ 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
@@ -143,9 +147,8 @@ void ShowTip( void * flagsVP )
{
long flags = VP2L(flagsVP);
long tipNum;
-
- if (showTipAtStart || (flags & SHOWTIP_FORCESHOW))
- {
+
+ if (showTipAtStart || (flags & SHOWTIP_FORCESHOW)) {
if (tipW == NULL) {
CreateTipW();
}
@@ -153,24 +156,26 @@ void ShowTip( void * flagsVP )
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 );
- }
+ }
}
/*--------------------------------------------------------------------*/
@@ -191,43 +196,54 @@ static paramData_t aboutPLs[] = {
};
static paramGroup_t aboutPG = { "about", 0, aboutPLs, COUNT( aboutPLs ) };
-/**
+/**
* Create and show the About window.
*/
void CreateAboutW(void *ptr)
{
- char *copyright = sAboutProd;
+// 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);
+ 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,
+ "\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");
+ wTextAppend(COPYRIGHT_T,
+ "\nThe following software is distributed with XTrackCAD\n\n");
#ifdef WINDOWS
wTextAppend(COPYRIGHT_T, FreeImage_GetCopyrightMessage());
wTextAppend(COPYRIGHT_T, "\n\n");
#endif
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,
+ "\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.");
+ 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);
@@ -238,8 +254,8 @@ void CreateAboutW(void *ptr)
/**
* Initialize the functions for small dialogs.
*/
-
+
void InitSmallDlg( void )
{
- ParamRegister( &tipPG );
-}
+ ParamRegister( &tipPG );
+}