#include <stdio.h>#include <X11/IntrinsicP.h>#include <X11/StringDefs.h>#include <X11/Xaw3d/XawInit.h>#include <X11/Xmu/Converters.h>#include <X11/Xmu/Misc.h>#include <X11/Xaw3d/ToggleP.h>Include dependency graph for Toggle.c:

Go to the source code of this file.
Defines | |
| #define | offset(field) XtOffsetOf(ToggleRec, field) |
| #define | SuperClass ((CommandWidgetClass)&commandClassRec) |
Functions | |
| static void | Toggle () |
| static void | Initialize () |
| static void | Notify () |
| static void | ToggleSet () |
| static void | ToggleDestroy () |
| static void | ClassInit () |
| static Boolean | SetValues () |
| static RadioGroup * | GetRadioGroup () |
| static void | CreateRadioGroup () |
| static void | AddToRadioGroup () |
| static void | TurnOffRadioSiblings () |
| static void | RemoveFromRadioGroup () |
| static void | Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args) |
| static void | ToggleSet (Widget w, XEvent *event, String *params, Cardinal *num_params) |
| static void | Toggle (Widget w, XEvent *event, String *params, Cardinal *num_params) |
| static void | Notify (Widget w, XEvent *event, String *params, Cardinal *num_params) |
| static Boolean | SetValues (Widget current, Widget request, Widget new, ArgList args, Cardinal *num_args) |
| static void | ToggleDestroy (Widget w, XtPointer junk, XtPointer garbage) |
| static RadioGroup * | GetRadioGroup (Widget w) |
| static void | CreateRadioGroup (Widget w1, Widget w2) |
| static void | AddToRadioGroup (RadioGroup *group, Widget w) |
| static void | TurnOffRadioSiblings (Widget w) |
| static void | RemoveFromRadioGroup (Widget w) |
| void | XawToggleChangeRadioGroup (Widget w, Widget radio_group) |
| XtPointer | XawToggleGetCurrent (Widget w) |
| void | XawToggleSetCurrent (Widget radio_group, XtPointer radio_data) |
| void | XawToggleUnsetCurrent (Widget radio_group) |
Variables | |
| static char | defaultTranslations [] |
| static XtResource | resources [] |
| static XtActionsRec | actionsList [] |
| ToggleClassRec | toggleClassRec |
| WidgetClass | toggleWidgetClass = (WidgetClass) &toggleClassRec |
| #define SuperClass ((CommandWidgetClass)&commandClassRec) |
| static void AddToRadioGroup | ( | RadioGroup * | group, | |
| Widget | w | |||
| ) | [static] |
Definition at line 395 of file Toggle.c.
References _RadioGroup::next, _RadioGroup::prev, TogglePart::radio_group, _ToggleRec::toggle, and _RadioGroup::widget.
00398 { 00399 ToggleWidget tw = (ToggleWidget) w; 00400 RadioGroup * local; 00401 00402 local = (RadioGroup *) XtMalloc( sizeof(RadioGroup) ); 00403 local->widget = w; 00404 tw->toggle.radio_group = local; 00405 00406 if (group == NULL) { /* Creating new group. */ 00407 group = local; 00408 group->next = NULL; 00409 group->prev = NULL; 00410 return; 00411 } 00412 local->prev = group; /* Adding to previous group. */ 00413 if ((local->next = group->next) != NULL) 00414 local->next->prev = local; 00415 group->next = local; 00416 }
| static void AddToRadioGroup | ( | ) |
Referenced by CreateRadioGroup(), Initialize(), and XawToggleChangeRadioGroup().
Here is the caller graph for this function:

