/* $XConsortium: Toggle.c,v 1.28 94/04/17 20:13:17 kaleb Exp $ */
/*
Copyright (c) 1989, 1994 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
*/
/*
* Toggle.c - Toggle button widget
*
* Author: Chris D. Peterson
* MIT X Consortium
* kit@expo.lcs.mit.edu
*
* Date: January 12, 1989
*
*/
#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
/****************************************************************
*
* Full class record constant
*
****************************************************************/
/* Private Data */
/*
* The order of toggle and notify are important, as the state has
* to be set when we call the notify proc.
*/
static char defaultTranslations[] =
"<EnterWindow>: highlight(Always) \n\
<LeaveWindow>: unhighlight() \n\
<Btn1Down>,<Btn1Up>: toggle() notify()";
};
static void ToggleDestroy(), ClassInit();
/* Functions for handling the Radio Group. */
static RadioGroup * GetRadioGroup();
static void RemoveFromRadioGroup();
{
{"toggle", Toggle},
{"notify", Notify},
{"set", ToggleSet},
};
{
"Toggle", /* class_name */
sizeof(ToggleRec), /* size */
ClassInit, /* class_initialize */
NULL, /* class_part_initialize */
FALSE, /* class_inited */
Initialize, /* initialize */
NULL, /* initialize_hook */
XtInheritRealize, /* realize */
actionsList, /* actions */
resources, /* resources */
NULLQUARK, /* xrm_class */
FALSE, /* compress_motion */
TRUE, /* compress_exposure */
TRUE, /* compress_enterleave */
FALSE, /* visible_interest */
NULL, /* destroy */
XtInheritResize, /* resize */
XtInheritExpose, /* expose */
SetValues, /* set_values */
NULL, /* set_values_hook */
XtInheritSetValuesAlmost, /* set_values_almost */
NULL, /* get_values_hook */
NULL, /* accept_focus */
XtVersion, /* version */
NULL, /* callback_private */
defaultTranslations, /* tm_table */
XtInheritQueryGeometry, /* query_geometry */
XtInheritDisplayAccelerator, /* display_accelerator */
NULL /* extension */
}, /* CoreClass fields initialization */
{
XtInheritChangeSensitive /* change_sensitive */
}, /* SimpleClass fields initialization */
{
0 /* field not used */
}, /* LabelClass fields initialization */
{
0 /* field not used */
}, /* CommandClass fields initialization */
{
NULL, /* Set Procedure. */
NULL, /* Unset Procedure. */
NULL /* extension. */
} /* ToggleClass fields initialization */
};
/* for public consumption */
/****************************************************************
*
* Private Procedures
*
****************************************************************/
static void
{
Cardinal i;
sizeof(Widget)}
};
(XtDestructor)NULL);
/*
* Find the set and unset actions in the command widget's action table.
*/
for (i = 0 ; i < num_actions ; i++) {
return;
}
}
/* We should never get here. */
XtError("Aborting, due to errors resolving bindings in the Toggle widget.");
}
/*ARGSUSED*/
{
else
}
/*
* Command widget assumes that the widget is unset, so we only
* have to handle the case where it needs to be set.
*
* If this widget is in a radio group then it may cause another
* widget to be unset, thus calling the notify proceedure.
*
* I want to set the toggle if the user set the state to "On" in
* the resource group, reguardless of what my ancestors did.
*/
}
/************************************************************
*
* Action Procedures
*
************************************************************/
/* ARGSUSED */
static void
Widget w;
{
}
/* ARGSUSED */
static void
Widget w;
{
else
}
/* ARGSUSED */
Widget w;
{
}
/************************************************************
*
* Set specified arguments into widget
*
***********************************************************/
/* ARGSUSED */
static Boolean
{
}
return(FALSE);
}
/* Function Name: ToggleDestroy
* Description: Destroy Callback for toggle widget.
* Arguments: w - the toggle widget that is being destroyed.
* junk, grabage - not used.
* Returns: none.
*/
/* ARGSUSED */
static void
Widget w;
{
}
/************************************************************
*
* Below are all the private procedures that handle
* radio toggle buttons.
*
************************************************************/
/* Function Name: GetRadioGroup
* Description: Gets the radio group associated with a give toggle
* widget.
* Arguments: w - the toggle widget who's radio group we are getting.
* Returns: the radio group associated with this toggle group.
*/
static RadioGroup *
Widget w;
{
}
/* Function Name: CreateRadioGroup
* Description: Creates a radio group. give two widgets.
* Arguments: w1, w2 - the toggle widgets to add to the radio group.
* Returns: none.
*
* NOTE: A pointer to the group is added to each widget's radio_group
* field.
*/
static void
{
"to create a new toggle group, when one already exists.");
}
}
/* Function Name: AddToRadioGroup
* Description: Adds a toggle to the radio group.
* Arguments: group - any element of the radio group the we are adding to.
* w - the new toggle widget to add to the group.
* Returns: none.
*/
static void
RadioGroup * group;
Widget w;
{
return;
}
}
/* Function Name: TurnOffRadioSiblings
* Description: Deactivates all radio siblings.
* Arguments: widget - a toggle widget.
* Returns: none.
*/
static void
Widget w;
{
return;
/* Go to the top of the group. */
}
}
}
/* Function Name: RemoveFromRadioGroup
* Description: Removes a toggle from a RadioGroup.
* Arguments: w - the toggle widget to remove.
* Returns: none.
*/
static void
Widget w;
{
}
}
/************************************************************
*
* Public Routines
*
************************************************************/
/* Function Name: XawToggleChangeRadioGroup
* Description: Allows a toggle widget to change radio groups.
* Arguments: w - The toggle widget to change groups.
* radio_group - any widget in the new group.
* Returns: none.
*/
void
#else
Widget w, radio_group;
#endif
{
/*
* If the toggle that we are about to add is set then we will
* unset all toggles in the new radio group.
*/
if (radio_group != NULL)
else AddToRadioGroup(group, w);
}
/* Function Name: XawToggleGetCurrent
* Description: Returns the RadioData associated with the toggle
* widget that is currently active in a toggle group.
* Arguments: w - any toggle widget in the toggle group.
* Returns: The XtNradioData associated with the toggle widget.
*/
#else
Widget w;
#endif
{
}
return(NULL);
}
/* Function Name: XawToggleSetCurrent
* Description: Sets the Toggle widget associated with the
* radio_data specified.
* Arguments: radio_group - any toggle widget in the toggle group.
* radio_data - radio data of the toggle widget to set.
* Returns: none.
*/
void
#else
#endif
{
/* Special case of no radio group. */
}
return;
}
/*
* find top of radio_roup
*/
/*
* search for matching radio data.
*/
}
return; /* found it, done */
}
}
}
/* Function Name: XawToggleUnsetCurrent
* Description: Unsets all Toggles in the radio_group specified.
* Arguments: radio_group - any toggle widget in the toggle group.
* Returns: none.
*/
void
#else
#endif
{
/* Special Case no radio group. */
}
}