ipaddress: uniform naming

Dimitrie O. Paun dpaun at rogers.com
Thu Mar 24 20:03:35 CST 2005


I don't much like hungarian notation. I used to hate it.
Not so much anymore, but that's besides the point.

Back in the day when I introduced these names they seemed
like a good idea. I was wrong, mea culpa. They are not
particulary good (why capitalize structure members?),
and they don't mix well with the rest of the naming
convention in the other controls.

They irk me every time I see them, so I'd like to change
them to something saner.

ChangeLog
    Rename the fields used in IPADDRESS_INFO to follow
    the naming convention used in the other controls.


Index: dlls/comctl32/ipaddress.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/ipaddress.c,v
retrieving revision 1.40
diff -u -r1.40 ipaddress.c
--- dlls/comctl32/ipaddress.c	27 Oct 2004 21:15:53 -0000	1.40
+++ dlls/comctl32/ipaddress.c	25 Mar 2005 01:55:33 -0000
@@ -52,17 +52,17 @@
 
 typedef struct
 {
-    HWND     EditHwnd;
-    INT      LowerLimit;
-    INT      UpperLimit;
-    WNDPROC  OrigProc;
+    HWND     hwndEdit;
+    INT      nLowerLimit;
+    INT      nUpperLimit;
+    WNDPROC  wndProcEdit;
 } IPPART_INFO;
 
 typedef struct
 {
-    HWND	Self;
-    HWND	Notify;
-    IPPART_INFO	Part[4];
+    HWND        hwndSelf;
+    HWN         hwndNotify;
+    IPPART_INFO ipPart[4];
 } IPADDRESS_INFO;
 
 static const WCHAR IP_SUBCLASS_PROP[] = 
@@ -78,11 +78,11 @@
 
 static LRESULT IPADDRESS_Notify (IPADDRESS_INFO *infoPtr, UINT command)
 {
-    HWND hwnd = infoPtr->Self;
+    HWND hwnd = infoPtr->hwndSelf;
 
     TRACE("(command=%x)\n", command);
 
-    return SendMessageW (infoPtr->Notify, WM_COMMAND,
+    return SendMessageW (infoPtr->hwndNotify, WM_COMMAND,
              MAKEWPARAM (GetWindowLongPtrW (hwnd, GWLP_ID), command), (LPARAM)hwnd);
 }
 
@@ -92,14 +92,14 @@
 
     TRACE("(field=%x, value=%d)\n", field, value);
 
-    nmip.hdr.hwndFrom = infoPtr->Self;
-    nmip.hdr.idFrom   = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
+    nmip.hdr.hwndFrom = infoPtr->hwndSelf;
+    nmip.hdr.idFrom   = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID);
     nmip.hdr.code     = IPN_FIELDCHANGED;
 
     nmip.iField = field;
     nmip.iValue = value;
 
-    SendMessageW (infoPtr->Notify, WM_NOTIFY,
+    SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
                   (WPARAM)nmip.hdr.idFrom, (LPARAM)&nmip);
 
     TRACE("<-- %d\n", nmip.iValue);
@@ -115,7 +115,7 @@
     TRACE("(hwnd=%p)\n", hwnd);
 
     for (i = 0; i < 4; i++)
-        if (infoPtr->Part[i].EditHwnd == hwnd) return i;
+        if (infoPtr->ipPart[i].hwndEdit == hwnd) return i;
 
     ERR("We subclassed the wrong window! (hwnd=%p)\n", hwnd);
     return -1;
@@ -131,17 +131,17 @@
 
     TRACE("\n");
 
