winecfg: x11drv tab update
Mike Hearn
mike at navi.cx
Sat Sep 25 11:36:58 CDT 2004
- switch x11drvdlg to kernel_style, and clean up some superflous code
- more win32 heapification
- move getDialogItemText into header and rename, use some more in x11drv page
- make label phrasing consistent in x11drv page
-------------- next part --------------
--- programs/winecfg.working/En.rc 2004-09-20 22:29:29.883438216 +0100
+++ programs/winecfg/En.rc 2004-09-20 21:45:51.203538072 +0100
@@ -62,7 +62,7 @@
LTEXT "Screen color depth: ",IDC_STATIC,8,10,70,30
COMBOBOX IDC_SCREEN_DEPTH,80,8,170,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CONTROL "Can DirectX programs prevent the mouse leaving their window?",IDC_DX_MOUSE_GRAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,35,230,8
+ CONTROL "Allow DirectX apps to stop the mouse leaving their window",IDC_DX_MOUSE_GRAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,35,230,8
CONTROL "Enable desktop double buffering",IDC_DOUBLE_BUFFER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,45,230,8
GROUPBOX " Window settings ",IDC_STATIC,8,25,244,120
--- programs/winecfg.working/drive.c 2004-09-20 22:29:29.949428184 +0100
+++ programs/winecfg/drive.c 2004-09-20 22:27:22.710771400 +0100
@@ -537,32 +537,32 @@
WINE_TRACE("controlID=%d\n", controlID);
switch (controlID) {
case IDC_EDIT_LABEL: {
- char *label = getDialogItemText(hDlg, controlID);
+ char *label = get_control_text(hDlg, controlID);
if(!label) label = strdup("");
setDriveLabel(editDriveEntry, label);
refreshDriveDlg(driveDlgHandle);
- if (label) free(label);
+ if (label) HeapFree(GetProcessHeap(), 0, label);
break;
}
case IDC_EDIT_PATH: {
- char *path = getDialogItemText(hDlg, controlID);
+ char *path = get_control_text(hDlg, controlID);
if (!path) path = strdup("fake_windows"); /* default to assuming fake_windows in the .wine directory */
WINE_TRACE("got path from control of '%s'\n", path);
setDrivePath(editDriveEntry, path);
- if(path) free(path);
+ if (path) HeapFree(GetProcessHeap(), 0, path);
break;
}
case IDC_EDIT_SERIAL: {
- char *serial = getDialogItemText(hDlg, controlID);
+ char *serial = get_control_text(hDlg, controlID);
if(!serial) serial = strdup("");
setDriveSerial(editDriveEntry, serial);
- if (serial) free (serial);
+ if (serial) HeapFree(GetProcessHeap(), 0, serial);
break;
}
case IDC_EDIT_DEVICE: {
- char *device = getDialogItemText(hDlg,controlID);
+ char *device = get_control_text(hDlg,controlID);
/* TODO: handle device if/when it makes sense to do so.... */
- if (device) free(device);
+ if (device) HeapFree(GetProcessHeap(), 0, device);
refreshDriveDlg(driveDlgHandle);
break;
}
@@ -634,15 +634,15 @@
case IDC_RADIO_ASSIGN:
{
char *edit, *serial;
- edit = getDialogItemText(hDlg, IDC_EDIT_LABEL);
+ edit = get_control_text(hDlg, IDC_EDIT_LABEL);
if(!edit) edit = strdup("");
setDriveLabel(editDriveEntry, edit);
- free(edit);
+ HeapFree(GetProcessHeap(), 0, edit);
- serial = getDialogItemText(hDlg, IDC_EDIT_SERIAL);
+ serial = get_control_text(hDlg, IDC_EDIT_SERIAL);
if(!serial) serial = strdup("");
setDriveSerial(editDriveEntry, serial);
- free(serial);
+ HeapFree(GetProcessHeap(), 0, serial);
/* TODO: we don't have a device at this point */
/* setDriveValue(editWindowLetter, "Device", NULL); */
@@ -668,9 +668,11 @@
}
void onAddDriveClicked(HWND hDlg) {
- /* we should allocate a drive letter automatically. We also need some way to let the user choose the mapping point,
- for now we will just force them to enter a path automatically, with / being the default. In future we should
- be able to temporarily map / then invoke the directory chooser dialog. */
+ /* we should allocate a drive letter automatically. We also need
+ some way to let the user choose the mapping point, for now we
+ will just force them to enter a path automatically, with / being
+ the default. In future we should be able to temporarily map /
+ then invoke the directory chooser dialog. */
char newLetter = 'C'; /* we skip A and B, they are historically floppy drives */
long mask = ~drive_available_mask(0); /* the mask is now which drives aren't available */
--- programs/winecfg.working/winecfg.h 2004-09-20 22:29:29.829446424 +0100
+++ programs/winecfg/winecfg.h 2004-09-20 22:15:32.896679544 +0100
@@ -93,7 +93,6 @@
INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* some basic utilities to make win32 suck less */
-char *getDialogItemText(HWND hDlg, WORD controlID);
#define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
@@ -105,6 +104,14 @@
return strcpy(r, s);
}
+static inline char *get_control_text(HWND dialog, WORD id)
+{
+ HWND item = GetDlgItem(dialog, id);
+ int len = GetWindowTextLength(item) + 1;
+ char *result = HeapAlloc(GetProcessHeap(), 0, len);
+ if (GetWindowText(item, result, len) == 0) return NULL;
+ return result;
+}
#define WINE_KEY_ROOT "Software\\Wine\\Testing\\Config"
--- programs/winecfg.working/winecfg.c 2004-09-20 22:29:29.761456760 +0100
+++ programs/winecfg/winecfg.c 2004-09-20 22:15:37.645957544 +0100
@@ -487,15 +487,6 @@
return result;
}
-/* returns a string with the window text of the dialog item. user is responsible for freeing the result */
-char *getDialogItemText(HWND hDlg, WORD controlID) {
- HWND item = GetDlgItem(hDlg, controlID);
- int len = GetWindowTextLength(item) + 1;
- char *result = malloc(len);
- if (GetWindowText(item, result, len) == 0) return NULL;
- return result;
-}
-
void PRINTERROR(void)
{
LPSTR msg;
--- programs/winecfg.working/x11drvdlg.c 2004-09-20 22:29:30.048413136 +0100
+++ programs/winecfg/x11drvdlg.c 2004-09-20 22:35:36.080767760 +0100
@@ -72,109 +72,119 @@
updating_ui = FALSE;
}
-/* pokes the win32 api to setup the dialog from the config struct */
-void initGraphDlg (HWND hDlg)
+static void init_dialog (HWND dialog)
{
static char *default_desktop = "640x480";
char *buf;
char *bufindex;
- update_gui_for_desktop_mode(hDlg);
+ update_gui_for_desktop_mode(dialog);
updating_ui = TRUE;
/* desktop size */
buf = get(keypath("x11drv"), "Desktop", default_desktop);
bufindex = strchr(buf, 'x');
+
if(!bufindex) /* handle invalid "Desktop" values */
{
- free(buf);
- buf = strdup(default_desktop);
- bufindex = strchr(buf, 'x');
+ HeapFree(GetProcessHeap(), 0, buf);
+ buf = strdupA(default_desktop);
+ bufindex = strchr(buf, 'x');
}
+
*bufindex = '\0';
bufindex++;
- SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), buf);
- SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), bufindex);
+ SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), buf);
+ SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), bufindex);
HeapFree(GetProcessHeap(), 0, buf);
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "8 bit");
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "16 bit");
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "24 bit");
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "32 bit"); /* is this valid? */
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "8 bit");
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "16 bit");
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "24 bit");
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "32 bit"); /* is this valid? */
buf = get(keypath("x11drv"), "ScreenDepth", "24");
if (strcmp(buf, "8") == 0)
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_SETCURSEL, 0, 0);
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_SETCURSEL, 0, 0);
else if (strcmp(buf, "16") == 0)
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_SETCURSEL, 1, 0);
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_SETCURSEL, 1, 0);
else if (strcmp(buf, "24") == 0)
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_SETCURSEL, 2, 0);
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_SETCURSEL, 2, 0);
else if (strcmp(buf, "32") == 0)
- SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_SETCURSEL, 3, 0);
+ SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_SETCURSEL, 3, 0);
else
WINE_ERR("Invalid screen depth read from registry (%s)\n", buf);
HeapFree(GetProcessHeap(), 0, buf);
- SendDlgItemMessage(hDlg, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
- SendDlgItemMessage(hDlg, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
+ SendDlgItemMessage(dialog, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
+ SendDlgItemMessage(dialog, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
buf = get(keypath("x11drv"), "DXGrab", "Y");
if (IS_OPTION_TRUE(*buf))
- CheckDlgButton(hDlg, IDC_DX_MOUSE_GRAB, BST_CHECKED);
+ CheckDlgButton(dialog, IDC_DX_MOUSE_GRAB, BST_CHECKED);
else
- CheckDlgButton(hDlg, IDC_DX_MOUSE_GRAB, BST_UNCHECKED);
+ CheckDlgButton(dialog, IDC_DX_MOUSE_GRAB, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
buf = get(keypath("x11drv"), "DesktopDoubleBuffered", "Y");
if (IS_OPTION_TRUE(*buf))
- CheckDlgButton(hDlg, IDC_DOUBLE_BUFFER, BST_CHECKED);
+ CheckDlgButton(dialog, IDC_DOUBLE_BUFFER, BST_CHECKED);
else
- CheckDlgButton(hDlg, IDC_DOUBLE_BUFFER, BST_UNCHECKED);
+ CheckDlgButton(dialog, IDC_DOUBLE_BUFFER, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
updating_ui = FALSE;
}
-void setFromDesktopSizeEdits(HWND hDlg) {
- char *width = HeapAlloc(GetProcessHeap(), 0, RES_MAXLEN+1);
- char *height = HeapAlloc(GetProcessHeap(), 0, RES_MAXLEN+1);
- char *new = HeapAlloc(GetProcessHeap(), 0, (RES_MAXLEN*2) + 2);
+static void set_from_desktop_edits(HWND dialog) {
+ char *width, *height, *new;
- if (updating_ui) goto end;
+ if (updating_ui) return;
WINE_TRACE("\n");
-
- GetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), width, RES_MAXLEN+1);
- GetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), height, RES_MAXLEN+1);
- if (strcmp(width, "") == 0) strcpy(width, "640");
- if (strcmp(height, "") == 0) strcpy(height, "480");
+ width = get_control_text(dialog, IDC_DESKTOP_WIDTH);
+ height = get_control_text(dialog, IDC_DESKTOP_HEIGHT);
+
+ if (strcmp(width, "") == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, width);
+ width = strdupA("640");
+ }
+ if (strcmp(height, "") == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, height);
+ height = strdupA("480");
+ }
+
+ new = HeapAlloc(GetProcessHeap(), 0, strlen(width) + strlen(height) + 2 /* x + terminator */);
sprintf(new, "%sx%s", width, height);
set(keypath("x11drv"), "Desktop", new);
-end:
HeapFree(GetProcessHeap(), 0, width);
HeapFree(GetProcessHeap(), 0, height);
HeapFree(GetProcessHeap(), 0, new);
}
-void onEnableDesktopClicked(HWND hDlg) {
+void on_enable_desktop_clicked(HWND dialog) {
WINE_TRACE("\n");
- if (IsDlgButtonChecked(hDlg, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
+
+ if (IsDlgButtonChecked(dialog, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
/* it was just unchecked, so read the values of the edit boxes, set the config value */
- setFromDesktopSizeEdits(hDlg);
+ set_from_desktop_edits(dialog);
} else {
/* it was just checked, so remove the config values */
set(keypath("x11drv"), "Desktop", NULL);
}
- update_gui_for_desktop_mode(hDlg);
+
+ update_gui_for_desktop_mode(dialog);
}
-void onScreenDepthChanged(HWND hDlg) {
- char *newvalue = getDialogItemText(hDlg, IDC_SCREEN_DEPTH);
+static void on_screen_depth_changed(HWND dialog) {
+ char *newvalue = get_control_text(dialog, IDC_SCREEN_DEPTH);
char *spaceIndex = strchr(newvalue, ' ');
WINE_TRACE("newvalue=%s\n", newvalue);
@@ -182,19 +192,19 @@
*spaceIndex = '\0';
set(keypath("x11drv"), "ScreenDepth", newvalue);
- free(newvalue);
+ HeapFree(GetProcessHeap(), 0, newvalue);
}
-void onDXMouseGrabClicked(HWND hDlg) {
- if (IsDlgButtonChecked(hDlg, IDC_DX_MOUSE_GRAB) == BST_CHECKED)
+static void on_dx_mouse_grab_clicked(HWND dialog) {
+ if (IsDlgButtonChecked(dialog, IDC_DX_MOUSE_GRAB) == BST_CHECKED)
set(keypath("x11drv"), "DXGrab", "Y");
else
set(keypath("x11drv"), "DXGrab", "N");
}
-void onDoubleBufferClicked(HWND hDlg) {
- if (IsDlgButtonChecked(hDlg, IDC_DOUBLE_BUFFER) == BST_CHECKED)
+static void on_double_buffer_clicked(HWND dialog) {
+ if (IsDlgButtonChecked(dialog, IDC_DOUBLE_BUFFER) == BST_CHECKED)
set(keypath("x11drv"), "DesktopDoubleBuffered", "Y");
else
set(keypath("x11drv"), "DesktopDoubleBuffered", "N");
@@ -216,20 +226,20 @@
case EN_CHANGE: {
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
if ( ((LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT)) && !updating_ui )
- setFromDesktopSizeEdits(hDlg);
+ set_from_desktop_edits(hDlg);
break;
}
case BN_CLICKED: {
if (updating_ui) break;
switch(LOWORD(wParam)) {
- case IDC_ENABLE_DESKTOP: onEnableDesktopClicked(hDlg); break;
- case IDC_DX_MOUSE_GRAB: onDXMouseGrabClicked(hDlg); break;
- case IDC_DOUBLE_BUFFER: onDoubleBufferClicked(hDlg); break;
- };
+ case IDC_ENABLE_DESKTOP: on_enable_desktop_clicked(hDlg); break;
+ case IDC_DX_MOUSE_GRAB: on_dx_mouse_grab_clicked(hDlg); break;
+ case IDC_DOUBLE_BUFFER: on_double_buffer_clicked(hDlg); break;
+ }
break;
}
case CBN_SELCHANGE: {
- if (LOWORD(wParam) == IDC_SCREEN_DEPTH) onScreenDepthChanged(hDlg);
+ if (LOWORD(wParam) == IDC_SCREEN_DEPTH) on_screen_depth_changed(hDlg);
break;
}
@@ -251,7 +261,7 @@
break;
}
case PSN_SETACTIVE: {
- initGraphDlg (hDlg);
+ init_dialog (hDlg);
break;
}
}
More information about the wine-patches
mailing list