mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-23 13:04:28 +00:00
Finalize doc string support. Add better callbacks.
This commit is contained in:
parent
b1fda97e9f
commit
60843dd1db
File diff suppressed because it is too large
Load Diff
@ -44,21 +44,41 @@ XFE_BEGIN_CPLUSPLUS_PROTECTION
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* XfeToolTipStringCallback */
|
||||
/* XfeTipStringObtainCallback */
|
||||
/* */
|
||||
/* This callback is invoked when an item that has tip string support is */
|
||||
/* ready to post a tooltip. An item is ready to post a tooltip right */
|
||||
/* after the following two events occur in am immediate sequence: */
|
||||
/* */
|
||||
/* 1. The pointer Enters the item. */
|
||||
/* 2. A timeout expires without an intervening cancellation. */
|
||||
/* */
|
||||
/* A cancellation occurs when: */
|
||||
/* */
|
||||
/* 1. The pointer leaves the item before the timeout expires. */
|
||||
/* 2. The item receives a Button or KetPress event. */
|
||||
/* */
|
||||
/* This callback should return the following: */
|
||||
/* */
|
||||
/* An XmString in 'string_return' */
|
||||
/* */
|
||||
/* Should that string should be freed after use in 'need_to_free_string'*/
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
typedef void
|
||||
(*XfeToolTipStringObtainCallback) (Widget w,
|
||||
XtPointer clientData1,
|
||||
XtPointer clientData2,
|
||||
XmString * string_return,
|
||||
Boolean * need_to_free_string);
|
||||
(*XfeTipStringObtainCallback) (Widget w,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2,
|
||||
XmString * string_return,
|
||||
Boolean * need_to_free_string);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Callback Reasons */
|
||||
/* */
|
||||
/* The 'reason' given to the XfeDocStringCallback callaback below. */
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
typedef enum _XfeDocStringReason
|
||||
{
|
||||
@ -68,47 +88,44 @@ typedef enum _XfeDocStringReason
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* XfeToolTipStringCallback */
|
||||
/* XfeDocStringCallback */
|
||||
/* */
|
||||
/* This callback is invoked when the pointer enters an item that has */
|
||||
/* doc string support and a valid doc string is obtain. A valid doc */
|
||||
/* string can be obtained in 2 ways: */
|
||||
/* */
|
||||
/* 1. Via an XfeTipStringObtainCallback callback which can be */
|
||||
/* installed by XfeDocStringSetObtainCallback() */
|
||||
/* */
|
||||
/* 2. Via the XmNdocumentationString resource for the item which can */
|
||||
/* be installed in an application resources file. */
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
typedef void
|
||||
(*XfeToolTipDocStringCallback) (Widget w,
|
||||
XtPointer clientData1,
|
||||
XtPointer clientData2,
|
||||
XfeDocStringReason reason,
|
||||
XmString string);
|
||||
(*XfeDocStringCallback) (Widget w,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2,
|
||||
XfeDocStringReason reason,
|
||||
XmString string);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* ToolTip label callback structure */
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
int reason; /* Reason why CB was invoked */
|
||||
XEvent * event; /* Event that triggered CB */
|
||||
XmString label_return; /* Label slot for caller */
|
||||
Boolean need_to_free_return; /* Should the label be freed ? */
|
||||
} XfeToolTipLabelCallbackStruct;
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* TipString public methods */
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipAddTipString (Widget w);
|
||||
XfeTipStringAdd (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipRemoveTipString (Widget w);
|
||||
XfeTipStringRemove (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipSetTipStringEnabledState (Widget w,
|
||||
XfeTipStringSetEnabledState (Widget w,
|
||||
Boolean state);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern Boolean
|
||||
XfeToolTipGetTipStringEnabledState (Widget w);
|
||||
XfeTipStringGetEnabledState (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@ -117,24 +134,29 @@ XfeToolTipGetTipStringEnabledState (Widget w);
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipSetTipStringCallback (Widget w,
|
||||
XtCallbackProc callback,
|
||||
XtPointer client_data);
|
||||
XfeTipStringSetObtainCallback (Widget w,
|
||||
XfeTipStringObtainCallback callback,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipClearTipStringCallback (Widget w);
|
||||
|
||||
XfeTipStringClearObtainCallback (Widget w);
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* TipString global enabled / disable functions */
|
||||
/* */
|
||||
/* Enable and disable tip strings on a global basis. You can use these */
|
||||
/* functions to diable tip strings everywhere. The individual enabled */
|
||||
/* state of items with tip string support is not affected by these */
|
||||
/* functions. */
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipGlobalSetTipStringEnabledState (Boolean state);
|
||||
XfeTipStringGlobalSetEnabledState (Boolean state);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern Boolean
|
||||
XfeToolTipGlobalGetTipStringEnabledState (void);
|
||||
XfeTipStringGlobalGetEnabledState (void);
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
@ -142,7 +164,7 @@ XfeToolTipGlobalGetTipStringEnabledState (void);
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern Boolean
|
||||
XfeToolTipIsTipStringShowing (void);
|
||||
XfeTipStringIsShowing (void);
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
@ -150,17 +172,18 @@ XfeToolTipIsTipStringShowing (void);
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipAddDocString (Widget w);
|
||||
XfeDocStringAdd (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipRemoveDocString (Widget w);
|
||||
XfeDocStringRemove (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipSetDocStringEnabledState (Widget w,
|
||||
XfeDocStringSetEnabledState (Widget w,
|
||||
Boolean state);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern Boolean
|
||||
XfeToolTipGetDocStringEnabledState (Widget w);
|
||||
XfeDocStringGetEnabledState (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
@ -168,24 +191,39 @@ XfeToolTipGetDocStringEnabledState (Widget w);
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipSetDocStringCallback (Widget w,
|
||||
XtCallbackProc callback,
|
||||
XtPointer client_data);
|
||||
XfeDocStringSetObtainCallback (Widget w,
|
||||
XfeTipStringObtainCallback callback,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipClearDocStringCallback (Widget w);
|
||||
XfeDocStringClearObtainCallback (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeDocStringSetCallback (Widget w,
|
||||
XfeDocStringCallback callback,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeDocStringClearCallback (Widget w);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* DocString global enabled / disable functions */
|
||||
/* */
|
||||
/* Enable and disable doc strings on a global basis. You can use these */
|
||||
/* functions to diable doc strings everywhere. The individual enabled */
|
||||
/* state of items with doc string support is not affected by these */
|
||||
/* functions. */
|
||||
/* */
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern void
|
||||
XfeToolTipGlobalSetDocStringEnabledState (Boolean state);
|
||||
XfeDocStringGlobalSetEnabledState (Boolean state);
|
||||
/*----------------------------------------------------------------------*/
|
||||
extern Boolean
|
||||
XfeToolTipGlobalGetDocStringEnabledState (void);
|
||||
XfeDocStringGlobalGetEnabledState (void);
|
||||
|
||||
XFE_END_CPLUSPLUS_PROTECTION
|
||||
|
||||
|
@ -16,11 +16,11 @@
|
||||
! Reserved.
|
||||
|
||||
|
||||
ToolTipTest*MainForm.width: 800
|
||||
ToolTipTest*MainForm.height: 400
|
||||
ToolTipTest*MainForm.width: 800
|
||||
ToolTipTest*MainForm.height: 500
|
||||
ToolTipTest*MainForm.background: Gray60
|
||||
ToolTipTest*MainForm.shadowThickness: 0
|
||||
ToolTipTest*MainForm.shadowType: shadow_in
|
||||
ToolTipTest*MainForm.shadowType: shadow_in
|
||||
|
||||
!ToolTipTest*fontList: -*-helvetica-medium-r-*-*-*-120-*-*-*-*-iso8859-*
|
||||
!ToolTipTest*labelFontList: -*-helvetica-medium-r-*-*-*-120-*-*-*-*-iso8859-*
|
||||
@ -114,3 +114,18 @@ ToolTipTest*XmLabelGadget.topOffset: 10
|
||||
|
||||
|
||||
ToolTipTest*XmLabelGadget*tipString: This is a Tool Tip
|
||||
|
||||
ToolTipTest*StatusLabel.bottomAttachment: attach_form
|
||||
ToolTipTest*StatusLabel.leftAttachment: attach_form
|
||||
ToolTipTest*StatusLabel.rightAttachment: attach_form
|
||||
ToolTipTest*StatusLabel.topAttachment: attach_none
|
||||
ToolTipTest*StatusLabel.bottomOffset: 2
|
||||
ToolTipTest*StatusLabel.leftOffset: 2
|
||||
ToolTipTest*StatusLabel.rightOffset: 2
|
||||
ToolTipTest*StatusLabel.usePreferredWidth: false
|
||||
ToolTipTest*StatusLabel.shadowType: shadow_in
|
||||
ToolTipTest*StatusLabel.background: gray70
|
||||
ToolTipTest*StatusLabel.labelAlignment: alignment_beginning
|
||||
|
||||
|
||||
|
||||
|
@ -27,13 +27,31 @@
|
||||
#include <Xfe/XfeTest.h>
|
||||
#include <Xfe/ToolTip.h>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void
|
||||
string_obtain_cb (Widget w,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2,
|
||||
XmString * string_return,
|
||||
Boolean * need_to_free_string);
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void
|
||||
doc_string_cb (Widget w,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2,
|
||||
XfeDocStringReason reason,
|
||||
XmString string);
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
static Widget _button_gadgets[3];
|
||||
static Widget _label_gadgets[3];
|
||||
|
||||
static Widget _button_widgets[3];
|
||||
static Widget _label_widgets[3];
|
||||
|
||||
static void tool_tip_cb(Widget,XtPointer,XtPointer);
|
||||
static Widget _status_label = NULL;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int
|
||||
@ -60,6 +78,8 @@ main(int argc,char *argv[])
|
||||
_label_gadgets[1] = XmCreateLabelGadget(form,"LabelGadget2",NULL,0);
|
||||
_label_gadgets[2] = XmCreateLabelGadget(form,"LabelGadget3",NULL,0);
|
||||
|
||||
_status_label = XfeCreateLabel(form,"StatusLabel",NULL,0);
|
||||
|
||||
XtVaSetValues(_button_gadgets[0],XmNtopWidget,_label_widgets[2],NULL);
|
||||
XtVaSetValues(_button_gadgets[1],XmNtopWidget,_button_gadgets[0],NULL);
|
||||
XtVaSetValues(_button_gadgets[2],XmNtopWidget,_button_gadgets[1],NULL);
|
||||
@ -86,31 +106,62 @@ main(int argc,char *argv[])
|
||||
XtManageChild(_label_gadgets[1]);
|
||||
XtManageChild(_label_gadgets[2]);
|
||||
|
||||
XtManageChild(_status_label);
|
||||
|
||||
XtPopup(frame,XtGrabNone);
|
||||
|
||||
XfeToolTipAddTipString(_button_widgets[0]);
|
||||
XfeToolTipAddTipString(_button_widgets[1]);
|
||||
/* XfeToolTipAddTipString(_button_widgets[2]); */
|
||||
/* Tip Strings */
|
||||
XfeTipStringAdd(_button_widgets[0]);
|
||||
XfeTipStringAdd(_button_widgets[1]);
|
||||
/* XfeTipStringAdd(_button_widgets[2]); */
|
||||
|
||||
XfeToolTipAddTipString(_label_widgets[0]);
|
||||
XfeToolTipAddTipString(_label_widgets[1]);
|
||||
/* XfeToolTipAddTipString(_label_widgets[2]); */
|
||||
XfeTipStringAdd(_label_widgets[0]);
|
||||
XfeTipStringAdd(_label_widgets[1]);
|
||||
/* XfeTipStringAdd(_label_widgets[2]); */
|
||||
|
||||
XfeToolTipAddTipString(_button_gadgets[0]);
|
||||
XfeToolTipAddTipString(_button_gadgets[1]);
|
||||
/* XfeToolTipAddTipString(_button_gadgets[2]); */
|
||||
XfeTipStringAdd(_button_gadgets[0]);
|
||||
XfeTipStringAdd(_button_gadgets[1]);
|
||||
/* XfeTipStringAdd(_button_gadgets[2]); */
|
||||
|
||||
XfeToolTipAddTipString(_label_gadgets[0]);
|
||||
XfeToolTipAddTipString(_label_gadgets[1]);
|
||||
/* XfeToolTipAddTipString(_label_gadgets[2]); */
|
||||
XfeTipStringAdd(_label_gadgets[0]);
|
||||
XfeTipStringAdd(_label_gadgets[1]);
|
||||
/* XfeTipStringAdd(_label_gadgets[2]); */
|
||||
|
||||
|
||||
XfeToolTipSetTipStringCallback(_button_widgets[0],
|
||||
tool_tip_cb,
|
||||
NULL);
|
||||
XfeTipStringSetObtainCallback(_button_widgets[0],
|
||||
string_obtain_cb,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
XfeToolTipGlobalSetTipStringEnabledState(True);
|
||||
XfeToolTipGlobalSetDocStringEnabledState(True);
|
||||
XfeTipStringGlobalSetEnabledState(True);
|
||||
|
||||
/* Doc Strings */
|
||||
XfeDocStringAdd(_button_widgets[0]);
|
||||
XfeDocStringAdd(_button_widgets[1]);
|
||||
/* XfeDocStringAdd(_button_widgets[2]); */
|
||||
|
||||
XfeDocStringAdd(_label_widgets[0]);
|
||||
XfeDocStringAdd(_label_widgets[1]);
|
||||
/* XfeDocStringAdd(_label_widgets[2]); */
|
||||
|
||||
XfeDocStringAdd(_button_gadgets[0]);
|
||||
XfeDocStringAdd(_button_gadgets[1]);
|
||||
/* XfeDocStringAdd(_button_gadgets[2]); */
|
||||
|
||||
XfeDocStringAdd(_label_gadgets[0]);
|
||||
XfeDocStringAdd(_label_gadgets[1]);
|
||||
/* XfeDocStringAdd(_label_gadgets[2]); */
|
||||
|
||||
XfeDocStringSetObtainCallback(_button_widgets[0],
|
||||
string_obtain_cb,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
XfeDocStringSetCallback(_button_widgets[0],
|
||||
doc_string_cb,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
XfeDocStringGlobalSetEnabledState(True);
|
||||
|
||||
XfeAppMainLoop();
|
||||
|
||||
@ -118,20 +169,41 @@ main(int argc,char *argv[])
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void
|
||||
tool_tip_cb(Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
string_obtain_cb(Widget w,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2,
|
||||
XmString * string_return,
|
||||
Boolean * need_to_free_string)
|
||||
{
|
||||
XfeToolTipLabelCallbackStruct * data =
|
||||
(XfeToolTipLabelCallbackStruct *) call_data;
|
||||
|
||||
static int count = 1;
|
||||
|
||||
char buf[256];
|
||||
|
||||
sprintf(buf,"%s_%d","Count",count++);
|
||||
|
||||
data->label_return = XmStringCreateLocalized(buf);
|
||||
data->need_to_free_return = True;
|
||||
*string_return = XmStringCreateLocalized(buf);
|
||||
*need_to_free_string = True;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void
|
||||
doc_string_cb(Widget w,
|
||||
XtPointer client_data1,
|
||||
XtPointer client_data2,
|
||||
XfeDocStringReason reason,
|
||||
XmString string)
|
||||
{
|
||||
if (!XfeIsAlive(_status_label))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (reason == XfeDOC_STRING_SET)
|
||||
{
|
||||
XfeLabelSetString(_status_label,string);
|
||||
}
|
||||
else if (reason == XfeDOC_STRING_CLEAR)
|
||||
{
|
||||
XfeLabelSetStringPSZ(_status_label,"");
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user