Add -fpermissive to linux standard c++ option define in linux.cf
[oweals/cde.git] / cde / programs / dtprintinfo / UI / DtProps.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: DtProps.C /main/2 1995/07/17 14:03:51 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 "DtProps.h"
32 #include "DtMainW.h"
33 #include "Button.h"
34 #include "Prompt.h"
35 #include "LabelObj.h"
36 #include "Container.h"
37 #include "BaseObj.h"
38
39 #include "dtprintinfomsg.h"
40
41 #include <stdio.h>
42
43 DtProps::DtProps(AnyUI *parent,
44                  char *name,
45                  char *location_id,
46                  boolean editable,
47                  int n_attributes,
48                  Attribute **attributes)
49         : Dialog(parent, name)
50 {
51    mainw = (DtMainW *) parent;
52    _location_id = location_id;
53    _has_been_posted = false;
54    rc = new Container(this, "rc", VERTICAL_ROW_COLUMN);
55    int i, captionWidth = 0, width, columns = 0;
56    for (i = 0; i < n_attributes; i++)
57     {
58       if ((width = StringWidth(attributes[i]->DisplayName)) > captionWidth)
59          captionWidth = width;
60       if ((width = strlen(attributes[i]->DisplayValue)) > columns)
61          columns = width;
62     }
63
64    for (i = 0; i < n_attributes; i++)
65     {
66       boolean _editable;
67       if (EditableAfterCreate(attributes[i]))
68          _editable = true;
69       else
70          _editable = false;
71       if (attributes[i]->ValueListType == INFORMATION_LINE)
72          new LabelObj(rc, attributes[i]->DisplayName);
73       else
74          new Prompt(rc, attributes[i]->DisplayName, _editable, STRING_PROMPT,
75                     attributes[i]->DisplayValue, NULL,
76                     NULL, true, columns, 1, captionWidth + 8);
77     }
78
79    ok = new Button(this, MESSAGE(OKL), PUSH_BUTTON, OkCB, this);
80    if (editable)
81     {
82       cancel = new Button(this, MESSAGE(CancelL), PUSH_BUTTON, CancelCB, this);
83       CancelButton(cancel);
84     }
85    else
86       CancelButton(ok);
87    help = new Button(this, MESSAGE(HelpL), PUSH_BUTTON, HelpCB, this);
88    rc->AttachAll();
89    DefaultButton(ok);
90 }
91
92 DtProps::~DtProps()
93 {
94    // Empty
95 }
96
97 boolean DtProps::SetVisiblity(boolean flag)
98 {
99    if (_has_been_posted == false)
100     {
101       Dialog::SetVisiblity(flag);
102       Refresh();
103       int width = StringWidth(Name()) + 35;
104       if (Width() < width)
105        {
106          Dialog::SetVisiblity(flag);
107          Width(width);
108        }
109       _has_been_posted = true;
110     }
111    Dialog::SetVisiblity(flag);
112    return true;
113 }
114
115 void DtProps::Reset()
116 {
117 }
118
119 void DtProps::Apply()
120 {
121 }
122
123 void DtProps::CloseCB()
124 {
125    Reset();
126    Visible(false);
127 }
128
129 void DtProps::OkCB(void *data)
130 {
131    DtProps *obj = (DtProps *) data;
132    
133    obj->Apply();
134    obj->Visible(false);
135 }
136
137 void DtProps::ApplyCB(void *data)
138 {
139    DtProps *obj = (DtProps *) data;
140    obj->Apply();
141 }
142
143 void DtProps::CancelCB(void *data)
144 {
145    DtProps *obj = (DtProps *) data;
146    
147    obj->Reset();
148    obj->Visible(false);
149 }
150
151 void DtProps::ResetCB(void *data)
152 {
153    DtProps *obj = (DtProps *) data;
154    
155    obj->Reset();
156 }
157
158 void DtProps::HelpCB(void *data)
159 {
160    DtProps *obj = (DtProps *) data;
161    obj->HandleHelpRequest();
162 }
163
164 boolean DtProps::HandleHelpRequest()
165 {
166    mainw->DisplayHelp(_location_id);
167    return true;
168 }