static void init_resources_dialog(HWND hwnd, unsigned int type) { unsigned int n = 0; int xpos1, xpos2; int size; RECT rect; int idc; int i; HWND element; if (type == UIROM_TYPE_MAIN) { /* translate all dialog items */ uilib_localize_dialog(hwnd, main_res_trans); idc = IDC_COMPUTER_RESOURCES; } else if (type == UIROM_TYPE_DRIVE) { /* translate all dialog items */ uilib_localize_dialog(hwnd, drive_res_trans); /* translate generic items */ for (i = 0; generic_res_trans[i].text != NULL; i++) { element = GetDlgItem(hwnd, generic_res_trans[i].idm); SetWindowText(element, generic_res_trans[i].text); } idc = IDC_DRIVE_RESOURCES; } /* get the max x of the group element */ uilib_get_element_max_x(hwnd, idc, &xpos1); /* get the size of the group element */ uilib_get_element_size(hwnd, idc, &size); /* adjust the size of the group element */ uilib_adjust_element_width(hwnd, idc); /* get the max x of the group element */ uilib_get_element_max_x(hwnd, idc, &xpos2); if (xpos2 < xpos1) { /* restore the size of the group element */ uilib_set_element_width(hwnd, idc, size); } else { /* resize the dialog window */ GetWindowRect(hwnd, &rect); MoveWindow(hwnd, rect.left, rect.top, xpos2 + 10, rect.bottom - rect.top, TRUE); /* recenter the buttons in the newly resized dialog window */ uilib_center_buttons(hwnd, move_buttons_group, 0); } while (settings[n].realname != NULL) { if (settings[n].type == type) { int enable; resources_get_int_sprintf("Romset%s", &enable, settings[n].resname); CheckDlgButton(hwnd, settings[n].idc_resource, enable ? BST_CHECKED : BST_UNCHECKED); } n++; } }
static void init_dialog(HWND hwnd, unsigned int num) { const char *disk_image, *dir; TCHAR *st_disk_image, *st_dir; int devtype, n; int xpos, xpos1, xpos2, xpos3; int distance1, distance2; RECT rect; uilib_localize_dialog_param *diskdevice_dialog = #ifdef HAVE_OPENCBM (opencbmlib_is_available()) ? diskdevice_opencbm_dialog : #endif diskdevice_normal_dialog; if (num >= 8 && num <= 11) { /* translate all dialog items */ uilib_localize_dialog(hwnd, diskdevice_dialog); /* adjust the size of the elements in the diskdevice_left_group */ uilib_adjust_group_width(hwnd, diskdevice_left_group); /* adjust the size of the 'read-only' element */ uilib_adjust_group_width(hwnd, diskdevice_read_only); /* get the min x of the read only element */ uilib_get_element_min_x(hwnd, IDC_TOGGLE_ATTACH_READONLY, &xpos3); /* get the min x of the autostart element */ uilib_get_element_min_x(hwnd, IDC_AUTOSTART, &xpos2); /* get the max x of the first browse element */ uilib_get_element_max_x(hwnd, IDC_BROWSEDISK, &xpos1); /* calculate the distance between the browse button and the autostart button */ distance1 = xpos2 - xpos1; /* get the max x of the autostart element */ uilib_get_element_max_x(hwnd, IDC_AUTOSTART, &xpos2); /* calculate the distance between the browse button and the read only element */ distance2 = xpos3 - xpos2; /* get the max x of the disk_device_left_group items */ uilib_get_group_max_x(hwnd, diskdevice_left_group, &xpos); /* move the filename elements and browse buttons to the right position */ uilib_move_group(hwnd, diskdevice_middle_group, xpos + 10); /* get the max x of the first browse element */ uilib_get_element_max_x(hwnd, IDC_BROWSEDISK, &xpos); /* move the autostart element to the right position */ uilib_move_element(hwnd, IDC_AUTOSTART, xpos + distance1); /* resize the autostart element */ uilib_adjust_element_width(hwnd, IDC_AUTOSTART); /* get the max x of the autostart element */ uilib_get_element_max_x(hwnd, IDC_AUTOSTART, &xpos); /* move the read only element to the right position */ uilib_move_element(hwnd, IDC_TOGGLE_ATTACH_READONLY, xpos + distance2); #ifdef HAVE_OPENCBM if (opencbmlib_is_available()) { /* adjust the size of the real iec element */ uilib_adjust_element_width(hwnd, IDC_SELECTREAL); /* get the max x of the real iec element */ uilib_get_element_max_x(hwnd, IDC_SELECTREAL, &xpos1); } else { xpos1 = 0; } #else xpos1 = 0; #endif /* get the max x of the second browse button */ uilib_get_element_max_x(hwnd, IDC_BROWSEDIR, &xpos2); if (xpos2 > xpos1) { xpos = xpos2 + 20; } else { xpos = xpos1 + 20; } /* move the diskdevice_right_group to the right position */ uilib_move_group(hwnd, diskdevice_right_group, xpos); /* move the p00 group element to the right position */ uilib_move_element(hwnd, IDC_DISKDEVICE_OPTIONS, xpos - 5); /* adjust the diskdevice_right_group elements size */ uilib_adjust_group_width(hwnd, diskdevice_right_group); /* adjust the p00 group element size */ uilib_adjust_element_width(hwnd, IDC_DISKDEVICE_OPTIONS); /* get the width of the disk_device_right_group items */ uilib_get_group_width(hwnd, diskdevice_right_group, &xpos1); /* get the width of the p00 group element */ uilib_get_element_width(hwnd, IDC_DISKDEVICE_OPTIONS, &xpos2); if (xpos2 + 5 > xpos1) { xpos = xpos2 + 15; } else { xpos = xpos1 + 10; } /* set the width of the p00 group element */ uilib_set_element_width(hwnd, IDC_DISKDEVICE_OPTIONS, xpos); /* adjust the none element size */ uilib_adjust_element_width(hwnd, IDC_SELECTNONE); /* adjust the size of the use iec device element */ uilib_adjust_element_width(hwnd, IDC_TOGGLE_USEIECDEVICE); /* get the max x of the window filling elements */ uilib_get_group_max_x(hwnd, diskdevice_filling_group, &xpos); /* set the width of the dialog to 'surround' all the elements */ GetWindowRect(hwnd, &rect); MoveWindow(hwnd, rect.left, rect.top, xpos + 10, rect.bottom - rect.top, TRUE); disk_image = file_system_get_disk_name(num); st_disk_image = system_mbstowcs_alloc(disk_image); SetDlgItemText(hwnd, IDC_DISKIMAGE, st_disk_image != NULL ? st_disk_image : TEXT("")); system_mbstowcs_free(st_disk_image); resources_get_string_sprintf("FSDevice%dDir", &dir, num); st_dir = system_mbstowcs_alloc(dir); SetDlgItemText(hwnd, IDC_DIR, st_dir != NULL ? st_dir : TEXT("")); system_mbstowcs_free(st_dir); resources_get_int_sprintf("FSDevice%dConvertP00", &n, num); CheckDlgButton(hwnd, IDC_TOGGLE_READP00, n ? BST_CHECKED : BST_UNCHECKED); resources_get_int_sprintf("FSDevice%dSaveP00", &n, num); CheckDlgButton(hwnd, IDC_TOGGLE_WRITEP00, n ? BST_CHECKED : BST_UNCHECKED); resources_get_int_sprintf("FSDevice%dHideCBMFiles", &n, num); CheckDlgButton(hwnd, IDC_TOGGLE_HIDENONP00, n ? BST_CHECKED : BST_UNCHECKED); resources_get_int_sprintf("AttachDevice%dReadonly", &n, num); CheckDlgButton(hwnd, IDC_TOGGLE_ATTACH_READONLY, n ? BST_CHECKED : BST_UNCHECKED); resources_get_int_sprintf("FileSystemDevice%d", &devtype, num); switch (devtype) { case ATTACH_DEVICE_FS: if (disk_image != NULL) { n = IDC_SELECTDISK; } else { n = IDC_SELECTDIR; } break; #ifdef HAVE_OPENCBM case ATTACH_DEVICE_REAL: n = IDC_SELECTREAL; break; #endif default: n = IDC_SELECTNONE; } #ifdef HAVE_OPENCBM if (opencbmlib_is_available()) { CheckRadioButton(hwnd, IDC_SELECTDISK, IDC_SELECTREAL, n); } else { CheckRadioButton(hwnd, IDC_SELECTDISK, IDC_SELECTDIR, n); } #else CheckRadioButton(hwnd, IDC_SELECTDISK, IDC_SELECTDIR, n); #endif enable_controls_for_disk_device_type(hwnd, n); if (iec_available_busses() & IEC_BUS_IEC) { resources_get_int_sprintf("IECDevice%d", &n, num); CheckDlgButton(hwnd, IDC_TOGGLE_USEIECDEVICE, n ? BST_CHECKED : BST_UNCHECKED); } else { CheckDlgButton(hwnd, IDC_TOGGLE_USEIECDEVICE, BST_UNCHECKED); ShowWindow(GetDlgItem(hwnd, IDC_TOGGLE_USEIECDEVICE), FALSE); } enable_controls(hwnd); } }
static void init_fullscreen_dialog(HWND hwnd) { HWND setting_hwnd; DirectDrawDeviceList *dev; ValueList *value; int xpos; int xstart; int xend; int distance; int size; double fval; TCHAR newval[64]; video_canvas_t *canvas; uilib_localize_dialog_param *fullscreen_dialog_trans = (video_dx9_enabled()) ? fullscreen_dialog_dx9_trans : fullscreen_dialog_ddraw_trans; uilib_dialog_group *fullscreen_left_group = (video_dx9_enabled()) ? fullscreen_left_dx9_group : fullscreen_left_ddraw_group; uilib_dialog_group *fullscreen_right_group = (video_dx9_enabled()) ? fullscreen_right_dx9_group : fullscreen_right_ddraw_group; canvas = video_canvas_for_hwnd(GetParent(GetParent(hwnd))); fullscreen_getmodes(); /* translate all dialog items */ uilib_localize_dialog(hwnd, fullscreen_dialog_trans); /* adjust the size of the elements in the left group */ uilib_adjust_group_width(hwnd, fullscreen_left_group); /* adjust the size of the elements in the rest group */ uilib_adjust_group_width(hwnd, fullscreen_rest_group); /* get the max x of the right group */ uilib_get_group_max_x(hwnd, fullscreen_right_group, &xend); /* get the min x of the right group */ uilib_get_group_min_x(hwnd, fullscreen_right_group, &xstart); /* get the max x of the left group */ uilib_get_group_max_x(hwnd, fullscreen_left_group, &xpos); if (xpos + 10 > xstart) { /* set the position of the right group */ uilib_move_group(hwnd, fullscreen_right_group, xpos + 10); /* get the max x of the right group */ uilib_get_group_max_x(hwnd, fullscreen_right_group, &xpos); /* calculate the distance between the old and new max x of the right group */ distance = xpos - xend; /* get the size of the driver element */ uilib_get_element_size(hwnd, IDC_FULLSCREEN_DEVICE, &size); /* set the size of the driver element */ uilib_set_element_width(hwnd, IDC_FULLSCREEN_DEVICE, size + distance); } validate_mode(&fullscreen_device, &fullscreen_width, &fullscreen_height, &fullscreen_bitdepth, &fullscreen_refreshrate); setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_DEVICE); SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0); dev = devices; while (dev != NULL) { SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)dev->desc); dev = dev->next; } SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)fullscreen_device, 0); get_bitdepthlist(fullscreen_device); setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_BITDEPTH); SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0); value = bitdepthlist; while (value != NULL) { SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)value->text); value = value->next; } SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)GetIndexFromList(bitdepthlist, fullscreen_bitdepth), 0); get_resolutionlist(fullscreen_device, fullscreen_bitdepth); setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_RESOLUTION); SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0); value = resolutionlist; while (value != NULL) { SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)value->text); value = value->next; } SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)GetIndexFromList(resolutionlist, (fullscreen_width << 16) + fullscreen_height), 0); get_refreshratelist(fullscreen_device, fullscreen_bitdepth, fullscreen_width, fullscreen_height); setting_hwnd = GetDlgItem(hwnd, IDC_FULLSCREEN_REFRESHRATE); SendMessage(setting_hwnd, CB_RESETCONTENT, 0, 0); value = refresh_rates; while (value != NULL) { SendMessage(setting_hwnd, CB_ADDSTRING, 0, (LPARAM)value->text); value = value->next; } SendMessage(setting_hwnd, CB_SETCURSEL, (WPARAM)GetIndexFromList(refresh_rates, fullscreen_refreshrate), 0); EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_VIDEO_VBLANK_SYNC), !video_dx9_enabled()); CheckDlgButton(hwnd, IDC_TOGGLE_VIDEO_VBLANK_SYNC, vblank_sync ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_TOGGLE_VIDEO_DX_PRIMARY, dx_primary ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwnd, IDC_TOGGLE_KEEP_ASPECT_RATIO), video_dx9_enabled()); if (video_dx9_enabled()) { CheckDlgButton(hwnd, IDC_TOGGLE_KEEP_ASPECT_RATIO, keep_aspect_ratio ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_TOGGLE_TRUE_ASPECT_RATIO, true_aspect_ratio ? BST_CHECKED : BST_UNCHECKED); enable_aspect_ratio(hwnd); fval = ((double)aspect_ratio) / 1000.0; _stprintf(newval, TEXT("%.3f"), (float)fval); SetDlgItemText(hwnd, IDC_ASPECT_RATIO, newval); fval = canvas->geometry->pixel_aspect_ratio; _stprintf(newval, TEXT("%.3f"), (float)fval); SetDlgItemText(hwnd, IDC_GEOMETRY_ASPECT_RATIO, newval); } }
static void init_functionrom_dialog(HWND hwnd) { int res_value; const char *romfile; TCHAR *st_romfile; int xstart; int xpos; int size; HWND temp_hwnd; /* translate all dialog items */ uilib_localize_dialog(hwnd, functionrom_dialog_trans); /* adjust the size of the enable group elements */ uilib_adjust_group_width(hwnd, enable_group); /* adjust the size of the file name group elements */ uilib_adjust_group_width(hwnd, file_name_group); /* get the max x of the file name indicator group */ uilib_get_group_max_x(hwnd, file_name_indicator_group, &xstart); /* get the size of the file name indicator group elements */ uilib_get_group_width(hwnd, file_name_indicator_group, &size); /* get the max x of the file name group */ uilib_get_group_max_x(hwnd, file_name_group, &xpos); /* move the file name indicator group to the correct position */ uilib_move_group(hwnd, file_name_indicator_group, xpos + 10); /* get the max x of the file name indicator group */ uilib_get_group_max_x(hwnd, file_name_indicator_group, &xpos); /* set the size of the file name indicator group */ uilib_set_element_width(hwnd, IDC_C128_FUNCTIONROM_INTERNAL_NAME, size - (xpos - xstart)); uilib_set_element_width(hwnd, IDC_C128_FUNCTIONROM_EXTERNAL_NAME, size - (xpos - xstart)); /* get the size of the internal function rom type label */ uilib_get_element_max_x(hwnd, IDC_C128_FUNCTIONROM_INTERNAL_TYPE_LABEL, &xpos); /* move the internal function rom type box */ uilib_move_element(hwnd, IDC_C128_FUNCTIONROM_INTERNAL_TYPE, xpos + 10); /* move the external function rom type box */ uilib_move_element(hwnd, IDC_C128_FUNCTIONROM_EXTERNAL_TYPE, xpos + 10); resources_get_string("InternalFunctionName", &romfile); st_romfile = system_mbstowcs_alloc(romfile); SetDlgItemText(hwnd, IDC_C128_FUNCTIONROM_INTERNAL_NAME, st_romfile != NULL ? st_romfile : TEXT("")); system_mbstowcs_free(st_romfile); resources_get_string("ExternalFunctionName", &romfile); st_romfile = system_mbstowcs_alloc(romfile); SetDlgItemText(hwnd, IDC_C128_FUNCTIONROM_EXTERNAL_NAME, st_romfile != NULL ? st_romfile : TEXT("")); system_mbstowcs_free(st_romfile); temp_hwnd = GetDlgItem(hwnd, IDC_C128_FUNCTIONROM_INTERNAL_TYPE); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NONE)); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"ROM"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"RAM"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"RAM+RTC"); resources_get_int("InternalFunctionROM", &res_value); SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0); temp_hwnd = GetDlgItem(hwnd, IDC_C128_FUNCTIONROM_EXTERNAL_TYPE); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NONE)); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"ROM"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"RAM"); SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"RAM+RTC"); resources_get_int("ExternalFunctionROM", &res_value); SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0); resources_get_int("InternalFunctionROMRTCSave", &res_value); CheckDlgButton(hwnd, IDC_C128_FUNCTIONROM_INTERNAL_RTC_SAVE, res_value ? BST_CHECKED : BST_UNCHECKED); resources_get_int("ExternalFunctionROMRTCSave", &res_value); CheckDlgButton(hwnd, IDC_C128_FUNCTIONROM_EXTERNAL_RTC_SAVE, res_value ? BST_CHECKED : BST_UNCHECKED); }
static void init_datasette_dialog(HWND hwnd) { HWND snd_hwnd; int res_value; int res_value_loop; int active_value; int xpos_max; int group_max; RECT rect; /* translate all dialog items */ uilib_localize_dialog(hwnd, datasette_dialog); /* adjust the size of the elements in the datasette_sub_group */ uilib_adjust_group_width(hwnd, datasette_sub_group); /* adjust the size of the 'reset with cpu' element */ uilib_adjust_element_width(hwnd, IDC_DATASETTE_RESET_WITH_CPU); /* adjust the size of the motor group element */ uilib_adjust_element_width(hwnd, IDC_DATASETTE_MOTOR_GROUP); /* get the max x of the datasette_sub_group */ uilib_get_group_max_x(hwnd, datasette_sub_group, &xpos_max); /* get the max x of the motor group element */ uilib_get_element_max_x(hwnd, IDC_DATASETTE_MOTOR_GROUP, &group_max); /* calculate the max x of the motor group element and the datasette_sub_group elements */ if (group_max < xpos_max + 10) { group_max = xpos_max + 10; } /* set the width of the motor group element to 'surround' the datasette_sub_group elements */ uilib_set_element_width(hwnd, IDC_DATASETTE_MOTOR_GROUP, group_max); /* get the max x of the datasette_main_group elements */ uilib_get_group_max_x(hwnd, datasette_main_group, &xpos_max); /* set the width of the dialog to 'surround' all the elements */ GetWindowRect(hwnd, &rect); MoveWindow(hwnd, rect.left, rect.top, xpos_max + 10, rect.bottom - rect.top, TRUE); /* recenter the buttons in the newly resized dialog window */ uilib_center_buttons(hwnd, move_buttons_group, 0); resources_get_int("DatasetteResetWithCPU", &res_value); CheckDlgButton(hwnd, IDC_DATASETTE_RESET_WITH_CPU, res_value ? BST_CHECKED : BST_UNCHECKED); snd_hwnd = GetDlgItem(hwnd, IDC_DATASETTE_ZERO_GAP_DELAY); for (res_value_loop = 0; res_value_loop < 7; res_value_loop++) { TCHAR st[10]; _stprintf(st, TEXT("%d"), ui_datasette_zero_gap_delay[res_value_loop]); SendMessage(snd_hwnd, CB_ADDSTRING, 0, (LPARAM)st); } resources_get_int("DatasetteZeroGapDelay", &res_value); active_value = 4; /* default */ for (res_value_loop = 0; res_value_loop < 7; res_value_loop++) { if (ui_datasette_zero_gap_delay[res_value_loop] == res_value) { active_value = res_value_loop; } } SendMessage(snd_hwnd, CB_SETCURSEL, (WPARAM)active_value, 0); snd_hwnd = GetDlgItem(hwnd, IDC_DATASETTE_SPEED_TUNING); for (res_value_loop = 0; res_value_loop < 8; res_value_loop++) { TCHAR st[10]; _stprintf(st, TEXT("%d"), res_value_loop); SendMessage(snd_hwnd, CB_ADDSTRING, 0, (LPARAM)st); } resources_get_int("DatasetteSpeedTuning", &res_value); SendMessage(snd_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0); }