Annotation of hatari/src/gui-sdl/dlgNewDisc.c, revision 1.1

1.1     ! root        1: /*
        !             2:   Hatari - dlgNewDisc.c
        !             3: 
        !             4:   This file is distributed under the GNU Public License, version 2 or at
        !             5:   your option any later version. Read the file gpl.txt for details.
        !             6: */
        !             7: char DlgNewDisc_rcsid[] = "Hatari $Id: dlgNewDisc.c,v 1.1 2003/12/29 20:10:04 thothy Exp $";
        !             8: 
        !             9: #include "main.h"
        !            10: #include "configuration.h"
        !            11: #include "createBlankImage.h"
        !            12: #include "dialog.h"
        !            13: #include "sdlgui.h"
        !            14: #include "memAlloc.h"
        !            15: #include "file.h"
        !            16: 
        !            17: 
        !            18: #define DLGNEWDISC_DECTRACK   3
        !            19: #define DLGNEWDISC_TRACKSTR   4
        !            20: #define DLGNEWDISC_INCTRACK   5
        !            21: #define DLGNEWDISC_SECTORS9   7
        !            22: #define DLGNEWDISC_SECTORS10  8
        !            23: #define DLGNEWDISC_SECTORS11  9
        !            24: #define DLGNEWDISC_SIDES1     11
        !            25: #define DLGNEWDISC_SIDES2     12
        !            26: #define DLGNEWDISC_SAVE       13
        !            27: #define DLGNEWDISC_EXIT       14
        !            28: 
        !            29: static char szTracks[3];
        !            30: static int nTracks = 80;
        !            31: 
        !            32: /* The new disc image dialog: */
        !            33: static SGOBJ newdiscdlg[] =
        !            34: {
        !            35:        { SGBOX, 0, 0, 0,0, 28,12, NULL },
        !            36:        { SGTEXT, 0, 0, 6,1, 16,1, "New floppy image" },
        !            37:        { SGTEXT, 0, 0, 2,3, 7,1, "Tracks:" },
        !            38:        { SGBUTTON, 0, 0, 12,3, 1,1, "\x04" },   /* Left-arrow button  */
        !            39:        { SGTEXT, 0, 0, 14,3, 2,1, szTracks },
        !            40:        { SGBUTTON, 0, 0, 17,3, 1,1, "\x03" },   /* Right-arrow button */
        !            41:        { SGTEXT, 0, 0, 2,5, 8,1, "Sectors:" },
        !            42:        { SGRADIOBUT, 0, SG_SELECTED, 12,5, 4,1, "9" },
        !            43:        { SGRADIOBUT, 0, 0, 17,5, 4,1, "10" },
        !            44:        { SGRADIOBUT, 0, 0, 22,5, 4,1, "11" },
        !            45:        { SGTEXT, 0, 0, 2,7, 6,1, "Sides:" },
        !            46:        { SGRADIOBUT, 0, 0, 12,7, 4,1, "1" },
        !            47:        { SGRADIOBUT, 0, SG_SELECTED, 17,7, 4,1, "2" },
        !            48:        { SGBUTTON, 0, 0, 4,10, 8,1, "Create" },
        !            49:        { SGBUTTON, 0, 0, 18,10, 6,1, "Back" },
        !            50:        { -1, 0, 0, 0,0, 0,0, NULL }
        !            51: };
        !            52: 
        !            53: 
        !            54: /*-----------------------------------------------------------------------*/
        !            55: /*
        !            56:   Show and process the "new blank disc image" dialog.
        !            57: */
        !            58: void DlgNewDisc_Main(void)
        !            59: {
        !            60:        int but;
        !            61:        char *szNewDiscName;
        !            62: 
        !            63:        sprintf(szTracks, "%i", nTracks);
        !            64: 
        !            65:        SDLGui_CenterDlg(newdiscdlg);
        !            66: 
        !            67:        /* Initialize disc image name: */
        !            68:        szNewDiscName = Memory_Alloc(FILENAME_MAX);
        !            69:        strcpy(szNewDiscName, DialogParams.DiscImage.szDiscImageDirectory);
        !            70:        if (strlen(szNewDiscName) < FILENAME_MAX-12)
        !            71:                strcat(szNewDiscName, "new_disc.st");
        !            72: 
        !            73:        /* Draw and process the dialog */
        !            74:        do
        !            75:        {
        !            76:                but = SDLGui_DoDialog(newdiscdlg);
        !            77:                switch(but)
        !            78:                {
        !            79:                 case DLGNEWDISC_DECTRACK:
        !            80:                        if (nTracks > 40)
        !            81:                                nTracks -= 1;
        !            82:                        sprintf(szTracks, "%i", nTracks);
        !            83:                        break;
        !            84:                 case DLGNEWDISC_INCTRACK:
        !            85:                        if (nTracks < 85)
        !            86:                                nTracks += 1;
        !            87:                        sprintf(szTracks, "%i", nTracks);
        !            88:                        break;
        !            89:                 case DLGNEWDISC_SAVE:
        !            90:                        if (SDLGui_FileSelect(szNewDiscName, NULL, TRUE))
        !            91:                        {
        !            92:                                if (!File_DoesFileNameEndWithSlash(szNewDiscName))
        !            93:                                {
        !            94:                                        int nSectors, nSides;
        !            95: 
        !            96:                                        /* Get number of sectors */
        !            97:                                        if (newdiscdlg[DLGNEWDISC_SECTORS11].state & SG_SELECTED)
        !            98:                                                nSectors = 11;
        !            99:                                        else if (newdiscdlg[DLGNEWDISC_SECTORS10].state & SG_SELECTED)
        !           100:                                                nSectors = 10;
        !           101:                                        else
        !           102:                                                nSectors = 9;
        !           103: 
        !           104:                                        /* Get number of sides */
        !           105:                                        if (newdiscdlg[DLGNEWDISC_SIDES1].state & SG_SELECTED)
        !           106:                                                nSides = 1;
        !           107:                                        else
        !           108:                                                nSides = 2;
        !           109: 
        !           110:                                        CreateBlankImage_CreateFile(szNewDiscName, nTracks, nSectors, nSides);
        !           111:                                }
        !           112:                        }
        !           113:                        break;
        !           114:                }
        !           115:        }
        !           116:        while (but != DLGNEWDISC_EXIT && !bQuitProgram);
        !           117: 
        !           118:        Memory_Free(szNewDiscName);
        !           119: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.