dialogs.pas 164 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214
  1. {********[ SOURCE FILE OF GRAPHICAL FREE VISION ]**********}
  2. { }
  3. { System independent GRAPHICAL clone of DIALOGS.PAS }
  4. { }
  5. { Interface Copyright (c) 1992 Borland International }
  6. { }
  7. { Copyright (c) 1996, 1997, 1998, 1999 by Leon de Boer }
  8. { [email protected] - primary e-mail addr }
  9. { [email protected] - backup e-mail addr }
  10. { }
  11. {****************[ THIS CODE IS FREEWARE ]*****************}
  12. { }
  13. { This sourcecode is released for the purpose to }
  14. { promote the pascal language on all platforms. You may }
  15. { redistribute it and/or modify with the following }
  16. { DISCLAIMER. }
  17. { }
  18. { This SOURCE CODE is distributed "AS IS" WITHOUT }
  19. { WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR }
  20. { ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. }
  21. { }
  22. {*****************[ SUPPORTED PLATFORMS ]******************}
  23. { 16 and 32 Bit compilers }
  24. { DOS - Turbo Pascal 7.0 + (16 Bit) }
  25. { DPMI - Turbo Pascal 7.0 + (16 Bit) }
  26. { - FPC 0.9912+ (GO32V2) (32 Bit) }
  27. { WINDOWS - Turbo Pascal 7.0 + (16 Bit) }
  28. { - Delphi 1.0+ (16 Bit) }
  29. { WIN95/NT - Delphi 2.0+ (32 Bit) }
  30. { - Virtual Pascal 2.0+ (32 Bit) }
  31. { - Speedsoft Sybil 2.0+ (32 Bit) }
  32. { - FPC 0.9912+ (32 Bit) }
  33. { OS2 - Virtual Pascal 1.0+ (32 Bit) }
  34. { }
  35. {******************[ REVISION HISTORY ]********************}
  36. { Version Date Fix }
  37. { ------- --------- --------------------------------- }
  38. { 1.00 11 Nov 96 First DOS/DPMI platform release. }
  39. { 1.10 13 Jul 97 Windows platform code added. }
  40. { 1.20 29 Aug 97 Platform.inc sort added. }
  41. { 1.30 13 Oct 97 Delphi 2 32 bit code added. }
  42. { 1.40 05 May 98 Virtual pascal 2.0 code added. }
  43. { 1.50 27 Oct 99 All objects completed and checked }
  44. { 1.51 03 Nov 99 FPC windows support added }
  45. { 1.60 26 Nov 99 Graphics stuff moved to GFVGraph }
  46. {**********************************************************}
  47. UNIT Dialogs;
  48. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  49. INTERFACE
  50. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  51. {====Include file to sort compiler platform out =====================}
  52. {$I Platform.inc}
  53. {====================================================================}
  54. {==== Compiler directives ===========================================}
  55. {$IFNDEF PPC_FPC}{ FPC doesn't support these switches }
  56. {$F-} { Short calls are okay }
  57. {$A+} { Word Align Data }
  58. {$B-} { Allow short circuit boolean evaluations }
  59. {$O+} { This unit may be overlaid }
  60. {$G+} { 286 Code optimization - if you're on an 8088 get a real computer }
  61. {$P-} { Normal string variables }
  62. {$N-} { No 80x87 code generation }
  63. {$E+} { Emulation is on }
  64. {$ENDIF}
  65. {$X+} { Extended syntax is ok }
  66. {$R-} { Disable range checking }
  67. {$S-} { Disable Stack Checking }
  68. {$I-} { Disable IO Checking }
  69. {$Q-} { Disable Overflow Checking }
  70. {$V-} { Turn off strict VAR strings }
  71. {====================================================================}
  72. USES
  73. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  74. {$IFNDEF PPC_SPEED} { NON SPEED COMPILER }
  75. {$IFDEF PPC_FPC} { FPC WINDOWS COMPILER }
  76. Windows, { Standard units }
  77. {$ELSE} { OTHER COMPILERS }
  78. WinTypes,WinProcs, { Standard units }
  79. {$ENDIF}
  80. {$ELSE} { SPEEDSOFT COMPILER }
  81. WinBase, WinDef, WinUser, WinGDI, { Standard units }
  82. {$ENDIF}
  83. {$IFDEF PPC_DELPHI} { DELPHI COMPILERS }
  84. Messages, { Standard unit }
  85. {$ENDIF}
  86. {$ENDIF}
  87. {$IFDEF OS_OS2} { OS2 CODE }
  88. OS2Def, OS2Base, OS2PMAPI, { Standard units }
  89. {$ENDIF}
  90. Common, GFVGraph, Objects, Drivers, Views, Validate; { Standard GFV units }
  91. {***************************************************************************}
  92. { PUBLIC CONSTANTS }
  93. {***************************************************************************}
  94. {---------------------------------------------------------------------------}
  95. { COLOUR PALETTE DEFINITIONS }
  96. {---------------------------------------------------------------------------}
  97. CONST
  98. CGrayDialog = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47 +
  99. #48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;
  100. CBlueDialog = #64#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79 +
  101. #80#81#82#83#84#85#86#87#88#89#90#91#92#92#94#95;
  102. CCyanDialog = #96#97#98#99#100#101#102#103#104#105#106#107#108 +
  103. #109#110#111#112#113#114#115#116#117#118#119#120 +
  104. #121#122#123#124#125#126#127;
  105. CStaticText = #6#7#8#9;
  106. CLabel = #7#8#9#9;
  107. CButton = #10#11#12#13#14#14#14#15;
  108. CCluster = #16#17#18#18#31#6;
  109. CInputLine = #19#19#20#21#14;
  110. CHistory = #22#23;
  111. CHistoryWindow = #19#19#21#24#25#19#20;
  112. CHistoryViewer = #6#6#7#6#6;
  113. CDialog = CGrayDialog; { Default palette }
  114. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  115. {---------------------------------------------------------------------------}
  116. { NEW WIN/NT/OS2 COMMAND CODES }
  117. {---------------------------------------------------------------------------}
  118. CONST
  119. cmTvClusterButton = $2001; { Cluster button cmd id }
  120. {$ENDIF}
  121. {---------------------------------------------------------------------------}
  122. { TDialog PALETTE COLOUR CONSTANTS }
  123. {---------------------------------------------------------------------------}
  124. CONST
  125. dpBlueDialog = 0; { Blue dialog colour }
  126. dpCyanDialog = 1; { Cyan dialog colour }
  127. dpGrayDialog = 2; { Gray dialog colour }
  128. {---------------------------------------------------------------------------}
  129. { TButton FLAGS MASKS }
  130. {---------------------------------------------------------------------------}
  131. CONST
  132. bfNormal = $00; { Normal displayed }
  133. bfDefault = $01; { Default command }
  134. bfLeftJust = $02; { Left just text }
  135. bfBroadcast = $04; { Broadcast command }
  136. bfGrabFocus = $08; { Grab focus }
  137. {---------------------------------------------------------------------------}
  138. { TMultiCheckBoxes FLAGS - (HiByte = Bits LoByte = Mask) }
  139. {---------------------------------------------------------------------------}
  140. CONST
  141. cfOneBit = $0101; { One bit masks }
  142. cfTwoBits = $0203; { Two bit masks }
  143. cfFourBits = $040F; { Four bit masks }
  144. cfEightBits = $08FF; { Eight bit masks }
  145. {---------------------------------------------------------------------------}
  146. { DIALOG BROADCAST COMMANDS }
  147. {---------------------------------------------------------------------------}
  148. CONST
  149. cmRecordHistory = 60; { Record history cmd }
  150. {***************************************************************************}
  151. { RECORD DEFINITIONS }
  152. {***************************************************************************}
  153. {---------------------------------------------------------------------------}
  154. { ITEM RECORD DEFINITION }
  155. {---------------------------------------------------------------------------}
  156. TYPE
  157. PSItem = ^TSItem;
  158. TSItem = RECORD
  159. Value: PString; { Item string }
  160. Next: PSItem; { Next item }
  161. END;
  162. {***************************************************************************}
  163. { OBJECT DEFINITIONS }
  164. {***************************************************************************}
  165. {---------------------------------------------------------------------------}
  166. { TDialog OBJECT - DIALOG OBJECT }
  167. {---------------------------------------------------------------------------}
  168. TYPE
  169. TDialog = OBJECT (TWindow)
  170. CONSTRUCTOR Init (Var Bounds: TRect; ATitle: TTitleStr);
  171. CONSTRUCTOR Load (Var S: TStream);
  172. FUNCTION GetPalette: PPalette; Virtual;
  173. FUNCTION Valid (Command: Word): Boolean; Virtual;
  174. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  175. END;
  176. PDialog = ^TDialog;
  177. {---------------------------------------------------------------------------}
  178. { TInputLine OBJECT - INPUT LINE OBJECT }
  179. {---------------------------------------------------------------------------}
  180. TYPE
  181. TInputLine = OBJECT (TView)
  182. MaxLen: Integer; { Max input length }
  183. CurPos: Integer; { Cursor position }
  184. FirstPos: Integer; { First position }
  185. SelStart: Integer; { Selected start }
  186. SelEnd: Integer; { Selected end }
  187. Data: PString; { Input line data }
  188. Validator: PValidator; { Validator of view }
  189. CONSTRUCTOR Init (Var Bounds: TRect; AMaxLen: Integer);
  190. CONSTRUCTOR Load (Var S: TStream);
  191. DESTRUCTOR Done; Virtual;
  192. FUNCTION DataSize: Word; Virtual;
  193. FUNCTION GetPalette: PPalette; Virtual;
  194. FUNCTION Valid (Command: Word): Boolean; Virtual;
  195. PROCEDURE Draw; Virtual;
  196. PROCEDURE DrawCursor; Virtual;
  197. PROCEDURE DrawbackGround; Virtual;
  198. PROCEDURE SelectAll (Enable: Boolean);
  199. PROCEDURE SetValidator (AValid: PValidator);
  200. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  201. PROCEDURE GetData (Var Rec); Virtual;
  202. PROCEDURE SetData (Var Rec); Virtual;
  203. PROCEDURE Store (Var S: TStream);
  204. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  205. PRIVATE
  206. FUNCTION CanScroll (Delta: Integer): Boolean;
  207. END;
  208. PInputLine = ^TInputLine;
  209. {---------------------------------------------------------------------------}
  210. { TButton OBJECT - BUTTON ANCESTOR OBJECT }
  211. {---------------------------------------------------------------------------}
  212. TYPE
  213. TButton = OBJECT (TView)
  214. AmDefault: Boolean; { If default button }
  215. Flags : Byte; { Button flags }
  216. Command : Word; { Button command }
  217. Title : PString; { Button title }
  218. CONSTRUCTOR Init (Var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
  219. AFlags: Word);
  220. CONSTRUCTOR Load (Var S: TStream);
  221. DESTRUCTOR Done; Virtual;
  222. FUNCTION GetPalette: PPalette; Virtual;
  223. PROCEDURE Press; Virtual;
  224. PROCEDURE DrawFocus; Virtual;
  225. PROCEDURE DrawState (Down: Boolean);
  226. PROCEDURE MakeDefault (Enable: Boolean);
  227. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  228. PROCEDURE Store (Var S: TStream);
  229. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  230. PRIVATE
  231. DownFlag: Boolean;
  232. END;
  233. PButton = ^TButton;
  234. {---------------------------------------------------------------------------}
  235. { TCluster OBJECT - CLUSTER ANCESTOR OBJECT }
  236. {---------------------------------------------------------------------------}
  237. TYPE
  238. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  239. TWndArray = Array [0..32000] Of HWnd; { Window handle array }
  240. PWndArray = ^TWndArray; { Ptr to handle array }
  241. {$ENDIF}
  242. TCluster = OBJECT (TView)
  243. Id : Integer; { New communicate id }
  244. Sel : Integer; { Selected item }
  245. Value : LongInt; { Bit value }
  246. EnableMask: LongInt; { Mask enable bits }
  247. Strings : TStringCollection; { String collection }
  248. {$IFNDEF OS_DOS} { WIN/NT/OS2 DATA }
  249. WndHandles: PWndArray; { Window handle array }
  250. {$ENDIF}
  251. CONSTRUCTOR Init (Var Bounds: TRect; AStrings: PSItem);
  252. CONSTRUCTOR Load (Var S: TStream);
  253. DESTRUCTOR Done; Virtual;
  254. FUNCTION DataSize: Word; Virtual;
  255. FUNCTION GetHelpCtx: Word; Virtual;
  256. FUNCTION GetPalette: PPalette; Virtual;
  257. FUNCTION Mark (Item: Integer): Boolean; Virtual;
  258. FUNCTION MultiMark (Item: Integer): Byte; Virtual;
  259. FUNCTION ButtonState (Item: Integer): Boolean;
  260. PROCEDURE DrawFocus; Virtual;
  261. PROCEDURE Press (Item: Integer); Virtual;
  262. PROCEDURE MovedTo (Item: Integer); Virtual;
  263. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  264. PROCEDURE DrawMultiBox (Const Icon, Marker: String);
  265. PROCEDURE DrawBox (Const Icon: String; Marker: Char);
  266. PROCEDURE SetButtonState (AMask: Longint; Enable: Boolean);
  267. PROCEDURE GetData (Var Rec); Virtual;
  268. PROCEDURE SetData (Var Rec); Virtual;
  269. PROCEDURE Store (Var S: TStream);
  270. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  271. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  272. FUNCTION GetClassName: String; Virtual;
  273. FUNCTION SubClassAttr: LongInt; Virtual;
  274. FUNCTION GetMsgHandler: Pointer; Virtual;
  275. PROCEDURE CreateWindowNow (CmdShow: Integer); Virtual;
  276. {$ENDIF}
  277. PRIVATE
  278. FUNCTION FindSel (P: TPoint): Integer;
  279. FUNCTION Row (Item: Integer): Integer;
  280. FUNCTION Column (Item: Integer): Integer;
  281. END;
  282. PCluster = ^TCluster;
  283. {---------------------------------------------------------------------------}
  284. { TRadioButtons OBJECT - RADIO BUTTON OBJECT }
  285. {---------------------------------------------------------------------------}
  286. TYPE
  287. TRadioButtons = OBJECT (TCluster)
  288. FUNCTION Mark (Item: Integer): Boolean; Virtual;
  289. PROCEDURE DrawFocus; Virtual;
  290. PROCEDURE Press (Item: Integer); Virtual;
  291. PROCEDURE MovedTo(Item: Integer); Virtual;
  292. PROCEDURE SetData (Var Rec); Virtual;
  293. {$IFNDEF OS_DOS} { WIN/NT CODE }
  294. FUNCTION SubClassAttr: LongInt; Virtual;
  295. {$ENDIF}
  296. END;
  297. PRadioButtons = ^TRadioButtons;
  298. {---------------------------------------------------------------------------}
  299. { TCheckBoxes OBJECT - CHECK BOXES OBJECT }
  300. {---------------------------------------------------------------------------}
  301. TYPE
  302. TCheckBoxes = OBJECT (TCluster)
  303. FUNCTION Mark (Item: Integer): Boolean; Virtual;
  304. PROCEDURE DrawFocus; Virtual;
  305. PROCEDURE Press (Item: Integer); Virtual;
  306. {$IFNDEF OS_DOS} { WIN/NT CODE }
  307. FUNCTION SubClassAttr: LongInt; Virtual;
  308. {$ENDIF}
  309. END;
  310. PCheckBoxes = ^TCheckBoxes;
  311. {---------------------------------------------------------------------------}
  312. { TMultiCheckBoxes OBJECT - CHECK BOXES OBJECT }
  313. {---------------------------------------------------------------------------}
  314. TYPE
  315. TMultiCheckBoxes = OBJECT (TCluster)
  316. SelRange: Byte; { Select item range }
  317. Flags : Word; { Select flags }
  318. States : PString; { Strings }
  319. CONSTRUCTOR Init (Var Bounds: TRect; AStrings: PSItem;
  320. ASelRange: Byte; AFlags: Word; Const AStates: String);
  321. CONSTRUCTOR Load (Var S: TStream);
  322. DESTRUCTOR Done; Virtual;
  323. FUNCTION DataSize: Word; Virtual;
  324. FUNCTION MultiMark (Item: Integer): Byte; Virtual;
  325. PROCEDURE DrawFocus; Virtual;
  326. PROCEDURE Press (Item: Integer); Virtual;
  327. PROCEDURE GetData (Var Rec); Virtual;
  328. PROCEDURE SetData (Var Rec); Virtual;
  329. PROCEDURE Store (Var S: TStream);
  330. {$IFNDEF OS_DOS} { WIN/NT CODE }
  331. FUNCTION SubClassAttr: LongInt; Virtual;
  332. {$ENDIF}
  333. END;
  334. PMultiCheckBoxes = ^TMultiCheckBoxes;
  335. {---------------------------------------------------------------------------}
  336. { TListBox OBJECT - LIST BOX OBJECT }
  337. {---------------------------------------------------------------------------}
  338. TYPE
  339. TListBox = OBJECT (TListViewer)
  340. List: PCollection; { List of strings }
  341. CONSTRUCTOR Init (Var Bounds: TRect; ANumCols: Word;
  342. AScrollBar: PScrollBar);
  343. CONSTRUCTOR Load (Var S: TStream);
  344. FUNCTION DataSize: Word; Virtual;
  345. FUNCTION GetText (Item: Integer; MaxLen: Integer): String; Virtual;
  346. PROCEDURE NewList(AList: PCollection); Virtual;
  347. PROCEDURE GetData (Var Rec); Virtual;
  348. PROCEDURE SetData (Var Rec); Virtual;
  349. PROCEDURE Store (Var S: TStream);
  350. END;
  351. PListBox = ^TListBox;
  352. {---------------------------------------------------------------------------}
  353. { TStaticText OBJECT - STATIC TEXT OBJECT }
  354. {---------------------------------------------------------------------------}
  355. TYPE
  356. TStaticText = OBJECT (TView)
  357. Text: PString; { Text string ptr }
  358. CONSTRUCTOR Init (Var Bounds: TRect; Const AText: String);
  359. CONSTRUCTOR Load (Var S: TStream);
  360. DESTRUCTOR Done; Virtual;
  361. FUNCTION GetPalette: PPalette; Virtual;
  362. PROCEDURE DrawBackGround; Virtual;
  363. PROCEDURE Store (Var S: TStream);
  364. PROCEDURE GetText (Var S: String); Virtual;
  365. END;
  366. PStaticText = ^TStaticText;
  367. {---------------------------------------------------------------------------}
  368. { TParamText OBJECT - PARMETER STATIC TEXT OBJECT }
  369. {---------------------------------------------------------------------------}
  370. TYPE
  371. TParamText = OBJECT (TStaticText)
  372. ParamCount: Integer; { Parameter count }
  373. ParamList : Pointer; { Parameter list }
  374. CONSTRUCTOR Init (Var Bounds: TRect; Const AText: String;
  375. AParamCount: Integer);
  376. CONSTRUCTOR Load (Var S: TStream);
  377. FUNCTION DataSize: Word; Virtual;
  378. PROCEDURE GetData (Var Rec); Virtual;
  379. PROCEDURE SetData (Var Rec); Virtual;
  380. PROCEDURE Store (Var S: TStream);
  381. PROCEDURE GetText (Var S: String); Virtual;
  382. END;
  383. PParamText = ^TParamText;
  384. {---------------------------------------------------------------------------}
  385. { TLabel OBJECT - LABEL OBJECT }
  386. {---------------------------------------------------------------------------}
  387. TYPE
  388. TLabel = OBJECT (TStaticText)
  389. Light: Boolean;
  390. Link: PView; { Linked view }
  391. CONSTRUCTOR Init (Var Bounds: TRect; CONST AText: String; ALink: PView);
  392. CONSTRUCTOR Load (Var S: TStream);
  393. FUNCTION GetPalette: PPalette; Virtual;
  394. PROCEDURE DrawBackGround; Virtual;
  395. PROCEDURE Store (Var S: TStream);
  396. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  397. END;
  398. PLabel = ^TLabel;
  399. {---------------------------------------------------------------------------}
  400. { THistoryViewer OBJECT - HISTORY VIEWER OBJECT }
  401. {---------------------------------------------------------------------------}
  402. TYPE
  403. THistoryViewer = OBJECT (TListViewer)
  404. HistoryId: Word; { History id }
  405. CONSTRUCTOR Init(Var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  406. AHistoryId: Word);
  407. FUNCTION HistoryWidth: Integer;
  408. FUNCTION GetPalette: PPalette; Virtual;
  409. FUNCTION GetText (Item: Integer; MaxLen: Integer): String; Virtual;
  410. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  411. END;
  412. PHistoryViewer = ^THistoryViewer;
  413. {---------------------------------------------------------------------------}
  414. { THistoryWindow OBJECT - HISTORY WINDOW OBJECT }
  415. {---------------------------------------------------------------------------}
  416. TYPE
  417. THistoryWindow = OBJECT (TWindow)
  418. Viewer: PListViewer; { List viewer object }
  419. CONSTRUCTOR Init (Var Bounds: TRect; HistoryId: Word);
  420. FUNCTION GetSelection: String; Virtual;
  421. FUNCTION GetPalette: PPalette; Virtual;
  422. PROCEDURE InitViewer (HistoryId: Word); Virtual;
  423. END;
  424. PHistoryWindow = ^THistoryWindow;
  425. {---------------------------------------------------------------------------}
  426. { THistory OBJECT - HISTORY OBJECT }
  427. {---------------------------------------------------------------------------}
  428. TYPE
  429. THistory = OBJECT (TView)
  430. HistoryId: Word;
  431. Link: PInputLine;
  432. CONSTRUCTOR Init (Var Bounds: TRect; ALink: PInputLine; AHistoryId: Word);
  433. CONSTRUCTOR Load (Var S: TStream);
  434. FUNCTION GetPalette: PPalette; Virtual;
  435. FUNCTION InitHistoryWindow (Var Bounds: TRect): PHistoryWindow; Virtual;
  436. PROCEDURE Draw; Virtual;
  437. PROCEDURE RecordHistory (CONST S: String); Virtual;
  438. PROCEDURE Store (Var S: TStream);
  439. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  440. END;
  441. PHistory = ^THistory;
  442. {***************************************************************************}
  443. { INTERFACE ROUTINES }
  444. {***************************************************************************}
  445. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  446. { ITEM STRING ROUTINES }
  447. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  448. {-NewSItem-----------------------------------------------------------
  449. Allocates memory for a new TSItem record and sets the text field
  450. and chains to the next TSItem. This allows easy construction of
  451. singly-linked lists of strings, to end a chain the next TSItem
  452. should be nil.
  453. 28Apr98 LdB
  454. ---------------------------------------------------------------------}
  455. FUNCTION NewSItem (Const Str: String; ANext: PSItem): PSItem;
  456. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  457. { DIALOG OBJECT REGISTRATION PROCEDURE }
  458. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  459. {-RegisterDialogs----------------------------------------------------
  460. This registers all the view type objects used in this unit.
  461. 30Sep99 LdB
  462. ---------------------------------------------------------------------}
  463. PROCEDURE RegisterDialogs;
  464. {***************************************************************************}
  465. { STREAM REGISTRATION RECORDS }
  466. {***************************************************************************}
  467. {---------------------------------------------------------------------------}
  468. { TDialog STREAM REGISTRATION }
  469. {---------------------------------------------------------------------------}
  470. CONST
  471. RDialog: TStreamRec = (
  472. ObjType: 10; { Register id = 10 }
  473. {$IFDEF BP_VMTLink} { BP style VMT link }
  474. VmtLink: Ofs(TypeOf(TDialog)^);
  475. {$ELSE} { Alt style VMT link }
  476. VmtLink: TypeOf(TDialog);
  477. {$ENDIF}
  478. Load: @TDialog.Load; { Object load method }
  479. Store: @TDialog.Store { Object store method }
  480. );
  481. {---------------------------------------------------------------------------}
  482. { TInputLine STREAM REGISTRATION }
  483. {---------------------------------------------------------------------------}
  484. CONST
  485. RInputLine: TStreamRec = (
  486. ObjType: 11; { Register id = 11 }
  487. {$IFDEF BP_VMTLink} { BP style VMT link }
  488. VmtLink: Ofs(TypeOf(TInputLine)^);
  489. {$ELSE} { Alt style VMT link }
  490. VmtLink: TypeOf(TInputLine);
  491. {$ENDIF}
  492. Load: @TInputLine.Load; { Object load method }
  493. Store: @TInputLine.Store { Object store method }
  494. );
  495. {---------------------------------------------------------------------------}
  496. { TButton STREAM REGISTRATION }
  497. {---------------------------------------------------------------------------}
  498. CONST
  499. RButton: TStreamRec = (
  500. ObjType: 12; { Register id = 12 }
  501. {$IFDEF BP_VMTLink} { BP style VMT link }
  502. VmtLink: Ofs(TypeOf(TButton)^);
  503. {$ELSE} { Alt style VMT link }
  504. VmtLink: TypeOf(TButton);
  505. {$ENDIF}
  506. Load: @TButton.Load; { Object load method }
  507. Store: @TButton.Store { Object store method }
  508. );
  509. {---------------------------------------------------------------------------}
  510. { TCluster STREAM REGISTRATION }
  511. {---------------------------------------------------------------------------}
  512. CONST
  513. RCluster: TStreamRec = (
  514. ObjType: 13; { Register id = 13 }
  515. {$IFDEF BP_VMTLink} { BP style VMT link }
  516. VmtLink: Ofs(TypeOf(TCluster)^);
  517. {$ELSE} { Alt style VMT link }
  518. VmtLink: TypeOf(TCluster);
  519. {$ENDIF}
  520. Load: @TCluster.Load; { Object load method }
  521. Store: @TCluster.Store { Objects store method }
  522. );
  523. {---------------------------------------------------------------------------}
  524. { TRadioButtons STREAM REGISTRATION }
  525. {---------------------------------------------------------------------------}
  526. CONST
  527. RRadioButtons: TStreamRec = (
  528. ObjType: 14; { Register id = 14 }
  529. {$IFDEF BP_VMTLink} { BP style VMT link }
  530. VmtLink: Ofs(TypeOf(TRadioButtons)^);
  531. {$ELSE} { Alt style VMT link }
  532. VmtLink: TypeOf(TRadioButtons);
  533. {$ENDIF}
  534. Load: @TRadioButtons.Load; { Object load method }
  535. Store: @TRadioButtons.Store { Object store method }
  536. );
  537. {---------------------------------------------------------------------------}
  538. { TCheckBoxes STREAM REGISTRATION }
  539. {---------------------------------------------------------------------------}
  540. CONST
  541. RCheckBoxes: TStreamRec = (
  542. ObjType: 15; { Register id = 15 }
  543. {$IFDEF BP_VMTLink} { BP style VMT link }
  544. VmtLink: Ofs(TypeOf(TCheckBoxes)^);
  545. {$ELSE} { Alt style VMT link }
  546. VmtLink: TypeOf(TCheckBoxes);
  547. {$ENDIF}
  548. Load: @TCheckBoxes.Load; { Object load method }
  549. Store: @TCheckBoxes.Store { Object store method }
  550. );
  551. {---------------------------------------------------------------------------}
  552. { TMultiCheckBoxes STREAM REGISTRATION }
  553. {---------------------------------------------------------------------------}
  554. CONST
  555. RMultiCheckBoxes: TStreamRec = (
  556. ObjType: 27; { Register id = 27 }
  557. {$IFDEF BP_VMTLink} { BP style VMT link }
  558. VmtLink: Ofs(TypeOf(TMultiCheckBoxes)^);
  559. {$ELSE} { Alt style VMT link }
  560. VmtLink: TypeOf(TMultiCheckBoxes);
  561. {$ENDIF}
  562. Load: @TMultiCheckBoxes.Load; { Object load method }
  563. Store: @TMultiCheckBoxes.Store { Object store method }
  564. );
  565. {---------------------------------------------------------------------------}
  566. { TListBox STREAM REGISTRATION }
  567. {---------------------------------------------------------------------------}
  568. CONST
  569. RListBox: TStreamRec = (
  570. ObjType: 16; { Register id = 16 }
  571. {$IFDEF BP_VMTLink} { BP style VMT link }
  572. VmtLink: Ofs(TypeOf(TListBox)^);
  573. {$ELSE} { Alt style VMT link }
  574. VmtLink: TypeOf(TListBox);
  575. {$ENDIF}
  576. Load: @TListBox.Load; { Object load method }
  577. Store: @TListBox.Store { Object store method }
  578. );
  579. {---------------------------------------------------------------------------}
  580. { TStaticText STREAM REGISTRATION }
  581. {---------------------------------------------------------------------------}
  582. CONST
  583. RStaticText: TStreamRec = (
  584. ObjType: 17; { Register id = 17 }
  585. {$IFDEF BP_VMTLink} { BP style VMT link }
  586. VmtLink: Ofs(TypeOf(TStaticText)^);
  587. {$ELSE} { Alt style VMT link }
  588. VmtLink: TypeOf(TStaticText);
  589. {$ENDIF}
  590. Load: @TStaticText.Load; { Object load method }
  591. Store: @TStaticText.Store { Object store method }
  592. );
  593. {---------------------------------------------------------------------------}
  594. { TLabel STREAM REGISTRATION }
  595. {---------------------------------------------------------------------------}
  596. CONST
  597. RLabel: TStreamRec = (
  598. ObjType: 18; { Register id = 18 }
  599. {$IFDEF BP_VMTLink} { BP style VMT link }
  600. VmtLink: Ofs(TypeOf(TLabel)^);
  601. {$ELSE} { Alt style VMT link }
  602. VmtLink: TypeOf(TLabel);
  603. {$ENDIF}
  604. Load: @TLabel.Load; { Object load method }
  605. Store: @TLabel.Store { Object store method }
  606. );
  607. {---------------------------------------------------------------------------}
  608. { THistory STREAM REGISTRATION }
  609. {---------------------------------------------------------------------------}
  610. CONST
  611. RHistory: TStreamRec = (
  612. ObjType: 19; { Register id = 19 }
  613. {$IFDEF BP_VMTLink} { BP style VMT link }
  614. VmtLink: Ofs(TypeOf(THistory)^);
  615. {$ELSE} { Alt style VMT link }
  616. VmtLink: TypeOf(THistory);
  617. {$ENDIF}
  618. Load: @THistory.Load; { Object load method }
  619. Store: @THistory.Store { Object store method }
  620. );
  621. {---------------------------------------------------------------------------}
  622. { TParamText STREAM REGISTRATION }
  623. {---------------------------------------------------------------------------}
  624. CONST
  625. RParamText: TStreamRec = (
  626. ObjType: 20; { Register id = 20 }
  627. {$IFDEF BP_VMTLink} { BP style VMT link }
  628. VmtLink: Ofs(TypeOf(TParamText)^);
  629. {$ELSE} { Alt style VMT link }
  630. VmtLink: TypeOf(TParamText);
  631. {$ENDIF}
  632. Load: @TParamText.Load; { Object load method }
  633. Store: @TParamText.Store { Object store method }
  634. );
  635. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  636. IMPLEMENTATION
  637. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  638. USES HistList; { Standard GFV unit }
  639. {***************************************************************************}
  640. { PRIVATE DEFINED CONSTANTS }
  641. {***************************************************************************}
  642. {---------------------------------------------------------------------------}
  643. { LEFT AND RIGHT ARROW CHARACTER CONSTANTS }
  644. {---------------------------------------------------------------------------}
  645. {$IFDEF OS_DOS} CONST LeftArr = #17; RightArr = #16; {$ENDIF}
  646. {$IFDEF OS_WINDOWS} CONST LeftArr = #$AB; RightArr = #$BB; {$ENDIF}
  647. {$IFDEF OS_OS2} CONST LeftArr = #17; RightArr = #16; {$ENDIF}
  648. {---------------------------------------------------------------------------}
  649. { TButton MESSAGES }
  650. {---------------------------------------------------------------------------}
  651. CONST
  652. cmGrabDefault = 61; { Grab default }
  653. cmReleaseDefault = 62; { Release default }
  654. {***************************************************************************}
  655. { PRIVATE INTERNAL ROUTINES }
  656. {***************************************************************************}
  657. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  658. {---------------------------------------------------------------------------}
  659. { TvClusterMsgHandler -> Platforms WIN/NT - Checked 08Jun98 LdB }
  660. {---------------------------------------------------------------------------}
  661. FUNCTION TvClusterMsgHandler (Wnd: hWnd; iMessage, wParam: sw_Word;
  662. lParam: LongInt): LongInt; {$IFDEF BIT_32} STDCALL; {$ELSE} EXPORT; {$ENDIF}
  663. VAR Sel: Integer; W: sw_Word; P: PCluster;
  664. BEGIN
  665. TvClusterMsgHandler := 0; { Reset return of zero }
  666. Case iMessage Of
  667. WM_KeyDown:; { Ignore keypresses }
  668. WM_Command: Begin
  669. If (wParam AND $FFFF = cmTvClusterButton) { Command message }
  670. Then Begin
  671. {$IFDEF BIT_16} { 16 BIT CODE }
  672. PtrRec(P).Seg := GetProp(Wnd, ViewSeg); { Fetch cluster seg }
  673. PtrRec(P).Ofs := GetProp(Wnd, ViewOfs); { Fetch cluster ofs }
  674. {$ENDIF}
  675. {$IFDEF BIT_32} { 32 BIT CODE }
  676. LongInt(P) := GetProp(Wnd, ViewPtr); { Fetch cluster ptr }
  677. {$ENDIF}
  678. If (P <> Nil) AND (P^.WndHandles <> Nil) { Cluster/handles valid }
  679. Then Begin
  680. If (P^.State AND sfFocused = 0) Then { We have not focus }
  681. P^.FocusFromTop; { Focus up to us }
  682. Sel := 0; { Start on first }
  683. {$IFDEF BIT_16} { 16 BIT CODE }
  684. W := LoWord(lParam); { Use only low part }
  685. {$ENDIF}
  686. {$IFDEF BIT_32} { 32 BIT CODE }
  687. W := lParam; { Use full param }
  688. {$ENDIF}
  689. While (Sel < P^.Strings.Count) AND { Valid item }
  690. (W <> P^.WndHandles^[Sel]) Do Inc(Sel); { Find handle }
  691. If (Sel < P^.Strings.Count) Then Begin { Handle was found }
  692. P^.Press(Sel); { Call press }
  693. P^.Sel := Sel; { Set selection }
  694. If (P^.GetState(sfSelected)=False) { Check not selected }
  695. Then P^.Select Else Begin { Select us then }
  696. P^.SetDrawMask(vdFocus OR vdInner); { Redraw inner }
  697. P^.DrawView; { Redraw partial view }
  698. End;
  699. End;
  700. End;
  701. End Else
  702. TvClusterMsgHandler := TvViewMsgHandler(Wnd,
  703. iMessage, wParam, lParam); { Call TV view handler }
  704. End;
  705. Else TvClusterMsgHandler := TvViewMsgHandler(Wnd,
  706. iMessage, wParam, lParam); { Call TV view handler }
  707. End;
  708. END;
  709. {$ENDIF}
  710. {$IFDEF OS_OS2} { OS2 CODE }
  711. {---------------------------------------------------------------------------}
  712. { TvClusterMsgHandler -> Platforms OS2 - Checked ??Sep99 LdB }
  713. {---------------------------------------------------------------------------}
  714. FUNCTION TvClusterMsgHandler (Wnd: hWnd; iMessage, wParam: sw_Word;
  715. lParam: LongInt): LongInt; STDCALL;
  716. VAR Sel: Integer; W: sw_Word; P: PCluster;
  717. BEGIN
  718. TvClusterMsgHandler := 0; { Reset return of zero }
  719. TvClusterMsgHandler := TvViewMsgHandler(Wnd,
  720. iMessage, wParam, lParam); { Call TV view handler }
  721. END;
  722. {$ENDIF}
  723. {---------------------------------------------------------------------------}
  724. { IsBlank -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  725. {---------------------------------------------------------------------------}
  726. FUNCTION IsBlank (Ch: Char): Boolean;
  727. BEGIN
  728. IsBlank := (Ch = ' ') OR (Ch = #13) OR (Ch = #10); { Check for characters }
  729. END;
  730. {---------------------------------------------------------------------------}
  731. { HotKey -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  732. {---------------------------------------------------------------------------}
  733. FUNCTION HotKey (Const S: String): Char;
  734. VAR I: Word;
  735. BEGIN
  736. HotKey := #0; { Preset fail }
  737. If (S <> '') Then Begin { Valid string }
  738. I := Pos('~', S); { Search for tilde }
  739. If (I <> 0) Then HotKey := UpCase(S[I+1]); { Return hotkey }
  740. End;
  741. END;
  742. {***************************************************************************}
  743. { OBJECT METHODS }
  744. {***************************************************************************}
  745. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  746. { TDialog OBJECT METHODS }
  747. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  748. {--TDialog------------------------------------------------------------------}
  749. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  750. {---------------------------------------------------------------------------}
  751. CONSTRUCTOR TDialog.Init (Var Bounds: TRect; ATitle: TTitleStr);
  752. BEGIN
  753. Inherited Init(Bounds, ATitle, wnNoNumber); { Call ancestor }
  754. Options := Options OR ofVersion20; { Version two dialog }
  755. GrowMode := 0; { Clear grow mode }
  756. Flags := wfMove + wfClose; { Close/moveable flags }
  757. Palette := dpGrayDialog; { Default gray colours }
  758. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  759. GOptions := GOptions AND NOT goThickFramed; { Turn thick frame off }
  760. ExStyle := ws_Ex_DlgModalFrame; { Set extended style }
  761. {$ENDIF}
  762. END;
  763. {--TDialog------------------------------------------------------------------}
  764. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  765. {---------------------------------------------------------------------------}
  766. CONSTRUCTOR TDialog.Load (Var S: TStream);
  767. BEGIN
  768. Inherited Load(S); { Call ancestor }
  769. If (Options AND ofVersion = ofVersion10) Then Begin
  770. Palette := dpGrayDialog; { Set gray palette }
  771. Options := Options OR ofVersion20; { Update version flag }
  772. End;
  773. END;
  774. {--TDialog------------------------------------------------------------------}
  775. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  776. {---------------------------------------------------------------------------}
  777. FUNCTION TDialog.GetPalette: PPalette;
  778. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  779. CONST P: Array[dpBlueDialog..dpGrayDialog] Of String =
  780. (CBlueDialog, CCyanDialog, CGrayDialog); { Possible huge string }
  781. {$ELSE} { OTHER COMPILERS }
  782. CONST P: Array[dpBlueDialog..dpGrayDialog] Of String[Length(CBlueDialog)] =
  783. (CBlueDialog, CCyanDialog, CGrayDialog); { Always normal string }
  784. {$ENDIF}
  785. BEGIN
  786. GetPalette := @P[Palette]; { Return palette }
  787. END;
  788. {--TDialog------------------------------------------------------------------}
  789. { Valid -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 25Apr98 LdB }
  790. {---------------------------------------------------------------------------}
  791. FUNCTION TDialog.Valid (Command: Word): Boolean;
  792. BEGIN
  793. If (Command = cmCancel) Then Valid := True { Cancel returns true }
  794. Else Valid := TGroup.Valid(Command); { Call group ancestor }
  795. END;
  796. {--TDialog------------------------------------------------------------------}
  797. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  798. {---------------------------------------------------------------------------}
  799. PROCEDURE TDialog.HandleEvent (Var Event: TEvent);
  800. BEGIN
  801. Inherited HandleEvent(Event); { Call ancestor }
  802. Case Event.What Of
  803. evNothing: Exit; { Speed up exit }
  804. evKeyDown: { Key down event }
  805. Case Event.KeyCode Of
  806. kbEsc: Begin { Escape key press }
  807. Event.What := evCommand; { Command event }
  808. Event.Command := cmCancel; { cancel command }
  809. Event.InfoPtr := Nil; { Clear info ptr }
  810. PutEvent(Event); { Put event on queue }
  811. ClearEvent(Event); { Clear the event }
  812. End;
  813. kbEnter: Begin { Enter key press }
  814. Event.What := evBroadcast; { Broadcast event }
  815. Event.Command := cmDefault; { Default command }
  816. Event.InfoPtr := Nil; { Clear info ptr }
  817. PutEvent(Event); { Put event on queue }
  818. ClearEvent(Event); { Clear the event }
  819. End;
  820. End;
  821. evCommand: { Command event }
  822. Case Event.Command Of
  823. cmOk, cmCancel, cmYes, cmNo: { End dialog cmds }
  824. If (State AND sfModal <> 0) Then Begin { View is modal }
  825. EndModal(Event.Command); { End modal state }
  826. ClearEvent(Event); { Clear the event }
  827. End;
  828. End;
  829. End;
  830. END;
  831. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  832. { TInputLine OBJECT METHODS }
  833. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  834. {--TInputLine---------------------------------------------------------------}
  835. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  836. {---------------------------------------------------------------------------}
  837. CONSTRUCTOR TInputLine.Init (Var Bounds: TRect; AMaxLen: Integer);
  838. BEGIN
  839. Inherited Init(Bounds); { Call ancestor }
  840. State := State OR sfCursorVis; { Cursor visible }
  841. Options := Options OR (ofSelectable + ofFirstClick
  842. + ofVersion20); { Set options }
  843. If (MaxAvail > AMaxLen + 1) Then Begin { Check enough memory }
  844. GetMem(Data, AMaxLen + 1); { Allocate memory }
  845. Data^ := ''; { Data = empty string }
  846. End;
  847. MaxLen := AMaxLen; { Hold maximum length }
  848. END;
  849. {--TInputLine---------------------------------------------------------------}
  850. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  851. {---------------------------------------------------------------------------}
  852. CONSTRUCTOR TInputLine.Load (Var S: TStream);
  853. VAR B: Byte;
  854. BEGIN
  855. Inherited Load(S); { Call ancestor }
  856. S.Read(MaxLen, 2); { Read max length }
  857. S.Read(CurPos, 2); { Read cursor position }
  858. S.Read(FirstPos, 2); { Read first position }
  859. S.Read(SelStart, 2); { Read selected start }
  860. S.Read(SelEnd, 2); { Read selected end }
  861. S.Read(B, 1); { Read string length }
  862. If (MaxAvail > MaxLen+1) Then Begin { Check enough memory }
  863. GetMem(Data, MaxLen + 1); { Allocate memory }
  864. S.Read(Data^[1], Length(Data^)); { Read string data }
  865. {$IFDEF PPC_DELPHI3} { DELPHI 3+ COMPILER }
  866. SetLength(Data^, B); { Xfer string length }
  867. {$ELSE} { OTHER COMPILERS }
  868. Data^[0] := Chr(B); { Set string length }
  869. {$ENDIF}
  870. End Else S.Seek(S.GetPos + B); { Move to position }
  871. If (Options AND ofVersion >= ofVersion20) Then { Version 2 or above }
  872. Validator := PValidator(S.Get); { Get any validator }
  873. Options := Options OR ofVersion20; { Set version 2 flag }
  874. END;
  875. {--TInputLine---------------------------------------------------------------}
  876. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  877. {---------------------------------------------------------------------------}
  878. DESTRUCTOR TInputLine.Done;
  879. BEGIN
  880. If (Data <> Nil) Then FreeMem(Data, MaxLen + 1); { Release any memory }
  881. SetValidator(Nil); { Clear any validator }
  882. Inherited Done; { Call ancestor }
  883. END;
  884. {--TInputLine---------------------------------------------------------------}
  885. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  886. {---------------------------------------------------------------------------}
  887. FUNCTION TInputLine.DataSize: Word;
  888. VAR DSize: Word;
  889. BEGIN
  890. DSize := 0; { Preset zero datasize }
  891. If (Validator <> Nil) AND (Data <> Nil) Then
  892. DSize := Validator^.Transfer(Data^, Nil,
  893. vtDataSize); { Add validator size }
  894. If (DSize <> 0) Then DataSize := DSize { Use validtor size }
  895. Else DataSize := MaxLen + 1; { No validator use size }
  896. END;
  897. {--TInputLine---------------------------------------------------------------}
  898. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  899. {---------------------------------------------------------------------------}
  900. FUNCTION TInputLine.GetPalette: PPalette;
  901. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  902. CONST P: String = CInputLine; { Possible huge string }
  903. {$ELSE} { OTHER COMPILERS }
  904. CONST P: String[Length(CInputLine)] = CInputLine; { Always normal string }
  905. {$ENDIF}
  906. BEGIN
  907. GetPalette := @P; { Return palette }
  908. END;
  909. {--TInputLine---------------------------------------------------------------}
  910. { Valid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  911. {---------------------------------------------------------------------------}
  912. FUNCTION TInputLine.Valid (Command: Word): Boolean;
  913. FUNCTION AppendError (Validator: PValidator): Boolean;
  914. BEGIN
  915. AppendError := False; { Preset false }
  916. If (Data <> Nil) Then
  917. With Validator^ Do
  918. If (Options AND voOnAppend <> 0) AND { Check options }
  919. (CurPos <> Length(Data^)) AND { Exceeds max length }
  920. NOT IsValidInput(Data^, True) Then Begin { Check data valid }
  921. Error; { Call error }
  922. AppendError := True; { Return true }
  923. End;
  924. END;
  925. BEGIN
  926. Valid := Inherited Valid(Command); { Call ancestor }
  927. If (Validator <> Nil) AND (Data <> Nil) AND { Validator present }
  928. (State AND sfDisabled = 0) Then { Not disabled }
  929. If (Command = cmValid) Then { Valid command }
  930. Valid := Validator^.Status = vsOk { Validator result }
  931. Else If (Command <> cmCancel) Then { Not cancel command }
  932. If AppendError(Validator) OR { Append any error }
  933. NOT Validator^.Valid(Data^) Then Begin { Check validator }
  934. Select; { Reselect view }
  935. Valid := False; { Return false }
  936. End;
  937. END;
  938. {--TInputLine---------------------------------------------------------------}
  939. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  940. {---------------------------------------------------------------------------}
  941. PROCEDURE TInputLine.Draw;
  942. VAR Color: Byte; X, L, R: Integer; S, T: String;
  943. BEGIN
  944. If (State AND sfFocused = 0) Then Color := 1 { Not focused colour }
  945. Else Color := 2; { Focused colour }
  946. If CanScroll(-1) Then WriteStr(0, 0, LeftArr, 4); { Set left scroll mark }
  947. If CanScroll(1) Then WriteStr(-(RawSize.X + 1 -
  948. TextWidth(RightArr)), 0, RightArr, 4); { Set right scroll mark }
  949. If (Data <> Nil) Then S := Copy(Data^, FirstPos+1,
  950. Length(Data^)-FirstPos) Else S := ''; { Fetch data string }
  951. X := TextWidth(LeftArr); { left arrow width }
  952. While (TextWidth(S) > ((RawSize.X+1)-X-TextWidth(
  953. RightArr))) Do Delete(S, Length(S), 1); { Cut to right length }
  954. If (State AND sfFocused <> 0) Then Begin
  955. L := SelStart - FirstPos; { Selected left end }
  956. R := SelEnd - FirstPos; { Selected right end }
  957. If (L < 0) Then L := 0; { Fix any negative }
  958. If (R > Length(S)) Then R := Length(S); { Fix to long case }
  959. If (L > 0) Then Begin
  960. T := Copy(S, 1, L); { Unhighlight bit }
  961. WriteStr(-X, 0, T, Color); { Write string to screen }
  962. X := X + TextWidth(T); { New x position }
  963. Delete(S, 1, L); { Reduce string }
  964. End;
  965. If (L < R) Then Begin
  966. T := Copy(S, 1, R-L); { Highlight bit }
  967. WriteStr(-X, 0, T, 3); { Write string to screen }
  968. X := X + TextWidth(T); { New x position }
  969. Delete(S, 1, R-L); { Reduce string }
  970. End;
  971. If (Length(S) > 0) Then
  972. WriteStr(-X, 0, S, Color); { Write string to screen }
  973. End Else WriteStr(-X, 0, S, Color); { Write string to screen }
  974. Cursor.X := CurPos - FirstPos + 1; { Update cursor position }
  975. END;
  976. {--TInputLine---------------------------------------------------------------}
  977. { DrawbackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  978. {---------------------------------------------------------------------------}
  979. PROCEDURE TInputLine.DrawBackGround;
  980. BEGIN
  981. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  982. If (HWindow <> 0) Then DestroyCaret; { Destroy any caret }
  983. {$ENDIF}
  984. {$IFDEF OS_OS2} { OS2 CODE }
  985. If (HWindow <> 0) Then WinDestroyCursor(HWindow); { Destroy any caret }
  986. {$ENDIF}
  987. Inherited DrawBackGround; { Call ancestor }
  988. END;
  989. {--TInputLine---------------------------------------------------------------}
  990. { DrawCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Oct99 LdB }
  991. {---------------------------------------------------------------------------}
  992. PROCEDURE TInputLine.DrawCursor;
  993. VAR I, X: Integer; S: String;
  994. BEGIN
  995. If (State AND sfFocused <> 0) Then Begin { Focused window }
  996. X := TextWidth(LeftArr); { Preset x position }
  997. I := 0; { Preset cursor width }
  998. If (Data <> Nil) Then Begin { Data pointer valid }
  999. S := Copy(Data^, FirstPos+1, CurPos-FirstPos); { Copy the string }
  1000. X := X + TextWidth(S); { Calculate position }
  1001. If (State AND sfCursorIns <> 0) Then { Check insert mode }
  1002. If ((CurPos+1) <= Length(Data^)) Then
  1003. I := TextWidth(Data^[CurPos+1]) { Insert caret width }
  1004. Else I := FontWidth; { At end use fontwidth }
  1005. End;
  1006. {$IFDEF OS_DOS}
  1007. If (State AND sfCursorIns <> 0) Then Begin { Insert mode }
  1008. If ((CurPos+1) <= Length(Data^)) Then { Not beyond end }
  1009. WriteStr(-X, 0, Data^[CurPos+1], 5) { Create block cursor }
  1010. Else ClearArea(X, 0, X+I, FontHeight, Green);{ Line cursor }
  1011. End Else ClearArea(X, 0, X+I, FontHeight, Green);{ Line cursor }
  1012. {$ENDIF}
  1013. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1014. If (HWindow <> 0) Then Begin
  1015. CreateCaret(HWindow, 0, I, FontHeight); { Create a craet }
  1016. SetCaretPos(X, 0); { Set caret position }
  1017. If (State AND sfCursorVis <> 0) Then
  1018. ShowCaret(HWindow); { Show the caret }
  1019. End;
  1020. {$ENDIF}
  1021. {$IFDEF OS_OS2} { OS2 CODE }
  1022. If (HWindow <> 0) Then Begin
  1023. WinCreateCursor(HWindow, X, 0, 0, FontHeight,
  1024. CURSOR_FLASH, Nil); { Create a craet }
  1025. If (State AND sfCursorVis <> 0) Then
  1026. WinShowCursor(HWindow, True); { Show the caret }
  1027. End;
  1028. {$ENDIF}
  1029. End;
  1030. END;
  1031. {--TInputLine---------------------------------------------------------------}
  1032. { SelectAll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1033. {---------------------------------------------------------------------------}
  1034. PROCEDURE TInputLine.SelectAll (Enable: Boolean);
  1035. BEGIN
  1036. CurPos := 0; { Cursor to start }
  1037. FirstPos := 0; { First pos to start }
  1038. SelStart := 0; { Selected at start }
  1039. If Enable AND (Data <> Nil) Then
  1040. SelEnd := Length(Data^) Else SelEnd := 0; { Selected which end }
  1041. DrawView; { Now redraw the view }
  1042. END;
  1043. {--TInputLine---------------------------------------------------------------}
  1044. { SetValidator -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1045. {---------------------------------------------------------------------------}
  1046. PROCEDURE TInputLine.SetValidator (AValid: PValidator);
  1047. BEGIN
  1048. If (Validator <> Nil) Then Validator^.Free; { Release validator }
  1049. Validator := AValid; { Set new validator }
  1050. END;
  1051. {--TInputLine---------------------------------------------------------------}
  1052. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1053. {---------------------------------------------------------------------------}
  1054. PROCEDURE TInputLine.SetState (AState: Word; Enable: Boolean);
  1055. BEGIN
  1056. Inherited SetState(AState, Enable); { Call ancestor }
  1057. If (AState = sfSelected) OR ((AState = sfActive)
  1058. AND (State and sfSelected <> 0)) Then
  1059. SelectAll(Enable) Else { Call select all }
  1060. If (AState = sfFocused) Then DrawView; { Redraw for focus }
  1061. END;
  1062. {--TInputLine---------------------------------------------------------------}
  1063. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1064. {---------------------------------------------------------------------------}
  1065. PROCEDURE TInputLine.GetData (Var Rec);
  1066. BEGIN
  1067. If (Data <> Nil) Then Begin { Data ptr valid }
  1068. If (Validator = Nil) OR (Validator^.Transfer(Data^,
  1069. @Rec, vtGetData) = 0) Then Begin { No validator/data }
  1070. FillChar(Rec, DataSize, #0); { Clear the data area }
  1071. Move(Data^, Rec, Length(Data^) + 1); { Transfer our data }
  1072. End;
  1073. End Else FillChar(Rec, DataSize, #0); { Clear the data area }
  1074. END;
  1075. {--TInputLine---------------------------------------------------------------}
  1076. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1077. {---------------------------------------------------------------------------}
  1078. PROCEDURE TInputLine.SetData (Var Rec);
  1079. {$IFDEF PPC_DELPHI3} VAR Buf: Array [0..256] Of Char; {$ENDIF}
  1080. BEGIN
  1081. If (Data <> Nil) Then Begin { Data ptr valid }
  1082. If (Validator = Nil) OR (Validator^.Transfer(
  1083. Data^, @Rec, vtSetData) = 0) Then { No validator/data }
  1084. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1085. Move(Rec, Buf, DataSize); { Fetch our data }
  1086. Move(Buf[1], Data^[1], Ord(Buf[0])); { Tranfer string }
  1087. SetLength(Data^, Ord(Buf[0])); { Set string length }
  1088. {$ELSE} { OTHER COMPILERS }
  1089. Move(Rec, Data^[0], DataSize); { Set our data }
  1090. {$ENDIF}
  1091. End;
  1092. SelectAll(True); { Now select all }
  1093. END;
  1094. {--TInputLine---------------------------------------------------------------}
  1095. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1096. {---------------------------------------------------------------------------}
  1097. PROCEDURE TInputLine.Store (Var S: TStream);
  1098. BEGIN
  1099. TView.Store(S); { Implict TView.Store }
  1100. S.Write(MaxLen, 2); { Read max length }
  1101. S.Write(CurPos, 2); { Read cursor position }
  1102. S.Write(FirstPos, 2); { Read first position }
  1103. S.Write(SelStart, 2); { Read selected start }
  1104. S.Write(SelEnd, 2); { Read selected end }
  1105. S.WriteStr(Data); { Write the data }
  1106. S.Put(Validator); { Write any validator }
  1107. END;
  1108. {--TInputLine---------------------------------------------------------------}
  1109. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1110. {---------------------------------------------------------------------------}
  1111. PROCEDURE TInputLine.HandleEvent (Var Event: TEvent);
  1112. CONST PadKeys = [$47, $4B, $4D, $4F, $73, $74];
  1113. VAR WasAppending: Boolean; ExtendBlock: Boolean; OldData: String;
  1114. Delta, Anchor, OldCurPos, OldFirstPos, OldSelStart, OldSelEnd: Integer;
  1115. FUNCTION MouseDelta: Integer;
  1116. BEGIN
  1117. If (Event.Where.X <= RawOrigin.X+TextWidth(LeftArr))
  1118. Then MouseDelta := -1 Else { To left of text area }
  1119. If ((Event.Where.X-RawOrigin.X) >= RawSize.X -
  1120. TextWidth(RightArr)) Then MouseDelta := 1 { To right of text area }
  1121. Else MouseDelta := 0; { In area return 0 }
  1122. END;
  1123. FUNCTION MousePos: Integer;
  1124. VAR Mp, Tw, Pos: Integer; S: String;
  1125. BEGIN
  1126. Mp := Event.Where.X - RawOrigin.X; { Mouse position }
  1127. If (Data <> Nil) Then S := Copy(Data^, FirstPos+1,
  1128. Length(Data^)-FirstPos) Else S := ''; { Text area string }
  1129. Tw := TextWidth(LeftArr); { Text width }
  1130. Pos := 0; { Zero position }
  1131. While (Mp > Tw) AND (Pos <= Length(S)) Do Begin { Still text to right }
  1132. Tw := Tw + TextWidth(S[Pos+1]); { Add next character }
  1133. Inc(Pos); { Next character }
  1134. End;
  1135. If (Pos > 0) Then Dec(Pos);
  1136. MousePos := FirstPos + Pos; { Return mouse position }
  1137. END;
  1138. PROCEDURE DeleteSelect;
  1139. BEGIN
  1140. If (SelStart <> SelEnd) Then Begin { An area selected }
  1141. If (Data <> Nil) Then
  1142. Delete(Data^, SelStart+1, SelEnd-SelStart); { Delete the text }
  1143. CurPos := SelStart; { Set cursor position }
  1144. End;
  1145. END;
  1146. PROCEDURE AdjustSelectBlock;
  1147. BEGIN
  1148. If (CurPos < Anchor) Then Begin { Selection backwards }
  1149. SelStart := CurPos; { Start of select }
  1150. SelEnd := Anchor; { End of select }
  1151. End Else Begin
  1152. SelStart := Anchor; { Start of select }
  1153. SelEnd := CurPos; { End of select }
  1154. End;
  1155. END;
  1156. PROCEDURE SaveState;
  1157. BEGIN
  1158. If (Validator <> Nil) Then Begin { Check for validator }
  1159. If (Data <> Nil) Then OldData := Data^; { Hold data }
  1160. OldCurPos := CurPos; { Hold cursor position }
  1161. OldFirstPos := FirstPos; { Hold first position }
  1162. OldSelStart := SelStart; { Hold select start }
  1163. OldSelEnd := SelEnd; { Hold select end }
  1164. If (Data = Nil) Then WasAppending := True { Invalid data ptr }
  1165. Else WasAppending := Length(Data^) = CurPos; { Hold appending state }
  1166. End;
  1167. END;
  1168. PROCEDURE RestoreState;
  1169. BEGIN
  1170. If (Validator <> Nil) Then Begin { Validator valid }
  1171. If (Data <> Nil) Then Data^ := OldData; { Restore data }
  1172. CurPos := OldCurPos; { Restore cursor pos }
  1173. FirstPos := OldFirstPos; { Restore first pos }
  1174. SelStart := OldSelStart; { Restore select start }
  1175. SelEnd := OldSelEnd; { Restore select end }
  1176. End;
  1177. END;
  1178. FUNCTION CheckValid (NoAutoFill: Boolean): Boolean;
  1179. VAR OldLen: Integer; NewData: String;
  1180. BEGIN
  1181. If (Validator <> Nil) Then Begin { Validator valid }
  1182. CheckValid := False; { Preset false return }
  1183. If (Data <> Nil) Then OldLen := Length(Data^); { Hold old length }
  1184. If (Validator^.Options AND voOnAppend = 0) OR
  1185. (WasAppending AND (CurPos = OldLen)) Then Begin
  1186. If (Data <> Nil) Then NewData := Data^ { Hold current data }
  1187. Else NewData := ''; { Set empty string }
  1188. If NOT Validator^.IsValidInput(NewData,
  1189. NoAutoFill) Then RestoreState Else Begin
  1190. If (Length(NewData) > MaxLen) Then { Exceeds maximum }
  1191. {$IFDEF PPC_DELPHI3} { DELPHI 3+ COMPILER }
  1192. SetLength(NewData, MaxLen); { Set string length }
  1193. {$ELSE} { OTHER COMPILERS }
  1194. NewData[0] := Chr(MaxLen); { Set string length }
  1195. {$ENDIF}
  1196. If (Data <> Nil) Then Data^ := NewData; { Set data value }
  1197. If (Data <> Nil) AND (CurPos >= OldLen) { Cursor beyond end }
  1198. AND (Length(Data^) > OldLen) Then { Cursor beyond string }
  1199. CurPos := Length(Data^); { Set cursor position }
  1200. CheckValid := True; { Return true result }
  1201. End;
  1202. End Else Begin
  1203. CheckValid := True; { Preset true return }
  1204. If (CurPos = OldLen) AND (Data <> Nil) Then { Lengths match }
  1205. If NOT Validator^.IsValidInput(Data^,
  1206. False) Then Begin { Check validator }
  1207. Validator^.Error; { Call error }
  1208. CheckValid := False; { Return false result }
  1209. End;
  1210. End;
  1211. End Else CheckValid := True; { No validator }
  1212. END;
  1213. BEGIN
  1214. Inherited HandleEvent(Event); { Call ancestor }
  1215. If (State AND sfSelected <> 0) Then Begin { View is selected }
  1216. Case Event.What Of
  1217. evNothing: Exit; { Speed up exit }
  1218. evMouseDown: Begin { Mouse down event }
  1219. Delta := MouseDelta; { Calc scroll value }
  1220. If CanScroll(Delta) Then Begin { Can scroll }
  1221. Repeat
  1222. If CanScroll(Delta) Then Begin { Still can scroll }
  1223. Inc(FirstPos, Delta); { Move start position }
  1224. DrawView; { Redraw the view }
  1225. End;
  1226. Until NOT MouseEvent(Event, evMouseAuto); { Until no mouse auto }
  1227. End Else If Event.Double Then { Double click }
  1228. SelectAll(True) Else Begin { Select whole text }
  1229. Anchor := MousePos; { Start of selection }
  1230. Repeat
  1231. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  1232. If (Event.What = evMouseAuto) { Mouse auto event }
  1233. {$ELSE} { WIN/NT/OS2 CODE }
  1234. If (Event.What = evMouseMove) { Mouse move event }
  1235. {$ENDIF}
  1236. Then Begin
  1237. Delta := MouseDelta; { New position }
  1238. If CanScroll(Delta) Then { If can scroll }
  1239. Inc(FirstPos, Delta);
  1240. End;
  1241. CurPos := MousePos; { Set cursor position }
  1242. AdjustSelectBlock; { Adjust selected }
  1243. DrawView; { Redraw the view }
  1244. Until NOT MouseEvent(Event, evMouseMove
  1245. + evMouseAuto); { Until mouse released }
  1246. End;
  1247. ClearEvent(Event); { Clear the event }
  1248. End;
  1249. evKeyDown: Begin
  1250. SaveState; { Save state of view }
  1251. Event.KeyCode := CtrlToArrow(Event.KeyCode); { Convert keycode }
  1252. If (Event.ScanCode IN PadKeys) AND
  1253. (GetShiftState AND $03 <> 0) Then Begin { Mark selection active }
  1254. Event.CharCode := #0; { Clear char code }
  1255. If (CurPos = SelEnd) Then { Find if at end }
  1256. Anchor := SelStart Else { Anchor from start }
  1257. Anchor := SelEnd; { Anchor from end }
  1258. ExtendBlock := True; { Extended block true }
  1259. End Else ExtendBlock := False; { No extended block }
  1260. Case Event.KeyCode Of
  1261. kbLeft: If (CurPos > 0) Then Dec(CurPos); { Move cursor left }
  1262. kbRight: If (Data <> Nil) AND { Move right cursor }
  1263. (CurPos < Length(Data^)) Then Begin { Check not at end }
  1264. Inc(CurPos); { Move cursor }
  1265. CheckValid(True); { Check if valid }
  1266. End;
  1267. kbHome: CurPos := 0; { Move to line start }
  1268. kbEnd: Begin { Move to line end }
  1269. If (Data = Nil) Then CurPos := 0 { Invalid data ptr }
  1270. Else CurPos := Length(Data^); { Set cursor position }
  1271. CheckValid(True); { Check if valid }
  1272. End;
  1273. kbBack: If (Data <> Nil) AND (CurPos > 0) { Not at line start }
  1274. Then Begin
  1275. Delete(Data^, CurPos, 1); { Backspace over char }
  1276. Dec(CurPos); { Move cursor back one }
  1277. If (FirstPos > 0) Then Dec(FirstPos); { Move first position }
  1278. CheckValid(True); { Check if valid }
  1279. End;
  1280. kbDel: If (Data <> Nil) Then Begin { Delete character }
  1281. If (SelStart = SelEnd) Then { Select all on }
  1282. If (CurPos < Length(Data^)) Then Begin { Cursor not at end }
  1283. SelStart := CurPos; { Set select start }
  1284. SelEnd := CurPos + 1; { Set select end }
  1285. End;
  1286. DeleteSelect; { Deselect selection }
  1287. CheckValid(True); { Check if valid }
  1288. End;
  1289. kbIns: SetState(sfCursorIns, State AND
  1290. sfCursorIns = 0); { Flip insert state }
  1291. Else Case Event.CharCode Of
  1292. ' '..#255: If (Data <> Nil) Then Begin { Character key }
  1293. If (State AND sfCursorIns <> 0) Then
  1294. Delete(Data^, CurPos + 1, 1) Else { Overwrite character }
  1295. DeleteSelect; { Deselect selected }
  1296. If CheckValid(True) Then Begin { Check data valid }
  1297. If (Length(Data^) < MaxLen) Then { Must not exceed maxlen }
  1298. Begin
  1299. If (FirstPos > CurPos) Then
  1300. FirstPos := CurPos; { Advance first position }
  1301. Inc(CurPos); { Increment cursor }
  1302. Insert(Event.CharCode, Data^,
  1303. CurPos); { Insert the character }
  1304. End;
  1305. CheckValid(False); { Check data valid }
  1306. End;
  1307. End;
  1308. ^Y: If (Data <> Nil) Then Begin { Clear all data }
  1309. Data^ := ''; { Set empty string }
  1310. CurPos := 0; { Cursor to start }
  1311. End;
  1312. Else Exit; { Unused key }
  1313. End
  1314. End;
  1315. If ExtendBlock Then AdjustSelectBlock { Extended block }
  1316. Else Begin
  1317. SelStart := CurPos; { Set select start }
  1318. SelEnd := CurPos; { Set select end }
  1319. End;
  1320. If (FirstPos > CurPos) Then
  1321. FirstPos := CurPos; { Advance first pos }
  1322. If (Data <> Nil) Then OldData := Copy(Data^,
  1323. FirstPos+1, CurPos-FirstPos) { Text area string }
  1324. Else OldData := ''; { Empty string }
  1325. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  1326. Delta := FontWidth; { Safety = 1 char }
  1327. {$ELSE} { WIN/NT CODE }
  1328. Delta := 2*FontWidth; { Safety = 2 char }
  1329. {$ENDIF}
  1330. While (TextWidth(OldData) > ((RawSize.X+1)-Delta)
  1331. - TextWidth(LeftArr) - TextWidth(RightArr)) { Check text fits }
  1332. Do Begin
  1333. Inc(FirstPos); { Advance first pos }
  1334. OldData := Copy(Data^, FirstPos+1,
  1335. CurPos-FirstPos) { Text area string }
  1336. End;
  1337. DrawView; { Redraw the view }
  1338. ClearEvent(Event); { Clear the event }
  1339. End;
  1340. End;
  1341. End;
  1342. END;
  1343. {***************************************************************************}
  1344. { TInputLine OBJECT PRIVATE METHODS }
  1345. {***************************************************************************}
  1346. {--TInputLine---------------------------------------------------------------}
  1347. { CanScroll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1348. {---------------------------------------------------------------------------}
  1349. FUNCTION TInputLine.CanScroll (Delta: Integer): Boolean;
  1350. VAR S: String;
  1351. BEGIN
  1352. If (Delta < 0) Then CanScroll := FirstPos > 0 { Check scroll left }
  1353. Else If (Delta > 0) Then Begin
  1354. If (Data = Nil) Then S := '' Else { Data ptr invalid }
  1355. S := Copy(Data^, FirstPos+1, Length(Data^)
  1356. - FirstPos); { Fetch max string }
  1357. CanScroll := (TextWidth(S)) > (RawSize.X -
  1358. TextWidth(LeftArr) - TextWidth(RightArr)); { Check scroll right }
  1359. End Else CanScroll := False; { Zero so no scroll }
  1360. END;
  1361. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1362. { TButton OBJECT METHODS }
  1363. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1364. {--TButton------------------------------------------------------------------}
  1365. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1366. {---------------------------------------------------------------------------}
  1367. CONSTRUCTOR TButton.Init (Var Bounds: TRect; ATitle: TTitleStr;
  1368. ACommand: Word; AFlags: Word);
  1369. BEGIN
  1370. Inherited Init(Bounds); { Call ancestor }
  1371. EventMask := EventMask OR evBroadcast; { Handle broadcasts }
  1372. GOptions := GOptions OR goDrawFocus; { Set new option mask }
  1373. Options := Options OR (ofSelectable + ofFirstClick
  1374. + ofPreProcess + ofPostProcess); { Set option flags }
  1375. If NOT CommandEnabled(ACommand) Then
  1376. State := State OR sfDisabled; { Check command state }
  1377. Flags := AFlags; { Hold flags }
  1378. If (AFlags AND bfDefault <> 0) Then AmDefault := True
  1379. Else AmDefault := False; { Check if default }
  1380. Title := NewStr(ATitle); { Hold title string }
  1381. Command := ACommand; { Hold button command }
  1382. TabMask := TabMask OR (tmLeft + tmRight +
  1383. tmTab + tmShiftTab + tmUp + tmDown); { Set tab masks }
  1384. END;
  1385. {--TButton------------------------------------------------------------------}
  1386. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1387. {---------------------------------------------------------------------------}
  1388. CONSTRUCTOR TButton.Load (Var S: TStream);
  1389. BEGIN
  1390. Inherited Load(S); { Call ancestor }
  1391. Title := S.ReadStr; { Read title }
  1392. S.Read(Command, 2); { Read command }
  1393. S.Read(Flags, 1); { Read flags }
  1394. S.Read(AmDefault, 1); { Read if default }
  1395. If NOT CommandEnabled(Command) Then { Check command state }
  1396. State := State OR sfDisabled Else { Command disabled }
  1397. State := State AND NOT sfDisabled; { Command enabled }
  1398. END;
  1399. {--TButton------------------------------------------------------------------}
  1400. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1401. {---------------------------------------------------------------------------}
  1402. DESTRUCTOR TButton.Done;
  1403. BEGIN
  1404. If (Title <> Nil) Then DisposeStr(Title); { Dispose title }
  1405. Inherited Done; { Call ancestor }
  1406. END;
  1407. {--TButton------------------------------------------------------------------}
  1408. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1409. {---------------------------------------------------------------------------}
  1410. FUNCTION TButton.GetPalette: PPalette;
  1411. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1412. CONST P: String = CButton; { Possible huge string }
  1413. {$ELSE} { OTHER COMPILERS }
  1414. CONST P: String[Length(CButton)] = CButton; { Always normal string }
  1415. {$ENDIF}
  1416. BEGIN
  1417. GetPalette := @P; { Get button palette }
  1418. END;
  1419. {--TButton------------------------------------------------------------------}
  1420. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Apr98 LdB }
  1421. {---------------------------------------------------------------------------}
  1422. PROCEDURE TButton.Press;
  1423. VAR E: TEvent;
  1424. BEGIN
  1425. Message(Owner, evBroadcast, cmRecordHistory, Nil); { Message for history }
  1426. If (Flags AND bfBroadcast <> 0) Then { Broadcasting button }
  1427. Message(Owner, evBroadcast, Command, @Self) { Send message }
  1428. Else Begin
  1429. E.What := evCommand; { Command event }
  1430. E.Command := Command; { Set command value }
  1431. E.InfoPtr := @Self; { Pointer to self }
  1432. PutEvent(E); { Put event on queue }
  1433. End;
  1434. END;
  1435. {--TButton------------------------------------------------------------------}
  1436. { DrawFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1437. {---------------------------------------------------------------------------}
  1438. PROCEDURE TButton.DrawFocus;
  1439. VAR B: Byte; I: Integer; Bc: Word; Db: TDrawBuffer;
  1440. BEGIN
  1441. If DownFlag Then B := 7 Else B := 0; { Shadow colour }
  1442. GraphRectangle(0, 0, RawSize.X, RawSize.Y, B); { Draw backing shadow }
  1443. GraphRectangle(1, 1, RawSize.X-1, RawSize.Y-1, B); { Draw backing shadow }
  1444. If DownFlag Then B := 0 Else B := 15; { Highlight colour }
  1445. GraphLine(0, RawSize.Y, 0, 0, B);
  1446. GraphLine(1, RawSize.Y-1, 1, 1, B); { Left highlights }
  1447. GraphLine(0, 0, RawSize.X, 0, B);
  1448. GraphLine(1, 1, RawSize.X-1, 1, B); { Top highlights }
  1449. If DownFlag Then B := 8 Else B := 7; { Select backing }
  1450. If (State AND sfFocused <> 0) AND
  1451. (DownFlag = False) Then B := 14; { Show as focused }
  1452. GraphRectangle(2, 2, RawSize.X-2, RawSize.Y-2, B); { Draw first border }
  1453. GraphRectangle(3, 3, RawSize.X-3, RawSize.Y-3, B); { Draw next border }
  1454. If (State AND sfDisabled <> 0) Then { Button disabled }
  1455. Bc := GetColor($0404) Else Begin { Disabled colour }
  1456. Bc := GetColor($0501); { Set normal colour }
  1457. If (State AND sfActive <> 0) Then { Button is active }
  1458. If (State AND sfSelected <> 0) Then
  1459. Bc := GetColor($0703) Else { Set selected colour }
  1460. If AmDefault Then Bc := GetColor($0602); { Set is default colour }
  1461. End;
  1462. If (Title <> Nil) Then Begin { We have a title }
  1463. If (Flags AND bfLeftJust = 0) Then Begin { Not left set title }
  1464. I := TextWidth(Title^); { Fetch title width }
  1465. I := (RawSize.X - I) DIV 2; { Centre in button }
  1466. End Else I := FontWidth; { Left edge of button }
  1467. MoveCStr(Db, Title^, Bc); { Move title to buffer }
  1468. GOptions := GOptions OR goGraphView; { Graphics co-ords mode }
  1469. WriteLine(I, FontHeight DIV 2, CStrLen(Title^),
  1470. 1, Db); { Write the title }
  1471. GOptions := GOptions AND NOT goGraphView; { Return to normal mode }
  1472. End;
  1473. END;
  1474. {--TButton------------------------------------------------------------------}
  1475. { DrawState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1476. {---------------------------------------------------------------------------}
  1477. PROCEDURE TButton.DrawState (Down: Boolean);
  1478. BEGIN
  1479. DownFlag := Down; { Set down flag }
  1480. SetDrawMask(vdFocus); { Set focus mask }
  1481. DrawView; { Redraw the view }
  1482. END;
  1483. {--TButton------------------------------------------------------------------}
  1484. { MakeDefault -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1485. {---------------------------------------------------------------------------}
  1486. PROCEDURE TButton.MakeDefault (Enable: Boolean);
  1487. VAR C: Word;
  1488. BEGIN
  1489. If (Flags AND bfDefault=0) Then Begin { Not default }
  1490. If Enable Then C := cmGrabDefault
  1491. Else C := cmReleaseDefault; { Change default }
  1492. Message(Owner, evBroadcast, C, @Self); { Message to owner }
  1493. AmDefault := Enable; { Set default flag }
  1494. DrawView; { Now redraw button }
  1495. End;
  1496. END;
  1497. {--TButton------------------------------------------------------------------}
  1498. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1499. {---------------------------------------------------------------------------}
  1500. PROCEDURE TButton.SetState (AState: Word; Enable: Boolean);
  1501. BEGIN
  1502. Inherited SetState(AState, Enable); { Call ancestor }
  1503. If (AState AND (sfSelected + sfActive) <> 0) { Changing select }
  1504. Then DrawView; { Redraw required }
  1505. If (AState AND sfFocused <> 0) Then
  1506. MakeDefault(Enable); { Check for default }
  1507. END;
  1508. {--TButton------------------------------------------------------------------}
  1509. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  1510. {---------------------------------------------------------------------------}
  1511. PROCEDURE TButton.Store (Var S: TStream);
  1512. BEGIN
  1513. TView.Store(S); { Implict TView.Store }
  1514. S.WriteStr(Title); { Store title string }
  1515. S.Write(Command, 2); { Store command }
  1516. S.Write(Flags, 1); { Store flags }
  1517. S.Write(AmDefault, 1); { Store default flag }
  1518. END;
  1519. {--TButton------------------------------------------------------------------}
  1520. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Sep99 LdB }
  1521. {---------------------------------------------------------------------------}
  1522. PROCEDURE TButton.HandleEvent (Var Event: TEvent);
  1523. VAR Down: Boolean; C: Char; ButRect: TRect;
  1524. BEGIN
  1525. ButRect.A := RawOrigin; { Get origin point }
  1526. ButRect.B.X := RawOrigin.X + RawSize.X; { Calc right side }
  1527. ButRect.B.Y := RawOrigin.Y + RawSize.Y; { Calc bottom }
  1528. If (Event.What = evMouseDown) Then Begin { Mouse down event }
  1529. If NOT MouseInView(Event.Where) Then Begin { If point not in view }
  1530. ClearEvent(Event); { Clear the event }
  1531. Exit; { Speed up exit }
  1532. End;
  1533. End;
  1534. If (Flags AND bfGrabFocus <> 0) Then { Check focus grab }
  1535. Inherited HandleEvent(Event); { Call ancestor }
  1536. Case Event.What Of
  1537. evNothing: Exit; { Speed up exit }
  1538. evMouseDown: Begin
  1539. If (State AND sfDisabled = 0) Then Begin { Button not disabled }
  1540. Down := False; { Clear down flag }
  1541. Repeat
  1542. If (Down <> ButRect.Contains(Event.Where)) { State has changed }
  1543. Then Begin
  1544. Down := NOT Down; { Invert down flag }
  1545. DrawState(Down); { Redraw button }
  1546. End;
  1547. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse move }
  1548. If Down Then Begin { Button is down }
  1549. Press; { Send out command }
  1550. DrawState(False); { Draw button up }
  1551. End;
  1552. End;
  1553. ClearEvent(Event); { Event was handled }
  1554. End;
  1555. evKeyDown: Begin
  1556. If (Title <> Nil) Then C := HotKey(Title^) { Key title hotkey }
  1557. Else C := #0; { Invalid title }
  1558. If (Event.KeyCode = GetAltCode(C)) OR { Alt char }
  1559. (Owner^.Phase = phPostProcess) AND (C <> #0)
  1560. AND (Upcase(Event.CharCode) = C) OR { Matches hotkey }
  1561. (State AND sfFocused <> 0) AND { View focused }
  1562. ((Event.CharCode = ' ') OR { Space bar }
  1563. (Event.KeyCode=kbEnter)) Then Begin { Enter key }
  1564. DrawState(True); { Draw button down }
  1565. Press; { Send out command }
  1566. ClearEvent(Event); { Clear the event }
  1567. DrawState(False); { Draw button up }
  1568. End;
  1569. End;
  1570. evBroadcast:
  1571. Case Event.Command of
  1572. cmDefault: If AmDefault AND { Default command }
  1573. (State AND sfDisabled = 0) Then Begin { Button enabled }
  1574. Press; { Send out command }
  1575. ClearEvent(Event); { Clear the event }
  1576. End;
  1577. cmGrabDefault, cmReleaseDefault: { Grab and release cmd }
  1578. If (Flags AND bfDefault <> 0) Then Begin { Change button state }
  1579. AmDefault := Event.Command = cmReleaseDefault;
  1580. DrawView; { Redraw the view }
  1581. End;
  1582. cmCommandSetChanged: Begin { Command set changed }
  1583. SetState(sfDisabled, NOT
  1584. CommandEnabled(Command)); { Set button state }
  1585. DrawView; { Redraw the view }
  1586. End;
  1587. End;
  1588. End;
  1589. END;
  1590. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1591. { TCluster OBJECT METHODS }
  1592. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1593. CONST TvClusterClassName = 'TVCLUSTER';
  1594. {--TCluster-----------------------------------------------------------------}
  1595. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  1596. {---------------------------------------------------------------------------}
  1597. CONSTRUCTOR TCluster.Init (Var Bounds: TRect; AStrings: PSItem);
  1598. VAR I: Integer; P: PSItem;
  1599. BEGIN
  1600. Inherited Init(Bounds); { Call ancestor }
  1601. GOptions := GOptions OR goDrawFocus; { Draw focus view }
  1602. Options := Options OR (ofSelectable + ofFirstClick
  1603. + ofPreProcess + ofPostProcess + ofVersion20); { Set option masks }
  1604. I := 0; { Zero string count }
  1605. P := AStrings; { First item }
  1606. While (P <> Nil) Do Begin
  1607. Inc(I); { Count 1 item }
  1608. P := P^.Next; { Move to next item }
  1609. End;
  1610. Strings.Init(I, 0); { Create collection }
  1611. While (AStrings <> Nil) Do Begin
  1612. P := AStrings; { Transfer item ptr }
  1613. Strings.AtInsert(Strings.Count, AStrings^.Value);{ Insert string }
  1614. AStrings := AStrings^.Next; { Move to next item }
  1615. Dispose(P); { Dispose prior item }
  1616. End;
  1617. EnableMask := $FFFFFFFF; { Enable bit masks }
  1618. END;
  1619. {--TCluster-----------------------------------------------------------------}
  1620. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Oct99 LdB }
  1621. {---------------------------------------------------------------------------}
  1622. CONSTRUCTOR TCluster.Load (Var S: TStream);
  1623. BEGIN
  1624. Inherited Load(S); { Call ancestor }
  1625. S.Read(Value, 4); { Read value }
  1626. S.Read(Sel, 2); { Read select item }
  1627. If ((Options AND ofVersion) >= ofVersion20) { Version 2 TV view }
  1628. Then S.Read(EnableMask, 4) Else Begin { Read enable masks }
  1629. EnableMask := $FFFFFFFF; { Enable all masks }
  1630. Options := Options OR ofVersion20; { Set version 2 mask }
  1631. End;
  1632. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  1633. S.Read(Id, 2); { Read view id }
  1634. Strings.Load(S); { Load string data }
  1635. SetButtonState(0, True); { Set button state }
  1636. END;
  1637. {--TCluster-----------------------------------------------------------------}
  1638. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  1639. {---------------------------------------------------------------------------}
  1640. DESTRUCTOR TCluster.Done;
  1641. VAR I: Integer;
  1642. BEGIN
  1643. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  1644. If (WndHandles <> Nil) Then Begin { Handles valid }
  1645. For I := 1 To Strings.Count Do { For each entry }
  1646. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1647. DestroyWindow(WndHandles^[I-1]); { Destroy button views }
  1648. {$ELSE} { OS2 CODE }
  1649. WinDestroyWindow(WndHandles^[I-1]); { Destroy button views }
  1650. {$ENDIF}
  1651. FreeMem(WndHandles, Strings.Count*SizeOf(HWnd)); { Release memory }
  1652. End;
  1653. {$ENDIF}
  1654. Strings.Done; { Dispose of strings }
  1655. Inherited Done; { Call ancestor }
  1656. END;
  1657. {--TCluster-----------------------------------------------------------------}
  1658. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1659. {---------------------------------------------------------------------------}
  1660. FUNCTION TCluster.DataSize: Word;
  1661. BEGIN
  1662. DataSize := SizeOf(Word); { Exchanges a word }
  1663. END;
  1664. {--TCluster-----------------------------------------------------------------}
  1665. { GetHelpCtx -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1666. {---------------------------------------------------------------------------}
  1667. FUNCTION TCluster.GetHelpCtx: Word;
  1668. BEGIN
  1669. If (HelpCtx = hcNoContext) Then { View has no help }
  1670. GetHelpCtx := hcNoContext Else { No help context }
  1671. GetHelpCtx := HelpCtx + Sel; { Help of selected }
  1672. END;
  1673. {--TCluster-----------------------------------------------------------------}
  1674. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1675. {---------------------------------------------------------------------------}
  1676. FUNCTION TCluster.GetPalette: PPalette;
  1677. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1678. CONST P: String = CCluster; { Possible huge string }
  1679. {$ELSE} { OTHER COMPILERS }
  1680. CONST P: String[Length(CCluster)] = CCluster; { Always normal string }
  1681. {$ENDIF}
  1682. BEGIN
  1683. GetPalette := @P; { Cluster palette }
  1684. END;
  1685. {--TCluster-----------------------------------------------------------------}
  1686. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1687. {---------------------------------------------------------------------------}
  1688. FUNCTION TCluster.Mark (Item: Integer): Boolean;
  1689. BEGIN
  1690. Mark := False; { Default false }
  1691. END;
  1692. {--TCluster-----------------------------------------------------------------}
  1693. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1694. {---------------------------------------------------------------------------}
  1695. FUNCTION TCluster.MultiMark (Item: Integer): Byte;
  1696. BEGIN
  1697. MultiMark := Byte(Mark(Item) = True); { Return multi mark }
  1698. END;
  1699. {--TCluster-----------------------------------------------------------------}
  1700. { ButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1701. {---------------------------------------------------------------------------}
  1702. FUNCTION TCluster.ButtonState (Item: Integer): Boolean;
  1703. BEGIN
  1704. If (Item > 31) Then ButtonState := False Else { Impossible item }
  1705. ButtonState := ((1 SHL Item) AND EnableMask)<>0; { Return true/false }
  1706. END;
  1707. {--TCluster-----------------------------------------------------------------}
  1708. { DrawFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Jul99 LdB }
  1709. {---------------------------------------------------------------------------}
  1710. PROCEDURE TCluster.DrawFocus;
  1711. BEGIN
  1712. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  1713. If (WndHandles <> Nil) Then { Valid window handles }
  1714. If (State AND sfFocused <> 0) Then Begin { View is focused }
  1715. If (Sel >= 0) AND (Sel < Strings.Count) Then
  1716. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1717. SetFocus(WndHandles^[Sel]) { Focus selected view }
  1718. Else SetFocus(AppWindow); { Focus owner }
  1719. {$ELSE} { OS2 CODE }
  1720. WinSetFocus(HWND_DESKTOP, WndHandles^[Sel]) { Focus selected view }
  1721. Else WinSetFocus(HWND_DESKTOP, HWindow); { Focus owner }
  1722. {$ENDIF}
  1723. End Else
  1724. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1725. SetFocus(AppWindow); { Focus owner }
  1726. {$ELSE} { OS2 CODE }
  1727. WinSetFocus(HWND_DESKTOP, AppWindow); { Focus owner }
  1728. {$ENDIF}
  1729. {$ENDIF}
  1730. END;
  1731. {--TCluster-----------------------------------------------------------------}
  1732. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1733. {---------------------------------------------------------------------------}
  1734. PROCEDURE TCluster.Press (Item: Integer);
  1735. VAR P: PView;
  1736. BEGIN
  1737. P := TopView;
  1738. If (Id <> 0) AND (P <> Nil) Then NewMessage(P,
  1739. evCommand, cmIdCommunicate, Id, Value, @Self); { Send new message }
  1740. END;
  1741. {--TCluster-----------------------------------------------------------------}
  1742. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1743. {---------------------------------------------------------------------------}
  1744. PROCEDURE TCluster.MovedTo (Item: Integer);
  1745. BEGIN { Abstract method }
  1746. END;
  1747. {--TCluster-----------------------------------------------------------------}
  1748. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1749. {---------------------------------------------------------------------------}
  1750. PROCEDURE TCluster.SetState (AState: Word; Enable: Boolean);
  1751. BEGIN
  1752. Inherited SetState(AState, Enable); { Call ancestor }
  1753. If (AState AND sfFocused <> 0) Then Begin
  1754. SetDrawMask(vdFocus OR vdInner); { Set redraw masks }
  1755. DrawView; { Redraw masked areas }
  1756. End;
  1757. END;
  1758. {--TCluster-----------------------------------------------------------------}
  1759. { DrawMultiBox -> Platforms DOS/DPMI/WIN/NT - Updated 05Jun98 LdB }
  1760. {---------------------------------------------------------------------------}
  1761. PROCEDURE TCluster.DrawMultiBox (Const Icon, Marker: String);
  1762. VAR I, J, K, Cur, Col: Integer; CNorm, CSel, CDis, Color: Word; B: TDrawBuffer;
  1763. Tb, SCOff: Byte;
  1764. {$IFNDEF OS_DOS} S: String; P: PString; Q: PChar; {$ENDIF}
  1765. BEGIN
  1766. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  1767. CNorm := GetColor($0301); { Normal colour }
  1768. CSel := GetColor($0402); { Selected colour }
  1769. CDis := GetColor($0505); { Disabled colour }
  1770. If (Options AND ofFramed <>0) OR { Normal frame }
  1771. (GOptions AND goThickFramed <>0) Then { Thick frame }
  1772. K := 1 Else K := 0; { Select offset }
  1773. For I := 0 To Size.Y-K-K-1 Do Begin { For each line }
  1774. MoveChar(B, ' ', Byte(CNorm), Size.X-K-K); { Fill buffer }
  1775. For J := 0 To (Strings.Count - 1) DIV Size.Y + 1
  1776. Do Begin
  1777. Cur := J*Size.Y + I; { Current line }
  1778. If (Cur < Strings.Count) Then Begin
  1779. Col := Column(Cur); { Calc column }
  1780. If (Col + CStrLen(PString(Strings.At(Cur))^)+
  1781. 5 < Sizeof(TDrawBuffer) DIV SizeOf(Word))
  1782. AND (Col < Size.X-K-K) Then Begin { Text fits in column }
  1783. If NOT ButtonState(Cur) Then
  1784. Color := CDis Else If (Cur = Sel) AND { Disabled colour }
  1785. (State and sfFocused <> 0) Then
  1786. Color := CSel Else { Selected colour }
  1787. Color := CNorm; { Normal colour }
  1788. MoveChar(B[Col], ' ', Byte(Color),
  1789. Size.X-K-K-Col); { Set this colour }
  1790. MoveStr(B[Col], Icon, Byte(Color)); { Transfer icon string }
  1791. WordRec(B[Col+2]).Lo := Byte(Marker[
  1792. MultiMark(Cur) + 1]); { Transfer marker }
  1793. MoveCStr(B[Col+5], PString(Strings.At(
  1794. Cur))^, Color); { Transfer item string }
  1795. If ShowMarkers AND (State AND sfFocused <> 0)
  1796. AND (Cur = Sel) Then Begin { Current is selected }
  1797. WordRec(B[Col]).Lo := Byte(SpecialChars[0]);
  1798. WordRec(B[Column(Cur+Size.Y)-1]).Lo
  1799. := Byte(SpecialChars[1]); { Set special character }
  1800. End;
  1801. End;
  1802. End;
  1803. End;
  1804. WriteBuf(K, K+I, Size.X-K-K, 1, B); { Write buffer }
  1805. End;
  1806. {$ELSE} { WIN/NT/OS2 CODE }
  1807. If (WndHandles <> Nil) Then Begin { Valid window handles }
  1808. For I := 1 To Strings.Count Do Begin { For each window }
  1809. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1810. Tb := GetWindowText(WndHandles^[I-1], @S[1],
  1811. 255); { Get window text }
  1812. {$ELSE} { OS2 CODE }
  1813. Tb := WinQueryWindowText(WndHandles^[I-1], 255,
  1814. @S[1]); { Get window text }
  1815. {$ENDIF}
  1816. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1817. SetLength(S, Tb); { Set string length }
  1818. {$ELSE} { OTHER COMPILERS }
  1819. S[0] := Chr(Tb); { Set string length }
  1820. {$ENDIF}
  1821. P := Strings.At(I-1); { Cluster strings }
  1822. If (P <> Nil) AND (P^ <> S) Then Begin { Something changed }
  1823. S := P^ + #0; { Transfer string }
  1824. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1825. SetWindowText(WndHandles^[I-1], @S[1]); { Set new window text }
  1826. {$ELSE} { OS2 CODE }
  1827. WinSetWindowText(WndHandles^[I-1], @S[1]); { Set new window text }
  1828. {$ENDIF}
  1829. End;
  1830. If Mark(I-1) Then { If item marked }
  1831. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1832. SendMessage(WndHandles^[I-1], bm_SetCheck,
  1833. 1, 0) Else { Check the box }
  1834. SendMessage(WndHandles^[I-1], bm_SetCheck,
  1835. 0, 0); { Uncheck the box }
  1836. {$ELSE} { OS2 CODE }
  1837. WinSendMsg(WndHandles^[I-1], bm_SetCheck,
  1838. 1, 0) Else { Check the box }
  1839. WinSendMsg(WndHandles^[I-1], bm_SetCheck,
  1840. 0, 0); { Uncheck the box }
  1841. {$ENDIF}
  1842. End;
  1843. End;
  1844. {$ENDIF}
  1845. END;
  1846. {--TCluster-----------------------------------------------------------------}
  1847. { DrawBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1848. {---------------------------------------------------------------------------}
  1849. PROCEDURE TCluster.DrawBox (Const Icon: String; Marker: Char);
  1850. BEGIN
  1851. DrawMultiBox(Icon, ' '+Marker); { Call draw routine }
  1852. END;
  1853. {--TCluster-----------------------------------------------------------------}
  1854. { SetButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1855. {---------------------------------------------------------------------------}
  1856. PROCEDURE TCluster.SetButtonState (AMask: Longint; Enable: Boolean);
  1857. VAR I: Integer; M: Longint;
  1858. BEGIN
  1859. If Enable Then EnableMask := EnableMask OR AMask { Set enable bit mask }
  1860. Else EnableMask := EnableMask AND NOT AMask; { Disable bit mask }
  1861. If (Strings.Count <= 32) Then Begin { Valid string number }
  1862. M := 1; { Preset bit masks }
  1863. For I := 1 To Strings.Count Do Begin { For each item string }
  1864. If ((M AND EnableMask) <> 0) Then Begin { Bit enabled }
  1865. Options := Options OR ofSelectable; { Set selectable option }
  1866. Exit; { Now exit }
  1867. End;
  1868. M := M SHL 1; { Create newbit mask }
  1869. End;
  1870. Options := Options AND NOT ofSelectable; { Make not selectable }
  1871. End;
  1872. END;
  1873. {--TCluster-----------------------------------------------------------------}
  1874. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1875. {---------------------------------------------------------------------------}
  1876. PROCEDURE TCluster.GetData (Var Rec);
  1877. BEGIN
  1878. Word(Rec) := Value; { Return current value }
  1879. END;
  1880. {--TCluster-----------------------------------------------------------------}
  1881. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1882. {---------------------------------------------------------------------------}
  1883. PROCEDURE TCluster.SetData (Var Rec);
  1884. BEGIN
  1885. Value := Word(Rec); { Set current value }
  1886. SetDrawMask(vdFocus OR vdInner); { Set redraw mask }
  1887. DrawView; { Redraw masked areas }
  1888. END;
  1889. {--TCluster-----------------------------------------------------------------}
  1890. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1891. {---------------------------------------------------------------------------}
  1892. PROCEDURE TCluster.Store (Var S: TStream);
  1893. BEGIN
  1894. TView.Store(S); { TView.Store called }
  1895. If ((Options AND ofVersion) >= ofVersion20) { Version 2 TV view }
  1896. Then Begin
  1897. S.Write(Value, SizeOf(LongInt)); { Write value }
  1898. S.Write(Sel, SizeOf(Sel)); { Write select item }
  1899. S.Write(EnableMask, SizeOf(EnableMask)); { Write enable masks }
  1900. End Else Begin
  1901. S.Write(Value, SizeOf(Word)); { Write value }
  1902. S.Write(Sel, SizeOf(Sel)); { Write select item }
  1903. End;
  1904. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  1905. S.Write(Id, SizeOf(Id)); { Write new id value }
  1906. Strings.Store(S); { Store strings }
  1907. END;
  1908. {--TCluster-----------------------------------------------------------------}
  1909. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Jun98 LdB }
  1910. {---------------------------------------------------------------------------}
  1911. PROCEDURE TCluster.HandleEvent (Var Event: TEvent);
  1912. VAR C: Char; I, J, S, Vh: Integer; Key: Word; Mouse: TPoint; Ts: PString;
  1913. PROCEDURE MoveSel;
  1914. BEGIN
  1915. If (I <= Strings.Count) Then Begin
  1916. Sel := S; { Set selected item }
  1917. MovedTo(Sel); { Move to selected }
  1918. SetDrawMask(vdInner OR vdFocus); { Set draw masks }
  1919. DrawView; { Now draw changes }
  1920. End;
  1921. END;
  1922. BEGIN
  1923. Inherited HandleEvent(Event); { Call ancestor }
  1924. If ((Options AND ofSelectable) = 0) Then Exit; { Check selectable }
  1925. If (Event.What = evMouseDown) Then Begin { MOUSE EVENT }
  1926. MakeLocal(Event.Where, Mouse); { Make point local }
  1927. I := FindSel(Mouse); { Find selected item }
  1928. If (I <> -1) Then { Check in view }
  1929. If ButtonState(I) Then Sel := I; { If enabled select }
  1930. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  1931. DrawView; { Now draw changes }
  1932. Repeat
  1933. MakeLocal(Event.Where, Mouse); { Make point local }
  1934. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse up }
  1935. MakeLocal(Event.Where, Mouse); { Make point local }
  1936. If (FindSel(Mouse) = Sel) AND ButtonState(Sel) { If valid/selected }
  1937. Then Begin
  1938. Press(Sel); { Call pressed }
  1939. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  1940. DrawView; { Now draw changes }
  1941. End;
  1942. ClearEvent(Event); { Event was handled }
  1943. End Else If (Event.What = evKeyDown) Then Begin { KEY EVENT }
  1944. If (Options AND ofFramed <> 0) OR { Normal frame }
  1945. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  1946. J := 1 Else J := 0; { Adjust value }
  1947. Vh := Size.Y - J - J; { View height }
  1948. S := Sel; { Hold current item }
  1949. Key := CtrlToArrow(Event.KeyCode); { Convert keystroke }
  1950. Case Key Of
  1951. kbUp, kbDown, kbRight, kbLeft:
  1952. If (State AND sfFocused <> 0) Then Begin { Focused key event }
  1953. I := 0; { Zero process count }
  1954. Repeat
  1955. Inc(I); { Inc process count }
  1956. Case Key Of
  1957. kbUp: Dec(S); { Next item up }
  1958. kbDown: Inc(S); { Next item down }
  1959. kbRight: Begin { Next column across }
  1960. Inc(S, Vh); { Move to next column }
  1961. If (S >= Strings.Count) Then { No next column check }
  1962. S := (S+1) MOD Vh; { Move to last column }
  1963. End;
  1964. kbLeft: Begin { Prior column across }
  1965. Dec(S, Vh); { Move to prior column }
  1966. If (S < 0) Then S := ((Strings.Count +
  1967. Vh - 1) DIV Vh) * Vh + S - 1; { No prior column check }
  1968. End;
  1969. End;
  1970. If (S >= Strings.Count) Then S := 0; { Roll up to top }
  1971. If (S < 0) Then S := Strings.Count - 1; { Roll down to bottom }
  1972. Until ButtonState(S) OR (I > Strings.Count); { Repeat until select }
  1973. MoveSel; { Move to selected }
  1974. ClearEvent(Event); { Event was handled }
  1975. End;
  1976. Else Begin { Not an arrow key }
  1977. For I := 0 To Strings.Count-1 Do Begin { Scan each item }
  1978. Ts := Strings.At(I); { Fetch string pointer }
  1979. If (Ts <> Nil) Then C := HotKey(Ts^) { Check for hotkey }
  1980. Else C := #0; { No valid string }
  1981. If (GetAltCode(C) = Event.KeyCode) OR { Hot key for item }
  1982. (((Owner^.Phase = phPostProcess) OR { Owner in post process }
  1983. (State AND sfFocused <> 0)) AND (C <> #0) { Non zero hotkey }
  1984. AND (UpCase(Event.CharCode) = C)) { Matches current key }
  1985. Then Begin
  1986. If ButtonState(I) Then Begin { Check mask enabled }
  1987. If Focus Then Begin { Check view focus }
  1988. Sel := I; { Set selected }
  1989. MovedTo(Sel); { Move to selected }
  1990. Press(Sel); { Call pressed }
  1991. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  1992. DrawView; { Now draw changes }
  1993. End;
  1994. ClearEvent(Event); { Event was handled }
  1995. End;
  1996. Exit; { Now exit }
  1997. End;
  1998. End;
  1999. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  2000. If (Event.CharCode = ' ') AND { Spacebar key }
  2001. (State AND sfFocused <> 0) AND { Check focused view }
  2002. ButtonState(Sel) Then Begin { Check item enabled }
  2003. Press(Sel); { Call pressed }
  2004. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  2005. DrawView; { Now draw changes }
  2006. ClearEvent(Event); { Event was handled }
  2007. End;
  2008. {$ENDIF}
  2009. End;
  2010. End;
  2011. End;
  2012. END;
  2013. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  2014. {***************************************************************************}
  2015. { TCLuster OBJECT WIN/NT/OS2 ONLY METHODS }
  2016. {***************************************************************************}
  2017. {--TCluster-----------------------------------------------------------------}
  2018. { GetClassName -> Platforms WIN/NT/OS2 - Updated 03Jun98 LdB }
  2019. {---------------------------------------------------------------------------}
  2020. FUNCTION TCluster.GetClassName: String;
  2021. BEGIN
  2022. GetClassName := TvClusterClassName; { Cluster class name }
  2023. END;
  2024. {--TCluster-----------------------------------------------------------------}
  2025. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 02Jun98 LdB }
  2026. {---------------------------------------------------------------------------}
  2027. FUNCTION TCluster.SubClassAttr: LongInt;
  2028. VAR Li: LongInt;
  2029. BEGIN
  2030. If (State AND sfVisible = 0) Then Li := 0 { View not visible }
  2031. Else Li := ws_Visible; { View is visible }
  2032. If (State AND sfDisabled <> 0) Then { Check disabled flag }
  2033. Li := Li OR ws_Disabled; { Set disabled flag }
  2034. Li := Li OR ws_ClipChildren OR ws_ClipSiblings; { Must have these }
  2035. SubClassAttr := Li; { Return attributes }
  2036. END;
  2037. {--TCluster-----------------------------------------------------------------}
  2038. { GetMsgHandler -> Platforms WIN/NT/OS2 - Updated 02Jun98 LdB }
  2039. {---------------------------------------------------------------------------}
  2040. FUNCTION TCluster.GetMsgHandler: Pointer;
  2041. BEGIN
  2042. GetMsgHandler := @TvClusterMsgHandler; { Cluster msg handler }
  2043. END;
  2044. {--TCluster-----------------------------------------------------------------}
  2045. { CreateWindowNow -> Platforms WIN/NT - Updated 28May98 LdB }
  2046. {---------------------------------------------------------------------------}
  2047. PROCEDURE TCluster.CreateWindowNow (CmdShow: Integer);
  2048. VAR I, J, L: Integer; Li: LongInt; Ct: String; Ts: PString; P: PChar; Wnd: HWnd;
  2049. BEGIN
  2050. If (HWindow = 0) Then Begin { Window not created }
  2051. Inherited CreateWindowNow (CmdShow); { Call ancestor }
  2052. If (HWindow <> 0) Then Begin { Window now created }
  2053. GetMem(WndHandles, Strings.Count*SizeOf(HWnd));{ Allocate memory }
  2054. For I := 1 To Strings.Count Do Begin
  2055. L := (I-1) * FontHeight; { Height of each line }
  2056. Ts := Strings.At(I-1); { Fetch string pointer }
  2057. If (Ts <> Nil) Then Ct := Ts^ Else Ct := ''; { Get string text }
  2058. Ct := Ct + #0; { Make asciiz }
  2059. J := Pos('~', Ct); { Check for tilde }
  2060. If (J <> 0) Then Ct[J] := '&'; { Sub 1st tilde }
  2061. Repeat
  2062. J := Pos('~', Ct); { Check for tilde }
  2063. If (J <> 0) Then System.Delete(Ct, J, 1); { Remove the tilde }
  2064. Until (J = 0); { Remove all tildes }
  2065. If (Ct <> #0) Then Begin { Check for empty }
  2066. GetMem(P, Length(Ct)); { Allocate memory }
  2067. Move(Ct[1], P^, Length(Ct)); { Move string data }
  2068. End Else P := Nil; { Return nil ptr }
  2069. {$IFDEF OS_WINDOWS}
  2070. If (Options AND ofFramed <> 0) OR { Normal frame }
  2071. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2072. Wnd := CreateWindowEx(0, 'BUTTON', P,
  2073. SubClassAttr OR ws_Child OR ws_Visible, FontWidth,
  2074. L+FontHeight, RawSize.X-2*FontWidth+1,
  2075. FontHeight, HWindow, cmTvClusterButton,
  2076. HInstance, Nil) Else { Create window }
  2077. Wnd := CreateWindowEx(0, 'BUTTON', P,
  2078. SubClassAttr OR ws_Child OR ws_Visible, 0, L,
  2079. RawSize.X+1, FontHeight, HWindow,
  2080. cmTvClusterButton, HInstance, Nil); { Create window }
  2081. If (Wnd <> 0) Then Begin { Window created ok }
  2082. {$IFDEF PPC_FPC}
  2083. Windows.SendMessage(Wnd, WM_SetFont,
  2084. DefGFVFont, 1); { Set font style }
  2085. {$ELSE}
  2086. WinProcs.SendMessage(Wnd, WM_SetFont,
  2087. DefGFVFont, 1); { Set font style }
  2088. {$ENDIF}
  2089. Li := LongInt(@Self); { Address of self }
  2090. {$IFDEF BIT_16} { 16 BIT CODE }
  2091. SetProp(Wnd, ViewSeg,
  2092. Li AND $FFFF0000 SHR 16); { Set seg property }
  2093. SetProp(Wnd, ViewOfs,
  2094. Li AND $0000FFFF); { Set ofs propertry }
  2095. {$ENDIF}
  2096. {$IFDEF BIT_32} { 32 BIT CODE }
  2097. SetProp(Wnd, ViewPtr, Li); { Set view property }
  2098. {$ENDIF}
  2099. If (CmdShow <> 0) Then
  2100. ShowWindow(Wnd, cmdShow); { Execute show cmd }
  2101. UpdateWindow(Wnd); { Update the window }
  2102. BringWindowToTop(Wnd); { Bring window to top }
  2103. End;
  2104. WndHandles^[I-1] := Wnd; { Hold the handle }
  2105. If Mark(I-1) Then { If item marked }
  2106. SendMessage(WndHandles^[I-1], bm_SetCheck,
  2107. 1, 0) Else { Check the item }
  2108. SendMessage(WndHandles^[I-1], bm_SetCheck,
  2109. 0, 0); { Uncheck the item }
  2110. {$ENDIF}
  2111. End;
  2112. End;
  2113. End;
  2114. END;
  2115. {$ENDIF}
  2116. {***************************************************************************}
  2117. { TCluster OBJECT PRIVATE METHODS }
  2118. {***************************************************************************}
  2119. {--TCluster-----------------------------------------------------------------}
  2120. { FindSel -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2121. {---------------------------------------------------------------------------}
  2122. FUNCTION TCluster.FindSel (P: TPoint): Integer;
  2123. VAR I, J, S, Vh: Integer; R: TRect;
  2124. BEGIN
  2125. GetExtent(R); { Get view extents }
  2126. If R.Contains(P) Then Begin { Point in view }
  2127. If (Options AND ofFramed <> 0) OR { Normal frame }
  2128. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2129. J := 1 Else J := 0; { Adjust value }
  2130. Vh := Size.Y - J - J; { View height }
  2131. I := 0; { Preset zero value }
  2132. While (P.X >= Column(I+Vh)) Do Inc(I, Vh); { Inc view size }
  2133. S := I + P.Y - J; { Line to select }
  2134. If ((S >= 0) AND (S < Strings.Count)) { Valid selection }
  2135. Then FindSel := S Else FindSel := -1; { Return selected item }
  2136. End Else FindSel := -1; { Point outside view }
  2137. END;
  2138. {--TCluster-----------------------------------------------------------------}
  2139. { Row -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2140. {---------------------------------------------------------------------------}
  2141. FUNCTION TCluster.Row (Item: Integer): Integer;
  2142. BEGIN
  2143. If (Options AND ofFramed <> 0) OR { Normal frame }
  2144. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2145. Row := Item MOD (Size.Y - 2) Else { Allow for frames }
  2146. Row := Item MOD Size.Y; { Normal mod value }
  2147. END;
  2148. {--TCluster-----------------------------------------------------------------}
  2149. { Column -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2150. {---------------------------------------------------------------------------}
  2151. FUNCTION TCluster.Column (Item: Integer): Integer;
  2152. VAR I, J, Col, Width, L, Vh: Integer; Ts: PString;
  2153. BEGIN
  2154. If (Options AND ofFramed <> 0) OR { Normal frame }
  2155. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2156. J := 1 Else J := 0; { Adjust value }
  2157. Vh := Size.Y - J - J; { Vertical size }
  2158. If (Item >= Vh) Then Begin { Valid selection }
  2159. Width := 0; { Zero width }
  2160. Col := -6; { Start column at -6 }
  2161. For I := 0 To Item Do Begin { For each item }
  2162. If (I MOD Vh = 0) Then Begin { Start next column }
  2163. Inc(Col, Width + 6); { Add column width }
  2164. Width := 0; { Zero width }
  2165. End;
  2166. If (I < Strings.Count) Then Begin { Valid string }
  2167. Ts := Strings.At(I); { Transfer string }
  2168. If (Ts <> Nil) Then L := CStrLen(Ts^) { Length of string }
  2169. Else L := 0; { No string }
  2170. End;
  2171. If (L > Width) Then Width := L; { Hold longest string }
  2172. End;
  2173. Column := Col; { Return column }
  2174. End Else Column := 0; { Outside select area }
  2175. END;
  2176. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2177. { TRadioButtons OBJECT METHODS }
  2178. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2179. {--TRadioButtons------------------------------------------------------------}
  2180. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2181. {---------------------------------------------------------------------------}
  2182. FUNCTION TRadioButtons.Mark (Item: Integer): Boolean;
  2183. BEGIN
  2184. Mark := Item = Value; { True if item = value }
  2185. END;
  2186. {--TRadioButtons------------------------------------------------------------}
  2187. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2188. {---------------------------------------------------------------------------}
  2189. PROCEDURE TRadioButtons.DrawFocus;
  2190. CONST Button = ' ( ) ';
  2191. BEGIN
  2192. Inherited DrawFocus;
  2193. DrawMultiBox(Button, #32#7); { Redraw the text }
  2194. END;
  2195. {--TRadioButtons------------------------------------------------------------}
  2196. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2197. {---------------------------------------------------------------------------}
  2198. PROCEDURE TRadioButtons.Press (Item: Integer);
  2199. BEGIN
  2200. Value := Item; { Set value field }
  2201. Inherited Press(Item); { Call ancestor }
  2202. END;
  2203. {--TRadioButtons------------------------------------------------------------}
  2204. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2205. {---------------------------------------------------------------------------}
  2206. PROCEDURE TRadioButtons.MovedTo (Item: Integer);
  2207. BEGIN
  2208. Value := Item; { Set value to item }
  2209. If (Id <> 0) Then NewMessage(Owner, evCommand,
  2210. cmIdCommunicate, Id, Value, @Self); { Send new message }
  2211. END;
  2212. {--TRadioButtons------------------------------------------------------------}
  2213. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2214. {---------------------------------------------------------------------------}
  2215. PROCEDURE TRadioButtons.SetData (Var Rec);
  2216. BEGIN
  2217. Sel := Integer(Rec); { Set selection }
  2218. Inherited SetData(Rec); { Call ancestor }
  2219. END;
  2220. {$IFNDEF OS_DOS} { WIN/NT CODE }
  2221. {***************************************************************************}
  2222. { TRadioButtons OBJECT WIN/NT/OS2 ONLY METHODS }
  2223. {***************************************************************************}
  2224. {--TRadioButtons------------------------------------------------------------}
  2225. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 20May98 LdB }
  2226. {---------------------------------------------------------------------------}
  2227. FUNCTION TRadioButtons.SubClassAttr: LongInt;
  2228. BEGIN
  2229. SubClassAttr := Inherited SubClassAttr OR
  2230. bs_RadioButton; { Radio button }
  2231. END;
  2232. {$ENDIF}
  2233. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2234. { TCheckBoxes OBJECT METHODS }
  2235. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2236. {--TCheckBoxes--------------------------------------------------------------}
  2237. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2238. {---------------------------------------------------------------------------}
  2239. FUNCTION TCheckBoxes.Mark(Item: Integer): Boolean;
  2240. BEGIN
  2241. If (Value AND (1 SHL Item) <> 0) Then { Check if item ticked }
  2242. Mark := True Else Mark := False; { Return result }
  2243. END;
  2244. {--TCheckBoxes--------------------------------------------------------------}
  2245. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2246. {---------------------------------------------------------------------------}
  2247. PROCEDURE TCheckBoxes.DrawFocus;
  2248. CONST Button = ' [ ] ';
  2249. BEGIN
  2250. Inherited DrawFocus;
  2251. DrawMultiBox(Button, ' X'); { Redraw the text }
  2252. END;
  2253. {--TCheckBoxes--------------------------------------------------------------}
  2254. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2255. {---------------------------------------------------------------------------}
  2256. PROCEDURE TCheckBoxes.Press (Item: Integer);
  2257. BEGIN
  2258. Value := Value XOR (1 SHL Item); { Flip the item mask }
  2259. Inherited Press(Item); { Call ancestor }
  2260. END;
  2261. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  2262. {***************************************************************************}
  2263. { TCheckBoxes OBJECT WIN/NT/OS2 ONLY METHODS }
  2264. {***************************************************************************}
  2265. {--TCheckBoxes--------------------------------------------------------------}
  2266. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 20May98 LdB }
  2267. {---------------------------------------------------------------------------}
  2268. FUNCTION TCheckBoxes.SubClassAttr: LongInt;
  2269. BEGIN
  2270. SubClassAttr := Inherited SubClassAttr OR
  2271. bs_CheckBox; { Check box buttons }
  2272. END;
  2273. {$ENDIF}
  2274. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2275. { TMultiCheckBoxes OBJECT METHODS }
  2276. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2277. {--TMultiCheckBoxes---------------------------------------------------------}
  2278. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Jun98 LdB }
  2279. {---------------------------------------------------------------------------}
  2280. CONSTRUCTOR TMultiCheckBoxes.Init (Var Bounds: TRect; AStrings: PSItem;
  2281. ASelRange: Byte; AFlags: Word; Const AStates: String);
  2282. BEGIN
  2283. Inherited Init(Bounds, AStrings); { Call ancestor }
  2284. SelRange := ASelRange; { Hold select range }
  2285. Flags := AFlags; { Hold flags }
  2286. States := NewStr(AStates); { Hold string }
  2287. END;
  2288. {--TMultiCheckBoxes---------------------------------------------------------}
  2289. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2290. {---------------------------------------------------------------------------}
  2291. CONSTRUCTOR TMultiCheckBoxes.Load (Var S: TStream);
  2292. BEGIN
  2293. Inherited Load(S); { Call ancestor }
  2294. S.Read(SelRange, SizeOf(SelRange)); { Read select range }
  2295. S.Read(Flags, SizeOf(Flags)); { Read flags }
  2296. States := S.ReadStr; { Read strings }
  2297. END;
  2298. {--TMultiCheckBoxes---------------------------------------------------------}
  2299. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2300. {---------------------------------------------------------------------------}
  2301. DESTRUCTOR TMultiCheckBoxes.Done;
  2302. BEGIN
  2303. If (States <> Nil) Then DisposeStr(States); { Dispose strings }
  2304. Inherited Done; { Call ancestor }
  2305. END;
  2306. {--TMultiCheckBoxes---------------------------------------------------------}
  2307. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2308. {---------------------------------------------------------------------------}
  2309. FUNCTION TMultiCheckBoxes.DataSize: Word;
  2310. BEGIN
  2311. DataSize := SizeOf(LongInt); { Size to exchange }
  2312. END;
  2313. {--TMultiCheckBoxes---------------------------------------------------------}
  2314. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2315. {---------------------------------------------------------------------------}
  2316. FUNCTION TMultiCheckBoxes.MultiMark (Item: Integer): Byte;
  2317. BEGIN
  2318. MultiMark := (Value SHR (Word(Item) *
  2319. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Return mark state }
  2320. END;
  2321. {--TMultiCheckBoxes---------------------------------------------------------}
  2322. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2323. {---------------------------------------------------------------------------}
  2324. PROCEDURE TMultiCheckBoxes.DrawFocus;
  2325. CONST Button = ' [ ] ';
  2326. BEGIN
  2327. Inherited DrawFocus;
  2328. DrawMultiBox(Button, States^); { Draw the items }
  2329. END;
  2330. {--TMultiCheckBoxes---------------------------------------------------------}
  2331. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2332. {---------------------------------------------------------------------------}
  2333. PROCEDURE TMultiCheckBoxes.Press (Item: Integer);
  2334. VAR CurState: ShortInt;
  2335. BEGIN
  2336. CurState := (Value SHR (Word(Item) *
  2337. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Hold current state }
  2338. Dec(CurState); { One down }
  2339. If (CurState >= SelRange) OR (CurState < 0) Then
  2340. CurState := SelRange - 1; { Roll if needed }
  2341. Value := (Value AND NOT (LongInt(WordRec(Flags).Lo)
  2342. SHL (Word(Item) * WordRec(Flags).Hi))) OR
  2343. (LongInt(CurState) SHL (Word(Item) *
  2344. WordRec(Flags).Hi)); { Calculate value }
  2345. Inherited Press(Item); { Call ancestor }
  2346. END;
  2347. {--TMultiCheckBoxes---------------------------------------------------------}
  2348. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2349. {---------------------------------------------------------------------------}
  2350. PROCEDURE TMultiCheckBoxes.GetData (Var Rec);
  2351. BEGIN
  2352. Longint(Rec) := Value; { Return value }
  2353. END;
  2354. {--TMultiCheckBoxes---------------------------------------------------------}
  2355. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2356. {---------------------------------------------------------------------------}
  2357. PROCEDURE TMultiCheckBoxes.SetData (Var Rec);
  2358. BEGIN
  2359. Value := Longint(Rec); { Set value }
  2360. SetDrawMask(vdFocus OR vdInner); { Set redraw mask }
  2361. DrawView; { Redraw masked areas }
  2362. END;
  2363. {--TMultiCheckBoxes---------------------------------------------------------}
  2364. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2365. {---------------------------------------------------------------------------}
  2366. PROCEDURE TMultiCheckBoxes.Store (Var S: TStream);
  2367. BEGIN
  2368. TCluster.Store(S); { TCluster store called }
  2369. S.Write(SelRange, SizeOf(SelRange)); { Write select range }
  2370. S.Write(Flags, SizeOf(Flags)); { Write select flags }
  2371. S.WriteStr(States); { Write strings }
  2372. END;
  2373. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  2374. {***************************************************************************}
  2375. { TMultiCheckBoxes OBJECT WIN/NT/OS2 ONLY METHODS }
  2376. {***************************************************************************}
  2377. {--TMultiCheckBoxes---------------------------------------------------------}
  2378. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 06Jun98 LdB }
  2379. {---------------------------------------------------------------------------}
  2380. FUNCTION TMultiCheckBoxes.SubClassAttr: LongInt;
  2381. BEGIN
  2382. SubClassAttr := Inherited SubClassAttr OR
  2383. bs_CheckBox; { Check box buttons }
  2384. END;
  2385. {$ENDIF}
  2386. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2387. { TListBox OBJECT METHODS }
  2388. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2389. TYPE
  2390. TListBoxRec = PACKED RECORD
  2391. List: PCollection; { List collection ptr }
  2392. Selection: Word; { Selected item }
  2393. END;
  2394. {--TListBox-----------------------------------------------------------------}
  2395. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2396. {---------------------------------------------------------------------------}
  2397. CONSTRUCTOR TListBox.Init (Var Bounds: TRect; ANumCols: Word;
  2398. AScrollBar: PScrollBar);
  2399. BEGIN
  2400. Inherited Init(Bounds, ANumCols, Nil, AScrollBar); { Call ancestor }
  2401. SetRange(0); { Set range to zero }
  2402. END;
  2403. {--TListBox-----------------------------------------------------------------}
  2404. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2405. {---------------------------------------------------------------------------}
  2406. CONSTRUCTOR TListBox.Load (Var S: TStream);
  2407. BEGIN
  2408. Inherited Load(S); { Call ancestor }
  2409. List := PCollection(S.Get); { Fetch collection }
  2410. END;
  2411. {--TListBox-----------------------------------------------------------------}
  2412. { DataSize -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 06Jun98 LdB }
  2413. {---------------------------------------------------------------------------}
  2414. FUNCTION TListBox.DataSize: Word;
  2415. BEGIN
  2416. DataSize := SizeOf(TListBoxRec); { Xchg data size }
  2417. END;
  2418. {--TListBox-----------------------------------------------------------------}
  2419. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2420. {---------------------------------------------------------------------------}
  2421. FUNCTION TListBox.GetText (Item: Integer; MaxLen: Integer): String;
  2422. VAR P: PString;
  2423. BEGIN
  2424. GetText := ''; { Preset return }
  2425. If (List <> Nil) Then Begin { A list exists }
  2426. P := PString(List^.At(Item)); { Get string ptr }
  2427. If (P <> Nil) Then GetText := P^; { Return string }
  2428. End;
  2429. END;
  2430. {--TListBox-----------------------------------------------------------------}
  2431. { NewList -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2432. {---------------------------------------------------------------------------}
  2433. PROCEDURE TListBox.NewList (AList: PCollection);
  2434. {$IFDEF OS_WINDOWS} VAR I: Integer; S: String; P: PString; {$ENDIF}
  2435. BEGIN
  2436. If (List <> Nil) Then Dispose(List, Done); { Dispose old list }
  2437. List := AList; { Hold new list }
  2438. If (AList <> Nil) Then SetRange(AList^.Count) { Set new item range }
  2439. Else SetRange(0); { Set zero range }
  2440. If (Range > 0) Then FocusItem(0); { Focus first item }
  2441. DrawView; { Redraw all view }
  2442. END;
  2443. {--TListBox-----------------------------------------------------------------}
  2444. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2445. {---------------------------------------------------------------------------}
  2446. PROCEDURE TListBox.GetData (Var Rec);
  2447. BEGIN
  2448. TListBoxRec(Rec).List := List; { Return current list }
  2449. TListBoxRec(Rec).Selection := Focused; { Return focused item }
  2450. END;
  2451. {--TListBox-----------------------------------------------------------------}
  2452. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2453. {---------------------------------------------------------------------------}
  2454. PROCEDURE TListBox.SetData (Var Rec);
  2455. BEGIN
  2456. NewList(TListBoxRec(Rec).List); { Hold new list }
  2457. FocusItem(TListBoxRec(Rec).Selection); { Focus selected item }
  2458. DrawView; { Redraw all view }
  2459. END;
  2460. {--TListBox-----------------------------------------------------------------}
  2461. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2462. {---------------------------------------------------------------------------}
  2463. PROCEDURE TListBox.Store (Var S: TStream);
  2464. BEGIN
  2465. TListViewer.Store(S); { TListViewer store }
  2466. S.Put(List); { Store list to stream }
  2467. END;
  2468. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2469. { TStaticText OBJECT METHODS }
  2470. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2471. {--TStaticText--------------------------------------------------------------}
  2472. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2473. {---------------------------------------------------------------------------}
  2474. CONSTRUCTOR TStaticText.Init (Var Bounds: TRect; Const AText: String);
  2475. BEGIN
  2476. Inherited Init(Bounds); { Call ancestor }
  2477. Text := NewStr(AText); { Create string ptr }
  2478. END;
  2479. {--TStaticText--------------------------------------------------------------}
  2480. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2481. {---------------------------------------------------------------------------}
  2482. CONSTRUCTOR TStaticText.Load (Var S: TStream);
  2483. BEGIN
  2484. Inherited Load(S); { Call ancestor }
  2485. Text := S.ReadStr; { Read text string }
  2486. END;
  2487. {--TStaticText--------------------------------------------------------------}
  2488. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2489. {---------------------------------------------------------------------------}
  2490. DESTRUCTOR TStaticText.Done;
  2491. BEGIN
  2492. If (Text <> Nil) Then DisposeStr(Text); { Dispose string }
  2493. Inherited Done; { Call ancestor }
  2494. END;
  2495. {--TStaticText--------------------------------------------------------------}
  2496. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2497. {---------------------------------------------------------------------------}
  2498. FUNCTION TStaticText.GetPalette: PPalette;
  2499. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2500. CONST P: String = CStaticText; { Possible huge string }
  2501. {$ELSE} { OTHER COMPILERS }
  2502. CONST P: String[Length(CStaticText)] = CStaticText; { Always normal string }
  2503. {$ENDIF}
  2504. BEGIN
  2505. GetPalette := @P; { Return palette }
  2506. END;
  2507. {--TStaticText--------------------------------------------------------------}
  2508. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2509. {---------------------------------------------------------------------------}
  2510. PROCEDURE TStaticText.DrawBackGround;
  2511. VAR Just: Byte; I, J, P, Y, L: Integer; S, T: String;
  2512. BEGIN
  2513. Inherited DrawBackGround; { Call ancestor }
  2514. GetText(S); { Fetch text to write }
  2515. P := 1; { X start position }
  2516. Y := 0; { Y start position }
  2517. L := Length(S); { Length of text }
  2518. While (Y < Size.Y) AND (P <= L) Do Begin
  2519. Just := 0; { Default left justify }
  2520. If (S[P] = #2) Then Begin { Right justify char }
  2521. Just := 2; { Set right justify }
  2522. Inc(P); { Next character }
  2523. End;
  2524. If (S[P] = #3) Then Begin { Centre justify char }
  2525. Just := 1; { Set centre justify }
  2526. Inc(P); { Next character }
  2527. End;
  2528. I := P; { Start position }
  2529. While (P <= L) AND (S[P] <> #13) Do Inc(P); { Scan for end }
  2530. T := Copy(S, I, P-I); { String to write }
  2531. Case Just Of
  2532. 0: J := 0; { Left justify }
  2533. 1: J := (RawSize.X - TextWidth(T)) DIV 2; { Centre justify }
  2534. 2: J := RawSize.X - TextWidth(T); { Right justify }
  2535. End;
  2536. While (J < 0) Do Begin { Text to long }
  2537. J := J + TextWidth(T[1]); { Add width to J }
  2538. Delete(T, 1, 1); { Delete the char }
  2539. End;
  2540. WriteStr(-J, -(Y*FontHeight), T, 1); { Write the text }
  2541. While (P <= L) AND ((S[P] = #13) OR (S[P] = #10))
  2542. Do Inc(P); { Remove CR/LF }
  2543. Inc(Y); { Next line }
  2544. End;
  2545. END;
  2546. {--TStaticText--------------------------------------------------------------}
  2547. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2548. {---------------------------------------------------------------------------}
  2549. PROCEDURE TStaticText.Store (Var S: TStream);
  2550. BEGIN
  2551. TView.Store(S); { Call TView store }
  2552. S.WriteStr(Text); { Write text string }
  2553. END;
  2554. {--TStaticText--------------------------------------------------------------}
  2555. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2556. {---------------------------------------------------------------------------}
  2557. PROCEDURE TStaticText.GetText (Var S: String);
  2558. BEGIN
  2559. If (Text <> Nil) Then S := Text^ { Copy text string }
  2560. Else S := ''; { Return empty string }
  2561. END;
  2562. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2563. { TParamText OBJECT METHODS }
  2564. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2565. {--TParamText---------------------------------------------------------------}
  2566. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2567. {---------------------------------------------------------------------------}
  2568. CONSTRUCTOR TParamText.Init (Var Bounds: TRect; Const AText: String;
  2569. AParamCount: Integer);
  2570. BEGIN
  2571. Inherited Init(Bounds, AText); { Call ancestor }
  2572. ParamCount := AParamCount; { Hold param count }
  2573. END;
  2574. {--TParamText---------------------------------------------------------------}
  2575. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2576. {---------------------------------------------------------------------------}
  2577. CONSTRUCTOR TParamText.Load (Var S: TStream);
  2578. BEGIN
  2579. Inherited Load(S); { Call ancestor }
  2580. S.Read(ParamCount, 2); { Read parameter count }
  2581. END;
  2582. {--TParamText---------------------------------------------------------------}
  2583. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2584. {---------------------------------------------------------------------------}
  2585. FUNCTION TParamText.DataSize: Word;
  2586. BEGIN
  2587. DataSize := ParamCount * SizeOf(Pointer); { Return data size }
  2588. END;
  2589. {--TParamText---------------------------------------------------------------}
  2590. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2591. {---------------------------------------------------------------------------}
  2592. PROCEDURE TParamText.GetData (Var Rec);
  2593. BEGIN
  2594. Pointer(Rec) := @ParamList; { Return parm ptr }
  2595. END;
  2596. {--TParamText---------------------------------------------------------------}
  2597. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2598. {---------------------------------------------------------------------------}
  2599. PROCEDURE TParamText.SetData (Var Rec);
  2600. BEGIN
  2601. ParamList := @Rec; { Fetch parameter list }
  2602. DrawView; { Redraw all the view }
  2603. END;
  2604. {--TParamText---------------------------------------------------------------}
  2605. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2606. {---------------------------------------------------------------------------}
  2607. PROCEDURE TParamText.Store (Var S: TStream);
  2608. BEGIN
  2609. TStaticText.Store(S); { Statictext store }
  2610. S.Write(ParamCount, 2); { Store param count }
  2611. END;
  2612. {--TParamText---------------------------------------------------------------}
  2613. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2614. {---------------------------------------------------------------------------}
  2615. PROCEDURE TParamText.GetText (Var S: String);
  2616. BEGIN
  2617. If (Text = Nil) Then S := '' Else { Return empty string }
  2618. FormatStr(S, Text^, ParamList^); { Return text string }
  2619. END;
  2620. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2621. { TLabel OBJECT METHODS }
  2622. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2623. {--TLabel-------------------------------------------------------------------}
  2624. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2625. {---------------------------------------------------------------------------}
  2626. CONSTRUCTOR TLabel.Init (Var Bounds: TRect; CONST AText: String; ALink: PView);
  2627. BEGIN
  2628. Inherited Init(Bounds, AText); { Call ancestor }
  2629. Link := ALink; { Hold link }
  2630. Options := Options OR (ofPreProcess+ofPostProcess);{ Set pre/post process }
  2631. EventMask := EventMask OR evBroadcast; { Sees broadcast events }
  2632. END;
  2633. {--TLabel-------------------------------------------------------------------}
  2634. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2635. {---------------------------------------------------------------------------}
  2636. CONSTRUCTOR TLabel.Load (Var S: TStream);
  2637. BEGIN
  2638. Inherited Load(S); { Call ancestor }
  2639. GetPeerViewPtr(S, Link); { Load link view }
  2640. END;
  2641. {--TLabel-------------------------------------------------------------------}
  2642. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2643. {---------------------------------------------------------------------------}
  2644. FUNCTION TLabel.GetPalette: PPalette;
  2645. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2646. CONST P: String = CLabel; { Possible huge string }
  2647. {$ELSE} { OTHER COMPILERS }
  2648. CONST P: String[Length(CLabel)] = CLabel; { Always normal string }
  2649. {$ENDIF}
  2650. BEGIN
  2651. GetPalette := @P; { Return palette }
  2652. END;
  2653. {--TLabel-------------------------------------------------------------------}
  2654. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2655. {---------------------------------------------------------------------------}
  2656. PROCEDURE TLabel.DrawBackGround;
  2657. VAR SCOff: Byte; Color: Word; B: TDrawBuffer;
  2658. BEGIN
  2659. TView.DrawBackGround; { Explict call to TView }
  2660. If Light Then Begin { Light colour select }
  2661. Color := GetColor($0402); { Choose light colour }
  2662. SCOff := 0; { Zero offset }
  2663. End Else Begin
  2664. Color := GetColor($0301); { Darker colour }
  2665. SCOff := 4; { Set offset }
  2666. End;
  2667. MoveChar(B[0], ' ', Byte(Color), Size.X); { Clear the buffer }
  2668. If (Text <> Nil) Then MoveCStr(B[1], Text^, Color);{ Transfer label text }
  2669. If ShowMarkers Then WordRec(B[0]).Lo := Byte(
  2670. SpecialChars[SCOff]); { Show marker if req }
  2671. WriteLine(0, 0, Size.X, 1, B); { Write the text }
  2672. END;
  2673. {--TLabel-------------------------------------------------------------------}
  2674. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2675. {---------------------------------------------------------------------------}
  2676. PROCEDURE TLabel.Store (Var S: TStream);
  2677. BEGIN
  2678. TStaticText.Store(S); { TStaticText.Store }
  2679. PutPeerViewPtr(S, Link); { Store link view }
  2680. END;
  2681. {--TLabel-------------------------------------------------------------------}
  2682. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2683. {---------------------------------------------------------------------------}
  2684. PROCEDURE TLabel.HandleEvent (Var Event: TEvent);
  2685. VAR C: Char;
  2686. PROCEDURE FocusLink;
  2687. BEGIN
  2688. If (Link <> Nil) AND (Link^.Options AND
  2689. ofSelectable <> 0) Then Link^.Focus; { Focus link view }
  2690. ClearEvent(Event); { Clear the event }
  2691. END;
  2692. BEGIN
  2693. Inherited HandleEvent(Event); { Call ancestor }
  2694. Case Event.What Of
  2695. evNothing: Exit; { Speed up exit }
  2696. evMouseDown: FocusLink; { Focus link view }
  2697. evKeyDown: Begin
  2698. C := HotKey(Text^); { Check for hotkey }
  2699. If (GetAltCode(C) = Event.KeyCode) OR { Alt plus char }
  2700. ((C <> #0) AND (Owner^.Phase = phPostProcess) { Post process phase }
  2701. AND (UpCase(Event.CharCode) = C)) Then { Upper case match }
  2702. FocusLink; { Focus link view }
  2703. End;
  2704. evBroadcast: If ((Event.Command = cmReceivedFocus)
  2705. OR (Event.Command = cmReleasedFocus)) AND { Focus state change }
  2706. (Link <> Nil) Then Begin
  2707. Light := Link^.State AND sfFocused <> 0; { Change light state }
  2708. DrawView; { Now redraw change }
  2709. End;
  2710. End;
  2711. END;
  2712. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2713. { THistoryViewer OBJECT METHODS }
  2714. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2715. {--THistoryViewer-----------------------------------------------------------}
  2716. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2717. {---------------------------------------------------------------------------}
  2718. CONSTRUCTOR THistoryViewer.Init (Var Bounds: TRect; AHScrollBar,
  2719. AVScrollBar: PScrollBar; AHistoryId: Word);
  2720. BEGIN
  2721. Inherited Init(Bounds, 1, AHScrollBar,
  2722. AVScrollBar); { Call ancestor }
  2723. HistoryId := AHistoryId; { Hold history id }
  2724. SetRange(HistoryCount(AHistoryId)); { Set history range }
  2725. If (Range > 1) Then FocusItem(1); { Set to item 1 }
  2726. If (HScrollBar <> Nil) Then
  2727. HScrollBar^.SetRange(1, HistoryWidth-Size.X + 3);{ Set scrollbar range }
  2728. END;
  2729. {--THistoryViewer-----------------------------------------------------------}
  2730. { HistoryWidth -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2731. {---------------------------------------------------------------------------}
  2732. FUNCTION THistoryViewer.HistoryWidth: Integer;
  2733. VAR Width, T, Count, I: Integer;
  2734. BEGIN
  2735. Width := 0; { Zero width variable }
  2736. Count := HistoryCount(HistoryId); { Hold count value }
  2737. For I := 0 To Count-1 Do Begin { For each item }
  2738. T := Length(HistoryStr(HistoryId, I)); { Get width of item }
  2739. If (T > Width) Then Width := T; { Set width to max }
  2740. End;
  2741. HistoryWidth := Width; { Return max item width }
  2742. END;
  2743. {--THistoryViewer-----------------------------------------------------------}
  2744. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2745. {---------------------------------------------------------------------------}
  2746. FUNCTION THistoryViewer.GetPalette: PPalette;
  2747. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2748. CONST P: String = CHistoryViewer; { Possible huge string }
  2749. {$ELSE} { OTHER COMPILERS }
  2750. CONST P: String[Length(CHistoryViewer)] = CHistoryViewer;{ Always normal string }
  2751. {$ENDIF}
  2752. BEGIN
  2753. GetPalette := @P; { Return palette }
  2754. END;
  2755. {--THistoryViewer-----------------------------------------------------------}
  2756. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2757. {---------------------------------------------------------------------------}
  2758. FUNCTION THistoryViewer.GetText (Item: Integer; MaxLen: Integer): String;
  2759. BEGIN
  2760. GetText := HistoryStr(HistoryId, Item); { Return history string }
  2761. END;
  2762. {--THistoryViewer-----------------------------------------------------------}
  2763. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2764. {---------------------------------------------------------------------------}
  2765. PROCEDURE THistoryViewer.HandleEvent (Var Event: TEvent);
  2766. BEGIN
  2767. If ((Event.What = evMouseDown) AND (Event.Double)) { Double click mouse }
  2768. OR ((Event.What = evKeyDown) AND
  2769. (Event.KeyCode = kbEnter)) Then Begin { Enter key press }
  2770. EndModal(cmOk); { End with cmOk }
  2771. ClearEvent(Event); { Event was handled }
  2772. End Else If ((Event.What = evKeyDown) AND
  2773. (Event.KeyCode = kbEsc)) OR { Esc key press }
  2774. ((Event.What = evCommand) AND
  2775. (Event.Command = cmCancel)) Then Begin { Cancel command }
  2776. EndModal(cmCancel); { End with cmCancel }
  2777. ClearEvent(Event); { Event was handled }
  2778. End Else Inherited HandleEvent(Event); { Call ancestor }
  2779. END;
  2780. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2781. { THistoryWindow OBJECT METHODS }
  2782. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2783. {--THistoryWindow-----------------------------------------------------------}
  2784. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2785. {---------------------------------------------------------------------------}
  2786. CONSTRUCTOR THistoryWindow.Init (Var Bounds: TRect; HistoryId: Word);
  2787. BEGIN
  2788. Inherited Init(Bounds, '', wnNoNumber); { Call ancestor }
  2789. Flags := wfClose; { Close flag only }
  2790. InitViewer(HistoryId); { Create list view }
  2791. END;
  2792. {--THistoryWindow-----------------------------------------------------------}
  2793. { GetSelection -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2794. {---------------------------------------------------------------------------}
  2795. FUNCTION THistoryWindow.GetSelection: String;
  2796. BEGIN
  2797. If (Viewer = Nil) Then GetSelection := '' Else { Return empty string }
  2798. GetSelection := Viewer^.GetText(Viewer^.Focused,
  2799. 255); { Get focused string }
  2800. END;
  2801. {--THistoryWindow-----------------------------------------------------------}
  2802. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2803. {---------------------------------------------------------------------------}
  2804. FUNCTION THistoryWindow.GetPalette: PPalette;
  2805. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2806. CONST P: String = CHistoryWindow; { Possible huge string }
  2807. {$ELSE} { OTHER COMPILERS }
  2808. CONST P: String[Length(CHistoryWindow)] = CHistoryWindow;{ Always normal string }
  2809. {$ENDIF}
  2810. BEGIN
  2811. GetPalette := @P; { Return the palette }
  2812. END;
  2813. {--THistoryWindow-----------------------------------------------------------}
  2814. { InitViewer -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2815. {---------------------------------------------------------------------------}
  2816. PROCEDURE THistoryWindow.InitViewer(HistoryId: Word);
  2817. VAR R: TRect;
  2818. BEGIN
  2819. GetExtent(R); { Get extents }
  2820. R.Grow(-1,-1); { Grow inside }
  2821. Viewer := New(PHistoryViewer, Init(R,
  2822. StandardScrollBar(sbHorizontal + sbHandleKeyboard),
  2823. StandardScrollBar(sbVertical + sbHandleKeyboard),
  2824. HistoryId)); { Create the viewer }
  2825. If (Viewer <> Nil) Then Insert(Viewer); { Insert viewer }
  2826. END;
  2827. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2828. { THistory OBJECT METHODS }
  2829. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2830. {--THistory-----------------------------------------------------------------}
  2831. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2832. {---------------------------------------------------------------------------}
  2833. CONSTRUCTOR THistory.Init (Var Bounds: TRect; ALink: PInputLine;
  2834. AHistoryId: Word);
  2835. BEGIN
  2836. Inherited Init(Bounds); { Call ancestor }
  2837. Options := Options OR ofPostProcess; { Set post process }
  2838. EventMask := EventMask OR evBroadcast; { See broadcast events }
  2839. Link := ALink; { Hold link view }
  2840. HistoryId := AHistoryId; { Hold history id }
  2841. END;
  2842. {--THistory-----------------------------------------------------------------}
  2843. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2844. {---------------------------------------------------------------------------}
  2845. CONSTRUCTOR THistory.Load (Var S: TStream);
  2846. BEGIN
  2847. Inherited Load(S); { Call ancestor }
  2848. GetPeerViewPtr(S, Link); { Load link view }
  2849. S.Read(HistoryId, 2); { Read history id }
  2850. END;
  2851. {--THistory-----------------------------------------------------------------}
  2852. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2853. {---------------------------------------------------------------------------}
  2854. FUNCTION THistory.GetPalette: PPalette;
  2855. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2856. CONST P: String = CHistory; { Possible huge string }
  2857. {$ELSE} { OTHER COMPILERS }
  2858. CONST P: String[Length(CHistory)] = CHistory; { Always normal string }
  2859. {$ENDIF}
  2860. BEGIN
  2861. GetPalette := @P; { Return the palette }
  2862. END;
  2863. {--THistory-----------------------------------------------------------------}
  2864. { InitHistoryWindow -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2865. {---------------------------------------------------------------------------}
  2866. FUNCTION THistory.InitHistoryWindow (Var Bounds: TRect): PHistoryWindow;
  2867. VAR P: PHistoryWindow;
  2868. BEGIN
  2869. P := New(PHistoryWindow, Init(Bounds, HistoryId)); { Create history window }
  2870. If (Link <> Nil) Then
  2871. P^.HelpCtx := Link^.HelpCtx; { Set help context }
  2872. InitHistoryWindow := P; { Return history window }
  2873. END;
  2874. PROCEDURE THistory.Draw;
  2875. VAR B: TDrawBuffer;
  2876. BEGIN
  2877. MoveCStr(B, #222'~'#25'~'#221, GetColor($0102)); { Set buffer data }
  2878. WriteLine(0, 0, Size.X, Size.Y, B); { Write buffer }
  2879. END;
  2880. {--THistory-----------------------------------------------------------------}
  2881. { RecordHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2882. {---------------------------------------------------------------------------}
  2883. PROCEDURE THistory.RecordHistory (CONST S: String);
  2884. BEGIN
  2885. HistoryAdd(HistoryId, S); { Add to history }
  2886. END;
  2887. {--THistory-----------------------------------------------------------------}
  2888. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2889. {---------------------------------------------------------------------------}
  2890. PROCEDURE THistory.Store (Var S: TStream);
  2891. BEGIN
  2892. TView.Store(S); { TView.Store called }
  2893. PutPeerViewPtr(S, Link); { Store link view }
  2894. S.Write(HistoryId, 2); { Store history id }
  2895. END;
  2896. {--THistory-----------------------------------------------------------------}
  2897. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2898. {---------------------------------------------------------------------------}
  2899. PROCEDURE THistory.HandleEvent (Var Event: TEvent);
  2900. VAR C: Word; Rslt: String; R, P: TRect; HistoryWindow: PHistoryWindow;
  2901. BEGIN
  2902. Inherited HandleEvent(Event); { Call ancestor }
  2903. If (Link = Nil) Then Exit; { No link view exits }
  2904. If (Event.What = evMouseDown) OR { Mouse down event }
  2905. ((Event.What = evKeyDown) AND
  2906. (CtrlToArrow(Event.KeyCode) = kbDown) AND { Down arrow key }
  2907. (Link^.State AND sfFocused <> 0)) Then Begin { Link view selected }
  2908. If NOT Link^.Focus Then Begin
  2909. ClearEvent(Event); { Event was handled }
  2910. Exit; { Now exit }
  2911. End;
  2912. RecordHistory(Link^.Data^); { Record current data }
  2913. Link^.GetBounds(R); { Get view bounds }
  2914. Dec(R.A.X); { One char in from us }
  2915. Inc(R.B.X); { One char short of us }
  2916. Inc(R.B.Y, 7); { Seven lines down }
  2917. Dec(R.A.Y,1); { One line below us }
  2918. Owner^.GetExtent(P); { Get owner extents }
  2919. R.Intersect(P); { Intersect views }
  2920. Dec(R.B.Y,1); { Shorten length by one }
  2921. HistoryWindow := InitHistoryWindow(R); { Create history window }
  2922. If (HistoryWindow <> Nil) Then Begin { Window crested okay }
  2923. C := Owner^.ExecView(HistoryWindow); { Execute this window }
  2924. If (C = cmOk) Then Begin { Result was okay }
  2925. Rslt := HistoryWindow^.GetSelection; { Get history selection }
  2926. If Length(Rslt) > Link^.MaxLen Then
  2927. {$IFDEF PPC_DELPHI3} { DELPHI 3+ COMPILER }
  2928. SetLength(Rslt, Link^.MaxLen); { Hold new length }
  2929. {$ELSE}
  2930. Rslt[0] := Char(Link^.MaxLen); { Hold new length }
  2931. {$ENDIF}
  2932. Link^.Data^ := Rslt; { Hold new selection }
  2933. Link^.SelectAll(True); { Select all string }
  2934. Link^.DrawView; { Redraw link view }
  2935. End;
  2936. Dispose(HistoryWindow, Done); { Dispose of window }
  2937. End;
  2938. ClearEvent(Event); { Event was handled }
  2939. End Else If (Event.What = evBroadcast) Then { Broadcast event }
  2940. If ((Event.Command = cmReleasedFocus) AND
  2941. (Event.InfoPtr = Link)) OR
  2942. (Event.Command = cmRecordHistory) Then { Record command }
  2943. RecordHistory(Link^.Data^); { Record the history }
  2944. END;
  2945. {***************************************************************************}
  2946. { INTERFACE ROUTINES }
  2947. {***************************************************************************}
  2948. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2949. { ITEM STRING ROUTINES }
  2950. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2951. {---------------------------------------------------------------------------}
  2952. { NewSItem -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2953. {---------------------------------------------------------------------------}
  2954. FUNCTION NewSItem (Const Str: String; ANext: PSItem): PSItem;
  2955. VAR Item: PSItem;
  2956. BEGIN
  2957. New(Item); { Allocate item }
  2958. Item^.Value := NewStr(Str); { Hold item string }
  2959. Item^.Next := ANext; { Chain the ptr }
  2960. NewSItem := Item; { Return item }
  2961. END;
  2962. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2963. { DIALOG OBJECT REGISTRATION ROUTINES }
  2964. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2965. {---------------------------------------------------------------------------}
  2966. { RegisterDialogs -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB }
  2967. {---------------------------------------------------------------------------}
  2968. PROCEDURE RegisterDialogs;
  2969. BEGIN
  2970. RegisterType(RDialog); { Register dialog }
  2971. RegisterType(RInputLine); { Register inputline }
  2972. RegisterType(RButton); { Register button }
  2973. RegisterType(RCluster); { Register cluster }
  2974. RegisterType(RRadioButtons); { Register radiobutton }
  2975. RegisterType(RCheckBoxes); { Register check boxes }
  2976. RegisterType(RMultiCheckBoxes); { Register multi boxes }
  2977. RegisterType(RListBox); { Register list box }
  2978. RegisterType(RStaticText); { Register static text }
  2979. RegisterType(RLabel); { Register label }
  2980. RegisterType(RHistory); { Register history }
  2981. RegisterType(RParamText); { Register parm text }
  2982. END;
  2983. END.