mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-27 13:14:26 -04:00
[ui] use our own custom bar with text
* Needed because native Windows produces obnoxious tearing on redrawing. * Also rename global partition scheme variable back to 'pt' * Also fix major and minor version numbers in the .rc
This commit is contained in:
parent
2fbe7be870
commit
7fef3c6434
5 changed files with 79 additions and 44 deletions
94
src/rufus.c
94
src/rufus.c
|
@ -102,7 +102,7 @@ BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }, bi_save = { 0 }
|
|||
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH];
|
||||
char *image_path = NULL, *short_image_path;
|
||||
float fScale = 1.0f;
|
||||
int default_fs, fs, bt, ps, tt;
|
||||
int default_fs, fs, bt, pt, tt; // file system, boot type, partition type, target type
|
||||
int cbw, ddw, ddbh = 0, bh = 0; // (empty) check box width, (empty) drop down width, button height (for and without dropdown match)
|
||||
uint32_t dur_mins, dur_secs;
|
||||
loc_cmd* selected_locale = NULL;
|
||||
|
@ -334,19 +334,19 @@ static void SetPartitionSchemeAndTargetSystem(BOOL only_target)
|
|||
preferred_ps = PARTITION_STYLE_MBR;
|
||||
}
|
||||
SetComboEntry(hPartitionScheme, preferred_ps);
|
||||
ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
|
||||
pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
|
||||
}
|
||||
|
||||
has_uefi_csm = FALSE;
|
||||
if (allowed_target_system[0] && (ps != PARTITION_STYLE_GPT)) {
|
||||
if (allowed_target_system[0] && (pt != PARTITION_STYLE_GPT)) {
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem,
|
||||
ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_031)), TT_BIOS));
|
||||
has_uefi_csm = TRUE;
|
||||
}
|
||||
if (allowed_target_system[1] && !((ps == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) )
|
||||
if (allowed_target_system[1] && !((pt == PARTITION_STYLE_MBR) && IS_BIOS_BOOTABLE(img_report) && IS_EFI_BOOTABLE(img_report)) )
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem,
|
||||
ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_032)), TT_UEFI));
|
||||
if (allowed_target_system[2] && ((ps != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE)))
|
||||
if (allowed_target_system[2] && ((pt != PARTITION_STYLE_GPT) || (bt == BT_NON_BOOTABLE)))
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hTargetSystem,
|
||||
ComboBox_AddStringU(hTargetSystem, lmprintf(MSG_033)), TT_BIOS));
|
||||
IGNORE_RETVAL(ComboBox_SetCurSel(hTargetSystem, 0));
|
||||
|
@ -647,7 +647,7 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes)
|
|||
BOOL actual_enable_fix = enable;
|
||||
static UINT uXPartChecked = BST_UNCHECKED;
|
||||
|
||||
if ((ps != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) {
|
||||
if ((pt != PARTITION_STYLE_MBR) || (tt != TT_BIOS) || ((bt == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) {
|
||||
// These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable
|
||||
actual_enable_mbr = FALSE;
|
||||
actual_enable_fix = FALSE;
|
||||
|
@ -1444,7 +1444,7 @@ static BOOL BootCheck(void)
|
|||
return FALSE;
|
||||
}
|
||||
if (SelectedDrive.MediaType != FixedMedia) {
|
||||
if ((tt == TT_UEFI) && (ps == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) {
|
||||
if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) {
|
||||
// Up to Windows 10 Creators Update, we were screwed, since we need access to 2 partitions at the same time.
|
||||
// Thankfully, the newer Windows allow mounting multiple partitions on the same REMOVABLE drive.
|
||||
MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
||||
|
@ -1750,25 +1750,69 @@ static __inline const char* IsAlphaOrBeta(void)
|
|||
static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hDC;
|
||||
RECT rect;
|
||||
PAINTSTRUCT paint_struct;
|
||||
wchar_t winfo[128] = L"Copying ISO files...";
|
||||
RECT rc;
|
||||
PAINTSTRUCT ps;
|
||||
SIZE size;
|
||||
LONG full_right;
|
||||
wchar_t winfo[128];
|
||||
static WORD pos = 0, min = 0, max = 0xFFFF;
|
||||
static COLORREF color = RGB(0x06, 0xB0, 0x25);
|
||||
|
||||
switch (message) {
|
||||
|
||||
case PBM_SETSTATE:
|
||||
switch (wParam) {
|
||||
case PBST_NORMAL:
|
||||
color = RGB(0x06, 0xB0, 0x25);
|
||||
break;
|
||||
case PBST_PAUSED:
|
||||
color = RGB(0xDA, 0xCB, 0x26);
|
||||
break;
|
||||
case PBST_ERROR:
|
||||
color = RGB(0xDA, 0x26, 0x26);
|
||||
break;
|
||||
}
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case PBM_SETRANGE:
|
||||
min = lParam & 0xFFFF;
|
||||
max = lParam >> 16;
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case PBM_SETPOS:
|
||||
pos = (WORD)wParam;
|
||||
InvalidateRect(hProgress, NULL, TRUE);
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hCtrl, &paint_struct);
|
||||
CallWindowProc(progress_original_proc, hCtrl, message, (WPARAM)hDC, lParam);
|
||||
hDC = BeginPaint(hCtrl, &ps);
|
||||
GetClientRect(hCtrl, &rc);
|
||||
SelectObject(hDC, GetStockObject(DC_PEN));
|
||||
SelectObject(hDC, GetStockObject(NULL_BRUSH));
|
||||
SetDCPenColor(hDC, RGB(0xBC, 0xBC, 0xBC));
|
||||
Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
|
||||
InflateRect(&rc, -1, -1);
|
||||
// TODO: Handle SetText message so we can avoid this call
|
||||
GetWindowTextW(hProgress, winfo, ARRAYSIZE(winfo));
|
||||
SetBkMode(hDC, TRANSPARENT);
|
||||
full_right = rc.right;
|
||||
rc.right = (pos > min) ? MulDiv(pos - min, rc.right, max - min) : rc.left;
|
||||
SelectObject(hDC, hInfoFont);
|
||||
GetTextExtentPoint32(hDC, winfo, wcslen(winfo), &size);
|
||||
// First half
|
||||
SetTextColor(hDC, RGB(0xFF, 0xFF, 0xFF));
|
||||
SetTextAlign(hDC, TA_CENTER | TA_BASELINE);
|
||||
GetClientRect(hCtrl, &rect);
|
||||
ExtTextOutW(hDC, rect.right / 2, rect.bottom / 2 + (int)(4.0f * fScale),
|
||||
ETO_CLIPPED | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0),
|
||||
&rect, winfo, (int)wcslen(winfo), NULL);
|
||||
EndPaint(hCtrl, &paint_struct);
|
||||
SetBkColor(hDC, color);
|
||||
ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2,
|
||||
ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0),
|
||||
&rc, winfo, wcslen(winfo), NULL);
|
||||
// Second half
|
||||
SetTextColor(hDC, RGB(0x00, 0x00, 0x00));
|
||||
SetBkColor(hDC, RGB(0xE6, 0xE6, 0xE6));
|
||||
rc.left = rc.right;
|
||||
rc.right = full_right;
|
||||
ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2,
|
||||
ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL | (right_to_left_mode ? ETO_RTLREADING : 0),
|
||||
&rc, winfo, wcslen(winfo), NULL);
|
||||
EndPaint(hCtrl, &ps);
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
|
||||
|
@ -2804,7 +2848,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
RECT rc, DialogRect, DesktopRect;
|
||||
LONG progress_style;
|
||||
HDC hDC;
|
||||
PAINTSTRUCT paint_struct;
|
||||
PAINTSTRUCT ps;
|
||||
int nDeviceIndex, i, nWidth, nHeight, nb_devices, selected_language, offset;
|
||||
char tmp[128];
|
||||
wchar_t* wbuffer = NULL;
|
||||
|
@ -2976,7 +3020,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
case IDC_PARTITION_TYPE:
|
||||
if (HIWORD(wParam) != CBN_SELCHANGE)
|
||||
break;
|
||||
ps = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
|
||||
pt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
|
||||
SetPartitionSchemeAndTargetSystem(TRUE);
|
||||
SetFileSystemAndClusterSize(NULL);
|
||||
EnableMBRBootOptions(TRUE, FALSE);
|
||||
|
@ -3026,7 +3070,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
SetProposedLabel(ComboBox_GetCurSel(hDeviceList));
|
||||
EnableControls(TRUE);
|
||||
tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
|
||||
ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem));
|
||||
pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem));
|
||||
return (INT_PTR)TRUE;
|
||||
case IDC_SELECT:
|
||||
if (iso_provided) {
|
||||
|
@ -3075,7 +3119,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
// Just in case
|
||||
bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
||||
tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
|
||||
ps = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem));
|
||||
pt = (int)ComboBox_GetItemData(hTargetSystem, ComboBox_GetCurSel(hTargetSystem));
|
||||
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
||||
write_as_image = FALSE;
|
||||
// Disable all controls except Cancel
|
||||
|
@ -3334,9 +3378,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hDlg, &paint_struct);
|
||||
hDC = BeginPaint(hDlg, &ps);
|
||||
OnPaint(hDC);
|
||||
EndPaint(hDlg, &paint_struct);
|
||||
EndPaint(hDlg, &ps);
|
||||
break;
|
||||
|
||||
case WM_CTLCOLORSTATIC:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue