|
From: <kr_...@us...> - 2003-03-26 19:20:55
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32
In directory sc8-pr-cvs1:/tmp/cvs-serv31265/port/src/cbits/Win32
Modified Files:
Window.c
Log Message:
Added implementation for tooltips
Index: Window.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Window.c 26 Mar 2003 15:39:48 -0000 1.12
--- Window.c 26 Mar 2003 19:20:21 -0000 1.13
***************
*** 22,25 ****
--- 22,27 ----
int disabledCtrlsCount;
HWND *disabledCtrls;
+
+ HWND hTooltip;
} WindowData;
***************
*** 176,180 ****
pData->disabledCtrlsCount = 0;
pData->disabledCtrls = NULL;
! SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData);
gActiveObjects++;
--- 178,183 ----
pData->disabledCtrlsCount = 0;
pData->disabledCtrls = NULL;
! pData->hTooltip = NULL;
! SetWindowLong(hWnd,GWL_USERDATA,(LONG) pData);
gActiveObjects++;
***************
*** 470,474 ****
handleWindowMouse(hWnd,evMouseLeave,pData->Origin.x+cx,pData->Origin.y+cy,GetModifiers());
pData->bInMouseMoveMode = FALSE;
! ReleaseCapture();
}
else
--- 473,477 ----
handleWindowMouse(hWnd,evMouseLeave,pData->Origin.x+cx,pData->Origin.y+cy,GetModifiers());
pData->bInMouseMoveMode = FALSE;
! //ReleaseCapture();
}
else
***************
*** 478,482 ****
{
pData->bInMouseMoveMode = TRUE;
! SetCapture(hWnd);
handleWindowMouse(hWnd,evMouseEnter,pData->Origin.x+cx,pData->Origin.y+cy,GetModifiers());
}
--- 481,485 ----
{
pData->bInMouseMoveMode = TRUE;
! //SetCapture(hWnd);
handleWindowMouse(hWnd,evMouseEnter,pData->Origin.x+cx,pData->Origin.y+cy,GetModifiers());
}
***************
*** 504,508 ****
{
pData->bInDragMode = TRUE;
! if (!pData->bInMouseMoveMode) SetCapture(hWnd);
handleWindowMouse(hWnd,evMouseLeftDown,pos.x,pos.y,GetModifiers());
}
--- 507,511 ----
{
pData->bInDragMode = TRUE;
! //if (!pData->bInMouseMoveMode) SetCapture(hWnd);
handleWindowMouse(hWnd,evMouseLeftDown,pos.x,pos.y,GetModifiers());
}
***************
*** 555,563 ****
handleWindowMouse(hWnd,evMouseLeave,pData->Origin.x+cx,pData->Origin.y+cy,GetModifiers());
pData->bInMouseMoveMode = FALSE;
! ReleaseCapture();
}
}
! else
! ReleaseCapture();
hCtrl = checkMousePosition(hWnd, &pos);
--- 558,566 ----
handleWindowMouse(hWnd,evMouseLeave,pData->Origin.x+cx,pData->Origin.y+cy,GetModifiers());
pData->bInMouseMoveMode = FALSE;
! //ReleaseCapture();
}
}
! //else
! // ReleaseCapture();
hCtrl = checkMousePosition(hWnd, &pos);
***************
*** 1209,1212 ****
--- 1212,1308 ----
{
return IsWindowEnabled(ctrl);
+ }
+
+ void osSetControlTip(WindowHandle ctrl, char *text)
+ {
+ TOOLINFO ti; /* The tool information that is sent to the tooltip control. */
+ HWND hParent;
+ WindowData *pData;
+
+ hParent = GetParent(ctrl);
+ pData = (WindowData *) GetWindowLong(GetParent(ctrl),GWL_USERDATA);
+
+ if (!pData->hTooltip)
+ {
+ pData->hTooltip = CreateWindowEx (WS_EX_TOPMOST, // Apply the topmost style for this window
+ TOOLTIPS_CLASS, // Class name
+ NULL, // Title (NULL)
+ WS_POPUP | TTS_ALWAYSTIP, // Style *must* be WS_POPUP
+ CW_USEDEFAULT, // Default position (x,y)
+ CW_USEDEFAULT,
+ CW_USEDEFAULT, // Default size (w,h)
+ CW_USEDEFAULT,
+ hParent, // Parent
+ (HMENU) NULL, // No menu
+ (HANDLE) ghModule, // The instance
+ NULL // No window creation data
+ );
+ }
+
+ if (text && *text)
+ {
+ text[256] = 0; // Truncate the tip text to 255 chars because the osGetControlTip function
+ //uses 256 bytes long buffer
+
+ /* Fill the tooltip info with the appropriate information. */
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
+ ti.hwnd = hParent;
+ ti.uId = (UINT) ctrl;
+ ti.rect.left = 0;
+ ti.rect.top = 0;
+ ti.rect.right = 0;
+ ti.rect.bottom= 0;
+ ti.hinst = ghModule;
+ ti.lpszText = text;
+
+ SendMessage (pData->hTooltip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO)&ti);
+ }
+ else
+ {
+ /* Fill the tooltip info with the appropriate information. */
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = hParent;
+ ti.uId = (UINT) ctrl;
+
+ SendMessage (pData->hTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO)&ti);
+ }
+ }
+
+ char *osGetControlTip(WindowHandle ctrl)
+ {
+ TOOLINFO ti; /* The tool information that is sent to the tooltip control. */
+ HWND hParent;
+ WindowData *pData;
+
+ hParent = GetParent(ctrl);
+ pData = (WindowData *) GetWindowLong(GetParent(ctrl),GWL_USERDATA);
+
+ if (pData->hTooltip)
+ {
+ /* Fill the tooltip info with the appropriate information. */
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = hParent;
+ ti.uId = (UINT) ctrl;
+ ti.lpszText = malloc(256);
+
+ if (ti.lpszText)
+ {
+ *ti.lpszText = 0;
+ SendMessage (pData->hTooltip, TTM_GETTEXT, 0, (LPARAM) (LPTOOLINFO)&ti);
+
+ if (*ti.lpszText == 0)
+ {
+ free(ti.lpszText);
+ ti.lpszText = NULL;
+ }
+ }
+
+ return ti.lpszText;
+ }
+ else
+ return NULL;
}
|