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: AppSpecific.c /main/4 1996/05/09 03:39:11 drk $ */
24 #include "PrintDemo.h"
27 * ------------------------------------------------------------------------
32 * Allocates a new AppObject data structure. If parent is non-NULL,
33 * an application-specific main window work region is created.
37 * A pointer to the new AppObject structure.
40 #define LABEL_FMTSTR "Filename: %s Size: %d"
43 ReadFile(char * filename, int * filesize)
49 if ((file = fopen(filename, "r")) == NULL) return NULL ;
51 fseek(file, 0L, SEEK_END);
52 *filesize = ftell(file);
55 buffer = (char *) malloc(*filesize+1);
56 if (fread(buffer, 1, *filesize, file) == *filesize ) {
57 buffer[*filesize] = '\0';
70 AppObject* me = (AppObject*)XtCalloc(1, sizeof(AppObject));
73 me->main_window = parent ;
75 if(file_name != (String)NULL)
76 me->file_name = XtNewString(file_name);
78 me->file_name = XtNewString("README.txt");
80 me->file_buffer = ReadFile(me->file_name, &filesize);
81 if (me->file_buffer == NULL) {
82 me->file_buffer = XtNewString("abcdefghijklmnopqrstuvwxyz");
83 filesize = strlen("abcdefghijklmnopqrstuvwxyz");
86 if(parent != (Widget)NULL)
91 buf = XtCalloc(strlen(LABEL_FMTSTR)+strlen(me->file_name)+10,
93 sprintf(buf, LABEL_FMTSTR, me->file_name, filesize);
94 label = XmStringCreateLocalized(buf);
97 XtVaCreateManagedWidget("AppWorkArea",
100 XmNlabelString, label,
109 * ------------------------------------------------------------------------
110 * Name: AppObject_customizePrintSetupBox
114 * Adds application specific items to the passed print setup box.
116 * The document file name is presented in the top work area.
124 AppObject_customizePrintSetupBox(
132 * create the app-specific top work area
134 XtVaSetValues(print_dialog,
135 DtNworkAreaLocation, DtWORK_AREA_TOP,
137 row = XtVaCreateManagedWidget(
139 xmRowColumnWidgetClass,
141 XmNorientation, XmHORIZONTAL,
144 * create the document name label
146 label = XmStringCreateLocalized("Document:");
147 w = XtVaCreateManagedWidget("DocumentNameLabel",
150 XmNlabelString, label,
154 * create the document name
156 label = XmStringCreateLocalized(me->file_name);
157 w = XtVaCreateManagedWidget("DocumentName",
160 XmNlabelString, label,