dialogs.pas 164 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229
  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 OS_DOS} { 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 OS_DOS} { 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_WINDOWS} CONST LeftArr = #$AB; RightArr = #$BB; {$ENDIF}
  649. {$IFDEF OS_OS2} CONST LeftArr = #17; RightArr = #16; {$ENDIF}
  650. {---------------------------------------------------------------------------}
  651. { TButton MESSAGES }
  652. {---------------------------------------------------------------------------}
  653. CONST
  654. cmGrabDefault = 61; { Grab default }
  655. cmReleaseDefault = 62; { Release default }
  656. {***************************************************************************}
  657. { PRIVATE INTERNAL ROUTINES }
  658. {***************************************************************************}
  659. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  660. {---------------------------------------------------------------------------}
  661. { TvClusterMsgHandler -> Platforms WIN/NT - Checked 08Jun98 LdB }
  662. {---------------------------------------------------------------------------}
  663. FUNCTION TvClusterMsgHandler (Wnd: hWnd; iMessage, wParam: sw_Word;
  664. lParam: LongInt): LongInt; {$IFDEF BIT_32} STDCALL; {$ELSE} EXPORT; {$ENDIF}
  665. VAR Sel: Integer; W: sw_Word; P: PCluster;
  666. BEGIN
  667. TvClusterMsgHandler := 0; { Reset return of zero }
  668. Case iMessage Of
  669. WM_KeyDown:; { Ignore keypresses }
  670. WM_Command: Begin
  671. If (wParam AND $FFFF = cmTvClusterButton) { Command message }
  672. Then Begin
  673. {$IFDEF BIT_16} { 16 BIT CODE }
  674. PtrRec(P).Seg := GetProp(Wnd, ViewSeg); { Fetch cluster seg }
  675. PtrRec(P).Ofs := GetProp(Wnd, ViewOfs); { Fetch cluster ofs }
  676. {$ENDIF}
  677. {$IFDEF BIT_32} { 32 BIT CODE }
  678. LongInt(P) := GetProp(Wnd, ViewPtr); { Fetch cluster ptr }
  679. {$ENDIF}
  680. If (P <> Nil) AND (P^.WndHandles <> Nil) { Cluster/handles valid }
  681. Then Begin
  682. If (P^.State AND sfFocused = 0) Then { We have not focus }
  683. P^.FocusFromTop; { Focus up to us }
  684. Sel := 0; { Start on first }
  685. {$IFDEF BIT_16} { 16 BIT CODE }
  686. W := LoWord(lParam); { Use only low part }
  687. {$ENDIF}
  688. {$IFDEF BIT_32} { 32 BIT CODE }
  689. W := lParam; { Use full param }
  690. {$ENDIF}
  691. While (Sel < P^.Strings.Count) AND { Valid item }
  692. (W <> P^.WndHandles^[Sel]) Do Inc(Sel); { Find handle }
  693. If (Sel < P^.Strings.Count) Then Begin { Handle was found }
  694. P^.Press(Sel); { Call press }
  695. P^.Sel := Sel; { Set selection }
  696. If (P^.GetState(sfSelected)=False) { Check not selected }
  697. Then P^.Select Else Begin { Select us then }
  698. P^.SetDrawMask(vdFocus OR vdInner); { Redraw inner }
  699. P^.DrawView; { Redraw partial view }
  700. End;
  701. End;
  702. End;
  703. End Else
  704. TvClusterMsgHandler := TvViewMsgHandler(Wnd,
  705. iMessage, wParam, lParam); { Call TV view handler }
  706. End;
  707. Else TvClusterMsgHandler := TvViewMsgHandler(Wnd,
  708. iMessage, wParam, lParam); { Call TV view handler }
  709. End;
  710. END;
  711. {$ENDIF}
  712. {$IFDEF OS_OS2} { OS2 CODE }
  713. {---------------------------------------------------------------------------}
  714. { TvClusterMsgHandler -> Platforms OS2 - Checked ??Sep99 LdB }
  715. {---------------------------------------------------------------------------}
  716. FUNCTION TvClusterMsgHandler (Wnd: hWnd; iMessage, wParam: sw_Word;
  717. lParam: LongInt): LongInt; STDCALL;
  718. VAR Sel: Integer; W: sw_Word; P: PCluster;
  719. BEGIN
  720. TvClusterMsgHandler := 0; { Reset return of zero }
  721. TvClusterMsgHandler := TvViewMsgHandler(Wnd,
  722. iMessage, wParam, lParam); { Call TV view handler }
  723. END;
  724. {$ENDIF}
  725. {---------------------------------------------------------------------------}
  726. { IsBlank -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  727. {---------------------------------------------------------------------------}
  728. FUNCTION IsBlank (Ch: Char): Boolean;
  729. BEGIN
  730. IsBlank := (Ch = ' ') OR (Ch = #13) OR (Ch = #10); { Check for characters }
  731. END;
  732. {---------------------------------------------------------------------------}
  733. { HotKey -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  734. {---------------------------------------------------------------------------}
  735. FUNCTION HotKey (Const S: String): Char;
  736. VAR I: Word;
  737. BEGIN
  738. HotKey := #0; { Preset fail }
  739. If (S <> '') Then Begin { Valid string }
  740. I := Pos('~', S); { Search for tilde }
  741. If (I <> 0) Then HotKey := UpCase(S[I+1]); { Return hotkey }
  742. End;
  743. END;
  744. {***************************************************************************}
  745. { OBJECT METHODS }
  746. {***************************************************************************}
  747. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  748. { TDialog OBJECT METHODS }
  749. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  750. {--TDialog------------------------------------------------------------------}
  751. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  752. {---------------------------------------------------------------------------}
  753. CONSTRUCTOR TDialog.Init (Var Bounds: TRect; ATitle: TTitleStr);
  754. BEGIN
  755. Inherited Init(Bounds, ATitle, wnNoNumber); { Call ancestor }
  756. Options := Options OR ofVersion20; { Version two dialog }
  757. GrowMode := 0; { Clear grow mode }
  758. Flags := wfMove + wfClose; { Close/moveable flags }
  759. Palette := dpGrayDialog; { Default gray colours }
  760. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  761. GOptions := GOptions AND NOT goThickFramed; { Turn thick frame off }
  762. ExStyle := ws_Ex_DlgModalFrame; { Set extended style }
  763. {$ENDIF}
  764. END;
  765. {--TDialog------------------------------------------------------------------}
  766. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  767. {---------------------------------------------------------------------------}
  768. CONSTRUCTOR TDialog.Load (Var S: TStream);
  769. BEGIN
  770. Inherited Load(S); { Call ancestor }
  771. If (Options AND ofVersion = ofVersion10) Then Begin
  772. Palette := dpGrayDialog; { Set gray palette }
  773. Options := Options OR ofVersion20; { Update version flag }
  774. End;
  775. END;
  776. {--TDialog------------------------------------------------------------------}
  777. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  778. {---------------------------------------------------------------------------}
  779. FUNCTION TDialog.GetPalette: PPalette;
  780. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  781. CONST P: Array[dpBlueDialog..dpGrayDialog] Of String =
  782. (CBlueDialog, CCyanDialog, CGrayDialog); { Possible huge string }
  783. {$ELSE} { OTHER COMPILERS }
  784. CONST P: Array[dpBlueDialog..dpGrayDialog] Of String[Length(CBlueDialog)] =
  785. (CBlueDialog, CCyanDialog, CGrayDialog); { Always normal string }
  786. {$ENDIF}
  787. BEGIN
  788. GetPalette := @P[Palette]; { Return palette }
  789. END;
  790. {--TDialog------------------------------------------------------------------}
  791. { Valid -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 25Apr98 LdB }
  792. {---------------------------------------------------------------------------}
  793. FUNCTION TDialog.Valid (Command: Word): Boolean;
  794. BEGIN
  795. If (Command = cmCancel) Then Valid := True { Cancel returns true }
  796. Else Valid := TGroup.Valid(Command); { Call group ancestor }
  797. END;
  798. {--TDialog------------------------------------------------------------------}
  799. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  800. {---------------------------------------------------------------------------}
  801. PROCEDURE TDialog.HandleEvent (Var Event: TEvent);
  802. BEGIN
  803. Inherited HandleEvent(Event); { Call ancestor }
  804. Case Event.What Of
  805. evNothing: Exit; { Speed up exit }
  806. evKeyDown: { Key down event }
  807. Case Event.KeyCode Of
  808. kbEsc: Begin { Escape key press }
  809. Event.What := evCommand; { Command event }
  810. Event.Command := cmCancel; { cancel command }
  811. Event.InfoPtr := Nil; { Clear info ptr }
  812. PutEvent(Event); { Put event on queue }
  813. ClearEvent(Event); { Clear the event }
  814. End;
  815. kbEnter: Begin { Enter key press }
  816. Event.What := evBroadcast; { Broadcast event }
  817. Event.Command := cmDefault; { Default command }
  818. Event.InfoPtr := Nil; { Clear info ptr }
  819. PutEvent(Event); { Put event on queue }
  820. ClearEvent(Event); { Clear the event }
  821. End;
  822. End;
  823. evCommand: { Command event }
  824. Case Event.Command Of
  825. cmOk, cmCancel, cmYes, cmNo: { End dialog cmds }
  826. If (State AND sfModal <> 0) Then Begin { View is modal }
  827. EndModal(Event.Command); { End modal state }
  828. ClearEvent(Event); { Clear the event }
  829. End;
  830. End;
  831. End;
  832. END;
  833. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  834. { TInputLine OBJECT METHODS }
  835. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  836. {--TInputLine---------------------------------------------------------------}
  837. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  838. {---------------------------------------------------------------------------}
  839. CONSTRUCTOR TInputLine.Init (Var Bounds: TRect; AMaxLen: Integer);
  840. BEGIN
  841. Inherited Init(Bounds); { Call ancestor }
  842. State := State OR sfCursorVis; { Cursor visible }
  843. Options := Options OR (ofSelectable + ofFirstClick
  844. + ofVersion20); { Set options }
  845. If (MaxAvail > AMaxLen + 1) Then Begin { Check enough memory }
  846. GetMem(Data, AMaxLen + 1); { Allocate memory }
  847. Data^ := ''; { Data = empty string }
  848. End;
  849. MaxLen := AMaxLen; { Hold maximum length }
  850. END;
  851. {--TInputLine---------------------------------------------------------------}
  852. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  853. {---------------------------------------------------------------------------}
  854. CONSTRUCTOR TInputLine.Load (Var S: TStream);
  855. VAR B: Byte;
  856. BEGIN
  857. Inherited Load(S); { Call ancestor }
  858. S.Read(MaxLen, 2); { Read max length }
  859. S.Read(CurPos, 2); { Read cursor position }
  860. S.Read(FirstPos, 2); { Read first position }
  861. S.Read(SelStart, 2); { Read selected start }
  862. S.Read(SelEnd, 2); { Read selected end }
  863. S.Read(B, 1); { Read string length }
  864. If (MaxAvail > MaxLen+1) Then Begin { Check enough memory }
  865. GetMem(Data, MaxLen + 1); { Allocate memory }
  866. S.Read(Data^[1], Length(Data^)); { Read string data }
  867. {$IFDEF PPC_DELPHI3} { DELPHI 3+ COMPILER }
  868. SetLength(Data^, B); { Xfer string length }
  869. {$ELSE} { OTHER COMPILERS }
  870. Data^[0] := Chr(B); { Set string length }
  871. {$ENDIF}
  872. End Else S.Seek(S.GetPos + B); { Move to position }
  873. If (Options AND ofVersion >= ofVersion20) Then { Version 2 or above }
  874. Validator := PValidator(S.Get); { Get any validator }
  875. Options := Options OR ofVersion20; { Set version 2 flag }
  876. END;
  877. {--TInputLine---------------------------------------------------------------}
  878. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  879. {---------------------------------------------------------------------------}
  880. DESTRUCTOR TInputLine.Done;
  881. BEGIN
  882. If (Data <> Nil) Then FreeMem(Data, MaxLen + 1); { Release any memory }
  883. SetValidator(Nil); { Clear any validator }
  884. Inherited Done; { Call ancestor }
  885. END;
  886. {--TInputLine---------------------------------------------------------------}
  887. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  888. {---------------------------------------------------------------------------}
  889. FUNCTION TInputLine.DataSize: Word;
  890. VAR DSize: Word;
  891. BEGIN
  892. DSize := 0; { Preset zero datasize }
  893. If (Validator <> Nil) AND (Data <> Nil) Then
  894. DSize := Validator^.Transfer(Data^, Nil,
  895. vtDataSize); { Add validator size }
  896. If (DSize <> 0) Then DataSize := DSize { Use validtor size }
  897. Else DataSize := MaxLen + 1; { No validator use size }
  898. END;
  899. {--TInputLine---------------------------------------------------------------}
  900. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  901. {---------------------------------------------------------------------------}
  902. FUNCTION TInputLine.GetPalette: PPalette;
  903. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  904. CONST P: String = CInputLine; { Possible huge string }
  905. {$ELSE} { OTHER COMPILERS }
  906. CONST P: String[Length(CInputLine)] = CInputLine; { Always normal string }
  907. {$ENDIF}
  908. BEGIN
  909. GetPalette := @P; { Return palette }
  910. END;
  911. {--TInputLine---------------------------------------------------------------}
  912. { Valid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  913. {---------------------------------------------------------------------------}
  914. FUNCTION TInputLine.Valid (Command: Word): Boolean;
  915. FUNCTION AppendError (Validator: PValidator): Boolean;
  916. BEGIN
  917. AppendError := False; { Preset false }
  918. If (Data <> Nil) Then
  919. With Validator^ Do
  920. If (Options AND voOnAppend <> 0) AND { Check options }
  921. (CurPos <> Length(Data^)) AND { Exceeds max length }
  922. NOT IsValidInput(Data^, True) Then Begin { Check data valid }
  923. Error; { Call error }
  924. AppendError := True; { Return true }
  925. End;
  926. END;
  927. BEGIN
  928. Valid := Inherited Valid(Command); { Call ancestor }
  929. If (Validator <> Nil) AND (Data <> Nil) AND { Validator present }
  930. (State AND sfDisabled = 0) Then { Not disabled }
  931. If (Command = cmValid) Then { Valid command }
  932. Valid := Validator^.Status = vsOk { Validator result }
  933. Else If (Command <> cmCancel) Then { Not cancel command }
  934. If AppendError(Validator) OR { Append any error }
  935. NOT Validator^.Valid(Data^) Then Begin { Check validator }
  936. Select; { Reselect view }
  937. Valid := False; { Return false }
  938. End;
  939. END;
  940. {--TInputLine---------------------------------------------------------------}
  941. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  942. {---------------------------------------------------------------------------}
  943. PROCEDURE TInputLine.Draw;
  944. VAR Color: Byte; X, L, R: Integer; S, T: String;
  945. BEGIN
  946. If (State AND sfFocused = 0) Then Color := 1 { Not focused colour }
  947. Else Color := 2; { Focused colour }
  948. If CanScroll(-1) Then WriteStr(0, 0, LeftArr, 4); { Set left scroll mark }
  949. If CanScroll(1) Then WriteStr(-(RawSize.X + 1 -
  950. TextWidth(RightArr)), 0, RightArr, 4); { Set right scroll mark }
  951. If (Data <> Nil) Then S := Copy(Data^, FirstPos+1,
  952. Length(Data^)-FirstPos) Else S := ''; { Fetch data string }
  953. X := TextWidth(LeftArr); { left arrow width }
  954. While (TextWidth(S) > ((RawSize.X+1)-X-TextWidth(
  955. RightArr))) Do Delete(S, Length(S), 1); { Cut to right length }
  956. If (State AND sfFocused <> 0) Then Begin
  957. L := SelStart - FirstPos; { Selected left end }
  958. R := SelEnd - FirstPos; { Selected right end }
  959. If (L < 0) Then L := 0; { Fix any negative }
  960. If (R > Length(S)) Then R := Length(S); { Fix to long case }
  961. If (L > 0) Then Begin
  962. T := Copy(S, 1, L); { Unhighlight bit }
  963. WriteStr(-X, 0, T, Color); { Write string to screen }
  964. X := X + TextWidth(T); { New x position }
  965. Delete(S, 1, L); { Reduce string }
  966. End;
  967. If (L < R) Then Begin
  968. T := Copy(S, 1, R-L); { Highlight bit }
  969. WriteStr(-X, 0, T, 3); { Write string to screen }
  970. X := X + TextWidth(T); { New x position }
  971. Delete(S, 1, R-L); { Reduce string }
  972. End;
  973. If (Length(S) > 0) Then
  974. WriteStr(-X, 0, S, Color); { Write string to screen }
  975. End Else WriteStr(-X, 0, S, Color); { Write string to screen }
  976. Cursor.X := CurPos - FirstPos + 1; { Update cursor position }
  977. END;
  978. {--TInputLine---------------------------------------------------------------}
  979. { DrawbackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  980. {---------------------------------------------------------------------------}
  981. PROCEDURE TInputLine.DrawBackGround;
  982. BEGIN
  983. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  984. If (HWindow <> 0) Then DestroyCaret; { Destroy any caret }
  985. {$ENDIF}
  986. {$IFDEF OS_OS2} { OS2 CODE }
  987. If (HWindow <> 0) Then WinDestroyCursor(HWindow); { Destroy any caret }
  988. {$ENDIF}
  989. Inherited DrawBackGround; { Call ancestor }
  990. END;
  991. {--TInputLine---------------------------------------------------------------}
  992. { DrawCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Oct99 LdB }
  993. {---------------------------------------------------------------------------}
  994. PROCEDURE TInputLine.DrawCursor;
  995. VAR I, X: Integer; S: String;
  996. BEGIN
  997. If (State AND sfFocused <> 0) Then Begin { Focused window }
  998. X := TextWidth(LeftArr); { Preset x position }
  999. I := 0; { Preset cursor width }
  1000. If (Data <> Nil) Then Begin { Data pointer valid }
  1001. S := Copy(Data^, FirstPos+1, CurPos-FirstPos); { Copy the string }
  1002. X := X + TextWidth(S); { Calculate position }
  1003. If (State AND sfCursorIns <> 0) Then { Check insert mode }
  1004. If ((CurPos+1) <= Length(Data^)) Then
  1005. I := TextWidth(Data^[CurPos+1]) { Insert caret width }
  1006. Else I := FontWidth; { At end use fontwidth }
  1007. End;
  1008. {$IFDEF OS_DOS}
  1009. If (State AND sfCursorIns <> 0) Then Begin { Insert mode }
  1010. If ((CurPos+1) <= Length(Data^)) Then { Not beyond end }
  1011. WriteStr(-X, 0, Data^[CurPos+1], 5) { Create block cursor }
  1012. Else ClearArea(X, 0, X+I, FontHeight, Green);{ Line cursor }
  1013. End Else ClearArea(X, 0, X+I, FontHeight, Green);{ Line cursor }
  1014. {$ENDIF}
  1015. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1016. If (HWindow <> 0) Then Begin
  1017. CreateCaret(HWindow, 0, I, FontHeight); { Create a craet }
  1018. SetCaretPos(X, 0); { Set caret position }
  1019. If (State AND sfCursorVis <> 0) Then
  1020. ShowCaret(HWindow); { Show the caret }
  1021. End;
  1022. {$ENDIF}
  1023. {$IFDEF OS_OS2} { OS2 CODE }
  1024. If (HWindow <> 0) Then Begin
  1025. WinCreateCursor(HWindow, X, 0, 0, FontHeight,
  1026. CURSOR_FLASH, Nil); { Create a craet }
  1027. If (State AND sfCursorVis <> 0) Then
  1028. WinShowCursor(HWindow, True); { Show the caret }
  1029. End;
  1030. {$ENDIF}
  1031. End;
  1032. END;
  1033. {--TInputLine---------------------------------------------------------------}
  1034. { SelectAll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1035. {---------------------------------------------------------------------------}
  1036. PROCEDURE TInputLine.SelectAll (Enable: Boolean);
  1037. BEGIN
  1038. CurPos := 0; { Cursor to start }
  1039. FirstPos := 0; { First pos to start }
  1040. SelStart := 0; { Selected at start }
  1041. If Enable AND (Data <> Nil) Then
  1042. SelEnd := Length(Data^) Else SelEnd := 0; { Selected which end }
  1043. DrawView; { Now redraw the view }
  1044. END;
  1045. {--TInputLine---------------------------------------------------------------}
  1046. { SetValidator -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1047. {---------------------------------------------------------------------------}
  1048. PROCEDURE TInputLine.SetValidator (AValid: PValidator);
  1049. BEGIN
  1050. If (Validator <> Nil) Then Validator^.Free; { Release validator }
  1051. Validator := AValid; { Set new validator }
  1052. END;
  1053. {--TInputLine---------------------------------------------------------------}
  1054. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1055. {---------------------------------------------------------------------------}
  1056. PROCEDURE TInputLine.SetState (AState: Word; Enable: Boolean);
  1057. BEGIN
  1058. Inherited SetState(AState, Enable); { Call ancestor }
  1059. If (AState = sfSelected) OR ((AState = sfActive)
  1060. AND (State and sfSelected <> 0)) Then
  1061. SelectAll(Enable) Else { Call select all }
  1062. If (AState = sfFocused) Then DrawView; { Redraw for focus }
  1063. END;
  1064. {--TInputLine---------------------------------------------------------------}
  1065. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1066. {---------------------------------------------------------------------------}
  1067. PROCEDURE TInputLine.GetData (Var Rec);
  1068. BEGIN
  1069. If (Data <> Nil) Then Begin { Data ptr valid }
  1070. If (Validator = Nil) OR (Validator^.Transfer(Data^,
  1071. @Rec, vtGetData) = 0) Then Begin { No validator/data }
  1072. FillChar(Rec, DataSize, #0); { Clear the data area }
  1073. Move(Data^, Rec, Length(Data^) + 1); { Transfer our data }
  1074. End;
  1075. End Else FillChar(Rec, DataSize, #0); { Clear the data area }
  1076. END;
  1077. {--TInputLine---------------------------------------------------------------}
  1078. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1079. {---------------------------------------------------------------------------}
  1080. PROCEDURE TInputLine.SetData (Var Rec);
  1081. {$IFDEF PPC_DELPHI3} VAR Buf: Array [0..256] Of Char; {$ENDIF}
  1082. BEGIN
  1083. If (Data <> Nil) Then Begin { Data ptr valid }
  1084. If (Validator = Nil) OR (Validator^.Transfer(
  1085. Data^, @Rec, vtSetData) = 0) Then { No validator/data }
  1086. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1087. Move(Rec, Buf, DataSize); { Fetch our data }
  1088. Move(Buf[1], Data^[1], Ord(Buf[0])); { Tranfer string }
  1089. SetLength(Data^, Ord(Buf[0])); { Set string length }
  1090. {$ELSE} { OTHER COMPILERS }
  1091. Move(Rec, Data^[0], DataSize); { Set our data }
  1092. {$ENDIF}
  1093. End;
  1094. SelectAll(True); { Now select all }
  1095. END;
  1096. {--TInputLine---------------------------------------------------------------}
  1097. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1098. {---------------------------------------------------------------------------}
  1099. PROCEDURE TInputLine.Store (Var S: TStream);
  1100. BEGIN
  1101. TView.Store(S); { Implict TView.Store }
  1102. S.Write(MaxLen, 2); { Read max length }
  1103. S.Write(CurPos, 2); { Read cursor position }
  1104. S.Write(FirstPos, 2); { Read first position }
  1105. S.Write(SelStart, 2); { Read selected start }
  1106. S.Write(SelEnd, 2); { Read selected end }
  1107. S.WriteStr(Data); { Write the data }
  1108. S.Put(Validator); { Write any validator }
  1109. END;
  1110. {--TInputLine---------------------------------------------------------------}
  1111. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1112. {---------------------------------------------------------------------------}
  1113. PROCEDURE TInputLine.HandleEvent (Var Event: TEvent);
  1114. CONST PadKeys = [$47, $4B, $4D, $4F, $73, $74];
  1115. VAR WasAppending: Boolean; ExtendBlock: Boolean; OldData: String;
  1116. Delta, Anchor, OldCurPos, OldFirstPos, OldSelStart, OldSelEnd: Integer;
  1117. FUNCTION MouseDelta: Integer;
  1118. BEGIN
  1119. If (Event.Where.X <= RawOrigin.X+TextWidth(LeftArr))
  1120. Then MouseDelta := -1 Else { To left of text area }
  1121. If ((Event.Where.X-RawOrigin.X) >= RawSize.X -
  1122. TextWidth(RightArr)) Then MouseDelta := 1 { To right of text area }
  1123. Else MouseDelta := 0; { In area return 0 }
  1124. END;
  1125. FUNCTION MousePos: Integer;
  1126. VAR Mp, Tw, Pos: Integer; S: String;
  1127. BEGIN
  1128. Mp := Event.Where.X - RawOrigin.X; { Mouse position }
  1129. If (Data <> Nil) Then S := Copy(Data^, FirstPos+1,
  1130. Length(Data^)-FirstPos) Else S := ''; { Text area string }
  1131. Tw := TextWidth(LeftArr); { Text width }
  1132. Pos := 0; { Zero position }
  1133. While (Mp > Tw) AND (Pos <= Length(S)) Do Begin { Still text to right }
  1134. Tw := Tw + TextWidth(S[Pos+1]); { Add next character }
  1135. Inc(Pos); { Next character }
  1136. End;
  1137. If (Pos > 0) Then Dec(Pos);
  1138. MousePos := FirstPos + Pos; { Return mouse position }
  1139. END;
  1140. PROCEDURE DeleteSelect;
  1141. BEGIN
  1142. If (SelStart <> SelEnd) Then Begin { An area selected }
  1143. If (Data <> Nil) Then
  1144. Delete(Data^, SelStart+1, SelEnd-SelStart); { Delete the text }
  1145. CurPos := SelStart; { Set cursor position }
  1146. End;
  1147. END;
  1148. PROCEDURE AdjustSelectBlock;
  1149. BEGIN
  1150. If (CurPos < Anchor) Then Begin { Selection backwards }
  1151. SelStart := CurPos; { Start of select }
  1152. SelEnd := Anchor; { End of select }
  1153. End Else Begin
  1154. SelStart := Anchor; { Start of select }
  1155. SelEnd := CurPos; { End of select }
  1156. End;
  1157. END;
  1158. PROCEDURE SaveState;
  1159. BEGIN
  1160. If (Validator <> Nil) Then Begin { Check for validator }
  1161. If (Data <> Nil) Then OldData := Data^; { Hold data }
  1162. OldCurPos := CurPos; { Hold cursor position }
  1163. OldFirstPos := FirstPos; { Hold first position }
  1164. OldSelStart := SelStart; { Hold select start }
  1165. OldSelEnd := SelEnd; { Hold select end }
  1166. If (Data = Nil) Then WasAppending := True { Invalid data ptr }
  1167. Else WasAppending := Length(Data^) = CurPos; { Hold appending state }
  1168. End;
  1169. END;
  1170. PROCEDURE RestoreState;
  1171. BEGIN
  1172. If (Validator <> Nil) Then Begin { Validator valid }
  1173. If (Data <> Nil) Then Data^ := OldData; { Restore data }
  1174. CurPos := OldCurPos; { Restore cursor pos }
  1175. FirstPos := OldFirstPos; { Restore first pos }
  1176. SelStart := OldSelStart; { Restore select start }
  1177. SelEnd := OldSelEnd; { Restore select end }
  1178. End;
  1179. END;
  1180. FUNCTION CheckValid (NoAutoFill: Boolean): Boolean;
  1181. VAR OldLen: Integer; NewData: String;
  1182. BEGIN
  1183. If (Validator <> Nil) Then Begin { Validator valid }
  1184. CheckValid := False; { Preset false return }
  1185. If (Data <> Nil) Then OldLen := Length(Data^); { Hold old length }
  1186. If (Validator^.Options AND voOnAppend = 0) OR
  1187. (WasAppending AND (CurPos = OldLen)) Then Begin
  1188. If (Data <> Nil) Then NewData := Data^ { Hold current data }
  1189. Else NewData := ''; { Set empty string }
  1190. If NOT Validator^.IsValidInput(NewData,
  1191. NoAutoFill) Then RestoreState Else Begin
  1192. If (Length(NewData) > MaxLen) Then { Exceeds maximum }
  1193. {$IFDEF PPC_DELPHI3} { DELPHI 3+ COMPILER }
  1194. SetLength(NewData, MaxLen); { Set string length }
  1195. {$ELSE} { OTHER COMPILERS }
  1196. NewData[0] := Chr(MaxLen); { Set string length }
  1197. {$ENDIF}
  1198. If (Data <> Nil) Then Data^ := NewData; { Set data value }
  1199. If (Data <> Nil) AND (CurPos >= OldLen) { Cursor beyond end }
  1200. AND (Length(Data^) > OldLen) Then { Cursor beyond string }
  1201. CurPos := Length(Data^); { Set cursor position }
  1202. CheckValid := True; { Return true result }
  1203. End;
  1204. End Else Begin
  1205. CheckValid := True; { Preset true return }
  1206. If (CurPos = OldLen) AND (Data <> Nil) Then { Lengths match }
  1207. If NOT Validator^.IsValidInput(Data^,
  1208. False) Then Begin { Check validator }
  1209. Validator^.Error; { Call error }
  1210. CheckValid := False; { Return false result }
  1211. End;
  1212. End;
  1213. End Else CheckValid := True; { No validator }
  1214. END;
  1215. BEGIN
  1216. Inherited HandleEvent(Event); { Call ancestor }
  1217. If (State AND sfSelected <> 0) Then Begin { View is selected }
  1218. Case Event.What Of
  1219. evNothing: Exit; { Speed up exit }
  1220. evMouseDown: Begin { Mouse down event }
  1221. Delta := MouseDelta; { Calc scroll value }
  1222. If CanScroll(Delta) Then Begin { Can scroll }
  1223. Repeat
  1224. If CanScroll(Delta) Then Begin { Still can scroll }
  1225. Inc(FirstPos, Delta); { Move start position }
  1226. DrawView; { Redraw the view }
  1227. End;
  1228. Until NOT MouseEvent(Event, evMouseAuto); { Until no mouse auto }
  1229. End Else If Event.Double Then { Double click }
  1230. SelectAll(True) Else Begin { Select whole text }
  1231. Anchor := MousePos; { Start of selection }
  1232. Repeat
  1233. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  1234. If (Event.What = evMouseAuto) { Mouse auto event }
  1235. {$ELSE} { WIN/NT/OS2 CODE }
  1236. If (Event.What = evMouseMove) { Mouse move event }
  1237. {$ENDIF}
  1238. Then Begin
  1239. Delta := MouseDelta; { New position }
  1240. If CanScroll(Delta) Then { If can scroll }
  1241. Inc(FirstPos, Delta);
  1242. End;
  1243. CurPos := MousePos; { Set cursor position }
  1244. AdjustSelectBlock; { Adjust selected }
  1245. DrawView; { Redraw the view }
  1246. Until NOT MouseEvent(Event, evMouseMove
  1247. + evMouseAuto); { Until mouse released }
  1248. End;
  1249. ClearEvent(Event); { Clear the event }
  1250. End;
  1251. evKeyDown: Begin
  1252. SaveState; { Save state of view }
  1253. Event.KeyCode := CtrlToArrow(Event.KeyCode); { Convert keycode }
  1254. If (Event.ScanCode IN PadKeys) AND
  1255. (GetShiftState AND $03 <> 0) Then Begin { Mark selection active }
  1256. Event.CharCode := #0; { Clear char code }
  1257. If (CurPos = SelEnd) Then { Find if at end }
  1258. Anchor := SelStart Else { Anchor from start }
  1259. Anchor := SelEnd; { Anchor from end }
  1260. ExtendBlock := True; { Extended block true }
  1261. End Else ExtendBlock := False; { No extended block }
  1262. Case Event.KeyCode Of
  1263. kbLeft: If (CurPos > 0) Then Dec(CurPos); { Move cursor left }
  1264. kbRight: If (Data <> Nil) AND { Move right cursor }
  1265. (CurPos < Length(Data^)) Then Begin { Check not at end }
  1266. Inc(CurPos); { Move cursor }
  1267. CheckValid(True); { Check if valid }
  1268. End;
  1269. kbHome: CurPos := 0; { Move to line start }
  1270. kbEnd: Begin { Move to line end }
  1271. If (Data = Nil) Then CurPos := 0 { Invalid data ptr }
  1272. Else CurPos := Length(Data^); { Set cursor position }
  1273. CheckValid(True); { Check if valid }
  1274. End;
  1275. kbBack: If (Data <> Nil) AND (CurPos > 0) { Not at line start }
  1276. Then Begin
  1277. Delete(Data^, CurPos, 1); { Backspace over char }
  1278. Dec(CurPos); { Move cursor back one }
  1279. If (FirstPos > 0) Then Dec(FirstPos); { Move first position }
  1280. CheckValid(True); { Check if valid }
  1281. End;
  1282. kbDel: If (Data <> Nil) Then Begin { Delete character }
  1283. If (SelStart = SelEnd) Then { Select all on }
  1284. If (CurPos < Length(Data^)) Then Begin { Cursor not at end }
  1285. SelStart := CurPos; { Set select start }
  1286. SelEnd := CurPos + 1; { Set select end }
  1287. End;
  1288. DeleteSelect; { Deselect selection }
  1289. CheckValid(True); { Check if valid }
  1290. End;
  1291. kbIns: SetState(sfCursorIns, State AND
  1292. sfCursorIns = 0); { Flip insert state }
  1293. Else Case Event.CharCode Of
  1294. ' '..#255: If (Data <> Nil) Then Begin { Character key }
  1295. If (State AND sfCursorIns <> 0) Then
  1296. Delete(Data^, CurPos + 1, 1) Else { Overwrite character }
  1297. DeleteSelect; { Deselect selected }
  1298. If CheckValid(True) Then Begin { Check data valid }
  1299. If (Length(Data^) < MaxLen) Then { Must not exceed maxlen }
  1300. Begin
  1301. If (FirstPos > CurPos) Then
  1302. FirstPos := CurPos; { Advance first position }
  1303. Inc(CurPos); { Increment cursor }
  1304. Insert(Event.CharCode, Data^,
  1305. CurPos); { Insert the character }
  1306. End;
  1307. CheckValid(False); { Check data valid }
  1308. End;
  1309. End;
  1310. ^Y: If (Data <> Nil) Then Begin { Clear all data }
  1311. Data^ := ''; { Set empty string }
  1312. CurPos := 0; { Cursor to start }
  1313. End;
  1314. Else Exit; { Unused key }
  1315. End
  1316. End;
  1317. If ExtendBlock Then AdjustSelectBlock { Extended block }
  1318. Else Begin
  1319. SelStart := CurPos; { Set select start }
  1320. SelEnd := CurPos; { Set select end }
  1321. End;
  1322. If (FirstPos > CurPos) Then
  1323. FirstPos := CurPos; { Advance first pos }
  1324. If (Data <> Nil) Then OldData := Copy(Data^,
  1325. FirstPos+1, CurPos-FirstPos) { Text area string }
  1326. Else OldData := ''; { Empty string }
  1327. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  1328. Delta := FontWidth; { Safety = 1 char }
  1329. {$ELSE} { WIN/NT CODE }
  1330. Delta := 2*FontWidth; { Safety = 2 char }
  1331. {$ENDIF}
  1332. While (TextWidth(OldData) > ((RawSize.X+1)-Delta)
  1333. - TextWidth(LeftArr) - TextWidth(RightArr)) { Check text fits }
  1334. Do Begin
  1335. Inc(FirstPos); { Advance first pos }
  1336. OldData := Copy(Data^, FirstPos+1,
  1337. CurPos-FirstPos) { Text area string }
  1338. End;
  1339. DrawView; { Redraw the view }
  1340. ClearEvent(Event); { Clear the event }
  1341. End;
  1342. End;
  1343. End;
  1344. END;
  1345. {***************************************************************************}
  1346. { TInputLine OBJECT PRIVATE METHODS }
  1347. {***************************************************************************}
  1348. {--TInputLine---------------------------------------------------------------}
  1349. { CanScroll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1350. {---------------------------------------------------------------------------}
  1351. FUNCTION TInputLine.CanScroll (Delta: Integer): Boolean;
  1352. VAR S: String;
  1353. BEGIN
  1354. If (Delta < 0) Then CanScroll := FirstPos > 0 { Check scroll left }
  1355. Else If (Delta > 0) Then Begin
  1356. If (Data = Nil) Then S := '' Else { Data ptr invalid }
  1357. S := Copy(Data^, FirstPos+1, Length(Data^)
  1358. - FirstPos); { Fetch max string }
  1359. CanScroll := (TextWidth(S)) > (RawSize.X -
  1360. TextWidth(LeftArr) - TextWidth(RightArr)); { Check scroll right }
  1361. End Else CanScroll := False; { Zero so no scroll }
  1362. END;
  1363. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1364. { TButton OBJECT METHODS }
  1365. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1366. {--TButton------------------------------------------------------------------}
  1367. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1368. {---------------------------------------------------------------------------}
  1369. CONSTRUCTOR TButton.Init (Var Bounds: TRect; ATitle: TTitleStr;
  1370. ACommand: Word; AFlags: Word);
  1371. BEGIN
  1372. Inherited Init(Bounds); { Call ancestor }
  1373. EventMask := EventMask OR evBroadcast; { Handle broadcasts }
  1374. GOptions := GOptions OR goDrawFocus; { Set new option mask }
  1375. Options := Options OR (ofSelectable + ofFirstClick
  1376. + ofPreProcess + ofPostProcess); { Set option flags }
  1377. If NOT CommandEnabled(ACommand) Then
  1378. State := State OR sfDisabled; { Check command state }
  1379. Flags := AFlags; { Hold flags }
  1380. If (AFlags AND bfDefault <> 0) Then AmDefault := True
  1381. Else AmDefault := False; { Check if default }
  1382. Title := NewStr(ATitle); { Hold title string }
  1383. Command := ACommand; { Hold button command }
  1384. TabMask := TabMask OR (tmLeft + tmRight +
  1385. tmTab + tmShiftTab + tmUp + tmDown); { Set tab masks }
  1386. END;
  1387. {--TButton------------------------------------------------------------------}
  1388. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1389. {---------------------------------------------------------------------------}
  1390. CONSTRUCTOR TButton.Load (Var S: TStream);
  1391. BEGIN
  1392. Inherited Load(S); { Call ancestor }
  1393. Title := S.ReadStr; { Read title }
  1394. S.Read(Command, 2); { Read command }
  1395. S.Read(Flags, 1); { Read flags }
  1396. S.Read(AmDefault, 1); { Read if default }
  1397. If NOT CommandEnabled(Command) Then { Check command state }
  1398. State := State OR sfDisabled Else { Command disabled }
  1399. State := State AND NOT sfDisabled; { Command enabled }
  1400. END;
  1401. {--TButton------------------------------------------------------------------}
  1402. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1403. {---------------------------------------------------------------------------}
  1404. DESTRUCTOR TButton.Done;
  1405. BEGIN
  1406. If (Title <> Nil) Then DisposeStr(Title); { Dispose title }
  1407. Inherited Done; { Call ancestor }
  1408. END;
  1409. {--TButton------------------------------------------------------------------}
  1410. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1411. {---------------------------------------------------------------------------}
  1412. FUNCTION TButton.GetPalette: PPalette;
  1413. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1414. CONST P: String = CButton; { Possible huge string }
  1415. {$ELSE} { OTHER COMPILERS }
  1416. CONST P: String[Length(CButton)] = CButton; { Always normal string }
  1417. {$ENDIF}
  1418. BEGIN
  1419. GetPalette := @P; { Get button palette }
  1420. END;
  1421. {--TButton------------------------------------------------------------------}
  1422. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Apr98 LdB }
  1423. {---------------------------------------------------------------------------}
  1424. PROCEDURE TButton.Press;
  1425. VAR E: TEvent;
  1426. BEGIN
  1427. Message(Owner, evBroadcast, cmRecordHistory, Nil); { Message for history }
  1428. If (Flags AND bfBroadcast <> 0) Then { Broadcasting button }
  1429. Message(Owner, evBroadcast, Command, @Self) { Send message }
  1430. Else Begin
  1431. E.What := evCommand; { Command event }
  1432. E.Command := Command; { Set command value }
  1433. E.InfoPtr := @Self; { Pointer to self }
  1434. PutEvent(E); { Put event on queue }
  1435. End;
  1436. END;
  1437. {--TButton------------------------------------------------------------------}
  1438. { DrawFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1439. {---------------------------------------------------------------------------}
  1440. PROCEDURE TButton.DrawFocus;
  1441. VAR B: Byte; I: Integer; Bc: Word; Db: TDrawBuffer;
  1442. BEGIN
  1443. If DownFlag Then B := 7 Else B := 0; { Shadow colour }
  1444. GraphRectangle(0, 0, RawSize.X, RawSize.Y, B); { Draw backing shadow }
  1445. GraphRectangle(1, 1, RawSize.X-1, RawSize.Y-1, B); { Draw backing shadow }
  1446. If DownFlag Then B := 0 Else B := 15; { Highlight colour }
  1447. GraphLine(0, RawSize.Y, 0, 0, B);
  1448. GraphLine(1, RawSize.Y-1, 1, 1, B); { Left highlights }
  1449. GraphLine(0, 0, RawSize.X, 0, B);
  1450. GraphLine(1, 1, RawSize.X-1, 1, B); { Top highlights }
  1451. If DownFlag Then B := 8 Else B := 7; { Select backing }
  1452. If (State AND sfFocused <> 0) AND
  1453. (DownFlag = False) Then B := 14; { Show as focused }
  1454. GraphRectangle(2, 2, RawSize.X-2, RawSize.Y-2, B); { Draw first border }
  1455. GraphRectangle(3, 3, RawSize.X-3, RawSize.Y-3, B); { Draw next border }
  1456. If (State AND sfDisabled <> 0) Then { Button disabled }
  1457. Bc := GetColor($0404) Else Begin { Disabled colour }
  1458. Bc := GetColor($0501); { Set normal colour }
  1459. If (State AND sfActive <> 0) Then { Button is active }
  1460. If (State AND sfSelected <> 0) Then
  1461. Bc := GetColor($0703) Else { Set selected colour }
  1462. If AmDefault Then Bc := GetColor($0602); { Set is default colour }
  1463. End;
  1464. If (Title <> Nil) Then Begin { We have a title }
  1465. If (Flags AND bfLeftJust = 0) Then Begin { Not left set title }
  1466. I := TextWidth(Title^); { Fetch title width }
  1467. I := (RawSize.X - I) DIV 2; { Centre in button }
  1468. End Else I := FontWidth; { Left edge of button }
  1469. MoveCStr(Db, Title^, Bc); { Move title to buffer }
  1470. GOptions := GOptions OR goGraphView; { Graphics co-ords mode }
  1471. WriteLine(I, FontHeight DIV 2, CStrLen(Title^),
  1472. 1, Db); { Write the title }
  1473. GOptions := GOptions AND NOT goGraphView; { Return to normal mode }
  1474. End;
  1475. END;
  1476. {--TButton------------------------------------------------------------------}
  1477. { DrawState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1478. {---------------------------------------------------------------------------}
  1479. PROCEDURE TButton.DrawState (Down: Boolean);
  1480. BEGIN
  1481. DownFlag := Down; { Set down flag }
  1482. SetDrawMask(vdFocus); { Set focus mask }
  1483. DrawView; { Redraw the view }
  1484. END;
  1485. {--TButton------------------------------------------------------------------}
  1486. { MakeDefault -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1487. {---------------------------------------------------------------------------}
  1488. PROCEDURE TButton.MakeDefault (Enable: Boolean);
  1489. VAR C: Word;
  1490. BEGIN
  1491. If (Flags AND bfDefault=0) Then Begin { Not default }
  1492. If Enable Then C := cmGrabDefault
  1493. Else C := cmReleaseDefault; { Change default }
  1494. Message(Owner, evBroadcast, C, @Self); { Message to owner }
  1495. AmDefault := Enable; { Set default flag }
  1496. DrawView; { Now redraw button }
  1497. End;
  1498. END;
  1499. {--TButton------------------------------------------------------------------}
  1500. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1501. {---------------------------------------------------------------------------}
  1502. PROCEDURE TButton.SetState (AState: Word; Enable: Boolean);
  1503. BEGIN
  1504. Inherited SetState(AState, Enable); { Call ancestor }
  1505. If (AState AND (sfSelected + sfActive) <> 0) { Changing select }
  1506. Then DrawView; { Redraw required }
  1507. If (AState AND sfFocused <> 0) Then
  1508. MakeDefault(Enable); { Check for default }
  1509. END;
  1510. {--TButton------------------------------------------------------------------}
  1511. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  1512. {---------------------------------------------------------------------------}
  1513. PROCEDURE TButton.Store (Var S: TStream);
  1514. BEGIN
  1515. TView.Store(S); { Implict TView.Store }
  1516. S.WriteStr(Title); { Store title string }
  1517. S.Write(Command, 2); { Store command }
  1518. S.Write(Flags, 1); { Store flags }
  1519. S.Write(AmDefault, 1); { Store default flag }
  1520. END;
  1521. {--TButton------------------------------------------------------------------}
  1522. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Sep99 LdB }
  1523. {---------------------------------------------------------------------------}
  1524. PROCEDURE TButton.HandleEvent (Var Event: TEvent);
  1525. VAR Down: Boolean; C: Char; ButRect: TRect;
  1526. BEGIN
  1527. ButRect.A := RawOrigin; { Get origin point }
  1528. ButRect.B.X := RawOrigin.X + RawSize.X; { Calc right side }
  1529. ButRect.B.Y := RawOrigin.Y + RawSize.Y; { Calc bottom }
  1530. If (Event.What = evMouseDown) Then Begin { Mouse down event }
  1531. If NOT MouseInView(Event.Where) Then Begin { If point not in view }
  1532. ClearEvent(Event); { Clear the event }
  1533. Exit; { Speed up exit }
  1534. End;
  1535. End;
  1536. If (Flags AND bfGrabFocus <> 0) Then { Check focus grab }
  1537. Inherited HandleEvent(Event); { Call ancestor }
  1538. Case Event.What Of
  1539. evNothing: Exit; { Speed up exit }
  1540. evMouseDown: Begin
  1541. If (State AND sfDisabled = 0) Then Begin { Button not disabled }
  1542. Down := False; { Clear down flag }
  1543. Repeat
  1544. If (Down <> ButRect.Contains(Event.Where)) { State has changed }
  1545. Then Begin
  1546. Down := NOT Down; { Invert down flag }
  1547. DrawState(Down); { Redraw button }
  1548. End;
  1549. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse move }
  1550. If Down Then Begin { Button is down }
  1551. Press; { Send out command }
  1552. DrawState(False); { Draw button up }
  1553. End;
  1554. End;
  1555. ClearEvent(Event); { Event was handled }
  1556. End;
  1557. evKeyDown: Begin
  1558. If (Title <> Nil) Then C := HotKey(Title^) { Key title hotkey }
  1559. Else C := #0; { Invalid title }
  1560. If (Event.KeyCode = GetAltCode(C)) OR { Alt char }
  1561. (Owner^.Phase = phPostProcess) AND (C <> #0)
  1562. AND (Upcase(Event.CharCode) = C) OR { Matches hotkey }
  1563. (State AND sfFocused <> 0) AND { View focused }
  1564. ((Event.CharCode = ' ') OR { Space bar }
  1565. (Event.KeyCode=kbEnter)) Then Begin { Enter key }
  1566. DrawState(True); { Draw button down }
  1567. Press; { Send out command }
  1568. ClearEvent(Event); { Clear the event }
  1569. DrawState(False); { Draw button up }
  1570. End;
  1571. End;
  1572. evBroadcast:
  1573. Case Event.Command of
  1574. cmDefault: If AmDefault AND { Default command }
  1575. (State AND sfDisabled = 0) Then Begin { Button enabled }
  1576. Press; { Send out command }
  1577. ClearEvent(Event); { Clear the event }
  1578. End;
  1579. cmGrabDefault, cmReleaseDefault: { Grab and release cmd }
  1580. If (Flags AND bfDefault <> 0) Then Begin { Change button state }
  1581. AmDefault := Event.Command = cmReleaseDefault;
  1582. DrawView; { Redraw the view }
  1583. End;
  1584. cmCommandSetChanged: Begin { Command set changed }
  1585. SetState(sfDisabled, NOT
  1586. CommandEnabled(Command)); { Set button state }
  1587. DrawView; { Redraw the view }
  1588. End;
  1589. End;
  1590. End;
  1591. END;
  1592. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1593. { TCluster OBJECT METHODS }
  1594. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1595. CONST TvClusterClassName = 'TVCLUSTER';
  1596. {--TCluster-----------------------------------------------------------------}
  1597. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  1598. {---------------------------------------------------------------------------}
  1599. CONSTRUCTOR TCluster.Init (Var Bounds: TRect; AStrings: PSItem);
  1600. VAR I: Integer; P: PSItem;
  1601. BEGIN
  1602. Inherited Init(Bounds); { Call ancestor }
  1603. GOptions := GOptions OR goDrawFocus; { Draw focus view }
  1604. Options := Options OR (ofSelectable + ofFirstClick
  1605. + ofPreProcess + ofPostProcess + ofVersion20); { Set option masks }
  1606. I := 0; { Zero string count }
  1607. P := AStrings; { First item }
  1608. While (P <> Nil) Do Begin
  1609. Inc(I); { Count 1 item }
  1610. P := P^.Next; { Move to next item }
  1611. End;
  1612. Strings.Init(I, 0); { Create collection }
  1613. While (AStrings <> Nil) Do Begin
  1614. P := AStrings; { Transfer item ptr }
  1615. Strings.AtInsert(Strings.Count, AStrings^.Value);{ Insert string }
  1616. AStrings := AStrings^.Next; { Move to next item }
  1617. Dispose(P); { Dispose prior item }
  1618. End;
  1619. EnableMask := $FFFFFFFF; { Enable bit masks }
  1620. END;
  1621. {--TCluster-----------------------------------------------------------------}
  1622. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Oct99 LdB }
  1623. {---------------------------------------------------------------------------}
  1624. CONSTRUCTOR TCluster.Load (Var S: TStream);
  1625. BEGIN
  1626. Inherited Load(S); { Call ancestor }
  1627. S.Read(Value, 4); { Read value }
  1628. S.Read(Sel, 2); { Read select item }
  1629. If ((Options AND ofVersion) >= ofVersion20) { Version 2 TV view }
  1630. Then S.Read(EnableMask, 4) Else Begin { Read enable masks }
  1631. EnableMask := $FFFFFFFF; { Enable all masks }
  1632. Options := Options OR ofVersion20; { Set version 2 mask }
  1633. End;
  1634. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  1635. S.Read(Id, 2); { Read view id }
  1636. Strings.Load(S); { Load string data }
  1637. SetButtonState(0, True); { Set button state }
  1638. END;
  1639. {--TCluster-----------------------------------------------------------------}
  1640. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  1641. {---------------------------------------------------------------------------}
  1642. DESTRUCTOR TCluster.Done;
  1643. VAR I: Integer;
  1644. BEGIN
  1645. {$IFNDEF NO_WINDOW} { WIN/NT/OS2 CODE }
  1646. If (WndHandles <> Nil) Then Begin { Handles valid }
  1647. For I := 1 To Strings.Count Do { For each entry }
  1648. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1649. DestroyWindow(WndHandles^[I-1]); { Destroy button views }
  1650. {$ELSE} { OS2 CODE }
  1651. WinDestroyWindow(WndHandles^[I-1]); { Destroy button views }
  1652. {$ENDIF}
  1653. FreeMem(WndHandles, Strings.Count*SizeOf(HWnd)); { Release memory }
  1654. End;
  1655. {$ENDIF}
  1656. Strings.Done; { Dispose of strings }
  1657. Inherited Done; { Call ancestor }
  1658. END;
  1659. {--TCluster-----------------------------------------------------------------}
  1660. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1661. {---------------------------------------------------------------------------}
  1662. FUNCTION TCluster.DataSize: Word;
  1663. BEGIN
  1664. DataSize := SizeOf(Word); { Exchanges a word }
  1665. END;
  1666. {--TCluster-----------------------------------------------------------------}
  1667. { GetHelpCtx -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1668. {---------------------------------------------------------------------------}
  1669. FUNCTION TCluster.GetHelpCtx: Word;
  1670. BEGIN
  1671. If (HelpCtx = hcNoContext) Then { View has no help }
  1672. GetHelpCtx := hcNoContext Else { No help context }
  1673. GetHelpCtx := HelpCtx + Sel; { Help of selected }
  1674. END;
  1675. {--TCluster-----------------------------------------------------------------}
  1676. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1677. {---------------------------------------------------------------------------}
  1678. FUNCTION TCluster.GetPalette: PPalette;
  1679. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1680. CONST P: String = CCluster; { Possible huge string }
  1681. {$ELSE} { OTHER COMPILERS }
  1682. CONST P: String[Length(CCluster)] = CCluster; { Always normal string }
  1683. {$ENDIF}
  1684. BEGIN
  1685. GetPalette := @P; { Cluster palette }
  1686. END;
  1687. {--TCluster-----------------------------------------------------------------}
  1688. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1689. {---------------------------------------------------------------------------}
  1690. FUNCTION TCluster.Mark (Item: Integer): Boolean;
  1691. BEGIN
  1692. Mark := False; { Default false }
  1693. END;
  1694. {--TCluster-----------------------------------------------------------------}
  1695. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1696. {---------------------------------------------------------------------------}
  1697. FUNCTION TCluster.MultiMark (Item: Integer): Byte;
  1698. BEGIN
  1699. MultiMark := Byte(Mark(Item) = True); { Return multi mark }
  1700. END;
  1701. {--TCluster-----------------------------------------------------------------}
  1702. { ButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1703. {---------------------------------------------------------------------------}
  1704. FUNCTION TCluster.ButtonState (Item: Integer): Boolean;
  1705. BEGIN
  1706. If (Item > 31) Then ButtonState := False Else { Impossible item }
  1707. ButtonState := ((1 SHL Item) AND EnableMask)<>0; { Return true/false }
  1708. END;
  1709. {--TCluster-----------------------------------------------------------------}
  1710. { DrawFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Jul99 LdB }
  1711. {---------------------------------------------------------------------------}
  1712. PROCEDURE TCluster.DrawFocus;
  1713. BEGIN
  1714. {$IFNDEF OS_DOS} { WIN/NT/OS2 CODE }
  1715. If (WndHandles <> Nil) Then { Valid window handles }
  1716. If (State AND sfFocused <> 0) Then Begin { View is focused }
  1717. If (Sel >= 0) AND (Sel < Strings.Count) Then
  1718. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1719. SetFocus(WndHandles^[Sel]) { Focus selected view }
  1720. Else SetFocus(AppWindow); { Focus owner }
  1721. {$ELSE} { OS2 CODE }
  1722. WinSetFocus(HWND_DESKTOP, WndHandles^[Sel]) { Focus selected view }
  1723. Else WinSetFocus(HWND_DESKTOP, HWindow); { Focus owner }
  1724. {$ENDIF}
  1725. End Else
  1726. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1727. SetFocus(AppWindow); { Focus owner }
  1728. {$ELSE} { OS2 CODE }
  1729. WinSetFocus(HWND_DESKTOP, AppWindow); { Focus owner }
  1730. {$ENDIF}
  1731. {$ENDIF}
  1732. END;
  1733. {--TCluster-----------------------------------------------------------------}
  1734. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1735. {---------------------------------------------------------------------------}
  1736. PROCEDURE TCluster.Press (Item: Integer);
  1737. VAR P: PView;
  1738. BEGIN
  1739. P := TopView;
  1740. If (Id <> 0) AND (P <> Nil) Then NewMessage(P,
  1741. evCommand, cmIdCommunicate, Id, Value, @Self); { Send new message }
  1742. END;
  1743. {--TCluster-----------------------------------------------------------------}
  1744. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1745. {---------------------------------------------------------------------------}
  1746. PROCEDURE TCluster.MovedTo (Item: Integer);
  1747. BEGIN { Abstract method }
  1748. END;
  1749. {--TCluster-----------------------------------------------------------------}
  1750. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1751. {---------------------------------------------------------------------------}
  1752. PROCEDURE TCluster.SetState (AState: Word; Enable: Boolean);
  1753. BEGIN
  1754. Inherited SetState(AState, Enable); { Call ancestor }
  1755. If (AState AND sfFocused <> 0) Then Begin
  1756. SetDrawMask(vdFocus OR vdInner); { Set redraw masks }
  1757. DrawView; { Redraw masked areas }
  1758. End;
  1759. END;
  1760. {--TCluster-----------------------------------------------------------------}
  1761. { DrawMultiBox -> Platforms DOS/DPMI/WIN/NT - Updated 05Jun98 LdB }
  1762. {---------------------------------------------------------------------------}
  1763. PROCEDURE TCluster.DrawMultiBox (Const Icon, Marker: String);
  1764. VAR I, J, K, Cur, Col: Integer; CNorm, CSel, CDis, Color: Word; B: TDrawBuffer;
  1765. Tb, SCOff: Byte;
  1766. {$IFNDEF OS_DOS} S: String; P: PString; Q: PChar; {$ENDIF}
  1767. BEGIN
  1768. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  1769. CNorm := GetColor($0301); { Normal colour }
  1770. CSel := GetColor($0402); { Selected colour }
  1771. CDis := GetColor($0505); { Disabled colour }
  1772. If (Options AND ofFramed <>0) OR { Normal frame }
  1773. (GOptions AND goThickFramed <>0) Then { Thick frame }
  1774. K := 1 Else K := 0; { Select offset }
  1775. For I := 0 To Size.Y-K-K-1 Do Begin { For each line }
  1776. MoveChar(B, ' ', Byte(CNorm), Size.X-K-K); { Fill buffer }
  1777. For J := 0 To (Strings.Count - 1) DIV Size.Y + 1
  1778. Do Begin
  1779. Cur := J*Size.Y + I; { Current line }
  1780. If (Cur < Strings.Count) Then Begin
  1781. Col := Column(Cur); { Calc column }
  1782. If (Col + CStrLen(PString(Strings.At(Cur))^)+
  1783. 5 < Sizeof(TDrawBuffer) DIV SizeOf(Word))
  1784. AND (Col < Size.X-K-K) Then Begin { Text fits in column }
  1785. If NOT ButtonState(Cur) Then
  1786. Color := CDis Else If (Cur = Sel) AND { Disabled colour }
  1787. (State and sfFocused <> 0) Then
  1788. Color := CSel Else { Selected colour }
  1789. Color := CNorm; { Normal colour }
  1790. MoveChar(B[Col], ' ', Byte(Color),
  1791. Size.X-K-K-Col); { Set this colour }
  1792. MoveStr(B[Col], Icon, Byte(Color)); { Transfer icon string }
  1793. WordRec(B[Col+2]).Lo := Byte(Marker[
  1794. MultiMark(Cur) + 1]); { Transfer marker }
  1795. MoveCStr(B[Col+5], PString(Strings.At(
  1796. Cur))^, Color); { Transfer item string }
  1797. If ShowMarkers AND (State AND sfFocused <> 0)
  1798. AND (Cur = Sel) Then Begin { Current is selected }
  1799. WordRec(B[Col]).Lo := Byte(SpecialChars[0]);
  1800. WordRec(B[Column(Cur+Size.Y)-1]).Lo
  1801. := Byte(SpecialChars[1]); { Set special character }
  1802. End;
  1803. End;
  1804. End;
  1805. End;
  1806. WriteBuf(K, K+I, Size.X-K-K, 1, B); { Write buffer }
  1807. End;
  1808. {$ELSE} { WIN/NT/OS2 CODE }
  1809. If (WndHandles <> Nil) Then Begin { Valid window handles }
  1810. For I := 1 To Strings.Count Do Begin { For each window }
  1811. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1812. Tb := GetWindowText(WndHandles^[I-1], @S[1],
  1813. 255); { Get window text }
  1814. {$ELSE} { OS2 CODE }
  1815. Tb := WinQueryWindowText(WndHandles^[I-1], 255,
  1816. @S[1]); { Get window text }
  1817. {$ENDIF}
  1818. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  1819. SetLength(S, Tb); { Set string length }
  1820. {$ELSE} { OTHER COMPILERS }
  1821. S[0] := Chr(Tb); { Set string length }
  1822. {$ENDIF}
  1823. P := Strings.At(I-1); { Cluster strings }
  1824. If (P <> Nil) AND (P^ <> S) Then Begin { Something changed }
  1825. S := P^ + #0; { Transfer string }
  1826. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1827. SetWindowText(WndHandles^[I-1], @S[1]); { Set new window text }
  1828. {$ELSE} { OS2 CODE }
  1829. WinSetWindowText(WndHandles^[I-1], @S[1]); { Set new window text }
  1830. {$ENDIF}
  1831. End;
  1832. If Mark(I-1) Then { If item marked }
  1833. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  1834. SendMessage(WndHandles^[I-1], bm_SetCheck,
  1835. 1, 0) Else { Check the box }
  1836. SendMessage(WndHandles^[I-1], bm_SetCheck,
  1837. 0, 0); { Uncheck the box }
  1838. {$ELSE} { OS2 CODE }
  1839. WinSendMsg(WndHandles^[I-1], bm_SetCheck,
  1840. 1, 0) Else { Check the box }
  1841. WinSendMsg(WndHandles^[I-1], bm_SetCheck,
  1842. 0, 0); { Uncheck the box }
  1843. {$ENDIF}
  1844. End;
  1845. End;
  1846. {$ENDIF}
  1847. END;
  1848. {--TCluster-----------------------------------------------------------------}
  1849. { DrawBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1850. {---------------------------------------------------------------------------}
  1851. PROCEDURE TCluster.DrawBox (Const Icon: String; Marker: Char);
  1852. BEGIN
  1853. DrawMultiBox(Icon, ' '+Marker); { Call draw routine }
  1854. END;
  1855. {--TCluster-----------------------------------------------------------------}
  1856. { SetButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1857. {---------------------------------------------------------------------------}
  1858. PROCEDURE TCluster.SetButtonState (AMask: Longint; Enable: Boolean);
  1859. VAR I: Integer; M: Longint;
  1860. BEGIN
  1861. If Enable Then EnableMask := EnableMask OR AMask { Set enable bit mask }
  1862. Else EnableMask := EnableMask AND NOT AMask; { Disable bit mask }
  1863. If (Strings.Count <= 32) Then Begin { Valid string number }
  1864. M := 1; { Preset bit masks }
  1865. For I := 1 To Strings.Count Do Begin { For each item string }
  1866. If ((M AND EnableMask) <> 0) Then Begin { Bit enabled }
  1867. Options := Options OR ofSelectable; { Set selectable option }
  1868. Exit; { Now exit }
  1869. End;
  1870. M := M SHL 1; { Create newbit mask }
  1871. End;
  1872. Options := Options AND NOT ofSelectable; { Make not selectable }
  1873. End;
  1874. END;
  1875. {--TCluster-----------------------------------------------------------------}
  1876. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1877. {---------------------------------------------------------------------------}
  1878. PROCEDURE TCluster.GetData (Var Rec);
  1879. BEGIN
  1880. Word(Rec) := Value; { Return current value }
  1881. END;
  1882. {--TCluster-----------------------------------------------------------------}
  1883. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1884. {---------------------------------------------------------------------------}
  1885. PROCEDURE TCluster.SetData (Var Rec);
  1886. BEGIN
  1887. Value := Word(Rec); { Set current value }
  1888. SetDrawMask(vdFocus OR vdInner); { Set redraw mask }
  1889. DrawView; { Redraw masked areas }
  1890. END;
  1891. {--TCluster-----------------------------------------------------------------}
  1892. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1893. {---------------------------------------------------------------------------}
  1894. PROCEDURE TCluster.Store (Var S: TStream);
  1895. BEGIN
  1896. TView.Store(S); { TView.Store called }
  1897. If ((Options AND ofVersion) >= ofVersion20) { Version 2 TV view }
  1898. Then Begin
  1899. S.Write(Value, SizeOf(LongInt)); { Write value }
  1900. S.Write(Sel, SizeOf(Sel)); { Write select item }
  1901. S.Write(EnableMask, SizeOf(EnableMask)); { Write enable masks }
  1902. End Else Begin
  1903. S.Write(Value, SizeOf(Word)); { Write value }
  1904. S.Write(Sel, SizeOf(Sel)); { Write select item }
  1905. End;
  1906. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  1907. S.Write(Id, SizeOf(Id)); { Write new id value }
  1908. Strings.Store(S); { Store strings }
  1909. END;
  1910. {--TCluster-----------------------------------------------------------------}
  1911. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Jun98 LdB }
  1912. {---------------------------------------------------------------------------}
  1913. PROCEDURE TCluster.HandleEvent (Var Event: TEvent);
  1914. VAR C: Char; I, J, S, Vh: Integer; Key: Word; Mouse: TPoint; Ts: PString;
  1915. PROCEDURE MoveSel;
  1916. BEGIN
  1917. If (I <= Strings.Count) Then Begin
  1918. Sel := S; { Set selected item }
  1919. MovedTo(Sel); { Move to selected }
  1920. SetDrawMask(vdInner OR vdFocus); { Set draw masks }
  1921. DrawView; { Now draw changes }
  1922. End;
  1923. END;
  1924. BEGIN
  1925. Inherited HandleEvent(Event); { Call ancestor }
  1926. If ((Options AND ofSelectable) = 0) Then Exit; { Check selectable }
  1927. If (Event.What = evMouseDown) Then Begin { MOUSE EVENT }
  1928. MakeLocal(Event.Where, Mouse); { Make point local }
  1929. I := FindSel(Mouse); { Find selected item }
  1930. If (I <> -1) Then { Check in view }
  1931. If ButtonState(I) Then Sel := I; { If enabled select }
  1932. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  1933. DrawView; { Now draw changes }
  1934. Repeat
  1935. MakeLocal(Event.Where, Mouse); { Make point local }
  1936. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse up }
  1937. MakeLocal(Event.Where, Mouse); { Make point local }
  1938. If (FindSel(Mouse) = Sel) AND ButtonState(Sel) { If valid/selected }
  1939. Then Begin
  1940. Press(Sel); { Call pressed }
  1941. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  1942. DrawView; { Now draw changes }
  1943. End;
  1944. ClearEvent(Event); { Event was handled }
  1945. End Else If (Event.What = evKeyDown) Then Begin { KEY EVENT }
  1946. If (Options AND ofFramed <> 0) OR { Normal frame }
  1947. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  1948. J := 1 Else J := 0; { Adjust value }
  1949. Vh := Size.Y - J - J; { View height }
  1950. S := Sel; { Hold current item }
  1951. Key := CtrlToArrow(Event.KeyCode); { Convert keystroke }
  1952. Case Key Of
  1953. kbUp, kbDown, kbRight, kbLeft:
  1954. If (State AND sfFocused <> 0) Then Begin { Focused key event }
  1955. I := 0; { Zero process count }
  1956. Repeat
  1957. Inc(I); { Inc process count }
  1958. Case Key Of
  1959. kbUp: Dec(S); { Next item up }
  1960. kbDown: Inc(S); { Next item down }
  1961. kbRight: Begin { Next column across }
  1962. Inc(S, Vh); { Move to next column }
  1963. If (S >= Strings.Count) Then { No next column check }
  1964. S := (S+1) MOD Vh; { Move to last column }
  1965. End;
  1966. kbLeft: Begin { Prior column across }
  1967. Dec(S, Vh); { Move to prior column }
  1968. If (S < 0) Then S := ((Strings.Count +
  1969. Vh - 1) DIV Vh) * Vh + S - 1; { No prior column check }
  1970. End;
  1971. End;
  1972. If (S >= Strings.Count) Then S := 0; { Roll up to top }
  1973. If (S < 0) Then S := Strings.Count - 1; { Roll down to bottom }
  1974. Until ButtonState(S) OR (I > Strings.Count); { Repeat until select }
  1975. MoveSel; { Move to selected }
  1976. ClearEvent(Event); { Event was handled }
  1977. End;
  1978. Else Begin { Not an arrow key }
  1979. For I := 0 To Strings.Count-1 Do Begin { Scan each item }
  1980. Ts := Strings.At(I); { Fetch string pointer }
  1981. If (Ts <> Nil) Then C := HotKey(Ts^) { Check for hotkey }
  1982. Else C := #0; { No valid string }
  1983. If (GetAltCode(C) = Event.KeyCode) OR { Hot key for item }
  1984. (((Owner^.Phase = phPostProcess) OR { Owner in post process }
  1985. (State AND sfFocused <> 0)) AND (C <> #0) { Non zero hotkey }
  1986. AND (UpCase(Event.CharCode) = C)) { Matches current key }
  1987. Then Begin
  1988. If ButtonState(I) Then Begin { Check mask enabled }
  1989. If Focus Then Begin { Check view focus }
  1990. Sel := I; { Set selected }
  1991. MovedTo(Sel); { Move to selected }
  1992. Press(Sel); { Call pressed }
  1993. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  1994. DrawView; { Now draw changes }
  1995. End;
  1996. ClearEvent(Event); { Event was handled }
  1997. End;
  1998. Exit; { Now exit }
  1999. End;
  2000. End;
  2001. {$IFDEF OS_DOS} { DOS/DPMI CODE }
  2002. If (Event.CharCode = ' ') AND { Spacebar key }
  2003. (State AND sfFocused <> 0) AND { Check focused view }
  2004. ButtonState(Sel) Then Begin { Check item enabled }
  2005. Press(Sel); { Call pressed }
  2006. SetDrawMask(vdFocus OR vdInner); { Set draw mask }
  2007. DrawView; { Now draw changes }
  2008. ClearEvent(Event); { Event was handled }
  2009. End;
  2010. {$ENDIF}
  2011. End;
  2012. End;
  2013. End;
  2014. END;
  2015. {$IFNDEF NO_WINDOW} { WIN/NT/OS2 CODE }
  2016. {***************************************************************************}
  2017. { TCLuster OBJECT WIN/NT/OS2 ONLY METHODS }
  2018. {***************************************************************************}
  2019. {--TCluster-----------------------------------------------------------------}
  2020. { GetClassName -> Platforms WIN/NT/OS2 - Updated 03Jun98 LdB }
  2021. {---------------------------------------------------------------------------}
  2022. FUNCTION TCluster.GetClassName: String;
  2023. BEGIN
  2024. GetClassName := TvClusterClassName; { Cluster class name }
  2025. END;
  2026. {--TCluster-----------------------------------------------------------------}
  2027. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 02Jun98 LdB }
  2028. {---------------------------------------------------------------------------}
  2029. FUNCTION TCluster.SubClassAttr: LongInt;
  2030. VAR Li: LongInt;
  2031. BEGIN
  2032. If (State AND sfVisible = 0) Then Li := 0 { View not visible }
  2033. Else Li := ws_Visible; { View is visible }
  2034. If (State AND sfDisabled <> 0) Then { Check disabled flag }
  2035. Li := Li OR ws_Disabled; { Set disabled flag }
  2036. Li := Li OR ws_ClipChildren OR ws_ClipSiblings; { Must have these }
  2037. SubClassAttr := Li; { Return attributes }
  2038. END;
  2039. {--TCluster-----------------------------------------------------------------}
  2040. { GetMsgHandler -> Platforms WIN/NT/OS2 - Updated 02Jun98 LdB }
  2041. {---------------------------------------------------------------------------}
  2042. FUNCTION TCluster.GetMsgHandler: Pointer;
  2043. BEGIN
  2044. GetMsgHandler := @TvClusterMsgHandler; { Cluster msg handler }
  2045. END;
  2046. {--TCluster-----------------------------------------------------------------}
  2047. { CreateWindowNow -> Platforms WIN/NT - Updated 28May98 LdB }
  2048. {---------------------------------------------------------------------------}
  2049. PROCEDURE TCluster.CreateWindowNow (CmdShow: Integer);
  2050. VAR I, J, L: Integer; Li: LongInt; Ct: String; Ts: PString; P: PChar; Wnd: HWnd;
  2051. BEGIN
  2052. If (HWindow = 0) Then Begin { Window not created }
  2053. Inherited CreateWindowNow (CmdShow); { Call ancestor }
  2054. If (HWindow <> 0) Then Begin { Window now created }
  2055. GetMem(WndHandles, Strings.Count*SizeOf(HWnd));{ Allocate memory }
  2056. For I := 1 To Strings.Count Do Begin
  2057. L := (I-1) * FontHeight; { Height of each line }
  2058. Ts := Strings.At(I-1); { Fetch string pointer }
  2059. If (Ts <> Nil) Then Ct := Ts^ Else Ct := ''; { Get string text }
  2060. Ct := Ct + #0; { Make asciiz }
  2061. J := Pos('~', Ct); { Check for tilde }
  2062. If (J <> 0) Then Ct[J] := '&'; { Sub 1st tilde }
  2063. Repeat
  2064. J := Pos('~', Ct); { Check for tilde }
  2065. If (J <> 0) Then System.Delete(Ct, J, 1); { Remove the tilde }
  2066. Until (J = 0); { Remove all tildes }
  2067. If (Ct <> #0) Then Begin { Check for empty }
  2068. GetMem(P, Length(Ct)); { Allocate memory }
  2069. Move(Ct[1], P^, Length(Ct)); { Move string data }
  2070. End Else P := Nil; { Return nil ptr }
  2071. {$IFDEF OS_WINDOWS}
  2072. If (Options AND ofFramed <> 0) OR { Normal frame }
  2073. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2074. Wnd := CreateWindowEx(0, 'BUTTON', P,
  2075. SubClassAttr OR ws_Child OR ws_Visible, FontWidth,
  2076. L+FontHeight, RawSize.X-2*FontWidth+1,
  2077. FontHeight, HWindow, cmTvClusterButton,
  2078. HInstance, Nil) Else { Create window }
  2079. Wnd := CreateWindowEx(0, 'BUTTON', P,
  2080. SubClassAttr OR ws_Child OR ws_Visible, 0, L,
  2081. RawSize.X+1, FontHeight, HWindow,
  2082. cmTvClusterButton, HInstance, Nil); { Create window }
  2083. If (Wnd <> 0) Then Begin { Window created ok }
  2084. {$IFDEF PPC_FPC}
  2085. Windows.SendMessage(Wnd, WM_SetFont,
  2086. DefGFVFont, 1); { Set font style }
  2087. {$ELSE}
  2088. WinProcs.SendMessage(Wnd, WM_SetFont,
  2089. DefGFVFont, 1); { Set font style }
  2090. {$ENDIF}
  2091. Li := LongInt(@Self); { Address of self }
  2092. {$IFDEF BIT_16} { 16 BIT CODE }
  2093. SetProp(Wnd, ViewSeg,
  2094. Li AND $FFFF0000 SHR 16); { Set seg property }
  2095. SetProp(Wnd, ViewOfs,
  2096. Li AND $0000FFFF); { Set ofs propertry }
  2097. {$ENDIF}
  2098. {$IFDEF BIT_32} { 32 BIT CODE }
  2099. SetProp(Wnd, ViewPtr, Li); { Set view property }
  2100. {$ENDIF}
  2101. If (CmdShow <> 0) Then
  2102. ShowWindow(Wnd, cmdShow); { Execute show cmd }
  2103. UpdateWindow(Wnd); { Update the window }
  2104. BringWindowToTop(Wnd); { Bring window to top }
  2105. End;
  2106. WndHandles^[I-1] := Wnd; { Hold the handle }
  2107. If Mark(I-1) Then { If item marked }
  2108. SendMessage(WndHandles^[I-1], bm_SetCheck,
  2109. 1, 0) Else { Check the item }
  2110. SendMessage(WndHandles^[I-1], bm_SetCheck,
  2111. 0, 0); { Uncheck the item }
  2112. {$ENDIF}
  2113. End;
  2114. End;
  2115. End;
  2116. END;
  2117. {$ENDIF}
  2118. {***************************************************************************}
  2119. { TCluster OBJECT PRIVATE METHODS }
  2120. {***************************************************************************}
  2121. {--TCluster-----------------------------------------------------------------}
  2122. { FindSel -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2123. {---------------------------------------------------------------------------}
  2124. FUNCTION TCluster.FindSel (P: TPoint): Integer;
  2125. VAR I, J, S, Vh: Integer; R: TRect;
  2126. BEGIN
  2127. GetExtent(R); { Get view extents }
  2128. If R.Contains(P) Then Begin { Point in view }
  2129. If (Options AND ofFramed <> 0) OR { Normal frame }
  2130. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2131. J := 1 Else J := 0; { Adjust value }
  2132. Vh := Size.Y - J - J; { View height }
  2133. I := 0; { Preset zero value }
  2134. While (P.X >= Column(I+Vh)) Do Inc(I, Vh); { Inc view size }
  2135. S := I + P.Y - J; { Line to select }
  2136. If ((S >= 0) AND (S < Strings.Count)) { Valid selection }
  2137. Then FindSel := S Else FindSel := -1; { Return selected item }
  2138. End Else FindSel := -1; { Point outside view }
  2139. END;
  2140. {--TCluster-----------------------------------------------------------------}
  2141. { Row -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2142. {---------------------------------------------------------------------------}
  2143. FUNCTION TCluster.Row (Item: Integer): Integer;
  2144. BEGIN
  2145. If (Options AND ofFramed <> 0) OR { Normal frame }
  2146. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2147. Row := Item MOD (Size.Y - 2) Else { Allow for frames }
  2148. Row := Item MOD Size.Y; { Normal mod value }
  2149. END;
  2150. {--TCluster-----------------------------------------------------------------}
  2151. { Column -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2152. {---------------------------------------------------------------------------}
  2153. FUNCTION TCluster.Column (Item: Integer): Integer;
  2154. VAR I, J, Col, Width, L, Vh: Integer; Ts: PString;
  2155. BEGIN
  2156. If (Options AND ofFramed <> 0) OR { Normal frame }
  2157. (GOptions AND goThickFramed <> 0) Then { Thick frame }
  2158. J := 1 Else J := 0; { Adjust value }
  2159. Vh := Size.Y - J - J; { Vertical size }
  2160. If (Item >= Vh) Then Begin { Valid selection }
  2161. Width := 0; { Zero width }
  2162. Col := -6; { Start column at -6 }
  2163. For I := 0 To Item Do Begin { For each item }
  2164. If (I MOD Vh = 0) Then Begin { Start next column }
  2165. Inc(Col, Width + 6); { Add column width }
  2166. Width := 0; { Zero width }
  2167. End;
  2168. If (I < Strings.Count) Then Begin { Valid string }
  2169. Ts := Strings.At(I); { Transfer string }
  2170. If (Ts <> Nil) Then L := CStrLen(Ts^) { Length of string }
  2171. Else L := 0; { No string }
  2172. End;
  2173. If (L > Width) Then Width := L; { Hold longest string }
  2174. End;
  2175. Column := Col; { Return column }
  2176. End Else Column := 0; { Outside select area }
  2177. END;
  2178. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2179. { TRadioButtons OBJECT METHODS }
  2180. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2181. {--TRadioButtons------------------------------------------------------------}
  2182. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2183. {---------------------------------------------------------------------------}
  2184. FUNCTION TRadioButtons.Mark (Item: Integer): Boolean;
  2185. BEGIN
  2186. Mark := Item = Value; { True if item = value }
  2187. END;
  2188. {--TRadioButtons------------------------------------------------------------}
  2189. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2190. {---------------------------------------------------------------------------}
  2191. PROCEDURE TRadioButtons.DrawFocus;
  2192. CONST Button = ' ( ) ';
  2193. BEGIN
  2194. Inherited DrawFocus;
  2195. DrawMultiBox(Button, #32#7); { Redraw the text }
  2196. END;
  2197. {--TRadioButtons------------------------------------------------------------}
  2198. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2199. {---------------------------------------------------------------------------}
  2200. PROCEDURE TRadioButtons.Press (Item: Integer);
  2201. BEGIN
  2202. Value := Item; { Set value field }
  2203. Inherited Press(Item); { Call ancestor }
  2204. END;
  2205. {--TRadioButtons------------------------------------------------------------}
  2206. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2207. {---------------------------------------------------------------------------}
  2208. PROCEDURE TRadioButtons.MovedTo (Item: Integer);
  2209. BEGIN
  2210. Value := Item; { Set value to item }
  2211. If (Id <> 0) Then NewMessage(Owner, evCommand,
  2212. cmIdCommunicate, Id, Value, @Self); { Send new message }
  2213. END;
  2214. {--TRadioButtons------------------------------------------------------------}
  2215. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2216. {---------------------------------------------------------------------------}
  2217. PROCEDURE TRadioButtons.SetData (Var Rec);
  2218. BEGIN
  2219. Sel := Integer(Rec); { Set selection }
  2220. Inherited SetData(Rec); { Call ancestor }
  2221. END;
  2222. {$IFNDEF NO_WINDOW} { WIN/NT CODE }
  2223. {***************************************************************************}
  2224. { TRadioButtons OBJECT WIN/NT/OS2 ONLY METHODS }
  2225. {***************************************************************************}
  2226. {--TRadioButtons------------------------------------------------------------}
  2227. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 20May98 LdB }
  2228. {---------------------------------------------------------------------------}
  2229. FUNCTION TRadioButtons.SubClassAttr: LongInt;
  2230. BEGIN
  2231. SubClassAttr := Inherited SubClassAttr OR
  2232. bs_RadioButton; { Radio button }
  2233. END;
  2234. {$ENDIF}
  2235. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2236. { TCheckBoxes OBJECT METHODS }
  2237. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2238. {--TCheckBoxes--------------------------------------------------------------}
  2239. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2240. {---------------------------------------------------------------------------}
  2241. FUNCTION TCheckBoxes.Mark(Item: Integer): Boolean;
  2242. BEGIN
  2243. If (Value AND (1 SHL Item) <> 0) Then { Check if item ticked }
  2244. Mark := True Else Mark := False; { Return result }
  2245. END;
  2246. {--TCheckBoxes--------------------------------------------------------------}
  2247. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2248. {---------------------------------------------------------------------------}
  2249. PROCEDURE TCheckBoxes.DrawFocus;
  2250. CONST Button = ' [ ] ';
  2251. BEGIN
  2252. Inherited DrawFocus;
  2253. DrawMultiBox(Button, ' X'); { Redraw the text }
  2254. END;
  2255. {--TCheckBoxes--------------------------------------------------------------}
  2256. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2257. {---------------------------------------------------------------------------}
  2258. PROCEDURE TCheckBoxes.Press (Item: Integer);
  2259. BEGIN
  2260. Value := Value XOR (1 SHL Item); { Flip the item mask }
  2261. Inherited Press(Item); { Call ancestor }
  2262. END;
  2263. {$IFNDEF NO_WINDOW} { WIN/NT/OS2 CODE }
  2264. {***************************************************************************}
  2265. { TCheckBoxes OBJECT WIN/NT/OS2 ONLY METHODS }
  2266. {***************************************************************************}
  2267. {--TCheckBoxes--------------------------------------------------------------}
  2268. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 20May98 LdB }
  2269. {---------------------------------------------------------------------------}
  2270. FUNCTION TCheckBoxes.SubClassAttr: LongInt;
  2271. BEGIN
  2272. SubClassAttr := Inherited SubClassAttr OR
  2273. bs_CheckBox; { Check box buttons }
  2274. END;
  2275. {$ENDIF}
  2276. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2277. { TMultiCheckBoxes OBJECT METHODS }
  2278. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2279. {--TMultiCheckBoxes---------------------------------------------------------}
  2280. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Jun98 LdB }
  2281. {---------------------------------------------------------------------------}
  2282. CONSTRUCTOR TMultiCheckBoxes.Init (Var Bounds: TRect; AStrings: PSItem;
  2283. ASelRange: Byte; AFlags: Word; Const AStates: String);
  2284. BEGIN
  2285. Inherited Init(Bounds, AStrings); { Call ancestor }
  2286. SelRange := ASelRange; { Hold select range }
  2287. Flags := AFlags; { Hold flags }
  2288. States := NewStr(AStates); { Hold string }
  2289. END;
  2290. {--TMultiCheckBoxes---------------------------------------------------------}
  2291. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2292. {---------------------------------------------------------------------------}
  2293. CONSTRUCTOR TMultiCheckBoxes.Load (Var S: TStream);
  2294. BEGIN
  2295. Inherited Load(S); { Call ancestor }
  2296. S.Read(SelRange, SizeOf(SelRange)); { Read select range }
  2297. S.Read(Flags, SizeOf(Flags)); { Read flags }
  2298. States := S.ReadStr; { Read strings }
  2299. END;
  2300. {--TMultiCheckBoxes---------------------------------------------------------}
  2301. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2302. {---------------------------------------------------------------------------}
  2303. DESTRUCTOR TMultiCheckBoxes.Done;
  2304. BEGIN
  2305. If (States <> Nil) Then DisposeStr(States); { Dispose strings }
  2306. Inherited Done; { Call ancestor }
  2307. END;
  2308. {--TMultiCheckBoxes---------------------------------------------------------}
  2309. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2310. {---------------------------------------------------------------------------}
  2311. FUNCTION TMultiCheckBoxes.DataSize: Word;
  2312. BEGIN
  2313. DataSize := SizeOf(LongInt); { Size to exchange }
  2314. END;
  2315. {--TMultiCheckBoxes---------------------------------------------------------}
  2316. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2317. {---------------------------------------------------------------------------}
  2318. FUNCTION TMultiCheckBoxes.MultiMark (Item: Integer): Byte;
  2319. BEGIN
  2320. MultiMark := (Value SHR (Word(Item) *
  2321. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Return mark state }
  2322. END;
  2323. {--TMultiCheckBoxes---------------------------------------------------------}
  2324. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2325. {---------------------------------------------------------------------------}
  2326. PROCEDURE TMultiCheckBoxes.DrawFocus;
  2327. CONST Button = ' [ ] ';
  2328. BEGIN
  2329. Inherited DrawFocus;
  2330. DrawMultiBox(Button, States^); { Draw the items }
  2331. END;
  2332. {--TMultiCheckBoxes---------------------------------------------------------}
  2333. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2334. {---------------------------------------------------------------------------}
  2335. PROCEDURE TMultiCheckBoxes.Press (Item: Integer);
  2336. VAR CurState: ShortInt;
  2337. BEGIN
  2338. CurState := (Value SHR (Word(Item) *
  2339. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Hold current state }
  2340. Dec(CurState); { One down }
  2341. If (CurState >= SelRange) OR (CurState < 0) Then
  2342. CurState := SelRange - 1; { Roll if needed }
  2343. Value := (Value AND NOT (LongInt(WordRec(Flags).Lo)
  2344. SHL (Word(Item) * WordRec(Flags).Hi))) OR
  2345. (LongInt(CurState) SHL (Word(Item) *
  2346. WordRec(Flags).Hi)); { Calculate value }
  2347. Inherited Press(Item); { Call ancestor }
  2348. END;
  2349. {--TMultiCheckBoxes---------------------------------------------------------}
  2350. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2351. {---------------------------------------------------------------------------}
  2352. PROCEDURE TMultiCheckBoxes.GetData (Var Rec);
  2353. BEGIN
  2354. Longint(Rec) := Value; { Return value }
  2355. END;
  2356. {--TMultiCheckBoxes---------------------------------------------------------}
  2357. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2358. {---------------------------------------------------------------------------}
  2359. PROCEDURE TMultiCheckBoxes.SetData (Var Rec);
  2360. BEGIN
  2361. Value := Longint(Rec); { Set value }
  2362. SetDrawMask(vdFocus OR vdInner); { Set redraw mask }
  2363. DrawView; { Redraw masked areas }
  2364. END;
  2365. {--TMultiCheckBoxes---------------------------------------------------------}
  2366. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2367. {---------------------------------------------------------------------------}
  2368. PROCEDURE TMultiCheckBoxes.Store (Var S: TStream);
  2369. BEGIN
  2370. TCluster.Store(S); { TCluster store called }
  2371. S.Write(SelRange, SizeOf(SelRange)); { Write select range }
  2372. S.Write(Flags, SizeOf(Flags)); { Write select flags }
  2373. S.WriteStr(States); { Write strings }
  2374. END;
  2375. {$IFNDEF NO_WINDOW} { WIN/NT/OS2 CODE }
  2376. {***************************************************************************}
  2377. { TMultiCheckBoxes OBJECT WIN/NT/OS2 ONLY METHODS }
  2378. {***************************************************************************}
  2379. {--TMultiCheckBoxes---------------------------------------------------------}
  2380. { SubClassAttr -> Platforms WIN/NT/OS2 - Updated 06Jun98 LdB }
  2381. {---------------------------------------------------------------------------}
  2382. FUNCTION TMultiCheckBoxes.SubClassAttr: LongInt;
  2383. BEGIN
  2384. SubClassAttr := Inherited SubClassAttr OR
  2385. bs_CheckBox; { Check box buttons }
  2386. END;
  2387. {$ENDIF}
  2388. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2389. { TListBox OBJECT METHODS }
  2390. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2391. TYPE
  2392. TListBoxRec = PACKED RECORD
  2393. List: PCollection; { List collection ptr }
  2394. Selection: Word; { Selected item }
  2395. END;
  2396. {--TListBox-----------------------------------------------------------------}
  2397. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2398. {---------------------------------------------------------------------------}
  2399. CONSTRUCTOR TListBox.Init (Var Bounds: TRect; ANumCols: Word;
  2400. AScrollBar: PScrollBar);
  2401. BEGIN
  2402. Inherited Init(Bounds, ANumCols, Nil, AScrollBar); { Call ancestor }
  2403. SetRange(0); { Set range to zero }
  2404. END;
  2405. {--TListBox-----------------------------------------------------------------}
  2406. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2407. {---------------------------------------------------------------------------}
  2408. CONSTRUCTOR TListBox.Load (Var S: TStream);
  2409. BEGIN
  2410. Inherited Load(S); { Call ancestor }
  2411. List := PCollection(S.Get); { Fetch collection }
  2412. END;
  2413. {--TListBox-----------------------------------------------------------------}
  2414. { DataSize -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 06Jun98 LdB }
  2415. {---------------------------------------------------------------------------}
  2416. FUNCTION TListBox.DataSize: Word;
  2417. BEGIN
  2418. DataSize := SizeOf(TListBoxRec); { Xchg data size }
  2419. END;
  2420. {--TListBox-----------------------------------------------------------------}
  2421. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2422. {---------------------------------------------------------------------------}
  2423. FUNCTION TListBox.GetText (Item: Integer; MaxLen: Integer): String;
  2424. VAR P: PString;
  2425. BEGIN
  2426. GetText := ''; { Preset return }
  2427. If (List <> Nil) Then Begin { A list exists }
  2428. P := PString(List^.At(Item)); { Get string ptr }
  2429. If (P <> Nil) Then GetText := P^; { Return string }
  2430. End;
  2431. END;
  2432. {--TListBox-----------------------------------------------------------------}
  2433. { NewList -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2434. {---------------------------------------------------------------------------}
  2435. PROCEDURE TListBox.NewList (AList: PCollection);
  2436. {$IFDEF OS_WINDOWS} VAR I: Integer; S: String; P: PString; {$ENDIF}
  2437. BEGIN
  2438. If (List <> Nil) Then Dispose(List, Done); { Dispose old list }
  2439. List := AList; { Hold new list }
  2440. If (AList <> Nil) Then SetRange(AList^.Count) { Set new item range }
  2441. Else SetRange(0); { Set zero range }
  2442. If (Range > 0) Then FocusItem(0); { Focus first item }
  2443. DrawView; { Redraw all view }
  2444. END;
  2445. {--TListBox-----------------------------------------------------------------}
  2446. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2447. {---------------------------------------------------------------------------}
  2448. PROCEDURE TListBox.GetData (Var Rec);
  2449. BEGIN
  2450. TListBoxRec(Rec).List := List; { Return current list }
  2451. TListBoxRec(Rec).Selection := Focused; { Return focused item }
  2452. END;
  2453. {--TListBox-----------------------------------------------------------------}
  2454. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2455. {---------------------------------------------------------------------------}
  2456. PROCEDURE TListBox.SetData (Var Rec);
  2457. BEGIN
  2458. NewList(TListBoxRec(Rec).List); { Hold new list }
  2459. FocusItem(TListBoxRec(Rec).Selection); { Focus selected item }
  2460. DrawView; { Redraw all view }
  2461. END;
  2462. {--TListBox-----------------------------------------------------------------}
  2463. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2464. {---------------------------------------------------------------------------}
  2465. PROCEDURE TListBox.Store (Var S: TStream);
  2466. BEGIN
  2467. TListViewer.Store(S); { TListViewer store }
  2468. S.Put(List); { Store list to stream }
  2469. END;
  2470. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2471. { TStaticText OBJECT METHODS }
  2472. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2473. {--TStaticText--------------------------------------------------------------}
  2474. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2475. {---------------------------------------------------------------------------}
  2476. CONSTRUCTOR TStaticText.Init (Var Bounds: TRect; Const AText: String);
  2477. BEGIN
  2478. Inherited Init(Bounds); { Call ancestor }
  2479. Text := NewStr(AText); { Create string ptr }
  2480. END;
  2481. {--TStaticText--------------------------------------------------------------}
  2482. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2483. {---------------------------------------------------------------------------}
  2484. CONSTRUCTOR TStaticText.Load (Var S: TStream);
  2485. BEGIN
  2486. Inherited Load(S); { Call ancestor }
  2487. Text := S.ReadStr; { Read text string }
  2488. END;
  2489. {--TStaticText--------------------------------------------------------------}
  2490. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2491. {---------------------------------------------------------------------------}
  2492. DESTRUCTOR TStaticText.Done;
  2493. BEGIN
  2494. If (Text <> Nil) Then DisposeStr(Text); { Dispose string }
  2495. Inherited Done; { Call ancestor }
  2496. END;
  2497. {--TStaticText--------------------------------------------------------------}
  2498. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2499. {---------------------------------------------------------------------------}
  2500. FUNCTION TStaticText.GetPalette: PPalette;
  2501. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2502. CONST P: String = CStaticText; { Possible huge string }
  2503. {$ELSE} { OTHER COMPILERS }
  2504. CONST P: String[Length(CStaticText)] = CStaticText; { Always normal string }
  2505. {$ENDIF}
  2506. BEGIN
  2507. GetPalette := @P; { Return palette }
  2508. END;
  2509. {--TStaticText--------------------------------------------------------------}
  2510. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2511. {---------------------------------------------------------------------------}
  2512. PROCEDURE TStaticText.DrawBackGround;
  2513. VAR Just: Byte; I, J, P, Y, L: Integer; S, T: String;
  2514. BEGIN
  2515. Inherited DrawBackGround; { Call ancestor }
  2516. GetText(S); { Fetch text to write }
  2517. P := 1; { X start position }
  2518. Y := 0; { Y start position }
  2519. L := Length(S); { Length of text }
  2520. While (Y < Size.Y) AND (P <= L) Do Begin
  2521. Just := 0; { Default left justify }
  2522. If (S[P] = #2) Then Begin { Right justify char }
  2523. Just := 2; { Set right justify }
  2524. Inc(P); { Next character }
  2525. End;
  2526. If (S[P] = #3) Then Begin { Centre justify char }
  2527. Just := 1; { Set centre justify }
  2528. Inc(P); { Next character }
  2529. End;
  2530. I := P; { Start position }
  2531. While (P <= L) AND (S[P] <> #13) Do Inc(P); { Scan for end }
  2532. T := Copy(S, I, P-I); { String to write }
  2533. Case Just Of
  2534. 0: J := 0; { Left justify }
  2535. 1: J := (RawSize.X - TextWidth(T)) DIV 2; { Centre justify }
  2536. 2: J := RawSize.X - TextWidth(T); { Right justify }
  2537. End;
  2538. While (J < 0) Do Begin { Text to long }
  2539. J := J + TextWidth(T[1]); { Add width to J }
  2540. Delete(T, 1, 1); { Delete the char }
  2541. End;
  2542. WriteStr(-J, -(Y*FontHeight), T, 1); { Write the text }
  2543. While (P <= L) AND ((S[P] = #13) OR (S[P] = #10))
  2544. Do Inc(P); { Remove CR/LF }
  2545. Inc(Y); { Next line }
  2546. End;
  2547. END;
  2548. {--TStaticText--------------------------------------------------------------}
  2549. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2550. {---------------------------------------------------------------------------}
  2551. PROCEDURE TStaticText.Store (Var S: TStream);
  2552. BEGIN
  2553. TView.Store(S); { Call TView store }
  2554. S.WriteStr(Text); { Write text string }
  2555. END;
  2556. {--TStaticText--------------------------------------------------------------}
  2557. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2558. {---------------------------------------------------------------------------}
  2559. PROCEDURE TStaticText.GetText (Var S: String);
  2560. BEGIN
  2561. If (Text <> Nil) Then S := Text^ { Copy text string }
  2562. Else S := ''; { Return empty string }
  2563. END;
  2564. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2565. { TParamText OBJECT METHODS }
  2566. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2567. {--TParamText---------------------------------------------------------------}
  2568. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2569. {---------------------------------------------------------------------------}
  2570. CONSTRUCTOR TParamText.Init (Var Bounds: TRect; Const AText: String;
  2571. AParamCount: Integer);
  2572. BEGIN
  2573. Inherited Init(Bounds, AText); { Call ancestor }
  2574. ParamCount := AParamCount; { Hold param count }
  2575. END;
  2576. {--TParamText---------------------------------------------------------------}
  2577. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2578. {---------------------------------------------------------------------------}
  2579. CONSTRUCTOR TParamText.Load (Var S: TStream);
  2580. BEGIN
  2581. Inherited Load(S); { Call ancestor }
  2582. S.Read(ParamCount, 2); { Read parameter count }
  2583. END;
  2584. {--TParamText---------------------------------------------------------------}
  2585. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2586. {---------------------------------------------------------------------------}
  2587. FUNCTION TParamText.DataSize: Word;
  2588. BEGIN
  2589. DataSize := ParamCount * SizeOf(Pointer); { Return data size }
  2590. END;
  2591. {--TParamText---------------------------------------------------------------}
  2592. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2593. {---------------------------------------------------------------------------}
  2594. PROCEDURE TParamText.GetData (Var Rec);
  2595. BEGIN
  2596. Pointer(Rec) := @ParamList; { Return parm ptr }
  2597. END;
  2598. {--TParamText---------------------------------------------------------------}
  2599. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2600. {---------------------------------------------------------------------------}
  2601. PROCEDURE TParamText.SetData (Var Rec);
  2602. BEGIN
  2603. ParamList := @Rec; { Fetch parameter list }
  2604. DrawView; { Redraw all the view }
  2605. END;
  2606. {--TParamText---------------------------------------------------------------}
  2607. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2608. {---------------------------------------------------------------------------}
  2609. PROCEDURE TParamText.Store (Var S: TStream);
  2610. BEGIN
  2611. TStaticText.Store(S); { Statictext store }
  2612. S.Write(ParamCount, 2); { Store param count }
  2613. END;
  2614. {--TParamText---------------------------------------------------------------}
  2615. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2616. {---------------------------------------------------------------------------}
  2617. PROCEDURE TParamText.GetText (Var S: String);
  2618. BEGIN
  2619. If (Text = Nil) Then S := '' Else { Return empty string }
  2620. FormatStr(S, Text^, ParamList^); { Return text string }
  2621. END;
  2622. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2623. { TLabel OBJECT METHODS }
  2624. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2625. {--TLabel-------------------------------------------------------------------}
  2626. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2627. {---------------------------------------------------------------------------}
  2628. CONSTRUCTOR TLabel.Init (Var Bounds: TRect; CONST AText: String; ALink: PView);
  2629. BEGIN
  2630. Inherited Init(Bounds, AText); { Call ancestor }
  2631. Link := ALink; { Hold link }
  2632. Options := Options OR (ofPreProcess+ofPostProcess);{ Set pre/post process }
  2633. EventMask := EventMask OR evBroadcast; { Sees broadcast events }
  2634. END;
  2635. {--TLabel-------------------------------------------------------------------}
  2636. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2637. {---------------------------------------------------------------------------}
  2638. CONSTRUCTOR TLabel.Load (Var S: TStream);
  2639. BEGIN
  2640. Inherited Load(S); { Call ancestor }
  2641. GetPeerViewPtr(S, Link); { Load link view }
  2642. END;
  2643. {--TLabel-------------------------------------------------------------------}
  2644. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2645. {---------------------------------------------------------------------------}
  2646. FUNCTION TLabel.GetPalette: PPalette;
  2647. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2648. CONST P: String = CLabel; { Possible huge string }
  2649. {$ELSE} { OTHER COMPILERS }
  2650. CONST P: String[Length(CLabel)] = CLabel; { Always normal string }
  2651. {$ENDIF}
  2652. BEGIN
  2653. GetPalette := @P; { Return palette }
  2654. END;
  2655. {--TLabel-------------------------------------------------------------------}
  2656. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2657. {---------------------------------------------------------------------------}
  2658. PROCEDURE TLabel.DrawBackGround;
  2659. VAR SCOff: Byte; Color: Word; B: TDrawBuffer;
  2660. BEGIN
  2661. TView.DrawBackGround; { Explict call to TView }
  2662. If Light Then Begin { Light colour select }
  2663. Color := GetColor($0402); { Choose light colour }
  2664. SCOff := 0; { Zero offset }
  2665. End Else Begin
  2666. Color := GetColor($0301); { Darker colour }
  2667. SCOff := 4; { Set offset }
  2668. End;
  2669. MoveChar(B[0], ' ', Byte(Color), Size.X); { Clear the buffer }
  2670. If (Text <> Nil) Then MoveCStr(B[1], Text^, Color);{ Transfer label text }
  2671. If ShowMarkers Then WordRec(B[0]).Lo := Byte(
  2672. SpecialChars[SCOff]); { Show marker if req }
  2673. WriteLine(0, 0, Size.X, 1, B); { Write the text }
  2674. END;
  2675. {--TLabel-------------------------------------------------------------------}
  2676. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2677. {---------------------------------------------------------------------------}
  2678. PROCEDURE TLabel.Store (Var S: TStream);
  2679. BEGIN
  2680. TStaticText.Store(S); { TStaticText.Store }
  2681. PutPeerViewPtr(S, Link); { Store link view }
  2682. END;
  2683. {--TLabel-------------------------------------------------------------------}
  2684. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2685. {---------------------------------------------------------------------------}
  2686. PROCEDURE TLabel.HandleEvent (Var Event: TEvent);
  2687. VAR C: Char;
  2688. PROCEDURE FocusLink;
  2689. BEGIN
  2690. If (Link <> Nil) AND (Link^.Options AND
  2691. ofSelectable <> 0) Then Link^.Focus; { Focus link view }
  2692. ClearEvent(Event); { Clear the event }
  2693. END;
  2694. BEGIN
  2695. Inherited HandleEvent(Event); { Call ancestor }
  2696. Case Event.What Of
  2697. evNothing: Exit; { Speed up exit }
  2698. evMouseDown: FocusLink; { Focus link view }
  2699. evKeyDown: Begin
  2700. C := HotKey(Text^); { Check for hotkey }
  2701. If (GetAltCode(C) = Event.KeyCode) OR { Alt plus char }
  2702. ((C <> #0) AND (Owner^.Phase = phPostProcess) { Post process phase }
  2703. AND (UpCase(Event.CharCode) = C)) Then { Upper case match }
  2704. FocusLink; { Focus link view }
  2705. End;
  2706. evBroadcast: If ((Event.Command = cmReceivedFocus)
  2707. OR (Event.Command = cmReleasedFocus)) AND { Focus state change }
  2708. (Link <> Nil) Then Begin
  2709. Light := Link^.State AND sfFocused <> 0; { Change light state }
  2710. DrawView; { Now redraw change }
  2711. End;
  2712. End;
  2713. END;
  2714. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2715. { THistoryViewer OBJECT METHODS }
  2716. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2717. {--THistoryViewer-----------------------------------------------------------}
  2718. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2719. {---------------------------------------------------------------------------}
  2720. CONSTRUCTOR THistoryViewer.Init (Var Bounds: TRect; AHScrollBar,
  2721. AVScrollBar: PScrollBar; AHistoryId: Word);
  2722. BEGIN
  2723. Inherited Init(Bounds, 1, AHScrollBar,
  2724. AVScrollBar); { Call ancestor }
  2725. HistoryId := AHistoryId; { Hold history id }
  2726. SetRange(HistoryCount(AHistoryId)); { Set history range }
  2727. If (Range > 1) Then FocusItem(1); { Set to item 1 }
  2728. If (HScrollBar <> Nil) Then
  2729. HScrollBar^.SetRange(1, HistoryWidth-Size.X + 3);{ Set scrollbar range }
  2730. END;
  2731. {--THistoryViewer-----------------------------------------------------------}
  2732. { HistoryWidth -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2733. {---------------------------------------------------------------------------}
  2734. FUNCTION THistoryViewer.HistoryWidth: Integer;
  2735. VAR Width, T, Count, I: Integer;
  2736. BEGIN
  2737. Width := 0; { Zero width variable }
  2738. Count := HistoryCount(HistoryId); { Hold count value }
  2739. For I := 0 To Count-1 Do Begin { For each item }
  2740. T := Length(HistoryStr(HistoryId, I)); { Get width of item }
  2741. If (T > Width) Then Width := T; { Set width to max }
  2742. End;
  2743. HistoryWidth := Width; { Return max item width }
  2744. END;
  2745. {--THistoryViewer-----------------------------------------------------------}
  2746. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2747. {---------------------------------------------------------------------------}
  2748. FUNCTION THistoryViewer.GetPalette: PPalette;
  2749. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2750. CONST P: String = CHistoryViewer; { Possible huge string }
  2751. {$ELSE} { OTHER COMPILERS }
  2752. CONST P: String[Length(CHistoryViewer)] = CHistoryViewer;{ Always normal string }
  2753. {$ENDIF}
  2754. BEGIN
  2755. GetPalette := @P; { Return palette }
  2756. END;
  2757. {--THistoryViewer-----------------------------------------------------------}
  2758. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2759. {---------------------------------------------------------------------------}
  2760. FUNCTION THistoryViewer.GetText (Item: Integer; MaxLen: Integer): String;
  2761. BEGIN
  2762. GetText := HistoryStr(HistoryId, Item); { Return history string }
  2763. END;
  2764. {--THistoryViewer-----------------------------------------------------------}
  2765. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2766. {---------------------------------------------------------------------------}
  2767. PROCEDURE THistoryViewer.HandleEvent (Var Event: TEvent);
  2768. BEGIN
  2769. If ((Event.What = evMouseDown) AND (Event.Double)) { Double click mouse }
  2770. OR ((Event.What = evKeyDown) AND
  2771. (Event.KeyCode = kbEnter)) Then Begin { Enter key press }
  2772. EndModal(cmOk); { End with cmOk }
  2773. ClearEvent(Event); { Event was handled }
  2774. End Else If ((Event.What = evKeyDown) AND
  2775. (Event.KeyCode = kbEsc)) OR { Esc key press }
  2776. ((Event.What = evCommand) AND
  2777. (Event.Command = cmCancel)) Then Begin { Cancel command }
  2778. EndModal(cmCancel); { End with cmCancel }
  2779. ClearEvent(Event); { Event was handled }
  2780. End Else Inherited HandleEvent(Event); { Call ancestor }
  2781. END;
  2782. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2783. { THistoryWindow OBJECT METHODS }
  2784. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2785. {--THistoryWindow-----------------------------------------------------------}
  2786. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2787. {---------------------------------------------------------------------------}
  2788. CONSTRUCTOR THistoryWindow.Init (Var Bounds: TRect; HistoryId: Word);
  2789. BEGIN
  2790. Inherited Init(Bounds, '', wnNoNumber); { Call ancestor }
  2791. Flags := wfClose; { Close flag only }
  2792. InitViewer(HistoryId); { Create list view }
  2793. END;
  2794. {--THistoryWindow-----------------------------------------------------------}
  2795. { GetSelection -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2796. {---------------------------------------------------------------------------}
  2797. FUNCTION THistoryWindow.GetSelection: String;
  2798. BEGIN
  2799. If (Viewer = Nil) Then GetSelection := '' Else { Return empty string }
  2800. GetSelection := Viewer^.GetText(Viewer^.Focused,
  2801. 255); { Get focused string }
  2802. END;
  2803. {--THistoryWindow-----------------------------------------------------------}
  2804. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2805. {---------------------------------------------------------------------------}
  2806. FUNCTION THistoryWindow.GetPalette: PPalette;
  2807. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2808. CONST P: String = CHistoryWindow; { Possible huge string }
  2809. {$ELSE} { OTHER COMPILERS }
  2810. CONST P: String[Length(CHistoryWindow)] = CHistoryWindow;{ Always normal string }
  2811. {$ENDIF}
  2812. BEGIN
  2813. GetPalette := @P; { Return the palette }
  2814. END;
  2815. {--THistoryWindow-----------------------------------------------------------}
  2816. { InitViewer -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2817. {---------------------------------------------------------------------------}
  2818. PROCEDURE THistoryWindow.InitViewer(HistoryId: Word);
  2819. VAR R: TRect;
  2820. BEGIN
  2821. GetExtent(R); { Get extents }
  2822. R.Grow(-1,-1); { Grow inside }
  2823. Viewer := New(PHistoryViewer, Init(R,
  2824. StandardScrollBar(sbHorizontal + sbHandleKeyboard),
  2825. StandardScrollBar(sbVertical + sbHandleKeyboard),
  2826. HistoryId)); { Create the viewer }
  2827. If (Viewer <> Nil) Then Insert(Viewer); { Insert viewer }
  2828. END;
  2829. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2830. { THistory OBJECT METHODS }
  2831. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2832. {--THistory-----------------------------------------------------------------}
  2833. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2834. {---------------------------------------------------------------------------}
  2835. CONSTRUCTOR THistory.Init (Var Bounds: TRect; ALink: PInputLine;
  2836. AHistoryId: Word);
  2837. BEGIN
  2838. Inherited Init(Bounds); { Call ancestor }
  2839. Options := Options OR ofPostProcess; { Set post process }
  2840. EventMask := EventMask OR evBroadcast; { See broadcast events }
  2841. Link := ALink; { Hold link view }
  2842. HistoryId := AHistoryId; { Hold history id }
  2843. END;
  2844. {--THistory-----------------------------------------------------------------}
  2845. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2846. {---------------------------------------------------------------------------}
  2847. CONSTRUCTOR THistory.Load (Var S: TStream);
  2848. BEGIN
  2849. Inherited Load(S); { Call ancestor }
  2850. GetPeerViewPtr(S, Link); { Load link view }
  2851. S.Read(HistoryId, 2); { Read history id }
  2852. END;
  2853. {--THistory-----------------------------------------------------------------}
  2854. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2855. {---------------------------------------------------------------------------}
  2856. FUNCTION THistory.GetPalette: PPalette;
  2857. {$IFDEF PPC_DELPHI3} { DELPHI3+ COMPILER }
  2858. CONST P: String = CHistory; { Possible huge string }
  2859. {$ELSE} { OTHER COMPILERS }
  2860. CONST P: String[Length(CHistory)] = CHistory; { Always normal string }
  2861. {$ENDIF}
  2862. BEGIN
  2863. GetPalette := @P; { Return the palette }
  2864. END;
  2865. {--THistory-----------------------------------------------------------------}
  2866. { InitHistoryWindow -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2867. {---------------------------------------------------------------------------}
  2868. FUNCTION THistory.InitHistoryWindow (Var Bounds: TRect): PHistoryWindow;
  2869. VAR P: PHistoryWindow;
  2870. BEGIN
  2871. P := New(PHistoryWindow, Init(Bounds, HistoryId)); { Create history window }
  2872. If (Link <> Nil) Then
  2873. P^.HelpCtx := Link^.HelpCtx; { Set help context }
  2874. InitHistoryWindow := P; { Return history window }
  2875. END;
  2876. PROCEDURE THistory.Draw;
  2877. VAR B: TDrawBuffer;
  2878. BEGIN
  2879. MoveCStr(B, #222'~'#25'~'#221, GetColor($0102)); { Set buffer data }
  2880. WriteLine(0, 0, Size.X, Size.Y, B); { Write buffer }
  2881. END;
  2882. {--THistory-----------------------------------------------------------------}
  2883. { RecordHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2884. {---------------------------------------------------------------------------}
  2885. PROCEDURE THistory.RecordHistory (CONST S: String);
  2886. BEGIN
  2887. HistoryAdd(HistoryId, S); { Add to history }
  2888. END;
  2889. {--THistory-----------------------------------------------------------------}
  2890. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2891. {---------------------------------------------------------------------------}
  2892. PROCEDURE THistory.Store (Var S: TStream);
  2893. BEGIN
  2894. TView.Store(S); { TView.Store called }
  2895. PutPeerViewPtr(S, Link); { Store link view }
  2896. S.Write(HistoryId, 2); { Store history id }
  2897. END;
  2898. {--THistory-----------------------------------------------------------------}
  2899. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2900. {---------------------------------------------------------------------------}
  2901. PROCEDURE THistory.HandleEvent (Var Event: TEvent);
  2902. VAR C: Word; Rslt: String; R, P: TRect; HistoryWindow: PHistoryWindow;
  2903. BEGIN
  2904. Inherited HandleEvent(Event); { Call ancestor }
  2905. If (Link = Nil) Then Exit; { No link view exits }
  2906. If (Event.What = evMouseDown) OR { Mouse down event }
  2907. ((Event.What = evKeyDown) AND
  2908. (CtrlToArrow(Event.KeyCode) = kbDown) AND { Down arrow key }
  2909. (Link^.State AND sfFocused <> 0)) Then Begin { Link view selected }
  2910. If NOT Link^.Focus Then Begin
  2911. ClearEvent(Event); { Event was handled }
  2912. Exit; { Now exit }
  2913. End;
  2914. RecordHistory(Link^.Data^); { Record current data }
  2915. Link^.GetBounds(R); { Get view bounds }
  2916. Dec(R.A.X); { One char in from us }
  2917. Inc(R.B.X); { One char short of us }
  2918. Inc(R.B.Y, 7); { Seven lines down }
  2919. Dec(R.A.Y,1); { One line below us }
  2920. Owner^.GetExtent(P); { Get owner extents }
  2921. R.Intersect(P); { Intersect views }
  2922. Dec(R.B.Y,1); { Shorten length by one }
  2923. HistoryWindow := InitHistoryWindow(R); { Create history window }
  2924. If (HistoryWindow <> Nil) Then Begin { Window crested okay }
  2925. C := Owner^.ExecView(HistoryWindow); { Execute this window }
  2926. If (C = cmOk) Then Begin { Result was okay }
  2927. Rslt := HistoryWindow^.GetSelection; { Get history selection }
  2928. If Length(Rslt) > Link^.MaxLen Then
  2929. {$IFDEF PPC_DELPHI3} { DELPHI 3+ COMPILER }
  2930. SetLength(Rslt, Link^.MaxLen); { Hold new length }
  2931. {$ELSE}
  2932. Rslt[0] := Char(Link^.MaxLen); { Hold new length }
  2933. {$ENDIF}
  2934. Link^.Data^ := Rslt; { Hold new selection }
  2935. Link^.SelectAll(True); { Select all string }
  2936. Link^.DrawView; { Redraw link view }
  2937. End;
  2938. Dispose(HistoryWindow, Done); { Dispose of window }
  2939. End;
  2940. ClearEvent(Event); { Event was handled }
  2941. End Else If (Event.What = evBroadcast) Then { Broadcast event }
  2942. If ((Event.Command = cmReleasedFocus) AND
  2943. (Event.InfoPtr = Link)) OR
  2944. (Event.Command = cmRecordHistory) Then { Record command }
  2945. RecordHistory(Link^.Data^); { Record the history }
  2946. END;
  2947. {***************************************************************************}
  2948. { INTERFACE ROUTINES }
  2949. {***************************************************************************}
  2950. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2951. { ITEM STRING ROUTINES }
  2952. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2953. {---------------------------------------------------------------------------}
  2954. { NewSItem -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2955. {---------------------------------------------------------------------------}
  2956. FUNCTION NewSItem (Const Str: String; ANext: PSItem): PSItem;
  2957. VAR Item: PSItem;
  2958. BEGIN
  2959. New(Item); { Allocate item }
  2960. Item^.Value := NewStr(Str); { Hold item string }
  2961. Item^.Next := ANext; { Chain the ptr }
  2962. NewSItem := Item; { Return item }
  2963. END;
  2964. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2965. { DIALOG OBJECT REGISTRATION ROUTINES }
  2966. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2967. {---------------------------------------------------------------------------}
  2968. { RegisterDialogs -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB }
  2969. {---------------------------------------------------------------------------}
  2970. PROCEDURE RegisterDialogs;
  2971. BEGIN
  2972. RegisterType(RDialog); { Register dialog }
  2973. RegisterType(RInputLine); { Register inputline }
  2974. RegisterType(RButton); { Register button }
  2975. RegisterType(RCluster); { Register cluster }
  2976. RegisterType(RRadioButtons); { Register radiobutton }
  2977. RegisterType(RCheckBoxes); { Register check boxes }
  2978. RegisterType(RMultiCheckBoxes); { Register multi boxes }
  2979. RegisterType(RListBox); { Register list box }
  2980. RegisterType(RStaticText); { Register static text }
  2981. RegisterType(RLabel); { Register label }
  2982. RegisterType(RHistory); { Register history }
  2983. RegisterType(RParamText); { Register parm text }
  2984. END;
  2985. END.
  2986. {
  2987. $Log$
  2988. Revision 1.4 2001-05-03 22:32:52 pierre
  2989. new bunch of changes, displays something for dos at least
  2990. Revision 1.3 2001/04/10 21:29:55 pierre
  2991. * import of Leon de Boer's files
  2992. Revision 1.2 2000/08/24 12:00:20 marco
  2993. * CVS log and ID tags
  2994. }