Release 940614

Tue Jun 14 08:09:14 1994  Bob Amstadt  (bob@pooh)

	* loader/selector.c (GetCurrentPDB): 
	Added trivial function GetCurrentPDB() which returns the program
	segment prefix selector.

	* memory/heap.c (HEAP_Free): 
	If free list is empty, make the freed block the free list.

Fri Jun 10 07:56:49 1994  Bob Amstadt  (bob@pooh)

	* controls/edit.c (EDIT_SetTextMsg): 
	Do not append a newline at the end of the last line.

	* windows/event.c (SetCapture): 
	Set winHasCursor if mouse capture succeeds.

Jun 13, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/listbox.c]
	Fix bug in listbox : InsertString should call AddString if -1.

	* [controls/menu.c]
	New function GetMenuState().

	* [controls/scroll.c] [windows/nonclient.c]
	Try to make ShowScrollBar() recalc NC_ regions. Not finished !

	* [objects/text.c]
	Add Stub for TabbedTextOut(), which temporarely call Textout().

	* [windows/keyboard.c] [windows/event.c]
	New function GetKeyBoardState() with an KeyStateTable array
		& associated handling in function EVENT_key().

Mon Jun 13 16:45:24 MET DST 1994 (erik@hacktic.nl)

        * [controls/menu.c]
        IsMenu() added.

        * [loader/library.c]
        ModuleFirst(), ModuleNext(), ModuleFindName(), ModuleFindHandle()
        added.

        * [object/gdiobj.c]
        IsGDIObject() added.

        * [miscemu/int2[56].c]
        bugfix: both didn't leave flags pushed on 16bit-stack.
        (winfile gets a bit further)

        * [miscemu/int16.c]
        Added (empty).

Sat Jun 11 22:56:48 1994 Jon Tombs (jon@esix2.us.es)
	* windows/event.c:
	Added code to drop redundant motion Events in the XEvent queue.

Thu Jun  9 10:55:55 MET DST 1994  Jochen Hein ( Hein@Student.TU-Clausthal.de )

	* [misc/main.c misc/message.c include/texts.h]
	Removed the text-constants from message.c into variables
	which may be changed from X-resources.

	* [misc/main.c misc/message.c]
	added <locale.h> and setlocale() to main.c, used toupper() in message.c

Mon, 13 Jun 94 09:41:16 -0500 Paul Bramel <paulbr@comm.mot.com>

        * controls/button.c ( [CR]B_LButton* ) 
        left rc.right at full window width so click on label also 
        activates the control (MSWin behavior)

Sat Jun 11 19:05:40 1994  Olaf Flebbe  (flebbe@tat.physik.uni-tuebingen.de)

        * include/windows.h:
          functions pointers can not be packed.
          (annoying warnings with forthcomming gcc-2.6.x)
        
        * loader/main.c (InitDLL): 
          Fixed a printf statement. (for control.exe) 

          (InitializeLoadedDLLs): 
          deleted shadow definition of  *wpnt.
          (Breaks many programs, because now COMMDLG will be
           initialized :-(

        * windows/win.c (SetWindowText): 
          added missing breaks; (PENSATE starts) 

        * windows/graphics.c (FloodFill): 
          Proper boundarys. (BANGBANG starts) FloodFile_rec should
          be rewritten.

        * objects/font.c (FONT_GetMetrics): 
          TYPO: use font->perchar only if it is defined. (WRITE starts)

Sun June 12, Peter Broadhurst (pbr@ua.nwl.ac.uk)
        controls/scroll.c:
        Fixes for improved behaviour when dragging thumb;
        Added SB_THUMBPOSITION message when thumb is released.
diff --git a/controls/menu.c b/controls/menu.c
index 6470497..58a9865 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -845,6 +845,9 @@
 	if (lpitem == NULL) goto EndOfPaint;
 	for(i = 0; i < lppop->nItems; i++) {
 		CopyRect(&rect2, &lpitem->rect);
+#ifdef DEBUG_MENU
+		printf("StdDrawMenuBar // start left=%d\n", rect2.left);
+#endif
 		if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) {
 			hMemDC = CreateCompatibleDC(hDC);
 			if (lpitem->hCheckBit == 0) {
@@ -856,7 +859,11 @@
 				GetObject(lpitem->hCheckBit, sizeof(BITMAP), (LPSTR)&bm);
 				}
 			BitBlt(hDC, rect2.left, rect2.top + 1,
-			bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+				bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+			rect2.left += bm.bmWidth;
+#ifdef DEBUG_MENU
+			printf("StdDrawMenuBar // MF_CHECKED bm.bmWidth=%d\n", bm.bmWidth);
+#endif
 			DeleteDC(hMemDC);
 			}
 		else {
@@ -866,6 +873,10 @@
 				GetObject(lpitem->hUnCheckBit, sizeof(BITMAP), (LPSTR)&bm);
 				BitBlt(hDC, rect2.left, rect2.top + 1,
 					bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+				rect2.left += bm.bmWidth;
+#ifdef DEBUG_MENU
+				printf("StdDrawMenuBar // MF_UNCHECKED bm.bmWidth=%d\n", bm.bmWidth);
+#endif
 				DeleteDC(hMemDC);
 				}
 			}
@@ -898,6 +909,9 @@
 				}
 			if ((lpitem->item_flags & MF_HILITE) == MF_HILITE)
 				FillRect(hDC, &rect2, GetStockObject(BLACK_BRUSH));
+#ifdef DEBUG_MENU
+			printf("StdDrawMenuBar // rect2.left=%d\n", rect2.left);
+#endif
 			DrawText(hDC, lpitem->item_text, -1, &rect2, 
 				DT_LEFT | DT_VCENTER | DT_SINGLELINE);
 			SetTextColor(hDC, OldTextColor);
@@ -1073,13 +1087,15 @@
 		lprect->left, lprect->top, lprect->right, lprect->bottom);
 #endif
 	hOldFont = SelectObject(hDC, GetStockObject(SYSTEM_FONT));
-	LineHeight = OldHeight = SYSMETRICS_CYMENU + 1;
+	lppop->CheckWidth = 0;
+	LineHeight = OldHeight = SYSMETRICS_CYMENU + 2;
 	SetRect(&rect, lprect->left, lprect->top, 0, lprect->top + LineHeight);
 	lpitem2 = lppop->firstItem;
 	while (lpitem != NULL) {
 		lpitem = lpitem2;
 		while(rect.right < lprect->right) {
 			if (lpitem == NULL) break;
+			rect.right = rect.left;
 			if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) {
 				hBitMap = (HBITMAP)LOWORD((LONG)lpitem->item_text);
 				GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
@@ -1095,6 +1111,21 @@
 				dwRet = max(SYSMETRICS_CYMENU, (HIWORD(dwRet) + 6));
 				LineHeight = max(LineHeight, (WORD)dwRet);
 				}
+			if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) {
+				if (lpitem->hCheckBit != 0)
+					GetObject(lpitem->hCheckBit, sizeof(BITMAP), (LPSTR)&bm);
+				else
+					GetObject(hStdCheck, sizeof(BITMAP), (LPSTR)&bm);
+				rect.right += bm.bmWidth;
+				LineHeight = max(LineHeight, bm.bmHeight);
+				}
+			else {
+				if (lpitem->hUnCheckBit != 0) {
+					GetObject(lpitem->hUnCheckBit, sizeof(BITMAP), (LPSTR)&bm);
+					rect.right += bm.bmWidth;
+					LineHeight = max(LineHeight, bm.bmHeight);
+ 					}
+				}
 			CopyRect(&lpitem->rect, &rect);
 			rect.left = rect.right;
 			lpitem = (LPMENUITEM)lpitem->next;
@@ -1112,7 +1143,7 @@
 			}
 		}
 	lppop->Width = lprect->right - lprect->left;
