Attachment "contexthelp-virtual.patch" to
ticket [845248ff]
added by
a_kovalenko
2005-12-27 12:56:24.
Index: win/tkWinCursor.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinCursor.c,v
retrieving revision 1.13
diff -u -r1.13 tkWinCursor.c
--- win/tkWinCursor.c 2 Dec 2005 00:19:04 -0000 1.13
+++ win/tkWinCursor.c 27 Dec 2005 05:43:56 -0000
@@ -246,6 +246,10 @@
TkpSetCursor(
TkpCursor cursor)
{
+ /* the hcursor_idc_help test is necessary for the CONTEXT HELP to work
+ by using wm attributes $window -contexthelp */
+
+ static HCURSOR hcursor_idc_help=NULL;
HCURSOR hcursor;
TkWinCursor *winCursor = (TkWinCursor *) cursor;
@@ -255,6 +259,8 @@
hcursor = winCursor->winCursor;
}
+ if (hcursor_idc_help==NULL) hcursor_idc_help=LoadCursor(NULL,IDC_HELP);
+ if (GetCursor()==hcursor_idc_help) return;
if (hcursor != NULL) {
SetCursor(hcursor);
}
Index: win/tkWinWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinWm.c,v
retrieving revision 1.107
diff -u -r1.107 tkWinWm.c
--- win/tkWinWm.c 10 Dec 2005 01:42:01 -0000 1.107
+++ win/tkWinWm.c 27 Dec 2005 05:44:06 -0000
@@ -3140,6 +3140,7 @@
Tcl_WrongNumArgs(interp, 2, objv,
"window"
" ?-alpha ?double??"
+ " ?-contexthelp ?bool??"
" ?-disabled ?bool??"
" ?-fullscreen ?bool??"
" ?-toolwindow ?bool??"
@@ -3169,6 +3170,10 @@
Tcl_NewStringObj("-topmost", -1));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewBooleanObj((exStyle & WS_EX_TOPMOST)));
+ Tcl_ListObjAppendElement(NULL, objPtr,
+ Tcl_NewStringObj("-contexthelp", -1));
+ Tcl_ListObjAppendElement(NULL, objPtr,
+ Tcl_NewBooleanObj((style & WS_EX_CONTEXTHELP)));
Tcl_SetObjResult(interp, objPtr);
return TCL_OK;
}
@@ -3186,6 +3191,9 @@
} else if (strncmp(string, "-fullscreen", length) == 0) {
config_fullscreen = 1;
styleBit = 0;
+ } else if (strncmp(string,"-contexthelp", length) == 0) {
+ stylePtr=&exStyle;
+ styleBit=WS_EX_CONTEXTHELP;
} else if ((length > 3)
&& (strncmp(string, "-toolwindow", length) == 0)) {
stylePtr = &exStyle;
Index: win/tkWinX.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinX.c,v
retrieving revision 1.52
diff -u -r1.52 tkWinX.c
--- win/tkWinX.c 2 Dec 2005 13:42:29 -0000 1.52
+++ win/tkWinX.c 27 Dec 2005 05:44:08 -0000
@@ -772,6 +772,62 @@
/*
*----------------------------------------------------------------------
*
+ * HelpEvent --
+ *
+ * Generates a "Help" virtual event. This can be used to do
+ * context-sensitive help.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Places a virtual event on the event queue.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+HelpEvent (hwnd, message, wParam, lParam)
+ HWND hwnd;
+ UINT message;
+ WPARAM wParam;
+ LPARAM lParam;
+{
+ TkWindow *winPtr = (TkWindow *)Tk_HWNDToWindow(hwnd);
+ XVirtualEvent event;
+ POINTS rootPoint;
+ POINT clientPoint;
+ DWORD msgPos;
+
+ event.type = VirtualEvent;
+ event.serial = winPtr->display->request;
+ event.send_event = 0;
+ event.display = winPtr->display;
+ event.event = Tk_WindowId(winPtr);
+ event.root = XRootWindow(winPtr->display, 0);
+ event.subwindow = None;
+ event.time = TkpGetMS();
+
+ msgPos = GetMessagePos();
+ rootPoint = MAKEPOINTS(msgPos);
+ clientPoint.x = rootPoint.x;
+ clientPoint.y = rootPoint.y;
+ ScreenToClient(hwnd, &clientPoint);
+ event.x = clientPoint.x;
+ event.y = clientPoint.y;
+ event.x_root = rootPoint.x;
+ event.y_root = rootPoint.y;
+ event.state = TkWinGetModifierState();
+ event.same_screen = 1;
+ event.name = Tk_GetUid("Help");
+ event.user_data = NULL;
+ Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkWinChildProc --
*
* Callback from Windows whenever an event occurs on a child window.
@@ -795,6 +851,12 @@
LRESULT result;
switch (message) {
+
+ case WM_HELP:
+ HelpEvent(hwnd, message, wParam, lParam);
+ result = DefWindowProc(hwnd, message, wParam, lParam);
+ break;
+
case WM_INPUTLANGCHANGE:
UpdateInputLanguage(wParam);
result = 1;