optionsCB.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. /* $XConsortium: optionsCB.c /main/3 1995/11/01 10:39:09 rswiston $ */
  24. /**********************************<+>*************************************
  25. ***************************************************************************
  26. **
  27. ** File: optionsCB.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 [Options] 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. * OverstrikeCB - set Editor widget overstike and "Options" menu
  58. * "Overstrike" radio button state based on value passed in
  59. * call_data->set.
  60. *
  61. * NOTE: The default overstrike state for the entire (pPad) edit
  62. * session is also reset.
  63. ************************************************************************/
  64. /* ARGSUSED */
  65. void
  66. OverstrikeCB(
  67. Widget w,
  68. caddr_t client_data,
  69. caddr_t call_data)
  70. {
  71. Arg al[1];
  72. Editor *pPad = (Editor *)client_data;
  73. XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
  74. call_data;
  75. XtSetArg(al[0], DtNoverstrike, (Boolean) cb->set);
  76. XtSetValues(pPad->editor, al, 1);
  77. pPad->xrdb.overstrike = (Boolean) cb->set; /* reset edit session default */
  78. }
  79. /************************************************************************
  80. * WordWrapCB - set Editor widget word wrap state and the default state
  81. * for the new line radio button in the "Save As" File menu dialog
  82. * based on value passed in call_data->set.
  83. *
  84. * NOTE: The default word wrap state for the entire (pPad) edit
  85. * session is also reset.
  86. ************************************************************************/
  87. /* ARGSUSED */
  88. void
  89. WordWrapCB(
  90. Widget w,
  91. caddr_t client_data,
  92. caddr_t call_data)
  93. {
  94. Arg al[1];
  95. Editor *pPad = (Editor *)client_data;
  96. XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
  97. call_data;
  98. SaveAs *pSaveAs = &pPad->fileStuff.fileWidgets.saveAs;
  99. Select *pSelect = &pPad->fileStuff.fileWidgets.select;
  100. XtSetArg(al[0], DtNwordWrap, (Boolean) cb->set);
  101. XtSetValues(pPad->editor, al, 1);
  102. pPad->xrdb.wordWrap = (Boolean) cb->set; /* reset edit session default */
  103. /* -----> set the default state for the "add new lines?" radio boxes in the
  104. * "Save As" file selection box and the "Save" prompt dialog
  105. * (these radio boxes are included only if word wrap is on) */
  106. if (pSaveAs->toggleWidgets.newl_radio != (Widget) 0) {
  107. if (pPad->xrdb.wordWrap == True) {
  108. XtManageChild(pSaveAs->toggleWidgets.newl_radio);
  109. } else {
  110. XtUnmanageChild(pSaveAs->toggleWidgets.newl_radio);
  111. }
  112. }
  113. if (pSelect->toggleWidgets.newl_radio != (Widget) 0) {
  114. if (pPad->xrdb.wordWrap == True) {
  115. XtManageChild(pSelect->separator);
  116. XtManageChild(pSelect->toggleWidgets.newl_radio);
  117. } else {
  118. XtUnmanageChild(pSelect->separator);
  119. XtUnmanageChild(pSelect->toggleWidgets.newl_radio);
  120. }
  121. }
  122. }
  123. /************************************************************************
  124. * StatusLineCB - set Editor widget statusLine based on value passed in
  125. * call_data->set.
  126. *
  127. * NOTE: The default statusLine state for the entire (pPad) edit
  128. * session is also reset.
  129. ************************************************************************/
  130. /* ARGSUSED */
  131. void
  132. StatusLineCB(
  133. Widget w,
  134. caddr_t client_data,
  135. caddr_t call_data)
  136. {
  137. Arg al[1];
  138. Editor *pPad = (Editor *)client_data;
  139. XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
  140. call_data;
  141. XtSetArg(al[0], DtNshowStatusLine, (Boolean) cb->set);
  142. XtSetValues(pPad->editor, al, 1);
  143. pPad->xrdb.statusLine = (Boolean) cb->set; /* reset edit session default */
  144. /* Reset the resize increment and minimum window size properties. */
  145. SetAppShellResizeHints(pPad);
  146. }