gadtools.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$PACKRECORDS 2}
  13. unit gadtools;
  14. INTERFACE
  15. uses exec, intuition, agraphics, utility;
  16. {------------------------------------------------------------------------}
  17. { The kinds (almost classes) of gadgets in the toolkit. Use these
  18. identifiers when calling CreateGadgetA() }
  19. CONST
  20. GENERIC_KIND = 0;
  21. BUTTON_KIND = 1;
  22. CHECKBOX_KIND = 2;
  23. INTEGER_KIND = 3;
  24. LISTVIEW_KIND = 4;
  25. MX_KIND = 5;
  26. NUMBER_KIND = 6;
  27. CYCLE_KIND = 7;
  28. PALETTE_KIND = 8;
  29. SCROLLER_KIND = 9;
  30. { Kind number 10 is reserved }
  31. SLIDER_KIND = 11;
  32. STRING_KIND = 12;
  33. TEXT_KIND = 13;
  34. NUM_KINDS = 14;
  35. GADTOOLSNAME : PChar = 'gadtools.library';
  36. {------------------------------------------------------------------------}
  37. { 'Or' the appropriate set together for your Window IDCMPFlags: }
  38. ARROWIDCMP = (IDCMP_GADGETUP + IDCMP_GADGETDOWN +
  39. IDCMP_INTUITICKS + IDCMP_MOUSEBUTTONS);
  40. BUTTONIDCMP = (IDCMP_GADGETUP);
  41. CHECKBOXIDCMP = (IDCMP_GADGETUP);
  42. INTEGERIDCMP = (IDCMP_GADGETUP);
  43. LISTVIEWIDCMP = (IDCMP_GADGETUP + IDCMP_GADGETDOWN +
  44. IDCMP_MOUSEMOVE + ARROWIDCMP);
  45. MXIDCMP = (IDCMP_GADGETDOWN);
  46. NUMBERIDCMP = 0;
  47. CYCLEIDCMP = (IDCMP_GADGETUP);
  48. PALETTEIDCMP = (IDCMP_GADGETUP);
  49. { Use ARROWIDCMP+SCROLLERIDCMP if your scrollers have arrows: }
  50. SCROLLERIDCMP = (IDCMP_GADGETUP + IDCMP_GADGETDOWN + IDCMP_MOUSEMOVE);
  51. SLIDERIDCMP = (IDCMP_GADGETUP + IDCMP_GADGETDOWN + IDCMP_MOUSEMOVE);
  52. STRINGIDCMP = (IDCMP_GADGETUP);
  53. TEXTIDCMP = 0;
  54. {------------------------------------------------------------------------}
  55. { Generic NewGadget used by several of the gadget classes: }
  56. Type
  57. pNewGadget = ^tNewGadget;
  58. tNewGadget = record
  59. ng_LeftEdge, ng_TopEdge : smallint; { gadget position }
  60. ng_Width, ng_Height : smallint; { gadget size }
  61. ng_GadgetText : STRPTR; { gadget label }
  62. ng_TextAttr : pTextAttr; { desired font for gadget label }
  63. ng_GadgetID : Word; { gadget ID }
  64. ng_Flags : ULONG; { see below }
  65. ng_VisualInfo : Pointer; { Set to retval of GetVisualInfo() }
  66. ng_UserData : Pointer; { gadget UserData }
  67. END;
  68. { ng_Flags control certain aspects of the gadget. The first five control
  69. the placement of the descriptive text. All larger groups supply a
  70. default: }
  71. CONST
  72. PLACETEXT_LEFT = $0001; { Right-align text on left side }
  73. PLACETEXT_RIGHT = $0002; { Left-align text on right side }
  74. PLACETEXT_ABOVE = $0004; { Center text above }
  75. PLACETEXT_BELOW = $0008; { Center text below }
  76. PLACETEXT_IN = $0010; { Center text on }
  77. NG_HIGHLABEL = $0020; { Highlight the label }
  78. {------------------------------------------------------------------------}
  79. { Fill out an array of these and pass that to CreateMenus(): }
  80. Type
  81. pNewMenu = ^tNewMenu;
  82. tNewMenu = record
  83. nm_Type : Byte; { See below }
  84. nm_Label : STRPTR; { Menu's label }
  85. nm_CommKey : STRPTR; { MenuItem Command Key Equiv }
  86. nm_Flags : Word; { Menu OR MenuItem flags (see note) }
  87. nm_MutualExclude : Longint; { MenuItem MutualExclude word }
  88. nm_UserData : Pointer; { For your own use, see note }
  89. END;
  90. const
  91. { Needed only by inside IM_ definitions below }
  92. MENU_IMAGE = 128;
  93. { nm_Type determines what each NewMenu structure corresponds to.
  94. * for the NM_TITLE, NM_ITEM, and NM_SUB values, nm_Label should
  95. * be a text string to use for that menu title, item, or sub-item.
  96. * For IM_ITEM or IM_SUB, set nm_Label to point at the Image structure
  97. * you wish to use for this item or sub-item.
  98. * NOTE: At present, you may only use conventional images.
  99. * Custom images created from Intuition image-classes do not work.
  100. }
  101. NM_TITLE = 1; { Menu header }
  102. NM_ITEM = 2; { Textual menu item }
  103. NM_SUB = 3; { Textual menu sub-item }
  104. IM_ITEM = (NM_ITEM OR MENU_IMAGE); { Graphical menu item }
  105. IM_SUB = (NM_SUB OR MENU_IMAGE); { Graphical menu sub-item }
  106. { The NewMenu array should be terminated with a NewMenu whose
  107. * nm_Type equals NM_END.
  108. }
  109. NM_END = 0; { End of NewMenu array }
  110. { Starting with V39, GadTools will skip any NewMenu entries whose
  111. * nm_Type field has the NM_IGNORE bit set.
  112. }
  113. NM_IGNORE = 64;
  114. { nm_Label should be a text string for textual items, a pointer
  115. * to an Image structure for graphical menu items, or the special
  116. * constant NM_BARLABEL, to get a separator bar.
  117. }
  118. NM_BARLABEL = -1;
  119. { The nm_Flags field is used to fill out either the Menu->Flags or
  120. * MenuItem->Flags field. Note that the sense of the MENUENABLED or
  121. * ITEMENABLED bit is inverted between this use and Intuition's use,
  122. * in other words, NewMenus are enabled by default. The following
  123. * labels are provided to disable them:
  124. }
  125. NM_MENUDISABLED = MENUENABLED;
  126. NM_ITEMDISABLED = ITEMENABLED;
  127. { New for V39: NM_COMMANDSTRING. For a textual MenuItem or SubItem,
  128. * point nm_CommKey at an arbitrary string, and set the NM_COMMANDSTRING
  129. * flag.
  130. }
  131. NM_COMMANDSTRING = COMMSEQ;
  132. { The following are pre-cleared (COMMSEQ, ITEMTEXT, and HIGHxxx are set
  133. * later as appropriate):
  134. * Under V39, the COMMSEQ flag bit is not cleared, since it now has
  135. * meaning.
  136. }
  137. NM_FLAGMASK = NOT (COMMSEQ OR ITEMTEXT OR HIGHFLAGS);
  138. NM_FLAGMASK_V39 = NOT (ITEMTEXT OR HIGHFLAGS);
  139. { You may choose among CHECKIT, MENUTOGGLE, and CHECKED.
  140. * Toggle-select menuitems are of type CHECKIT|MENUTOGGLE, along
  141. * with CHECKED if currently selected. Mutually exclusive ones
  142. * are of type CHECKIT, and possibly CHECKED too. The nm_MutualExclude
  143. * is a bit-wise representation of the items excluded by this one,
  144. * so in the simplest case (choose 1 among n), these flags would be
  145. * ~1, ~2, ~4, ~8, ~16, etc. See the Intuition Menus chapter.
  146. }
  147. { A UserData pointer can be associated with each Menu and MenuItem structure.
  148. * The CreateMenus() call allocates space for a UserData after each
  149. * Menu or MenuItem (header, item or sub-item). You should use the
  150. * GTMENU_USERDATA() or GTMENUITEM_USERDATA() macro to extract it.
  151. }
  152. const
  153. { These return codes can be obtained through the GTMN_SecondaryError tag }
  154. GTMENU_TRIMMED = $00000001; { Too many menus, items, or subitems,
  155. * menu has been trimmed down
  156. }
  157. GTMENU_INVALID = $00000002; { Invalid NewMenu array }
  158. GTMENU_NOMEM = $00000003; { Out of memory }
  159. {------------------------------------------------------------------------}
  160. { Starting with V39, checkboxes and mx gadgets can be scaled to your
  161. * specified gadget width/height. Use the new GTCB_Scaled or GTMX_Scaled
  162. * tags, respectively. Under V37, and by default in V39, the imagery
  163. * is of the following fixed size:
  164. }
  165. { MX gadget default dimensions: }
  166. MX_WIDTH = 17;
  167. MX_HEIGHT = 9;
  168. { Checkbox default dimensions: }
  169. CHECKBOX_WIDTH = 26;
  170. CHECKBOX_HEIGHT = 11;
  171. {------------------------------------------------------------------------}
  172. {------------------------------------------------------------------------}
  173. { Tags for GadTools functions: }
  174. CONST
  175. GT_TagBase = TAG_USER + $80000;
  176. GTVI_NewWindow = GT_TagBase+1; { Unused }
  177. GTVI_NWTags = GT_TagBase+2; { Unused }
  178. GT_Private0 = GT_TagBase+3; { (private) }
  179. GTCB_Checked = GT_TagBase+4; { State of checkbox }
  180. GTLV_Top = GT_TagBase+5; { Top visible one in listview }
  181. GTLV_Labels = GT_TagBase+6; { List to display in listview }
  182. GTLV_ReadOnly = GT_TagBase+7; { TRUE IF listview is to be
  183. read-only }
  184. GTLV_ScrollWidth = GT_TagBase+8; { Width of scrollbar }
  185. GTMX_Labels = GT_TagBase+9; { NULL-terminated array of labels }
  186. GTMX_Active = GT_TagBase+10; { Active one in mx gadget }
  187. GTTX_Text = GT_TagBase+11; { Text to display }
  188. GTTX_CopyText = GT_TagBase+12; { Copy text label instead of
  189. referencing it }
  190. GTNM_Number = GT_TagBase+13; { Number to display }
  191. GTCY_Labels = GT_TagBase+14; { NULL-terminated array of labels }
  192. GTCY_Active = GT_TagBase+15; { The active one in the cycle gad }
  193. GTPA_Depth = GT_TagBase+16; { Number of bitplanes in palette }
  194. GTPA_Color = GT_TagBase+17; { Palette color }
  195. GTPA_ColorOffset = GT_TagBase+18; { First color to use in palette }
  196. GTPA_IndicatorWidth = GT_TagBase+19; { Width of current-color indicator }
  197. GTPA_IndicatorHeight = GT_TagBase+20; { Height of current-color indicator }
  198. GTSC_Top = GT_TagBase+21; { Top visible in scroller }
  199. GTSC_Total = GT_TagBase+22; { Total in scroller area }
  200. GTSC_Visible = GT_TagBase+23; { Number visible in scroller }
  201. GTSC_Overlap = GT_TagBase+24; { Unused }
  202. { GT_TagBase+25 through GT_TagBase+37 are reserved }
  203. GTSL_Min = GT_TagBase+38; { Slider min value }
  204. GTSL_Max = GT_TagBase+39; { Slider max value }
  205. GTSL_Level = GT_TagBase+40; { Slider level }
  206. GTSL_MaxLevelLen = GT_TagBase+41; { Max length of printed level }
  207. GTSL_LevelFormat = GT_TagBase+42; { Format string for level }
  208. GTSL_LevelPlace = GT_TagBase+43; { Where level should be placed }
  209. GTSL_DispFunc = GT_TagBase+44; { Callback for number calculation
  210. before display }
  211. GTST_String = GT_TagBase+45; { String gadget's displayed string }
  212. GTST_MaxChars = GT_TagBase+46; { Max length of string }
  213. GTIN_Number = GT_TagBase+47; { Number in integer gadget }
  214. GTIN_MaxChars = GT_TagBase+48; { Max number of digits }
  215. GTMN_TextAttr = GT_TagBase+49; { MenuItem font TextAttr }
  216. GTMN_FrontPen = GT_TagBase+50; { MenuItem text pen color }
  217. GTBB_Recessed = GT_TagBase+51; { Make BevelBox recessed }
  218. GT_VisualInfo = GT_TagBase+52; { result of VisualInfo call }
  219. GTLV_ShowSelected = GT_TagBase+53; { show selected entry beneath
  220. listview, set tag data = NULL for display-only, or pointer
  221. to a string gadget you've created }
  222. GTLV_Selected = GT_TagBase+54; { Set ordinal number of selected
  223. entry in the list }
  224. GT_Reserved0 = GT_TagBase+55; { Reserved }
  225. GT_Reserved1 = GT_TagBase+56; { Reserved for future use }
  226. GTTX_Border = GT_TagBase+57; { Put a border around
  227. Text-display gadgets }
  228. GTNM_Border = GT_TagBase+58; { Put a border around
  229. Number-display gadgets }
  230. GTSC_Arrows = GT_TagBase+59; { Specify size of arrows for
  231. scroller }
  232. GTMN_Menu = GT_TagBase+60; { Pointer to Menu for use by
  233. LayoutMenuItems() }
  234. GTMX_Spacing = GT_TagBase+61; { Added to font height to
  235. figure spacing between mx choices. Use this instead
  236. of LAYOUTA_SPACING for mx gadgets. }
  237. { New to V37 GadTools. Ignored by GadTools V36 }
  238. GTMN_FullMenu = GT_TagBase+62; { Asks CreateMenus() to
  239. validate that this is a complete menu structure }
  240. GTMN_SecondaryError = GT_TagBase+63; { ti_Data is a pointer
  241. to a ULONG to receive error reports from CreateMenus() }
  242. GT_Underscore = GT_TagBase+64; { ti_Data points to the symbol
  243. that preceeds the character you'd like to underline in a
  244. gadget label }
  245. { New to V39 GadTools. Ignored by GadTools V36 and V37 }
  246. GTMN_Checkmark = GT_TagBase+65; { ti_Data is checkmark img to use }
  247. GTMN_AmigaKey = GT_TagBase+66; { ti_Data is Amiga-key img to use }
  248. GTMN_NewLookMenus = GT_TagBase+67; { ti_Data is boolean }
  249. { New to V39 GadTools. Ignored by GadTools V36 and V37.
  250. * Set to TRUE if you want the checkbox or mx image scaled to
  251. * the gadget width/height you specify. Defaults to FALSE,
  252. * for compatibility.
  253. }
  254. GTCB_Scaled = GT_TagBase+68; { ti_Data is boolean }
  255. GTMX_Scaled = GT_TagBase+69; { ti_Data is boolean }
  256. GTPA_NumColors = GT_TagBase+70; { Number of colors in palette }
  257. GTMX_TitlePlace = GT_TagBase+71; { Where to put the title }
  258. GTTX_FrontPen = GT_TagBase+72; { Text color in TEXT_KIND gad }
  259. GTTX_BackPen = GT_TagBase+73; { Bgrnd color in TEXT_KIND gad }
  260. GTTX_Justification = GT_TagBase+74; { See GTJ_#? constants }
  261. GTNM_FrontPen = GT_TagBase+72; { Text color in NUMBER_KIND gad }
  262. GTNM_BackPen = GT_TagBase+73; { Bgrnd color in NUMBER_KIND gad }
  263. GTNM_Justification = GT_TagBase+74; { See GTJ_#? constants }
  264. GTNM_Format = GT_TagBase+75; { Formatting string for number }
  265. GTNM_MaxNumberLen = GT_TagBase+76; { Maximum length of number }
  266. GTBB_FrameType = GT_TagBase+77; { defines what kind of boxes
  267. * DrawBevelBox() renders. See
  268. * the BBFT_#? constants for
  269. * possible values
  270. }
  271. GTLV_MakeVisible = GT_TagBase+78; { Make this item visible }
  272. GTLV_ItemHeight = GT_TagBase+79; { Height of an individual item }
  273. GTSL_MaxPixelLen = GT_TagBase+80; { Max pixel size of level display }
  274. GTSL_Justification = GT_TagBase+81; { how should the level be displayed }
  275. GTPA_ColorTable = GT_TagBase+82; { colors to use in palette }
  276. GTLV_CallBack = GT_TagBase+83; { general-purpose listview call back }
  277. GTLV_MaxPen = GT_TagBase+84; { maximum pen number used by call back }
  278. GTTX_Clipped = GT_TagBase+85; { make a TEXT_KIND clip text }
  279. GTNM_Clipped = GT_TagBase+85; { make a NUMBER_KIND clip text }
  280. {------------------------------------------------------------------------}
  281. { Justification types for GTTX_Justification and GTNM_Justification tags }
  282. GTJ_LEFT = 0;
  283. GTJ_RIGHT = 1;
  284. GTJ_CENTER = 2;
  285. {------------------------------------------------------------------------}
  286. { Bevel box frame types for GTBB_FrameType tag }
  287. BBFT_BUTTON = 1; { Standard button gadget box }
  288. BBFT_RIDGE = 2; { Standard string gadget box }
  289. BBFT_ICONDROPBOX = 3; { Standard icon drop box }
  290. {------------------------------------------------------------------------}
  291. { Typical suggested spacing between "elements": }
  292. INTERWIDTH = 8;
  293. INTERHEIGHT = 4;
  294. {------------------------------------------------------------------------}
  295. { "NWay" is an old synonym for cycle gadgets }
  296. NWAY_KIND = CYCLE_KIND;
  297. NWAYIDCMP = CYCLEIDCMP;
  298. GTNW_Labels = GTCY_Labels;
  299. GTNW_Active = GTCY_Active;
  300. {------------------------------------------------------------------------}
  301. { These two definitions are obsolete, but are here for backwards
  302. * compatibility. You never need to worry about these:
  303. }
  304. GADTOOLBIT = ($8000);
  305. { Use this mask to isolate the user part: }
  306. GADTOOLMASK = NOT (GADTOOLBIT);
  307. {------------------------------------------------------------------------}
  308. { These definitions are for the GTLV_CallBack tag }
  309. { The different types of messages that a listview callback hook can see }
  310. LV_DRAW = $202; { draw yourself, with state }
  311. { Possible return values from a callback hook }
  312. LVCB_OK = 0; { callback understands this message type }
  313. LVCB_UNKNOWN = 1; { callback does not understand this message }
  314. { states for LVDrawMsg.lvdm_State }
  315. LVR_NORMAL = 0; { the usual }
  316. LVR_SELECTED = 1; { for selected gadgets }
  317. LVR_NORMALDISABLED = 2; { for disabled gadgets }
  318. LVR_SELECTEDDISABLED = 8; { disabled and selected }
  319. Type
  320. { structure of LV_DRAW messages, object is a (struct Node *) }
  321. pLVDrawMsg = ^tLVDrawMsg;
  322. tLVDrawMsg = record
  323. lvdm_MethodID : ULONG; { LV_DRAW }
  324. lvdm_RastPort : pRastPort; { where to render to }
  325. lvdm_DrawInfo : pDrawInfo; { useful to have around }
  326. lvdm_Bounds : tRectangle; { limits of where to render }
  327. lvdm_State : ULONG; { how to render }
  328. end;
  329. VAR
  330. GadToolsBase : pLibrary;
  331. FUNCTION CreateContext(glistptr : pGadget location 'a0'): pGadget; syscall GadToolsBase 114;
  332. FUNCTION CreateGadgetA(kind : ULONG location 'd0'; gad : pGadget location 'a0'; const ng : pNewGadget location 'a1'; const taglist : pTagItem location 'a2') : pGadget; syscall GadToolsBase 030;
  333. FUNCTION CreateMenusA(const newmenu : pNewMenu location 'a0'; const taglist : pTagItem location 'a1') : pMenu; syscall GadToolsBase 048;
  334. PROCEDURE DrawBevelBoxA(rport : pRastPort location 'a0'; left : LONGINT location 'd0'; top : LONGINT location 'd1'; width : LONGINT location 'd2'; height : LONGINT location 'd3'; const taglist : pTagItem location 'a1'); syscall GadToolsBase 120;
  335. PROCEDURE FreeGadgets(gad : pGadget location 'a0'); syscall GadToolsBase 036;
  336. PROCEDURE FreeMenus(menu : pMenu location 'a0'); syscall GadToolsBase 054;
  337. PROCEDURE FreeVisualInfo(vi : POINTER location 'a0'); syscall GadToolsBase 132;
  338. FUNCTION GetVisualInfoA(screen : pScreen location 'a0'; const taglist : pTagItem location 'a1') : POINTER; syscall GadToolsBase 126;
  339. PROCEDURE GT_BeginRefresh(win : pWindow location 'a0'); syscall GadToolsBase 090;
  340. PROCEDURE GT_EndRefresh(win : pWindow location 'a0'; complete : LONGINT location 'd0'); syscall GadToolsBase 096;
  341. FUNCTION GT_FilterIMsg(const imsg : pIntuiMessage location 'a1') : pIntuiMessage; syscall GadToolsBase 102;
  342. FUNCTION GT_GetGadgetAttrsA(gad : pGadget location 'a0'; win : pWindow location 'a1'; req : pRequester location 'a2'; const taglist : pTagItem location 'a3') : LONGINT; syscall GadToolsBase 174;
  343. FUNCTION GT_GetIMsg(iport : pMsgPort location 'a0') : pIntuiMessage; syscall GadToolsBase 072;
  344. FUNCTION GT_PostFilterIMsg(imsg : pIntuiMessage location 'a1') : pIntuiMessage; syscall GadToolsBase 108;
  345. PROCEDURE GT_RefreshWindow(win : pWindow location 'a0'; req : pRequester location 'a1'); syscall GadToolsBase 084;
  346. PROCEDURE GT_ReplyIMsg(imsg : pIntuiMessage location 'a1'); syscall GadToolsBase 078;
  347. PROCEDURE GT_SetGadgetAttrsA(gad : pGadget location 'a0'; win : pWindow location 'a1'; req : pRequester location 'a2'; const taglist : pTagItem location 'a3'); syscall GadToolsBase 042;
  348. FUNCTION LayoutMenuItemsA(firstitem : pMenuItem location 'a0'; vi : POINTER location 'a1'; const taglist : pTagItem location 'a2') : LongBool; syscall GadToolsBase 060;
  349. FUNCTION LayoutMenusA(firstmenu : pMenu location 'a0'; vi : POINTER location 'a1'; const taglist : pTagItem location 'a2') : LongBool; syscall GadToolsBase 066;
  350. function GTMENUITEM_USERDATA(menuitem : pMenuItem): pointer;
  351. function GTMENU_USERDATA(menu : pMenu): pointer;
  352. function InitGadToolsLibrary: Boolean;
  353. IMPLEMENTATION
  354. function GTMENUITEM_USERDATA(menuitem : pMenuItem): pointer;
  355. begin
  356. GTMENUITEM_USERDATA := pointer((pMenuItem(menuitem)+1));
  357. end;
  358. function GTMENU_USERDATA(menu : pMenu): pointer;
  359. begin
  360. GTMENU_USERDATA := pointer((pMenu(menu)+1));
  361. end;
  362. const
  363. { Change VERSION and LIBVERSION to proper values }
  364. VERSION : string[2] = '0';
  365. LIBVERSION : longword = 0;
  366. var
  367. GadTools_Exit : Pointer;
  368. procedure CloseGadToolsLibrary;
  369. begin
  370. ExitProc := gadtools_exit;
  371. if GadToolsBase <> nil then begin
  372. CloseLibrary(GadToolsBase);
  373. GadToolsBase := nil;
  374. end;
  375. end;
  376. function InitGadToolsLibrary: Boolean;
  377. begin
  378. InitGadToolsLibrary := False;
  379. GadToolsBase := nil;
  380. GadToolsBase := OpenLibrary(GADTOOLSNAME,LIBVERSION);
  381. if GadToolsBase <> nil then
  382. begin
  383. GadTools_Exit := ExitProc;
  384. ExitProc := @CloseGadToolsLibrary;
  385. InitGadToolsLibrary := True;
  386. end;
  387. end;
  388. END. (* UNIT GADTOOLS *)