1998-08-26 09:59:32 +04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Name: <Xfe/ToolTip.c> */
|
1998-09-24 13:22:27 +04:00
|
|
|
/* Description: XfeToolTip - TipString / DocString support. */
|
1998-08-26 09:59:32 +04:00
|
|
|
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include <Xfe/ToolTipP.h>
|
|
|
|
#include <Xfe/ToolTipShell.h>
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
#include <Xfe/ClientData.h>
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
#include <Xm/LabelGP.h>
|
|
|
|
#include <Xm/PushBGP.h>
|
|
|
|
|
|
|
|
#define TOOL_TIP_SHELL_NAME "ToolTipShell"
|
|
|
|
#define TOOL_TIP_INTERVAL 1000
|
|
|
|
|
|
|
|
#define TOOL_TIP_EVENT_MASK \
|
|
|
|
( EnterWindowMask | \
|
|
|
|
LeaveWindowMask | \
|
|
|
|
ButtonPressMask | \
|
|
|
|
ButtonReleaseMask | \
|
|
|
|
KeyPressMask | \
|
|
|
|
KeyReleaseMask )
|
|
|
|
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
#if 0
|
|
|
|
#define DEBUG_TOOL_TIPS yes
|
|
|
|
#endif
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* _XfeTipItemInfoRec */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
typedef struct
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Item */
|
|
|
|
Widget item;
|
|
|
|
|
|
|
|
/* Does the item have tip string support ? */
|
|
|
|
Boolean tip_string_installed;
|
|
|
|
|
|
|
|
/* Does the item have doc string support ? */
|
|
|
|
Boolean doc_string_installed;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
/* TipString */
|
1998-09-24 18:25:56 +04:00
|
|
|
Boolean tip_string_enabled;
|
|
|
|
XfeTipStringObtainCallback tip_string_obtain_callback;
|
|
|
|
XtPointer tip_string_obtain_data1;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
/* DocString */
|
1998-09-24 18:25:56 +04:00
|
|
|
Boolean doc_string_enabled;
|
|
|
|
XfeTipStringObtainCallback doc_string_obtain_callback;
|
|
|
|
XtPointer doc_string_obtain_data1;
|
|
|
|
|
|
|
|
/* DocString callback */
|
|
|
|
XfeDocStringCallback doc_string_callback;
|
|
|
|
XtPointer doc_string_data1;
|
1998-09-28 12:11:25 +04:00
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
} _XfeTipItemInfoRec,*_XfeTipItemInfo;
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Gadget phony input functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void GadgetHackInputDispatch (Widget);
|
|
|
|
static void GadgetPhonyInputDispatch (Widget,XEvent *,Mask);
|
|
|
|
static void GadgetSaveRealInputDispatchMethod (Widget);
|
|
|
|
static XmWidgetDispatchProc GadgetGetRealInputDispatchMethod (Widget);
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Widget functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 18:25:56 +04:00
|
|
|
static void WidgetAddStageOneEH (Widget);
|
|
|
|
static void WidgetRemoveStageOneEH (Widget);
|
1998-09-28 23:39:44 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
static _XfeTipItemInfo WidgetAddTipString (Widget);
|
|
|
|
static _XfeTipItemInfo WidgetAddDocString (Widget);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Gadget functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 18:25:56 +04:00
|
|
|
static _XfeTipItemInfo GadgetAddTipString (Widget);
|
|
|
|
static _XfeTipItemInfo GadgetAddDocString (Widget);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Item (Widget or Gadget) functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-28 12:11:25 +04:00
|
|
|
static void ItemFreeInfo (_XfeTipItemInfo);
|
1998-09-28 23:39:44 +04:00
|
|
|
static void ClientDataFreeFunc (Widget,XtPointer);
|
1998-09-28 12:11:25 +04:00
|
|
|
static _XfeTipItemInfo ItemAllocateInfo (Widget);
|
|
|
|
static void ItemGetTipString (Widget,XmString *,Boolean *);
|
|
|
|
static void ItemGetDocString (Widget,XmString *,Boolean *);
|
|
|
|
static void ItemPostToolTip (Widget);
|
|
|
|
static void ItemUnPostToolTip (Widget);
|
|
|
|
static void ItemUninstallTipString (Widget,_XfeTipItemInfo);
|
|
|
|
static void ItemUninstallDocString (Widget,_XfeTipItemInfo);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
static _XfeTipItemInfo ItemGetInfo (Widget);
|
|
|
|
static void ItemAddInfo (Widget,_XfeTipItemInfo);
|
|
|
|
static void ItemRemoveInfo (Widget,_XfeTipItemInfo);
|
|
|
|
static _XfeTipItemInfo ItemFindOrAddInfo (Widget);
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
1998-09-24 13:22:27 +04:00
|
|
|
/* TipString enter / leave / cancel functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void TipStringEnterItem (Widget,_XfeTipItemInfo);
|
|
|
|
static void TipStringLeaveItem (Widget,_XfeTipItemInfo);
|
|
|
|
static void TipStringCancelItem (Widget,_XfeTipItemInfo);
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* DocString enter / leave / cancel functions */
|
1998-08-26 09:59:32 +04:00
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 13:22:27 +04:00
|
|
|
static void DocStringEnterItem (Widget,_XfeTipItemInfo);
|
|
|
|
static void DocStringLeaveItem (Widget,_XfeTipItemInfo);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Event handlers */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void WidgetStageOneEH (Widget,XtPointer,XEvent *,Boolean *);
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* State Two timeout functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void StageTwoTimeout (XtPointer,XtIntervalId *);
|
|
|
|
static void StageTwoAddTimeout (Widget);
|
|
|
|
static void StageTwoRemoveTimeout (Widget);
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* ClientData key functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static XfeClientDataKey GetClientDataKey (void);
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Gadget phony input functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
GadgetPhonyInputDispatch(Widget w,
|
|
|
|
XEvent * event,
|
|
|
|
Mask event_mask)
|
|
|
|
{
|
|
|
|
XmWidgetDispatchProc input_dispatch = NULL;
|
|
|
|
|
|
|
|
assert( XmIsGadget(w) );
|
|
|
|
|
|
|
|
input_dispatch = GadgetGetRealInputDispatchMethod(w);
|
|
|
|
|
|
|
|
assert( input_dispatch != NULL );
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
/* Do the tip magic only if tip or doc strings are globally enabled */
|
1998-09-24 18:25:56 +04:00
|
|
|
if (XfeTipStringGlobalGetEnabledState() ||
|
|
|
|
XfeDocStringGlobalGetEnabledState())
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
_XfeTipItemInfo info = info = ItemGetInfo(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
if (info != NULL)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
Boolean do_tip_string =
|
|
|
|
XfeTipStringGlobalGetEnabledState() &&
|
|
|
|
info->tip_string_enabled;
|
|
|
|
|
|
|
|
Boolean do_doc_string =
|
|
|
|
XfeDocStringGlobalGetEnabledState() &&
|
|
|
|
info->doc_string_enabled;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Enter */
|
|
|
|
if (event_mask & XmENTER_EVENT)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
if (do_tip_string)
|
|
|
|
{
|
|
|
|
TipStringEnterItem(w,info);
|
|
|
|
}
|
1998-09-24 18:25:56 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
if (do_doc_string)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
DocStringEnterItem(w,info);
|
|
|
|
}
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Leave */
|
|
|
|
else if (event_mask & XmLEAVE_EVENT)
|
|
|
|
{
|
|
|
|
if (do_tip_string)
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringLeaveItem(w,info);
|
1998-09-28 23:39:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (do_doc_string)
|
|
|
|
{
|
|
|
|
DocStringLeaveItem(w,info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* XmARM_EVENT
|
|
|
|
* XmMULTI_ARM_EVENT
|
|
|
|
* XmACTIVATE_EVENT
|
|
|
|
* XmMULTI_ACTIVATE_EVENT
|
|
|
|
* XmHELP_EVENT
|
|
|
|
* XmENTER_EVENT
|
|
|
|
* XmLEAVE_EVENT
|
|
|
|
* XmFOCUS_IN_EVENT
|
|
|
|
* XmFOCUS_OUT_EVENT
|
|
|
|
* XmBDRAG_EVENT
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (do_tip_string)
|
|
|
|
{
|
|
|
|
TipStringCancelItem(w,info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* info != NULL */
|
1998-09-24 18:25:56 +04:00
|
|
|
} /* XfeTipStringGlobalGetEnabledState() == True */
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/* Invoke the original InputDispatch() method */
|
|
|
|
(*input_dispatch)(w,event,event_mask);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
GadgetHackInputDispatch(Widget g)
|
|
|
|
{
|
|
|
|
XmGadgetClass gadget_class = NULL;
|
|
|
|
|
|
|
|
assert( XmIsGadget(g) );
|
|
|
|
|
|
|
|
gadget_class = (XmGadgetClass) XtClass(g);
|
|
|
|
|
|
|
|
/* Override the original input dispatch with the phony one */
|
|
|
|
gadget_class->gadget_class.input_dispatch = GadgetPhonyInputDispatch;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static XmWidgetDispatchProc _xm_real_pbg_input_dispatch = NULL;
|
|
|
|
static XmWidgetDispatchProc _xm_real_lg_input_dispatch = NULL;
|
|
|
|
|
|
|
|
static XmWidgetDispatchProc
|
|
|
|
GadgetGetRealInputDispatchMethod(Widget g)
|
|
|
|
{
|
|
|
|
XmWidgetDispatchProc id = NULL;
|
|
|
|
|
|
|
|
assert( _XfeIsAlive(g) ) ;
|
|
|
|
assert( XmIsGadget(g) ) ;
|
|
|
|
|
|
|
|
if (XmIsPushButtonGadget(g))
|
|
|
|
{
|
|
|
|
assert( _xm_real_pbg_input_dispatch != NULL );
|
|
|
|
|
|
|
|
id = _xm_real_pbg_input_dispatch;
|
|
|
|
}
|
|
|
|
else if (XmIsLabelGadget(g))
|
|
|
|
{
|
|
|
|
assert( _xm_real_lg_input_dispatch != NULL );
|
|
|
|
|
|
|
|
id = _xm_real_lg_input_dispatch;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_ramiro
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert( 0 );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
GadgetSaveRealInputDispatchMethod(Widget w)
|
|
|
|
{
|
|
|
|
assert( _XfeIsAlive(w) ) ;
|
|
|
|
assert( XmIsGadget(w) ) ;
|
|
|
|
|
|
|
|
if (XmIsPushButtonGadget(w))
|
|
|
|
{
|
|
|
|
/* Save the original XmPushButtonGadget input dispatch method */
|
|
|
|
if (_xm_real_pbg_input_dispatch == NULL)
|
|
|
|
{
|
|
|
|
_xm_real_pbg_input_dispatch =
|
|
|
|
xmPushButtonGadgetClassRec.gadget_class.input_dispatch;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (XmIsLabelGadget(w))
|
|
|
|
{
|
|
|
|
/* Save the original XmLabelGadget input dispatch method */
|
|
|
|
if (_xm_real_lg_input_dispatch == NULL)
|
|
|
|
{
|
|
|
|
_xm_real_lg_input_dispatch =
|
|
|
|
xmLabelGadgetClassRec.gadget_class.input_dispatch;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_ramiro
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert( 0 );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Widget functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
WidgetAddStageOneEH(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 15:03:11 +04:00
|
|
|
assert( w != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
assert( XtIsWidget(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Remove the event handler so that we start with a clean item */
|
1998-08-26 09:59:32 +04:00
|
|
|
XtRemoveEventHandler(w,
|
|
|
|
TOOL_TIP_EVENT_MASK,
|
|
|
|
FALSE,
|
|
|
|
WidgetStageOneEH,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* Insert the tool tip event handler */
|
|
|
|
XtInsertEventHandler(w,
|
|
|
|
TOOL_TIP_EVENT_MASK,
|
|
|
|
FALSE,
|
|
|
|
WidgetStageOneEH,
|
|
|
|
NULL,
|
|
|
|
XtListHead);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
WidgetRemoveStageOneEH(Widget w)
|
|
|
|
{
|
1998-09-28 15:03:11 +04:00
|
|
|
assert( w != NULL );
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( XtIsWidget(w) );
|
|
|
|
|
|
|
|
/* Remove the event handler so that we start with a clean item */
|
|
|
|
XtRemoveEventHandler(w,
|
|
|
|
TOOL_TIP_EVENT_MASK,
|
|
|
|
FALSE,
|
|
|
|
WidgetStageOneEH,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static _XfeTipItemInfo
|
|
|
|
WidgetAddTipString(Widget w)
|
|
|
|
{
|
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
1998-09-28 15:03:11 +04:00
|
|
|
assert( w != NULL );
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
assert( XtIsWidget(w) );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Find or add the info */
|
|
|
|
info = ItemFindOrAddInfo(w);
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
assert( info->tip_string_installed == False );
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
/* Mark the tip string info as installed */
|
|
|
|
info->tip_string_installed = True;
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
/* If the doc string info was already installed, we are done */
|
|
|
|
if (info->doc_string_installed)
|
|
|
|
{
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Add the stage one event handler */
|
|
|
|
WidgetAddStageOneEH(w);
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-28 12:11:25 +04:00
|
|
|
ItemUninstallTipString(Widget w,_XfeTipItemInfo info)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Mark the tip string info as not installed */
|
|
|
|
info->tip_string_installed = False;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Reset all the tip string members */
|
|
|
|
info->tip_string_enabled = False;
|
|
|
|
info->tip_string_obtain_callback = NULL;
|
|
|
|
info->tip_string_obtain_data1 = NULL;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static _XfeTipItemInfo
|
|
|
|
WidgetAddDocString(Widget w)
|
|
|
|
{
|
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
1998-09-28 15:03:11 +04:00
|
|
|
assert( w != NULL );
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
assert( XtIsWidget(w) );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Find or add the info */
|
|
|
|
info = ItemFindOrAddInfo(w);
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
assert( info->doc_string_installed == False );
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
/* Mark the doc string info as installed */
|
|
|
|
info->doc_string_installed = True;
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
/* If the tip string info was already installed, we are done */
|
|
|
|
if (info->tip_string_installed)
|
|
|
|
{
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Add the stage one event handler */
|
|
|
|
WidgetAddStageOneEH(w);
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-28 12:11:25 +04:00
|
|
|
ItemUninstallDocString(Widget w,_XfeTipItemInfo info)
|
1998-09-24 18:25:56 +04:00
|
|
|
{
|
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
/* Mark the doc string info as not installed */
|
|
|
|
info->doc_string_installed = False;
|
|
|
|
|
|
|
|
/* Reset all the doc string members */
|
|
|
|
info->doc_string_enabled = False;
|
|
|
|
info->doc_string_obtain_callback = NULL;
|
|
|
|
info->doc_string_obtain_data1 = NULL;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Gadget functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 18:25:56 +04:00
|
|
|
static _XfeTipItemInfo
|
|
|
|
GadgetAddTipString(Widget w)
|
|
|
|
{
|
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
assert( XmIsGadget(w) );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Find or add the info */
|
|
|
|
info = ItemFindOrAddInfo(w);
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
assert( info->tip_string_installed == False );
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
/* Mark the tip string info as installed */
|
|
|
|
info->tip_string_installed = True;
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
/* If the doc string was already installed, we are done */
|
1998-09-24 18:25:56 +04:00
|
|
|
if (info->doc_string_installed)
|
|
|
|
{
|
1998-09-28 12:11:25 +04:00
|
|
|
return info;
|
1998-09-24 18:25:56 +04:00
|
|
|
}
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
GadgetSaveRealInputDispatchMethod(w);
|
|
|
|
|
|
|
|
GadgetHackInputDispatch(w);
|
1998-09-24 18:25:56 +04:00
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
return info;
|
1998-09-24 18:25:56 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static _XfeTipItemInfo
|
|
|
|
GadgetAddDocString(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info = NULL;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
assert( XmIsGadget(w) );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Find or add the info */
|
|
|
|
info = ItemFindOrAddInfo(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
assert( info->doc_string_installed == False );
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Mark the doc string info as installed */
|
|
|
|
info->doc_string_installed = True;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
/* If the tip string was already installed, we are done */
|
|
|
|
if (info->tip_string_installed)
|
|
|
|
{
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
GadgetSaveRealInputDispatchMethod(w);
|
|
|
|
|
|
|
|
GadgetHackInputDispatch(w);
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
return info;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Item (Widget or Gadget) functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-08-26 09:59:32 +04:00
|
|
|
static _XfeTipItemInfo
|
1998-09-24 13:22:27 +04:00
|
|
|
ItemAllocateInfo(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info = NULL;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 15:03:11 +04:00
|
|
|
assert( w != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = (_XfeTipItemInfo) XtMalloc(sizeof(_XfeTipItemInfoRec) * 1);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
/* Initialize the members */
|
1998-09-24 18:25:56 +04:00
|
|
|
info->item = w;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info->tip_string_installed = False;
|
|
|
|
info->doc_string_installed = False;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* TipString */
|
|
|
|
info->tip_string_enabled = False;
|
|
|
|
info->tip_string_obtain_callback = NULL;
|
|
|
|
info->tip_string_obtain_data1 = NULL;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* DocString */
|
|
|
|
info->doc_string_enabled = False;
|
|
|
|
info->doc_string_obtain_callback = NULL;
|
|
|
|
info->doc_string_obtain_data1 = NULL;
|
|
|
|
|
|
|
|
/* DocString callback */
|
|
|
|
info->doc_string_callback = NULL;
|
|
|
|
info->doc_string_data1 = NULL;
|
1998-09-28 12:11:25 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
return info;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
ItemFreeInfo(_XfeTipItemInfo info)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
XtFree((char *) info);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-28 23:39:44 +04:00
|
|
|
static void
|
|
|
|
ClientDataFreeFunc(Widget w,XtPointer client_data)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
_XfeTipItemInfo info = (_XfeTipItemInfo) client_data;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Free the info */
|
|
|
|
ItemFreeInfo(info);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-08 16:22:21 +04:00
|
|
|
static void
|
1998-09-24 13:22:27 +04:00
|
|
|
ItemGetTipString(Widget w,XmString * xmstr_out,Boolean * need_to_free_out)
|
1998-09-08 16:22:21 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info;
|
1998-09-08 16:22:21 +04:00
|
|
|
|
|
|
|
assert( xmstr_out != NULL );
|
|
|
|
assert( need_to_free_out != NULL );
|
|
|
|
|
|
|
|
*xmstr_out = NULL;
|
|
|
|
*need_to_free_out = False;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
1998-09-08 16:22:21 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
1998-09-08 16:22:21 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Invoke the tip string obtain callback if present */
|
|
|
|
if (info->tip_string_obtain_callback != NULL)
|
1998-09-08 16:22:21 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
(*info->tip_string_obtain_callback)(w,
|
|
|
|
info->tip_string_obtain_data1,
|
|
|
|
xmstr_out,
|
|
|
|
need_to_free_out);
|
1998-09-08 16:22:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 13:22:27 +04:00
|
|
|
static void
|
|
|
|
ItemGetDocString(Widget w,XmString * xmstr_out,Boolean * need_to_free_out)
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
assert( xmstr_out != NULL );
|
|
|
|
assert( need_to_free_out != NULL );
|
|
|
|
|
|
|
|
*xmstr_out = NULL;
|
|
|
|
*need_to_free_out = False;
|
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
/* Invoke the doc string obtain callback if present */
|
|
|
|
if (info->doc_string_obtain_callback != NULL)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
(*info->doc_string_obtain_callback)(w,
|
|
|
|
info->doc_string_obtain_data1,
|
|
|
|
xmstr_out,
|
|
|
|
need_to_free_out);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
1998-09-28 23:39:44 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static _XfeTipItemInfo
|
|
|
|
ItemGetInfo(Widget w)
|
|
|
|
{
|
|
|
|
assert( w != NULL );
|
|
|
|
|
|
|
|
return (_XfeTipItemInfo) XfeClientDataGet(w,GetClientDataKey());
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
ItemAddInfo(Widget w,_XfeTipItemInfo info)
|
|
|
|
{
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
XfeClientDataAdd(w,
|
|
|
|
GetClientDataKey(),
|
|
|
|
(XtPointer) info,
|
|
|
|
ClientDataFreeFunc);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
ItemRemoveInfo(Widget w,_XfeTipItemInfo info)
|
|
|
|
{
|
|
|
|
assert( w != NULL );
|
|
|
|
|
|
|
|
XfeClientDataRemove(w,GetClientDataKey());
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static _XfeTipItemInfo
|
|
|
|
ItemFindOrAddInfo(Widget w)
|
|
|
|
{
|
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
|
|
|
/* Try to find the info */
|
|
|
|
info = ItemGetInfo(w);
|
|
|
|
|
|
|
|
/* If the info is not found, allocate it and add it to the item */
|
|
|
|
if (info == NULL)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
info = ItemAllocateInfo(w);
|
|
|
|
|
|
|
|
ItemAddInfo(w,info);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
1998-09-28 23:39:44 +04:00
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
return info;
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
1998-09-24 13:22:27 +04:00
|
|
|
/* TipString enter / leave / cancel functions */
|
1998-08-26 09:59:32 +04:00
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static Widget _xfe_tt_stage_one_target = NULL;
|
|
|
|
static Widget _xfe_tt_stage_two_target = NULL;
|
|
|
|
static XtIntervalId _xfe_tt_timer_id = 0;
|
|
|
|
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringEnterItem(Widget w,_XfeTipItemInfo info)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
|
|
|
if (_XfeToolTipIsLocked())
|
|
|
|
{
|
1998-10-13 08:26:38 +04:00
|
|
|
_xfe_tt_stage_one_target = NULL;
|
|
|
|
|
|
|
|
/* Remove the timeout if its still active */
|
|
|
|
StageTwoRemoveTimeout(w);
|
|
|
|
|
|
|
|
_xfe_tt_stage_two_target = NULL;
|
|
|
|
|
|
|
|
_XfeToolTipUnlock();
|
|
|
|
|
|
|
|
/* printf("TipStringEnterItem(%s): tool tips are locked - abort\n", */
|
|
|
|
/* XtName(w)); */
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("TipStringEnterItem(%s): tool tips are locked - abort\n",
|
|
|
|
XtName(w));
|
|
|
|
#endif
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
_XfeToolTipLock();
|
|
|
|
|
1998-10-13 08:26:38 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("TipStringEnterItem: stage_one_target = %s\n",XtName(w));
|
|
|
|
#endif
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
_xfe_tt_stage_one_target = w;
|
|
|
|
|
|
|
|
StageTwoAddTimeout(w);
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("TipStringEnterItem(%s)\n",XtName(w));
|
|
|
|
#endif
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringLeaveItem(Widget w,_XfeTipItemInfo info)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
|
|
|
/* Check for stage one */
|
|
|
|
|
|
|
|
/* If a target exists, reset it so that stage two aborts */
|
|
|
|
if (_XfeIsAlive(_xfe_tt_stage_one_target))
|
|
|
|
{
|
1998-10-13 08:26:38 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("TipStringLeaveItem: stage_one_target = NULL\n");
|
|
|
|
#endif
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
_xfe_tt_stage_one_target = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the timeout if its still active */
|
|
|
|
StageTwoRemoveTimeout(w);
|
|
|
|
|
|
|
|
/* Check for stage two */
|
|
|
|
if (_XfeIsAlive(_xfe_tt_stage_two_target))
|
|
|
|
{
|
1998-09-08 16:22:21 +04:00
|
|
|
/* Set the stage two target */
|
1998-08-26 09:59:32 +04:00
|
|
|
_xfe_tt_stage_two_target = NULL;
|
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
ItemUnPostToolTip(w);
|
|
|
|
}
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
_XfeToolTipUnlock();
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("TipStringLeaveItem(%s)\n",XtName(w));
|
|
|
|
#endif
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringCancelItem(Widget w,_XfeTipItemInfo info)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 13:22:27 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("TipStringCancelItem(%s)\n",XtName(w));
|
|
|
|
#endif
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringLeaveItem(w,info);
|
1998-09-08 16:22:21 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
1998-09-24 13:22:27 +04:00
|
|
|
/* DocString enter / leave / cancel functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
DocStringEnterItem(Widget w,_XfeTipItemInfo info)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
XmString xmstr = NULL;
|
|
|
|
Boolean need_to_free = False;
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
ItemGetDocString(w,&xmstr,&need_to_free);
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
if (xmstr == NULL)
|
|
|
|
{
|
|
|
|
xmstr = XmStringCreateLocalized("No doc string found. You Suck!");
|
|
|
|
|
|
|
|
need_to_free = True;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Invoke the doc string SET callback if present */
|
|
|
|
if (info->doc_string_callback != NULL)
|
|
|
|
{
|
|
|
|
(*info->doc_string_callback)(w,
|
|
|
|
info->doc_string_data1,
|
|
|
|
XfeDOC_STRING_SET,
|
|
|
|
xmstr);
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Widget '%s' has doc string support, but no callback\n",
|
|
|
|
XtName(w));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Free the string if needed */
|
|
|
|
if (need_to_free)
|
|
|
|
{
|
|
|
|
XmStringFree(xmstr);
|
|
|
|
}
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("DocStringEnterItem(%s)\n",XtName(w));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-24 18:25:56 +04:00
|
|
|
DocStringLeaveItem(Widget w,_XfeTipItemInfo info)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
|
|
|
assert( _XfeIsAlive(w) );
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
/* Invoke the doc string CLEAR callback if present */
|
|
|
|
if (info->doc_string_callback != NULL)
|
|
|
|
{
|
|
|
|
(*info->doc_string_callback)(w,
|
|
|
|
info->doc_string_data1,
|
|
|
|
XfeDOC_STRING_CLEAR,
|
|
|
|
NULL);
|
|
|
|
}
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("DocStringLeaveItem(%s)\n",XtName(w));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Item Post / UnPost ToolTip functions */
|
1998-09-08 16:22:21 +04:00
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static Boolean _xfe_tt_posted = False;
|
|
|
|
|
|
|
|
static void
|
|
|
|
ItemPostToolTip(Widget w)
|
|
|
|
{
|
|
|
|
Widget shell = NULL;
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Widget label = NULL; */
|
1998-09-08 16:22:21 +04:00
|
|
|
|
|
|
|
XmString xmstr = NULL;
|
|
|
|
Boolean need_to_free = False;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
shell = _XfeToolTipGetShell(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
assert( _XfeIsAlive(shell) );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* label = _XfeToolTipGetLabel(w); */
|
1998-09-08 16:22:21 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* assert( _XfeIsAlive(label) ); */
|
1998-09-08 16:22:21 +04:00
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
ItemGetTipString(w,&xmstr,&need_to_free);
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
if (xmstr == NULL)
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
xmstr = XmStringCreateLocalized("No tip string found. You Suck!");
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
need_to_free = True;
|
|
|
|
}
|
|
|
|
#endif
|
1998-09-08 16:22:21 +04:00
|
|
|
|
|
|
|
if (xmstr != NULL)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
XfeToolTipShellSetString(shell,xmstr);
|
|
|
|
|
|
|
|
/* XfeLabelSetString(label,xmstr); */
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
/* Free the string if needed */
|
|
|
|
if (need_to_free)
|
|
|
|
{
|
|
|
|
XmStringFree(xmstr);
|
|
|
|
}
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* XfeBypassShellUpdateSize(shell); */
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
_xfe_tt_posted = True;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
_XfeMoveWidget(shell,
|
|
|
|
XfeRootX(w) + 10,
|
|
|
|
XfeRootY(w) + _XfeHeight(w) + 10);
|
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
XtPopup(shell,XtGrabNone);
|
|
|
|
}
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("ItemPostToolTip(%s)\n",XtName(w));
|
|
|
|
#endif
|
1998-09-08 16:22:21 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
ItemUnPostToolTip(Widget w)
|
|
|
|
{
|
|
|
|
if (_xfe_tt_posted)
|
|
|
|
{
|
|
|
|
Widget shell = _XfeToolTipGetShell(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
_xfe_tt_posted = True;
|
|
|
|
|
|
|
|
if (_XfeIsAlive(shell))
|
|
|
|
{
|
|
|
|
XtPopdown(shell);
|
|
|
|
}
|
|
|
|
}
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("ItemUnPostToolTip(%s)\n",XtName(w));
|
|
|
|
#endif
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* State Two timeout functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
StageTwoTimeout(XtPointer closure,XtIntervalId * id)
|
|
|
|
{
|
1998-09-08 16:22:21 +04:00
|
|
|
Widget w = (Widget) closure;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Always clear timer_id, so we don't kill someone else's timer
|
|
|
|
* by accident later.
|
|
|
|
*/
|
|
|
|
_xfe_tt_timer_id = 0;
|
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
/*
|
|
|
|
* Post the tooltip if a target is still alive.
|
|
|
|
*
|
|
|
|
* A dead or missing target means the tooltip operation was aborted.
|
|
|
|
* The user could have boinked or left the target.
|
|
|
|
*/
|
|
|
|
if (_XfeIsAlive(_xfe_tt_stage_one_target))
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-08 16:22:21 +04:00
|
|
|
assert( w == _xfe_tt_stage_one_target);
|
1998-10-13 08:26:38 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
|
|
|
printf("StageTwoTimeout: stage_one_target = NULL\n");
|
|
|
|
#endif
|
1998-09-08 16:22:21 +04:00
|
|
|
|
|
|
|
/* Reset the stage one target */
|
|
|
|
_xfe_tt_stage_one_target = NULL;
|
|
|
|
|
|
|
|
/* Set the stage two target */
|
|
|
|
_xfe_tt_stage_two_target = w;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-08 16:22:21 +04:00
|
|
|
ItemPostToolTip(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
StageTwoAddTimeout(Widget w)
|
|
|
|
{
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
|
|
|
_xfe_tt_timer_id = XtAppAddTimeOut(XtWidgetToApplicationContext(w),
|
|
|
|
TOOL_TIP_INTERVAL,
|
|
|
|
StageTwoTimeout,
|
|
|
|
(XtPointer) w);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
StageTwoRemoveTimeout(Widget w)
|
|
|
|
{
|
|
|
|
if (_xfe_tt_timer_id != 0)
|
|
|
|
{
|
|
|
|
XtRemoveTimeOut(_xfe_tt_timer_id);
|
|
|
|
|
|
|
|
_xfe_tt_timer_id = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Event handlers */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
WidgetStageOneEH(Widget w,
|
|
|
|
XtPointer client_data,
|
|
|
|
XEvent * event,
|
|
|
|
Boolean * cont)
|
|
|
|
{
|
1998-09-24 13:22:27 +04:00
|
|
|
/* Do the tip magic only if tip or doc strings are globally enabled */
|
1998-09-24 18:25:56 +04:00
|
|
|
if (XfeTipStringGlobalGetEnabledState() ||
|
|
|
|
XfeDocStringGlobalGetEnabledState())
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
_XfeTipItemInfo info = ItemGetInfo(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
if (info != NULL)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 13:22:27 +04:00
|
|
|
Boolean do_tip_string =
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringGlobalGetEnabledState() &&
|
|
|
|
info->tip_string_enabled;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
Boolean do_doc_string =
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeDocStringGlobalGetEnabledState() &&
|
|
|
|
info->doc_string_enabled;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
/* Enter */
|
|
|
|
if (event->type == EnterNotify)
|
|
|
|
{
|
|
|
|
if (do_tip_string)
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringEnterItem(w,info);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (do_doc_string)
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
DocStringEnterItem(w,info);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Leave */
|
|
|
|
else if (event->type == LeaveNotify)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 13:22:27 +04:00
|
|
|
if (do_tip_string)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringLeaveItem(w,info);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
if (do_doc_string)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
DocStringLeaveItem(w,info);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
/* Cancel */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (do_tip_string)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
TipStringCancelItem(w,info);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
1998-09-24 18:25:56 +04:00
|
|
|
} /* info != NULL */
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
*cont = True;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* XfeToolTip Private Methods */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Tool tip shell access */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ Widget
|
|
|
|
_XfeToolTipGetShell(Widget w)
|
|
|
|
{
|
1998-10-01 05:01:03 +04:00
|
|
|
static Widget _tool_tip_shell = NULL;
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
/* Create to global tool tip shell if needed */
|
1998-10-01 05:01:03 +04:00
|
|
|
if (!_tool_tip_shell)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-10-01 05:01:03 +04:00
|
|
|
/* Find the ancestor shell */
|
|
|
|
Widget aw = XfeAncestorFindShell(w);
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
assert( _XfeIsAlive(aw) );
|
|
|
|
|
1998-10-01 05:01:03 +04:00
|
|
|
/* Create tool tip shell with the same visual, depth & cmap as aw */
|
|
|
|
_tool_tip_shell = XtVaCreateWidget(TOOL_TIP_SHELL_NAME,
|
|
|
|
xfeToolTipShellWidgetClass,
|
|
|
|
aw,
|
|
|
|
XmNvisual, XfeVisual(aw),
|
|
|
|
XmNcolormap, XfeColormap(aw),
|
|
|
|
XmNdepth, XfeDepth(aw),
|
|
|
|
NULL);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 05:01:03 +04:00
|
|
|
return _tool_tip_shell;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ Widget
|
|
|
|
_XfeToolTipGetLabel(Widget w)
|
|
|
|
{
|
|
|
|
Widget shell = _XfeToolTipGetShell(w);
|
|
|
|
|
|
|
|
assert( _XfeIsAlive(shell) );
|
|
|
|
assert( _XfeIsAlive(XfeToolTipShellGetLabel(shell)) );
|
|
|
|
|
|
|
|
return XfeToolTipShellGetLabel(shell);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Lock / Unlock functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static Boolean _xfe_tt_locked = False;
|
|
|
|
|
|
|
|
/* extern */ void
|
|
|
|
_XfeToolTipLock(void)
|
|
|
|
{
|
|
|
|
_xfe_tt_locked = True;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
|
|
|
_XfeToolTipUnlock(void)
|
|
|
|
{
|
|
|
|
_xfe_tt_locked = False;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ Boolean
|
|
|
|
_XfeToolTipIsLocked(void)
|
|
|
|
{
|
|
|
|
return _xfe_tt_locked;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* ClientData key functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
static XfeClientDataKey
|
|
|
|
GetClientDataKey(void)
|
|
|
|
{
|
|
|
|
static XfeClientDataKey _client_data_key = 0;
|
|
|
|
|
|
|
|
if (_client_data_key == 0)
|
|
|
|
{
|
|
|
|
_client_data_key = XfeClientGetUniqueKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
return _client_data_key;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* TipString public methods */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringAdd(Widget w)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
1998-09-24 18:25:56 +04:00
|
|
|
printf("XfeTipStringAdd(%s)\n",XtName(w));
|
1998-09-24 13:22:27 +04:00
|
|
|
#endif
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
if (XmIsGadget(w))
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info = GadgetAddTipString(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info = WidgetAddTipString(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
/* Enable the tip string by default */
|
|
|
|
info->tip_string_enabled = True;
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringRemove(Widget w)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-28 12:11:25 +04:00
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
assert( w != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
1998-09-24 18:25:56 +04:00
|
|
|
printf("XfeTipStringRemove(%s)\n",XtName(w));
|
1998-09-24 13:22:27 +04:00
|
|
|
#endif
|
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
info = ItemGetInfo(w);
|
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
ItemUninstallTipString(w,info);
|
|
|
|
|
|
|
|
if (!info->doc_string_installed)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Remove the info */
|
|
|
|
ItemRemoveInfo(w,info);
|
|
|
|
|
|
|
|
/* Free the item info */
|
|
|
|
ItemFreeInfo(info);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
1998-09-28 12:11:25 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Remove stage one event handler if needed */
|
|
|
|
if (XtIsWidget(w))
|
|
|
|
{
|
|
|
|
WidgetRemoveStageOneEH(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 18:25:56 +04:00
|
|
|
/* extern */ void
|
|
|
|
XfeTipStringSetEnabledState(Widget w,Boolean state)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
if (info != NULL)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info->tip_string_enabled = state;
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 18:25:56 +04:00
|
|
|
/* extern */ Boolean
|
|
|
|
XfeTipStringGetEnabledState(Widget w)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
if (info != NULL)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
return info->tip_string_enabled;
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
return False;
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* TipString callback functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringSetObtainCallback(Widget w,
|
|
|
|
XfeTipStringObtainCallback callback,
|
1998-09-28 23:39:44 +04:00
|
|
|
XtPointer client_data)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
|
|
|
|
|
|
|
assert( info != NULL );
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
if (info != NULL)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info->tip_string_obtain_callback = callback;
|
1998-09-28 23:39:44 +04:00
|
|
|
info->tip_string_obtain_data1 = client_data;
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringClearObtainCallback(Widget w)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
XfeTipStringSetObtainCallback(w,NULL,NULL);
|
1998-09-24 13:22:27 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* TipString global enabled / disable functions */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-28 12:11:25 +04:00
|
|
|
static Boolean _xfe_tip_string_global_enabled = True;
|
1998-09-24 13:22:27 +04:00
|
|
|
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringGlobalSetEnabledState(Boolean state)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
|
|
|
_xfe_tip_string_global_enabled = state;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ Boolean
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringGlobalGetEnabledState(void)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
|
|
|
return _xfe_tip_string_global_enabled;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* Check whether the global tooltip is showing */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
extern Boolean
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeTipStringIsShowing(void)
|
1998-09-24 13:22:27 +04:00
|
|
|
{
|
|
|
|
/* writeme */
|
|
|
|
assert( 0 );
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
1998-09-24 13:22:27 +04:00
|
|
|
/* DocString public methods */
|
1998-08-26 09:59:32 +04:00
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeDocStringAdd(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
1998-09-24 18:25:56 +04:00
|
|
|
printf("XfeDocStringAdd(%s)\n",XtName(w));
|
1998-09-24 13:22:27 +04:00
|
|
|
#endif
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
if (XmIsGadget(w))
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info = GadgetAddDocString(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info = WidgetAddDocString(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
/* Enable the doc string by default */
|
|
|
|
info->doc_string_enabled = True;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeDocStringRemove(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 12:11:25 +04:00
|
|
|
_XfeTipItemInfo info = NULL;
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
assert( w != NULL );
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 13:22:27 +04:00
|
|
|
#ifdef DEBUG_TOOL_TIPS
|
1998-09-24 18:25:56 +04:00
|
|
|
printf("XfeDocStringRemove(%s)\n",XtName(w));
|
1998-09-24 13:22:27 +04:00
|
|
|
#endif
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-28 12:11:25 +04:00
|
|
|
info = ItemGetInfo(w);
|
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
ItemUninstallDocString(w,info);
|
|
|
|
|
|
|
|
if (!info->tip_string_installed)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Remove the info */
|
|
|
|
ItemRemoveInfo(w,info);
|
|
|
|
|
|
|
|
/* Free the item info */
|
|
|
|
ItemFreeInfo(info);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
1998-09-28 12:11:25 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
/* Remove stage one event handler if needed */
|
|
|
|
if (XtIsWidget(w))
|
|
|
|
{
|
|
|
|
WidgetRemoveStageOneEH(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 18:25:56 +04:00
|
|
|
/* extern */ void
|
|
|
|
XfeDocStringSetEnabledState(Widget w,Boolean state)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
if (info != NULL)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info->doc_string_enabled = state;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 18:25:56 +04:00
|
|
|
/* extern */ Boolean
|
|
|
|
XfeDocStringGetEnabledState(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
_XfeTipItemInfo info;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
1998-08-26 09:59:32 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
if (info != NULL)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
return info->doc_string_enabled;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
1998-09-24 18:25:56 +04:00
|
|
|
|
|
|
|
return False;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
|
1998-08-26 09:59:32 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
1998-09-24 13:22:27 +04:00
|
|
|
/* DocString callback functions */
|
1998-08-26 09:59:32 +04:00
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeDocStringSetObtainCallback(Widget w,
|
|
|
|
XfeTipStringObtainCallback callback,
|
1998-09-28 23:39:44 +04:00
|
|
|
XtPointer client_data)
|
1998-09-24 18:25:56 +04:00
|
|
|
{
|
|
|
|
_XfeTipItemInfo info;
|
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
|
|
|
info = ItemGetInfo(w);
|
|
|
|
|
|
|
|
assert( info != NULL );
|
|
|
|
|
|
|
|
if (info != NULL)
|
|
|
|
{
|
|
|
|
info->doc_string_obtain_callback = callback;
|
1998-09-28 23:39:44 +04:00
|
|
|
info->doc_string_obtain_data1 = client_data;
|
1998-09-24 18:25:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
|
|
|
XfeDocStringClearObtainCallback(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
XfeDocStringSetObtainCallback(w,NULL,NULL);
|
1998-09-24 18:25:56 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
|
|
|
XfeDocStringSetCallback(Widget w,
|
|
|
|
XfeDocStringCallback callback,
|
1998-09-28 23:39:44 +04:00
|
|
|
XtPointer client_data)
|
1998-09-24 18:25:56 +04:00
|
|
|
{
|
|
|
|
_XfeTipItemInfo info;
|
1998-09-08 16:22:21 +04:00
|
|
|
|
|
|
|
assert( _XfeIsAlive(w) );
|
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
info = ItemGetInfo(w);
|
|
|
|
|
|
|
|
assert( info != NULL );
|
1998-09-08 16:22:21 +04:00
|
|
|
|
1998-09-24 18:25:56 +04:00
|
|
|
if (info != NULL)
|
1998-09-08 16:22:21 +04:00
|
|
|
{
|
1998-09-24 18:25:56 +04:00
|
|
|
info->doc_string_callback = callback;
|
1998-09-28 23:39:44 +04:00
|
|
|
info->doc_string_data1 = client_data;
|
1998-09-08 16:22:21 +04:00
|
|
|
}
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeDocStringClearCallback(Widget w)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-28 23:39:44 +04:00
|
|
|
XfeDocStringSetCallback(w,NULL,NULL);
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
1998-09-24 13:22:27 +04:00
|
|
|
/* DocString global enabled / disable functions */
|
1998-08-26 09:59:32 +04:00
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-28 12:11:25 +04:00
|
|
|
static Boolean _xfe_doc_string_global_enabled = True;
|
1998-08-26 09:59:32 +04:00
|
|
|
|
|
|
|
/* extern */ void
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeDocStringGlobalSetEnabledState(Boolean state)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 13:22:27 +04:00
|
|
|
_xfe_doc_string_global_enabled = state;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ Boolean
|
1998-09-24 18:25:56 +04:00
|
|
|
XfeDocStringGlobalGetEnabledState(void)
|
1998-08-26 09:59:32 +04:00
|
|
|
{
|
1998-09-24 13:22:27 +04:00
|
|
|
return _xfe_doc_string_global_enabled;
|
1998-08-26 09:59:32 +04:00
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
1998-09-24 13:22:27 +04:00
|
|
|
|
1998-09-28 23:39:44 +04:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* XfeDocStringGetFromAppDefaults() */
|
|
|
|
/* */
|
|
|
|
/* Obtain an XmString from application defaults for the resource named */
|
|
|
|
/* "documentationString" */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ XmString
|
|
|
|
XfeDocStringGetFromAppDefaults(Widget w)
|
|
|
|
{
|
|
|
|
return XfeSubResourceGetWidgetXmStringValue(w,
|
|
|
|
XmNdocumentationString,
|
|
|
|
XmCDocumentationString);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/* XfeTipStringGetFromAppDefaults() */
|
|
|
|
/* */
|
|
|
|
/* Obtain an XmString from application defaults for the resource named */
|
|
|
|
/* "tipString" */
|
|
|
|
/* */
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* extern */ XmString
|
|
|
|
XfeTipStringGetFromAppDefaults(Widget w)
|
|
|
|
{
|
|
|
|
return XfeSubResourceGetWidgetXmStringValue(w,
|
|
|
|
XmNtipString,
|
|
|
|
XmCTipString);
|
|
|
|
}
|
|
|
|
/*----------------------------------------------------------------------*/
|