{ -------------------------------------------------------------------------------------------------------------- } { -------------------------------------------------------------------------------------------------------------- } { GENERIC TOOLBOX ``````````````````````````` A Generic Utilities unit, for use by any program. Copyright İ by David Sinclair, 1990 ­ 2001. I am releasing these units to the Pascal community. Feel free to use them in whole or part in your Pascal programs. You are also welcome to modify these units to suit your needs. If you wish to re-distribute the sources with your changes, please clearly indicate that you have changed them. In all cases, you must leave these comments and the copyright notice intact. If you use a significant portion of these units, I would appreciate acknowledgement in your About dialog and/or documentation, e.g. ³Dejal Generic Utilities copyright İ by David Sinclair, 1990 - 2001.² Iıd appreciate it if you also e-mail me at if you find these units useful. If you have any questions about these units, you can e-mail me at that address and I will do my best to help, time permitting. However, these units are provided ³as is² and I do not guarantee their reliablity or suitability for any particular purpose. These units have been used extensively in my Dejal shareware and freeware products over the years. Most of the code was written many years ago, and the code and style may not be optimal in all cases, but unless otherwise noted all routines have been used in released software, so should work as described. Please visit and try out Dejal QuickEncrypt and/or my other shareware products. If you want to show your appreciation for these units financially, registrations for my shareware are always welcome! Or you can make a donation to me via my online order form: . I hope you find these units useful, and good luck in your Pascal endeavors! - David Sinclair, Dejal * * * UNIT HISTORY: (Reverse chronology) Start ­ finish dates: Comments / changes: 27 October 2001 Public release as source code. 31 January 1999 Added the Abs routine. 7 July 1997 Added the Geneva, Monaco and Palatino routines. 26-27 April 1997 Started unit when moving from THINK Pascal to CodeWarrior. } { -------------------------------------------------------------------------------------------------------------- } { -------------------------------------------------------------------------------------------------------------- } UNIT genToolbox; INTERFACE USES Controls, Windows, TextEdit, Dialogs, Fonts, Lists, Icons, Menus, Resources, Scrap, OSUtils, Files, Folders, QuickDrawText, MixedMode, DiskInit, Errors, Memory, Events, Devices, Appletalk, Quickdraw, Types, ToolUtils, Serial, GestaltEqu, Aliases, Processes, Notification, QDOffscreen, SegLoad, Sound, SoundInput, Packages, Printing, TextUtils, StandardFile, Drag, FP{, Appearance}; {$SETC application = True} {$SETC debug = False} TYPE GlobalsType = RECORD unused1: Integer; qd: QDGlobals; unused2: Integer; END; VAR globals: GlobalsType; { -------------------------------------------------------------------------------------------------------------- } PROCEDURE InitialiseToolbox; FUNCTION Abs(number: Longint): Longint; FUNCTION Copy(source: Str255; index, count: Integer): Str255; FUNCTION Geneva: Integer; FUNCTION Monaco: Integer; FUNCTION Palatino: Integer; { -------------------------------------------------------------------------------------------------------------- } { -------------------------------------------------------------------------------------------------------------- } IMPLEMENTATION PROCEDURE InitialiseToolbox; {Calls all the standard toolbox initialisation routines.} {Written by David Sinclair, 26 April 1997.} BEGIN SetApplLimit(Ptr(Ord4(GetApplLimit)-16384)); MaxApplZone; MoreMasters; MoreMasters; MoreMasters; MoreMasters; MoreMasters; InitGraf(@globals.qd.thePort); InitFonts; FlushEvents(everyEvent,0); InitWindows; InitMenus; TEInit; InitDialogs(Nil); SetCursor(GetCursor(watchCursor)^^); END; { -------------------------------------------------------------------------------------------------------------- } FUNCTION Abs(number: Longint): Longint; {A patch on the built-in function of the same name. There is a bug in CW Pro 1.0ıs Abs function: Abs(-128) results in -128 instead of 128.} {Written by David Sinclair, 31 January 1999.} BEGIN IF number < 0 THEN number:= -number; Abs:= number END; {--------------------------------|--------------------------------------------------------------------|---------------------------------------------------------|------------------------} FUNCTION Copy(source: Str255; index, count: Integer): Str255; {A patch on the built-in function of the same name, to make it work as it does in THINK Pascal, i.e. so a valid string is returned even if there arenıt len characters from the specified position in the source.} {Written by David Sinclair, 27 April 1997.} VAR max: Integer; BEGIN max:= Length(source)-index+1; IF count > max THEN count:= max; Copy:= System.Copy(source,index,count) END; { -------------------------------------------------------------------------------------------------------------- } FUNCTION Geneva: Integer; {A hack to allow use of the old constant ³Geneva², but doing it the proper way.} {Written by David Sinclair, 7 July 1997.} VAR fontNum: Integer; BEGIN GetFNum('Geneva',fontNum); Geneva:= fontNum; END; { -------------------------------------------------------------------------------------------------------------- } FUNCTION Monaco: Integer; {A hack to allow use of the old constant ³Monaco², but doing it the proper way.} {Written by David Sinclair, 7 July 1997.} VAR fontNum: Integer; BEGIN GetFNum('Monaco',fontNum); Monaco:= fontNum; END; { -------------------------------------------------------------------------------------------------------------- } FUNCTION Palatino: Integer; {A hack to allow use of the old constant ³Palatino², but doing it the proper way.} {Written by David Sinclair, 7 July 1997.} VAR fontNum: Integer; BEGIN GetFNum('Palatino',fontNum); Palatino:= fontNum; END; { -------------------------------------------------------------------------------------------------------------- } { -------------------------------------------------------------------------------------------------------------- } END.