diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-12-28 20:24:50 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-12-28 20:24:50 +0100 |
commit | 09795a01ef859f072920de9df974d1b03b9ab9a4 (patch) | |
tree | 4d05907fc37f1bd781e506f5e196f7435aeec0ab /app/wlib/mswlib | |
parent | 5b4163d8c76b03f0d31b09866aa4bd06b4d8d804 (diff) |
New upstream version 4.2.4aupstream/4.2.4a
Diffstat (limited to 'app/wlib/mswlib')
-rw-r--r-- | app/wlib/mswlib/mswbutt.c | 14 | ||||
-rw-r--r-- | app/wlib/mswlib/mswlist.c | 35 | ||||
-rw-r--r-- | app/wlib/mswlib/mswmenu.c | 71 | ||||
-rw-r--r-- | app/wlib/mswlib/mswmisc.c | 62 | ||||
-rw-r--r-- | app/wlib/mswlib/simple-gettext.c | 7 |
5 files changed, 168 insertions, 21 deletions
diff --git a/app/wlib/mswlib/mswbutt.c b/app/wlib/mswlib/mswbutt.c index b5d7b49..24e669f 100644 --- a/app/wlib/mswlib/mswbutt.c +++ b/app/wlib/mswlib/mswbutt.c @@ -257,7 +257,7 @@ static void buttDone( free(b); } -long FAR PASCAL _export pushButt( +LRESULT CALLBACK pushButt( HWND hWnd, UINT message, UINT wParam, @@ -301,9 +301,10 @@ long FAR PASCAL _export pushButt( InvalidateRect( b->hWnd, NULL, TRUE ); return 0L; break; - case WM_ERASEBKGND: - if (kludge12) - return 1L; + case WM_LBUTTONUP: + /* don't know why but this solves a problem with color selection */ + Sleep( 0 ); + break; } return CallWindowProc( oldButtProc, hWnd, message, wParam, lParam ); } @@ -372,9 +373,8 @@ wButton_p wButtonCreate( b->action = action; mswCallBacks[B_BUTTON] = &buttonCallBacks; mswChainFocus( (wControl_p)b ); - newButtProc = MakeProcInstance( (XWNDPROC)pushButt, mswHInst ); - oldButtProc = (XWNDPROC)GetWindowLong( b->hWnd, GWL_WNDPROC ); - SetWindowLong( b->hWnd, GWL_WNDPROC, (LONG)newButtProc ); + + oldButtProc = (WNDPROC) SetWindowLongPtr(b->hWnd, GWL_WNDPROC, (LONG_PTR)&pushButt); if (mswPalette) { hDc = GetDC( b->hWnd ); SelectPalette( hDc, mswPalette, 0 ); diff --git a/app/wlib/mswlib/mswlist.c b/app/wlib/mswlib/mswlist.c index 968624a..18fa92d 100644 --- a/app/wlib/mswlib/mswlist.c +++ b/app/wlib/mswlib/mswlist.c @@ -285,6 +285,39 @@ void wListDelete( } +/** + * Select all items in list. + * + * \param bl IN list handle + * \return + */ + +void wListSelectAll( wList_p bl ) +{ + wIndex_t inx; + listData *ldp; + + // mark all items selected + SendMessage( bl->hWnd, + LB_SETSEL, + (WPARAM)TRUE, + (DWORD)-1L ); + + // and synchronize the internal data structures + wListGetCount(bl); + for ( inx=0; inx<bl->count; inx++ ) { + ldp = (listData*)SendMessage( bl->hWnd, + (bl->type==B_LIST?LB_GETITEMDATA:CB_GETITEMDATA), + inx, 0L ); + ldp->selected = TRUE; + SendMessage( bl->hWnd, + (UINT)bl->type==B_LIST?LB_SETITEMDATA:CB_SETITEMDATA, + (WPARAM)inx, + (DWORD)ldp ); + } +} + + wIndex_t wListGetCount( wList_p bl ) { @@ -333,6 +366,8 @@ wIndex_t wListGetSelectedCount( } + + wIndex_t wListAddValue( wList_p b, const char * value, diff --git a/app/wlib/mswlib/mswmenu.c b/app/wlib/mswlib/mswmenu.c index 15053a2..de49742 100644 --- a/app/wlib/mswlib/mswmenu.c +++ b/app/wlib/mswlib/mswmenu.c @@ -1,3 +1,26 @@ +/** \file mswmenu.c + * Pulldown menu creation and handling + * \todo Code for accelerator keys was copied and pasted, replace with utility function + */ + +/* XTrkCad - Model Railroad CAD + * Copyright (C) (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ + #define OEMRESOURCE #include <windows.h> @@ -9,6 +32,7 @@ #include <ctype.h> #include <assert.h> #include "mswint.h" +#include "i18n.h" /* ***************************************************************************** @@ -834,6 +858,11 @@ wMenuToggle_p wMenuToggleCreate( { wMenuToggle_p mt; int rc; + char label[80]; + char *cp; + char ac; + UINT vk; + long modifier; mt = (wMenuToggle_p)createMenuItem( m, M_TOGGLE, helpStr, labelStr, sizeof *mt ); /*setAcclKey( m->parent, m->menu, mt->menu_item, acclKey );*/ @@ -842,7 +871,47 @@ wMenuToggle_p wMenuToggleCreate( mt->mparent = m; mt->enabled = TRUE; mt->parentMenu = m; - rc = AppendMenu( m->menu, MF_STRING, mt->index, labelStr ); + strcpy( label, mt->labelStr ); + modifier = 0; + + if ( acclKey != 0 ) { + DYNARR_APPEND( acclTable_t, acclTable_da, 10 ); + cp = label + strlen( label ); + *cp++ = '\t'; + if (acclKey & WCTL ) { + strcpy( cp, _("Ctrl+") ); +// cp += 5; + modifier |= WKEY_CTRL; + } + if (acclKey & WALT ) { + strcpy( cp, _("Alt+") ); +// cp += 4; + modifier |= WKEY_ALT; + } + if (acclKey & WSHIFT ) { + strcpy( cp, _("Shift+") ); +// cp += 6; + modifier |= WKEY_SHIFT; + } + cp = label + strlen( label ); + if( ((char)acclKey & 0xFF ) == ' ' ) { + strcat( label, _("Space") ); + } else { + *cp++ = toupper( (char)(acclKey & 0xFF) ); + *cp++ = '\0'; + } + ac = (char)(acclKey & 0xFF); + if (isalpha(ac)) { + ac = tolower( ac ); + } + vk = VkKeyScan( ac ); + if ( vk & 0xFF00 ) + modifier |= WKEY_SHIFT; + acclTable(acclTable_da.cnt-1).acclKey = (modifier<<8) | (vk&0x00FF); + acclTable(acclTable_da.cnt-1).mp = mt; + } + + rc = AppendMenu( m->menu, MF_STRING, mt->index, label ); wMenuToggleSet( mt, set ); return mt; } diff --git a/app/wlib/mswlib/mswmisc.c b/app/wlib/mswlib/mswmisc.c index fc1dbe6..85438e0 100644 --- a/app/wlib/mswlib/mswmisc.c +++ b/app/wlib/mswlib/mswmisc.c @@ -1,7 +1,5 @@ /** \file mswmisc.c * Basic windows functions and main entry point for application. - * - * $Header: /home/dmarkle/xtrkcad-fork-cvs/xtrkcad/app/wlib/mswlib/mswmisc.c,v 1.28 2010-04-28 04:04:38 dspagnol Exp $ */ /* XTrkCad - Model Railroad CAD @@ -2003,13 +2001,26 @@ static char selFileName[1024]; static char selFileTitle[1024]; static char sysDirName[1024]; +/** + * Run the file selector. After the selector is finished an array of filenames is + * created. Each filename will be fully qualified. The array and the number of + * filenames are passed to a callback function. This is similar to the argc argv c + * convention in C. Once the callback returns, the allocated strings are free'd. + * + * \param fs IN the file selector dialog + * \param dirName IN the initial directory presented + * \return FALSE on error, TRUE if ok + */ + int wFilSelect( struct wFilSel_t * fs, const char * dirName ) { int rc; OPENFILENAME ofn; - char * fileName; + char **fileName; + char *nextFileName; + int cntFiles; const char * ext; char defExt[4]; int i; @@ -2024,7 +2035,7 @@ int wFilSelect( ofn.hwndOwner = mswHWnd; ofn.lpstrFilter = fs->extList; ofn.nFilterIndex = 0; - selFileName[0] = '\0'; + memset( selFileName, '\0', sizeof(selFileName)); ofn.lpstrFile = selFileName; ofn.nMaxFile = sizeof selFileName; selFileTitle[0] = '\0'; @@ -2041,7 +2052,13 @@ int wFilSelect( defExt[0] = '\0'; } ofn.lpstrDefExt = defExt; - ofn.Flags |= OFN_LONGFILENAMES; + + if ( fs->option & FS_MULTIPLEFILES ) { + ofn.Flags = OFN_ALLOWMULTISELECT | OFN_LONGFILENAMES | OFN_EXPLORER; + } else { + ofn.Flags = OFN_LONGFILENAMES; + } + if (fs->mode == FS_LOAD) { ofn.Flags |= OFN_FILEMUSTEXIST; rc = GetOpenFileName( &ofn ); @@ -2054,12 +2071,37 @@ int wFilSelect( return FALSE; if (!rc) return FALSE; - fileName = strrchr( selFileName, '\\' ); - if (fileName == NULL) { - mswFail( "wFilSelect: cant extract fileName" ); - return FALSE; + + nextFileName = selFileName; + selFileName[ofn.nFileOffset - 1] = '\0'; + cntFiles = 0; + + while (*nextFileName) { + cntFiles++; + nextFileName = nextFileName + strlen( nextFileName ) + 1; + } + + // strings were counted including the path on its own so reduce the count + cntFiles--; + + // build up the array of filenames + fileName = malloc(sizeof(nextFileName) * cntFiles); + nextFileName = selFileName + ofn.nFileOffset; + for ( i=0; i < cntFiles; i++) { + fileName[ i ] = malloc(strlen(selFileName) + strlen(nextFileName) + 2 ); + strcpy(fileName[ i ], selFileName); + strcat(fileName[ i ], FILE_SEP_CHAR); + strcat(fileName[ i ], nextFileName); + nextFileName = nextFileName + strlen( nextFileName ) + 1; } - fs->action( selFileName, fileName+1, fs->data ); + + fs->action( cntFiles, fileName, fs->data ); + + for (i=0; i < cntFiles; i++) { + free( fileName[ i ] ); + } + free( fileName ); + return TRUE; } diff --git a/app/wlib/mswlib/simple-gettext.c b/app/wlib/mswlib/simple-gettext.c index 295d515..d213fc3 100644 --- a/app/wlib/mswlib/simple-gettext.c +++ b/app/wlib/mswlib/simple-gettext.c @@ -1,4 +1,5 @@ -/* simple-gettext.c - a simplified version of gettext. +/* \file simple-gettext.c + * a simplified version of gettext. * Copyright (C) 1995, 1996, 1997, 1999, * 2005 Free Software Foundation, Inc. * @@ -378,7 +379,7 @@ get_string( struct loaded_domain *domain, u32 idx ) */ char * -gettext( char *msgid ) +gettext( const char *msgid ) { struct loaded_domain *domain; size_t act = 0; @@ -446,7 +447,7 @@ gettext( char *msgid ) } not_found: - return msgid; + return (char *)msgid; } /** |