[localization] move ResizeMoveCtrl() to stdlg.c

* Also set controls to visible by default
This commit is contained in:
Pete Batard 2013-06-23 01:16:13 +01:00
parent 8f3681188d
commit d7db1ebb94
6 changed files with 43 additions and 51 deletions

View File

@ -78,24 +78,6 @@ void free_loc_cmd(loc_cmd* lcmd)
free(lcmd);
}
// TODO: factorize this with rufus.c's MoveControl()
void ResizeMoveCtrl(HWND hDlg, HWND hCtrl, int mx, int my, int rx, int ry)
{
RECT rect;
POINT point;
GetWindowRect(hCtrl, &rect);
point.x = rect.left;
point.y = rect.top;
ScreenToClient(hDlg, &point);
GetClientRect(hCtrl, &rect);
MoveWindow(hCtrl, point.x + (int)(fScale*(float)mx), point.y + (int)(fScale*(float)my),
(rect.right - rect.left) + (int)(fScale*(float)rx),
(rect.bottom - rect.top) + (int)(fScale*(float)ry), TRUE);
InvalidateRect(hCtrl, NULL, TRUE);
}
// TODO: we need to store a revert for every action we execute here,
// or do we want to reinstantiate the dialogs?
BOOL execute_loc_cmd(loc_cmd* lcmd)

View File

@ -321,7 +321,7 @@ static wchar_t* get_token_data_line(const wchar_t* wtoken, wchar_t* wline)
return (wline[r] == 0)?NULL:&wline[r];
}
// Parse a file (ANSI or UTF-8 or UTF-16) and return the data for the first occurrence of 'token'
// Parse a file (ANSI or UTF-8 or UTF-16) and return the data for the first occurrence of 'token'
// The returned string is UTF-8 and MUST be freed by the caller
char* get_token_data_file(const char* token, const char* filename)
{
@ -366,7 +366,7 @@ out:
return ret;
}
// Parse a buffer (ANSI or UTF-8) and return the data for the 'n'th occurrence of 'token'
// Parse a buffer (ANSI or UTF-8) and return the data for the 'n'th occurrence of 'token'
// The returned string is UTF-8 and MUST be freed by the caller
char* get_token_data_buffer(const char* token, unsigned int n, const char* buffer, size_t buffer_size)
{
@ -575,7 +575,7 @@ out:
if (fd_in != NULL) fclose(fd_in);
if (fd_out != NULL) fclose(fd_out);
// If an insertion occurred, delete existing file and use the new one
// If an insertion occurred, delete existing file and use the new one
if (ret != NULL) {
// We're in Windows text mode => Remove CRs if requested
fd_in = _wfopen(wtmpname, L"rb");
@ -605,10 +605,10 @@ out:
return ret;
}
// Search for a specific 'src' substring data for all occurrences of 'token', and replace
// Search for a specific 'src' substring data for all occurrences of 'token', and replace
// it with 'rep'. File can be ANSI or UNICODE and is overwritten. Parameters are UTF-8.
// The parsed line is of the form: [ ]token[ ]data
// Returns a pointer to rep if replacement occurred, NULL otherwise
// Returns a pointer to rep if replacement occurred, NULL otherwise
char* replace_in_token_data(const char* filename, const char* token, const char* src, const char* rep, BOOL dos2unix)
{
const wchar_t* outmode[] = { L"w", L"w, ccs=UTF-8", L"w, ccs=UTF-16LE" };
@ -720,7 +720,7 @@ out:
if (fd_in != NULL) fclose(fd_in);
if (fd_out != NULL) fclose(fd_out);
// If a replacement occurred, delete existing file and use the new one
// If a replacement occurred, delete existing file and use the new one
if (ret != NULL) {
// We're in Windows text mode => Remove CRs if requested
fd_in = _wfopen(wtmpname, L"rb");

View File

@ -1095,20 +1095,10 @@ out:
ExitThread(0);
}
void MoveControl(HWND hDlg, int nID, float vertical_shift)
{
RECT rect;
POINT point;
HWND hControl;
hControl = GetDlgItem(hDlg, nID);
GetWindowRect(hControl, &rect);
point.x = rect.left;
point.y = rect.top;
ScreenToClient(hDlg, &point);
GetClientRect(hControl, &rect);
MoveWindow(hControl, point.x, point.y + (int)(fScale*(advanced_mode?vertical_shift:-vertical_shift)),
(rect.right - rect.left), (rect.bottom - rect.top), TRUE);
// Move a control along the Y axis according to the advanced mode setting
void MoveCtrlY(HWND hDlg, int nID, float vertical_shift) {
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, nID), 0,
(int)(advanced_mode?vertical_shift:-vertical_shift), 0, 0);
}
void SetPassesTooltip(void)
@ -1137,14 +1127,14 @@ void ToggleAdvanced(void)
point.y + (int)(fScale*(advanced_mode?dialog_shift:-dialog_shift)), TRUE);
// Move the status bar up or down
MoveControl(hMainDialog, IDC_STATUS, dialog_shift);
MoveControl(hMainDialog, IDC_START, dialog_shift);
MoveControl(hMainDialog, IDC_PROGRESS, dialog_shift);
MoveControl(hMainDialog, IDC_ABOUT, dialog_shift);
MoveControl(hMainDialog, IDC_LOG, dialog_shift);
MoveControl(hMainDialog, IDCANCEL, dialog_shift);
MoveCtrlY(hMainDialog, IDC_STATUS, dialog_shift);
MoveCtrlY(hMainDialog, IDC_START, dialog_shift);
MoveCtrlY(hMainDialog, IDC_PROGRESS, dialog_shift);
MoveCtrlY(hMainDialog, IDC_ABOUT, dialog_shift);
MoveCtrlY(hMainDialog, IDC_LOG, dialog_shift);
MoveCtrlY(hMainDialog, IDCANCEL, dialog_shift);
#ifdef RUFUS_TEST
MoveControl(hMainDialog, IDC_TEST, dialog_shift);
MoveCtrlY(hMainDialog, IDC_TEST, dialog_shift);
#endif
// And do the same for the log dialog while we're at it
@ -1153,9 +1143,9 @@ void ToggleAdvanced(void)
point.y = (rect.bottom - rect.top);
MoveWindow(hLogDlg, rect.left, rect.top, point.x,
point.y + (int)(fScale*(advanced_mode?dialog_shift:-dialog_shift)), TRUE);
MoveControl(hLogDlg, IDC_LOG_CLEAR, dialog_shift);
MoveControl(hLogDlg, IDC_LOG_SAVE, dialog_shift);
MoveControl(hLogDlg, IDCANCEL, dialog_shift);
MoveCtrlY(hLogDlg, IDC_LOG_CLEAR, dialog_shift);
MoveCtrlY(hLogDlg, IDC_LOG_SAVE, dialog_shift);
MoveCtrlY(hLogDlg, IDCANCEL, dialog_shift);
GetWindowRect(hLog, &rect);
point.x = (rect.right - rect.left);
point.y = (rect.bottom - rect.top) + (int)(fScale*(advanced_mode?dialog_shift:-dialog_shift));

