dthelp: Remove spectaculaly obsolete MSDOS support
[oweals/cde.git] / cde / programs / dtpad / formatCB.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 libraries 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 /* $TOG: formatCB.c /main/5 1999/09/15 14:29:27 mgreess $ */
24 /**********************************<+>*************************************
25 ***************************************************************************
26 **
27 **  File:        formatCB.c
28 **
29 **  Project:     DT dtpad, a memo maker type editor based on the Dt Editor
30 **               widget.
31 **
32 **  Description:
33 **  -----------
34 **
35 **       This file contains the callbacks for the [Format] menu items.
36 **
37 *******************************************************************
38 **  (c) Copyright Hewlett-Packard Company, 1991, 1992.  All rights are
39 **  reserved.  Copying or other reproduction of this program
40 **  except for archival purposes is prohibited without prior
41 **  written consent of Hewlett-Packard Company.
42 ********************************************************************
43 **
44 ********************************************************************
45 **  (c) Copyright 1993, 1994 Hewlett-Packard Company
46 **  (c) Copyright 1993, 1994 International Business Machines Corp.
47 **  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
48 **  (c) Copyright 1993, 1994 Novell, Inc.
49 ********************************************************************
50 **
51 **
52 **************************************************************************
53 **********************************<+>*************************************/
54 #include "dtpad.h"
55 /* #include <Dt/HourGlass.h> */
56
57 /************************************************************************
58  * FormatCB - [Format] menu, [Settings...] button
59  ************************************************************************/
60 /* ARGSUSED */
61 void
62 FormatCB(
63         Widget w,
64         caddr_t client_data,
65         caddr_t call_data)
66 {
67     Editor *pPad = (Editor *) client_data;
68     DtEditorInvokeFormatDialog(pPad->editor);
69 }
70
71
72 /************************************************************************
73  * FormatParaCB - [Format] menu, [Paragraph] button
74  ************************************************************************/
75 /* ARGSUSED */
76 void
77 FormatParaCB(
78         Widget w,
79         caddr_t client_data,
80         caddr_t call_data)
81 {
82     Editor              *pPad = (Editor *) client_data;
83     DtEditorErrorCode    error = DtEDITOR_NO_ERRORS;
84
85     error = DtEditorFormat(pPad->editor, NULL, DtEDITOR_FORMAT_PARAGRAPH);
86     if (DtEDITOR_NO_ERRORS != error)
87     {
88         switch(error)
89         {
90             case DtEDITOR_INSUFFICIENT_MEMORY:
91                 Warning(
92                         pPad,
93                         (char *) GETMESSAGE(5, 47, "Operation failed due to insufficient memory.\nTry increasing swap space."),
94                         XmDIALOG_ERROR);
95                 return;
96             default:
97                 Warning(
98                         pPad,
99                         (char *) GETMESSAGE(5, 48, "Format operation failed."),
100                         XmDIALOG_ERROR);
101                 return;
102         }
103     }
104 }
105
106
107 /************************************************************************
108  * FormatAllCB - [Format] menu, [All] button
109  ************************************************************************/
110 /* ARGSUSED */
111 void
112 FormatAllCB(
113         Widget w,
114         caddr_t client_data,
115         caddr_t call_data)
116 {
117     Editor              *pPad = (Editor *)client_data;
118     DtEditorErrorCode    error = DtEDITOR_NO_ERRORS;
119
120     error = DtEditorFormat(pPad->editor, NULL, DtEDITOR_FORMAT_ALL);
121     if (DtEDITOR_NO_ERRORS != error)
122     {
123         switch(error)
124         {
125             case DtEDITOR_INSUFFICIENT_MEMORY:
126                 Warning(
127                         pPad,
128                         (char *) GETMESSAGE(5, 47, "Operation failed due to insufficient memory.\nTry increasing swap space."),
129                         XmDIALOG_ERROR);
130                 return;
131             default:
132                 Warning(
133                         pPad,
134                         (char *) GETMESSAGE(5, 48, "Format operation failed."),
135                         XmDIALOG_ERROR);
136                 return;
137         }
138     }
139 }