-    GetClientRect (infoPtr->Self, &rect);
+    GetClientRect (infoPtr->hwndSelf, &rect);
     DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
 
     for (i = 0; i < 3; i++) {
-        GetWindowRect (infoPtr->Part[i].EditHwnd, &rcPart);
+        GetWindowRect (infoPtr->ipPart[i].hwndEdit, &rcPart);
 	pt.x = rcPart.right;
-	ScreenToClient(infoPtr->Self, &pt);
+	ScreenToClient(infoPtr->hwndSelf, &pt);
 	rect.left = pt.x;
-	GetWindowRect (infoPtr->Part[i+1].EditHwnd, &rcPart);
+	GetWindowRect (infoPtr->ipPart[i+1].hwndEdit, &rcPart);
 	pt.x = rcPart.left;
-	ScreenToClient(infoPtr->Self, &pt);
+	ScreenToClient(infoPtr->hwndSelf, &pt);
 	rect.right = pt.x;
 	DrawTextW(hdc, dotW, 1, &rect, DT_SINGLELINE | DT_CENTER | DT_BOTTOM);
     }
@@ -173,24 +173,24 @@
     edit.top    = rcClient.top + 2;
     edit.bottom = rcClient.bottom - 2;
 
-    infoPtr->Self = hwnd;
-    infoPtr->Notify = lpCreate->hwndParent;
+    infoPtr->hwndSelf = hwnd;
+    infoPtr->hwndNotify = lpCreate->hwndParent;
 
     for (i = 0; i < 4; i++) {
-	IPPART_INFO* part = &infoPtr->Part[i];
+	IPPART_INFO* part = &infoPtr->ipPart[i];
 
-	part->LowerLimit = 0;
-	part->UpperLimit = 255;
+	part->nLowerLimit = 0;
+	part->nUpperLimit = 255;
         edit.left = rcClient.left + i*fieldsize + 6;
         edit.right = rcClient.left + (i+1)*fieldsize - 2;
-        part->EditHwnd =
+        part->hwndEdit =
 		CreateWindowW (EDIT, NULL, WS_CHILD | WS_VISIBLE | ES_CENTER,
                                edit.left, edit.top, edit.right - edit.left,
 			       edit.bottom - edit.top, hwnd, (HMENU) 1,
 			       (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), NULL);
-	SetPropW(part->EditHwnd, IP_SUBCLASS_PROP, hwnd);
-        part->OrigProc = (WNDPROC)
-		SetWindowLongPtrW (part->EditHwnd, GWLP_WNDPROC,
+	SetPropW(part->hwndEdit, IP_SUBCLASS_PROP, hwnd);
+        part->wndProcEdit = (WNDPROC)
+		SetWindowLongPtrW (part->hwndEdit, GWLP_WNDPROC,
 				(DWORD_PTR)IPADDRESS_SubclassProc);
     }
 
@@ -205,11 +205,11 @@
     TRACE("\n");
 
     for (i = 0; i < 4; i++) {
-	IPPART_INFO* part = &infoPtr->Part[i];
-        SetWindowLongPtrW (part->EditHwnd, GWLP_WNDPROC, (DWORD_PTR)part->OrigProc);
+	IPPART_INFO* part = &infoPtr->ipPart[i];
+        SetWindowLongPtrW (part->hwndEdit, GWLP_WNDPROC, (DWORD_PTR)part->wndProcEdit);
     }
 
-    SetWindowLongPtrW (infoPtr->Self, 0, 0);
+    SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
     Free (infoPtr);
     return 0;
 }
@@ -223,9 +223,9 @@
 
     if (hdc) return IPADDRESS_Draw (infoPtr, hdc);
 
-    hdc = BeginPaint (infoPtr->Self, &ps);
+    hdc = BeginPaint (infoPtr->hwndSelf, &ps);
     IPADDRESS_Draw (infoPtr, hdc);
-    EndPaint (infoPtr->Self, &ps);
+    EndPaint (infoPtr->hwndSelf, &ps);
     return 0;
 }
 
@@ -237,7 +237,7 @@
     TRACE("\n");
 
     for (i = 0; i < 4; i++)
-        if (GetWindowTextLengthW (infoPtr->Part[i].EditHwnd)) return FALSE;
+        if (GetWindowTextLengthW (infoPtr->ipPart[i].hwndEdit)) return FALSE;
 
     return TRUE;
 }
