FreeWRL/FreeX3D  3.0.0
main.c
1 
2 /****************************************************************************
3  This file is part of the FreeWRL/FreeX3D Distribution.
4 
5  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
6 
7  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
19 ****************************************************************************/
20 
21 
22 /* put a string on the console. This is fork'd by FreeWRL for error messages,
23  * because when running within an HTML browser, error messages to the command
24  * line get lost.
25  */
26 
27 /* our defines for this build */
28 # include <config.h>
29 
30 // OLD_IPHONE_AQUA #if !defined(TARGET_AQUA)
31 #include "system.h"
32 
33 #define MESG "something strange happened with\nthe FreeWRL console..."
34 #define WINTITLE "FreeWRL X3D/VRML Console:"
35 #define MINTITLE "FreeWRL Console:"
36 #define MAXLINE 2000
37 
38 /* Define an application context */
39 XtAppContext app_context;
40 
41 /* Define the widgets */
42 Widget top, mainBox, messageText, dismissButton;
43 
44 char inLine[MAXLINE];
45 
46 /* what to do when the user hits the dismiss button */
47 void dismiss_proc (Widget w, XtPointer client_data, XtPointer call_data) {
48  XtDestroyApplicationContext(app_context);
49  exit (0);
50 }
51 
52 int main(int argc, char **argv) {
53 
54  if (argc > 1) {
55  strncpy (inLine,argv[1],strlen(argv[1]));
56  } else {
57  strncpy (inLine,MESG,strlen(MESG));
58  }
59 
60  /* Create the application shell widget */
61  top = XtVaAppInitialize(&app_context, "XViewfile", NULL, 0, &argc, argv, NULL,
62  XtNtitle,WINTITLE,
63  XtNiconName,MINTITLE,
64  NULL);
65 
66  /* Create a box to hold everything */
67  mainBox = XtVaCreateManagedWidget("mainBox", boxWidgetClass, top,
68  NULL);
69 
70  /* Create a read only, scrollable text widget, to display the text */
71  messageText = XtVaCreateManagedWidget("messageText", asciiTextWidgetClass,
72  mainBox,
73  XtNheight, 100,
74  XtNwidth, 400,
75  XtNtype, XawAsciiString,
76  XtNscrollVertical, XawtextScrollAlways,
77  XtNscrollHorizontal, XawtextScrollWhenNeeded,
78  XtNstring, inLine,
79  XtNlength, strlen(inLine),
80  NULL);
81 
82 
83  /* Create a file button and file menu, with open & dismiss selections */
84  dismissButton = XtVaCreateManagedWidget("dismiss_button", commandWidgetClass,
85  mainBox, XtNlabel, "Dismiss", NULL);
86 
87 
88  /* Tie in the callbacks */
89  XtAddCallback(dismissButton,XtNcallback, dismiss_proc, NULL);
90  XtRealizeWidget(top);
91  XtAppMainLoop(app_context);
92  return 0;
93 }
94 // OLD_IPHONE_AQUA #endif