MainWindow.c 4.3 KB

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