Annotation of hatari/src/gui-sdl/dlgDevice.c, revision 1.1.1.2

1.1       root        1: /*
                      2:   Hatari - dlgDevice.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:   Device (Printer etc.) setup dialog
                      8: */
1.1.1.2 ! root        9: char DlgDevice_rcsid[] = "Hatari $Id: dlgDevice.c,v 1.7 2005/02/13 16:18:52 thothy Exp $";
1.1       root       10: 
                     11: #include "main.h"
                     12: #include "configuration.h"
                     13: #include "dialog.h"
                     14: #include "sdlgui.h"
                     15: #include "file.h"
                     16: #include "screen.h"
                     17: 
                     18: 
                     19: #define DEVDLG_PRNENABLE       3
                     20: #define DEVDLG_PRNBROWSE       4
                     21: #define DEVDLG_PRNFILENAME     6
                     22: #define DEVDLG_RS232ENABLE     8
                     23: #define DEVDLG_RS232OUTBROWSE  10
                     24: #define DEVDLG_RS232OUTNAME    11
                     25: #define DEVDLG_RS232INBROWSE   13
                     26: #define DEVDLG_RS232INNAME     14
                     27: #define DEVDLG_MIDIENABLE      16
                     28: #define DEVDLG_MIDIBROWSE      18
                     29: #define DEVDLG_MIDIOUTNAME     19
                     30: #define DEVDLG_EXIT            20
                     31: 
                     32: 
                     33: static char dlgPrinterName[46+1];
                     34: static char dlgRs232OutName[46+1];
                     35: static char dlgRs232InName[46+1];
                     36: static char dlgMidiOutName[46+1];
                     37: 
                     38: 
                     39: /* The devices dialog: */
                     40: static SGOBJ devicedlg[] =
                     41: {
                     42:        { SGBOX, 0, 0, 0,0, 52,22, NULL },
                     43:        { SGTEXT, 0, 0, 20,1, 13,1, "Devices setup" },
                     44: 
                     45:        { SGBOX, 0, 0, 1,3, 50,4, NULL },
                     46:        { SGCHECKBOX, 0, 0, 2,3, 28,1, "Enable printer emulation" },
                     47:        { SGTEXT, 0, 0, 2,5, 10,1, "Print to file:" },
                     48:        { SGBUTTON, 0, 0, 42,5, 8,1, "Browse" },
                     49:        { SGTEXT, 0, 0, 3,6, 46,1, dlgPrinterName },
                     50: 
                     51:        { SGBOX, 0, 0, 1,8, 50,6, NULL },
                     52:        { SGCHECKBOX, 0, 0, 2,8, 28,1, "Enable RS232 emulation" },
                     53:        { SGTEXT, 0, 0, 2,10, 10,1, "Write RS232 output to file:" },
                     54:        { SGBUTTON, 0, 0, 42,10, 8,1, "Browse" },
                     55:        { SGTEXT, 0, 0, 3,11, 46,1, dlgRs232OutName },
                     56:        { SGTEXT, 0, 0, 2,12, 10,1, "Read RS232 input from file:" },
                     57:        { SGBUTTON, 0, 0, 42,12, 8,1, "Browse" },
                     58:        { SGTEXT, 0, 0, 3,13, 46,1, dlgRs232InName },
                     59: 
                     60:        { SGBOX, 0, 0, 1,15, 50,4, NULL },
                     61:        { SGCHECKBOX, 0, 0, 2,15, 28,1, "Enable MIDI emulation" },
                     62:        { SGTEXT, 0, 0, 2,17, 10,1, "Write MIDI output to file:" },
                     63:        { SGBUTTON, 0, 0, 42,17, 8,1, "Browse" },
                     64:        { SGTEXT, 0, 0, 3,18, 46,1, dlgMidiOutName },
                     65: 
                     66:        { SGBUTTON, 0, 0, 16,20, 20,1, "Back to main menu" },
                     67:        { -1, 0, 0, 0,0, 0,0, NULL }
                     68: };
                     69: 
                     70: 
                     71: /*-----------------------------------------------------------------------*/
                     72: /*
                     73:   Show and process the "Device" dialog.
                     74: */
                     75: void Dialog_DeviceDlg(void)
                     76: {
                     77:        int but;
                     78:        char *tmpname;
                     79: 
                     80:        /* Allocate memory for tmpname: */
1.1.1.2 ! root       81:        tmpname = malloc(FILENAME_MAX);
        !            82:        if (!tmpname)
        !            83:        {
        !            84:                perror("Dialog_DeviceDlg");
        !            85:                return;
        !            86:        }
1.1       root       87: 
                     88:        SDLGui_CenterDlg(devicedlg);
                     89: 
                     90:        /* Set up dialog from actual values: */
                     91: 
                     92:        if (DialogParams.Printer.bEnablePrinting)
                     93:                devicedlg[DEVDLG_PRNENABLE].state |= SG_SELECTED;
                     94:        else
                     95:                devicedlg[DEVDLG_PRNENABLE].state &= ~SG_SELECTED;
                     96:        File_ShrinkName(dlgPrinterName, DialogParams.Printer.szPrintToFileName, devicedlg[DEVDLG_PRNFILENAME].w);
                     97: 
                     98:        if (DialogParams.RS232.bEnableRS232)
                     99:                devicedlg[DEVDLG_RS232ENABLE].state |= SG_SELECTED;
                    100:        else
                    101:                devicedlg[DEVDLG_RS232ENABLE].state &= ~SG_SELECTED;
                    102:        File_ShrinkName(dlgRs232OutName, DialogParams.RS232.szOutFileName, devicedlg[DEVDLG_RS232OUTNAME].w);
                    103:        File_ShrinkName(dlgRs232InName, DialogParams.RS232.szInFileName, devicedlg[DEVDLG_RS232INNAME].w);
                    104: 
                    105:        if (DialogParams.Midi.bEnableMidi)
                    106:                devicedlg[DEVDLG_MIDIENABLE].state |= SG_SELECTED;
                    107:        else
                    108:                devicedlg[DEVDLG_MIDIENABLE].state &= ~SG_SELECTED;
                    109:        File_ShrinkName(dlgMidiOutName, DialogParams.Midi.szMidiOutFileName, devicedlg[DEVDLG_MIDIOUTNAME].w);
                    110: 
                    111:        /* The devices dialog main loop */
                    112:        do
                    113:        {
1.1.1.2 ! root      114:                but = SDLGui_DoDialog(devicedlg, NULL);
1.1       root      115: 
                    116:                switch(but)
                    117:                {
                    118:                 case DEVDLG_PRNBROWSE:                 /* Choose a new printer file */
                    119:                        strcpy(tmpname, DialogParams.Printer.szPrintToFileName);
                    120:                        if (SDLGui_FileSelect(tmpname, NULL, TRUE))
                    121:                        {
                    122:                                if (!File_DoesFileNameEndWithSlash(tmpname))
                    123:                                {
                    124:                                        strcpy(DialogParams.Printer.szPrintToFileName, tmpname);
                    125:                                        File_ShrinkName(dlgPrinterName, tmpname, devicedlg[DEVDLG_PRNFILENAME].w);
                    126:                                }
                    127:                        }
                    128:                        break;
                    129:                 case DEVDLG_RS232OUTBROWSE:            /* Choose a new RS232 output file */
                    130:                        strcpy(tmpname, DialogParams.RS232.szOutFileName);
                    131:                        if (SDLGui_FileSelect(tmpname, NULL, TRUE))
                    132:                        {
                    133:                                if (!File_DoesFileNameEndWithSlash(tmpname))
                    134:                                {
                    135:                                        strcpy(DialogParams.RS232.szOutFileName, tmpname);
                    136:                                        File_ShrinkName(dlgRs232OutName, tmpname, devicedlg[DEVDLG_RS232OUTNAME].w);
                    137:                                }
                    138:                        }
                    139:                        break;
                    140:                 case DEVDLG_RS232INBROWSE:             /* Choose a new RS232 input file */
                    141:                        strcpy(tmpname, DialogParams.RS232.szInFileName);
                    142:                        if (SDLGui_FileSelect(tmpname, NULL, TRUE))
                    143:                        {
                    144:                                if (!File_DoesFileNameEndWithSlash(tmpname))
                    145:                                {
                    146:                                        strcpy(DialogParams.RS232.szInFileName, tmpname);
                    147:                                        File_ShrinkName(dlgRs232InName, tmpname, devicedlg[DEVDLG_RS232INNAME].w);
                    148:                                }
                    149:                        }
                    150:                        break;
                    151:                 case DEVDLG_MIDIBROWSE:                /* Choose a new MIDI file */
                    152:                        strcpy(tmpname, DialogParams.Midi.szMidiOutFileName);
                    153:                        if (SDLGui_FileSelect(tmpname, NULL, TRUE))
                    154:                        {
                    155:                                if (!File_DoesFileNameEndWithSlash(tmpname))
                    156:                                {
                    157:                                        strcpy(DialogParams.Midi.szMidiOutFileName, tmpname);
                    158:                                        File_ShrinkName(dlgMidiOutName, tmpname, devicedlg[DEVDLG_MIDIOUTNAME].w);
                    159:                                }
                    160:                        }
                    161:                        break;
                    162:                }
                    163:        }
1.1.1.2 ! root      164:        while (but != DEVDLG_EXIT && but != SDLGUI_QUIT && !bQuitProgram);
1.1       root      165: 
                    166:        /* Read values from dialog */
                    167:        DialogParams.Printer.bEnablePrinting = (devicedlg[DEVDLG_PRNENABLE].state & SG_SELECTED);
                    168:        DialogParams.RS232.bEnableRS232 = (devicedlg[DEVDLG_RS232ENABLE].state & SG_SELECTED);
                    169:        DialogParams.Midi.bEnableMidi = (devicedlg[DEVDLG_MIDIENABLE].state & SG_SELECTED);
                    170: 
1.1.1.2 ! root      171:        free(tmpname);
1.1       root      172: }

unix.superglobalmegacorp.com

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