ksh: fix up shipin for more modern systems WRT test and wc
[oweals/cde.git] / cde / examples / dtprint / MainWindow.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: MainWindow.c /main/3 1996/05/09 03:39:51 drk $ */
24 #include "PrintDemo.h"
25
26 /*
27  * static function declarations
28  */
29 static void MainWindow_createMenuBar(MainWindow* me);
30 static void MainWindow_createToolBar(MainWindow* me);
31
32 /*
33  * ------------------------------------------------------------------------
34  * Name: MainWindow_new
35  *
36  * Description:
37  *
38  *     Creates the main window of the DtPrint demo program.
39  *
40  * Return value:
41  *
42  *     A pointer to a new MainWindow structure.
43  *
44  */
45 MainWindow*
46 MainWindow_new(Widget parent)
47 {
48     MainWindow* me =  (MainWindow*)XtCalloc(1, sizeof(MainWindow));
49     /*
50      * create the main window
51      */
52     me->widget =
53         XtVaCreateWidget("MainWindow",
54                          xmMainWindowWidgetClass,
55                          parent,
56                          NULL);
57     /*
58      * create the menu bar and tool bar
59      */
60     MainWindow_createMenuBar(me);
61     MainWindow_createToolBar(me);
62     /*
63      * return
64      */
65     return me;
66 }
67
68 /*
69  * ------------------------------------------------------------------------
70  * Name: MainWindow_createMenuBar
71  *
72  * Description:
73  *
74  *     Creates the menu bar for the main window of the DtPrint demo
75  *     program.
76  *
77  */
78 static void
79 MainWindow_createMenuBar(MainWindow* me)
80 {
81     Widget file_menu;
82     Widget menu_bar;
83     XmString label;
84     Widget w;
85     /*
86      * create the menu bar
87      */
88     menu_bar = XmCreateMenuBar(me->widget, "MenuBar", NULL, 0);
89     /*
90      * create the file menu
91      */
92     file_menu = XmCreatePulldownMenu(menu_bar, "FileMenu", NULL, 0);
93     /*
94      * create the file menu cascade button
95      */
96     label = XmStringCreateLocalized("File");
97     XtVaCreateManagedWidget("FileCascade",
98                             xmCascadeButtonGadgetClass,
99                             menu_bar,
100                             XmNsubMenuId, file_menu,
101                             XmNlabelString, label,
102                             NULL);
103     XmStringFree(label);
104     /*
105      * create the "Print..." file menu item
106      */
107     label = XmStringCreateLocalized("Print...");
108     me->print_menu_button =
109         XtVaCreateManagedWidget("PrintButton",
110                                 xmPushButtonWidgetClass,
111                                 file_menu,
112                                 XmNlabelString, label,
113                                 NULL);
114     XmStringFree(label);
115     /*
116      * separator
117      */
118     XtVaCreateManagedWidget("", xmSeparatorGadgetClass, file_menu, NULL);
119     /*
120      * "Exit" button
121      */
122     label = XmStringCreateLocalized("Exit");
123     me->exit_button =
124         XtVaCreateManagedWidget("ExitButton",
125                                 xmPushButtonWidgetClass,
126                                 file_menu,
127                                 XmNlabelString, label,
128                                 NULL);
129     XmStringFree(label);
130     /*
131      * manage the menu bar and return it
132      */
133     XtManageChild(menu_bar);
134 }
135
136 /*
137  * ------------------------------------------------------------------------
138  * Name: MainWindow_createToolBar
139  *
140  * Description:
141  *
142  *     Creates a simple tool bar for the main window of the DtPrint demo
143  *     program.
144  *
145  */
146 static void
147 MainWindow_createToolBar(MainWindow* me)
148 {
149     Widget row;
150     XmString label;
151
152     row = XtVaCreateManagedWidget(
153                                   "ToolBarRow",
154                                   xmRowColumnWidgetClass,
155                                   me->widget,
156                                   XmNorientation, XmHORIZONTAL,
157                                   XmNscrolledWindowChildType, XmCOMMAND_WINDOW,
158                                   NULL);
159     /*
160      * create just the "quick print" button
161      */
162     label = XmStringCreateLocalized("Quick Print");
163     me->quick_print_button =
164         XtVaCreateManagedWidget("QuickPrintButton",
165                                 xmPushButtonWidgetClass,
166                                 row,
167                                 XmNlabelString, label,
168                                 NULL);
169     XmStringFree(label);
170 }