| static void ClassInit | ( | ) |
Definition at line 165 of file Toggle.c.
References actions, commandWidgetClass, i, streq, string, toggleWidgetClass, XawInitializeWidgetSet(), and XmuNewCvtStringToWidget().
00166 { 00167 XtActionList actions; 00168 Cardinal num_actions; 00169 Cardinal i; 00170 ToggleWidgetClass class = (ToggleWidgetClass) toggleWidgetClass; 00171 static XtConvertArgRec parentCvtArgs[] = { 00172 {XtBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.parent), 00173 sizeof(Widget)} 00174 }; 00175 00176 XawInitializeWidgetSet(); 00177 XtSetTypeConverter(XtRString, XtRWidget, XmuNewCvtStringToWidget, 00178 parentCvtArgs, XtNumber(parentCvtArgs), XtCacheNone, 00179 (XtDestructor)NULL); 00180 /* 00181 * Find the set and unset actions in the command widget's action table. 00182 */ 00183 00184 XtGetActionList(commandWidgetClass, &actions, &num_actions); 00185 00186 for (i = 0 ; i < num_actions ; i++) { 00187 if (streq(actions[i].string, "set")) 00188 class->toggle_class.Set = actions[i].proc; 00189 if (streq(actions[i].string, "unset")) 00190 class->toggle_class.Unset = actions[i].proc; 00191 00192 if ( (class->toggle_class.Set != NULL) && 00193 (class->toggle_class.Unset != NULL) ) { 00194 XtFree((char *) actions); 00195 return; 00196 } 00197 } 00198 00199 /* We should never get here. */ 00200 XtError("Aborting, due to errors resolving bindings in the Toggle widget."); 00201 }
Here is the call graph for this function:

| static void CreateRadioGroup | ( | Widget | w1, | |
| Widget | w2 | |||
| ) | [static] |
Definition at line 370 of file Toggle.c.
References AddToRadioGroup(), GetRadioGroup(), TogglePart::radio_group, _ToggleRec::toggle, and void().
00372 { 00373 char error_buf[BUFSIZ]; 00374 ToggleWidget tw1 = (ToggleWidget) w1; 00375 ToggleWidget tw2 = (ToggleWidget) w2; 00376 00377 if ( (tw1->toggle.radio_group != NULL) || (tw2->toggle.radio_group != NULL) ) { 00378 (void) sprintf(error_buf, "%s %s", "Toggle Widget Error - Attempting", 00379 "to create a new toggle group, when one already exists."); 00380 XtWarning(error_buf); 00381 } 00382 00383 AddToRadioGroup( (RadioGroup *)NULL, w1 ); 00384 AddToRadioGroup( GetRadioGroup(w1), w2 ); 00385 }
Here is the call graph for this function:

| static void CreateRadioGroup | ( | ) | [static] |
Referenced by Initialize(), and XawToggleChangeRadioGroup().
Here is the caller graph for this function:

| static RadioGroup* GetRadioGroup | ( | Widget | w | ) | [static] |
Definition at line 351 of file Toggle.c.
References TogglePart::radio_group, and _ToggleRec::toggle.
00353 { 00354 ToggleWidget tw = (ToggleWidget) w; 00355 00356 if (tw == NULL) return(NULL); 00357 return( tw->toggle.radio_group ); 00358 }
| static RadioGroup* GetRadioGroup | ( | ) | [static] |
Referenced by CreateRadioGroup(), Initialize(), RemoveFromRadioGroup(), TurnOffRadioSiblings(), XawToggleChangeRadioGroup(), XawToggleGetCurrent(), XawToggleSetCurrent(), and XawToggleUnsetCurrent().
Here is the caller graph for this function:

| static void Initialize | ( | Widget | request, | |
| Widget | new, | |||
| ArgList | args, | |||
| Cardinal * | num_args | |||
| ) | [static] |
Definition at line 204 of file Toggle.c.
References AddToRadioGroup(), _ToggleRec::command, CreateRadioGroup(), GetRadioGroup(), TogglePart::radio_data, TogglePart::radio_group, CommandPart::set, _ToggleRec::toggle, ToggleDestroy(), ToggleSet(), and TogglePart::widget.
00208 { 00209 ToggleWidget tw = (ToggleWidget) new; 00210 ToggleWidget tw_req = (ToggleWidget) request; 00211 00212 tw->toggle.radio_group = NULL; 00213 00214 if (tw->toggle.radio_data == NULL) 00215 tw->toggle.radio_data = (XtPointer) new->core.name; 00216 00217 if (tw->toggle.widget != NULL) { 00218 if ( GetRadioGroup(tw->toggle.widget) == NULL) 00219 CreateRadioGroup(new, tw->toggle.widget); 00220 else 00221 AddToRadioGroup( GetRadioGroup(tw->toggle.widget), new); 00222 } 00223 XtAddCallback(new, XtNdestroyCallback, ToggleDestroy, (XtPointer)NULL); 00224 00225 /* 00226 * Command widget assumes that the widget is unset, so we only 00227 * have to handle the case where it needs to be set. 00228 * 00229 * If this widget is in a radio group then it may cause another 00230 * widget to be unset, thus calling the notify proceedure. 00231 * 00232 * I want to set the toggle if the user set the state to "On" in 00233 * the resource group, reguardless of what my ancestors did. 00234 */ 00235 00236 if (tw_req->command.set) 00237 ToggleSet(new, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00238 }
Here is the call graph for this function:

| static void Initialize | ( | void | ) |
Initialisation of Scilab
| static void Notify | ( | Widget | w, | |
| XEvent * | event, | |||
| String * | params, | |||
| Cardinal * | num_params | |||
| ) | [static] |
Definition at line 278 of file Toggle.c.
References _ToggleRec::command, and CommandPart::set.
00283 { 00284 ToggleWidget tw = (ToggleWidget) w; 00285 long antilint = tw->command.set; 00286 00287 XtCallCallbacks( w, XtNcallback, (XtPointer) antilint ); 00288 }
| static void Notify | ( | ) |
| static void RemoveFromRadioGroup | ( | Widget | w | ) | [static] |
Definition at line 455 of file Toggle.c.
References GetRadioGroup(), _RadioGroup::next, and _RadioGroup::prev.
00457 { 00458 RadioGroup * group = GetRadioGroup(w); 00459 if (group != NULL) { 00460 if (group->prev != NULL) 00461 (group->prev)->next = group->next; 00462 if (group->next != NULL) 00463 (group->next)->prev = group->prev; 00464 XtFree((char *) group); 00465 } 00466 }
Here is the call graph for this function:

| static void RemoveFromRadioGroup | ( | ) | [static] |
Referenced by ToggleDestroy(), and XawToggleChangeRadioGroup().
Here is the caller graph for this function:

| static Boolean SetValues | ( | Widget | current, | |
| Widget | request, | |||
| Widget | new, | |||
| ArgList | args, | |||
| Cardinal * | num_args | |||
| ) | [static] |
Definition at line 298 of file Toggle.c.
References _ToggleRec::command, _ToggleRec::core, FALSE, CommandPart::set, Toggle(), _ToggleRec::toggle, TogglePart::widget, and XawToggleChangeRadioGroup().
00302 { 00303 ToggleWidget oldtw = (ToggleWidget) current; 00304 ToggleWidget tw = (ToggleWidget) new; 00305 ToggleWidget rtw = (ToggleWidget) request; 00306 00307 if (oldtw->toggle.widget != tw->toggle.widget) 00308 XawToggleChangeRadioGroup(new, tw->toggle.widget); 00309 00310 if (!tw->core.sensitive && oldtw->core.sensitive && rtw->command.set) 00311 tw->command.set = True; 00312 00313 if (oldtw->command.set != tw->command.set) { 00314 tw->command.set = oldtw->command.set; 00315 Toggle(new, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00316 } 00317 return(FALSE); 00318 }
Here is the call graph for this function:

| static Boolean SetValues | ( | ) | [static] |
| static void Toggle | ( | Widget | w, | |
| XEvent * | event, | |||
| String * | params, | |||
| Cardinal * | num_params | |||
| ) | [static] |
Definition at line 262 of file Toggle.c.
References _ToggleRec::command, CommandPart::set, _ToggleClassRec::toggle_class, ToggleSet(), _ToggleClass::Unset, and w.
00267 { 00268 ToggleWidget tw = (ToggleWidget)w; 00269 ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class; 00270 00271 if (tw->command.set) 00272 class->toggle_class.Unset(w, event, NULL, 0); 00273 else 00274 ToggleSet(w, event, params, num_params); 00275 }
Here is the call graph for this function:

| static void Toggle | ( | ) | [static] |
| static void ToggleDestroy | ( | Widget | w, | |
| XtPointer | junk, | |||
| XtPointer | garbage | |||
| ) | [static] |
Definition at line 329 of file Toggle.c.
References RemoveFromRadioGroup().
00332 { 00333 RemoveFromRadioGroup(w); 00334 }
Here is the call graph for this function:

| static void ToggleDestroy | ( | ) | [static] |
| static void ToggleSet | ( | Widget | w, | |
| XEvent * | event, | |||
| String * | params, | |||
| Cardinal * | num_params | |||
| ) | [static] |
Definition at line 248 of file Toggle.c.
References TurnOffRadioSiblings(), and w.
00253 { 00254 ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class; 00255 00256 TurnOffRadioSiblings(w); 00257 class->toggle_class.Set(w, event, NULL, 0); 00258 }
Here is the call graph for this function:

| static void ToggleSet | ( | ) |
Referenced by Initialize(), Toggle(), and XawToggleSetCurrent().
Here is the caller graph for this function:

| static void TurnOffRadioSiblings | ( | Widget | w | ) | [static] |
Definition at line 425 of file Toggle.c.
References GetRadioGroup(), _RadioGroup::next, Notify(), _RadioGroup::prev, w, and _RadioGroup::widget.
00427 { 00428 RadioGroup * group; 00429 ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class; 00430 00431 if ( (group = GetRadioGroup(w)) == NULL) /* Punt if there is no group */ 00432 return; 00433 00434 /* Go to the top of the group. */ 00435 00436 for ( ; group->prev != NULL ; group = group->prev ); 00437 00438 while ( group != NULL ) { 00439 ToggleWidget local_tog = (ToggleWidget) group->widget; 00440 if ( local_tog->command.set ) { 00441 class->toggle_class.Unset(group->widget, NULL, NULL, 0); 00442 Notify( group->widget, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00443 } 00444 group = group->next; 00445 } 00446 }
Here is the call graph for this function:

| static void TurnOffRadioSiblings | ( | ) |
| void XawToggleChangeRadioGroup | ( | Widget | w, | |
| Widget | radio_group | |||
| ) |
Definition at line 485 of file Toggle.c.
References AddToRadioGroup(), _ToggleRec::command, CreateRadioGroup(), GetRadioGroup(), RemoveFromRadioGroup(), CommandPart::set, and XawToggleUnsetCurrent().
Referenced by SetValues().
00488 { 00489 ToggleWidget tw = (ToggleWidget) w; 00490 RadioGroup * group; 00491 00492 RemoveFromRadioGroup(w); 00493 00494 /* 00495 * If the toggle that we are about to add is set then we will 00496 * unset all toggles in the new radio group. 00497 */ 00498 00499 if ( tw->command.set && radio_group != NULL ) 00500 XawToggleUnsetCurrent(radio_group); 00501 00502 if (radio_group != NULL) 00503 if ((group = GetRadioGroup(radio_group)) == NULL) 00504 CreateRadioGroup(w, radio_group); 00505 else AddToRadioGroup(group, w); 00506 }
Here is the call graph for this function:

Here is the caller graph for this function:

| XtPointer XawToggleGetCurrent | ( | Widget | w | ) |
Definition at line 519 of file Toggle.c.
References GetRadioGroup(), _RadioGroup::next, _RadioGroup::prev, and _RadioGroup::widget.
Referenced by DoSearch(), and Replace().
00522 { 00523 RadioGroup * group; 00524 00525 if ( (group = GetRadioGroup(w)) == NULL) return(NULL); 00526 for ( ; group->prev != NULL ; group = group->prev); 00527 00528 while ( group != NULL ) { 00529 ToggleWidget local_tog = (ToggleWidget) group->widget; 00530 if ( local_tog->command.set ) 00531 return( local_tog->toggle.radio_data ); 00532 group = group->next; 00533 } 00534 return(NULL); 00535 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void XawToggleSetCurrent | ( | Widget | radio_group, | |
| XtPointer | radio_data | |||
| ) |
Definition at line 549 of file Toggle.c.
References _ToggleRec::command, GetRadioGroup(), Notify(), _RadioGroup::prev, TogglePart::radio_data, CommandPart::set, _ToggleRec::toggle, ToggleSet(), and _RadioGroup::widget.
00553 { 00554 RadioGroup * group; 00555 ToggleWidget local_tog; 00556 00557 /* Special case of no radio group. */ 00558 00559 if ( (group = GetRadioGroup(radio_group)) == NULL) { 00560 local_tog = (ToggleWidget) radio_group; 00561 if ( (local_tog->toggle.radio_data == radio_data) ) 00562 if (!local_tog->command.set) { 00563 ToggleSet((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00564 Notify((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00565 } 00566 return; 00567 } 00568 00569 /* 00570 * find top of radio_roup 00571 */ 00572 00573 for ( ; group->prev != NULL ; group = group->prev); 00574 00575 /* 00576 * search for matching radio data. 00577 */ 00578 00579 while ( group != NULL ) { 00580 local_tog = (ToggleWidget) group->widget; 00581 if ( (local_tog->toggle.radio_data == radio_data) ) { 00582 if (!local_tog->command.set) { /* if not already set. */ 00583 ToggleSet((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00584 Notify((Widget) local_tog, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00585 } 00586 return; /* found it, done */ 00587 } 00588 group = group->next; 00589 } 00590 }
Here is the call graph for this function:

| void XawToggleUnsetCurrent | ( | Widget | radio_group | ) |
Definition at line 602 of file Toggle.c.
References _ToggleRec::command, GetRadioGroup(), Notify(), CommandPart::set, _ToggleClassRec::toggle_class, TurnOffRadioSiblings(), and _ToggleClass::Unset.
Referenced by XawToggleChangeRadioGroup().
00605 { 00606 ToggleWidgetClass class; 00607 ToggleWidget local_tog = (ToggleWidget) radio_group; 00608 00609 /* Special Case no radio group. */ 00610 00611 if (local_tog->command.set) { 00612 class = (ToggleWidgetClass) local_tog->core.widget_class; 00613 class->toggle_class.Unset(radio_group, NULL, NULL, 0); 00614 Notify(radio_group, (XEvent *)NULL, (String *)NULL, (Cardinal *)0); 00615 } 00616 if ( GetRadioGroup(radio_group) == NULL) return; 00617 TurnOffRadioSiblings(radio_group); 00618 }
Here is the call graph for this function:

Here is the caller graph for this function:

XtActionsRec actionsList[] [static] |
char defaultTranslations[] [static] |
XtResource resources[] [static] |
Initial value:
{
{XtNstate, XtCState, XtRBoolean, sizeof(Boolean),
offset(command.set), XtRString, "off"},
{XtNradioGroup, XtCWidget, XtRWidget, sizeof(Widget),
offset(toggle.widget), XtRWidget, (XtPointer) NULL },
{XtNradioData, XtCRadioData, XtRPointer, sizeof(XtPointer),
offset(toggle.radio_data), XtRPointer, (XtPointer) NULL },
}
| WidgetClass toggleWidgetClass = (WidgetClass) &toggleClassRec |
1.5.1