View File

@ -284,6 +284,7 @@ extern const char* StrError(DWORD error_code);
extern char* GuidToString(const GUID* guid);
extern char* SizeToHumanReadable(LARGE_INTEGER size);
extern void CenterDialog(HWND hDlg);
extern void ResizeMoveCtrl(HWND hDlg, HWND hCtrl, int dx, int dy, int dw, int dh);
extern void CreateStatusBar(void);
extern void SetTitleBarIcon(HWND hDlg);
extern BOOL CreateTaskbarList(void);

View File

@ -58,10 +58,10 @@ BEGIN
COMBOBOX IDC_NBPASSES,119,159,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_BOOTTYPE,119,183,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON
CONTROL "Use Rufus MBR with BIOS ID:",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,13,248,106,10
CONTROL "Use Rufus MBR with BIOS ID:",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,248,106,10
PUSHBUTTON "",IDC_ADVANCED,63,148,14,10,BS_TOP | BS_FLAT
GROUPBOX "Advanced Options",IDC_ADVANCED_GROUP,7,210,192,54,NOT WS_VISIBLE
COMBOBOX IDC_DISK_ID,119,246,73,30,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Advanced Options",IDC_ADVANCED_GROUP,7,210,192,54
COMBOBOX IDC_DISK_ID,119,246,73,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Add fixes for old BIOSes (extra partition, align, etc.)",IDC_EXTRA_PARTITION,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,235,184,10
CONTROL "List fixed (non-flash) or unpartitioned USB disks",IDC_ENABLE_FIXED_DISKS,

View File

@ -435,6 +435,25 @@ void CenterDialog(HWND hDlg)
MoveWindow(hDlg, Point.x, Point.y, nWidth, nHeight, FALSE);
}
/*
* Change the position and/or size of a control belonging to a specific dialog
*/
void ResizeMoveCtrl(HWND hDlg, HWND hCtrl, int dx, int dy, int dw, int dh)
{
RECT rect;
POINT point;
GetWindowRect(hCtrl, &rect);
point.x = rect.left;
point.y = rect.top;
ScreenToClient(hDlg, &point);
GetClientRect(hCtrl, &rect);
MoveWindow(hCtrl, point.x + (int)(fScale*(float)dx), point.y + (int)(fScale*(float)dy),
(rect.right - rect.left) + (int)(fScale*(float)dw),
(rect.bottom - rect.top) + (int)(fScale*(float)dh), TRUE);
InvalidateRect(hCtrl, NULL, TRUE);
}
/*
* License callback
*/