|
From: <kr_...@us...> - 2003-03-26 15:39:52
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32
In directory sc8-pr-cvs1:/tmp/cvs-serv16051/port/src/cbits/Win32
Modified Files:
Util.c Window.c
Log Message:
This commit implements instances for Able type class for all kinds of windows and controls.
Index: Util.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Util.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Util.c 26 Mar 2003 08:45:56 -0000 1.8
--- Util.c 26 Mar 2003 15:39:48 -0000 1.9
***************
*** 3,6 ****
--- 3,7 ----
#include "RtsAPI.h"
#include "Types.h"
+ #include "Window.h"
#include "Handlers_stub.h"
***************
*** 161,164 ****
--- 162,167 ----
WindowHandle checkWindow(HWND hWnd, char *className)
{
+ HWND hParent;
+
if (!hWnd)
{
***************
*** 168,171 ****
--- 171,180 ----
SendMessage(hWnd, WM_SETFONT, (WPARAM)ghControlFont, MAKELPARAM (TRUE,0));
+
+ hParent = GetParent(hWnd);
+
+ if (hParent && !osGetWindowEnabled(hParent))
+ EnableWindow(hWnd, FALSE);
+
return hWnd;
}
Index: Window.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Window.c 26 Mar 2003 00:41:46 -0000 1.11
--- Window.c 26 Mar 2003 15:39:48 -0000 1.12
***************
*** 18,21 ****
--- 18,25 ----
int hatchStyle;
BitmapHandle patBmp;
+
+ BOOL enabled;
+ int disabledCtrlsCount;
+ HWND *disabledCtrls;
} WindowData;
***************
*** 117,135 ****
while (hCtrl)
{
! GetWindowRect(hCtrl,&rect);
! upLeft.x = rect.left;
! upLeft.y = rect.top;
! ScreenToClient(hWnd,&upLeft);
! downRight.x = rect.right;
! downRight.y = rect.bottom;
! ScreenToClient(hWnd,&downRight);
! if (pos->x >= upLeft.x &&
! pos->x <= downRight.x &&
! pos->y >= upLeft.y &&
! pos->y <= downRight.y)
! {
! return hCtrl;
! }
hCtrl = GetNextWindow(hCtrl,GW_HWNDNEXT);
--- 121,142 ----
while (hCtrl)
{
! if (IsWindowEnabled(hCtrl))
! {
! GetWindowRect(hCtrl,&rect);
! upLeft.x = rect.left;
! upLeft.y = rect.top;
! ScreenToClient(hWnd,&upLeft);
! downRight.x = rect.right;
! downRight.y = rect.bottom;
! ScreenToClient(hWnd,&downRight);
! if (pos->x >= upLeft.x &&
! pos->x <= downRight.x &&
! pos->y >= upLeft.y &&
! pos->y <= downRight.y)
! {
! return hCtrl;
! }
! }
hCtrl = GetNextWindow(hCtrl,GW_HWNDNEXT);
***************
*** 166,169 ****
--- 173,179 ----
pData->hBackBrush = CreateSolidBrush (pData->backColor);
pData->nWindowKind = ((int) lpcs->lpCreateParams);
+ pData->enabled = TRUE;
+ pData->disabledCtrlsCount = 0;
+ pData->disabledCtrls = NULL;
SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData);
***************
*** 423,426 ****
--- 433,437 ----
break;
case WM_CAPTURECHANGED:
+ if (pData->enabled)
{
int cx = GET_X_LPARAM(lParam);
***************
*** 441,444 ****
--- 452,456 ----
break;
case WM_MOUSEMOVE:
+ if (pData->enabled)
{
int cx = GET_X_LPARAM(lParam);
***************
*** 473,476 ****
--- 485,489 ----
break;
case WM_LBUTTONDOWN:
+ if (pData->enabled)
{
POINT pos;
***************
*** 497,500 ****
--- 510,514 ----
break;
case WM_LBUTTONDBLCLK:
+ if (pData->enabled)
{
POINT pos;
***************
*** 517,520 ****
--- 531,535 ----
break;
case WM_LBUTTONUP:
+ if (pData->enabled)
{
POINT pos;
***************
*** 557,560 ****
--- 572,576 ----
break;
case WM_RBUTTONDOWN:
+ if (pData->enabled)
{
POINT pos;
***************
*** 579,582 ****
--- 595,599 ----
break;
case WM_RBUTTONUP:
+ if (pData->enabled)
{
POINT pos;
***************
*** 600,603 ****
--- 617,621 ----
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
+ if (pData->enabled)
{
int c = CheckVirtualKeyCode ((int) wParam);
***************
*** 628,631 ****
--- 646,650 ----
case WM_SYSCHAR:
case WM_CHAR:
+ if (pData->enabled)
{
if (GetKeyState(VK_MENU) < 0)
***************
*** 653,660 ****
case WM_SYSKEYUP:
case WM_KEYUP:
! if (gInKey)
! handleWindowKeyboard(hWnd, evKeyUp, gCurChar, GetModifiers());
! gInKey = FALSE;
! gCurChar = 0;
break;
case WM_CTLCOLORSTATIC:
--- 672,682 ----
case WM_SYSKEYUP:
case WM_KEYUP:
! if (pData->enabled)
! {
! if (gInKey)
! handleWindowKeyboard(hWnd, evKeyUp, gCurChar, GetModifiers());
! gInKey = FALSE;
! gCurChar = 0;
! }
break;
case WM_CTLCOLORSTATIC:
***************
*** 1017,1020 ****
--- 1039,1102 ----
}
+ void osSetWindowEnabled(WindowHandle window, BOOL enabled)
+ {
+ int i;
+ HWND hCtrl;
+ WindowData *pData;
+
+ pData = (WindowData *) GetWindowLong(window,GWL_USERDATA);
+
+ if (pData->enabled != enabled)
+ {
+ pData->enabled = enabled;
+
+ if (enabled)
+ {
+ hCtrl = GetTopWindow(window);
+ while (hCtrl)
+ {
+ if (pData->disabledCtrlsCount == 0)
+ EnableWindow(hCtrl, TRUE);
+ else
+ {
+ pData->disabledCtrls[pData->disabledCtrlsCount] = hCtrl;
+ for (i = 0; pData->disabledCtrls[i] != hCtrl; i++);
+ EnableWindow(hCtrl, i >= pData->disabledCtrlsCount);
+ }
+
+ hCtrl = GetNextWindow(hCtrl,GW_HWNDNEXT);
+ }
+ free(pData->disabledCtrls);
+ pData->disabledCtrls = NULL;
+ pData->disabledCtrlsCount = 0;
+ }
+ else
+ {
+ hCtrl = GetTopWindow(window);
+ while (hCtrl)
+ {
+ if (!IsWindowEnabled(hCtrl))
+ {
+ if (pData->disabledCtrlsCount % 8 == 0)
+ {
+ pData->disabledCtrls = realloc(pData->disabledCtrls, (pData->disabledCtrlsCount+9)*sizeof(HWND));
+ }
+
+ pData->disabledCtrls[pData->disabledCtrlsCount++] = hCtrl;
+ }
+
+ EnableWindow(hCtrl, FALSE);
+ hCtrl = GetNextWindow(hCtrl,GW_HWNDNEXT);
+ }
+ }
+ }
+ }
+
+ BOOL osGetWindowEnabled(WindowHandle window)
+ {
+ WindowData *pData = (WindowData *) GetWindowLong(window,GWL_USERDATA);
+ return pData->enabled;
+ }
+
CanvasHandle osGetWindowCanvas(WindowHandle window)
{
***************
*** 1090,1093 ****
--- 1172,1212 ----
res[2] = rect.right+pData->Origin.x;
res[3] = rect.bottom+pData->Origin.y;
+ }
+
+ void osSetControlEnabled(WindowHandle ctrl, BOOL enabled)
+ {
+ int i;
+ WindowData *pData = (WindowData *) GetWindowLong(GetParent(ctrl),GWL_USERDATA);
+
+ if (pData->enabled)
+ EnableWindow(ctrl, enabled);
+ else
+ {
+ if (enabled)
+ {
+ pData->disabledCtrls[pData->disabledCtrlsCount] = ctrl;
+ for (i = 0; pData->disabledCtrls[i] != ctrl; i++);
+
+ if (i < pData->disabledCtrlsCount)
+ {
+ pData->disabledCtrlsCount--;
+ memmove(pData->disabledCtrls+i, pData->disabledCtrls+i+1, (pData->disabledCtrlsCount-i)*sizeof(HWND));
+ }
+ }
+ else
+ {
+ if (pData->disabledCtrlsCount % 8 == 0)
+ {
+ pData->disabledCtrls = realloc(pData->disabledCtrls, (pData->disabledCtrlsCount+9)*sizeof(HWND));
+ }
+
+ pData->disabledCtrls[pData->disabledCtrlsCount++] = ctrl;
+ }
+ }
+ }
+
+ BOOL osGetControlEnabled(WindowHandle ctrl)
+ {
+ return IsWindowEnabled(ctrl);
}
|