Use C++ linker
[oweals/cde.git] / cde / programs / dtwm / Print.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: Print.c /main/4 1995/11/01 11:29:33 rswiston $ */
24 /*****************************************************************************
25  *
26  *   File:         Print.c
27  *
28  *   Project:       DT
29  *
30  *   Description:  This file contains the function which prints out the
31  *                 front panel contents.  It is used as a client for this
32  *                 purpose.
33  *
34  * (c) Copyright 1993, 1994 Hewlett-Packard Company
35  * (c) Copyright 1993, 1994 International Business Machines Corp.
36  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
37  * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
38  *
39  ****************************************************************************/
40
41 #include <Dt/DtP.h>                /* required for DtDirPaths type */
42 #include <Dt/DbReader.h>            /* required for DtDbPathId type */
43 #include <Dt/WsmM.h>
44 #include <Dt/IconFile.h>
45 #include "DataBaseLoad.h"
46 #include "Parse.h"
47
48 #ifdef __STDC__
49 const char *szWM_TOOL_CLASS = DtWM_TOOL_CLASS;
50 #else
51 char *szWM_TOOL_CLASS = DtWM_TOOL_CLASS;
52 #endif /* __STDC__ */
53
54
55
56 String unpost_arrow_image;
57 String unpost_monitor_arrow_image;
58
59 /************************************************************************
60  *
61  *  CheckOtherMonitorsOn
62  *      Due to a dependancy, CheckOtherMonitorsOn must be defined.  This
63  *      is a stubbed procedure that ensures that the procedure is defined.
64  *
65  ************************************************************************/
66 Boolean
67 CheckOtherMonitorsOn(SubpanelData * subpanel_data)
68 {
69    return False;
70 }
71
72
73 /************************************************************************
74  *
75  *  ToggleDefaultControl
76  *      Due to a dependancy, ToggleDefaultControl must be defined.  This
77  *      is a stubbed procedure that ensures that the procedure is defined.
78  *
79  ************************************************************************/
80
81
82 void
83 ToggleDefaultControl (ControlData  * main_control_data,
84                       SubpanelData * subpanel_data,
85                       ControlData  * control_data)
86
87
88 {
89 }
90
91
92
93
94 /************************************************************************
95  *
96  *  GetIconName
97  *      Get the file name for an icon by extracting the panel resolution
98  *      and then looking up the image name.
99  *
100  ************************************************************************/
101
102
103 String
104 GetIconName (String       image_name, 
105              unsigned int icon_size)
106
107
108 {
109    String       return_name;
110    Screen     * screen = XtScreen (panel.shell);
111
112    /*  Get name.  */
113
114    return_name = _DtGetIconFileName (screen, image_name, NULL, NULL, icon_size);
115
116    if (return_name == NULL)
117        return_name = _DtGetIconFileName (screen, image_name, NULL, NULL,
118                                          DtUNSPECIFIED);
119    if (return_name == NULL)
120        return_name = XtNewString (image_name);
121
122
123    /*  Return value to be freed by caller.  */
124
125    return (return_name);
126 }
127
128
129
130
131 /************************************************************************
132  *
133  *  PrintFrontPanelContents
134  *      Using the information from the loading of the database
135  *      print out the contents of the database.
136  *
137  ************************************************************************/
138
139 void
140
141 PrintFrontPanelContents(void)
142
143 {
144    BoxData * box_data;
145    SwitchData * switch_data;
146    ControlData * control_data, * switch_control_data;
147    SubpanelData * subpanel_data;
148    int switch_position = POSITION_FIRST;
149    int i,j, k;
150
151
152    /*  print out the component tree  */
153    
154    printf ("PANEL       %s\n", (char *) panel.element_values[0].parsed_value);
155
156    for (i = 0; i < panel.box_data_count; i++)
157    {
158       box_data = panel.box_data[i];
159
160       if (box_data->switch_data != NULL)
161       {
162          switch_data = box_data->switch_data;
163          switch_position = (int) box_data->switch_data->element_values[SWITCH_POSITION_HINTS].parsed_value;
164       }
165       else
166          switch_data = NULL;
167
168
169       printf ("   BOX   %s\n", 
170               (char *) box_data->element_values[0].parsed_value);
171
172       for (j = 0; j < box_data->control_data_count; j++)
173       {
174          control_data = box_data->control_data[j];
175
176          if (switch_data != NULL &&
177              switch_position < (int) (control_data->element_values[CONTROL_POSITION_HINTS].parsed_value))
178          {
179             printf ("      SWITCH       %s\n",
180                  (char *) switch_data->element_values[0].parsed_value);
181
182             switch_position = POSITION_LAST;
183
184             for (k = 0; k < switch_data->control_data_count; k++)
185             {
186                 switch_control_data = switch_data->control_data[k];
187
188                 printf ("         CONTROL       %s\n", (char *)
189                         switch_control_data->element_values[0].parsed_value);
190
191             }
192          }
193
194          printf ("      CONTROL %s\n",
195                  (char *) control_data->element_values[0].parsed_value);
196
197          if (control_data->subpanel_data != NULL)
198          {
199             subpanel_data = control_data->subpanel_data;
200
201             printf("         SUBPANEL   %s\n", (char *)
202                     subpanel_data->element_values[0].parsed_value);
203       
204             for (k = 0; k < subpanel_data->control_data_count; k++)
205             {
206                 control_data = subpanel_data->control_data[k];
207
208                 printf ("               CONTROL %s\n", (char *)
209                         control_data->element_values[0].parsed_value);
210             }
211          }
212       }
213    }
214 }
215
216
217
218
219 /************************************************************************
220  *
221  *  The main program for the fron panel print function.
222  *
223  ************************************************************************/
224
225 void
226 main (int argc,
227       char         **argv)
228
229
230 {
231     XtAppContext    appContext;
232     Widget              widget;
233
234    /* This call is required to have values to pass to DtAppInitialize */
235     widget = XtAppInitialize( &appContext, "Dtfplist",
236                               NULL, 0, &argc, argv, NULL, NULL, 0);
237
238    /* This is required initialization so that FrontPanelReadDatabases()
239     * procedure complete successfully.
240     */
241     DtAppInitialize( appContext, XtDisplay(widget), widget,
242                      argv[0], (char *)szWM_TOOL_CLASS);
243
244     
245    /* Load the database for use in printing. If it is able to load print
246     * contents of front panel.
247     */
248     DtDbLoad();
249
250     panel.app_name = strdup(argv[0]);
251     if (FrontPanelReadDatabases ())
252     {
253       /* Print out the contents of the .fp database */
254        PrintFrontPanelContents ();
255     }
256     else
257     {
258       /* NEEDS TO BE LOCALIZED */
259        printf ("PANEL not found. Error in reading database.\n");
260     }
261
262 }