-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / IndexedOptionMenuUiItem.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 /* $TOG: IndexedOptionMenuUiItem.C /main/4 1997/11/21 17:19:04 mgreess $ */
24 /*
25  *+SNOTICE
26  *
27  *      RESTRICTED CONFIDENTIAL INFORMATION:
28  *      
29  *      The information in this document is subject to special
30  *      restrictions in a confidential disclosure agreement bertween
31  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
32  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
33  *      Sun's specific written approval.  This documment and all copies
34  *      and derivative works thereof must be returned or destroyed at
35  *      Sun's request.
36  *
37  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
38  *
39  *+ENOTICE
40  */
41 /*
42  *                   Common Desktop Environment
43  *
44  *   (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
45  *   (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
46  *   (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
47  *   (c) Copyright 1993, 1994, 1995 Novell, Inc.
48  *   (c) Copyright 1995 Digital Equipment Corp.
49  *   (c) Copyright 1995 Fujitsu Limited
50  *   (c) Copyright 1995 Hitachi, Ltd.
51  *                                                                   
52  *
53  *                     RESTRICTED RIGHTS LEGEND                              
54  *
55  *Use, duplication, or disclosure by the U.S. Government is subject to
56  *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
57  *Technical Data and Computer Software clause in DFARS 252.227-7013.  Rights
58  *for non-DOD U.S. Government Departments and Agencies are as set forth in
59  *FAR 52.227-19(c)(1,2).
60
61  *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
62  *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A. 
63  *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
64  *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
65  *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
66  *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
67  *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
68  */
69
70
71 #include <DtMail/options_util.h>
72 #include <DtMail/PropUi.hh>
73 #include <DtMail/IndexedOptionMenuUiItem.hh>
74
75 extern Boolean props_changed;
76
77 // IndexedOptionMenuUiItem::IndexedOptionMenuUiItem
78 // IndexedOptionMenuUiItem ctor
79 ////////////////////////////////////////////////////////////////////
80
81 IndexedOptionMenuUiItem::IndexedOptionMenuUiItem(
82                         IndexedOptionMenu *iom,
83                         int source,
84                         char *search_key
85                         ) : PropUiItem(iom->baseWidget(), source, search_key)
86 {
87   _iom = iom;
88   _iom->addMenuButtonCallback(
89                         XmNactivateCallback,
90                         IndexedOptionMenuUiItem::valueChangedCB,
91                         (XtPointer) this);
92 }
93
94 // IndexedOptionMenuUiItem::writeFromUiToSource()
95 // Takes values in the UI and puts them into the source DB
96 ///////////////////////////////////////////////////////////////////
97 void IndexedOptionMenuUiItem::writeFromUiToSource()
98 {
99   char  *value;
100   Widget w;
101   
102   w = this->getWidget();
103   value = (char*) _iom->getDataSpec();
104   prop_source->setValue(value);
105 }
106
107 // IndexedOptionMenuUiItem::writeFromSourceToUi()
108 // Takes values in the UI and puts them into the source DB
109 ///////////////////////////////////////////////////////////////////
110 void IndexedOptionMenuUiItem::writeFromSourceToUi()
111 {
112   const char *value;
113   
114   value = (char *)prop_source->getValue();
115   _iom->setSpec((void*) value);
116   if (NULL != value)
117     free((void*) value);
118 }
119
120 // IndexedOptionMenuUiItem::valueChangedCB()
121 // Marks the item as having its value changed.
122 ///////////////////////////////////////////////////////////////////
123 void IndexedOptionMenuUiItem::valueChangedCB(
124                                 Widget,
125                                 XtPointer clientdata,
126                                 XtPointer
127                                 )
128 {
129     IndexedOptionMenuUiItem     *thisIomui;
130
131     thisIomui = (IndexedOptionMenuUiItem *) clientdata;
132     thisIomui->dirty_bit = TRUE;
133     props_changed = TRUE;
134 }
135