1 /*---------------------------------------------------------------------------- 2 -- 3 -- Module: xitCreTb 4 -- 5 -- Project: xit - X Internal Toolkit 6 -- System: xit - X Internal Toolkit 7 -- Subsystem: <> 8 -- Function block: <> 9 -- 10 -- Description: 11 -- Creates a toggle button widget. 12 -- 13 -- Filename: xitCreTb.c 14 -- 15 -- Authors: Roger Larsson, Ulrika Bornetun 16 -- Creation date: 1991-10-20 17 -- 18 -- 19 -- (C) Copyright Ulrika Bornetun, Roger Larsson (1995) 20 -- All rights reserved 21 -- 22 -- Permission to use, copy, modify, and distribute this software and its 23 -- documentation for any purpose and without fee is hereby granted, 24 -- provided that the above copyright notice appear in all copies. Ulrika 25 -- Bornetun and Roger Larsson make no representations about the usability 26 -- of this software for any purpose. It is provided "as is" without express 27 -- or implied warranty. 28 ----------------------------------------------------------------------------*/ 29 30 /* SCCS module identifier. */ 31 static char SCCSID[] = "@(#) Module: xitCreTb.c, Version: 1.1, Date: 95/02/18 15:10:26"; 32 33 34 /*---------------------------------------------------------------------------- 35 -- Include files 36 ----------------------------------------------------------------------------*/ 37 38 #include <X11/Intrinsic.h> 39 #include <X11/Shell.h> 40 41 #include <Xm/Xm.h> 42 #include <Xm/ToggleB.h> 43 44 #include "xitTools.h" 45 46 47 /*---------------------------------------------------------------------------- 48 -- Macro definitions 49 ----------------------------------------------------------------------------*/ 50 51 52 /*---------------------------------------------------------------------------- 53 -- Type declarations 54 ----------------------------------------------------------------------------*/ 55 56 57 /*---------------------------------------------------------------------------- 58 -- Global definitions 59 ----------------------------------------------------------------------------*/ 60 61 62 /*---------------------------------------------------------------------------- 63 -- Function prototypes 64 ----------------------------------------------------------------------------*/ 65 66 67 68 /*---------------------------------------------------------------------------- 69 -- Functions 70 ----------------------------------------------------------------------------*/ 71 72 Widget xitCreateToggleButton(Widget parent,char * name,char * label,Boolean set)73 xitCreateToggleButton( Widget parent, 74 char *name, 75 char *label, 76 Boolean set ) 77 { 78 79 /* Variables. */ 80 Arg args[ 10 ]; 81 Cardinal n; 82 Widget w; 83 XmString xstr = NULL; 84 85 86 /* Code. */ 87 88 n = 0; 89 if( strlen( label ) > 0 ) { 90 xstr = XmStringCreateLtoR( label, CS ); 91 XtSetArg( args[ n ], XmNlabelString, xstr ); n++; 92 } 93 94 XtSetArg( args[ n ], XmNalignment, XmALIGNMENT_CENTER ); n++; 95 96 if( set ) { 97 XtSetArg( args[ n ], XmNset, True ); n++; 98 } 99 100 w = XmCreateToggleButton( parent, name, args, n ); 101 102 if( strlen( label ) > 0 ) 103 XmStringFree( xstr ); 104 105 return( w ); 106 107 } /* xitCreateToggleButton */ 108