Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtprintinfo / libUI / MotifUI / Group.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: Group.C /main/2 1995/07/17 14:05:44 drk $ */
24 /*                                                                      *
25  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
26  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
27  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
28  * (c) Copyright 1993, 1994 Novell, Inc.                                *
29  */
30
31 #include "Group.h"
32 #include "Dialog.h"
33
34 #include <Xm/Frame.h>
35 #include <Xm/Label.h>
36 #include <Xm/RowColumn.h>
37 #include <Xm/Form.h>
38
39 Group::Group(MotifUI *parent,
40              char *name,
41              GroupType group_type)
42         : MotifUI(parent, name, NULL)
43 {
44    Widget parentW;
45
46    _group_type = group_type;
47
48    parentW = parent->InnerWidget();
49    XmString xm_string = StringCreate(name);
50
51    _w = XtVaCreateManagedWidget(name, xmFrameWidgetClass, parentW, NULL);
52    if (name)
53       _label = XtVaCreateManagedWidget(name, xmLabelWidgetClass, _w, 
54                                        XmNchildType, XmFRAME_TITLE_CHILD,
55                                        XmNlabelString, xm_string, NULL);
56    else
57       _label = XtVaCreateWidget(name, xmLabelWidgetClass, _w, 
58                                 XmNchildType, XmFRAME_TITLE_CHILD,
59                                 XmNlabelString, xm_string, NULL);
60    if (group_type == FORM_BOX)
61       _rc = XtVaCreateManagedWidget(name, xmFormWidgetClass, _w, NULL);
62    else
63     {
64       boolean flag;
65       int orientaion;
66       if (group_type == RADIO_GROUP || group_type == HORIZONTAL_RADIO_GROUP)
67          flag = true;
68       else
69          flag = false;
70       if (group_type == HORIZONTAL_CHECK_BOX ||
71           group_type == HORIZONTAL_RADIO_GROUP)
72          orientaion = XmHORIZONTAL;
73       else
74          orientaion = XmVERTICAL;
75       _rc = XtVaCreateManagedWidget(name, xmRowColumnWidgetClass, _w, 
76                                     XmNradioBehavior, flag,
77                                     XmNorientation, orientaion, NULL);
78     }
79    StringFree(xm_string);
80 }
81
82 boolean Group::SetName(char *name)
83 {
84    if (name)
85     {
86       XmString xm_string = StringCreate(name);
87       XtVaSetValues(_label, XmNlabelString, xm_string, NULL);
88       StringFree(xm_string);
89       XtManageChild(_label);
90     }
91    else
92       XtUnmanageChild(_label);
93
94    return true;
95 }