@@ -253,7 +253,7 @@
 
     for (i = 0; i < 4; i++) {
         ip_addr *= 256;
-        if (GetWindowTextW (infoPtr->Part[i].EditHwnd, field, 4))
+        if (GetWindowTextW (infoPtr->ipPart[i].hwndEdit, field, 4))
   	    ip_addr += atolW(field);
 	else
 	    invalid++;
@@ -270,8 +270,8 @@
 
     if ( (index < 0) || (index > 3) ) return FALSE;
 
-    infoPtr->Part[index].LowerLimit = range & 0xFF;
-    infoPtr->Part[index].UpperLimit = (range >> 8)  & 0xFF;
+    infoPtr->ipPart[index].nLowerLimit = range & 0xFF;
+    infoPtr->ipPart[index].nUpperLimit = (range >> 8)  & 0xFF;
 
     return TRUE;
 }
@@ -285,7 +285,7 @@
     TRACE("\n");
 
     for (i = 0; i < 4; i++)
-        SetWindowTextW (infoPtr->Part[i].EditHwnd, nil);
+        SetWindowTextW (infoPtr->ipPart[i].hwndEdit, nil);
 }
 
 
@@ -298,11 +298,11 @@
     TRACE("\n");
 
     for (i = 3; i >= 0; i--) {
-	IPPART_INFO* part = &infoPtr->Part[i];
+	IPPART_INFO* part = &infoPtr->ipPart[i];
         int value = ip_address & 0xff;
-	if ( (value >= part->LowerLimit) && (value <= part->UpperLimit) ) {
+	if ( (value >= part->nLowerLimit) && (value <= part->nUpperLimit) ) {
 	    wsprintfW (buf, fmt, value);
-	    SetWindowTextW (part->EditHwnd, buf);
+	    SetWindowTextW (part->hwndEdit, buf);
 	    IPADDRESS_Notify (infoPtr, EN_CHANGE);
         }
         ip_address >>= 8;
@@ -318,17 +318,17 @@
 
     if (index > 3) {
 	for (index = 0; index < 4; index++)
-	    if (!GetWindowTextLengthW(infoPtr->Part[index].EditHwnd)) break;
+	    if (!GetWindowTextLengthW(infoPtr->ipPart[index].hwndEdit)) break;
     }
     if (index < 9 || index > 3) index = 0;
 
-    SetFocus (infoPtr->Part[index].EditHwnd);
+    SetFocus (infoPtr->ipPart[index].hwndEdit);
 }
 
 
 static BOOL IPADDRESS_ConstrainField (IPADDRESS_INFO *infoPtr, int currentfield)
 {
-    IPPART_INFO *part = &infoPtr->Part[currentfield];
+    IPPART_INFO *part = &infoPtr->ipPart[currentfield];
     WCHAR field[10];
     static const WCHAR fmt[] = { '%', 'd', 0 };
     int curValue, newValue;
@@ -337,7 +337,7 @@
 
     if (currentfield < 0 || currentfield > 3) return FALSE;
 
-    if (!GetWindowTextW (part->EditHwnd, field, 4)) return FALSE;
+    if (!GetWindowTextW (part->hwndEdit, field, 4)) return FALSE;
 
     curValue = atoiW(field);
     TRACE("  curValue=%d\n", curValue);
@@ -345,14 +345,14 @@
     newValue = IPADDRESS_IPNotify(infoPtr, currentfield, curValue);
     TRACE("  newValue=%d\n", newValue);
 
-    if (newValue < part->LowerLimit) newValue = part->LowerLimit;
-    if (newValue > part->UpperLimit) newValue = part->UpperLimit;
+    if (newValue < part->nLowerLimit) newValue = part->nLowerLimit;
+    if (newValue > part->nUpperLimit) newValue = part->nUpperLimit;
 
     if (newValue == curValue) return FALSE;
 
     wsprintfW (field, fmt, newValue);
     TRACE("  field='%s'\n", debugstr_w(field));
-    return SetWindowTextW (part->EditHwnd, field);
+    return SetWindowTextW (part->hwndEdit, field);
 }
 
 
@@ -364,15 +364,15 @@
 	IPADDRESS_ConstrainField(infoPtr, cur);
 
 	if(cur < 3) {
-	    IPPART_INFO *next = &infoPtr->Part[cur + 1];
+	    IPPART_INFO *next = &infoPtr->ipPart[cur + 1];
 	    int start = 0, end = 0;
-            SetFocus (next->EditHwnd);
+            SetFocus (next->hwndEdit);
 	    if (sel != POS_DEFAULT) {
 		if (sel == POS_RIGHT)
-		    start = end = GetWindowTextLengthW(next->EditHwnd);
+		    start = end = GetWindowTextLengthW(next->hwndEdit);
 		else if (sel == POS_SELALL)
 		    end = -1;
-	        SendMessageW(next->EditHwnd, EM_SETSEL, start, end);
+	        SendMessageW(next->hwndEdit, EM_SETSEL, start, end);
 	    }
 	    return TRUE;
 	}
@@ -419,8 +419,8 @@
 LRESULT CALLBACK
 IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    HWND Self = (HWND)GetPropW (hwnd, IP_SUBCLASS_PROP);
-    IPADDRESS_INFO *infoPtr = (IPADDRESS_INFO *)GetWindowLongPtrW (Self, 0);
+    HWND hwndSelf = (HWND)GetPropW (hwnd, IP_SUBCLASS_PROP);
+    IPADDRESS_INFO *infoPtr = (IPADDRESS_INFO *)GetWindowLongPtrW (hwndSelf, 0);
     CHAR c = (CHAR)wParam;
     INT index, len = 0, startsel, endsel;
     IPPART_INFO *part;
@@ -428,7 +428,7 @@
     TRACE("(hwnd=%p msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam);
 
     if ( (index = IPADDRESS_GetPartIndex(infoPtr, hwnd)) < 0) return 0;
-    part = &infoPtr->Part[index];
+    part = &infoPtr->ipPart[index];
 
     if (uMsg == WM_CHAR || uMsg == WM_KEYDOWN) {
 	len = GetWindowTextLengthW (hwnd);
@@ -439,7 +439,7 @@
  	    if(isdigit(c)) {
 		if(len == 2 && startsel==endsel && endsel==len) {
 		    /* process the digit press before we check the field */
-		    int return_val = CallWindowProcW (part->OrigProc, hwnd, uMsg, wParam, lParam);
+		    int return_val = CallWindowProcW (part->wndProcEdit, hwnd, uMsg, wParam, lParam);
 
 		    /* if the field value was changed stay at the current field */
 		    if(!IPADDRESS_ConstrainField(infoPtr, index))
@@ -472,12 +472,12 @@
 		    break;
 		case VK_BACK:
 		    if(startsel==endsel && startsel==0 && index > 0) {
-			IPPART_INFO *prev = &infoPtr->Part[index-1];
+			IPPART_INFO *prev = &infoPtr->ipPart[index-1];
 			WCHAR val[10];
 
-			if(GetWindowTextW(prev->EditHwnd, val, 5)) {
+			if(GetWindowTextW(prev->hwndEdit, val, 5)) {
 			    val[lstrlenW(val) - 1] = 0;
-			    SetWindowTextW(prev->EditHwnd, val);
+			    SetWindowTextW(prev->hwndEdit, val);
 			}
 
 			IPADDRESS_GotoNextField(infoPtr, index - 2, POS_RIGHT);
@@ -495,7 +495,7 @@
 		IPADDRESS_Notify(infoPtr, EN_SETFOCUS);
 	    break;
     }
-    return CallWindowProcW (part->OrigProc, hwnd, uMsg, wParam, lParam);
+    return CallWindowProcW (part->wndProcEdit, hwnd, uMsg, wParam, lParam);
 }
 
 

-- 
Dimi.



More information about the wine-patches mailing list