Changeset 11 for trunk/settings.cpp


Ignore:
Timestamp:
Feb 21, 2018, 1:01:16 AM (7 years ago)
Author:
Gregg Young
Message:

This changes the bitmap save from an internal bitmap or the use of MMOS2 to using GBM. The save code was adapted from GBMv2 by Heiko Nitzsche and Andy Keys. Also fixed the failure of the file dialog to update the file extension name on the first save after a format changes. Non English resources haven't been updated yet. Several more build error warning fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/settings.cpp

    r2 r11  
    1717 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1818 ***/
    19 
     19#include <direct.h>
    2020#include "settings.h"
    2121#include "ctype.h"
     
    3232USHORT ausDefSSW[7] = { 0 };
    3333
     34#if 0
    3435ImageFormatInfo Settings::ifi[BMF_INVALID] =
    3536{
     
    4849};
    4950
     51#else
     52// pbm and gif don't save anything
     53ImageFormatInfo Settings::ifi[BMF_INVALID] =
     54{
     55    { TRUE, BMF_JPG,  0L, "JPEG Interchange File Format (jpg)", "jpg", "JPG" },
     56    { TRUE, BMF_PNG,  0L, "Portable Network Graphics (png)", "png", "PNG" },
     57    { TRUE, BMF_OS20, 0L, "OS/2 Bitmap 2.0 (bmp)", "bmp", "Bitmap" },
     58    { TRUE, BMF_TIF,  0L, "Microsoft/Aldus Tagged Image File Format (tif)", "tif", "TIFF" },
     59    { TRUE, BMF_TGA,  0L, "Truevision Targa/Vista (tga)", "tga", "Targa" },
     60    { TRUE, BMF_PCX,  0L, "ZSoft PC Paintbrush Image Format (pcx)", "pcx", "PCX" },
     61    { TRUE, BMF_GIF,  0L, "Portable Anymap (pnm)", "pnm", "PNM" },
     62    { TRUE, BMF_PBM,  0L, "Portable Pixel-map (ppm)", "ppm", "PPM" },
     63    { TRUE, BMF_JP2,  0L, "Jpeg 2000 (provided by the Open Source OpenJPEG library) (jp2)", "jp2", "JP2" },
     64    { TRUE, BMF_JBG,  0L, "JBIG Joint Bi-level Image experts Group (jbg)", "jbg", "JBG" },
     65    { TRUE, BMF_RAW,  0L, "Camera RAW Image Format (raw)", "raw", "RAW" },
     66    { TRUE, BMF_DIB,  0L, "Device Independent Bitmap (dib)", "dib", "DIB" }
     67};
     68#endif
     69
    5070PTHTH_SE apse[] =
    5171{
    52     new THTH_SES (SEI_SAVEFILE, "Save", "Filename", "gotcha.bmp"),
    53     new THTH_SES (SEI_FORCESAVEFILE, "Save", "ForceSaveFilename", "force.bmp"),
    54     new THTH_SEL (SEI_SAVESTYLE, "Save", "Style", SAVESTYLE_CLIPBOARD),
    55     new THTH_SEL (SEI_FILEFORMAT, "Save", "FileFormat", BMF_16),
     72    new THTH_SES (SEI_SAVEFILE, "Save", "Filename", "gotcha.png"),
     73    new THTH_SES (SEI_FORCESAVEFILE, "Save", "ForceSaveFilename", "force.png"),
     74    new THTH_SEL (SEI_SAVESTYLE, "Save", "Style", SAVESTYLE_FILE),
     75    new THTH_SEL (SEI_FILEFORMAT, "Save", "FileFormat", BMF_PNG),
    5676    new THTH_SEL (SEI_FILESAVESTYLE, "Save", "FileSaveStyle", FSS_PROMPT),
    5777
     
    133153
    134154        if( pv ) {
    135             if( mmio->pfmmioGetFormats( &mmfi, lNumFormats, pv, &lReturned, 0, 0 )
     155            if( mmioGetFormats( &mmfi, lNumFormats, pv, &lReturned, 0, 0 )
    136156                != MMIO_SUCCESS ) {
    137157                DisplayError( "MMIO-Error",
     
    440460}
    441461
    442 // ** Page1Procedure ****************************************************** /*fold00*/
     462// ** Page1Procedure ****************************************************** /*FOLD00*/
    443463
    444464MRESULT EXPENTRY
     
    494514                           MPFROM2SHORT (0, _MAX_PATH), (MPARAM)0);
    495515
    496 /*        switch (pset->QueryFileFormat ())
    497         {
    498         case BMF_20:
    499             WinSendDlgItemMsg (hwnd, WID_RB_BMF20, BM_CLICK,
    500                                MPFROMSHORT(TRUE), 0);
    501             break;
    502         case BMF_12:
    503             WinSendDlgItemMsg (hwnd, WID_RB_BMF12, BM_CLICK,
    504                                MPFROMSHORT(TRUE), 0);
    505             break;
    506         default:
    507             WinSendDlgItemMsg (hwnd, WID_RB_BMF16, BM_CLICK,
    508                                MPFROMSHORT(TRUE), 0);
    509             break;
    510         } */
    511 
    512516        // Select the appropriate entry in the fileformat-listbox.
    513517        HWND     hwndLB = WinWindowFromID( hwnd, WID_LB_FILEFORMAT );
     
    584588                                           MPFROMLONG( ul ), NULL ) );
    585589            pset->SetFileFormat( SHORT( ul ) );
    586 /*            if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_BMF12),
    587                             BM_QUERYCHECK, 0,0))
    588                 pset->SetFileFormat (BMF_12);
    589             else if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_BMF20),
    590                                  BM_QUERYCHECK, 0,0))
    591                 pset->SetFileFormat (BMF_20);
    592             else
    593                 pset->SetFileFormat (BMF_16); */
     590
     591            pset->SetSaveFile(AddExtensionToFilename(pset->QuerySaveFile()));
     592
    594593#ifdef _DOLOGDEBUG_
    595594            LogDebug( "Page1Procedure: checkpoint 2" );
     
    912911                LogDebug( "Page4Procedure: WM_INITDLG: Doing '%s' ...", findbuf.achName );
    913912#endif
    914                 if ((psz = _getext (findbuf.achName)))
     913                if ((psz = strchr (findbuf.achName, '.')))
    915914                    *psz = '\0';
    916915                findbuf.achName[0] = toupper (findbuf.achName[0]);
     
    10711070}
    10721071
    1073 // ** ReloadResources ***************************************************** /*fold00*/
     1072// ** ReloadResources ***************************************************** /*FOLD00*/
    10741073
    10751074BOOL Settings :: ReloadResources (PSZ psz)
     
    10801079    APIRET  rc;
    10811080
    1082     if ((rc = DosLoadModule(PSZ(NULL), 0, psz, &g_hmod)))
     1081    if ((rc = DosLoadModule(PSZ(NULL), 0, "gotresen.dll", &g_hmod)))
    10831082    {
    10841083        DisplayError("ERROR", "Could not (re)load Gotcha! resource module "
     
    10971096
    10981097    for( int i = 0; i < BMF_INVALID; i++ ) {
    1099         ifi[ i ].label = RSTR ( IDS_BITMAP12INTERNAL+i ); }
     1098        ifi[ i ].label = RSTR ( IDS_BMF_JPG+i ); }
    11001099
    11011100    return TRUE;
     
    11171116}
    11181117
    1119 // ** GetLanguages ******************************************************** /*fold00*/
     1118// ** GetLanguages ******************************************************** /*FOLD00*/
    11201119
    11211120USHORT Settings :: GetLanguages (HWND hwnd)
     
    11371136    {
    11381137        // we don't want the extension
    1139         if ((psz = _getext (findbuf.achName)))
     1138        if ((psz = strchr (findbuf.achName, '.')))
    11401139            *psz = '\0';
    11411140        // try opening the dll and read the version etc. data
     
    11611160}
    11621161
    1163 // ** GetFileExtension **************************************************** /*fold00*/
    1164 
    1165 PSZ Settings :: GetFileExtension( SHORT type = BMF_INVALID )
     1162// ** GetFileExtension **************************************************** /*FOLD00*/
     1163
     1164PSZ Settings :: GetFileExtension( SHORT type )
    11661165{
    11671166    if( type == BMF_INVALID )
    11681167        type = SHORT( QueryFileFormat() );
    1169     if( ( type >= BMF_12 ) && ( type < BMF_INVALID ) )
     1168    if( ( type >= BMF_JPG ) && ( type < BMF_INVALID ) )
    11701169        return ifi[ type ].extension;
    11711170    return "";
    11721171}
    11731172
    1174 // ** GetFOURCC *********************************************************** /*fold00*/
    1175 
    1176 FOURCC Settings :: GetFOURCC( SHORT type = BMF_INVALID )
     1173// ** GetFOURCC *********************************************************** /*FOLD00*/
     1174
     1175FOURCC Settings :: GetFOURCC( SHORT type )
    11771176{
    11781177    if( type == BMF_INVALID )
    11791178        type = SHORT( QueryFileFormat() );
    1180     if( ( type >= BMF_12 ) && ( type < BMF_INVALID ) )
     1179    if( ( type >= BMF_JPG ) && ( type < BMF_INVALID ) )
    11811180        return ifi[ type ].fourcc;
    11821181    return 0L;
    11831182}
    11841183
    1185 // ** GetFileEAType ******************************************************* /*fold00*/
    1186 
    1187 PSZ Settings :: GetFileEAType( SHORT type = BMF_INVALID )
     1184// ** GetFileEAType ******************************************************* /*FOLD00*/
     1185
     1186PSZ Settings :: GetFileEAType( SHORT type )
    11881187{
    11891188    if( type == BMF_INVALID )
    11901189        type = SHORT( QueryFileFormat() );
    1191     if( ( type >= BMF_12 ) && ( type < BMF_INVALID ) )
     1190    if( ( type >= BMF_JPG ) && ( type < BMF_INVALID ) )
    11921191        return ifi[ type ].eaType;
    11931192    return "";
Note: See TracChangeset for help on using the changeset viewer.