PageRenderTime 56ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/www/documentation/opendylan/dguide/dguid_33.htm

https://github.com/dylan-hackers/temporary_complete_dylan_repo
HTML | 206 lines | 192 code | 12 blank | 2 comment | 0 complexity | ba9d36d23500eb893dd140ab4463b174 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <HTML>
  3. <!-- Generated by Harlequin WebMaker 3.0.2 ( 8-May-1997) -->
  4. <HEAD>
  5. <LINK REL=TOP HREF="dguide_1.htm">
  6. <LINK REL=UP HREF="dguid_28.htm">
  7. <LINK REL=PREV HREF="dguid_32.htm">
  8. <LINK REL=NEXT HREF="dguid_34.htm">
  9. <TITLE>4.3 Gluing the final design together</TITLE>
  10. <META NAME=GENERATOR CONTENT="Harlequin WebMaker 3.0.2 ( 8-May-1997)">
  11. </HEAD>
  12. <BODY BGCOLOR="#FEFEF2" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
  13. <DIV>
  14. <A NAME=HEADING33></A>
  15. <DIV>
  16. <P><A HREF="dguid_34.htm"><IMG ALIGN=BOTTOM SRC=next.gif ALT=Next BORDER=0></A> <A HREF="dguid_32.htm"><IMG ALIGN=BOTTOM SRC=prev.gif ALT=Previous BORDER=0></A> <A HREF="dguid_28.htm"><IMG ALIGN=BOTTOM SRC=up.gif ALT=Up BORDER=0></A> <A HREF="dguide_1.htm"><IMG ALIGN=BOTTOM SRC=top.gif ALT=Top BORDER=0></A> <A HREF="dguide_2.htm"><IMG ALIGN=BOTTOM SRC=content.gif ALT=Contents BORDER=0></A> <A HREF="dgui_110.htm"><IMG ALIGN=BOTTOM SRC=index.gif ALT=Index BORDER=0></A></P>
  17. <P>4 Adding Menus To The Application</P>
  18. </DIV>
  19. <A NAME=HEADING33-0></A>
  20. <A NAME=UID-menus-889892></A>
  21. <H1>4.3 <A NAME=MARKER-2-210></A><A NAME=MARKER-9-211></A>Gluing the final design together</H1>
  22. <P>You can now add the definitions of the menu bar, menus, and menu buttons, to the definition of the <CODE>&lt;task-frame&gt;</CODE> class, to give the code shown below. At this stage, the only thing missing from the final application are real callback functions. Callbacks are dealt with in <A HREF="dguid_34.htm#MARKER-9-245">Chapter 5, "Adding Callbacks to the Application"</A>.</P>
  23. <P>Note that the final definition of <CODE>&lt;task-frame&gt;</CODE> includes the definition of a slot: <CODE>frame-task-list</CODE>. This takes an instance of the class <CODE>&lt;task-list&gt;</CODE> as a value, the default value being an empty <CODE>&lt;task-list&gt;</CODE>. Although it has not been referred to so far, this class will be used as the basic data structure in which task lists are stored, and a more complete description of these data structures is given in <A HREF="dguid_35.htm#MARKER-9-247">Section 5.1 on page 42</A>. It transpires that defining the <CODE>frame-task-list</CODE> slot is essential for some of the file handling routines that are described in <A HREF="dguid_38.htm#MARKER-9-258">Section 5.3.1 on page 48</A>.</P>
  24. <PRE>
  25. <A NAME=MARKER-10-212></A>define frame &lt;task-frame&gt; (&lt;simple-frame&gt;)
  26. slot frame-task-list :: &lt;task-list&gt; = make(&lt;task-list&gt;);
  27. // definition of menu bar
  28. pane task-menu-bar (frame)
  29. make(&lt;menu-bar&gt;,
  30. children: vector(frame.file-menu,
  31. frame.edit-menu,
  32. frame.task-menu,
  33. frame.help-menu));
  34. <P></P>
  35. // definition of menus
  36. pane file-menu (frame)
  37. make(&lt;menu&gt;, label: &quot;File&quot;,
  38. children: vector(frame.open-menu-button,
  39. frame.save-menu-button,
  40. frame.save-as-menu-button,
  41. frame.exit-menu-button));
  42. <P></P>
  43. pane edit-menu (frame)
  44. make(&lt;menu&gt;, label: &quot;Edit&quot;,
  45. children: vector(frame.cut-menu-button,
  46. frame.copy-menu-button,
  47. frame.paste-menu-button));
  48. <P></P>
  49. pane task-menu (frame)
  50. make(&lt;menu&gt;, label: &quot;Task&quot;,
  51. children: vector(frame.add-menu-button,
  52. frame.remove-menu-button));
  53. <P></P>
  54. pane help-menu (frame)
  55. make(&lt;menu&gt;, label: &quot;Help&quot;,
  56. children: vector(frame.about-menu-button));
  57. <P></P>
  58. // definition of menu buttons
  59. // Commands in the File menu
  60. pane open-menu-button (frame)
  61. make(&lt;menu-button&gt;, label: &quot;Open...&quot;,
  62. activate-callback: not-yet-implemented,
  63. accelerator: make-keyboard-gesture(#&quot;o&quot;, #&quot;control&quot;),
  64. documentation: &quot;Opens an existing file.&quot;);
  65. pane save-menu-button (frame)
  66. make(&lt;menu-button&gt;, label: &quot;Save&quot;,
  67. activate-callback: not-yet-implemented,
  68. accelerator: make-keyboard-gesture(#&quot;s&quot;, #&quot;control&quot;),
  69. documentation: &quot;Saves the current file to disk.&quot;);
  70. pane save-as-menu-button (frame)
  71. make(&lt;menu-button&gt;, label: &quot;Save As...&quot;,
  72. activate-callback: save-as-file,
  73. documentation:
  74. &quot;Saves the current file with a new name.&quot;);
  75. pane exit-menu-button (frame)
  76. make(&lt;menu-button&gt;, label: &quot;Exit&quot;,
  77. activate-callback: not-yet-implemented,
  78. accelerator: make-keyboard-gesture(#&quot;f4&quot;, #&quot;alt&quot;),
  79. documentation: &quot;Exits the application.&quot;);
  80. <P></P>
  81. //Commands in the Edit menu
  82. pane cut-menu-button (frame)
  83. make(&lt;menu-button&gt;, label: &quot;Cut&quot;,
  84. activate-callback: not-yet-implemented,
  85. accelerator: make-keyboard-gesture(#&quot;x&quot;, #&quot;control&quot;),
  86. documentation: &quot;Cut the selection to the clipboard.&quot;);
  87. pane copy-menu-button (frame)
  88. make(&lt;menu-button&gt;, label: &quot;Copy&quot;,
  89. activate-callback: not-yet-implemented,
  90. accelerator: make-keyboard-gesture(#&quot;c&quot;, #&quot;control&quot;),
  91. documentation: &quot;Copy the selection to the clipboard.&quot;);
  92. pane paste-menu-button (frame)
  93. make(&lt;menu-button&gt;, label: &quot;Paste&quot;,
  94. activate-callback: not-yet-implemented,
  95. accelerator: make-keyboard-gesture(#&quot;v&quot;, #&quot;control&quot;),
  96. documentation:
  97. &quot;Paste the selection in the clipboard at the current position.&quot;);
  98. //Commands in the Task menu
  99. pane add-menu-button (frame)
  100. make(&lt;menu-button&gt;, label: &quot;Add...&quot;,
  101. activate-callback: not-yet-implemented,
  102. accelerator: make-keyboard-gesture
  103. (#&quot;a&quot;, #&quot;control&quot;, #&quot;shift&quot;),
  104. documentation: &quot;Add a new task.&quot;);
  105. pane remove-menu-button (frame)
  106. make(&lt;menu-button&gt;, label: &quot;Remove&quot;,
  107. activate-callback: not-yet-implemented,
  108. accelerator: make-keyboard-gesture
  109. (#&quot;d&quot;, #&quot;control&quot;, #&quot;shift&quot;),
  110. documentation:
  111. &quot;Remove the selected task from the list.&quot;);
  112. <P></P>
  113. //Commands in the Help menu
  114. pane about-menu-button (frame)
  115. make(&lt;menu-button&gt;, label: &quot;About&quot;,
  116. activate-callback: not-yet-implemented,
  117. accelerator: make-keyboard-gesture(#&quot;f1&quot;),
  118. documentation:
  119. &quot;Display information about the application.&quot;);
  120. <P></P>
  121. // definition of buttons
  122. pane add-button (frame)
  123. make(&lt;push-button&gt;, label: &quot;Add task&quot;,
  124. activate-callback: not-yet-implemented);
  125. pane remove-button (frame)
  126. make(&lt;push-button&gt;, label: &quot;Remove task&quot;,
  127. activate-callback: not-yet-implemented);
  128. pane open-button (frame)
  129. make(&lt;push-button&gt;, label: &quot;Open file&quot;,
  130. activate-callback: not-yet-implemented);
  131. pane save-button (frame)
  132. make(&lt;push-button&gt;, label: &quot;Save file&quot;,
  133. activate-callback: not-yet-implemented);
  134. <P></P>
  135. // definition of radio box
  136. pane priority-box (frame)
  137. make (&lt;radio-box&gt;,
  138. items: $priority-items,
  139. orientation: #&quot;horizontal&quot;,
  140. label-key: first,
  141. value-key: second,
  142. value: #&quot;medium&quot;,
  143. activate-callback: not-yet-implemented);
  144. <P></P>
  145. // definition of tool bar
  146. pane task-tool-bar (frame)
  147. make(&lt;tool-bar&gt;,
  148. child: horizontally ()
  149. frame.open-button;
  150. frame.save-button;
  151. frame.add-button;
  152. frame.remove-button
  153. end);
  154. <P></P>
  155. // definition of status bar
  156. pane task-status-bar (frame)
  157. make(&lt;status-bar&gt;, label: &quot;Task Manager&quot;);
  158. <P></P>
  159. // definition of list
  160. pane task-list (frame)
  161. make (&lt;list-box&gt;, items: #(), lines: 15,
  162. activate-callback: not-yet-implemented);
  163. <P></P>
  164. // main layout
  165. pane task-layout (frame)
  166. vertically ()
  167. frame.task-list;
  168. frame.priority-box;
  169. end;
  170. <P></P>
  171. // activation of frame elements
  172. layout (frame) frame.task-layout;
  173. tool-bar (frame) frame.task-tool-bar;
  174. status-bar (frame) frame.task-status-bar;
  175. menu-bar (frame) frame.task-menu-bar;
  176. <P></P>
  177. // frame title
  178. keyword title: = &quot;Task List Manager&quot;;
  179. end frame &lt;task-frame&gt;;
  180. <P></P>
  181. </PRE>
  182. <P></P>
  183. <A NAME=LINK-menus-lastpage></A><A NAME=LINK-callbacks-firstpage></A><!-- FM pgf ignored -->
  184. </DIV>
  185. <DIV>
  186. <DIV>
  187. <!-- TOC -->
  188. </DIV>
  189. <HR>
  190. <ADDRESS>Building Applications Using DUIM - 26 May 1999</ADDRESS>
  191. <P><A HREF="dguid_34.htm"><IMG ALIGN=BOTTOM SRC=next.gif ALT=Next BORDER=0></A> <A HREF="dguid_32.htm"><IMG ALIGN=BOTTOM SRC=prev.gif ALT=Previous BORDER=0></A> <A HREF="dguid_28.htm"><IMG ALIGN=BOTTOM SRC=up.gif ALT=Up BORDER=0></A> <A HREF="dguide_1.htm"><IMG ALIGN=BOTTOM SRC=top.gif ALT=Top BORDER=0></A> <A HREF="dguide_2.htm"><IMG ALIGN=BOTTOM SRC=content.gif ALT=Contents BORDER=0></A> <A HREF="dgui_110.htm"><IMG ALIGN=BOTTOM SRC=index.gif ALT=Index BORDER=0></A></P>
  192. </DIV>
  193. </BODY>
  194. </HTML>