ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/dlgDrives.cpp
Revision: 1.1
Committed: 2007-01-28T19:00:13Z (17 years, 2 months ago) by berlac
Branch: MAIN
CVS Tags: HEAD
Log Message:
Initial revision.

File Contents

# Content
1 /*
2 * dlgDrives.cpp - SDL GUI dialog for C64 drive settings
3 *
4 * (C) 2006 Bernd Lachner
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include "sysdeps.h"
22 #include "sdlgui.h"
23 #include "file.h"
24
25 #include "Prefs.h"
26
27 #include "dlgFileSelect.h"
28
29
30 enum DRIVESDLG {
31 box_main,
32 box_drives,
33 text_drives,
34 text_drive8,
35 PATH8TXT,
36 PATH8,
37 text_drive9,
38 PATH9TXT,
39 PATH9,
40 text_drive10,
41 PATH10TXT,
42 PATH10,
43 text_drive11,
44 PATH11TXT,
45 PATH11,
46 box_options,
47 text_options,
48 ENABLE_FULL_1541,
49 MAP_FILE_NAMES,
50 OK,
51 CANCEL
52 };
53
54 static char DrivePath[4][18];
55
56 /* The keyboard dialog: */
57 /* Spalte, Zeile, Länge, Höhe*/
58 static SGOBJ drivesdlg[] =
59 {
60 { SGBOX, SG_BACKGROUND, 0, 0,0, 35,20, NULL },
61 { SGBOX, 0, 0, 1,2, 33,9, NULL },
62 { SGTEXT, 0, 0, 2, 1, 13, 1, " Drive Paths"},
63
64 { SGTEXT, 0, 0, 2, 3, 8, 1, "Drive 8:"},
65 { SGEDITFIELD, 0, 0, 12, 3, sizeof(DrivePath[0])-1, 1, DrivePath[0]},
66 { SGBUTTON, SG_SELECTABLE | SG_TOUCHEXIT, 0, 30, 3, 4, 1, "Path"},
67
68 { SGTEXT, 0, 0, 2, 5, 16, 1, "Drive 9:"},
69 { SGEDITFIELD, 0, 0, 12, 5, sizeof(DrivePath[1])-1, 1, DrivePath[1]},
70 { SGBUTTON, SG_SELECTABLE | SG_TOUCHEXIT, 0, 30, 5, 4, 1, "Path"},
71
72 { SGTEXT, 0, 0, 2, 7, 16, 1, "Drive 10:"},
73 { SGEDITFIELD, 0, 0, 12, 7, sizeof(DrivePath[2])-1, 1, DrivePath[2]},
74 { SGBUTTON, SG_SELECTABLE | SG_TOUCHEXIT, 0, 30, 7, 4, 1, "Path"},
75
76 { SGTEXT, 0, 0, 2, 9, 16, 1, "Drive 11:"},
77 { SGEDITFIELD, 0, 0, 12, 9, sizeof(DrivePath[3])-1, 1, DrivePath[3]},
78 { SGBUTTON, SG_SELECTABLE | SG_TOUCHEXIT, 0, 30, 9, 4, 1, "Path"},
79
80 { SGBOX, 0, 0, 1,13, 33,3, NULL },
81 { SGTEXT, 0, 0, 2, 12, 8, 1, " Options"},
82 { SGCHECKBOX, SG_SELECTABLE, 0, 2, 14, 30, 1, "Enable Full 1541 Emulation"},
83 { SGCHECKBOX, SG_SELECTABLE, 0, 2, 15, 30, 1, "Map '/' to '\\` in File Names"},
84
85 {SGBUTTON, SG_SELECTABLE|SG_EXIT|SG_DEFAULT, 0, 1, 18, 6, 1, "OK"},
86 {SGBUTTON, SG_SELECTABLE|SG_EXIT, 0, 9, 18, 6, 1, "Cancel"},
87
88 { -1, 0, 0, 0,0, 0,0, NULL }
89 };
90
91 void Dialog_Drives(Prefs &prefs)
92 {
93 // Set values from prefs
94 // TODO Check length
95 char path[4][MAX_FILENAME_LENGTH];
96 for (int i = 0; i < 4; i++)
97 {
98 int widget = PATH8 + i*3;
99 char shrinkedpath[MAX_FILENAME_LENGTH];
100 File_ShrinkName(shrinkedpath, prefs.DrivePath[i], drivesdlg[widget-1].w);
101 strcpy(drivesdlg[widget-1].txt, shrinkedpath);
102 strcpy(path[i], prefs.DrivePath[i]);
103 }
104 drivesdlg[ENABLE_FULL_1541].state |= prefs.Emul1541Proc == true ? SG_SELECTED : 0;
105 drivesdlg[MAP_FILE_NAMES].state |= prefs.MapSlash == true ? SG_SELECTED : 0;
106 while (1)
107 {
108 int widget = SDLGui_DoDialog(drivesdlg);
109 switch (widget)
110 {
111 case PATH8:
112 case PATH9:
113 case PATH10:
114 case PATH11:
115 {
116 if (SDLGui_FileSelect(path[(widget-PATH8)/3], false))
117 {
118 char shrinkedpath[MAX_FILENAME_LENGTH];
119 File_ShrinkName(shrinkedpath, path[(widget-PATH8)/3], drivesdlg[widget-1].w);
120 strcpy(drivesdlg[widget-1].txt, shrinkedpath);
121 }
122 }
123 break;
124 case OK:
125 for (int i = 0; i < 4; i++)
126 {
127 strcpy(prefs.DrivePath[i], path[i]);
128 fprintf (stderr, "Path(%s)\n", prefs.DrivePath[i]);
129 }
130 prefs.Emul1541Proc = drivesdlg[ENABLE_FULL_1541].state &= SG_SELECTED ? true : false;
131 prefs.MapSlash = drivesdlg[MAP_FILE_NAMES].state &= SG_SELECTED ? true : false;
132 return;
133 case CANCEL:
134 return;
135 }
136 }
137 }
138