-	lppop->Height =  rect.bottom - lprect->top;
+	lppop->Height = rect.bottom - lprect->top;
 	lprect->bottom = lprect->top + lppop->Height;
 	CopyRect(&lppop->rect, lprect);
 #ifdef DEBUG_MENUCALC
@@ -1362,8 +1393,10 @@
 {
 	LPPOPUPMENU	menu;
 	LPMENUITEM 	lpitem;
+#ifdef DEBUG_MENU
 	printf("HiliteMenuItem(%04X, %04X, %04X, %04X);\n", 
 						hWnd, hMenu, wItemID, wHilite);
+#endif
 	menu = (LPPOPUPMENU) GlobalLock(hMenu);
 	if (menu == NULL) return FALSE;
 	lpitem = FindMenuItem(hMenu, wItemID, wHilite);
@@ -1373,6 +1406,24 @@
 
 
 /**********************************************************************
+ *			GetMenuState		[USER.250]
+ */
+WORD GetMenuState(HMENU hMenu, WORD wItemID, WORD wFlags)
+{
+	LPPOPUPMENU	menu;
+	LPMENUITEM 	lpitem;
+#ifdef DEBUG_MENU
+	printf("GetMenuState(%04X, %04X, %04X);\n", hMenu, wItemID, wFlags);
+#endif
+	menu = (LPPOPUPMENU) GlobalLock(hMenu);
+	if (menu == NULL) return -1;
+	lpitem = FindMenuItem(hMenu, wItemID, wFlags);
+	if (lpitem == NULL) return -1;
+	return lpitem->item_flags;
+}
+
+
+/**********************************************************************
  *			GetMenuItemCount		[USER.263]
  */
 WORD GetMenuItemCount(HMENU hMenu)
@@ -2186,10 +2237,20 @@
 #endif
 		lppop = (LPPOPUPMENU) GlobalLock(wndPtr->wIDmenu);
 		if (lppop == NULL) return;
-		if ((lppop->rect.bottom - lppop->rect.top) != 0) {
+		if (lppop->Height != 0) {
+			int oldHeight;
+			oldHeight = lppop->Height;
 			hDC = GetWindowDC(hWnd);
 			StdDrawMenuBar(hDC, &lppop->rect, lppop, FALSE);
 			ReleaseDC(hWnd, hDC);
+			if (oldHeight != lppop->Height) {
+				printf("DrawMenuBar // menubar changed oldHeight=%d != lppop->Height=%d\n",
+											oldHeight, lppop->Height);
+				/* Reduce ClientRect according to MenuBar height */
+				wndPtr->rectClient.top -= oldHeight;
+				wndPtr->rectClient.top += lppop->Height;
+				SendMessage(hWnd, WM_NCPAINT, 1, 0L);
+				}
 			}
 		else
 			SendMessage(hWnd, WM_NCPAINT, 1, 0L);
@@ -2319,4 +2380,17 @@
     return next_item;
 }
 
+/**********************************************************************
+ *		IsMenu(USER.358)
+ */
+BOOL IsMenu(HMENU hMenu)
+{
+	LPPOPUPMENU	menu;
 
+	menu = (LPPOPUPMENU) GlobalLock(hMenu);
+	if (menu == NULL) 
+		return FALSE;
+
+	GlobalUnlock(hMenu);
+	return TRUE;
+}