|
|
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.5 ! root 9: const char DlgDevice_rcsid[] = "Hatari $Id: dlgDevice.c,v 1.13 2008/06/08 16:07:39 eerot 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
1.1.1.3 root 20: #define DEVDLG_PRNBROWSE 5
1.1 root 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:
1.1.1.4 root 33: #define MAX_DLG_FILENAME 46+1
34: static char dlgPrinterName[MAX_DLG_FILENAME];
35: static char dlgRs232OutName[MAX_DLG_FILENAME];
36: static char dlgRs232InName[MAX_DLG_FILENAME];
37: static char dlgMidiOutName[MAX_DLG_FILENAME];
1.1 root 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:
1.1.1.4 root 66: { SGBUTTON, SG_DEFAULT, 0, 16,20, 20,1, "Back to main menu" },
1.1 root 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:
79: SDLGui_CenterDlg(devicedlg);
80:
81: /* Set up dialog from actual values: */
82:
1.1.1.5 ! root 83: if (ConfigureParams.Printer.bEnablePrinting)
1.1 root 84: devicedlg[DEVDLG_PRNENABLE].state |= SG_SELECTED;
85: else
86: devicedlg[DEVDLG_PRNENABLE].state &= ~SG_SELECTED;
1.1.1.5 ! root 87: File_ShrinkName(dlgPrinterName, ConfigureParams.Printer.szPrintToFileName, devicedlg[DEVDLG_PRNFILENAME].w);
1.1 root 88:
1.1.1.5 ! root 89: if (ConfigureParams.RS232.bEnableRS232)
1.1 root 90: devicedlg[DEVDLG_RS232ENABLE].state |= SG_SELECTED;
91: else
92: devicedlg[DEVDLG_RS232ENABLE].state &= ~SG_SELECTED;
1.1.1.5 ! root 93: File_ShrinkName(dlgRs232OutName, ConfigureParams.RS232.szOutFileName, devicedlg[DEVDLG_RS232OUTNAME].w);
! 94: File_ShrinkName(dlgRs232InName, ConfigureParams.RS232.szInFileName, devicedlg[DEVDLG_RS232INNAME].w);
1.1 root 95:
1.1.1.5 ! root 96: if (ConfigureParams.Midi.bEnableMidi)
1.1 root 97: devicedlg[DEVDLG_MIDIENABLE].state |= SG_SELECTED;
98: else
99: devicedlg[DEVDLG_MIDIENABLE].state &= ~SG_SELECTED;
1.1.1.5 ! root 100: File_ShrinkName(dlgMidiOutName, ConfigureParams.Midi.szMidiOutFileName, devicedlg[DEVDLG_MIDIOUTNAME].w);
1.1 root 101:
102: /* The devices dialog main loop */
103: do
104: {
1.1.1.2 root 105: but = SDLGui_DoDialog(devicedlg, NULL);
1.1 root 106:
107: switch(but)
108: {
109: case DEVDLG_PRNBROWSE: /* Choose a new printer file */
1.1.1.4 root 110: SDLGui_FileConfSelect(dlgPrinterName,
1.1.1.5 ! root 111: ConfigureParams.Printer.szPrintToFileName,
1.1.1.4 root 112: devicedlg[DEVDLG_PRNFILENAME].w,
113: TRUE);
1.1 root 114: break;
115: case DEVDLG_RS232OUTBROWSE: /* Choose a new RS232 output file */
1.1.1.4 root 116: SDLGui_FileConfSelect(dlgRs232OutName,
1.1.1.5 ! root 117: ConfigureParams.RS232.szOutFileName,
1.1.1.4 root 118: devicedlg[DEVDLG_RS232OUTNAME].w,
119: TRUE);
1.1 root 120: break;
121: case DEVDLG_RS232INBROWSE: /* Choose a new RS232 input file */
1.1.1.4 root 122: SDLGui_FileConfSelect(dlgRs232InName,
1.1.1.5 ! root 123: ConfigureParams.RS232.szInFileName,
1.1.1.4 root 124: devicedlg[DEVDLG_RS232INNAME].w,
125: TRUE);
1.1 root 126: break;
127: case DEVDLG_MIDIBROWSE: /* Choose a new MIDI file */
1.1.1.4 root 128: SDLGui_FileConfSelect(dlgMidiOutName,
1.1.1.5 ! root 129: ConfigureParams.Midi.szMidiOutFileName,
1.1.1.4 root 130: devicedlg[DEVDLG_MIDIOUTNAME].w,
131: TRUE);
1.1 root 132: break;
133: }
134: }
1.1.1.4 root 135: while (but != DEVDLG_EXIT && but != SDLGUI_QUIT
136: && but != SDLGUI_ERROR && !bQuitProgram);
1.1 root 137:
138: /* Read values from dialog */
1.1.1.5 ! root 139: ConfigureParams.Printer.bEnablePrinting = (devicedlg[DEVDLG_PRNENABLE].state & SG_SELECTED);
! 140: ConfigureParams.RS232.bEnableRS232 = (devicedlg[DEVDLG_RS232ENABLE].state & SG_SELECTED);
! 141: ConfigureParams.Midi.bEnableMidi = (devicedlg[DEVDLG_MIDIENABLE].state & SG_SELECTED);
1.1 root 142: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.