1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile cctl_tooltip.c:
|
---|
4 | * implementation for the "tooltip" common control.
|
---|
5 | * See comctl.c for an overview.
|
---|
6 | *
|
---|
7 | * This has been extracted from comctl.c with V0.9.3 (2000-05-21) [umoeller].
|
---|
8 | *
|
---|
9 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
10 | * numbering.
|
---|
11 | *
|
---|
12 | *@@header "helpers\comctl.h"
|
---|
13 | *@@added V0.9.3 (2000-05-21) [umoeller].
|
---|
14 | */
|
---|
15 |
|
---|
16 | /*
|
---|
17 | * Copyright (C) 1997-2005 Ulrich Mller.
|
---|
18 | * This file is part of the "XWorkplace helpers" source package.
|
---|
19 | * This is free software; you can redistribute it and/or modify
|
---|
20 | * it under the terms of the GNU General Public License as published
|
---|
21 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
22 | * "COPYING" file of the XWorkplace main distribution.
|
---|
23 | * This program is distributed in the hope that it will be useful,
|
---|
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
26 | * GNU General Public License for more details.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #define OS2EMX_PLAIN_CHAR
|
---|
30 | // this is needed for "os2emx.h"; if this is defined,
|
---|
31 | // emx will define PSZ as _signed_ char, otherwise
|
---|
32 | // as unsigned char
|
---|
33 |
|
---|
34 | #define INCL_DOSEXCEPTIONS
|
---|
35 | #define INCL_DOSPROCESS
|
---|
36 | #define INCL_DOSSEMAPHORES
|
---|
37 | #define INCL_DOSERRORS
|
---|
38 |
|
---|
39 | #define INCL_WINWINDOWMGR
|
---|
40 | #define INCL_WINFRAMEMGR
|
---|
41 | #define INCL_WINMESSAGEMGR
|
---|
42 | #define INCL_WININPUT
|
---|
43 | #define INCL_WINPOINTERS
|
---|
44 | #define INCL_WINTRACKRECT
|
---|
45 | #define INCL_WINTIMER
|
---|
46 | #define INCL_WINSYS
|
---|
47 |
|
---|
48 | #define INCL_WINRECTANGLES /// xxx temporary
|
---|
49 |
|
---|
50 | #define INCL_WINMENUS
|
---|
51 | #define INCL_WINSTATICS
|
---|
52 | #define INCL_WINBUTTONS
|
---|
53 | #define INCL_WINSTDCNR
|
---|
54 |
|
---|
55 | #define INCL_GPIPRIMITIVES
|
---|
56 | #define INCL_GPILOGCOLORTABLE
|
---|
57 | #define INCL_GPILCIDS
|
---|
58 | #define INCL_GPIPATHS
|
---|
59 | #define INCL_GPIREGIONS
|
---|
60 | #define INCL_GPIBITMAPS // added V0.9.1 (2000-01-04) [umoeller]: needed for EMX headers
|
---|
61 | #include <os2.h>
|
---|
62 |
|
---|
63 | #include <stdlib.h>
|
---|
64 | #include <stdio.h>
|
---|
65 | #include <string.h>
|
---|
66 | #include <setjmp.h> // needed for except.h
|
---|
67 | #include <assert.h> // needed for except.h
|
---|
68 |
|
---|
69 | #include "setup.h" // code generation and debugging options
|
---|
70 |
|
---|
71 | #include "helpers\cnrh.h"
|
---|
72 | #include "helpers\except.h" // exception handling
|
---|
73 | #include "helpers\gpih.h"
|
---|
74 | #include "helpers\linklist.h"
|
---|
75 | #include "helpers\nls.h"
|
---|
76 | #include "helpers\winh.h"
|
---|
77 |
|
---|
78 | #include "helpers\comctl.h"
|
---|
79 |
|
---|
80 | #pragma hdrstop
|
---|
81 |
|
---|
82 | /*
|
---|
83 | *@@category: Helpers\PM helpers\Window classes\Tooltips
|
---|
84 | * See cctl_tooltip.c.
|
---|
85 | */
|
---|
86 |
|
---|
87 | /* ******************************************************************
|
---|
88 | *
|
---|
89 | * Global variables
|
---|
90 | *
|
---|
91 | ********************************************************************/
|
---|
92 |
|
---|
93 | // linked list of all tools which were subclassed for tooltip
|
---|
94 | HMTX G_hmtxSubclassedTools = NULLHANDLE;
|
---|
95 | LINKLIST G_llSubclassedTools; // linked list of SUBCLASSEDTOOL items
|
---|
96 |
|
---|
97 | /* ******************************************************************
|
---|
98 | *
|
---|
99 | * "Tooltip" control
|
---|
100 | *
|
---|
101 | ********************************************************************/
|
---|
102 |
|
---|
103 | /*
|
---|
104 | *@@ ctlRegisterTooltip:
|
---|
105 | * this registers the Tooltip window class (ctl_fnwpTooltip)
|
---|
106 | * for an application. This is required before the tooltip
|
---|
107 | * control can be used.
|
---|
108 | *
|
---|
109 | *@@added V0.9.0 [umoeller]
|
---|
110 | */
|
---|
111 |
|
---|
112 | BOOL ctlRegisterTooltip(HAB hab)
|
---|
113 | {
|
---|
114 | return WinRegisterClass(hab,
|
---|
115 | COMCTL_TOOLTIP_CLASS,
|
---|
116 | ctl_fnwpTooltip,
|
---|
117 | CS_HITTEST, // class styles;
|
---|
118 | // CS_FRAME not working,
|
---|
119 | // CS_CLIPSIBLINGS not working
|
---|
120 | sizeof(PVOID) * 2); // addt'l bytes to reserve:
|
---|
121 | // one pointer for QWL_USER,
|
---|
122 | // one more for instance data
|
---|
123 | }
|
---|
124 |
|
---|
125 | /* ******************************************************************
|
---|
126 | *
|
---|
127 | * Subclassing
|
---|
128 | *
|
---|
129 | ********************************************************************/
|
---|
130 |
|
---|
131 | /*
|
---|
132 | *@@ LockSubclassedTools:
|
---|
133 | * locks the global list of subclassed tools.
|
---|
134 | *
|
---|
135 | *@@added V0.9.12 (2001-04-28) [umoeller]
|
---|
136 | */
|
---|
137 |
|
---|
138 | STATIC BOOL LockSubclassedTools(VOID)
|
---|
139 | {
|
---|
140 | if (!G_hmtxSubclassedTools)
|
---|
141 | {
|
---|
142 | // first call:
|
---|
143 |
|
---|
144 | // initialize the list
|
---|
145 | lstInit(&G_llSubclassedTools,
|
---|
146 | TRUE); // auto-free
|
---|
147 |
|
---|
148 | // create mutex and request it right away
|
---|
149 | return (!DosCreateMutexSem(NULL,
|
---|
150 | &G_hmtxSubclassedTools,
|
---|
151 | 0,
|
---|
152 | TRUE)); // request!
|
---|
153 | }
|
---|
154 |
|
---|
155 | return !DosRequestMutexSem(G_hmtxSubclassedTools, SEM_INDEFINITE_WAIT);
|
---|
156 | }
|
---|
157 |
|
---|
158 | /*
|
---|
159 | *@@ UnlockSubclassedTools:
|
---|
160 | * unlocks the global list of subclassed tools.
|
---|
161 | *
|
---|
162 | *@@added V0.9.12 (2001-04-28) [umoeller]
|
---|
163 | *@@changed V0.9.12 (2001-05-03) [umoeller]: this did nothing... fixed
|
---|
164 | */
|
---|
165 |
|
---|
166 | STATIC VOID UnlockSubclassedTools(VOID)
|
---|
167 | {
|
---|
168 | DosReleaseMutexSem(G_hmtxSubclassedTools); // was missing V0.9.12 (2001-05-03) [umoeller]
|
---|
169 | }
|
---|
170 |
|
---|
171 | /*
|
---|
172 | *@@ SUBCLASSEDTOOL:
|
---|
173 | * structure created for each control which is
|
---|
174 | * subclassed by the tooltip control (ctl_fnwpTooltip).
|
---|
175 | *
|
---|
176 | *@@added V0.9.0 [umoeller]
|
---|
177 | */
|
---|
178 |
|
---|
179 | typedef struct _SUBCLASSEDTOOL
|
---|
180 | {
|
---|
181 | HWND hwndTool;
|
---|
182 | PFNWP pfnwpOrig;
|
---|
183 | HWND hwndTooltip;
|
---|
184 | HAB hab;
|
---|
185 | } SUBCLASSEDTOOL, *PSUBCLASSEDTOOL;
|
---|
186 |
|
---|
187 | /*
|
---|
188 | *@@ FindSubclassedTool:
|
---|
189 | * returns the SUBCLASSEDTOOL struct from the
|
---|
190 | * global list which matches hwndTool or NULL
|
---|
191 | * if not found.
|
---|
192 | *
|
---|
193 | * Preconditions: Caller must hold the subclassed
|
---|
194 | * tools mutex.
|
---|
195 | *
|
---|
196 | *@@added V0.9.12 (2001-04-28) [umoeller]
|
---|
197 | */
|
---|
198 |
|
---|
199 | STATIC PSUBCLASSEDTOOL FindSubclassedTool(HWND hwndTool)
|
---|
200 | {
|
---|
201 | PLISTNODE pNode = lstQueryFirstNode(&G_llSubclassedTools);
|
---|
202 | while (pNode)
|
---|
203 | {
|
---|
204 | PSUBCLASSEDTOOL pstThis = (PSUBCLASSEDTOOL)pNode->pItemData;
|
---|
205 | if (pstThis->hwndTool == hwndTool)
|
---|
206 | return pstThis;
|
---|
207 |
|
---|
208 | pNode = pNode->pNext;
|
---|
209 | }
|
---|
210 |
|
---|
211 | return NULL;
|
---|
212 | }
|
---|
213 |
|
---|
214 | /*
|
---|
215 | *@@ ctl_fnwpSubclassedTool:
|
---|
216 | * window procedure for tools which were subclassed
|
---|
217 | * to support tooltips.
|
---|
218 | *
|
---|
219 | *@@added V0.9.0 [umoeller]
|
---|
220 | *@@changed V0.9.12 (2001-04-28) [umoeller]: added mutex protection
|
---|
221 | *@@changed V1.0.2 (2003-07-26) [pr]: fixed tooltip moving with mouse from xcenters @@fixes 455
|
---|
222 | */
|
---|
223 |
|
---|
224 | MRESULT EXPENTRY ctl_fnwpSubclassedTool(HWND hwndTool, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
225 | {
|
---|
226 | MRESULT mrc = 0;
|
---|
227 |
|
---|
228 | PFNWP pfnwpOrig = NULL;
|
---|
229 |
|
---|
230 | if (LockSubclassedTools())
|
---|
231 | {
|
---|
232 | PSUBCLASSEDTOOL pst;
|
---|
233 |
|
---|
234 | if (pst = FindSubclassedTool(hwndTool))
|
---|
235 | {
|
---|
236 | pfnwpOrig = pst->pfnwpOrig; // call default
|
---|
237 |
|
---|
238 | switch (msg)
|
---|
239 | {
|
---|
240 | case WM_MOUSEMOVE:
|
---|
241 | case WM_BUTTON1DOWN:
|
---|
242 | case WM_BUTTON1UP:
|
---|
243 | case WM_BUTTON2DOWN:
|
---|
244 | case WM_BUTTON2UP:
|
---|
245 | case WM_BUTTON3DOWN:
|
---|
246 | case WM_BUTTON3UP:
|
---|
247 | case WM_MOUSELEAVE: // V1.0.2 (2003-07-26) [pr]: @@fixes 455
|
---|
248 | {
|
---|
249 | QMSG qmsg;
|
---|
250 | qmsg.hwnd = hwndTool;
|
---|
251 | qmsg.msg = msg;
|
---|
252 | qmsg.mp1 = mp1;
|
---|
253 | qmsg.mp2 = mp2;
|
---|
254 | // _Pmpf((__FUNCTION__ ": sending TTM_RELAYEVENT"));
|
---|
255 | WinSendMsg(pst->hwndTooltip,
|
---|
256 | TTM_RELAYEVENT,
|
---|
257 | (MPARAM)0,
|
---|
258 | (MPARAM)&qmsg);
|
---|
259 | }
|
---|
260 | break;
|
---|
261 |
|
---|
262 | case WM_DESTROY:
|
---|
263 | lstRemoveItem(&G_llSubclassedTools, pst);
|
---|
264 | // this frees the item
|
---|
265 | break;
|
---|
266 | }
|
---|
267 | }
|
---|
268 |
|
---|
269 | UnlockSubclassedTools();
|
---|
270 | }
|
---|
271 |
|
---|
272 | if (pfnwpOrig)
|
---|
273 | mrc = pfnwpOrig(hwndTool, msg, mp1, mp2);
|
---|
274 |
|
---|
275 | return mrc;
|
---|
276 | }
|
---|
277 |
|
---|
278 | /*
|
---|
279 | *@@ SubclassTool:
|
---|
280 | * this gets called from ctl_fnwpTooltip if a control
|
---|
281 | * is to be subclassed to support mouse messaging
|
---|
282 | * (TTF_SUBCLASS flag).
|
---|
283 | *
|
---|
284 | * Preconditions: Caller must hold the subclassed
|
---|
285 | * tools mutex.
|
---|
286 | *
|
---|
287 | *@@added V0.9.0 [umoeller]
|
---|
288 | *@@changed V0.9.12 (2001-04-28) [umoeller]: renamed from SubclassToolForToolInfo
|
---|
289 | */
|
---|
290 |
|
---|
291 | STATIC BOOL SubclassTool(HWND hwndTooltip,
|
---|
292 | HWND hwndTool)
|
---|
293 | {
|
---|
294 | BOOL brc = FALSE;
|
---|
295 |
|
---|
296 | // make sure the tool is not on the list yet
|
---|
297 | // V0.9.12 (2001-04-28) [umoeller]
|
---|
298 | if (!FindSubclassedTool(hwndTool))
|
---|
299 | {
|
---|
300 | PFNWP pfnwpOrig = WinSubclassWindow(hwndTool,
|
---|
301 | ctl_fnwpSubclassedTool);
|
---|
302 | if (pfnwpOrig)
|
---|
303 | {
|
---|
304 | PSUBCLASSEDTOOL pst = (PSUBCLASSEDTOOL)malloc(sizeof(SUBCLASSEDTOOL));
|
---|
305 | if (pst)
|
---|
306 | {
|
---|
307 | pst->pfnwpOrig = pfnwpOrig;
|
---|
308 | pst->hwndTooltip = hwndTooltip;
|
---|
309 | pst->hwndTool = hwndTool;
|
---|
310 | pst->hab = WinQueryAnchorBlock(hwndTool);
|
---|
311 |
|
---|
312 | brc = !!lstAppendItem(&G_llSubclassedTools, pst);
|
---|
313 | }
|
---|
314 | }
|
---|
315 | }
|
---|
316 |
|
---|
317 | return brc;
|
---|
318 | }
|
---|
319 |
|
---|
320 | /*
|
---|
321 | *@@ UnSubclassTool:
|
---|
322 | * un-subclasses a tool previously subclassed by
|
---|
323 | * SubclassToolForToolinfo.
|
---|
324 | *
|
---|
325 | * Preconditions: Caller must hold the subclassed
|
---|
326 | * tools mutex.
|
---|
327 | *
|
---|
328 | *@@added V0.9.12 (2001-04-28) [umoeller]
|
---|
329 | */
|
---|
330 |
|
---|
331 | STATIC BOOL UnSubclassTool(HWND hwndTool)
|
---|
332 | {
|
---|
333 | PSUBCLASSEDTOOL pst;
|
---|
334 | if (pst = FindSubclassedTool(hwndTool))
|
---|
335 | {
|
---|
336 | WinSubclassWindow(hwndTool,
|
---|
337 | pst->pfnwpOrig);
|
---|
338 | // orig winproc == un-subclass
|
---|
339 | return lstRemoveItem(&G_llSubclassedTools, pst);
|
---|
340 | // this frees the item
|
---|
341 | }
|
---|
342 |
|
---|
343 | return FALSE;
|
---|
344 | }
|
---|
345 |
|
---|
346 | /* ******************************************************************
|
---|
347 | *
|
---|
348 | * Implementation
|
---|
349 | *
|
---|
350 | ********************************************************************/
|
---|
351 |
|
---|
352 | /*
|
---|
353 | *@@ TOOLTIPDATA:
|
---|
354 | * private data structure stored in the window
|
---|
355 | * words of ctl_fnwpTooltip to hold information for
|
---|
356 | * a tooltip instance.
|
---|
357 | *
|
---|
358 | *@@added V0.9.0 [umoeller]
|
---|
359 | */
|
---|
360 |
|
---|
361 | typedef struct _TOOLTIPDATA
|
---|
362 | {
|
---|
363 | HWND hwndOwner; // from WM_CREATE
|
---|
364 | HAB hab; // from WM_CREATE
|
---|
365 | USHORT usTooltipID; // from WM_CREATE
|
---|
366 |
|
---|
367 | LONG cxScreen,
|
---|
368 | cyScreen;
|
---|
369 |
|
---|
370 | BOOL fIsActive; // TRUE per default; changed by TTM_ACTIVATE
|
---|
371 |
|
---|
372 | ULONG idTimerInitial, // if != 0, "initial" timer is running
|
---|
373 | idTimerAutopop; // if != 0, "autopop" (hide) timer is running
|
---|
374 |
|
---|
375 | ULONG ulTimeoutInitial, // "initial" timer timeout (ms)
|
---|
376 | ulTimeoutAutopop, // "autopop" (hide) timer timeout (ms)
|
---|
377 | ulTimeoutReshow; // "reshow" timer timeout (ms)
|
---|
378 |
|
---|
379 | LINKLIST llTools; // linked list of TOOLINFO structures
|
---|
380 | // containing the tools
|
---|
381 | FONTMETRICS fontmetrics; // current font
|
---|
382 | LONG lForeColor, // current foreground color
|
---|
383 | lBackColor, // current background color
|
---|
384 | l3DHiColor, // 3D border light color
|
---|
385 | l3DLoColor; // 3D border dark color
|
---|
386 | PSZ pszPaintText; // text to paint (new buffer)
|
---|
387 |
|
---|
388 | POINTL ptlPointerLast; // last mouse pointer position
|
---|
389 |
|
---|
390 | PTOOLINFO ptiMouseOver; // tool info over which the mouse resides
|
---|
391 |
|
---|
392 | BOOL fIsVisible; // TRUE if tooltip is visible
|
---|
393 |
|
---|
394 | // CHAR szTextBuf[256]; // static buffer for copying/loading strings
|
---|
395 | } TOOLTIPDATA, *PTOOLTIPDATA;
|
---|
396 |
|
---|
397 | // timer IDs
|
---|
398 | #define TOOLTIP_ID_TIMER_INITIAL 1
|
---|
399 | #define TOOLTIP_ID_TIMER_AUTOPOP 2
|
---|
400 |
|
---|
401 | // tooltip window border (free spaces)
|
---|
402 | #define TOOLTIP_CX_BORDER 5
|
---|
403 | #define TOOLTIP_CY_BORDER 3
|
---|
404 |
|
---|
405 | /*
|
---|
406 | *@@ UpdateTooltipPresColors:
|
---|
407 | * this gets called during WM_CREATE and WM_PRESPARAMCHANGED
|
---|
408 | * in ctl_fnwpTooltip to set the colors in TOOLTIPDATA according
|
---|
409 | * to the control's presparams.
|
---|
410 | */
|
---|
411 |
|
---|
412 | STATIC VOID UpdateTooltipPresColors(HWND hwndTooltip) // in: tooltip control
|
---|
413 | {
|
---|
414 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
415 |
|
---|
416 | // tooltip background color:
|
---|
417 | pttd->lBackColor = winhQueryPresColor(hwndTooltip,
|
---|
418 | PP_MENUBACKGROUNDCOLOR,
|
---|
419 | FALSE, // no inherit
|
---|
420 | SYSCLR_ENTRYFIELD);
|
---|
421 | // tooltip text color:
|
---|
422 | pttd->lForeColor = winhQueryPresColor(hwndTooltip,
|
---|
423 | PP_MENUFOREGROUNDCOLOR,
|
---|
424 | FALSE, // no inherit
|
---|
425 | SYSCLR_WINDOWTEXT);
|
---|
426 | // 3D border light color:
|
---|
427 | pttd->l3DHiColor = winhQueryPresColor(hwndTooltip,
|
---|
428 | PP_MENUHILITEFGNDCOLOR,
|
---|
429 | FALSE, // no inherit
|
---|
430 | SYSCLR_WINDOWTEXT);
|
---|
431 | // 3D border dark color:
|
---|
432 | pttd->l3DLoColor = winhQueryPresColor(hwndTooltip,
|
---|
433 | PP_MENUHILITEBGNDCOLOR,
|
---|
434 | FALSE, // no inherit
|
---|
435 | SYSCLR_WINDOWTEXT);
|
---|
436 | }
|
---|
437 |
|
---|
438 | /*
|
---|
439 | *@@ TtmCreate:
|
---|
440 | * implementation for WM_CREATE in ctl_fnwpTooltip.
|
---|
441 | *
|
---|
442 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
443 | */
|
---|
444 |
|
---|
445 | STATIC MRESULT TtmCreate(HWND hwndTooltip,
|
---|
446 | MPARAM mp2)
|
---|
447 | {
|
---|
448 | PTOOLTIPDATA pttd;
|
---|
449 | PCREATESTRUCT pcs = (PCREATESTRUCT)mp2;
|
---|
450 |
|
---|
451 | // allocate and initialize tooltip data
|
---|
452 | if (pttd = (PTOOLTIPDATA)malloc(sizeof(TOOLTIPDATA)))
|
---|
453 | {
|
---|
454 | CHAR szFont[256];
|
---|
455 | memset(pttd, 0, sizeof(TOOLTIPDATA));
|
---|
456 | WinSetWindowPtr(hwndTooltip, 1, pttd);
|
---|
457 |
|
---|
458 | pttd->hwndOwner = pcs->hwndOwner;
|
---|
459 | pttd->hab = WinQueryAnchorBlock(hwndTooltip);
|
---|
460 | pttd->usTooltipID = pcs->id;
|
---|
461 |
|
---|
462 | pttd->cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
|
---|
463 | pttd->cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
|
---|
464 |
|
---|
465 | pttd->fIsActive = TRUE;
|
---|
466 |
|
---|
467 | // default timeouts
|
---|
468 | pttd->ulTimeoutInitial = 1000;
|
---|
469 | pttd->ulTimeoutAutopop = 5000;
|
---|
470 | pttd->ulTimeoutReshow = 500;
|
---|
471 |
|
---|
472 | // get colors from presparams/syscolors
|
---|
473 | UpdateTooltipPresColors(hwndTooltip);
|
---|
474 |
|
---|
475 | // check if font presparam set
|
---|
476 | if (WinQueryPresParam(hwndTooltip,
|
---|
477 | PP_FONTNAMESIZE, 0,
|
---|
478 | NULL,
|
---|
479 | sizeof(szFont),
|
---|
480 | szFont,
|
---|
481 | QPF_NOINHERIT)
|
---|
482 | == 0)
|
---|
483 | {
|
---|
484 | // no: set default font presparam
|
---|
485 | // (we never want the System Proportional font)
|
---|
486 | winhSetWindowFont(hwndTooltip,
|
---|
487 | NULL); // default (WarpSans or 8.Helv)
|
---|
488 | }
|
---|
489 |
|
---|
490 | pttd->pszPaintText = strdup("undefined");
|
---|
491 |
|
---|
492 | lstInit(&pttd->llTools, TRUE); // auto-free items
|
---|
493 |
|
---|
494 | // override CREATESTRUCT
|
---|
495 | WinSetWindowPos(hwndTooltip,
|
---|
496 | HWND_TOP,
|
---|
497 | 50, 50,
|
---|
498 | 100, 100,
|
---|
499 | SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_HIDE);
|
---|
500 |
|
---|
501 | return (MPARAM)FALSE;
|
---|
502 | }
|
---|
503 |
|
---|
504 | // malloc failed:
|
---|
505 | return (MPARAM)TRUE;
|
---|
506 | }
|
---|
507 |
|
---|
508 | /*
|
---|
509 | *@@ TtmTimer:
|
---|
510 | * implementation for WM_TIMER in ctl_fnwpTooltip.
|
---|
511 | *
|
---|
512 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
513 | */
|
---|
514 |
|
---|
515 | STATIC BOOL TtmTimer(HWND hwndTooltip, MPARAM mp1)
|
---|
516 | {
|
---|
517 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
518 | USHORT usTimer = SHORT1FROMMP(mp1);
|
---|
519 |
|
---|
520 | switch (usTimer)
|
---|
521 | {
|
---|
522 | case TOOLTIP_ID_TIMER_INITIAL:
|
---|
523 | // _Pmpf(("WM_TIMER: Stopping initial timer: %d", usTimer));
|
---|
524 | // _Pmpf((__FUNCTION__ ": TOOLTIP_ID_TIMER_INITIAL"));
|
---|
525 | WinStopTimer(pttd->hab,
|
---|
526 | hwndTooltip,
|
---|
527 | usTimer);
|
---|
528 | pttd->idTimerInitial = 0;
|
---|
529 |
|
---|
530 | if (pttd->fIsActive)
|
---|
531 | // show tooltip
|
---|
532 | WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)TRUE, 0);
|
---|
533 | break;
|
---|
534 |
|
---|
535 | case TOOLTIP_ID_TIMER_AUTOPOP:
|
---|
536 | // _Pmpf(("WM_TIMER: Stopping autopop timer: %d", usTimer));
|
---|
537 | WinStopTimer(pttd->hab,
|
---|
538 | hwndTooltip,
|
---|
539 | usTimer);
|
---|
540 | pttd->idTimerAutopop = 0;
|
---|
541 | WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)FALSE, 0);
|
---|
542 | break;
|
---|
543 |
|
---|
544 | default:
|
---|
545 | return FALSE;
|
---|
546 | } // end switch
|
---|
547 |
|
---|
548 | return TRUE;
|
---|
549 | }
|
---|
550 |
|
---|
551 | /*
|
---|
552 | *@@ TtmPaint:
|
---|
553 | * implementation for WM_PAINT in ctl_fnwpTooltip.
|
---|
554 | *
|
---|
555 | *@@added V0.9.1 (99-11-30) [umoeller]
|
---|
556 | */
|
---|
557 |
|
---|
558 | STATIC VOID TtmPaint(HWND hwndTooltip)
|
---|
559 | {
|
---|
560 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
561 | HPS hps = WinBeginPaint(hwndTooltip, NULLHANDLE, NULL);
|
---|
562 | POINTL ptl = {0, 0};
|
---|
563 | RECTL rclWindow,
|
---|
564 | rclWindowBak;
|
---|
565 | ULONG ulStyle = WinQueryWindowULong(hwndTooltip, QWL_STYLE);
|
---|
566 |
|
---|
567 | ULONG ulRounding = 0;
|
---|
568 | if (ulStyle & TTS_ROUNDED)
|
---|
569 | ulRounding = TT_ROUNDING;
|
---|
570 |
|
---|
571 |
|
---|
572 | gpihSwitchToRGB(hps);
|
---|
573 |
|
---|
574 | // get tooltip size; this has been properly calculated
|
---|
575 | // by TTM_SHOWTOOLTIPNOW earlier
|
---|
576 | WinQueryWindowRect(hwndTooltip, &rclWindow);
|
---|
577 | memcpy(&rclWindowBak, &rclWindow, sizeof(RECTL));
|
---|
578 |
|
---|
579 | if (ulStyle & TTS_SHADOW)
|
---|
580 | {
|
---|
581 | // if shadows are on, the window is too large;
|
---|
582 | // make rectl smaller for rest of paint
|
---|
583 | rclWindow.xRight -= TT_SHADOWOFS;
|
---|
584 | rclWindow.yBottom += TT_SHADOWOFS;
|
---|
585 | // restore old pattern
|
---|
586 | GpiSetPattern(hps, PATSYM_DEFAULT);
|
---|
587 | }
|
---|
588 |
|
---|
589 | // draw shadow
|
---|
590 | if (ulStyle & TTS_SHADOW)
|
---|
591 | {
|
---|
592 | GpiSetColor(hps, CLR_BLACK);
|
---|
593 | GpiSetPattern(hps, PATSYM_HALFTONE);
|
---|
594 | ptl.x = rclWindowBak.xLeft + TT_SHADOWOFS;
|
---|
595 | ptl.y = rclWindowBak.yBottom;
|
---|
596 | GpiMove(hps, &ptl);
|
---|
597 | ptl.x = rclWindowBak.xRight - 1;
|
---|
598 | ptl.y = rclWindowBak.yTop - TT_SHADOWOFS;
|
---|
599 | GpiBox(hps,
|
---|
600 | DRO_FILL,
|
---|
601 | &ptl,
|
---|
602 | ulRounding, ulRounding);
|
---|
603 | // restore pattern
|
---|
604 | GpiSetPattern(hps, PATSYM_DEFAULT);
|
---|
605 | }
|
---|
606 |
|
---|
607 | // draw "real" rectangle
|
---|
608 | ptl.x = rclWindow.xLeft;
|
---|
609 | ptl.y = rclWindow.yBottom;
|
---|
610 | GpiMove(hps, &ptl);
|
---|
611 | ptl.x = rclWindow.xRight - 1;
|
---|
612 | ptl.y = rclWindow.yTop - 1;
|
---|
613 | GpiSetColor(hps, pttd->lBackColor);
|
---|
614 | GpiBox(hps,
|
---|
615 | DRO_FILL,
|
---|
616 | &ptl,
|
---|
617 | 6, 6);
|
---|
618 |
|
---|
619 | GpiSetColor(hps, pttd->lForeColor);
|
---|
620 | GpiBox(hps,
|
---|
621 | DRO_OUTLINE,
|
---|
622 | &ptl,
|
---|
623 | ulRounding, ulRounding);
|
---|
624 |
|
---|
625 | if (pttd->pszPaintText)
|
---|
626 | {
|
---|
627 | RECTL rclText;
|
---|
628 | GpiSetColor(hps, pttd->lForeColor);
|
---|
629 | GpiSetBackColor(hps, pttd->lBackColor);
|
---|
630 | rclText.xLeft = rclWindow.xLeft + TOOLTIP_CX_BORDER;
|
---|
631 | rclText.xRight = rclWindow.xRight - TOOLTIP_CX_BORDER;
|
---|
632 | rclText.yBottom = rclWindow.yBottom + TOOLTIP_CY_BORDER;
|
---|
633 | rclText.yTop = rclWindow.yTop - TOOLTIP_CY_BORDER;
|
---|
634 | winhDrawFormattedText(hps,
|
---|
635 | &rclText,
|
---|
636 | pttd->pszPaintText,
|
---|
637 | DT_LEFT | DT_TOP | DT_WORDBREAK);
|
---|
638 | }
|
---|
639 |
|
---|
640 | WinEndPaint(hps);
|
---|
641 | }
|
---|
642 |
|
---|
643 | /*
|
---|
644 | *@@ TtmDestroy:
|
---|
645 | * implementation for WM_DESTROY in ctl_fnwpTooltip.
|
---|
646 | *
|
---|
647 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
648 | */
|
---|
649 |
|
---|
650 | STATIC VOID TtmDestroy(HWND hwndTooltip)
|
---|
651 | {
|
---|
652 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
653 | // stop timers
|
---|
654 | if (pttd->idTimerInitial)
|
---|
655 | WinStopTimer(pttd->hab,
|
---|
656 | hwndTooltip,
|
---|
657 | pttd->idTimerInitial);
|
---|
658 | if (pttd->idTimerAutopop)
|
---|
659 | WinStopTimer(pttd->hab,
|
---|
660 | hwndTooltip,
|
---|
661 | pttd->idTimerAutopop);
|
---|
662 | if (pttd->pszPaintText)
|
---|
663 | free(pttd->pszPaintText);
|
---|
664 |
|
---|
665 | // un-subclass all tools that we subclassed
|
---|
666 | // V0.9.12 (2001-04-28) [umoeller]
|
---|
667 | if (LockSubclassedTools())
|
---|
668 | {
|
---|
669 | PLISTNODE pNode;
|
---|
670 | PSUBCLASSEDTOOL pst;
|
---|
671 | for (pNode = lstQueryFirstNode(&pttd->llTools);
|
---|
672 | pNode;
|
---|
673 | pNode = pNode->pNext)
|
---|
674 | {
|
---|
675 | PTOOLINFO pti = (PTOOLINFO)pNode->pItemData;
|
---|
676 | if (pst = FindSubclassedTool(pti->hwndTool))
|
---|
677 | UnSubclassTool(pti->hwndTool);
|
---|
678 | }
|
---|
679 |
|
---|
680 | UnlockSubclassedTools();
|
---|
681 | }
|
---|
682 | // end V0.9.12 (2001-04-28) [umoeller]
|
---|
683 |
|
---|
684 | lstClear(&pttd->llTools);
|
---|
685 |
|
---|
686 | free(pttd);
|
---|
687 | }
|
---|
688 |
|
---|
689 | /*
|
---|
690 | *@@ TtmAddTool:
|
---|
691 | * implementation for TTM_ADDTOOL in ctl_fnwpTooltip.
|
---|
692 | *
|
---|
693 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
694 | */
|
---|
695 |
|
---|
696 | STATIC MRESULT TtmAddTool(HWND hwndTooltip, MPARAM mp2)
|
---|
697 | {
|
---|
698 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
699 | if (mp2)
|
---|
700 | {
|
---|
701 | PTOOLINFO ptiPassed = (PTOOLINFO)mp2,
|
---|
702 | ptiNew = (PTOOLINFO)malloc(sizeof(TOOLINFO));
|
---|
703 | if (ptiNew)
|
---|
704 | {
|
---|
705 | memcpy(ptiNew, ptiPassed, sizeof(TOOLINFO));
|
---|
706 | lstAppendItem(&pttd->llTools,
|
---|
707 | ptiNew);
|
---|
708 |
|
---|
709 | if ( (ptiPassed->ulFlags & TTF_SUBCLASS)
|
---|
710 | && (LockSubclassedTools()) // V0.9.12 (2001-04-28) [umoeller]
|
---|
711 | )
|
---|
712 | {
|
---|
713 | // caller wants this tool to be subclassed:
|
---|
714 | // well, do it then
|
---|
715 | SubclassTool(hwndTooltip,
|
---|
716 | ptiPassed->hwndTool);
|
---|
717 |
|
---|
718 | UnlockSubclassedTools();
|
---|
719 | }
|
---|
720 |
|
---|
721 | return ((MPARAM)TRUE);
|
---|
722 | }
|
---|
723 | }
|
---|
724 |
|
---|
725 | return (MPARAM)FALSE;
|
---|
726 | }
|
---|
727 |
|
---|
728 | /*
|
---|
729 | *@@ TtmDelTool:
|
---|
730 | * implementation for TTM_DELTOOL in ctl_fnwpTooltip.
|
---|
731 | *
|
---|
732 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
733 | *@@changed V0.9.13 (2001-06-21) [umoeller]: fixed missing unlock
|
---|
734 | *@@changed V0.9.13 (2001-06-21) [umoeller]: fixed endless loop
|
---|
735 | */
|
---|
736 |
|
---|
737 | STATIC VOID TtmDelTool(HWND hwndTooltip, MPARAM mp2)
|
---|
738 | {
|
---|
739 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
740 | PTOOLINFO ptiSearch;
|
---|
741 | if (ptiSearch = (PTOOLINFO)mp2)
|
---|
742 | {
|
---|
743 | PLISTNODE pToolNode = lstQueryFirstNode(&pttd->llTools);
|
---|
744 | while (pToolNode)
|
---|
745 | {
|
---|
746 | PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData;
|
---|
747 | if ( (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner)
|
---|
748 | && (ptiThis->hwndTool == ptiSearch->hwndTool)
|
---|
749 | )
|
---|
750 | {
|
---|
751 | // found:
|
---|
752 |
|
---|
753 | // V0.9.12 (2001-04-28) [umoeller]
|
---|
754 | // unsubclass if this was subclassed
|
---|
755 | if (ptiThis->ulFlags & TTF_SUBCLASS)
|
---|
756 | {
|
---|
757 | if (LockSubclassedTools())
|
---|
758 | {
|
---|
759 | UnSubclassTool(ptiSearch->hwndTool);
|
---|
760 |
|
---|
761 | UnlockSubclassedTools();
|
---|
762 | // was missing V0.9.13 (2001-06-21) [umoeller]
|
---|
763 | }
|
---|
764 | }
|
---|
765 |
|
---|
766 | // remove the tool from the list
|
---|
767 | lstRemoveNode(&pttd->llTools, pToolNode);
|
---|
768 |
|
---|
769 | break;
|
---|
770 | }
|
---|
771 |
|
---|
772 | pToolNode = pToolNode->pNext;
|
---|
773 | // fixed endless loop V0.9.13 (2001-06-21) [umoeller]
|
---|
774 | }
|
---|
775 | }
|
---|
776 | }
|
---|
777 |
|
---|
778 | /*
|
---|
779 | *@@ TtmRelayEvent:
|
---|
780 | * implementation for TTM_RELAYEVENT in ctl_fnwpTooltip.
|
---|
781 | *
|
---|
782 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
783 | *@@changed V0.9.19 (2002-05-14) [umoeller]: fixed bad stop timer, thanks yuri
|
---|
784 | *@@changed V1.0.2 (2003-07-26) [pr]: fixed tooltip moving with mouse from xcenters @@fixes 455
|
---|
785 | */
|
---|
786 |
|
---|
787 | STATIC VOID TtmRelayEvent(HWND hwndTooltip, MPARAM mp2)
|
---|
788 | {
|
---|
789 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
790 | PQMSG pqmsg = (PQMSG)mp2;
|
---|
791 | if (pqmsg)
|
---|
792 | {
|
---|
793 | POINTL ptlPointer;
|
---|
794 | PLISTNODE pToolNode;
|
---|
795 |
|
---|
796 | // moved stop timer down V0.9.19 (2002-05-14) [umoeller]
|
---|
797 |
|
---|
798 | WinQueryPointerPos(HWND_DESKTOP, &ptlPointer);
|
---|
799 |
|
---|
800 | // find TOOLINFO from mouse position
|
---|
801 | pttd->ptiMouseOver = NULL;
|
---|
802 | pToolNode = lstQueryFirstNode(&pttd->llTools);
|
---|
803 | while (pToolNode)
|
---|
804 | {
|
---|
805 | PTOOLINFO pti = (PTOOLINFO)pToolNode->pItemData;
|
---|
806 | if (pti->hwndTool == pqmsg->hwnd)
|
---|
807 | {
|
---|
808 | // _Pmpf((__FUNCTION__ ": found tool"));
|
---|
809 | pttd->ptiMouseOver = pti;
|
---|
810 | break;
|
---|
811 | }
|
---|
812 | pToolNode = pToolNode->pNext;
|
---|
813 | }
|
---|
814 |
|
---|
815 | if ( (ptlPointer.x < pttd->ptlPointerLast.x - 4)
|
---|
816 | || (ptlPointer.x > pttd->ptlPointerLast.x + 4)
|
---|
817 | || (ptlPointer.y < pttd->ptlPointerLast.y - 4)
|
---|
818 | || (ptlPointer.y > pttd->ptlPointerLast.y + 4)
|
---|
819 | || (pqmsg->msg == WM_BUTTON1DOWN)
|
---|
820 | || (pqmsg->msg == WM_BUTTON2DOWN)
|
---|
821 | || (pqmsg->msg == WM_BUTTON3DOWN)
|
---|
822 | || (pqmsg->msg == WM_MOUSELEAVE) // V1.0.2 (2003-07-26) [pr]: @@fixes 455
|
---|
823 | )
|
---|
824 | {
|
---|
825 | // mouse pos changed:
|
---|
826 | // moved stop timer here V0.9.19 (2002-05-14) [umoeller]
|
---|
827 | if (pttd->idTimerInitial)
|
---|
828 | {
|
---|
829 | // _Pmpf(("TTM_RELAYEVENT: Stopping timer: %d", pttd->idTimerInitial));
|
---|
830 | WinStopTimer(pttd->hab,
|
---|
831 | hwndTooltip,
|
---|
832 | TOOLTIP_ID_TIMER_INITIAL);
|
---|
833 | pttd->idTimerInitial = 0;
|
---|
834 | }
|
---|
835 |
|
---|
836 | // hide tooltip
|
---|
837 | WinPostMsg(hwndTooltip,
|
---|
838 | TTM_SHOWTOOLTIPNOW,
|
---|
839 | (MPARAM)FALSE,
|
---|
840 | 0);
|
---|
841 | memcpy(&pttd->ptlPointerLast, &ptlPointer, sizeof(POINTL));
|
---|
842 |
|
---|
843 | // _Pmpf((__FUNCTION__ ": pttd->ptiMouseOver: 0x%lX", pttd->ptiMouseOver));
|
---|
844 | // _Pmpf((__FUNCTION__ ": pttd->fIsActive: 0x%lX", pttd->fIsActive));
|
---|
845 | if ( (pttd->ptiMouseOver)
|
---|
846 | && (pttd->fIsActive)
|
---|
847 | && (pqmsg->msg != WM_MOUSELEAVE) // V1.0.2 (2003-07-26) [pr]: @@fixes 455
|
---|
848 | )
|
---|
849 | {
|
---|
850 | // tool found and tooltip is activated:
|
---|
851 | pttd->idTimerInitial = WinStartTimer(pttd->hab,
|
---|
852 | hwndTooltip,
|
---|
853 | TOOLTIP_ID_TIMER_INITIAL,
|
---|
854 | pttd->ulTimeoutInitial);
|
---|
855 | // _Pmpf(("TTM_RELAYEVENT: Started timer: %d", pttd->idTimerInitial));
|
---|
856 | }
|
---|
857 | }
|
---|
858 | } // end if (pqmsg)
|
---|
859 | }
|
---|
860 |
|
---|
861 | /*
|
---|
862 | *@@ TtmGetDelayTime:
|
---|
863 | * implementation for TTM_GETDELAYTIME in ctl_fnwpTooltip.
|
---|
864 | *
|
---|
865 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
866 | */
|
---|
867 |
|
---|
868 | STATIC MRESULT TtmGetDelayTime(HWND hwndTooltip, MPARAM mp1)
|
---|
869 | {
|
---|
870 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
871 | switch ((ULONG)mp1)
|
---|
872 | {
|
---|
873 | case TTDT_AUTOPOP:
|
---|
874 | return (MRESULT)pttd->ulTimeoutAutopop;
|
---|
875 |
|
---|
876 | case TTDT_INITIAL:
|
---|
877 | return (MRESULT)pttd->ulTimeoutInitial;
|
---|
878 |
|
---|
879 | case TTDT_RESHOW:
|
---|
880 | return (MRESULT)pttd->ulTimeoutReshow;
|
---|
881 | }
|
---|
882 |
|
---|
883 | return (0);
|
---|
884 | }
|
---|
885 |
|
---|
886 | /*
|
---|
887 | *@@ TtmSetDelayTime:
|
---|
888 | * implementation for TTM_SETDELAYTIME in ctl_fnwpTooltip.
|
---|
889 | *
|
---|
890 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
891 | */
|
---|
892 |
|
---|
893 | STATIC VOID TtmSetDelayTime(HWND hwndTooltip, MPARAM mp1, MPARAM mp2)
|
---|
894 | {
|
---|
895 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
896 | ULONG iDelay = (ULONG)mp2;
|
---|
897 | switch (SHORT1FROMMP(mp1))
|
---|
898 | {
|
---|
899 | case TTDT_AUTOMATIC:
|
---|
900 | pttd->ulTimeoutInitial = iDelay;
|
---|
901 | pttd->ulTimeoutAutopop = iDelay * 5;
|
---|
902 | pttd->ulTimeoutReshow = iDelay / 2;
|
---|
903 | break;
|
---|
904 |
|
---|
905 | case TTDT_AUTOPOP:
|
---|
906 | pttd->ulTimeoutAutopop = iDelay;
|
---|
907 | break;
|
---|
908 |
|
---|
909 | case TTDT_INITIAL:
|
---|
910 | pttd->ulTimeoutInitial = iDelay;
|
---|
911 | break;
|
---|
912 |
|
---|
913 | case TTDT_RESHOW:
|
---|
914 | pttd->ulTimeoutReshow = iDelay;
|
---|
915 | break;
|
---|
916 | }
|
---|
917 | }
|
---|
918 |
|
---|
919 | /*
|
---|
920 | *@@ TtmGetText:
|
---|
921 | * implementation for TTM_GETTEXT in ctl_fnwpTooltip.
|
---|
922 | *
|
---|
923 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
924 | */
|
---|
925 |
|
---|
926 | STATIC VOID TtmGetText(HWND hwndTooltip, MPARAM mp2)
|
---|
927 | {
|
---|
928 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
929 | PTOOLINFO pti = (PTOOLINFO)mp2;
|
---|
930 |
|
---|
931 | if (pti->pszText == PSZ_TEXTCALLBACK)
|
---|
932 | {
|
---|
933 | // TTN_NEEDTEXT notification desired:
|
---|
934 | // compose values for that msg
|
---|
935 | TOOLTIPTEXT ttt = {0};
|
---|
936 | ttt.hwndTooltip = hwndTooltip;
|
---|
937 | ttt.hwndTool = pti->hwndTool;
|
---|
938 | WinSendMsg(pti->hwndToolOwner,
|
---|
939 | WM_CONTROL,
|
---|
940 | MPFROM2SHORT(pttd->usTooltipID, // tooltip control wnd ID
|
---|
941 | TTN_NEEDTEXT),
|
---|
942 | &ttt);
|
---|
943 |
|
---|
944 | // in case of error: set lpszText to NULL; this
|
---|
945 | // is not specified in the docs however.
|
---|
946 | pti->pszText = NULL;
|
---|
947 |
|
---|
948 | switch (ttt.ulFormat)
|
---|
949 | {
|
---|
950 | case TTFMT_PSZ:
|
---|
951 | if (ttt.pszText)
|
---|
952 | pti->pszText = ttt.pszText;
|
---|
953 | break;
|
---|
954 |
|
---|
955 | case TTFMT_STRINGRES:
|
---|
956 | // @@todo
|
---|
957 | break;
|
---|
958 | }
|
---|
959 | }
|
---|
960 | }
|
---|
961 |
|
---|
962 | /*
|
---|
963 | *@@ TtmEnumTools:
|
---|
964 | * implementation for TTM_ENUMTOOLS in ctl_fnwpTooltip.
|
---|
965 | *
|
---|
966 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
967 | */
|
---|
968 |
|
---|
969 | STATIC MRESULT TtmEnumTools(HWND hwndTooltip, MPARAM mp1, MPARAM mp2)
|
---|
970 | {
|
---|
971 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
972 | PTOOLINFO ptiTarget;
|
---|
973 | if (ptiTarget = (PTOOLINFO)mp2)
|
---|
974 | {
|
---|
975 | PTOOLINFO ptiFound = (PTOOLINFO)lstItemFromIndex(&pttd->llTools,
|
---|
976 | SHORT1FROMMP(mp1));
|
---|
977 | if (ptiFound)
|
---|
978 | {
|
---|
979 | memcpy(ptiTarget, ptiFound, sizeof(TOOLINFO));
|
---|
980 | return (MRESULT)TRUE;
|
---|
981 | }
|
---|
982 | }
|
---|
983 |
|
---|
984 | return (MRESULT)FALSE;
|
---|
985 | }
|
---|
986 |
|
---|
987 | /*
|
---|
988 | *@@ TtmGetCurrentTool:
|
---|
989 | * implementation for TTM_GETCURRENTTOOL in ctl_fnwpTooltip.
|
---|
990 | *
|
---|
991 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
992 | */
|
---|
993 |
|
---|
994 | STATIC MRESULT TtmGetCurrentTool(HWND hwndTooltip, MPARAM mp2)
|
---|
995 | {
|
---|
996 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
997 | PTOOLINFO ptiTarget;
|
---|
998 | if (ptiTarget = (PTOOLINFO)mp2)
|
---|
999 | {
|
---|
1000 | if (pttd->ptiMouseOver)
|
---|
1001 | {
|
---|
1002 | memcpy(ptiTarget, pttd->ptiMouseOver, sizeof(TOOLINFO));
|
---|
1003 | return (MRESULT)TRUE;
|
---|
1004 | }
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | return (MRESULT)FALSE;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | /*
|
---|
1011 | *@@ TtmGetToolInfo:
|
---|
1012 | * implementation for TTM_GETTOOLINFO in ctl_fnwpTooltip.
|
---|
1013 | *
|
---|
1014 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
1015 | */
|
---|
1016 |
|
---|
1017 | STATIC MRESULT TtmGetToolInfo(HWND hwndTooltip, MPARAM mp2)
|
---|
1018 | {
|
---|
1019 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
1020 | PTOOLINFO ptiSearch;
|
---|
1021 | if (ptiSearch = (PTOOLINFO)mp2)
|
---|
1022 | {
|
---|
1023 | PLISTNODE pToolNode = lstQueryFirstNode(&pttd->llTools);
|
---|
1024 | while (pToolNode)
|
---|
1025 | {
|
---|
1026 | PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData;
|
---|
1027 | if ( (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner)
|
---|
1028 | && (ptiThis->hwndTool == ptiSearch->hwndTool)
|
---|
1029 | )
|
---|
1030 | {
|
---|
1031 | // found:
|
---|
1032 | memcpy(ptiSearch, ptiThis, sizeof(TOOLINFO));
|
---|
1033 | return (MPARAM)TRUE;
|
---|
1034 | }
|
---|
1035 | pToolNode = pToolNode->pNext;
|
---|
1036 | }
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | return ((MPARAM)FALSE);
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | /*
|
---|
1043 | *@@ FormatTooltip:
|
---|
1044 | * formats the tooltip window according to
|
---|
1045 | * its text (which is assumed to be in
|
---|
1046 | * pttd->pszPaintText) and positions it
|
---|
1047 | * on the screen.
|
---|
1048 | *
|
---|
1049 | * This does not change the visibility
|
---|
1050 | * of the tooltip; if it is not yet visible,
|
---|
1051 | * you must show it afterwards.
|
---|
1052 | *
|
---|
1053 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
1054 | *@@changed V1.0.4 (2005-10-15) [bvl]: Add 1 pixel to width of DBCS tooltip @@fixes 676
|
---|
1055 | */
|
---|
1056 |
|
---|
1057 | STATIC VOID FormatTooltip(HWND hwndTooltip,
|
---|
1058 | PTOOLTIPDATA pttd,
|
---|
1059 | PPOINTL pptlPointer) // in: current pointer pos or NULL
|
---|
1060 | {
|
---|
1061 | // find out how much space we need
|
---|
1062 | RECTL rcl = { 0, 0, 300, 1000 };
|
---|
1063 | POINTL ptlTooltip;
|
---|
1064 | LONG cx, cy;
|
---|
1065 | ULONG ulStyle = WinQueryWindowULong(hwndTooltip, QWL_STYLE);
|
---|
1066 |
|
---|
1067 | HPS hps = WinGetPS(hwndTooltip);
|
---|
1068 |
|
---|
1069 | winhDrawFormattedText(hps,
|
---|
1070 | &rcl,
|
---|
1071 | pttd->pszPaintText,
|
---|
1072 | DT_LEFT | DT_TOP | DT_WORDBREAK | DT_QUERYEXTENT);
|
---|
1073 | WinReleasePS(hps);
|
---|
1074 |
|
---|
1075 | // calc width and height of tooltip
|
---|
1076 | // DBCS needs a extra pixel to show characters.
|
---|
1077 | cx = rcl.xRight + 2*TOOLTIP_CX_BORDER;
|
---|
1078 | if (nlsDBCS())
|
---|
1079 | cx++;
|
---|
1080 |
|
---|
1081 | cy = (rcl.yTop - rcl.yBottom) + 2*TOOLTIP_CY_BORDER;
|
---|
1082 |
|
---|
1083 | // calc x and y pos of tooltip:
|
---|
1084 |
|
---|
1085 | // per default, use pointer pos
|
---|
1086 | ptlTooltip.x = pptlPointer->x - cx/2;
|
---|
1087 | ptlTooltip.y = pptlPointer->y - cy;
|
---|
1088 |
|
---|
1089 | // do we need the tool's position?
|
---|
1090 | if ( pttd->ptiMouseOver->ulFlags
|
---|
1091 | & (TTF_CENTER_X_ON_TOOL | TTF_POS_Y_ABOVE_TOOL | TTF_POS_Y_BELOW_TOOL)
|
---|
1092 | )
|
---|
1093 | {
|
---|
1094 | // yes:
|
---|
1095 | SWP swpTool;
|
---|
1096 | POINTL ptlTool;
|
---|
1097 | WinQueryWindowPos(pttd->ptiMouseOver->hwndTool, &swpTool);
|
---|
1098 | ptlTool.x = swpTool.x;
|
---|
1099 | ptlTool.y = swpTool.y;
|
---|
1100 | // convert x, y to desktop points
|
---|
1101 | WinMapWindowPoints(WinQueryWindow(pttd->ptiMouseOver->hwndTool,
|
---|
1102 | QW_PARENT), // hwndFrom
|
---|
1103 | HWND_DESKTOP, // hwndTo
|
---|
1104 | &ptlTool,
|
---|
1105 | 1);
|
---|
1106 |
|
---|
1107 | // X
|
---|
1108 | if (pttd->ptiMouseOver->ulFlags & TTF_CENTER_X_ON_TOOL)
|
---|
1109 | // center X on tool:
|
---|
1110 | ptlTooltip.x = ptlTool.x + ((swpTool.cx - cx) / 2L);
|
---|
1111 |
|
---|
1112 | // Y
|
---|
1113 | if (pttd->ptiMouseOver->ulFlags & TTF_POS_Y_ABOVE_TOOL)
|
---|
1114 | ptlTooltip.y = ptlTool.y + swpTool.cy;
|
---|
1115 | else if (pttd->ptiMouseOver->ulFlags & TTF_POS_Y_BELOW_TOOL)
|
---|
1116 | ptlTooltip.y = ptlTool.y - cy;
|
---|
1117 | }
|
---|
1118 |
|
---|
1119 | // if "shy mouse" is enabled, make
|
---|
1120 | // sure the tool tip is not under the
|
---|
1121 | // mouse pointer
|
---|
1122 | if (ulStyle & TTF_SHYMOUSE)
|
---|
1123 | {
|
---|
1124 | // we need to subtract the current mouse
|
---|
1125 | // pointer's hot spot from the current
|
---|
1126 | // pointer position
|
---|
1127 | HPOINTER hptr = WinQueryPointer(HWND_DESKTOP);
|
---|
1128 | POINTERINFO pi;
|
---|
1129 | if (WinQueryPointerInfo(hptr, &pi))
|
---|
1130 | {
|
---|
1131 | // calc bottom edge of mouse pointer rect
|
---|
1132 | ULONG yBottomPointer = (pptlPointer->y - pi.yHotspot);
|
---|
1133 | // _Pmpf(("yHotspot: %d", pi.yHotspot));
|
---|
1134 | if ( (ptlTooltip.y + cy) // top edge of tool tip
|
---|
1135 | > yBottomPointer
|
---|
1136 | )
|
---|
1137 | {
|
---|
1138 | ptlTooltip.y = pptlPointer->y - cy - pi.yHotspot;
|
---|
1139 | }
|
---|
1140 | }
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 | // constrain to screen
|
---|
1144 | if (ptlTooltip.x < 0)
|
---|
1145 | ptlTooltip.x = 0;
|
---|
1146 | if (ptlTooltip.y < 0)
|
---|
1147 | ptlTooltip.y = 0;
|
---|
1148 | if (ptlTooltip.x + cx > pttd->cxScreen)
|
---|
1149 | ptlTooltip.x = pttd->cxScreen-cx;
|
---|
1150 | if (ptlTooltip.y + cy > pttd->cyScreen)
|
---|
1151 | ptlTooltip.y = pttd->cyScreen-cy;
|
---|
1152 |
|
---|
1153 | // if shadow is enabled,
|
---|
1154 | // enlarge; the shadow might by
|
---|
1155 | // off-screen now, but that's OK
|
---|
1156 | if (ulStyle & TTS_SHADOW)
|
---|
1157 | {
|
---|
1158 | cx += TT_SHADOWOFS;
|
---|
1159 | cy += TT_SHADOWOFS;
|
---|
1160 | ptlTooltip.y -= TT_SHADOWOFS;
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | // set tooltip position at the pos we calculated
|
---|
1164 | // and show tooltip
|
---|
1165 | WinSetWindowPos(hwndTooltip,
|
---|
1166 | HWND_TOP,
|
---|
1167 | ptlTooltip.x,
|
---|
1168 | ptlTooltip.y,
|
---|
1169 | cx,
|
---|
1170 | cy,
|
---|
1171 | SWP_MOVE | SWP_SIZE | SWP_ZORDER);
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | /*
|
---|
1175 | *@@ TtmUpdateTipText:
|
---|
1176 | * implementation for TTM_UPDATETIPTEXT in ctl_fnwpTooltip.
|
---|
1177 | *
|
---|
1178 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
1179 | */
|
---|
1180 |
|
---|
1181 | STATIC VOID TtmUpdateTipText(HWND hwndTooltip,
|
---|
1182 | const char *pcszNewText)
|
---|
1183 | {
|
---|
1184 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
1185 |
|
---|
1186 | // has text really changed?
|
---|
1187 | if ( ( (pttd->pszPaintText)
|
---|
1188 | && (pcszNewText)
|
---|
1189 | && (strcmp(pttd->pszPaintText, pcszNewText))
|
---|
1190 | )
|
---|
1191 | || (pttd->pszPaintText && !pcszNewText)
|
---|
1192 | || (!pttd->pszPaintText && pcszNewText)
|
---|
1193 | )
|
---|
1194 | {
|
---|
1195 | // yes:
|
---|
1196 | if (pttd->pszPaintText)
|
---|
1197 | {
|
---|
1198 | free(pttd->pszPaintText);
|
---|
1199 | pttd->pszPaintText = NULL;
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | if (pcszNewText)
|
---|
1203 | pttd->pszPaintText = strdup(pcszNewText);
|
---|
1204 |
|
---|
1205 | if (pttd->fIsVisible)
|
---|
1206 | {
|
---|
1207 | // currently showing:
|
---|
1208 | // reformat
|
---|
1209 | POINTL ptlPointer;
|
---|
1210 | WinQueryPointerPos(HWND_DESKTOP, &ptlPointer);
|
---|
1211 | FormatTooltip(hwndTooltip,
|
---|
1212 | pttd,
|
---|
1213 | &ptlPointer);
|
---|
1214 | WinInvalidateRect(hwndTooltip, NULL, FALSE);
|
---|
1215 | }
|
---|
1216 | }
|
---|
1217 | }
|
---|
1218 |
|
---|
1219 | /*
|
---|
1220 | *@@ TtmShowTooltip:
|
---|
1221 | * implementation for TTM_SHOW_TOOLTIP.
|
---|
1222 | *
|
---|
1223 | * Depending on fShow, this shows or hides the
|
---|
1224 | * tool tip at the position specified by the
|
---|
1225 | * current tool or the mouse pointer (specified
|
---|
1226 | * by the tool's style flags).
|
---|
1227 | *
|
---|
1228 | *@@added V0.9.1 (2000-02-04) [umoeller]
|
---|
1229 | */
|
---|
1230 |
|
---|
1231 | STATIC VOID TtmShowTooltip(HWND hwndTooltip,
|
---|
1232 | BOOL fShow) // if TRUE: show, else: HIDE
|
---|
1233 | {
|
---|
1234 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
1235 | if (fShow)
|
---|
1236 | {
|
---|
1237 | /*
|
---|
1238 | * show tooltip::
|
---|
1239 | *
|
---|
1240 | */
|
---|
1241 |
|
---|
1242 | POINTL ptlPointer;
|
---|
1243 | // HPS hps;
|
---|
1244 |
|
---|
1245 | // free old text
|
---|
1246 | if (pttd->pszPaintText)
|
---|
1247 | {
|
---|
1248 | free(pttd->pszPaintText);
|
---|
1249 | pttd->pszPaintText = NULL;
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | WinQueryPointerPos(HWND_DESKTOP, &ptlPointer);
|
---|
1253 |
|
---|
1254 | if ( (ptlPointer.x >= pttd->ptlPointerLast.x - 4)
|
---|
1255 | && (ptlPointer.x <= pttd->ptlPointerLast.x + 4)
|
---|
1256 | && (ptlPointer.y >= pttd->ptlPointerLast.y - 4)
|
---|
1257 | && (ptlPointer.y <= pttd->ptlPointerLast.y + 4)
|
---|
1258 | )
|
---|
1259 | {
|
---|
1260 | // mouse not moved since timer was started:
|
---|
1261 | // find the current TOOLINFO
|
---|
1262 | if (pttd->ptiMouseOver)
|
---|
1263 | {
|
---|
1264 | TOOLINFO tiTemp;
|
---|
1265 | memcpy(&tiTemp, pttd->ptiMouseOver, sizeof(TOOLINFO));
|
---|
1266 | // get the text for the TOOLINFO
|
---|
1267 | WinSendMsg(hwndTooltip,
|
---|
1268 | TTM_GETTEXT,
|
---|
1269 | (MPARAM)0,
|
---|
1270 | (MPARAM)&tiTemp);
|
---|
1271 | if (tiTemp.pszText)
|
---|
1272 | pttd->pszPaintText = strdup(tiTemp.pszText);
|
---|
1273 | else
|
---|
1274 | pttd->pszPaintText = NULL;
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | if (pttd->pszPaintText)
|
---|
1278 | {
|
---|
1279 | FormatTooltip(hwndTooltip,
|
---|
1280 | pttd,
|
---|
1281 | &ptlPointer);
|
---|
1282 |
|
---|
1283 | // notify owner (TTN_SHOW)
|
---|
1284 | WinSendMsg(pttd->hwndOwner,
|
---|
1285 | WM_CONTROL,
|
---|
1286 | MPFROM2SHORT(pttd->usTooltipID, // tooltip control wnd ID
|
---|
1287 | TTN_SHOW),
|
---|
1288 | pttd->ptiMouseOver);
|
---|
1289 |
|
---|
1290 | WinShowWindow(hwndTooltip, TRUE);
|
---|
1291 | pttd->fIsVisible = TRUE;
|
---|
1292 |
|
---|
1293 | // start autopop timer
|
---|
1294 | pttd->idTimerAutopop = WinStartTimer(pttd->hab,
|
---|
1295 | hwndTooltip,
|
---|
1296 | TOOLTIP_ID_TIMER_AUTOPOP,
|
---|
1297 | pttd->ulTimeoutAutopop);
|
---|
1298 | } // end if (pttd->pszPaintText)
|
---|
1299 | } // end if ( (ptlPointer.x == pttd->ptlPointerLast.x)...
|
---|
1300 | } // end if (mp1)
|
---|
1301 | else
|
---|
1302 | {
|
---|
1303 | /*
|
---|
1304 | * hide tooltip::
|
---|
1305 | *
|
---|
1306 | */
|
---|
1307 |
|
---|
1308 | if (pttd->fIsVisible)
|
---|
1309 | {
|
---|
1310 | // notify owner (TTN_POP)
|
---|
1311 | WinSendMsg(pttd->hwndOwner,
|
---|
1312 | WM_CONTROL,
|
---|
1313 | MPFROM2SHORT(pttd->usTooltipID, // tooltip control wnd ID
|
---|
1314 | TTN_POP),
|
---|
1315 | pttd->ptiMouseOver);
|
---|
1316 | WinShowWindow(hwndTooltip, FALSE);
|
---|
1317 | }
|
---|
1318 |
|
---|
1319 | // stop autopop timer
|
---|
1320 | if (pttd->idTimerAutopop)
|
---|
1321 | {
|
---|
1322 | WinStopTimer(pttd->hab,
|
---|
1323 | hwndTooltip,
|
---|
1324 | TOOLTIP_ID_TIMER_AUTOPOP);
|
---|
1325 | pttd->idTimerAutopop = 0;
|
---|
1326 | }
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | // store new visibility
|
---|
1330 | pttd->fIsVisible = fShow;
|
---|
1331 | }
|
---|
1332 |
|
---|
1333 | /*
|
---|
1334 | *@@ ctl_fnwpTooltip:
|
---|
1335 | * window procedure for the "tooltip" control. This control is
|
---|
1336 | * largely source-code compatible to the Win32 version and has
|
---|
1337 | * been modelled according to the Win32 programmer's reference.
|
---|
1338 | *
|
---|
1339 | * A tooltip control is a small pop-up window that displays a
|
---|
1340 | * single line of descriptive text giving the purpose of "tools"
|
---|
1341 | * in an application.
|
---|
1342 | * A "tool" is either a window, such as a child window or control,
|
---|
1343 | * or an application-defined rectangular area within a window.
|
---|
1344 | * See the TTM_ADDTOOL message for details.
|
---|
1345 | *
|
---|
1346 | * To clarify: There is usually one tooltip control, which is hidden
|
---|
1347 | * most of the time, for many "tools" (parts of a visible window).
|
---|
1348 | * When the user puts the cursor on a tool and leaves it there for
|
---|
1349 | * approximately one-half second, the tooltip control is set up for
|
---|
1350 | * that tool and made visible. The tooltip control appears near the
|
---|
1351 | * pointer and disappears when the user clicks a mouse button or moves
|
---|
1352 | * the pointer off of the tool.
|
---|
1353 | *
|
---|
1354 | * The Win32 concept has been extended with this implementation to
|
---|
1355 | * display even longer texts, including line breaks. The tooltip
|
---|
1356 | * window is formatted accordingly.
|
---|
1357 | *
|
---|
1358 | * All default window styles are ignored when you create the tooltip,
|
---|
1359 | * but will rather be set by this window proc automatically. The
|
---|
1360 | * only valid window styles are the TTS_* flags (see notes below).
|
---|
1361 | *
|
---|
1362 | * Presentation parameters are fully supported.
|
---|
1363 | *
|
---|
1364 | * To create a tooltip control using comctl.c, use
|
---|
1365 | + ctlRegisterTooltip(hab);
|
---|
1366 | + hwndTooltip = WinCreateWindow(HWND_DESKTOP, // parent
|
---|
1367 | + COMCTL_TOOLTIP_CLASS, // wnd class (comctl.h)
|
---|
1368 | + NULL, // window text
|
---|
1369 | + TTS_ALWAYSTIP, // window style, ignored except for TTS_* flags
|
---|
1370 | + 0, 0, 0, 0, // window pos and size, ignored
|
---|
1371 | + hwndOwner, // owner window -- important!
|
---|
1372 | + NULLHANDLE, // hwndInsertBehind, ignored
|
---|
1373 | + ulID, // window ID, optional
|
---|
1374 | + NULL, // control data
|
---|
1375 | + NULL); // presparams
|
---|
1376 | +
|
---|
1377 | * ctl_fnwpTooltip automatically sets the size, position, and visibility
|
---|
1378 | * of the tooltip control. The size of the tooltip window will vary
|
---|
1379 | * depending on the text to be displayed and on the font presentation
|
---|
1380 | * parameters, which are supported by this control (OS/2 only).
|
---|
1381 | *
|
---|
1382 | * Note: OS/2 normally does not destroy windows which are only owned by
|
---|
1383 | * another window. As a result, when the tooltip's owner is destroyed,
|
---|
1384 | * you must explicitly also destroy the tooltip window.
|
---|
1385 | *
|
---|
1386 | * Under both Win32 and OS/2, a tooltip control has two class-specific styles:
|
---|
1387 | *
|
---|
1388 | * -- TTS_ALWAYSTIP: the tooltip appears when the cursor is on a tool,
|
---|
1389 | * regardless of whether the tooltip control's owner window is active
|
---|
1390 | * or inactive. Without this style, the tooltip control appears when the
|
---|
1391 | * tool's owner window is active, but not when it is inactive.
|
---|
1392 | *
|
---|
1393 | * -- TTS_NOPREFIX: this prevents the system from stripping the ampersand (&)
|
---|
1394 | * character from a string. If a tooltip control does not have the TTS_NOPREFIX
|
---|
1395 | * style, the system automatically strips ampersand characters, allowing an
|
---|
1396 | * application to use the same string as both a menu item and tooltip text.
|
---|
1397 | *
|
---|
1398 | * The tooltip control can be (de)activated using the TTM_ACTIVATE message.
|
---|
1399 | *
|
---|
1400 | * To register tools with the tooltip control (to make it do anything
|
---|
1401 | * meaningful), send the TTM_ADDTOOL message to the tooltip control.
|
---|
1402 | *
|
---|
1403 | * This control supports the following presentation parameters (if the
|
---|
1404 | * PP_* value is not found, the SYSCLR_* system color is used):
|
---|
1405 | * -- PP_MENUBACKGROUNDCOLOR / SYSCLR_ENTRYFIELD: tooltip background color.
|
---|
1406 | * -- PP_MENUFOREGROUNDCOLOR / SYSCLR_WINDOWTEXT: tooltip text color.
|
---|
1407 | * -- PP_MENUHILITEFGNDCOLOR / SYSCLR_WINDOWTEXT: 3D border light color.
|
---|
1408 | * -- PP_MENUHILITEBGNDCOLOR / SYSCLR_WINDOWTEXT: 3D border dark color.
|
---|
1409 | * -- PP_FONTNAMESIZE: font to use for the tooltip. The default is "8.Helv"
|
---|
1410 | * on Warp 3 and "9.WarpSans" on Warp 4.
|
---|
1411 | *
|
---|
1412 | * So per default, if no presentation parameters are set, the control
|
---|
1413 | * paints the background like an entry field and the text and the border
|
---|
1414 | * in the same window text color (usually black).
|
---|
1415 | * The tooltip does _not_ inherit presentation parameters from the parent,
|
---|
1416 | * so unless you explicitly set presparams, the tooltip looks pretty much
|
---|
1417 | * like the Win32 counterpart (with the default system colors, black border
|
---|
1418 | * and text on yellow background).
|
---|
1419 | *
|
---|
1420 | *@@added V0.9.0 [umoeller]
|
---|
1421 | *@@changed V0.9.12 (2001-04-28) [umoeller]: various fixes WRT subclassing
|
---|
1422 | */
|
---|
1423 |
|
---|
1424 | MRESULT EXPENTRY ctl_fnwpTooltip(HWND hwndTooltip, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1425 | {
|
---|
1426 | MRESULT mrc = 0;
|
---|
1427 |
|
---|
1428 | TRY_LOUD(excpt1)
|
---|
1429 | {
|
---|
1430 | switch (msg)
|
---|
1431 | {
|
---|
1432 | /*
|
---|
1433 | * WM_CREATE:
|
---|
1434 | * this message is sent to the window procedure of
|
---|
1435 | * the window being created, thus offering it an
|
---|
1436 | * opportunity to initialize that window.
|
---|
1437 | *
|
---|
1438 | * The window procedure receives this after the window
|
---|
1439 | * is created but before the window becomes visible.
|
---|
1440 | */
|
---|
1441 |
|
---|
1442 | case WM_CREATE:
|
---|
1443 | mrc = TtmCreate(hwndTooltip, mp2);
|
---|
1444 | break;
|
---|
1445 |
|
---|
1446 | /*
|
---|
1447 | * WM_HITTEST:
|
---|
1448 | * since we have the CS_HITTEST class style set,
|
---|
1449 | * we get this message. We return HT_TRANSPARENT
|
---|
1450 | * always so the tooltip does not block mouse clicks
|
---|
1451 | * for the windows which lie below.
|
---|
1452 | */
|
---|
1453 |
|
---|
1454 | case WM_HITTEST: // done
|
---|
1455 | mrc = (MPARAM)HT_TRANSPARENT;
|
---|
1456 | break;
|
---|
1457 |
|
---|
1458 | /*
|
---|
1459 | * WM_TIMER:
|
---|
1460 | * posted when either the "initial" timer
|
---|
1461 | * or the "autopop" timer times out.
|
---|
1462 | * We'll show or hide the tooltip then.
|
---|
1463 | */
|
---|
1464 |
|
---|
1465 | case WM_TIMER: // done
|
---|
1466 | if (!TtmTimer(hwndTooltip, mp1))
|
---|
1467 | mrc = WinDefWindowProc(hwndTooltip, msg, mp1, mp2);
|
---|
1468 | break;
|
---|
1469 |
|
---|
1470 | /*
|
---|
1471 | * WM_PAINT:
|
---|
1472 | *
|
---|
1473 | */
|
---|
1474 |
|
---|
1475 | case WM_PAINT: // done
|
---|
1476 | TtmPaint(hwndTooltip);
|
---|
1477 | break;
|
---|
1478 |
|
---|
1479 | /*
|
---|
1480 | * WM_PRESPARAMCHANGED:
|
---|
1481 | * presentation parameter has changed.
|
---|
1482 | */
|
---|
1483 |
|
---|
1484 | case WM_PRESPARAMCHANGED:
|
---|
1485 |
|
---|
1486 | switch ((LONG)mp1) // pp index
|
---|
1487 | {
|
---|
1488 | case 0: // layout palette thing dropped
|
---|
1489 | case PP_MENUBACKGROUNDCOLOR:
|
---|
1490 | case PP_MENUFOREGROUNDCOLOR:
|
---|
1491 | case PP_MENUHILITEFGNDCOLOR:
|
---|
1492 | case PP_MENUHILITEBGNDCOLOR:
|
---|
1493 | // re-query our presparams
|
---|
1494 | UpdateTooltipPresColors(hwndTooltip);
|
---|
1495 | }
|
---|
1496 |
|
---|
1497 | break;
|
---|
1498 |
|
---|
1499 | /*
|
---|
1500 | * WM_SYSCOLORCHANGE:
|
---|
1501 | * system color has changed.
|
---|
1502 | */
|
---|
1503 |
|
---|
1504 | case WM_SYSCOLORCHANGE:
|
---|
1505 | UpdateTooltipPresColors(hwndTooltip);
|
---|
1506 | break;
|
---|
1507 |
|
---|
1508 | /*
|
---|
1509 | * WM_DESTROY:
|
---|
1510 | * clean up upon destruction.
|
---|
1511 | */
|
---|
1512 |
|
---|
1513 | case WM_DESTROY:
|
---|
1514 | TtmDestroy(hwndTooltip);
|
---|
1515 | break;
|
---|
1516 |
|
---|
1517 | /*
|
---|
1518 | *@@ TTM_ACTIVATE:
|
---|
1519 | * activates or deactives the tooltip control.
|
---|
1520 | *
|
---|
1521 | * Parameters:
|
---|
1522 | * -- BOOL mp1: if TRUE, activate, if FALSE, deactivate.
|
---|
1523 | * -- mp2: always 0.
|
---|
1524 | *
|
---|
1525 | * Return value: 0 always.
|
---|
1526 | */
|
---|
1527 |
|
---|
1528 | case TTM_ACTIVATE: // done
|
---|
1529 | {
|
---|
1530 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
1531 | if (!(pttd->fIsActive = (BOOL)mp1))
|
---|
1532 | // disable: hide tooltip
|
---|
1533 | WinPostMsg(hwndTooltip, TTM_SHOWTOOLTIPNOW, (MPARAM)FALSE, 0);
|
---|
1534 | }
|
---|
1535 | break;
|
---|
1536 |
|
---|
1537 | /*
|
---|
1538 | *@@ TTM_ADDTOOL:
|
---|
1539 | * registers a tool with a tooltip control.
|
---|
1540 | *
|
---|
1541 | * Parameters:
|
---|
1542 | * -- mp1: always 0.
|
---|
1543 | * -- PTOOLINFO mp2: information about the tool.
|
---|
1544 | *
|
---|
1545 | * Return value: TRUE if successful or FALSE otherwise.
|
---|
1546 | *
|
---|
1547 | * A tooltip control can support any number of tools. To
|
---|
1548 | * support a particular tool, you must register the tool
|
---|
1549 | * with the tooltip control by sending the TTM_ADDTOOL
|
---|
1550 | * message to the tooltip control. The message includes
|
---|
1551 | * the address of a TOOLINFO structure, which provides
|
---|
1552 | * information the tooltip control needs to display text
|
---|
1553 | * for the tool.
|
---|
1554 | *
|
---|
1555 | * A tooltip control supports tools implemented as windows
|
---|
1556 | * (such as child windows or control windows) and as
|
---|
1557 | * rectangular areas within a window's client area.
|
---|
1558 | *
|
---|
1559 | * -- When you add a tool implemented as a rectangular
|
---|
1560 | * area, the "hwndToolOwner" member of TOOLINFO must
|
---|
1561 | * specify the handle of the window that contains the
|
---|
1562 | * area, and the "rect" member must specify the client
|
---|
1563 | * coordinates of the area's bounding rectangle.
|
---|
1564 | *
|
---|
1565 | * -- When you add a tool implemented as a window, the
|
---|
1566 | * "hwndTool" member of TOOLINFO must contain the
|
---|
1567 | * window handle of the tool. hwndToolOwner should be
|
---|
1568 | * the owner of the tool.
|
---|
1569 | *
|
---|
1570 | * When you add a tool to a tooltip control, the "pszText"
|
---|
1571 | * member of the TOOLINFO structure must specify the string
|
---|
1572 | * to display for the tool. You can change the text any time
|
---|
1573 | * after adding the tool by using the TTM_UPDATETIPTEXT message.
|
---|
1574 | *
|
---|
1575 | * If you specify the PSZ_TEXTCALLBACK value in the pszText
|
---|
1576 | * member, whenever the tooltip control needs the text for the
|
---|
1577 | * tool, it sends a WM_CONTROL message to hwndToolOwner with
|
---|
1578 | * the TTN_NEEDTEXT notification code.
|
---|
1579 | *
|
---|
1580 | * The message includes the address of a TOOLTIPTEXT structure,
|
---|
1581 | * which contains the window handle of the tool. You can then
|
---|
1582 | * fill the TOOLTIPTEXT structure with the tool text.
|
---|
1583 | *
|
---|
1584 | * To retrieve the text for a tool, use the TTM_GETTEXT message.
|
---|
1585 | *
|
---|
1586 | *@@todo: add tool rectangles
|
---|
1587 | */
|
---|
1588 |
|
---|
1589 | case TTM_ADDTOOL: // done
|
---|
1590 | mrc = TtmAddTool(hwndTooltip, mp2);
|
---|
1591 | break;
|
---|
1592 |
|
---|
1593 | /*
|
---|
1594 | *@@ TTM_DELTOOL:
|
---|
1595 | * removes a tool from a tooltip control.
|
---|
1596 | *
|
---|
1597 | * Parameters:
|
---|
1598 | * -- mp1: always 0.
|
---|
1599 | * -- PTOOLINFO mp2: information about the tool;
|
---|
1600 | * all fields except cbSize, hwndToolOwner,
|
---|
1601 | * and hwndTool are ignored.
|
---|
1602 | *
|
---|
1603 | * Return value: 0 always.
|
---|
1604 | */
|
---|
1605 |
|
---|
1606 | case TTM_DELTOOL: // done
|
---|
1607 | TtmDelTool(hwndTooltip, mp2);
|
---|
1608 | break;
|
---|
1609 |
|
---|
1610 | /*
|
---|
1611 | *@@ TTM_NEWTOOLRECT:
|
---|
1612 | * sets a new bounding rectangle for a tool
|
---|
1613 | * already registered with a tooltip control.
|
---|
1614 | *
|
---|
1615 | * Parameters:
|
---|
1616 | * -- mp1: always 0.
|
---|
1617 | * -- PTOOLINFO mp2: information about the tool;
|
---|
1618 | * all fields except hwnd, uID, and rect
|
---|
1619 | * are ignored.
|
---|
1620 | *
|
---|
1621 | * Return value: 0 always.
|
---|
1622 | *
|
---|
1623 | * If an application includes a tool implemented as a rectangular
|
---|
1624 | * area and the size or position of the control changes, it can
|
---|
1625 | * use the TTM_NEWTOOLRECT message to report the change to the
|
---|
1626 | * tooltip control. An application does not need to report size
|
---|
1627 | * and position changes for a tool implemented as a window.
|
---|
1628 | * Reporting that is not necessary because the tooltip control
|
---|
1629 | * uses the window handle of a tool to determine if the cursor
|
---|
1630 | * is on the tool, not the tool's bounding rectangle.
|
---|
1631 | */
|
---|
1632 |
|
---|
1633 | case TTM_NEWTOOLRECT:
|
---|
1634 |
|
---|
1635 | break;
|
---|
1636 |
|
---|
1637 | /*
|
---|
1638 | *@@ TTM_RELAYEVENT:
|
---|
1639 | * passes a mouse message to a tooltip control
|
---|
1640 | * for further processing.
|
---|
1641 | *
|
---|
1642 | * Parameters:
|
---|
1643 | * -- mp1: always 0.
|
---|
1644 | * -- PQMSG mp2: pointer to a QMSG struct (Win95: MSG struct)
|
---|
1645 | * containing a mouse message. Only the above messages
|
---|
1646 | * are processed.
|
---|
1647 | *
|
---|
1648 | * Return value: 0 always.
|
---|
1649 | *
|
---|
1650 | * A tooltip control needs to receive mouse messages to determine
|
---|
1651 | * when to display the tooltip window. Because mouse messages are
|
---|
1652 | * sent only to the window that contains the cursor, you must
|
---|
1653 | * use the TTM_RELAYEVENT message to relay mouse messages to the
|
---|
1654 | * tooltip control.
|
---|
1655 | *
|
---|
1656 | * If a tool is implemented as a rectangular area in an
|
---|
1657 | * application-defined window, the window procedure receives all
|
---|
1658 | * mouse messages and can relay the ones listed below to the
|
---|
1659 | * tooltip control, using this message.
|
---|
1660 | *
|
---|
1661 | * However, if a tool is implemented as a system-defined window,
|
---|
1662 | * the mouse messages are sent to that window and are not readily
|
---|
1663 | * available to the application. There are two ways you can have
|
---|
1664 | * the tooltip control notified of these mouse messages:
|
---|
1665 | *
|
---|
1666 | * -- You can specify the TTF_SUBCLASS flag when adding the tool
|
---|
1667 | * to the tooltip control. The tooltip control will then subclass
|
---|
1668 | * the tool window to get mouse-related messages, and you're off.
|
---|
1669 | *
|
---|
1670 | * -- You can implement a message hook for your process and check
|
---|
1671 | * for your tool windows there and send TTM_RELAYEVENT to the
|
---|
1672 | * tooltip control. In that case, you need to intercept the
|
---|
1673 | * messages specified below.
|
---|
1674 | *
|
---|
1675 | * When a tooltip control receives a relayed WM_MOUSEMOVE message,
|
---|
1676 | * it determines whether the cursor is in the bounding rectangle of
|
---|
1677 | * a tool. If the cursor is there, the tooltip control sets a timer.
|
---|
1678 | * At the end of the time-out duration, the tooltip control checks
|
---|
1679 | * the position of the cursor to see whether it has moved. If the
|
---|
1680 | * cursor has not, the tooltip control retrieves the text for the tool,
|
---|
1681 | * copies the text into the tooltip window, and shows the window.
|
---|
1682 | * The tooltip control continues to show the window until it receives
|
---|
1683 | * a relayed button-up or button-down message or until a relayed
|
---|
1684 | * WM_MOUSEMOVE message indicates that the cursor has moved outside
|
---|
1685 | * the bounding rectangle of the tool.
|
---|
1686 | *
|
---|
1687 | * For the timer descriptions, see TTM_SETDELAYTIME.
|
---|
1688 | *
|
---|
1689 | * When it is about to be displayed, a tootip control sends the
|
---|
1690 | * TTN_SHOW notification to the owner window. A tooltip control
|
---|
1691 | * sends the TTN_POP notification when it is about to be hidden.
|
---|
1692 | * Each notification is sent in the context of a WM_NOTIFY message
|
---|
1693 | * (OS/2: WM_CONTROL).
|
---|
1694 | *
|
---|
1695 | * Relevant messages:
|
---|
1696 | * -- WM_MOUSEMOVE
|
---|
1697 | * -- WM_BUTTON1DOWN (Win95: WM_LBUTTONDOWN)
|
---|
1698 | * -- WM_BUTTON1UP (Win95: WM_LBUTTONUP)
|
---|
1699 | * -- WM_BUTTON2DOWN (Win95: WM_RBUTTONDOWN)
|
---|
1700 | * -- WM_BUTTON2UP (Win95: WM_RBUTTONUP)
|
---|
1701 | * -- WM_BUTTON3DOWN (Win95: WM_MBUTTONDOWN)
|
---|
1702 | * -- WM_BUTTON3UP (Win95: WM_MBUTTONUP)
|
---|
1703 | */
|
---|
1704 |
|
---|
1705 | case TTM_RELAYEVENT:
|
---|
1706 | TtmRelayEvent(hwndTooltip, mp2);
|
---|
1707 | break;
|
---|
1708 |
|
---|
1709 | /*
|
---|
1710 | *@@ TTM_GETDELAYTIME:
|
---|
1711 | * returns the current value of the specified
|
---|
1712 | * timeout value. See TTM_SETDELAYTIME.
|
---|
1713 | *
|
---|
1714 | * Parameters:
|
---|
1715 | *
|
---|
1716 | * -- USHORT mp1: timer value to query. One of:
|
---|
1717 | * -- TTDT_AUTOPOP
|
---|
1718 | * -- TTDT_INITIAL
|
---|
1719 | * -- TTDT_RESHOW
|
---|
1720 | *
|
---|
1721 | * Returns: ULONG timeout value.
|
---|
1722 | *
|
---|
1723 | *@@added V0.9.12 (2001-04-28) [umoeller]
|
---|
1724 | */
|
---|
1725 |
|
---|
1726 | case TTM_GETDELAYTIME:
|
---|
1727 | mrc = TtmGetDelayTime(hwndTooltip, mp1);
|
---|
1728 | break;
|
---|
1729 |
|
---|
1730 | /*
|
---|
1731 | *@@ TTM_SETDELAYTIME:
|
---|
1732 | * overrides a few default timeout values for the
|
---|
1733 | * tooltip control.
|
---|
1734 | *
|
---|
1735 | * A tooltip control actually has three time-out durations
|
---|
1736 | * associated with it. The initial duration is the length
|
---|
1737 | * of time that the cursor must remain stationary within
|
---|
1738 | * the bounding rectangle of a tool before the tooltip window
|
---|
1739 | * is displayed. The reshow duration is the length of the delay
|
---|
1740 | * before subsequent tooltip windows are displayed when the
|
---|
1741 | * cursor moves from one tool to another. The autopopup duration
|
---|
1742 | * is the length of time that the tooltip window remains
|
---|
1743 | * displayed before it is hidden. That is, if the cursor remains
|
---|
1744 | * stationary within the bounding rectangle after the tooltip
|
---|
1745 | * window is displayed, the tooltip window is automatically
|
---|
1746 | * hidden at the end of the autopopup duration.
|
---|
1747 | *
|
---|
1748 | * You can adjust all of the time-out durations by using this
|
---|
1749 | * message.
|
---|
1750 | *
|
---|
1751 | * Parameters:
|
---|
1752 | * -- USHORT mp1: parameter selection. One of the following:
|
---|
1753 | * -- TTDT_AUTOMATIC: automatically calculates the initial,
|
---|
1754 | * reshow, and autopopup durations based on the value of mp2.
|
---|
1755 | * -- TTDT_AUTOPOP: sets the length of time before the tooltip
|
---|
1756 | * window is hidden if the cursor remains stationary
|
---|
1757 | * in the tool's bounding rectangle after the tooltip window
|
---|
1758 | * has appeared.
|
---|
1759 | * -- TTDT_INITIAL: sets the length of time that the cursor must
|
---|
1760 | * remain stationary within the bounding rectangle of
|
---|
1761 | * a tool before the tooltip window is displayed.
|
---|
1762 | * -- TTDT_RESHOW: sets the length of the delay before subsequent
|
---|
1763 | * tooltip windows are displayed when the cursor is moved
|
---|
1764 | * from one tool to another.
|
---|
1765 | * -- ULONG mp2: new duration, in milliseconds.
|
---|
1766 | *
|
---|
1767 | * Return value: 0 always.
|
---|
1768 | */
|
---|
1769 |
|
---|
1770 | case TTM_SETDELAYTIME: // done
|
---|
1771 | TtmSetDelayTime(hwndTooltip, mp1, mp2);
|
---|
1772 | break;
|
---|
1773 |
|
---|
1774 | /*
|
---|
1775 | *@@ TTM_GETTEXT:
|
---|
1776 | * retrieves the text for a tool in the tooltip control.
|
---|
1777 | *
|
---|
1778 | * Parameters:
|
---|
1779 | * -- mp1: always 0
|
---|
1780 | * -- PTOOLINFO mp2: pointer to a TOOLINFO structure.
|
---|
1781 | * hwndTool identifies a tool. If the tooltip control
|
---|
1782 | * includes the tool, the pszText member receives
|
---|
1783 | * the pointer to the string on output.
|
---|
1784 | *
|
---|
1785 | * Return value: 0 always.
|
---|
1786 | *
|
---|
1787 | * Additional note: On input, if TOOLINFO.lpszText == PSZ_TEXTCALLBACK,
|
---|
1788 | * this sends the TTN_NEEDTEXT notification to TOOLINFO.hwnd.
|
---|
1789 | *
|
---|
1790 | */
|
---|
1791 |
|
---|
1792 | case TTM_GETTEXT: // done, I think
|
---|
1793 | TtmGetText(hwndTooltip, mp2);
|
---|
1794 | break;
|
---|
1795 |
|
---|
1796 | /*
|
---|
1797 | *@@ TTM_UPDATETIPTEXT:
|
---|
1798 | * sets the current tooltip text explicitly,
|
---|
1799 | * no matter for what tool the tooltip is
|
---|
1800 | * currently being displayed. This might be
|
---|
1801 | * useful if you want to dynamically update
|
---|
1802 | * the tooltip display.
|
---|
1803 | *
|
---|
1804 | * If the tooltip is currently showing,
|
---|
1805 | * it is reformatted with the new text.
|
---|
1806 | *
|
---|
1807 | * Note that the change is not permanent;
|
---|
1808 | * if the mouse moves over a different
|
---|
1809 | * tool next, the change will be lost.
|
---|
1810 | *
|
---|
1811 | * Parameters:
|
---|
1812 | * -- PSZ mp1: new text to display.
|
---|
1813 | *
|
---|
1814 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
1815 | */
|
---|
1816 |
|
---|
1817 | case TTM_UPDATETIPTEXT:
|
---|
1818 | TtmUpdateTipText(hwndTooltip, (PSZ)mp1);
|
---|
1819 | break;
|
---|
1820 |
|
---|
1821 | /*
|
---|
1822 | *@@ TTM_HITTEST:
|
---|
1823 | * tests a point to determine whether it is within the
|
---|
1824 | * bounding rectangle of the specified tool and, if the
|
---|
1825 | * point is within, retrieves information about the tool.
|
---|
1826 | *
|
---|
1827 | * Parameters:
|
---|
1828 | * -- mp1: always 0.
|
---|
1829 | * -- PHITTESTINFO mp2: pointer to a TTHITTESTINFO structure.
|
---|
1830 | * When sending the message, the "hwnd" member must specify
|
---|
1831 | * the handle of a tool and the "pt" member must specify the
|
---|
1832 | * coordinates of a point. If the return value is TRUE, the
|
---|
1833 | * "ti" member receives information about the tool that
|
---|
1834 | * occupies the point.
|
---|
1835 | *
|
---|
1836 | * Return value: returns TRUE if the tool occupies the specified
|
---|
1837 | * point or FALSE otherwise.
|
---|
1838 | */
|
---|
1839 |
|
---|
1840 | case TTM_HITTEST:
|
---|
1841 | break;
|
---|
1842 |
|
---|
1843 | /*
|
---|
1844 | *@@ TTM_WINDOWFROMPOINT:
|
---|
1845 | * this message allows a subclass procedure to cause a tooltip
|
---|
1846 | * to display text for a window other than the one beneath the
|
---|
1847 | * mouse cursor.
|
---|
1848 | *
|
---|
1849 | * Parameters:
|
---|
1850 | * -- mp1: always 0.
|
---|
1851 | * -- mp2: PPOINTL lppt (Win95: (POINT FAR *)lppt):
|
---|
1852 | * pointer to a POINTL structure that defines the point to be checked.
|
---|
1853 | *
|
---|
1854 | * Return value: the handle to the window that contains the point, or
|
---|
1855 | * NULL if no window exists at the specified point.
|
---|
1856 | *
|
---|
1857 | * This message is intended to be processed by an application that
|
---|
1858 | * subclasses a tooltip. It is not intended to be sent by an
|
---|
1859 | * application. A tooltip sends this message to itself before
|
---|
1860 | * displaying the text for a window. By changing the coordinates
|
---|
1861 | * of the point specified by lppt, the subclass procedure can cause
|
---|
1862 | * the tooltip to display text for a window other than the one
|
---|
1863 | * beneath the mouse cursor.
|
---|
1864 | */
|
---|
1865 |
|
---|
1866 | case TTM_WINDOWFROMPOINT:
|
---|
1867 | break;
|
---|
1868 |
|
---|
1869 | /*
|
---|
1870 | *@@ TTM_ENUMTOOLS:
|
---|
1871 | * this message retrieves the information that a tooltip control
|
---|
1872 | * maintains about a certain tool.
|
---|
1873 | *
|
---|
1874 | * Parameters:
|
---|
1875 | * -- USHORT mp1: zero-based index of the tool for which to
|
---|
1876 | * retrieve information.
|
---|
1877 | * -- PTOOLINFO mp2: pointer to a TOOLINFO structure that
|
---|
1878 | * receives information about the tool. Before sending
|
---|
1879 | * this message, the cbSize member must specify the size
|
---|
1880 | * of the structure.
|
---|
1881 | *
|
---|
1882 | * Return value: TRUE if any tools are enumerated or FALSE otherwise.
|
---|
1883 | */
|
---|
1884 |
|
---|
1885 | case TTM_ENUMTOOLS: // done
|
---|
1886 | mrc = TtmEnumTools(hwndTooltip, mp1, mp2);
|
---|
1887 | break;
|
---|
1888 |
|
---|
1889 | /*
|
---|
1890 | *@@ TTM_GETCURRENTTOOL:
|
---|
1891 | * this message retrieves the information that the
|
---|
1892 | * tooltip control maintains for the _current_ tool;
|
---|
1893 | * that is, the one for which the tooltip control
|
---|
1894 | * is currently displaying text.
|
---|
1895 | *
|
---|
1896 | * Parameters:
|
---|
1897 | * -- mp1: always 0.
|
---|
1898 | * -- PTOOLINFO mp2: pointer to a TOOLINFO structure that receives
|
---|
1899 | * information about the current tool.
|
---|
1900 | *
|
---|
1901 | * Return value: TRUE if successful or FALSE otherwise.
|
---|
1902 | */
|
---|
1903 |
|
---|
1904 | case TTM_GETCURRENTTOOL: // done
|
---|
1905 | mrc = TtmGetCurrentTool(hwndTooltip, mp2);
|
---|
1906 | break;
|
---|
1907 |
|
---|
1908 | /*
|
---|
1909 | *@@ TTM_GETTOOLCOUNT:
|
---|
1910 | * returns the number of tools in the tooltip control.
|
---|
1911 | *
|
---|
1912 | * No parameters.
|
---|
1913 | */
|
---|
1914 |
|
---|
1915 | case TTM_GETTOOLCOUNT: // done
|
---|
1916 | {
|
---|
1917 | PTOOLTIPDATA pttd = (PTOOLTIPDATA)WinQueryWindowPtr(hwndTooltip, 1);
|
---|
1918 | mrc = (MPARAM)lstCountItems(&pttd->llTools);
|
---|
1919 | }
|
---|
1920 | break;
|
---|
1921 |
|
---|
1922 | /*
|
---|
1923 | *@@ TTM_GETTOOLINFO:
|
---|
1924 | * this message retrieves the information that a tooltip
|
---|
1925 | * control maintains about a tool.
|
---|
1926 | *
|
---|
1927 | * Parameters:
|
---|
1928 | * -- mp1: always 0.
|
---|
1929 | * -- PTOOLINFO mp2:
|
---|
1930 | * pointer to a TOOLINFO structure. When sending the message,
|
---|
1931 | * the hwnd and uId members identify a tool, and the cbSize
|
---|
1932 | * member must specify the size of the structure. If the
|
---|
1933 | * tooltip control includes the tool, the structure receives
|
---|
1934 | * information about the tool.
|
---|
1935 | *
|
---|
1936 | * Return value: TRUE if successful or FALSE otherwise.
|
---|
1937 | */
|
---|
1938 |
|
---|
1939 | case TTM_GETTOOLINFO: // done
|
---|
1940 | mrc = TtmGetToolInfo(hwndTooltip, mp2);
|
---|
1941 | break;
|
---|
1942 |
|
---|
1943 | /*
|
---|
1944 | *@@ TTM_SETTOOLINFO:
|
---|
1945 | * this message sets the information that a tooltip control
|
---|
1946 | * maintains for a tool.
|
---|
1947 | *
|
---|
1948 | * Parameters:
|
---|
1949 | * -- mp1: always 0.
|
---|
1950 | * -- PTOOLINFO mp2: pointer to a TOOLINFO structure that
|
---|
1951 | * specifies the information to set.
|
---|
1952 | *
|
---|
1953 | * Return value: 0 always.
|
---|
1954 | */
|
---|
1955 |
|
---|
1956 | case TTM_SETTOOLINFO:
|
---|
1957 | break;
|
---|
1958 |
|
---|
1959 | /*
|
---|
1960 | *@@ TTM_SHOWTOOLTIPNOW:
|
---|
1961 | * depending on BOOL mp1, shows or hides the tooltip.
|
---|
1962 | * This is required because we cannot show or hide
|
---|
1963 | * the window during processing of WM_MOUSEMOVE etc,
|
---|
1964 | * which will lead to strange PM hangs.
|
---|
1965 | *
|
---|
1966 | * This is not part of the Win95 message set but used
|
---|
1967 | * in the OS/2 implementation only. This calls
|
---|
1968 | * TtmShowTooltip in turn.
|
---|
1969 | */
|
---|
1970 |
|
---|
1971 | case TTM_SHOWTOOLTIPNOW:
|
---|
1972 | TtmShowTooltip(hwndTooltip, (BOOL)mp1);
|
---|
1973 | break;
|
---|
1974 |
|
---|
1975 | default:
|
---|
1976 | mrc = WinDefWindowProc(hwndTooltip, msg, mp1, mp2);
|
---|
1977 | }
|
---|
1978 | }
|
---|
1979 | CATCH(excpt1)
|
---|
1980 | {
|
---|
1981 | mrc = 0; // XWP V1.0.4 (2005-10-09) [pr]
|
---|
1982 | }
|
---|
1983 | END_CATCH();
|
---|
1984 |
|
---|
1985 | return mrc;
|
---|
1986 | }
|
---|
1987 |
|
---|