static BOOL store_printer_dialog_results(HWND hwnd, unsigned int num) { char printer_name[30]; if (num == 0) { sprintf(printer_name, "PrinterUserport"); } else { sprintf(printer_name, "Printer%d", num); } resources_set_int(printer_name, (int)SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TYPE), CB_GETCURSEL, 0, 0)); if (num == 6) { resources_set_string_sprintf("%sDriver", ui_plotter_driver_1520[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_DRIVER), CB_GETCURSEL, 0, 0)], printer_name); } else { resources_set_string_sprintf("%sDriver", ui_printer_driver_ascii[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_DRIVER), CB_GETCURSEL, 0, 0)], printer_name); } resources_set_string_sprintf("%sOutput", ui_printer_output_ascii[SendMessage(GetDlgItem(hwnd, IDC_PRINTER_OUTPUT), CB_GETCURSEL, 0, 0)], printer_name); resources_set_int_sprintf("%sTextDevice", (int)SendMessage(GetDlgItem(hwnd, IDC_PRINTER_TEXTOUT), CB_GETCURSEL, 0, 0), printer_name); resources_set_string("PrinterTextDevice1", printertextdevice[0]); resources_set_string("PrinterTextDevice2", printertextdevice[1]); resources_set_string("PrinterTextDevice3", printertextdevice[2]); if (num > 0 && (iec_available_busses() & IEC_BUS_IEC)) { resources_set_int_sprintf("IECDevice%d", (IsDlgButtonChecked(hwnd, IDC_PRINTER_USEIECDEVICE) == BST_CHECKED), num); } return 1; }
static TUI_MENU_CALLBACK(set_directory_callback) { char s[256]; int drive = (int)param; const char *v; if (!(check_current_drive_type(ATTACH_DEVICE_FS, drive))) { return "N/A"; } if (been_activated) { *s = '\0'; if (tui_input_string("Change directory name", "New name:", s, 255) == -1) { return NULL; } if (*s == '\0') { return NULL; } resources_set_string_sprintf("FSDevice%iDir", s, drive); ui_update_menus(); } resources_get_string_sprintf("FSDevice%iDir", &v, drive); return v; }
/** \brief Handler for the "toggled" event of the radio buttons * * \param[in] radio radio button * \param[in] user_data new value for the resource (`const char *`) */ static void on_radio_toggled(GtkWidget *radio, gpointer user_data) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) { int device; const char *type; /* get device number from the "DeviceNumber" property of the radio * button */ device = resource_widget_get_int(radio, "DeviceNumber"); type = (const char *)user_data; debug_gtk3("setting Printer%dDriver to '%s'.", device, type); resources_set_string_sprintf("Printer%dDriver", type, device); } }
static BOOL store_dialog_results(HWND hwnd, unsigned int num) { char s[MAX_PATH]; TCHAR st[MAX_PATH]; int devtype = ATTACH_DEVICE_NONE; if (iec_available_busses() & IEC_BUS_IEC) { resources_set_int_sprintf("IECDevice%d", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_USEIECDEVICE) == BST_CHECKED), num); } if (IsDlgButtonChecked(hwnd, IDC_SELECTDISK) == BST_CHECKED || IsDlgButtonChecked(hwnd, IDC_SELECTDIR) == BST_CHECKED) { devtype = ATTACH_DEVICE_FS; } #ifdef HAVE_OPENCBM if (opencbmlib_is_available()) { if (IsDlgButtonChecked(hwnd, IDC_SELECTREAL) == BST_CHECKED) { devtype = ATTACH_DEVICE_REAL; } } #endif resources_set_int_sprintf("FileSystemDevice%d", devtype, num); resources_set_int_sprintf("FSDevice%dConvertP00", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_READP00) == BST_CHECKED), num); resources_set_int_sprintf("FSDevice%dSaveP00", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_WRITEP00) == BST_CHECKED), num); resources_set_int_sprintf("FSDevice%dHideCBMFiles", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_HIDENONP00) == BST_CHECKED), num); resources_set_int_sprintf("AttachDevice%dReadonly", (IsDlgButtonChecked(hwnd, IDC_TOGGLE_ATTACH_READONLY) == BST_CHECKED), num); GetDlgItemText(hwnd, IDC_DIR, st, MAX_PATH); system_wcstombs(s, st, MAX_PATH); resources_set_string_sprintf("FSDevice%dDir", s, num); if (IsDlgButtonChecked(hwnd, IDC_SELECTDISK) == BST_CHECKED) { GetDlgItemText(hwnd, IDC_DISKIMAGE, st, MAX_PATH); system_wcstombs(s, st, MAX_PATH); if (file_system_attach_disk(num, s) < 0 ) { ui_error(translate_text(IDS_CANNOT_ATTACH_FILE)); return 0; } } else { if ((IsDlgButtonChecked(hwnd, IDC_SELECTDIR) == BST_CHECKED) && file_system_get_disk_name(num)) { file_system_detach_disk(num); } } return 1; }
static int pet_set_model_info(petinfo_t *pi) { /* set hardware config */ petmem_set_conf_info(pi); if (pi->pet2k) { /* set resource only when necessary */ resources_set_int("Basic1", pi->pet2k); } resources_set_int("Basic1Chars", pi->pet2kchar); resources_set_string("ChargenName", pi->chargenName); resources_set_string("KernalName", pi->kernalName); resources_set_string("BasicName", pi->basicName); resources_set_string("EditorName", pi->editorName); /* allow additional ROMs to survive a model switch. */ if (pi->mem9name) { resources_set_string("RomModule9Name", pi->mem9name); } if (pi->memAname) { resources_set_string("RomModuleAName", pi->memAname); } if (pi->memBname) { resources_set_string("RomModuleBName", pi->memBname); } if (pi->superpet) { int i; for (i = 0; i < NUM_6809_ROMS; i++) { if (pi->h6809romName[i]) { resources_set_string_sprintf("H6809Rom%cName", pi->h6809romName[i], 'A' + i); } } } return 0; }
static MRESULT EXPENTRY pm_drive(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static int drive = 0; switch (msg) { case WM_INITDLG: { int val, i = 0; HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE); while (i < 10 && ui_status.imageHist[i][0]) { WinLboxInsertItem(ihwnd, ui_status.imageHist[i++]); } WinLboxInsertItem(ihwnd, ""); resources_get_int("DriveTrueEmulation", &val); WinCheckButton(hwnd, CB_TRUEDRIVE, val); WinCheckButton(hwnd, RB_DRIVE8|drive, 1); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); WinSendMsg(hwnd, WM_DRIVESTATE, (void*)ui_status.lastDriveState, NULL); for (i = 0; i < 3; i++) { WinSendMsg(hwnd, WM_TRACK, (void*)i, (void*)(int)(ui_status.lastTrack[i] * 2)); } } break; case WM_COMMAND: switch (LONGFROMMP(mp1)) { case PB_CREATE: create_dialog(hwnd); return FALSE; case PB_ATTACH: ViceFileDialog(hwnd, 0x0100 | (drive + 1), FDS_OPEN_DIALOG); return FALSE; case PB_DETACH: file_system_detach_disk(drive + 8); return FALSE; case PB_FLIPADD: fliplist_add_image(drive + 8); return FALSE; case PB_FLIPREMOVE: fliplist_remove(drive + 8, NULL); return FALSE; case PB_FLIP: fliplist_attach_head(drive + 8, FLIP_NEXT); return FALSE; } break; case WM_CONTROL: { switch (SHORT1FROMMP(mp1)) { case RB_DRIVE8: case RB_DRIVE9: case RB_DRIVE10: case RB_DRIVE11: WinSendMsg(hwnd, WM_SWITCH, (void*)(SHORT1FROMMP(mp1) & 0x3), 0); break; case CB_TRUEDRIVE: toggle("DriveTrueEmulation"); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); break; case CB_CONVERTP00: toggle_drive_res("FSDevice%dConvertP00", drive);//); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); break; case CB_SAVEP00: toggle_drive_res("FileDevice%dSaveP00", drive); break; case CB_ALLOWACCESS: toggle_drive_res("FileSystemDevice%d", drive); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); break; case CB_HIDENONP00: toggle_drive_res("FSDevice%dHideCBMFiles", drive); break; case CB_MEM2000: toggle_drive_res("Drive%dRAM2000", drive); break; case CB_MEM4000: toggle_drive_res("Drive%dRAM4000", drive); break; case CB_MEM6000: toggle_drive_res("Drive%dRAM6000", drive); break; case CB_MEM8000: toggle_drive_res("Drive%dRAM8000", drive); break; case CB_MEMA000: toggle_drive_res("Drive%dRAMA000", drive); break; case CB_READONLY: toggle_drive_res("AttachDevice%dReadonly", drive); break; case CB_PARALLEL: if (drive == 0 || drive == 1) { toggle_drive_res("Drive%dParallelCable", drive); } break; case RB_NEVER: case RB_ASK: case RB_ALWAYS: if (drive == 0 || drive == 1) { resources_set_int_sprintf("Drive%dExtendImagePolicy", (SHORT1FROMMP(mp1) & 0x3), drive + 8); } break; case RB_NONE: case RB_TRAP: case RB_SKIP: if (drive == 0 || drive == 1) { resources_set_int_sprintf("Drive%dIdleMethod", (SHORT1FROMMP(mp1) & 0x3), drive + 8); } break; case CBS_IMAGE: if (SHORT2FROMMP(mp1) == CBN_ENTER) { char psz[CCHMAXPATH]; WinLboxQuerySelectedItemText(hwnd, CBS_IMAGE, psz, CCHMAXPATH); if (!strlen(psz)) { file_system_detach_disk(drive + 8); return FALSE; } if (file_system_attach_disk(drive + 8, psz)) { WinMessageBox(HWND_DESKTOP, hwnd, "Cannot attach specified file.", "VICE/2 Error", 0, MB_OK); } } return FALSE; case CBS_PATH: switch (SHORT2FROMMP(mp1)) { case SPBN_CHANGE: { char path[255]; WinSendDlgMsg(hwnd, CBS_PATH, SPBM_QUERYVALUE, &path, 255); if (!chdir(path)) { resources_set_string_sprintf("FSDevice%dDir", path, drive + 8); } } break; case SPBN_KILLFOCUS: { const char *path; resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8); WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1); WinSetDlgSpinVal(hwnd, CBS_PATH, 0); } break; } return FALSE; case CBS_TYPE: if (SHORT2FROMMP(mp1) == CBN_ENTER && (drive == 0 || drive == 1)) { const int nr = WinQueryLboxSelectedItem((HWND)mp2); const int val = WinLboxItemHandle((HWND)mp2, nr); resources_set_int_sprintf("Drive%dType", val, drive + 8); } return FALSE; } } break; case WM_DRIVEIMAGE: { HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE); const char *name = (char *)mp1; int pos; for (pos = 0; pos < 9; pos++) { WinDeleteLboxItem(ihwnd, 0); } pos = 0; while (pos < 10 && ui_status.imageHist[pos][0]) { WinLboxInsertItem(ihwnd, ui_status.imageHist[pos++]); } WinLboxInsertItem(ihwnd, ""); if (drive == (int)mp2) { WinLboxSelectItem(ihwnd, name[0] ? 0 : pos); } } return FALSE; case WM_TRACK: if (!(ui_status.lastDriveState & (1 << (int)mp1))) { break; } WinSetDlgSpinVal(hwnd, SPB_TRACK8+(int)mp1, (int)((int)mp2 / 2)); WinShowDlg(hwnd, SS_HALFTRACK8 + (int)mp1, ((int)mp2 % 2)); break; case WM_DRIVELEDS: WinShowDlg(hwnd, SS_LED8+(int)mp1, (int)mp2); break; case WM_DRIVESTATE: WinShowDlg(hwnd, SPB_TRACK8, (int)mp1 & 1 == 1); WinShowDlg(hwnd, SS_HALFTRACK8, (int)mp1 & 1 == 1); WinShowDlg(hwnd, SPB_TRACK9, (int)mp1 & 2 == 1); WinShowDlg(hwnd, SS_HALFTRACK9, (int)mp1 & 2 == 1); WinShowDlg(hwnd, SS_LED8, 0); WinShowDlg(hwnd, SS_LED9, 0); break; case WM_SWITCH: drive = (int)mp1; { const HWND lbox = WinWindowFromID(hwnd, CBS_TYPE); int type = 0; int val; int res; int drive89 = (drive == 0 || drive == 1); resources_get_int("DriveTrueEmulation", &val); WinLboxEmpty(lbox); if (drive89) { int i, nr; WinCheckButton(hwnd, RB_NEVER | get_drive_res("Drive%dExtendImagePolicy", drive), 1); WinCheckButton(hwnd, RB_NONE | get_drive_res("Drive%dIdleMethod", drive), 1); nr = 0; res = get_drive_res("Drive%dType", drive); for (i = 0; i < nDRIVES; i++) { if (!drive_check_type(driveRes[i], drive)) { continue; } WinLboxInsertItem(lbox, driveName[i]); WinLboxSetItemHandle(lbox, nr, driveRes[i]); if (res == driveRes[i]) { type = nr; } nr++; } } else { WinCheckButton(hwnd, RB_NEVER, 0); WinCheckButton(hwnd, RB_ASK, 0); WinCheckButton(hwnd, RB_ALWAYS, 0); WinCheckButton(hwnd, RB_NONE, 0); WinCheckButton(hwnd, RB_SKIP, 0); WinCheckButton(hwnd, RB_TRAP, 0); } WinLboxSelectItem(lbox, type); WinCheckButton(hwnd, CB_PARALLEL, drive89 && get_drive_res("Drive%dParallelCable", drive) != 0); WinCheckButton(hwnd, CB_MEM2000, drive89 && get_drive_res("Drive%dRAM2000", drive) != 0); WinCheckButton(hwnd, CB_MEM4000, drive89 && get_drive_res("Drive%dRAM4000", drive) != 0); WinCheckButton(hwnd, CB_MEM6000, drive89 && get_drive_res("Drive%dRAM6000", drive) != 0); WinCheckButton(hwnd, CB_MEM8000, drive89 && get_drive_res("Drive%dRAM8000", drive) != 0); WinCheckButton(hwnd, CB_MEMA000, drive89 && get_drive_res("Drive%dRAMA000", drive) != 0); WinEnableControl(hwnd, CB_PARALLEL, drive89 && val); WinEnableControl(hwnd, RB_NEVER, drive89 && val); WinEnableControl(hwnd, RB_ASK, drive89 && val); WinEnableControl(hwnd, RB_ALWAYS, drive89 && val); WinEnableControl(hwnd, RB_NONE, drive89 && val); WinEnableControl(hwnd, RB_SKIP, drive89 && val); WinEnableControl(hwnd, RB_TRAP, drive89 && val); WinEnableControl(hwnd, CBS_TYPE, drive89 && val); WinEnableControl(hwnd, CB_MEM2000, drive89 && val); WinEnableControl(hwnd, CB_MEM4000, drive89 && val); WinEnableControl(hwnd, CB_MEM6000, drive89 && val); WinEnableControl(hwnd, CB_MEM8000, drive89 && val); WinEnableControl(hwnd, CB_MEMA000, drive89 && val); { int acc = get_drive_res("FileSystemDevice%d", drive) != 0; int conv = get_drive_res("FSDevice%dConvertP00", drive) != 0; if (!conv) { resources_set_int_sprintf("FSDevice%dHideCBMFiles", 0, drive + 8); } WinCheckButton(hwnd, CB_ALLOWACCESS, acc); WinCheckButton(hwnd, CB_CONVERTP00, conv); WinCheckButton(hwnd, CB_SAVEP00, get_drive_res("FSDevice%dSaveP00", drive) != 0); WinCheckButton(hwnd, CB_HIDENONP00, get_drive_res("FSDevice%dHideCBMFiles", drive) != 0); WinEnableControl(hwnd, CB_ALLOWACCESS, !(drive89 && val)); WinEnableControl(hwnd, CB_SAVEP00, !(drive89 && val) && acc); WinEnableControl(hwnd, CB_CONVERTP00, !(drive89 && val) && acc); WinEnableControl(hwnd, CBS_PATH, !(drive89 && val) && acc); WinEnableControl(hwnd, CB_HIDENONP00, !(drive89 && val) && acc && conv); WinCheckButton(hwnd, CB_READONLY, get_drive_res("AttachDevice%dReadonly", drive) != 0); } { char tmp[CCHMAXPATH]; int max = WinDlgLboxQueryCount(hwnd, CBS_IMAGE); int pos = -1; do { WinLboxQueryItem(hwnd, CBS_IMAGE, ++pos, tmp, CCHMAXPATH); } while (pos < max && strcmp(ui_status.lastImage[drive], tmp)); WinDlgLboxSelectItem(hwnd, CBS_IMAGE, pos); } { const char *path; resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8); WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1); WinSetDlgSpinVal(hwnd, CBS_PATH, 0); } } return FALSE; } return WinDefDlgProc (hwnd, msg, mp1, mp2); }