dialogs.pas 164 KB

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