muihelper.pas 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005 Karoly Balogh
  4. MUI helper functions for MorphOS/PowerPC
  5. Based on work of Nils Sjoholm member of the Amiga RTL
  6. development team.
  7. MorphOS port was done on a free Pegasos II/G4 machine
  8. provided by Genesi S.a.r.l. <www.genesi.lu>
  9. See the file COPYING.FPC, included in this distribution,
  10. for details about the copyright.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. **********************************************************************}
  15. unit muihelper;
  16. interface
  17. uses intuition, mui, doslib, utility;
  18. const
  19. NoFrame = MUIV_Frame_None;
  20. ButtonFrame = MUIV_Frame_Button;
  21. ImageButtonFrame = MUIV_Frame_ImageButton;
  22. TextFrame = MUIV_Frame_Text;
  23. StringFrame = MUIV_Frame_String;
  24. ReadListFrame = MUIV_Frame_ReadList;
  25. InputListFrame = MUIV_Frame_InputList;
  26. PropFrame = MUIV_Frame_Prop;
  27. SliderFrame = MUIV_Frame_Slider;
  28. GaugeFrame = MUIV_Frame_Gauge;
  29. VirtualFrame = MUIV_Frame_Virtual;
  30. GroupFrame = MUIV_Frame_Group;
  31. const
  32. Child = MUIA_Group_Child;
  33. SubWindow = MUIA_Application_Window;
  34. WindowContents = MUIA_Window_RootObject;
  35. // Creates a MUI application
  36. function MH_Application(tags: array of LongWord): pObject_;
  37. function MH_Application(var app; tags: array of LongWord): pObject_;
  38. // Creates a MUI window
  39. function MH_Window(tags: array of LongWord): pObject_;
  40. function MH_Window(var win; tags: array of LongWord): pObject_;
  41. // Creates a MUI button
  42. function MH_MakeButton(blabel: pchar): pObject_;
  43. function MH_MakeButton(var button; blabel: pchar): pObject_;
  44. // Creates a MUI HBar
  45. function MH_MakeHBar(space: longword): pObject_;
  46. function MH_MakeHBar(var hbar; space: longword): pObject_;
  47. // Creates MUI V/HGroup
  48. function MH_VGroup(tags: array of LongWord): pObject_;
  49. function MH_VGroup(frame: longword; tags: array of LongWord): pObject_;
  50. function MH_VGroup(title: PChar; tags: array of LongWord): pObject_;
  51. function MH_HGroup(tags: array of LongWord): pObject_;
  52. function MH_HGroup(frame: longword; tags: array of LongWord): pObject_;
  53. function MH_HGroup(title: PChar; tags: array of LongWord): pObject_;
  54. // Creates MUI Col/RowGroup
  55. function MH_ColGroup(cols: longword; tags: array of LongWord): pObject_;
  56. function MH_ColGroup(cols: longword; frame: longword; tags: array of LongWord): pObject_;
  57. function MH_ColGroup(cols: longword; title: PChar; tags: array of LongWord): pObject_;
  58. function MH_RowGroup(rows: longword; tags: array of LongWord): pObject_;
  59. function MH_RowGroup(rows: longword; frame: longword; tags: array of LongWord): pObject_;
  60. function MH_RowGroup(rows: longword; title: PChar; tags: array of LongWord): pObject_;
  61. // Creates a MUI Text area
  62. function MH_Text(contents: PChar): pObject_;
  63. function MH_Text(contents: PChar; tags: array of LongWord): pObject_;
  64. function MH_Text(var text_; contents: PChar): pObject_;
  65. function MH_Text(var text_; contents: PChar; tags: array of LongWord): pObject_;
  66. implementation
  67. // Creates a MUI application
  68. // ************************************************************************
  69. function MH_Application(tags: array of LongWord): pObject_;
  70. begin
  71. MH_Application:=MUI_NewObject(MUIC_Application, tags);
  72. end;
  73. function MH_Application(var app; tags: array of LongWord): pObject_;
  74. begin
  75. pObject_(app):=MUI_NewObject(MUIC_Application, tags);
  76. MH_Application:=pObject_(app);
  77. end;
  78. // Creates a MUI window
  79. // ************************************************************************
  80. function MH_Window(tags: array of LongWord): pObject_;
  81. begin
  82. MH_Window:=MUI_NewObject(MUIC_Window, tags);
  83. end;
  84. function MH_Window(var win; tags: array of LongWord): pObject_;
  85. begin
  86. pObject_(win):=MUI_NewObject(MUIC_Window, tags);
  87. MH_Window:=pObject_(win);
  88. end;
  89. // Creates a MUI button
  90. // ************************************************************************
  91. function MH_MakeButton(blabel: pchar): pObject_;
  92. begin
  93. MH_MakeButton:=MUI_MakeObject(MUIO_Button, [DWord(blabel)]);
  94. end;
  95. function MH_MakeButton(var button; blabel: pchar): pObject_;
  96. begin
  97. pObject_(button):=MUI_MakeObject(MUIO_Button, [DWord(blabel)]);
  98. MH_MakeButton:=pObject_(button);
  99. end;
  100. // Creates a MUI HBar
  101. // ************************************************************************
  102. function MH_MakeHBar(space: longword): pObject_;
  103. begin
  104. MH_MakeHBar:=MUI_MakeObject(MUIO_HBar, [space]);
  105. end;
  106. function MH_MakeHBar(var hbar; space: longword): pObject_;
  107. begin
  108. pObject_(hbar):=MUI_MakeObject(MUIO_HBar, [space]);
  109. MH_MakeHBar:=pObject_(hbar);
  110. end;
  111. // Creates a MUI VGroup
  112. // ************************************************************************
  113. function MH_VGroup(tags: array of LongWord): pObject_;
  114. begin
  115. MH_VGroup:=MUI_NewObject(MUIC_Group, tags);
  116. end;
  117. function MH_VGroup(frame: longword; tags: array of LongWord): pObject_;
  118. begin
  119. MH_VGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Frame, frame, TAG_MORE, DWord(@tags) ] );
  120. end;
  121. function MH_VGroup(title: PChar; tags: array of LongWord): pObject_;
  122. begin
  123. MH_VGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Frame, MUIV_Frame_Group,
  124. MUIA_FrameTitle, longword(title),
  125. MUIA_Background, MUII_GroupBack,
  126. TAG_MORE, DWord(@tags) ]);
  127. end;
  128. // Creates a MUI HGroup
  129. // ************************************************************************
  130. function MH_HGroup(tags: array of LongWord): pObject_;
  131. begin
  132. MH_HGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Horiz, MUI_TRUE, TAG_MORE, DWord(@tags) ]);
  133. end;
  134. function MH_HGroup(frame: longword; tags: array of LongWord): pObject_;
  135. begin
  136. MH_HGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Horiz, MUI_TRUE,
  137. MUIA_Frame, frame,
  138. TAG_MORE, DWord(@tags) ] );
  139. end;
  140. function MH_HGroup(title: PChar; tags: array of LongWord): pObject_;
  141. begin
  142. MH_HGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Horiz, MUI_TRUE,
  143. MUIA_Frame, MUIV_Frame_Group,
  144. MUIA_FrameTitle, longword(title),
  145. MUIA_Background, MUII_GroupBack,
  146. TAG_MORE, DWord(@tags) ]);
  147. end;
  148. // Creates MUI ColGroup
  149. // ************************************************************************
  150. function MH_ColGroup(cols: longword; tags: array of LongWord): pObject_;
  151. begin
  152. MH_ColGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Columns, cols, TAG_MORE, DWord(@tags) ]);
  153. end;
  154. function MH_ColGroup(cols: longword; frame: longword; tags: array of LongWord): pObject_;
  155. begin
  156. MH_ColGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Columns, cols,
  157. MUIA_Frame, frame,
  158. TAG_MORE, DWord(@tags) ]);
  159. end;
  160. function MH_ColGroup(cols: longword; title: PChar; tags: array of LongWord): pObject_;
  161. begin
  162. MH_ColGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Columns, cols,
  163. MUIA_Frame, MUIV_Frame_Group,
  164. MUIA_FrameTitle, longword(title),
  165. MUIA_Background, MUII_GroupBack,
  166. TAG_MORE, DWord(@tags) ]);
  167. end;
  168. // Creates MUI RowGroup
  169. // ************************************************************************
  170. function MH_RowGroup(rows: longword; tags: array of LongWord): pObject_;
  171. begin
  172. MH_RowGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Rows, rows, TAG_MORE, DWord(@tags) ]);
  173. end;
  174. function MH_RowGroup(rows: longword; frame: longword; tags: array of LongWord): pObject_;
  175. begin
  176. MH_RowGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Rows, rows,
  177. MUIA_Frame, frame,
  178. TAG_MORE, DWord(@tags) ]);
  179. end;
  180. function MH_RowGroup(rows: longword; title: PChar; tags: array of LongWord): pObject_;
  181. begin
  182. MH_RowGroup:=MUI_NewObject(MUIC_Group, [ MUIA_Group_Rows, rows,
  183. MUIA_Frame, MUIV_Frame_Group,
  184. MUIA_FrameTitle, longword(title),
  185. MUIA_Background, MUII_GroupBack,
  186. TAG_MORE, DWord(@tags) ]);
  187. end;
  188. // Creates a MUI text area
  189. // ************************************************************************
  190. function MH_Text(contents: PChar): pObject_;
  191. begin
  192. MH_Text:=MUI_NewObject(MUIC_Text,[ MUIA_Text_Contents, DWord(contents), TAG_DONE ]);
  193. end;
  194. function MH_Text(contents: PChar; tags: array of LongWord): pObject_;
  195. begin
  196. MH_Text:=MUI_NewObject(MUIC_Text,[ MUIA_Text_Contents, DWord(contents),
  197. TAG_MORE, DWord(@tags) ]);
  198. end;
  199. function MH_Text(var text_; contents: PChar): pObject_;
  200. begin
  201. pObject_(text_):=MUI_NewObject(MUIC_Text,[ MUIA_Text_Contents, DWord(contents), TAG_DONE ]);
  202. MH_Text:=pObject_(text_);
  203. end;
  204. function MH_Text(var text_; contents: PChar; tags: array of LongWord): pObject_;
  205. begin
  206. pObject_(text_):=MUI_NewObject(MUIC_Text,[ MUIA_Text_Contents, DWord(contents),
  207. TAG_MORE, DWord(@tags) ]);
  208. MH_Text:=pObject_(text_);
  209. end;
  210. end.