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

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

unix.superglobalmegacorp.com

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