| 
      
      
      From: <kr_...@us...> - 2003-08-26 20:01:04
      
     | 
| Update of /cvsroot/htoolkit/port/src/cbits/Win32
In directory sc8-pr-cvs1:/tmp/cvs-serv21238/src/cbits/Win32
Modified Files:
	RadioBox.c 
Log Message:
Consistent behaviour for RadioBox under Windows & GNOME
Index: RadioBox.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/RadioBox.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** RadioBox.c	24 Aug 2003 21:07:48 -0000	1.8
--- RadioBox.c	26 Aug 2003 20:00:55 -0000	1.9
***************
*** 1,120 ****
! #include "RadioBox.h"
! #include "Internals.h"
! #include "Handlers_stub.h"
! 
! WindowHandle osCreateRadioBox(WindowHandle window)
! {
! 	HWND hRadioBox;
! 
! 	hRadioBox = CreateWindow(
! 			  "BUTTON",
! 			  NULL,
! 			  WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | WS_TABSTOP,
! 			  0,0,0,0,
! 			  window,
! 			  NULL,
! 			  ghModule,
! 			  NULL
! 			);
! 	SetWindowLong(hRadioBox, GWL_USERDATA, (LONG) hRadioBox);
! 	return checkWindow(hRadioBox, "RADIOBOX");
! };
! 
! void osGetRadioBoxReqSize(WindowHandle radiobox, int *res)
! {
! 	SIZE sz;
! 	TEXTMETRIC tm;
! 	HFONT hOldFont;
! 	HDC hDC = GetDC(radiobox);
! 	int nLen = GetWindowTextLength(radiobox);
! 	char *buffer = (char *) rmalloc(nLen+1);
! 	nLen = GetWindowText(radiobox, buffer, nLen+1);
! 
! 	hOldFont = SelectObject(hDC, (HFONT) SendMessage(radiobox, WM_GETFONT, 0, 0));
! 	
! 	GetTextExtentPoint32(hDC, buffer, nLen, &sz);
! 	GetTextMetrics(hDC, &tm);
! 	
! 	SelectObject(hDC, hOldFont);
! 
! 	rfree(buffer);
! 	ReleaseDC(radiobox, hDC);
! 
! 	res[0] = sz.cx + 32;
! 	res[1] = tm.tmHeight+tm.tmDescent;
! };
! 
! char *osGetRadioBoxText(WindowHandle radiobox)
! {
! 	int nLen = GetWindowTextLength(radiobox);
! 	char *buffer = (char *) rmalloc(nLen+1);
! 	GetWindowText(radiobox, buffer, nLen+1);
! 	return buffer;
! };
! 
! void osSetRadioBoxText(WindowHandle radiobox, char *txt)
! {
! 	SetWindowText(radiobox, txt);
! 	osForceContainerReLayout(radiobox);
! };
! 
! BOOL osGetRadioBoxState(WindowHandle radiobox)
! {
! 	return SendMessage(radiobox,BM_GETCHECK,0,0) == BST_CHECKED;
! };
! 
! void osSetRadioBoxState(WindowHandle radiobox, BOOL state)
! {
! 	HWND hNextCtrl;
! 	
! 	if (state)
! 	{
! 		SendMessage(radiobox,BM_SETCHECK,BST_CHECKED,0);
! 		
! 		hNextCtrl = radiobox;
! 		for (;;)
! 		{
! 			hNextCtrl = (WindowHandle) GetWindowLong(hNextCtrl, GWL_USERDATA);
! 			if (hNextCtrl == radiobox) break;
! 
! 			SendMessage(hNextCtrl,BM_SETCHECK,BST_UNCHECKED,0);
! 		}
! 	}
! 	else
! 		SendMessage(radiobox,BM_SETCHECK,BST_UNCHECKED,0);
! };
! 
! void osSetRadioBoxGroup(WindowHandle *handles)
! {
! 	WindowHandle first, next, child, handle, *phandle;
! 
! 	if (!(handles && *handles))
! 		return;
! 
! 	phandle=handles;
! 	for (;;)
! 	{
! 		handle = *phandle;
! 
! 		first = (WindowHandle) GetWindowLong(handle, GWL_USERDATA);
! 		child = first;
! 		for (;;)
! 		{
! 			next = (WindowHandle) GetWindowLong(child, GWL_USERDATA);
! 			if (next == handle) break;
! 			child = next;
! 		}
! 		SetWindowLong(child, GWL_USERDATA, (LONG) first);
! 		
! 		SendMessage(handle,BM_SETCHECK,(handle == *handles) ? BST_CHECKED : BST_UNCHECKED,0);
! 
! 		phandle++;
! 		if (*phandle)
! 			SetWindowLong(handle, GWL_USERDATA, (LONG) *phandle);
! 		else
! 		{
! 			SetWindowLong(handle, GWL_USERDATA, (LONG) *handles);
! 			break;
! 		}
! 	}
! };
--- 1,149 ----
! #include "RadioBox.h"
! #include "Internals.h"
! #include "Handlers_stub.h"
! 
! WindowHandle osCreateRadioBox(WindowHandle window)
! {
! 	HWND hRadioBox;
! 
! 	hRadioBox = CreateWindow(
! 			  "BUTTON",
! 			  NULL,
! 			  WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | WS_TABSTOP,
! 			  0,0,0,0,
! 			  window,
! 			  NULL,
! 			  ghModule,
! 			  NULL
! 			);
! 	SetWindowLong(hRadioBox, GWL_USERDATA, (LONG) hRadioBox);
! 	return checkWindow(hRadioBox, "RADIOBOX");
! };
! 
! void osGetRadioBoxReqSize(WindowHandle radiobox, int *res)
! {
! 	SIZE sz;
! 	TEXTMETRIC tm;
! 	HFONT hOldFont;
! 	HDC hDC = GetDC(radiobox);
! 	int nLen = GetWindowTextLength(radiobox);
! 	char *buffer = (char *) rmalloc(nLen+1);
! 	nLen = GetWindowText(radiobox, buffer, nLen+1);
! 
! 	hOldFont = SelectObject(hDC, (HFONT) SendMessage(radiobox, WM_GETFONT, 0, 0));
! 	
! 	GetTextExtentPoint32(hDC, buffer, nLen, &sz);
! 	GetTextMetrics(hDC, &tm);
! 	
! 	SelectObject(hDC, hOldFont);
! 
! 	rfree(buffer);
! 	ReleaseDC(radiobox, hDC);
! 
! 	res[0] = sz.cx + 32;
! 	res[1] = tm.tmHeight+tm.tmDescent;
! };
! 
! char *osGetRadioBoxText(WindowHandle radiobox)
! {
! 	int nLen = GetWindowTextLength(radiobox);
! 	char *buffer = (char *) rmalloc(nLen+1);
! 	GetWindowText(radiobox, buffer, nLen+1);
! 	return buffer;
! };
! 
! void osSetRadioBoxText(WindowHandle radiobox, char *txt)
! {
! 	SetWindowText(radiobox, txt);
! 	osForceContainerReLayout(radiobox);
! };
! 
! BOOL osGetRadioBoxState(WindowHandle radiobox)
! {
! 	return SendMessage(radiobox,BM_GETCHECK,0,0) == BST_CHECKED;
! };
! 
! void osSetRadioBoxState(WindowHandle radiobox, BOOL state)
! {
! 	HWND hNextCtrl;
! 
! 	if (state)
! 	{
! 		if (SendMessage(radiobox,BM_GETCHECK,0,0) == BST_UNCHECKED)
! 		{
! 			SendMessage(radiobox,BM_SETCHECK,BST_CHECKED,0);
! 			handleControlCommand(radiobox);
! 		}
! 
! 		hNextCtrl = radiobox;
! 		for (;;)
! 		{
! 			hNextCtrl = (WindowHandle) GetWindowLong(hNextCtrl, GWL_USERDATA);
! 			if (hNextCtrl == radiobox) break;
! 
! 			if (SendMessage(hNextCtrl,BM_GETCHECK,0,0) == BST_CHECKED)
! 			{
! 				SendMessage(hNextCtrl,BM_SETCHECK,BST_UNCHECKED,0);
! 				handleControlCommand(hNextCtrl);
! 			}
! 		}
! 	}
! 	else
! 	{
! 		if (SendMessage(radiobox,BM_GETCHECK,0,0) == BST_CHECKED)
! 		{
! 			SendMessage(radiobox,BM_SETCHECK,BST_UNCHECKED,0);
! 			handleControlCommand(radiobox);
! 		}
! 	}
! };
! 
! void osSetRadioBoxGroup(WindowHandle *handles)
! {
! 	WindowHandle first, next, child, handle, *phandle;
! 
! 	if (!(handles && *handles))
! 		return;
! 
! 	phandle=handles;
! 	for (;;)
! 	{
! 		handle = *phandle;
! 
! 		first = (WindowHandle) GetWindowLong(handle, GWL_USERDATA);
! 		child = first;
! 		for (;;)
! 		{
! 			next = (WindowHandle) GetWindowLong(child, GWL_USERDATA);
! 			if (next == handle) break;
! 			child = next;
! 		}
! 		SetWindowLong(child, GWL_USERDATA, (LONG) first);
! 
! 		if (SendMessage(handle,BM_GETCHECK,0,0) == BST_CHECKED)
! 		{
! 			if (handle != *handles)
! 			{
! 				SendMessage(handle,BM_SETCHECK,BST_UNCHECKED,0);
! 				handleControlCommand(handle);
! 			}
! 		}
! 		else
! 		{
! 			if (handle == *handles)
! 			{
! 				SendMessage(handle,BM_SETCHECK,BST_CHECKED,0);
! 				handleControlCommand(handle);
! 			}
! 		}
! 
! 		phandle++;
! 		if (*phandle)
! 			SetWindowLong(handle, GWL_USERDATA, (LONG) *phandle);
! 		else
! 		{
! 			SetWindowLong(handle, GWL_USERDATA, (LONG) *handles);
! 			break;
! 		}
! 	}
! };
 |