Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtpad / optionsCB.c
1 /* $XConsortium: optionsCB.c /main/3 1995/11/01 10:39:09 rswiston $ */
2 /**********************************<+>*************************************
3 ***************************************************************************
4 **
5 **  File:        optionsCB.c
6 **
7 **  Project:     DT dtpad, a memo maker type editor based on the Dt Editor
8 **               widget.
9 **
10 **  Description:
11 **  -----------
12 **
13 **      This file contains the callbacks for the [Options] menu items.
14 **
15 *******************************************************************
16 **  (c) Copyright Hewlett-Packard Company, 1991, 1992.  All rights are
17 **  reserved.  Copying or other reproduction of this program
18 **  except for archival purposes is prohibited without prior
19 **  written consent of Hewlett-Packard Company.
20 ********************************************************************
21 **
22 ********************************************************************
23 **  (c) Copyright 1993, 1994 Hewlett-Packard Company
24 **  (c) Copyright 1993, 1994 International Business Machines Corp.
25 **  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
26 **  (c) Copyright 1993, 1994 Novell, Inc.
27 ********************************************************************
28 **
29 **
30 **************************************************************************
31 **********************************<+>*************************************/
32 #include "dtpad.h"
33 #include <Dt/HourGlass.h>
34
35
36 /************************************************************************
37  * OverstrikeCB - set Editor widget overstike and "Options" menu
38  *      "Overstrike" radio button state based on value passed in
39  *      call_data->set.
40  *
41  *        NOTE: The default overstrike state for the entire (pPad) edit
42  *              session is also reset.
43  ************************************************************************/
44 /* ARGSUSED */
45 void
46 OverstrikeCB(
47         Widget w,
48         caddr_t client_data,
49         caddr_t call_data)
50 {
51     Arg al[1];
52     Editor *pPad = (Editor *)client_data;
53     XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *) 
54                                        call_data;
55                                        
56     XtSetArg(al[0], DtNoverstrike, (Boolean) cb->set);
57     XtSetValues(pPad->editor, al, 1);
58     pPad->xrdb.overstrike = (Boolean) cb->set;  /* reset edit session default */
59
60 }
61
62
63 /************************************************************************
64  * WordWrapCB - set Editor widget word wrap state and the default state
65  *      for the new line radio button in the "Save As" File menu dialog
66  *      based on value passed in call_data->set.
67  *
68  *        NOTE: The default word wrap state for the entire (pPad) edit
69  *              session is also reset.
70  ************************************************************************/
71 /* ARGSUSED */
72 void
73 WordWrapCB(
74         Widget w,
75         caddr_t client_data,
76         caddr_t call_data)
77 {
78     Arg al[1];
79     Editor *pPad = (Editor *)client_data;
80     XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *) 
81                                        call_data;
82     SaveAs *pSaveAs = &pPad->fileStuff.fileWidgets.saveAs;
83     Select *pSelect = &pPad->fileStuff.fileWidgets.select;
84
85     XtSetArg(al[0], DtNwordWrap, (Boolean) cb->set);
86     XtSetValues(pPad->editor, al, 1);
87
88     pPad->xrdb.wordWrap = (Boolean) cb->set;    /* reset edit session default */
89
90     /* -----> set the default state for the "add new lines?" radio boxes in the
91      *        "Save As" file selection box and the "Save" prompt dialog
92      *        (these radio boxes are included only if word wrap is on) */
93     if (pSaveAs->toggleWidgets.newl_radio != (Widget) 0) {
94         if (pPad->xrdb.wordWrap == True) {
95             XtManageChild(pSaveAs->toggleWidgets.newl_radio);
96         } else {
97             XtUnmanageChild(pSaveAs->toggleWidgets.newl_radio);
98         }
99     }
100     if (pSelect->toggleWidgets.newl_radio != (Widget) 0) {
101         if (pPad->xrdb.wordWrap == True) {
102             XtManageChild(pSelect->separator);
103             XtManageChild(pSelect->toggleWidgets.newl_radio);
104         } else {
105             XtUnmanageChild(pSelect->separator);
106             XtUnmanageChild(pSelect->toggleWidgets.newl_radio);
107         }
108     }
109
110 }
111
112
113 /************************************************************************
114  * StatusLineCB - set Editor widget statusLine based on value passed in
115  *      call_data->set.
116  *
117  *        NOTE: The default statusLine state for the entire (pPad) edit
118  *              session is also reset.
119  ************************************************************************/
120 /* ARGSUSED */
121 void
122 StatusLineCB(
123         Widget w,
124         caddr_t client_data,
125         caddr_t call_data)
126 {
127     Arg al[1];
128     Editor *pPad = (Editor *)client_data;
129     XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *) 
130                                        call_data;
131                                        
132     XtSetArg(al[0], DtNshowStatusLine, (Boolean) cb->set);
133     XtSetValues(pPad->editor, al, 1);
134     pPad->xrdb.statusLine = (Boolean) cb->set;  /* reset edit session default */
135  
136     /* Reset the resize increment and minimum window size properties. */
137     SetAppShellResizeHints(pPad);
138 }