2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: LabelObj.C /main/2 1995/07/17 14:06:12 drk $ */
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. *
37 LabelObj::LabelObj(MotifUI *parent,
41 : MotifUI(parent, name, NULL)
43 XmString xm_string = StringCreate(name);
48 switch (_style = style)
50 case LEFT_JUSTIFIED: alignment = XmALIGNMENT_BEGINNING; break;
51 case CENTERED: alignment = XmALIGNMENT_CENTER; break;
52 case RIGHT_JUSTIFIED: alignment = XmALIGNMENT_END; break;
55 p = parent->InnerWidget();
56 if (!XtIsComposite(p))
58 XtVaGetValues(p, XmNbackground, &bg, NULL);
59 // If p is a icon then set superNode to it, otherwise set superNode to NULL
60 super_node = parent->UIClass() == ICON ? parent->BaseWidget() : NULL;
63 _w = XtVaCreateManagedWidget(name, xmFrameWidgetClass, p,
64 XmNbackground, bg, XmNuserData, this,
65 XmNshadowType, XmSHADOW_OUT,
66 XmNshadowThickness, shadowThickness, NULL);
69 _label = XtVaCreateManagedWidget(name, xmLabelWidgetClass, p,
70 XmNlabelString, xm_string,
71 GuiNsuperNode, super_node,
72 XmNalignment, alignment,
73 XmNbackground, bg, XmNuserData, this, NULL);
77 StringFree(xm_string);
80 void LabelObj::LabelStyle(LabelType style)
84 switch (_style = style)
86 case LEFT_JUSTIFIED: alignment = XmALIGNMENT_BEGINNING; break;
87 case CENTERED: alignment = XmALIGNMENT_CENTER; break;
88 case RIGHT_JUSTIFIED: alignment = XmALIGNMENT_END; break;
90 XtVaSetValues(_label, XmNalignment, alignment, NULL);