Toggle.c revision 749
749N/A/* $XConsortium: Toggle.c,v 1.28 94/04/17 20:13:17 kaleb Exp $ */ 749N/ACopyright (c) 1989, 1994 X Consortium 749N/APermission is hereby granted, free of charge, to any person obtaining a copy 749N/Aof this software and associated documentation files (the "Software"), to deal 749N/Ain the Software without restriction, including without limitation the rights 749N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell 749N/Acopies of the Software, and to permit persons to whom the Software is 749N/Afurnished to do so, subject to the following conditions: 749N/AThe above copyright notice and this permission notice shall be included in 749N/Aall copies or substantial portions of the Software. 749N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 749N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 749N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 749N/AX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 749N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 749N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 749N/AExcept as contained in this notice, the name of the X Consortium shall not be 749N/Aused in advertising or otherwise to promote the sale, use or other dealings 749N/Ain this Software without prior written authorization from the X Consortium. 749N/A * Author: Chris D. Peterson 749N/A * Date: January 12, 1989 749N/A/**************************************************************** 749N/A * Full class record constant 749N/A ****************************************************************/ 749N/A * The order of toggle and notify are important, as the state has 749N/A * to be set when we call the notify proc. 749N/A "<EnterWindow>: highlight(Always) \n\ 749N/A <LeaveWindow>: unhighlight() \n\ 749N/A <Btn1Down>,<Btn1Up>: toggle() notify()";
749N/A/* Functions for handling the Radio Group. */ "Toggle",
/* class_name */ NULL,
/* class_part_initialize */ FALSE,
/* class_inited */ NULL,
/* initialize_hook */ FALSE,
/* compress_motion */ TRUE,
/* compress_exposure */ TRUE,
/* compress_enterleave */ FALSE,
/* visible_interest */ NULL,
/* set_values_hook */ NULL,
/* get_values_hook */ NULL,
/* callback_private */ },
/* CoreClass fields initialization */ },
/* SimpleClass fields initialization */ },
/* LabelClass fields initialization */ },
/* CommandClass fields initialization */ NULL,
/* Set Procedure. */ NULL,
/* Unset Procedure. */ }
/* ToggleClass fields initialization */ /* for public consumption */ /**************************************************************** ****************************************************************/ * Find the set and unset actions in the command widget's action table. /* We should never get here. */ XtError(
"Aborting, due to errors resolving bindings in the Toggle widget.");
* 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. /************************************************************ ************************************************************/ /************************************************************ * Set specified arguments into widget ***********************************************************/ /* Function Name: ToggleDestroy * Description: Destroy Callback for toggle widget. * Arguments: w - the toggle widget that is being destroyed. * junk, grabage - not used. /************************************************************ * Below are all the private procedures that handle ************************************************************/ /* Function Name: GetRadioGroup * Description: Gets the radio group associated with a give toggle * Arguments: w - the toggle widget who's radio group we are getting. * Returns: the radio group associated with this toggle group. /* Function Name: CreateRadioGroup * Description: Creates a radio group. give two widgets. * Arguments: w1, w2 - the toggle widgets to add to the radio group. * NOTE: A pointer to the group is added to each widget's radio_group "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. if (
group ==
NULL) {
/* Creating new group. */ /* Function Name: TurnOffRadioSiblings * Description: Deactivates all radio siblings. * Arguments: widget - a toggle widget. /* Go to the top of the group. */ /* Function Name: RemoveFromRadioGroup * Description: Removes a toggle from a RadioGroup. * Arguments: w - the toggle widget to remove. /************************************************************ ************************************************************/ /* 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. * If the toggle that we are about to add is set then we will * unset all toggles in the new radio group. /* 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. /* Function Name: XawToggleSetCurrent * Description: Sets the Toggle widget associated with the * Arguments: radio_group - any toggle widget in the toggle group. * radio_data - radio data of the toggle widget to set. /* Special case of no radio group. */ * 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. /* Special Case no radio group. */