dialogs.pas 184 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186
  1. {********[ SOURCE FILE OF GRAPHICAL FREE VISION ]**********}
  2. { }
  3. { System independent GRAPHICAL clone of DIALOGS.PAS }
  4. { }
  5. { Interface Copyright (c) 1992 Borland International }
  6. { }
  7. { Copyright (c) 1996, 1997, 1998, 1999 by Leon de Boer }
  8. { [email protected] - primary e-mail addr }
  9. { [email protected] - backup e-mail addr }
  10. { }
  11. {****************[ THIS CODE IS FREEWARE ]*****************}
  12. { }
  13. { This sourcecode is released for the purpose to }
  14. { promote the pascal language on all platforms. You may }
  15. { redistribute it and/or modify with the following }
  16. { DISCLAIMER. }
  17. { }
  18. { This SOURCE CODE is distributed "AS IS" WITHOUT }
  19. { WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR }
  20. { ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. }
  21. { }
  22. {*****************[ SUPPORTED PLATFORMS ]******************}
  23. { }
  24. { Only Free Pascal Compiler supported }
  25. { }
  26. {**********************************************************}
  27. UNIT Dialogs;
  28. {$CODEPAGE cp437}
  29. {2.0 compatibility}
  30. {$ifdef VER2_0}
  31. {$macro on}
  32. {$define resourcestring := const}
  33. {$endif}
  34. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  35. INTERFACE
  36. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  37. {====Include file to sort compiler platform out =====================}
  38. {$I platform.inc}
  39. {====================================================================}
  40. {==== Compiler directives ===========================================}
  41. {$X+} { Extended syntax is ok }
  42. {$R-} { Disable range checking }
  43. {$S-} { Disable Stack Checking }
  44. {$I-} { Disable IO Checking }
  45. {$Q-} { Disable Overflow Checking }
  46. {$V-} { Turn off strict VAR strings }
  47. {====================================================================}
  48. USES
  49. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  50. Windows, { Standard units }
  51. {$ENDIF}
  52. {$IFDEF OS_OS2} { OS2 CODE }
  53. OS2Def, DosCalls, PMWIN, { Standard units }
  54. {$ENDIF}
  55. FVCommon, FVConsts, Objects, Drivers, Views, Validate; { Standard GFV units }
  56. {***************************************************************************}
  57. { PUBLIC CONSTANTS }
  58. {***************************************************************************}
  59. {---------------------------------------------------------------------------}
  60. { COLOUR PALETTE DEFINITIONS }
  61. {---------------------------------------------------------------------------}
  62. CONST
  63. CGrayDialog = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47 +
  64. #48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;
  65. CBlueDialog = #64#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79 +
  66. #80#81#82#83#84#85#86#87#88#89#90#91#92#92#94#95;
  67. CCyanDialog = #96#97#98#99#100#101#102#103#104#105#106#107#108 +
  68. #109#110#111#112#113#114#115#116#117#118#119#120 +
  69. #121#122#123#124#125#126#127;
  70. CStaticText = #6#7#8#9;
  71. CLabel = #7#8#9#9;
  72. CButton = #10#11#12#13#14#14#14#15;
  73. CCluster = #16#17#18#18#31#6;
  74. CInputLine = #19#19#20#21#14;
  75. CHistory = #22#23;
  76. CHistoryWindow = #19#19#21#24#25#19#20;
  77. CHistoryViewer = #6#6#7#6#6;
  78. CDialog = CGrayDialog; { Default palette }
  79. const
  80. { ldXXXX constants }
  81. ldNone = $0000;
  82. ldNew = $0001;
  83. ldEdit = $0002;
  84. ldDelete = $0004;
  85. ldNewEditDelete = ldNew or ldEdit or ldDelete;
  86. ldHelp = $0008;
  87. ldAllButtons = ldNew or ldEdit or ldDelete or ldHelp;
  88. ldNewIcon = $0010;
  89. ldEditIcon = $0020;
  90. ldDeleteIcon = $0040;
  91. ldAllIcons = ldNewIcon or ldEditIcon or ldDeleteIcon;
  92. ldAll = ldAllIcons or ldAllButtons;
  93. ldNoFrame = $0080;
  94. ldNoScrollBar = $0100;
  95. { ofXXXX constants }
  96. ofNew = $0001;
  97. ofDelete = $0002;
  98. ofEdit = $0004;
  99. ofNewEditDelete = ofNew or ofDelete or ofEdit;
  100. {---------------------------------------------------------------------------}
  101. { TDialog PALETTE COLOUR CONSTANTS }
  102. {---------------------------------------------------------------------------}
  103. CONST
  104. dpBlueDialog = 0; { Blue dialog colour }
  105. dpCyanDialog = 1; { Cyan dialog colour }
  106. dpGrayDialog = 2; { Gray dialog colour }
  107. {---------------------------------------------------------------------------}
  108. { TButton FLAGS MASKS }
  109. {---------------------------------------------------------------------------}
  110. CONST
  111. bfNormal = $00; { Normal displayed }
  112. bfDefault = $01; { Default command }
  113. bfLeftJust = $02; { Left just text }
  114. bfBroadcast = $04; { Broadcast command }
  115. bfGrabFocus = $08; { Grab focus }
  116. {---------------------------------------------------------------------------}
  117. { TMultiCheckBoxes FLAGS - (HiByte = Bits LoByte = Mask) }
  118. {---------------------------------------------------------------------------}
  119. CONST
  120. cfOneBit = $0101; { One bit masks }
  121. cfTwoBits = $0203; { Two bit masks }
  122. cfFourBits = $040F; { Four bit masks }
  123. cfEightBits = $08FF; { Eight bit masks }
  124. {---------------------------------------------------------------------------}
  125. { DIALOG BROADCAST COMMANDS }
  126. {---------------------------------------------------------------------------}
  127. CONST
  128. cmRecordHistory = 60; { Record history cmd }
  129. {***************************************************************************}
  130. { RECORD DEFINITIONS }
  131. {***************************************************************************}
  132. {---------------------------------------------------------------------------}
  133. { ITEM RECORD DEFINITION }
  134. {---------------------------------------------------------------------------}
  135. TYPE
  136. PSItem = ^TSItem;
  137. TSItem = RECORD
  138. Value: PString; { Item string }
  139. Next: PSItem; { Next item }
  140. END;
  141. {***************************************************************************}
  142. { OBJECT DEFINITIONS }
  143. {***************************************************************************}
  144. {---------------------------------------------------------------------------}
  145. { TInputLine OBJECT - INPUT LINE OBJECT }
  146. {---------------------------------------------------------------------------}
  147. TYPE
  148. TInputLine = OBJECT (TView)
  149. MaxLen: Sw_Integer; { Max input length }
  150. CurPos: Sw_Integer; { Cursor position }
  151. FirstPos: Sw_Integer; { First position }
  152. SelStart: Sw_Integer; { Selected start }
  153. SelEnd: Sw_Integer; { Selected end }
  154. Data: PString; { Input line data }
  155. Validator: PValidator; { Validator of view }
  156. CONSTRUCTOR Init (Var Bounds: TRect; AMaxLen: Sw_Integer);
  157. CONSTRUCTOR Load (Var S: TStream);
  158. DESTRUCTOR Done; Virtual;
  159. FUNCTION DataSize: Sw_Word; Virtual;
  160. FUNCTION GetPalette: PPalette; Virtual;
  161. FUNCTION Valid (Command: Word): Boolean; Virtual;
  162. PROCEDURE Draw; Virtual;
  163. PROCEDURE DrawCursor; Virtual;
  164. PROCEDURE SelectAll (Enable: Boolean);
  165. PROCEDURE SetValidator (AValid: PValidator);
  166. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  167. PROCEDURE GetData (Var Rec); Virtual;
  168. PROCEDURE SetData (Var Rec); Virtual;
  169. PROCEDURE Store (Var S: TStream);
  170. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  171. PRIVATE
  172. FUNCTION CanScroll (Delta: Sw_Integer): Boolean;
  173. END;
  174. PInputLine = ^TInputLine;
  175. {---------------------------------------------------------------------------}
  176. { TButton OBJECT - BUTTON ANCESTOR OBJECT }
  177. {---------------------------------------------------------------------------}
  178. TYPE
  179. TButton = OBJECT (TView)
  180. AmDefault: Boolean; { If default button }
  181. Flags : Byte; { Button flags }
  182. Command : Word; { Button command }
  183. Title : PString; { Button title }
  184. CONSTRUCTOR Init (Var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
  185. AFlags: Word);
  186. CONSTRUCTOR Load (Var S: TStream);
  187. DESTRUCTOR Done; Virtual;
  188. FUNCTION GetPalette: PPalette; Virtual;
  189. PROCEDURE Press; Virtual;
  190. PROCEDURE Draw; Virtual;
  191. PROCEDURE DrawState (Down: Boolean);
  192. PROCEDURE MakeDefault (Enable: Boolean);
  193. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  194. PROCEDURE Store (Var S: TStream);
  195. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  196. PRIVATE
  197. DownFlag: Boolean;
  198. END;
  199. PButton = ^TButton;
  200. {---------------------------------------------------------------------------}
  201. { TCluster OBJECT - CLUSTER ANCESTOR OBJECT }
  202. {---------------------------------------------------------------------------}
  203. TYPE
  204. { Palette layout }
  205. { 1 = Normal text }
  206. { 2 = Selected text }
  207. { 3 = Normal shortcut }
  208. { 4 = Selected shortcut }
  209. { 5 = Disabled text }
  210. TCluster = OBJECT (TView)
  211. Id : Sw_Integer; { New communicate id }
  212. Sel : Sw_Integer; { Selected item }
  213. Value : LongInt; { Bit value }
  214. EnableMask: LongInt; { Mask enable bits }
  215. Strings : TStringCollection; { String collection }
  216. CONSTRUCTOR Init (Var Bounds: TRect; AStrings: PSItem);
  217. CONSTRUCTOR Load (Var S: TStream);
  218. DESTRUCTOR Done; Virtual;
  219. FUNCTION DataSize: Sw_Word; Virtual;
  220. FUNCTION GetHelpCtx: Word; Virtual;
  221. FUNCTION GetPalette: PPalette; Virtual;
  222. FUNCTION Mark (Item: Sw_Integer): Boolean; Virtual;
  223. FUNCTION MultiMark (Item: Sw_Integer): Byte; Virtual;
  224. FUNCTION ButtonState (Item: Sw_Integer): Boolean;
  225. PROCEDURE Draw; Virtual;
  226. PROCEDURE Press (Item: Sw_Integer); Virtual;
  227. PROCEDURE MovedTo (Item: Sw_Integer); Virtual;
  228. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  229. PROCEDURE DrawMultiBox (Const Icon, Marker: String);
  230. PROCEDURE DrawBox (Const Icon: String; Marker: Char);
  231. PROCEDURE SetButtonState (AMask: Longint; Enable: Boolean);
  232. PROCEDURE GetData (Var Rec); Virtual;
  233. PROCEDURE SetData (Var Rec); Virtual;
  234. PROCEDURE Store (Var S: TStream);
  235. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  236. PRIVATE
  237. FUNCTION FindSel (P: TPoint): Sw_Integer;
  238. FUNCTION Row (Item: Sw_Integer): Sw_Integer;
  239. FUNCTION Column (Item: Sw_Integer): Sw_Integer;
  240. END;
  241. PCluster = ^TCluster;
  242. {---------------------------------------------------------------------------}
  243. { TRadioButtons OBJECT - RADIO BUTTON OBJECT }
  244. {---------------------------------------------------------------------------}
  245. { Palette layout }
  246. { 1 = Normal text }
  247. { 2 = Selected text }
  248. { 3 = Normal shortcut }
  249. { 4 = Selected shortcut }
  250. TYPE
  251. TRadioButtons = OBJECT (TCluster)
  252. FUNCTION Mark (Item: Sw_Integer): Boolean; Virtual;
  253. PROCEDURE Draw; Virtual;
  254. PROCEDURE Press (Item: Sw_Integer); Virtual;
  255. PROCEDURE MovedTo(Item: Sw_Integer); Virtual;
  256. PROCEDURE SetData (Var Rec); Virtual;
  257. END;
  258. PRadioButtons = ^TRadioButtons;
  259. {---------------------------------------------------------------------------}
  260. { TCheckBoxes OBJECT - CHECK BOXES OBJECT }
  261. {---------------------------------------------------------------------------}
  262. { Palette layout }
  263. { 1 = Normal text }
  264. { 2 = Selected text }
  265. { 3 = Normal shortcut }
  266. { 4 = Selected shortcut }
  267. TYPE
  268. TCheckBoxes = OBJECT (TCluster)
  269. FUNCTION Mark (Item: Sw_Integer): Boolean; Virtual;
  270. PROCEDURE Draw; Virtual;
  271. PROCEDURE Press (Item: Sw_Integer); Virtual;
  272. END;
  273. PCheckBoxes = ^TCheckBoxes;
  274. {---------------------------------------------------------------------------}
  275. { TMultiCheckBoxes OBJECT - CHECK BOXES OBJECT }
  276. {---------------------------------------------------------------------------}
  277. { Palette layout }
  278. { 1 = Normal text }
  279. { 2 = Selected text }
  280. { 3 = Normal shortcut }
  281. { 4 = Selected shortcut }
  282. TYPE
  283. TMultiCheckBoxes = OBJECT (TCluster)
  284. SelRange: Byte; { Select item range }
  285. Flags : Word; { Select flags }
  286. States : PString; { Strings }
  287. CONSTRUCTOR Init (Var Bounds: TRect; AStrings: PSItem;
  288. ASelRange: Byte; AFlags: Word; Const AStates: String);
  289. CONSTRUCTOR Load (Var S: TStream);
  290. DESTRUCTOR Done; Virtual;
  291. FUNCTION DataSize: Sw_Word; Virtual;
  292. FUNCTION MultiMark (Item: Sw_Integer): Byte; Virtual;
  293. PROCEDURE Draw; Virtual;
  294. PROCEDURE Press (Item: Sw_Integer); Virtual;
  295. PROCEDURE GetData (Var Rec); Virtual;
  296. PROCEDURE SetData (Var Rec); Virtual;
  297. PROCEDURE Store (Var S: TStream);
  298. END;
  299. PMultiCheckBoxes = ^TMultiCheckBoxes;
  300. {---------------------------------------------------------------------------}
  301. { TListBox OBJECT - LIST BOX OBJECT }
  302. {---------------------------------------------------------------------------}
  303. { Palette layout }
  304. { 1 = Active }
  305. { 2 = Inactive }
  306. { 3 = Focused }
  307. { 4 = Selected }
  308. { 5 = Divider }
  309. TYPE
  310. TListBox = OBJECT (TListViewer)
  311. List: PCollection; { List of strings }
  312. CONSTRUCTOR Init (Var Bounds: TRect; ANumCols: Sw_Word;
  313. AScrollBar: PScrollBar);
  314. CONSTRUCTOR Load (Var S: TStream);
  315. FUNCTION DataSize: Sw_Word; Virtual;
  316. FUNCTION GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String; Virtual;
  317. PROCEDURE NewList(AList: PCollection); Virtual;
  318. PROCEDURE GetData (Var Rec); Virtual;
  319. PROCEDURE SetData (Var Rec); Virtual;
  320. PROCEDURE Store (Var S: TStream);
  321. procedure DeleteFocusedItem; virtual;
  322. { DeleteFocusedItem deletes the focused item and redraws the view. }
  323. {#X FreeFocusedItem }
  324. procedure DeleteItem (Item : Sw_Integer); virtual;
  325. { DeleteItem deletes Item from the associated collection. }
  326. {#X FreeItem }
  327. procedure FreeAll; virtual;
  328. { FreeAll deletes and disposes of all items in the associated
  329. collection. }
  330. { FreeFocusedItem FreeItem }
  331. procedure FreeFocusedItem; virtual;
  332. { FreeFocusedItem deletes and disposes of the focused item then redraws
  333. the listbox. }
  334. {#X FreeAll FreeItem }
  335. procedure FreeItem (Item : Sw_Integer); virtual;
  336. { FreeItem deletes Item from the associated collection and disposes of
  337. it, then redraws the listbox. }
  338. {#X FreeFocusedItem FreeAll }
  339. function GetFocusedItem : Pointer; virtual;
  340. { GetFocusedItem is a more readable method of returning the focused
  341. item from the listbox. It is however slightly slower than: }
  342. {#M+}
  343. {
  344. Item := ListBox^.List^.At(ListBox^.Focused); }
  345. {#M-}
  346. procedure Insert (Item : Pointer); virtual;
  347. { Insert inserts Item into the collection, adjusts the listbox's range,
  348. then redraws the listbox. }
  349. {#X FreeItem }
  350. procedure SetFocusedItem (Item : Pointer); virtual;
  351. { SetFocusedItem changes the focused item to Item then redraws the
  352. listbox. }
  353. {# FocusItemNum }
  354. END;
  355. PListBox = ^TListBox;
  356. {---------------------------------------------------------------------------}
  357. { TStaticText OBJECT - STATIC TEXT OBJECT }
  358. {---------------------------------------------------------------------------}
  359. TYPE
  360. TStaticText = OBJECT (TView)
  361. Text: PString; { Text string ptr }
  362. CONSTRUCTOR Init (Var Bounds: TRect; Const AText: String);
  363. CONSTRUCTOR Load (Var S: TStream);
  364. DESTRUCTOR Done; Virtual;
  365. FUNCTION GetPalette: PPalette; Virtual;
  366. PROCEDURE Draw; Virtual;
  367. PROCEDURE Store (Var S: TStream);
  368. PROCEDURE GetText (Var S: String); Virtual;
  369. END;
  370. PStaticText = ^TStaticText;
  371. {---------------------------------------------------------------------------}
  372. { TParamText OBJECT - PARMETER STATIC TEXT OBJECT }
  373. {---------------------------------------------------------------------------}
  374. { Palette layout }
  375. { 1 = Text }
  376. TYPE
  377. TParamText = OBJECT (TStaticText)
  378. ParamCount: Sw_Integer; { Parameter count }
  379. ParamList : Pointer; { Parameter list }
  380. CONSTRUCTOR Init (Var Bounds: TRect; Const AText: String;
  381. AParamCount: Sw_Integer);
  382. CONSTRUCTOR Load (Var S: TStream);
  383. FUNCTION DataSize: Sw_Word; Virtual;
  384. PROCEDURE GetData (Var Rec); Virtual;
  385. PROCEDURE SetData (Var Rec); Virtual;
  386. PROCEDURE Store (Var S: TStream);
  387. PROCEDURE GetText (Var S: String); Virtual;
  388. END;
  389. PParamText = ^TParamText;
  390. {---------------------------------------------------------------------------}
  391. { TLabel OBJECT - LABEL OBJECT }
  392. {---------------------------------------------------------------------------}
  393. TYPE
  394. TLabel = OBJECT (TStaticText)
  395. Light: Boolean;
  396. Link: PView; { Linked view }
  397. CONSTRUCTOR Init (Var Bounds: TRect; CONST AText: String; ALink: PView);
  398. CONSTRUCTOR Load (Var S: TStream);
  399. FUNCTION GetPalette: PPalette; Virtual;
  400. PROCEDURE Draw; Virtual;
  401. PROCEDURE Store (Var S: TStream);
  402. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  403. END;
  404. PLabel = ^TLabel;
  405. {---------------------------------------------------------------------------}
  406. { THistoryViewer OBJECT - HISTORY VIEWER OBJECT }
  407. {---------------------------------------------------------------------------}
  408. { Palette layout }
  409. { 1 = Active }
  410. { 2 = Inactive }
  411. { 3 = Focused }
  412. { 4 = Selected }
  413. { 5 = Divider }
  414. TYPE
  415. THistoryViewer = OBJECT (TListViewer)
  416. HistoryId: Word; { History id }
  417. CONSTRUCTOR Init(Var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  418. AHistoryId: Word);
  419. FUNCTION HistoryWidth: Sw_Integer;
  420. FUNCTION GetPalette: PPalette; Virtual;
  421. FUNCTION GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String; Virtual;
  422. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  423. END;
  424. PHistoryViewer = ^THistoryViewer;
  425. {---------------------------------------------------------------------------}
  426. { THistoryWindow OBJECT - HISTORY WINDOW OBJECT }
  427. {---------------------------------------------------------------------------}
  428. { Palette layout }
  429. { 1 = Frame passive }
  430. { 2 = Frame active }
  431. { 3 = Frame icon }
  432. { 4 = ScrollBar page area }
  433. { 5 = ScrollBar controls }
  434. { 6 = HistoryViewer normal text }
  435. { 7 = HistoryViewer selected text }
  436. TYPE
  437. THistoryWindow = OBJECT (TWindow)
  438. Viewer: PListViewer; { List viewer object }
  439. CONSTRUCTOR Init (Var Bounds: TRect; HistoryId: Word);
  440. FUNCTION GetSelection: String; Virtual;
  441. FUNCTION GetPalette: PPalette; Virtual;
  442. PROCEDURE InitViewer (HistoryId: Word); Virtual;
  443. END;
  444. PHistoryWindow = ^THistoryWindow;
  445. {---------------------------------------------------------------------------}
  446. { THistory OBJECT - HISTORY OBJECT }
  447. {---------------------------------------------------------------------------}
  448. { Palette layout }
  449. { 1 = Arrow }
  450. { 2 = Sides }
  451. TYPE
  452. THistory = OBJECT (TView)
  453. HistoryId: Word;
  454. Link: PInputLine;
  455. CONSTRUCTOR Init (Var Bounds: TRect; ALink: PInputLine; AHistoryId: Word);
  456. CONSTRUCTOR Load (Var S: TStream);
  457. FUNCTION GetPalette: PPalette; Virtual;
  458. FUNCTION InitHistoryWindow (Var Bounds: TRect): PHistoryWindow; Virtual;
  459. PROCEDURE Draw; Virtual;
  460. PROCEDURE RecordHistory (CONST S: String); Virtual;
  461. PROCEDURE Store (Var S: TStream);
  462. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  463. END;
  464. PHistory = ^THistory;
  465. {#Z+}
  466. PBrowseInputLine = ^TBrowseInputLine;
  467. TBrowseInputLine = Object(TInputLine)
  468. History: Sw_Word;
  469. constructor Init(var Bounds: TRect; AMaxLen: Sw_Integer; AHistory: Sw_Word);
  470. constructor Load(var S: TStream);
  471. function DataSize: Sw_Word; virtual;
  472. procedure GetData(var Rec); virtual;
  473. procedure SetData(var Rec); virtual;
  474. procedure Store(var S: TStream);
  475. end; { of TBrowseInputLine }
  476. TBrowseInputLineRec = record
  477. Text: string;
  478. History: Sw_Word;
  479. end; { of TBrowseInputLineRec }
  480. {#Z+}
  481. PBrowseButton = ^TBrowseButton;
  482. {#Z-}
  483. TBrowseButton = Object(TButton)
  484. Link: PBrowseInputLine;
  485. constructor Init(var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
  486. AFlags: Byte; ALink: PBrowseInputLine);
  487. constructor Load(var S: TStream);
  488. procedure Press; virtual;
  489. procedure Store(var S: TStream);
  490. end; { of TBrowseButton }
  491. {#Z+}
  492. PCommandIcon = ^TCommandIcon;
  493. {#Z-}
  494. TCommandIcon = Object(TStaticText)
  495. { A TCommandIcon sends an evCommand message to its owner with
  496. Event.Command set to #Command# when it is clicked with a mouse. }
  497. constructor Init (var Bounds : TRect; AText : String; ACommand : Word);
  498. { Creates an instance of a TCommandIcon and sets #Command# to
  499. ACommand. AText is the text which is displayed as the icon. If an
  500. error occurs Init fails. }
  501. procedure HandleEvent (var Event : TEvent); virtual;
  502. { Captures mouse events within its borders and sends an evCommand to
  503. its owner in response to the mouse event. }
  504. {#X Command }
  505. private
  506. Command : Word;
  507. { Command is the command sent to the command icon's owner when it is
  508. clicked. }
  509. end; { of TCommandIcon }
  510. {#Z+}
  511. PCommandSItem = ^TCommandSItem;
  512. {#Z-}
  513. TCommandSItem = record
  514. { A TCommandSItem is the data structure used to initialize command
  515. clusters with #NewCommandSItem# rather than the standarad #NewSItem#.
  516. It is used to associate a command with an individual cluster item. }
  517. {#X TCommandCheckBoxes TCommandRadioButtons }
  518. Value : String;
  519. { Value is the text displayed for the cluster item. }
  520. {#X Command Next }
  521. Command : Word;
  522. { Command is the command broadcast when the cluster item is pressed. }
  523. {#X Value Next }
  524. Next : PCommandSItem;
  525. { Next is a pointer to the next item in the cluster. }
  526. {#X Value Command }
  527. end; { of TCommandSItem }
  528. TCommandArray = array[0..15] of Word;
  529. { TCommandArray holds a list of commands which are associated with a
  530. cluster. }
  531. {#X TCommandCheckBoxes TCommandRadioButtons }
  532. {#Z+}
  533. PCommandCheckBoxes = ^TCommandCheckBoxes;
  534. {#Z-}
  535. TCommandCheckBoxes = Object(TCheckBoxes)
  536. { TCommandCheckBoxes function as normal TCheckBoxes, except that when a
  537. cluster item is pressed it broadcasts a command associated with the
  538. cluster item to the cluster's owner.
  539. TCommandCheckBoxes are useful when other parts of a dialog should be
  540. enabled or disabled in response to a check box's status. }
  541. CommandList : TCommandArray;
  542. { CommandList is the list of commands associated with each check box
  543. item. }
  544. {#X Init Load Store }
  545. constructor Init (var Bounds : TRect; ACommandStrings : PCommandSItem);
  546. { Init calls the inherited constructor, then sets up the #CommandList#
  547. with the specified commands. If an error occurs Init fails. }
  548. {#X NewCommandSItem }
  549. constructor Load (var S : TStream);
  550. { Load calls the inherited constructor, then loads the #CommandList#
  551. from the stream S. If an error occurs Load fails. }
  552. {#X Store Init }
  553. procedure Press (Item : Sw_Integer); virtual;
  554. { Press calls the inherited Press then broadcasts the command
  555. associated with the cluster item that was pressed to the check boxes'
  556. owner. }
  557. {#X CommandList }
  558. procedure Store (var S : TStream); { store should never be virtual;}
  559. { Store calls the inherited Store method then writes the #CommandList#
  560. to the stream. }
  561. {#X Load }
  562. end; { of TCommandCheckBoxes }
  563. {#Z+}
  564. PCommandRadioButtons = ^TCommandRadioButtons;
  565. {#Z-}
  566. TCommandRadioButtons = Object(TRadioButtons)
  567. { TCommandRadioButtons function as normal TRadioButtons, except that when
  568. a cluster item is pressed it broadcasts a command associated with the
  569. cluster item to the cluster's owner.
  570. TCommandRadioButtons are useful when other parts of a dialog should be
  571. enabled or disabled in response to a radiobutton's status. }
  572. CommandList : TCommandArray; { commands for each possible value }
  573. { The list of commands associated with each radio button item. }
  574. {#X Init Load Store }
  575. constructor Init (var Bounds : TRect; ACommandStrings : PCommandSItem);
  576. { Init calls the inherited constructor and sets up the #CommandList#
  577. with the specified commands. If an error occurs Init disposes of the
  578. command strings then fails. }
  579. {#X NewCommandSItem }
  580. constructor Load (var S : TStream);
  581. { Load calls the inherited constructor then loads the #CommandList#
  582. from the stream S. If an error occurs Load fails. }
  583. {#X Store }
  584. procedure MovedTo (Item : Sw_Integer); virtual;
  585. { MovedTo calls the inherited MoveTo, then broadcasts the command of
  586. the newly selected cluster item to the cluster's owner. }
  587. {#X Press CommandList }
  588. procedure Press (Item : Sw_Integer); virtual;
  589. { Press calls the inherited Press then broadcasts the command
  590. associated with the cluster item that was pressed to the check boxes
  591. owner. }
  592. {#X CommandList MovedTo }
  593. procedure Store (var S : TStream); { store should never be virtual;}
  594. { Store calls the inherited Store method then writes the #CommandList#
  595. to the stream. }
  596. {#X Load }
  597. end; { of TCommandRadioButtons }
  598. PEditListBox = ^TEditListBox;
  599. TEditListBox = Object(TListBox)
  600. CurrentField : Integer;
  601. constructor Init (Bounds : TRect; ANumCols: Word;
  602. AVScrollBar : PScrollBar);
  603. constructor Load (var S : TStream);
  604. function FieldValidator : PValidator; virtual;
  605. function FieldWidth : Integer; virtual;
  606. procedure GetField (InputLine : PInputLine); virtual;
  607. function GetPalette : PPalette; virtual;
  608. procedure HandleEvent (var Event : TEvent); virtual;
  609. procedure SetField (InputLine : PInputLine); virtual;
  610. function StartColumn : Integer; virtual;
  611. PRIVATE
  612. procedure EditField (var Event : TEvent);
  613. end; { of TEditListBox }
  614. PModalInputLine = ^TModalInputLine;
  615. TModalInputLine = Object(TInputLine)
  616. function Execute : Word; virtual;
  617. procedure HandleEvent (var Event : TEvent); virtual;
  618. procedure SetState (AState : Word; Enable : Boolean); virtual;
  619. private
  620. EndState : Word;
  621. end; { of TModalInputLine }
  622. {---------------------------------------------------------------------------}
  623. { TDialog OBJECT - DIALOG OBJECT }
  624. {---------------------------------------------------------------------------}
  625. { Palette layout }
  626. { 1 = Frame passive }
  627. { 2 = Frame active }
  628. { 3 = Frame icon }
  629. { 4 = ScrollBar page area }
  630. { 5 = ScrollBar controls }
  631. { 6 = StaticText }
  632. { 7 = Label normal }
  633. { 8 = Label selected }
  634. { 9 = Label shortcut }
  635. { 10 = Button normal }
  636. { 11 = Button default }
  637. { 12 = Button selected }
  638. { 13 = Button disabled }
  639. { 14 = Button shortcut }
  640. { 15 = Button shadow }
  641. { 16 = Cluster normal }
  642. { 17 = Cluster selected }
  643. { 18 = Cluster shortcut }
  644. { 19 = InputLine normal text }
  645. { 20 = InputLine selected text }
  646. { 21 = InputLine arrows }
  647. { 22 = History arrow }
  648. { 23 = History sides }
  649. { 24 = HistoryWindow scrollbar page area }
  650. { 25 = HistoryWindow scrollbar controls }
  651. { 26 = ListViewer normal }
  652. { 27 = ListViewer focused }
  653. { 28 = ListViewer selected }
  654. { 29 = ListViewer divider }
  655. { 30 = InfoPane }
  656. { 31 = Cluster disabled }
  657. { 32 = Reserved }
  658. PDialog = ^TDialog;
  659. TDialog = object(TWindow)
  660. constructor Init(var Bounds: TRect; ATitle: TTitleStr);
  661. constructor Load(var S: TStream);
  662. procedure Cancel (ACommand : Word); virtual;
  663. { If the dialog is a modal dialog, Cancel calls EndModal(ACommand). If
  664. the dialog is non-modal Cancel calls Close.
  665. Cancel may be overridden to provide special processing prior to
  666. destructing the dialog. }
  667. procedure ChangeTitle (ANewTitle : TTitleStr); virtual;
  668. { ChangeTitle disposes of the current title, assigns ANewTitle to Title,
  669. then redraws the dialog. }
  670. procedure FreeSubView (ASubView : PView); virtual;
  671. { FreeSubView deletes and disposes ASubView from the dialog. }
  672. {#X FreeAllSubViews IsSubView }
  673. procedure FreeAllSubViews; virtual;
  674. { Deletes then disposes all subviews in the dialog. }
  675. {#X FreeSubView IsSubView }
  676. function GetPalette: PPalette; virtual;
  677. procedure HandleEvent(var Event: TEvent); virtual;
  678. function IsSubView (AView : PView) : Boolean; virtual;
  679. { IsSubView returns True if AView is non-nil and is a subview of the
  680. dialog. }
  681. {#X FreeSubView FreeAllSubViews }
  682. function NewButton (X, Y, W, H : Sw_Integer; ATitle : TTitleStr;
  683. ACommand, AHelpCtx : Word;
  684. AFlags : Byte) : PButton;
  685. { Creates and inserts into the dialog a new TButton with the
  686. help context AHelpCtx.
  687. A pointer to the new button is returned for checking validity of the
  688. initialization. }
  689. {#X NewInputLine NewLabel }
  690. function NewLabel (X, Y : Sw_Integer; AText : String;
  691. ALink : PView) : PLabel;
  692. { NewLabel creates and inserts into the dialog a new TLabel and
  693. associates it with ALink. }
  694. {#X NewButton NewInputLine }
  695. function NewInputLine (X, Y, W, AMaxLen : Sw_Integer; AHelpCtx : Word
  696. ; AValidator : PValidator) : PInputLine;
  697. { NewInputLine creates and inserts into the dialog a new TBSDInputLine
  698. with the help context to AHelpCtx and the validator AValidator.
  699. A pointer to the inputline is returned for checking validity of the
  700. initialization. }
  701. {#X NewButton NewLabel }
  702. function Valid(Command: Word): Boolean; virtual;
  703. end;
  704. PListDlg = ^TListDlg;
  705. TListDlg = object(TDialog)
  706. { TListDlg displays a listbox of items, with optional New, Edit, and
  707. Delete buttons displayed according to the options bit set in the
  708. dialog. Use the ofXXXX flags declared in this unit OR'd with the
  709. standard ofXXXX flags to set the appropriate bits in Options.
  710. If enabled, when the New or Edit buttons are pressed, an evCommand
  711. message is sent to the application with a Command value of NewCommand
  712. or EditCommand, respectively. Using this mechanism in combination with
  713. the declared Init parameters, a standard TListDlg can be used with any
  714. type of list displayable in a TListBox or its descendant. }
  715. NewCommand: Word;
  716. EditCommand: Word;
  717. ListBox: PListBox;
  718. ldOptions: Word;
  719. constructor Init (ATitle: TTitleStr; Items: string; AButtons: Word;
  720. AListBox: PListBox; AEditCommand, ANewCommand: Word);
  721. constructor Load(var S: TStream);
  722. procedure HandleEvent(var Event: TEvent); virtual;
  723. procedure Store(var S: TStream); { store should never be virtual;}
  724. end; { of TListDlg }
  725. {***************************************************************************}
  726. { INTERFACE ROUTINES }
  727. {***************************************************************************}
  728. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  729. { ITEM STRING ROUTINES }
  730. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  731. {-NewSItem-----------------------------------------------------------
  732. Allocates memory for a new TSItem record and sets the text field
  733. and chains to the next TSItem. This allows easy construction of
  734. singly-linked lists of strings, to end a chain the next TSItem
  735. should be nil.
  736. 28Apr98 LdB
  737. ---------------------------------------------------------------------}
  738. FUNCTION NewSItem (Const Str: String; ANext: PSItem): PSItem;
  739. { NewCommandSItem allocates and returns a pointer to a new #TCommandSItem#
  740. record. The Value and Next fields of the record are set to NewStr(Str)
  741. and ANext, respectively. The NewSItem function and the TSItem record type
  742. allow easy construction of singly-linked lists of command strings. }
  743. function NewCommandSItem (Str : String; ACommand : Word;
  744. ANext : PCommandSItem) : PCommandSItem;
  745. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  746. { DIALOG OBJECT REGISTRATION PROCEDURE }
  747. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  748. {-RegisterDialogs----------------------------------------------------
  749. This registers all the view type objects used in this unit.
  750. 30Sep99 LdB
  751. ---------------------------------------------------------------------}
  752. PROCEDURE RegisterDialogs;
  753. {***************************************************************************}
  754. { STREAM REGISTRATION RECORDS }
  755. {***************************************************************************}
  756. {---------------------------------------------------------------------------}
  757. { TDialog STREAM REGISTRATION }
  758. {---------------------------------------------------------------------------}
  759. CONST
  760. RDialog: TStreamRec = (
  761. ObjType: idDialog; { Register id = 10 }
  762. VmtLink: TypeOf(TDialog);
  763. Load: @TDialog.Load; { Object load method }
  764. Store: @TDialog.Store { Object store method }
  765. );
  766. {---------------------------------------------------------------------------}
  767. { TInputLine STREAM REGISTRATION }
  768. {---------------------------------------------------------------------------}
  769. CONST
  770. RInputLine: TStreamRec = (
  771. ObjType: idInputLine; { Register id = 11 }
  772. VmtLink: TypeOf(TInputLine);
  773. Load: @TInputLine.Load; { Object load method }
  774. Store: @TInputLine.Store { Object store method }
  775. );
  776. {---------------------------------------------------------------------------}
  777. { TButton STREAM REGISTRATION }
  778. {---------------------------------------------------------------------------}
  779. CONST
  780. RButton: TStreamRec = (
  781. ObjType: idButton; { Register id = 12 }
  782. VmtLink: TypeOf(TButton);
  783. Load: @TButton.Load; { Object load method }
  784. Store: @TButton.Store { Object store method }
  785. );
  786. {---------------------------------------------------------------------------}
  787. { TCluster STREAM REGISTRATION }
  788. {---------------------------------------------------------------------------}
  789. CONST
  790. RCluster: TStreamRec = (
  791. ObjType: idCluster; { Register id = 13 }
  792. VmtLink: TypeOf(TCluster);
  793. Load: @TCluster.Load; { Object load method }
  794. Store: @TCluster.Store { Objects store method }
  795. );
  796. {---------------------------------------------------------------------------}
  797. { TRadioButtons STREAM REGISTRATION }
  798. {---------------------------------------------------------------------------}
  799. CONST
  800. RRadioButtons: TStreamRec = (
  801. ObjType: idRadioButtons; { Register id = 14 }
  802. VmtLink: TypeOf(TRadioButtons);
  803. Load: @TRadioButtons.Load; { Object load method }
  804. Store: @TRadioButtons.Store { Object store method }
  805. );
  806. {---------------------------------------------------------------------------}
  807. { TCheckBoxes STREAM REGISTRATION }
  808. {---------------------------------------------------------------------------}
  809. CONST
  810. RCheckBoxes: TStreamRec = (
  811. ObjType: idCheckBoxes; { Register id = 15 }
  812. VmtLink: TypeOf(TCheckBoxes);
  813. Load: @TCheckBoxes.Load; { Object load method }
  814. Store: @TCheckBoxes.Store { Object store method }
  815. );
  816. {---------------------------------------------------------------------------}
  817. { TMultiCheckBoxes STREAM REGISTRATION }
  818. {---------------------------------------------------------------------------}
  819. CONST
  820. RMultiCheckBoxes: TStreamRec = (
  821. ObjType: idMultiCheckBoxes; { Register id = 27 }
  822. VmtLink: TypeOf(TMultiCheckBoxes);
  823. Load: @TMultiCheckBoxes.Load; { Object load method }
  824. Store: @TMultiCheckBoxes.Store { Object store method }
  825. );
  826. {---------------------------------------------------------------------------}
  827. { TListBox STREAM REGISTRATION }
  828. {---------------------------------------------------------------------------}
  829. CONST
  830. RListBox: TStreamRec = (
  831. ObjType: idListBox; { Register id = 16 }
  832. VmtLink: TypeOf(TListBox);
  833. Load: @TListBox.Load; { Object load method }
  834. Store: @TListBox.Store { Object store method }
  835. );
  836. {---------------------------------------------------------------------------}
  837. { TStaticText STREAM REGISTRATION }
  838. {---------------------------------------------------------------------------}
  839. CONST
  840. RStaticText: TStreamRec = (
  841. ObjType: idStaticText; { Register id = 17 }
  842. VmtLink: TypeOf(TStaticText);
  843. Load: @TStaticText.Load; { Object load method }
  844. Store: @TStaticText.Store { Object store method }
  845. );
  846. {---------------------------------------------------------------------------}
  847. { TLabel STREAM REGISTRATION }
  848. {---------------------------------------------------------------------------}
  849. CONST
  850. RLabel: TStreamRec = (
  851. ObjType: idLabel; { Register id = 18 }
  852. VmtLink: TypeOf(TLabel);
  853. Load: @TLabel.Load; { Object load method }
  854. Store: @TLabel.Store { Object store method }
  855. );
  856. {---------------------------------------------------------------------------}
  857. { THistory STREAM REGISTRATION }
  858. {---------------------------------------------------------------------------}
  859. CONST
  860. RHistory: TStreamRec = (
  861. ObjType: idHistory; { Register id = 19 }
  862. VmtLink: TypeOf(THistory);
  863. Load: @THistory.Load; { Object load method }
  864. Store: @THistory.Store { Object store method }
  865. );
  866. {---------------------------------------------------------------------------}
  867. { TParamText STREAM REGISTRATION }
  868. {---------------------------------------------------------------------------}
  869. CONST
  870. RParamText: TStreamRec = (
  871. ObjType: idParamText; { Register id = 20 }
  872. VmtLink: TypeOf(TParamText);
  873. Load: @TParamText.Load; { Object load method }
  874. Store: @TParamText.Store { Object store method }
  875. );
  876. RCommandCheckBoxes : TStreamRec = (
  877. ObjType : idCommandCheckBoxes;
  878. VmtLink : Ofs(TypeOf(TCommandCheckBoxes)^);
  879. Load : @TCommandCheckBoxes.Load;
  880. Store : @TCommandCheckBoxes.Store);
  881. RCommandRadioButtons : TStreamRec = (
  882. ObjType : idCommandRadioButtons;
  883. VmtLink : Ofs(TypeOf(TCommandRadioButtons)^);
  884. Load : @TCommandRadioButtons.Load;
  885. Store : @TCommandRadioButtons.Store);
  886. RCommandIcon : TStreamRec = (
  887. ObjType : idCommandIcon;
  888. VmtLink : Ofs(Typeof(TCommandIcon)^);
  889. Load : @TCommandIcon.Load;
  890. Store : @TCommandIcon.Store);
  891. RBrowseButton: TStreamRec = (
  892. ObjType : idBrowseButton;
  893. VmtLink : Ofs(TypeOf(TBrowseButton)^);
  894. Load : @TBrowseButton.Load;
  895. Store : @TBrowseButton.Store);
  896. REditListBox : TStreamRec = (
  897. ObjType : idEditListBox;
  898. VmtLink : Ofs(TypeOf(TEditListBox)^);
  899. Load : @TEditListBox.Load;
  900. Store : @TEditListBox.Store);
  901. RListDlg : TStreamRec = (
  902. ObjType : idListDlg;
  903. VmtLink : Ofs(TypeOf(TListDlg)^);
  904. Load : @TListDlg.Load;
  905. Store : @TListDlg.Store);
  906. RModalInputLine : TStreamRec = (
  907. ObjType : idModalInputLine;
  908. VmtLink : Ofs(TypeOf(TModalInputLine)^);
  909. Load : @TModalInputLine.Load;
  910. Store : @TModalInputLine.Store);
  911. resourcestring slCancel='Cancel';
  912. slOk='O~k~';
  913. slYes='~Y~es';
  914. slNo='~N~o';
  915. slHelp='~H~elp';
  916. slName='~N~ame';
  917. slOpen='~O~pen';
  918. slClose='~C~lose';
  919. slCloseAll='Cl~o~se all';
  920. slSave='~S~ave';
  921. slSaveAll='Save a~l~l';
  922. slSaveAs='S~a~ve as...';
  923. slSaveFileAs='~S~ave file as';
  924. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  925. IMPLEMENTATION
  926. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  927. USES App,HistList; { Standard GFV unit }
  928. {***************************************************************************}
  929. { PRIVATE DEFINED CONSTANTS }
  930. {***************************************************************************}
  931. {---------------------------------------------------------------------------}
  932. { LEFT AND RIGHT ARROW CHARACTER CONSTANTS }
  933. {---------------------------------------------------------------------------}
  934. CONST LeftArr = '<'; RightArr = '>';
  935. {---------------------------------------------------------------------------}
  936. { TButton MESSAGES }
  937. {---------------------------------------------------------------------------}
  938. CONST
  939. cmGrabDefault = 61; { Grab default }
  940. cmReleaseDefault = 62; { Release default }
  941. {---------------------------------------------------------------------------}
  942. { IsBlank -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  943. {---------------------------------------------------------------------------}
  944. FUNCTION IsBlank (Ch: Char): Boolean;
  945. BEGIN
  946. IsBlank := (Ch = ' ') OR (Ch = #13) OR (Ch = #10); { Check for characters }
  947. END;
  948. {---------------------------------------------------------------------------}
  949. { HotKey -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  950. {---------------------------------------------------------------------------}
  951. FUNCTION HotKey (Const S: String): Char;
  952. VAR I: Sw_Word;
  953. BEGIN
  954. HotKey := #0; { Preset fail }
  955. If (S <> '') Then Begin { Valid string }
  956. I := Pos('~', S); { Search for tilde }
  957. If (I <> 0) Then HotKey := UpCase(S[I+1]); { Return hotkey }
  958. End;
  959. END;
  960. {***************************************************************************}
  961. { OBJECT METHODS }
  962. {***************************************************************************}
  963. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  964. { TDialog OBJECT METHODS }
  965. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  966. {--TDialog------------------------------------------------------------------}
  967. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  968. {---------------------------------------------------------------------------}
  969. CONSTRUCTOR TDialog.Init (Var Bounds: TRect; ATitle: TTitleStr);
  970. BEGIN
  971. Inherited Init(Bounds, ATitle, wnNoNumber); { Call ancestor }
  972. Options := Options OR ofVersion20; { Version two dialog }
  973. GrowMode := 0; { Clear grow mode }
  974. Flags := wfMove + wfClose; { Close/moveable flags }
  975. Palette := dpGrayDialog; { Default gray colours }
  976. END;
  977. {--TDialog------------------------------------------------------------------}
  978. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  979. {---------------------------------------------------------------------------}
  980. CONSTRUCTOR TDialog.Load (Var S: TStream);
  981. BEGIN
  982. Inherited Load(S); { Call ancestor }
  983. If (Options AND ofVersion = ofVersion10) Then Begin
  984. Palette := dpGrayDialog; { Set gray palette }
  985. Options := Options OR ofVersion20; { Update version flag }
  986. End;
  987. END;
  988. {--TDialog------------------------------------------------------------------}
  989. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  990. {---------------------------------------------------------------------------}
  991. FUNCTION TDialog.GetPalette: PPalette;
  992. CONST P: Array[dpBlueDialog..dpGrayDialog] Of String[Length(CBlueDialog)] =
  993. (CBlueDialog, CCyanDialog, CGrayDialog); { Always normal string }
  994. BEGIN
  995. GetPalette := PPalette(@P[Palette]); { Return palette }
  996. END;
  997. {--TDialog------------------------------------------------------------------}
  998. { Valid -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 25Apr98 LdB }
  999. {---------------------------------------------------------------------------}
  1000. FUNCTION TDialog.Valid (Command: Word): Boolean;
  1001. BEGIN
  1002. If (Command = cmCancel) Then Valid := True { Cancel returns true }
  1003. Else Valid := TGroup.Valid(Command); { Call group ancestor }
  1004. END;
  1005. {--TDialog------------------------------------------------------------------}
  1006. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1007. {---------------------------------------------------------------------------}
  1008. PROCEDURE TDialog.HandleEvent (Var Event: TEvent);
  1009. BEGIN
  1010. Inherited HandleEvent(Event); { Call ancestor }
  1011. Case Event.What Of
  1012. evNothing: Exit; { Speed up exit }
  1013. evKeyDown: { Key down event }
  1014. Case Event.KeyCode Of
  1015. kbEsc, kbCtrlF4: Begin { Escape key press }
  1016. Event.What := evCommand; { Command event }
  1017. Event.Command := cmCancel; { cancel command }
  1018. Event.InfoPtr := Nil; { Clear info ptr }
  1019. PutEvent(Event); { Put event on queue }
  1020. ClearEvent(Event); { Clear the event }
  1021. End;
  1022. kbCtrlF5: Begin { movement of modal dialogs }
  1023. If (State AND sfModal <> 0) Then
  1024. begin
  1025. Event.What := evCommand;
  1026. Event.Command := cmResize;
  1027. Event.InfoPtr := Nil;
  1028. PutEvent(Event);
  1029. ClearEvent(Event);
  1030. end;
  1031. End;
  1032. kbEnter: Begin { Enter key press }
  1033. Event.What := evBroadcast; { Broadcast event }
  1034. Event.Command := cmDefault; { Default command }
  1035. Event.InfoPtr := Nil; { Clear info ptr }
  1036. PutEvent(Event); { Put event on queue }
  1037. ClearEvent(Event); { Clear the event }
  1038. End;
  1039. End;
  1040. evCommand: { Command event }
  1041. Case Event.Command Of
  1042. cmOk, cmCancel, cmYes, cmNo: { End dialog cmds }
  1043. If (State AND sfModal <> 0) Then Begin { View is modal }
  1044. EndModal(Event.Command); { End modal state }
  1045. ClearEvent(Event); { Clear the event }
  1046. End;
  1047. End;
  1048. End;
  1049. END;
  1050. {****************************************************************************}
  1051. { TDialog.Cancel }
  1052. {****************************************************************************}
  1053. procedure TDialog.Cancel (ACommand : Word);
  1054. begin
  1055. if State and sfModal = sfModal then
  1056. EndModal(ACommand)
  1057. else Close;
  1058. end;
  1059. {****************************************************************************}
  1060. { TDialog.ChangeTitle }
  1061. {****************************************************************************}
  1062. procedure TDialog.ChangeTitle (ANewTitle : TTitleStr);
  1063. begin
  1064. if (Title <> nil) then
  1065. DisposeStr(Title);
  1066. Title := NewStr(ANewTitle);
  1067. Frame^.DrawView;
  1068. end;
  1069. {****************************************************************************}
  1070. { TDialog.FreeSubView }
  1071. {****************************************************************************}
  1072. procedure TDialog.FreeSubView (ASubView : PView);
  1073. begin
  1074. if IsSubView(ASubView) then begin
  1075. Delete(ASubView);
  1076. Dispose(ASubView,Done);
  1077. DrawView;
  1078. end;
  1079. end;
  1080. {****************************************************************************}
  1081. { TDialog.FreeAllSubViews }
  1082. {****************************************************************************}
  1083. procedure TDialog.FreeAllSubViews;
  1084. var
  1085. P : PView;
  1086. begin
  1087. P := First;
  1088. repeat
  1089. P := First;
  1090. if (P <> nil) then begin
  1091. Delete(P);
  1092. Dispose(P,Done);
  1093. end;
  1094. until (P = nil);
  1095. DrawView;
  1096. end;
  1097. {****************************************************************************}
  1098. { TDialog.IsSubView }
  1099. {****************************************************************************}
  1100. function TDialog.IsSubView (AView : PView) : Boolean;
  1101. var P : PView;
  1102. begin
  1103. P := First;
  1104. while (P <> nil) and (P <> AView) do
  1105. P := P^.NextView;
  1106. IsSubView := ((P <> nil) and (P = AView));
  1107. end;
  1108. {****************************************************************************}
  1109. { TDialog.NewButton }
  1110. {****************************************************************************}
  1111. function TDialog.NewButton (X, Y, W, H : Sw_Integer; ATitle : TTitleStr;
  1112. ACommand, AHelpCtx : Word;
  1113. AFlags : Byte) : PButton;
  1114. var
  1115. B : PButton;
  1116. R : TRect;
  1117. begin
  1118. R.Assign(X,Y,X+W,Y+H);
  1119. B := New(PButton,Init(R,ATitle,ACommand,AFlags));
  1120. if (B <> nil) then begin
  1121. B^.HelpCtx := AHelpCtx;
  1122. Insert(B);
  1123. end;
  1124. NewButton := B;
  1125. end;
  1126. {****************************************************************************}
  1127. { TDialog.NewInputLine }
  1128. {****************************************************************************}
  1129. function TDialog.NewInputLine (X, Y, W, AMaxLen : Sw_Integer; AHelpCtx : Word
  1130. ; AValidator : PValidator) : PInputLine;
  1131. var
  1132. P : PInputLine;
  1133. R : TRect;
  1134. begin
  1135. R.Assign(X,Y,X+W,Y+1);
  1136. P := New(PInputLine,Init(R,AMaxLen));
  1137. if (P <> nil) then begin
  1138. P^.SetValidator(AValidator);
  1139. P^.HelpCtx := AHelpCtx;
  1140. Insert(P);
  1141. end;
  1142. NewInputLine := P;
  1143. end;
  1144. {****************************************************************************}
  1145. { TDialog.NewLabel }
  1146. {****************************************************************************}
  1147. function TDialog.NewLabel (X, Y : Sw_Integer; AText : String;
  1148. ALink : PView) : PLabel;
  1149. var
  1150. P : PLabel;
  1151. R : TRect;
  1152. begin
  1153. R.Assign(X,Y,X+CStrLen(AText)+1,Y+1);
  1154. P := New(PLabel,Init(R,AText,ALink));
  1155. if (P <> nil) then
  1156. Insert(P);
  1157. NewLabel := P;
  1158. end;
  1159. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1160. { TInputLine OBJECT METHODS }
  1161. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1162. {--TInputLine---------------------------------------------------------------}
  1163. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1164. {---------------------------------------------------------------------------}
  1165. CONSTRUCTOR TInputLine.Init (Var Bounds: TRect; AMaxLen: Sw_Integer);
  1166. BEGIN
  1167. Inherited Init(Bounds); { Call ancestor }
  1168. State := State OR sfCursorVis; { Cursor visible }
  1169. Options := Options OR (ofSelectable + ofFirstClick
  1170. + ofVersion20); { Set options }
  1171. If (MaxAvail > AMaxLen + 1) Then Begin { Check enough memory }
  1172. GetMem(Data, AMaxLen + 1); { Allocate memory }
  1173. Data^ := ''; { Data = empty string }
  1174. End;
  1175. MaxLen := AMaxLen; { Hold maximum length }
  1176. END;
  1177. {--TInputLine---------------------------------------------------------------}
  1178. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1179. {---------------------------------------------------------------------------}
  1180. CONSTRUCTOR TInputLine.Load (Var S: TStream);
  1181. VAR B: Byte;
  1182. W: Word;
  1183. BEGIN
  1184. Inherited Load(S); { Call ancestor }
  1185. S.Read(W, sizeof(w)); MaxLen:=W; { Read max length }
  1186. S.Read(W, sizeof(w)); CurPos:=w; { Read cursor position }
  1187. S.Read(W, sizeof(w)); FirstPos:=w; { Read first position }
  1188. S.Read(W, sizeof(w)); SelStart:=w; { Read selected start }
  1189. S.Read(W, sizeof(w)); SelEnd:=w; { Read selected end }
  1190. S.Read(B, SizeOf(B)); { Read string length }
  1191. GetMem(Data, B + 1); { Allocate memory }
  1192. S.Read(Data^[1], B); { Read string data }
  1193. SetLength(Data^, B); { Xfer string length }
  1194. If (Options AND ofVersion >= ofVersion20) Then { Version 2 or above }
  1195. Validator := PValidator(S.Get); { Get any validator }
  1196. Options := Options OR ofVersion20; { Set version 2 flag }
  1197. END;
  1198. {--TInputLine---------------------------------------------------------------}
  1199. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1200. {---------------------------------------------------------------------------}
  1201. DESTRUCTOR TInputLine.Done;
  1202. BEGIN
  1203. If (Data <> Nil) Then FreeMem(Data, MaxLen + 1); { Release any memory }
  1204. SetValidator(Nil); { Clear any validator }
  1205. Inherited Done; { Call ancestor }
  1206. END;
  1207. {--TInputLine---------------------------------------------------------------}
  1208. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1209. {---------------------------------------------------------------------------}
  1210. FUNCTION TInputLine.DataSize: Sw_Word;
  1211. VAR DSize: Sw_Word;
  1212. BEGIN
  1213. DSize := 0; { Preset zero datasize }
  1214. If (Validator <> Nil) AND (Data <> Nil) Then
  1215. DSize := Validator^.Transfer(Data^, Nil,
  1216. vtDataSize); { Add validator size }
  1217. If (DSize <> 0) Then DataSize := DSize { Use validtor size }
  1218. Else DataSize := MaxLen + 1; { No validator use size }
  1219. END;
  1220. {--TInputLine---------------------------------------------------------------}
  1221. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1222. {---------------------------------------------------------------------------}
  1223. FUNCTION TInputLine.GetPalette: PPalette;
  1224. CONST P: String[Length(CInputLine)] = CInputLine; { Always normal string }
  1225. BEGIN
  1226. GetPalette := PPalette(@P); { Return palette }
  1227. END;
  1228. {--TInputLine---------------------------------------------------------------}
  1229. { Valid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1230. {---------------------------------------------------------------------------}
  1231. FUNCTION TInputLine.Valid (Command: Word): Boolean;
  1232. FUNCTION AppendError (AValidator: PValidator): Boolean;
  1233. BEGIN
  1234. AppendError := False; { Preset false }
  1235. If (Data <> Nil) Then
  1236. With AValidator^ Do
  1237. If (Options AND voOnAppend <> 0) AND { Check options }
  1238. (CurPos <> Length(Data^)) AND { Exceeds max length }
  1239. NOT IsValidInput(Data^, True) Then Begin { Check data valid }
  1240. Error; { Call error }
  1241. AppendError := True; { Return true }
  1242. End;
  1243. END;
  1244. BEGIN
  1245. Valid := Inherited Valid(Command); { Call ancestor }
  1246. If (Validator <> Nil) AND (Data <> Nil) AND { Validator present }
  1247. (State AND sfDisabled = 0) Then { Not disabled }
  1248. If (Command = cmValid) Then { Valid command }
  1249. Valid := Validator^.Status = vsOk { Validator result }
  1250. Else If (Command <> cmCancel) Then { Not cancel command }
  1251. If AppendError(Validator) OR { Append any error }
  1252. NOT Validator^.Valid(Data^) Then Begin { Check validator }
  1253. Select; { Reselect view }
  1254. Valid := False; { Return false }
  1255. End;
  1256. END;
  1257. {--TInputLine---------------------------------------------------------------}
  1258. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1259. {---------------------------------------------------------------------------}
  1260. PROCEDURE TInputLine.Draw;
  1261. VAR Color: Byte; L, R: Sw_Integer;
  1262. B : TDrawBuffer;
  1263. BEGIN
  1264. if Options and ofSelectable = 0 then
  1265. Color := GetColor(5)
  1266. else
  1267. If (State AND sfFocused = 0) Then
  1268. Color := GetColor(1) { Not focused colour }
  1269. Else
  1270. Color := GetColor(2); { Focused colour }
  1271. MoveChar(B, ' ', Color, Size.X);
  1272. MoveStr(B[1], Copy(Data^, FirstPos + 1, Size.X - 2), Color);
  1273. if CanScroll(1) then
  1274. MoveChar(B[Size.X - 1], RightArr, GetColor(4), 1);
  1275. if (State and sfFocused <> 0) and
  1276. (Options and ofSelectable <> 0) then
  1277. begin
  1278. if CanScroll(-1) then
  1279. MoveChar(B[0], LeftArr, GetColor(4), 1);
  1280. { Highlighted part }
  1281. L := SelStart - FirstPos;
  1282. R := SelEnd - FirstPos;
  1283. if L < 0 then
  1284. L := 0;
  1285. if R > Size.X - 2 then
  1286. R := Size.X - 2;
  1287. if L < R then
  1288. MoveChar(B[L + 1], #0, GetColor(3), R - L);
  1289. SetCursor(CurPos - FirstPos + 1, 0);
  1290. end;
  1291. WriteLine(0, 0, Size.X, Size.Y, B);
  1292. end;
  1293. {--TInputLine---------------------------------------------------------------}
  1294. { DrawCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Oct99 LdB }
  1295. {---------------------------------------------------------------------------}
  1296. PROCEDURE TInputLine.DrawCursor;
  1297. BEGIN
  1298. If (State AND sfFocused <> 0) Then
  1299. Begin { Focused window }
  1300. Cursor.Y:=0;
  1301. Cursor.X:=CurPos-FirstPos+1;
  1302. ResetCursor;
  1303. end;
  1304. END;
  1305. {--TInputLine---------------------------------------------------------------}
  1306. { SelectAll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1307. {---------------------------------------------------------------------------}
  1308. PROCEDURE TInputLine.SelectAll (Enable: Boolean);
  1309. BEGIN
  1310. CurPos := 0; { Cursor to start }
  1311. FirstPos := 0; { First pos to start }
  1312. SelStart := 0; { Selected at start }
  1313. If Enable AND (Data <> Nil) Then
  1314. SelEnd := Length(Data^) Else SelEnd := 0; { Selected which end }
  1315. DrawView; { Now redraw the view }
  1316. END;
  1317. {--TInputLine---------------------------------------------------------------}
  1318. { SetValidator -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1319. {---------------------------------------------------------------------------}
  1320. PROCEDURE TInputLine.SetValidator (AValid: PValidator);
  1321. BEGIN
  1322. If (Validator <> Nil) Then Validator^.Free; { Release validator }
  1323. Validator := AValid; { Set new validator }
  1324. END;
  1325. {--TInputLine---------------------------------------------------------------}
  1326. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1327. {---------------------------------------------------------------------------}
  1328. PROCEDURE TInputLine.SetState (AState: Word; Enable: Boolean);
  1329. BEGIN
  1330. Inherited SetState(AState, Enable); { Call ancestor }
  1331. If (AState = sfSelected) OR ((AState = sfActive)
  1332. AND (State and sfSelected <> 0)) Then
  1333. SelectAll(Enable) Else { Call select all }
  1334. If (AState = sfFocused) Then DrawView; { Redraw for focus }
  1335. END;
  1336. {--TInputLine---------------------------------------------------------------}
  1337. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1338. {---------------------------------------------------------------------------}
  1339. PROCEDURE TInputLine.GetData (Var Rec);
  1340. BEGIN
  1341. If (Data <> Nil) Then Begin { Data ptr valid }
  1342. If (Validator = Nil) OR (Validator^.Transfer(Data^,
  1343. @Rec, vtGetData) = 0) Then Begin { No validator/data }
  1344. FillChar(Rec, DataSize, #0); { Clear the data area }
  1345. Move(Data^, Rec, Length(Data^) + 1); { Transfer our data }
  1346. End;
  1347. End Else FillChar(Rec, DataSize, #0); { Clear the data area }
  1348. END;
  1349. {--TInputLine---------------------------------------------------------------}
  1350. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1351. {---------------------------------------------------------------------------}
  1352. PROCEDURE TInputLine.SetData (Var Rec);
  1353. BEGIN
  1354. If (Data <> Nil) Then Begin { Data ptr valid }
  1355. If (Validator = Nil) OR (Validator^.Transfer(
  1356. Data^, @Rec, vtSetData) = 0) Then { No validator/data }
  1357. Move(Rec, Data^[0], DataSize); { Set our data }
  1358. End;
  1359. SelectAll(True); { Now select all }
  1360. END;
  1361. {--TInputLine---------------------------------------------------------------}
  1362. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1363. {---------------------------------------------------------------------------}
  1364. PROCEDURE TInputLine.Store (Var S: TStream);
  1365. VAR w: Word;
  1366. BEGIN
  1367. TView.Store(S); { Implict TView.Store }
  1368. w:=MaxLen;S.Write(w, SizeOf(w)); { Read max length }
  1369. w:=CurPos;S.Write(w, SizeOf(w)); { Read cursor position }
  1370. w:=FirstPos;S.Write(w, SizeOf(w)); { Read first position }
  1371. w:=SelStart;S.Write(w, SizeOf(w)); { Read selected start }
  1372. w:=SelEnd;S.Write(w, SizeOf(w)); { Read selected end }
  1373. S.WriteStr(Data); { Write the data }
  1374. S.Put(Validator); { Write any validator }
  1375. END;
  1376. {--TInputLine---------------------------------------------------------------}
  1377. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1378. {---------------------------------------------------------------------------}
  1379. PROCEDURE TInputLine.HandleEvent (Var Event: TEvent);
  1380. CONST PadKeys = [$47, $4B, $4D, $4F, $73, $74];
  1381. VAR WasAppending: Boolean; ExtendBlock: Boolean; OldData: String;
  1382. Delta, Anchor, OldCurPos, OldFirstPos, OldSelStart, OldSelEnd: Sw_Integer;
  1383. FUNCTION MouseDelta: Sw_Integer;
  1384. VAR Mouse : TPOint;
  1385. BEGIN
  1386. MakeLocal(Event.Where, Mouse);
  1387. if Mouse.X <= 0 then
  1388. MouseDelta := -1
  1389. else if Mouse.X >= Size.X - 1 then
  1390. MouseDelta := 1
  1391. else
  1392. MouseDelta := 0;
  1393. END;
  1394. FUNCTION MousePos: Sw_Integer;
  1395. VAR Pos: Sw_Integer;
  1396. Mouse : TPoint;
  1397. BEGIN
  1398. MakeLocal(Event.Where, Mouse);
  1399. if Mouse.X < 1 then Mouse.X := 1;
  1400. Pos := Mouse.X + FirstPos - 1;
  1401. if Pos < 0 then Pos := 0;
  1402. if Pos > Length(Data^) then Pos := Length(Data^);
  1403. MousePos := Pos;
  1404. END;
  1405. PROCEDURE DeleteSelect;
  1406. BEGIN
  1407. If (SelStart <> SelEnd) Then Begin { An area selected }
  1408. If (Data <> Nil) Then
  1409. Delete(Data^, SelStart+1, SelEnd-SelStart); { Delete the text }
  1410. CurPos := SelStart; { Set cursor position }
  1411. End;
  1412. END;
  1413. PROCEDURE AdjustSelectBlock;
  1414. BEGIN
  1415. If (CurPos < Anchor) Then Begin { Selection backwards }
  1416. SelStart := CurPos; { Start of select }
  1417. SelEnd := Anchor; { End of select }
  1418. End Else Begin
  1419. SelStart := Anchor; { Start of select }
  1420. SelEnd := CurPos; { End of select }
  1421. End;
  1422. END;
  1423. PROCEDURE SaveState;
  1424. BEGIN
  1425. If (Validator <> Nil) Then Begin { Check for validator }
  1426. If (Data <> Nil) Then OldData := Data^; { Hold data }
  1427. OldCurPos := CurPos; { Hold cursor position }
  1428. OldFirstPos := FirstPos; { Hold first position }
  1429. OldSelStart := SelStart; { Hold select start }
  1430. OldSelEnd := SelEnd; { Hold select end }
  1431. If (Data = Nil) Then WasAppending := True { Invalid data ptr }
  1432. Else WasAppending := Length(Data^) = CurPos; { Hold appending state }
  1433. End;
  1434. END;
  1435. PROCEDURE RestoreState;
  1436. BEGIN
  1437. If (Validator <> Nil) Then Begin { Validator valid }
  1438. If (Data <> Nil) Then Data^ := OldData; { Restore data }
  1439. CurPos := OldCurPos; { Restore cursor pos }
  1440. FirstPos := OldFirstPos; { Restore first pos }
  1441. SelStart := OldSelStart; { Restore select start }
  1442. SelEnd := OldSelEnd; { Restore select end }
  1443. End;
  1444. END;
  1445. FUNCTION CheckValid (NoAutoFill: Boolean): Boolean;
  1446. VAR OldLen: Sw_Integer; NewData: String;
  1447. BEGIN
  1448. If (Validator <> Nil) Then Begin { Validator valid }
  1449. CheckValid := False; { Preset false return }
  1450. If (Data <> Nil) Then OldLen := Length(Data^); { Hold old length }
  1451. If (Validator^.Options AND voOnAppend = 0) OR
  1452. (WasAppending AND (CurPos = OldLen)) Then Begin
  1453. If (Data <> Nil) Then NewData := Data^ { Hold current data }
  1454. Else NewData := ''; { Set empty string }
  1455. If NOT Validator^.IsValidInput(NewData,
  1456. NoAutoFill) Then RestoreState Else Begin
  1457. If (Length(NewData) > MaxLen) Then { Exceeds maximum }
  1458. SetLength(NewData, MaxLen); { Set string length }
  1459. If (Data <> Nil) Then Data^ := NewData; { Set data value }
  1460. If (Data <> Nil) AND (CurPos >= OldLen) { Cursor beyond end }
  1461. AND (Length(Data^) > OldLen) Then { Cursor beyond string }
  1462. CurPos := Length(Data^); { Set cursor position }
  1463. CheckValid := True; { Return true result }
  1464. End;
  1465. End Else Begin
  1466. CheckValid := True; { Preset true return }
  1467. If (CurPos = OldLen) AND (Data <> Nil) Then { Lengths match }
  1468. If NOT Validator^.IsValidInput(Data^,
  1469. False) Then Begin { Check validator }
  1470. Validator^.Error; { Call error }
  1471. CheckValid := False; { Return false result }
  1472. End;
  1473. End;
  1474. End Else CheckValid := True; { No validator }
  1475. END;
  1476. BEGIN
  1477. Inherited HandleEvent(Event); { Call ancestor }
  1478. If (State AND sfSelected <> 0) Then Begin { View is selected }
  1479. Case Event.What Of
  1480. evNothing: Exit; { Speed up exit }
  1481. evMouseDown: Begin { Mouse down event }
  1482. Delta := MouseDelta; { Calc scroll value }
  1483. If CanScroll(Delta) Then Begin { Can scroll }
  1484. Repeat
  1485. If CanScroll(Delta) Then Begin { Still can scroll }
  1486. Inc(FirstPos, Delta); { Move start position }
  1487. DrawView; { Redraw the view }
  1488. End;
  1489. Until NOT MouseEvent(Event, evMouseAuto); { Until no mouse auto }
  1490. End Else If Event.Double Then { Double click }
  1491. SelectAll(True) Else Begin { Select whole text }
  1492. Anchor := MousePos; { Start of selection }
  1493. Repeat
  1494. If (Event.What = evMouseAuto) { Mouse auto event }
  1495. Then Begin
  1496. Delta := MouseDelta; { New position }
  1497. If CanScroll(Delta) Then { If can scroll }
  1498. Inc(FirstPos, Delta);
  1499. End;
  1500. CurPos := MousePos; { Set cursor position }
  1501. AdjustSelectBlock; { Adjust selected }
  1502. DrawView; { Redraw the view }
  1503. Until NOT MouseEvent(Event, evMouseMove
  1504. + evMouseAuto); { Until mouse released }
  1505. End;
  1506. ClearEvent(Event); { Clear the event }
  1507. End;
  1508. evKeyDown: Begin
  1509. SaveState; { Save state of view }
  1510. Event.KeyCode := CtrlToArrow(Event.KeyCode); { Convert keycode }
  1511. If (Event.ScanCode IN PadKeys) AND
  1512. (GetShiftState AND $03 <> 0) Then Begin { Mark selection active }
  1513. Event.CharCode := #0; { Clear char code }
  1514. If (CurPos = SelEnd) Then { Find if at end }
  1515. Anchor := SelStart Else { Anchor from start }
  1516. Anchor := SelEnd; { Anchor from end }
  1517. ExtendBlock := True; { Extended block true }
  1518. End Else ExtendBlock := False; { No extended block }
  1519. Case Event.KeyCode Of
  1520. kbLeft: If (CurPos > 0) Then Dec(CurPos); { Move cursor left }
  1521. kbRight: If (Data <> Nil) AND { Move right cursor }
  1522. (CurPos < Length(Data^)) Then Begin { Check not at end }
  1523. Inc(CurPos); { Move cursor }
  1524. CheckValid(True); { Check if valid }
  1525. End;
  1526. kbHome: CurPos := 0; { Move to line start }
  1527. kbEnd: Begin { Move to line end }
  1528. If (Data = Nil) Then CurPos := 0 { Invalid data ptr }
  1529. Else CurPos := Length(Data^); { Set cursor position }
  1530. CheckValid(True); { Check if valid }
  1531. End;
  1532. kbBack: If (Data <> Nil) AND (CurPos > 0) { Not at line start }
  1533. Then Begin
  1534. Delete(Data^, CurPos, 1); { Backspace over char }
  1535. Dec(CurPos); { Move cursor back one }
  1536. If (FirstPos > 0) Then Dec(FirstPos); { Move first position }
  1537. CheckValid(True); { Check if valid }
  1538. End;
  1539. kbDel: If (Data <> Nil) Then Begin { Delete character }
  1540. If (SelStart = SelEnd) Then { Select all on }
  1541. If (CurPos < Length(Data^)) Then Begin { Cursor not at end }
  1542. SelStart := CurPos; { Set select start }
  1543. SelEnd := CurPos + 1; { Set select end }
  1544. End;
  1545. DeleteSelect; { Deselect selection }
  1546. CheckValid(True); { Check if valid }
  1547. End;
  1548. kbIns: SetState(sfCursorIns, State AND
  1549. sfCursorIns = 0); { Flip insert state }
  1550. Else Case Event.CharCode Of
  1551. ' '..#255: If (Data <> Nil) Then Begin { Character key }
  1552. If (State AND sfCursorIns <> 0) Then
  1553. Delete(Data^, CurPos + 1, 1) Else { Overwrite character }
  1554. DeleteSelect; { Deselect selected }
  1555. If CheckValid(True) Then Begin { Check data valid }
  1556. If (Length(Data^) < MaxLen) Then { Must not exceed maxlen }
  1557. Begin
  1558. If (FirstPos > CurPos) Then
  1559. FirstPos := CurPos; { Advance first position }
  1560. Inc(CurPos); { Increment cursor }
  1561. Insert(Event.CharCode, Data^,
  1562. CurPos); { Insert the character }
  1563. End;
  1564. CheckValid(False); { Check data valid }
  1565. End;
  1566. End;
  1567. ^Y: If (Data <> Nil) Then Begin { Clear all data }
  1568. Data^ := ''; { Set empty string }
  1569. CurPos := 0; { Cursor to start }
  1570. End;
  1571. Else Exit; { Unused key }
  1572. End
  1573. End;
  1574. If ExtendBlock Then AdjustSelectBlock { Extended block }
  1575. Else Begin
  1576. SelStart := CurPos; { Set select start }
  1577. SelEnd := CurPos; { Set select end }
  1578. End;
  1579. If (FirstPos > CurPos) Then
  1580. FirstPos := CurPos; { Advance first pos }
  1581. If (Data <> Nil) Then OldData := Copy(Data^,
  1582. FirstPos+1, CurPos-FirstPos) { Text area string }
  1583. Else OldData := ''; { Empty string }
  1584. Delta := 1; { Safety = 1 char }
  1585. While (TextWidth(OldData) > (Size.X-Delta)
  1586. - TextWidth(LeftArr) - TextWidth(RightArr)) { Check text fits }
  1587. Do Begin
  1588. Inc(FirstPos); { Advance first pos }
  1589. OldData := Copy(Data^, FirstPos+1,
  1590. CurPos-FirstPos) { Text area string }
  1591. End;
  1592. DrawView; { Redraw the view }
  1593. ClearEvent(Event); { Clear the event }
  1594. End;
  1595. End;
  1596. End;
  1597. END;
  1598. {***************************************************************************}
  1599. { TInputLine OBJECT PRIVATE METHODS }
  1600. {***************************************************************************}
  1601. {--TInputLine---------------------------------------------------------------}
  1602. { CanScroll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1603. {---------------------------------------------------------------------------}
  1604. FUNCTION TInputLine.CanScroll (Delta: Sw_Integer): Boolean;
  1605. VAR S: String;
  1606. BEGIN
  1607. If (Delta < 0) Then CanScroll := FirstPos > 0 { Check scroll left }
  1608. Else If (Delta > 0) Then Begin
  1609. If (Data = Nil) Then S := '' Else { Data ptr invalid }
  1610. S := Copy(Data^, FirstPos+1, Length(Data^)
  1611. - FirstPos); { Fetch max string }
  1612. CanScroll := (TextWidth(S)) > (Size.X -
  1613. TextWidth(LeftArr) - TextWidth(RightArr)); { Check scroll right }
  1614. End Else CanScroll := False; { Zero so no scroll }
  1615. END;
  1616. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1617. { TButton OBJECT METHODS }
  1618. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1619. {--TButton------------------------------------------------------------------}
  1620. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1621. {---------------------------------------------------------------------------}
  1622. CONSTRUCTOR TButton.Init (Var Bounds: TRect; ATitle: TTitleStr;
  1623. ACommand: Word; AFlags: Word);
  1624. BEGIN
  1625. Inherited Init(Bounds); { Call ancestor }
  1626. EventMask := EventMask OR evBroadcast; { Handle broadcasts }
  1627. Options := Options OR (ofSelectable + ofFirstClick
  1628. + ofPreProcess + ofPostProcess); { Set option flags }
  1629. If NOT CommandEnabled(ACommand) Then
  1630. State := State OR sfDisabled; { Check command state }
  1631. Flags := AFlags; { Hold flags }
  1632. If (AFlags AND bfDefault <> 0) Then AmDefault := True
  1633. Else AmDefault := False; { Check if default }
  1634. Title := NewStr(ATitle); { Hold title string }
  1635. Command := ACommand; { Hold button command }
  1636. TabMask := TabMask OR (tmLeft + tmRight +
  1637. tmTab + tmShiftTab + tmUp + tmDown); { Set tab masks }
  1638. END;
  1639. {--TButton------------------------------------------------------------------}
  1640. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1641. {---------------------------------------------------------------------------}
  1642. CONSTRUCTOR TButton.Load (Var S: TStream);
  1643. BEGIN
  1644. Inherited Load(S); { Call ancestor }
  1645. Title := S.ReadStr; { Read title }
  1646. S.Read(Command, SizeOf(Command)); { Read command }
  1647. S.Read(Flags, SizeOf(Flags)); { Read flags }
  1648. S.Read(AmDefault, SizeOf(AmDefault)); { Read if default }
  1649. If NOT CommandEnabled(Command) Then { Check command state }
  1650. State := State OR sfDisabled Else { Command disabled }
  1651. State := State AND NOT sfDisabled; { Command enabled }
  1652. END;
  1653. {--TButton------------------------------------------------------------------}
  1654. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1655. {---------------------------------------------------------------------------}
  1656. DESTRUCTOR TButton.Done;
  1657. BEGIN
  1658. If (Title <> Nil) Then DisposeStr(Title); { Dispose title }
  1659. Inherited Done; { Call ancestor }
  1660. END;
  1661. {--TButton------------------------------------------------------------------}
  1662. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1663. {---------------------------------------------------------------------------}
  1664. FUNCTION TButton.GetPalette: PPalette;
  1665. CONST P: String[Length(CButton)] = CButton; { Always normal string }
  1666. BEGIN
  1667. GetPalette := PPalette(@P); { Get button palette }
  1668. END;
  1669. {--TButton------------------------------------------------------------------}
  1670. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Apr98 LdB }
  1671. {---------------------------------------------------------------------------}
  1672. PROCEDURE TButton.Press;
  1673. VAR E: TEvent;
  1674. BEGIN
  1675. Message(Owner, evBroadcast, cmRecordHistory, Nil); { Message for history }
  1676. If (Flags AND bfBroadcast <> 0) Then { Broadcasting button }
  1677. Message(Owner, evBroadcast, Command, @Self) { Send message }
  1678. Else Begin
  1679. E.What := evCommand; { Command event }
  1680. E.Command := Command; { Set command value }
  1681. E.InfoPtr := @Self; { Pointer to self }
  1682. PutEvent(E); { Put event on queue }
  1683. End;
  1684. END;
  1685. {--TButton------------------------------------------------------------------}
  1686. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1687. {---------------------------------------------------------------------------}
  1688. PROCEDURE TButton.Draw;
  1689. VAR I, J, Pos: Sw_Integer;
  1690. Bc: Word; Db: TDrawBuffer;
  1691. C : char;
  1692. BEGIN
  1693. If (State AND sfDisabled <> 0) Then { Button disabled }
  1694. Bc := GetColor($0404) Else Begin { Disabled colour }
  1695. Bc := GetColor($0501); { Set normal colour }
  1696. If (State AND sfActive <> 0) Then { Button is active }
  1697. If (State AND sfSelected <> 0) Then
  1698. Bc := GetColor($0703) Else { Set selected colour }
  1699. If AmDefault Then Bc := GetColor($0602); { Set is default colour }
  1700. End;
  1701. if title=nil then
  1702. begin
  1703. MoveChar(Db[0],' ',GetColor(8),1);
  1704. {No title, draw an empty button.}
  1705. for j:=sw_integer(downflag) to size.x-2 do
  1706. MoveChar(Db[j],' ',Bc,1);
  1707. end
  1708. else
  1709. {We have a title.}
  1710. begin
  1711. If (Flags AND bfLeftJust = 0) Then Begin { Not left set title }
  1712. I := CTextWidth(Title^); { Fetch title width }
  1713. I := (Size.X - I) DIV 2; { Centre in button }
  1714. End
  1715. Else
  1716. I := 1; { Left edge of button }
  1717. If DownFlag then
  1718. begin
  1719. MoveChar(Db[0],' ',GetColor(8),1);
  1720. Pos:=1;
  1721. end
  1722. else
  1723. pos:=0;
  1724. For j:=0 to I-1 do
  1725. MoveChar(Db[pos+j],' ',Bc,1);
  1726. MoveCStr(Db[I+pos], Title^, Bc); { Move title to buffer }
  1727. For j:=pos+CStrLen(Title^)+I to size.X-2 do
  1728. MoveChar(Db[j],' ',Bc,1);
  1729. end;
  1730. If not DownFlag then
  1731. Bc:=GetColor(8);
  1732. MoveChar(Db[Size.X-1],' ',Bc,1);
  1733. WriteLine(0, 0, Size.X,1, Db); { Write the title }
  1734. If Size.Y>1 then Begin
  1735. Bc:=GetColor(8);
  1736. if not DownFlag then
  1737. begin
  1738. c:='Ü';
  1739. MoveChar(Db,c,Bc,1);
  1740. WriteLine(Size.X-1, 0, 1, 1, Db);
  1741. end;
  1742. MoveChar(Db,' ',Bc,1);
  1743. if DownFlag then c:=' '
  1744. else c:='ß';
  1745. MoveChar(Db[1],c,Bc,Size.X-1);
  1746. WriteLine(0, 1, Size.X, 1, Db);
  1747. End;
  1748. END;
  1749. {--TButton------------------------------------------------------------------}
  1750. { DrawState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1751. {---------------------------------------------------------------------------}
  1752. PROCEDURE TButton.DrawState (Down: Boolean);
  1753. BEGIN
  1754. DownFlag := Down; { Set down flag }
  1755. DrawView; { Redraw the view }
  1756. END;
  1757. {--TButton------------------------------------------------------------------}
  1758. { MakeDefault -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1759. {---------------------------------------------------------------------------}
  1760. PROCEDURE TButton.MakeDefault (Enable: Boolean);
  1761. VAR C: Word;
  1762. BEGIN
  1763. If (Flags AND bfDefault=0) Then Begin { Not default }
  1764. If Enable Then C := cmGrabDefault
  1765. Else C := cmReleaseDefault; { Change default }
  1766. Message(Owner, evBroadcast, C, @Self); { Message to owner }
  1767. AmDefault := Enable; { Set default flag }
  1768. DrawView; { Now redraw button }
  1769. End;
  1770. END;
  1771. {--TButton------------------------------------------------------------------}
  1772. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1773. {---------------------------------------------------------------------------}
  1774. PROCEDURE TButton.SetState (AState: Word; Enable: Boolean);
  1775. BEGIN
  1776. Inherited SetState(AState, Enable); { Call ancestor }
  1777. If (AState AND (sfSelected + sfActive) <> 0) { Changing select }
  1778. Then DrawView; { Redraw required }
  1779. If (AState AND sfFocused <> 0) Then
  1780. MakeDefault(Enable); { Check for default }
  1781. END;
  1782. {--TButton------------------------------------------------------------------}
  1783. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  1784. {---------------------------------------------------------------------------}
  1785. PROCEDURE TButton.Store (Var S: TStream);
  1786. BEGIN
  1787. TView.Store(S); { Implict TView.Store }
  1788. S.WriteStr(Title); { Store title string }
  1789. S.Write(Command, SizeOf(Command)); { Store command }
  1790. S.Write(Flags, SizeOf(Flags)); { Store flags }
  1791. S.Write(AmDefault, SizeOf(AmDefault)); { Store default flag }
  1792. END;
  1793. {--TButton------------------------------------------------------------------}
  1794. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Sep99 LdB }
  1795. {---------------------------------------------------------------------------}
  1796. PROCEDURE TButton.HandleEvent (Var Event: TEvent);
  1797. VAR Down: Boolean; C: Char; ButRect: TRect;
  1798. Mouse : TPoint;
  1799. BEGIN
  1800. ButRect.A.X := 0; { Get origin point }
  1801. ButRect.A.Y := 0; { Get origin point }
  1802. ButRect.B.X := Size.X + 2; { Calc right side }
  1803. ButRect.B.Y := Size.Y + 1; { Calc bottom }
  1804. If (Event.What = evMouseDown) Then Begin { Mouse down event }
  1805. MakeLocal(Event.Where, Mouse);
  1806. If NOT ButRect.Contains(Mouse) Then Begin { If point not in view }
  1807. ClearEvent(Event); { Clear the event }
  1808. Exit; { Speed up exit }
  1809. End;
  1810. End;
  1811. If (Flags AND bfGrabFocus <> 0) Then { Check focus grab }
  1812. Inherited HandleEvent(Event); { Call ancestor }
  1813. Case Event.What Of
  1814. evNothing: Exit; { Speed up exit }
  1815. evMouseDown: Begin
  1816. If (State AND sfDisabled = 0) Then Begin { Button not disabled }
  1817. Down := False; { Clear down flag }
  1818. Repeat
  1819. MakeLocal(Event.Where, Mouse);
  1820. If (Down <> ButRect.Contains(Mouse)) { State has changed }
  1821. Then Begin
  1822. Down := NOT Down; { Invert down flag }
  1823. DrawState(Down); { Redraw button }
  1824. End;
  1825. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse move }
  1826. If Down Then Begin { Button is down }
  1827. Press; { Send out command }
  1828. DrawState(False); { Draw button up }
  1829. End;
  1830. End;
  1831. ClearEvent(Event); { Event was handled }
  1832. End;
  1833. evKeyDown: Begin
  1834. If (Title <> Nil) Then C := HotKey(Title^) { Key title hotkey }
  1835. Else C := #0; { Invalid title }
  1836. If (Event.KeyCode = GetAltCode(C)) OR { Alt char }
  1837. (Owner^.Phase = phPostProcess) AND (C <> #0)
  1838. AND (Upcase(Event.CharCode) = C) OR { Matches hotkey }
  1839. (State AND sfFocused <> 0) AND { View focused }
  1840. ((Event.CharCode = ' ') OR { Space bar }
  1841. (Event.KeyCode=kbEnter)) Then Begin { Enter key }
  1842. DrawState(True); { Draw button down }
  1843. Press; { Send out command }
  1844. ClearEvent(Event); { Clear the event }
  1845. DrawState(False); { Draw button up }
  1846. End;
  1847. End;
  1848. evBroadcast:
  1849. Case Event.Command of
  1850. cmDefault: If AmDefault AND { Default command }
  1851. (State AND sfDisabled = 0) Then Begin { Button enabled }
  1852. Press; { Send out command }
  1853. ClearEvent(Event); { Clear the event }
  1854. End;
  1855. cmGrabDefault, cmReleaseDefault: { Grab and release cmd }
  1856. If (Flags AND bfDefault <> 0) Then Begin { Change button state }
  1857. AmDefault := Event.Command = cmReleaseDefault;
  1858. DrawView; { Redraw the view }
  1859. End;
  1860. cmCommandSetChanged: Begin { Command set changed }
  1861. SetState(sfDisabled, NOT
  1862. CommandEnabled(Command)); { Set button state }
  1863. DrawView; { Redraw the view }
  1864. End;
  1865. End;
  1866. End;
  1867. END;
  1868. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1869. { TCluster OBJECT METHODS }
  1870. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1871. CONST TvClusterClassName = 'TVCLUSTER';
  1872. {--TCluster-----------------------------------------------------------------}
  1873. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  1874. {---------------------------------------------------------------------------}
  1875. CONSTRUCTOR TCluster.Init (Var Bounds: TRect; AStrings: PSItem);
  1876. VAR I: Sw_Integer; P: PSItem;
  1877. BEGIN
  1878. Inherited Init(Bounds); { Call ancestor }
  1879. Options := Options OR (ofSelectable + ofFirstClick
  1880. + ofPreProcess + ofPostProcess + ofVersion20); { Set option masks }
  1881. I := 0; { Zero string count }
  1882. P := AStrings; { First item }
  1883. While (P <> Nil) Do Begin
  1884. Inc(I); { Count 1 item }
  1885. P := P^.Next; { Move to next item }
  1886. End;
  1887. Strings.Init(I, 0); { Create collection }
  1888. While (AStrings <> Nil) Do Begin
  1889. P := AStrings; { Transfer item ptr }
  1890. Strings.AtInsert(Strings.Count, AStrings^.Value);{ Insert string }
  1891. AStrings := AStrings^.Next; { Move to next item }
  1892. Dispose(P); { Dispose prior item }
  1893. End;
  1894. Sel := 0;
  1895. SetCursor(2,0);
  1896. ShowCursor;
  1897. EnableMask := Sw_Integer($FFFFFFFF); { Enable bit masks }
  1898. END;
  1899. {--TCluster-----------------------------------------------------------------}
  1900. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Oct99 LdB }
  1901. {---------------------------------------------------------------------------}
  1902. CONSTRUCTOR TCluster.Load (Var S: TStream);
  1903. VAR w: word;
  1904. BEGIN
  1905. Inherited Load(S); { Call ancestor }
  1906. If ((Options AND ofVersion) >= ofVersion20) Then { Version 2 TV view }
  1907. Begin
  1908. S.Read(Value, SizeOf(Value)); { Read value }
  1909. S.Read(Sel, Sizeof(Sel)); { Read select item }
  1910. S.Read(EnableMask, SizeOf(EnableMask)) { Read enable masks }
  1911. End
  1912. Else
  1913. Begin
  1914. w:=Value;
  1915. S.Read(w, SizeOf(w)); Value:=w; { Read value }
  1916. S.Read(Sel, SizeOf(Sel)); { Read select item }
  1917. EnableMask := Sw_integer($FFFFFFFF); { Enable all masks }
  1918. Options := Options OR ofVersion20; { Set version 2 mask }
  1919. End;
  1920. Strings.Load(S); { Load string data }
  1921. SetButtonState(0, True); { Set button state }
  1922. END;
  1923. {--TCluster-----------------------------------------------------------------}
  1924. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  1925. {---------------------------------------------------------------------------}
  1926. DESTRUCTOR TCluster.Done;
  1927. BEGIN
  1928. Strings.Done; { Dispose of strings }
  1929. Inherited Done; { Call ancestor }
  1930. END;
  1931. {--TCluster-----------------------------------------------------------------}
  1932. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1933. {---------------------------------------------------------------------------}
  1934. FUNCTION TCluster.DataSize: Sw_Word;
  1935. BEGIN
  1936. DataSize := SizeOf(Sw_Word); { Exchanges a word }
  1937. END;
  1938. {--TCluster-----------------------------------------------------------------}
  1939. { GetHelpCtx -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1940. {---------------------------------------------------------------------------}
  1941. FUNCTION TCluster.GetHelpCtx: Word;
  1942. BEGIN
  1943. If (HelpCtx = hcNoContext) Then { View has no help }
  1944. GetHelpCtx := hcNoContext Else { No help context }
  1945. GetHelpCtx := HelpCtx + Sel; { Help of selected }
  1946. END;
  1947. {--TCluster-----------------------------------------------------------------}
  1948. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1949. {---------------------------------------------------------------------------}
  1950. FUNCTION TCluster.GetPalette: PPalette;
  1951. CONST P: String[Length(CCluster)] = CCluster; { Always normal string }
  1952. BEGIN
  1953. GetPalette := PPalette(@P); { Cluster palette }
  1954. END;
  1955. {--TCluster-----------------------------------------------------------------}
  1956. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1957. {---------------------------------------------------------------------------}
  1958. FUNCTION TCluster.Mark (Item: Sw_Integer): Boolean;
  1959. BEGIN
  1960. Mark := False; { Default false }
  1961. END;
  1962. {--TCluster-----------------------------------------------------------------}
  1963. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1964. {---------------------------------------------------------------------------}
  1965. FUNCTION TCluster.MultiMark (Item: Sw_Integer): Byte;
  1966. BEGIN
  1967. MultiMark := Byte(Mark(Item) = True); { Return multi mark }
  1968. END;
  1969. {--TCluster-----------------------------------------------------------------}
  1970. { ButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1971. {---------------------------------------------------------------------------}
  1972. FUNCTION TCluster.ButtonState (Item: Sw_Integer): Boolean;
  1973. BEGIN
  1974. If (Item > 31) Then ButtonState := False Else { Impossible item }
  1975. ButtonState := ((1 SHL Item) AND EnableMask)<>0; { Return true/false }
  1976. END;
  1977. {--TCluster-----------------------------------------------------------------}
  1978. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Jul99 LdB }
  1979. {---------------------------------------------------------------------------}
  1980. PROCEDURE TCluster.Draw;
  1981. BEGIN
  1982. END;
  1983. {--TCluster-----------------------------------------------------------------}
  1984. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1985. {---------------------------------------------------------------------------}
  1986. PROCEDURE TCluster.Press (Item: Sw_Integer);
  1987. VAR P: PView;
  1988. BEGIN
  1989. P := TopView;
  1990. If (Id <> 0) AND (P <> Nil) Then NewMessage(P,
  1991. evCommand, cmIdCommunicate, Id, Value, @Self); { Send new message }
  1992. END;
  1993. {--TCluster-----------------------------------------------------------------}
  1994. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1995. {---------------------------------------------------------------------------}
  1996. PROCEDURE TCluster.MovedTo (Item: Sw_Integer);
  1997. BEGIN { Abstract method }
  1998. END;
  1999. {--TCluster-----------------------------------------------------------------}
  2000. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2001. {---------------------------------------------------------------------------}
  2002. PROCEDURE TCluster.SetState (AState: Word; Enable: Boolean);
  2003. BEGIN
  2004. Inherited SetState(AState, Enable); { Call ancestor }
  2005. If (AState AND sfFocused <> 0) Then Begin
  2006. DrawView; { Redraw masked areas }
  2007. End;
  2008. END;
  2009. {--TCluster-----------------------------------------------------------------}
  2010. { DrawMultiBox -> Platforms DOS/DPMI/WIN/NT - Updated 05Jun98 LdB }
  2011. {---------------------------------------------------------------------------}
  2012. PROCEDURE TCluster.DrawMultiBox (Const Icon, Marker: String);
  2013. VAR I, J, Cur, Col: Sw_Integer; CNorm, CSel, CDis, Color: Word; B: TDrawBuffer;
  2014. BEGIN
  2015. CNorm := GetColor($0301); { Normal colour }
  2016. CSel := GetColor($0402); { Selected colour }
  2017. CDis := GetColor($0505); { Disabled colour }
  2018. For I := 0 To Size.Y-1 Do Begin { For each line }
  2019. MoveChar(B, ' ', Byte(CNorm), Size.X); { Fill buffer }
  2020. For J := 0 To (Strings.Count - 1) DIV Size.Y + 1
  2021. Do Begin
  2022. Cur := J*Size.Y + I; { Current line }
  2023. If (Cur < Strings.Count) Then Begin
  2024. Col := Column(Cur); { Calc column }
  2025. If (Col + CStrLen(PString(Strings.At(Cur))^)+
  2026. 5 < Sizeof(TDrawBuffer) DIV SizeOf(Word))
  2027. AND (Col < Size.X) Then Begin { Text fits in column }
  2028. If NOT ButtonState(Cur) Then
  2029. Color := CDis Else If (Cur = Sel) AND { Disabled colour }
  2030. (State and sfFocused <> 0) Then
  2031. Color := CSel Else { Selected colour }
  2032. Color := CNorm; { Normal colour }
  2033. MoveChar(B[Col], ' ', Byte(Color),
  2034. Size.X-Col); { Set this colour }
  2035. MoveStr(B[Col], Icon, Byte(Color)); { Transfer icon string }
  2036. WordRec(B[Col+2]).Lo := Byte(Marker[
  2037. MultiMark(Cur) + 1]); { Transfer marker }
  2038. MoveCStr(B[Col+5], PString(Strings.At(
  2039. Cur))^, Color); { Transfer item string }
  2040. If ShowMarkers AND (State AND sfFocused <> 0)
  2041. AND (Cur = Sel) Then Begin { Current is selected }
  2042. WordRec(B[Col]).Lo := Byte(SpecialChars[0]);
  2043. WordRec(B[Column(Cur+Size.Y)-1]).Lo
  2044. := Byte(SpecialChars[1]); { Set special character }
  2045. End;
  2046. End;
  2047. End;
  2048. End;
  2049. WriteBuf(0, I, Size.X, 1, B); { Write buffer }
  2050. End;
  2051. SetCursor(Column(Sel)+2,Row(Sel));
  2052. END;
  2053. {--TCluster-----------------------------------------------------------------}
  2054. { DrawBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2055. {---------------------------------------------------------------------------}
  2056. PROCEDURE TCluster.DrawBox (Const Icon: String; Marker: Char);
  2057. BEGIN
  2058. DrawMultiBox(Icon, ' '+Marker); { Call draw routine }
  2059. END;
  2060. {--TCluster-----------------------------------------------------------------}
  2061. { SetButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2062. {---------------------------------------------------------------------------}
  2063. PROCEDURE TCluster.SetButtonState (AMask: Longint; Enable: Boolean);
  2064. VAR I: Sw_Integer; M: Longint;
  2065. BEGIN
  2066. If Enable Then EnableMask := EnableMask OR AMask { Set enable bit mask }
  2067. Else EnableMask := EnableMask AND NOT AMask; { Disable bit mask }
  2068. If (Strings.Count <= 32) Then Begin { Valid string number }
  2069. M := 1; { Preset bit masks }
  2070. For I := 1 To Strings.Count Do Begin { For each item string }
  2071. If ((M AND EnableMask) <> 0) Then Begin { Bit enabled }
  2072. Options := Options OR ofSelectable; { Set selectable option }
  2073. Exit; { Now exit }
  2074. End;
  2075. M := M SHL 1; { Create newbit mask }
  2076. End;
  2077. Options := Options AND NOT ofSelectable; { Make not selectable }
  2078. End;
  2079. END;
  2080. {--TCluster-----------------------------------------------------------------}
  2081. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2082. {---------------------------------------------------------------------------}
  2083. PROCEDURE TCluster.GetData (Var Rec);
  2084. BEGIN
  2085. sw_Word(Rec) := Value; { Return current value }
  2086. END;
  2087. {--TCluster-----------------------------------------------------------------}
  2088. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2089. {---------------------------------------------------------------------------}
  2090. PROCEDURE TCluster.SetData (Var Rec);
  2091. BEGIN
  2092. Value :=sw_Word(Rec); { Set current value }
  2093. DrawView; { Redraw masked areas }
  2094. END;
  2095. {--TCluster-----------------------------------------------------------------}
  2096. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2097. {---------------------------------------------------------------------------}
  2098. PROCEDURE TCluster.Store (Var S: TStream);
  2099. var
  2100. w : word;
  2101. BEGIN
  2102. TView.Store(S); { TView.Store called }
  2103. If ((Options AND ofVersion) >= ofVersion20) { Version 2 TV view }
  2104. Then Begin
  2105. S.Write(Value, SizeOf(Value)); { Write value }
  2106. S.Write(Sel, SizeOf(Sel)); { Write select item }
  2107. S.Write(EnableMask, SizeOf(EnableMask)); { Write enable masks }
  2108. End Else Begin
  2109. w:=Value;
  2110. S.Write(w, SizeOf(Word)); { Write value }
  2111. S.Write(Sel, SizeOf(Sel)); { Write select item }
  2112. End;
  2113. Strings.Store(S); { Store strings }
  2114. END;
  2115. {--TCluster-----------------------------------------------------------------}
  2116. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Jun98 LdB }
  2117. {---------------------------------------------------------------------------}
  2118. PROCEDURE TCluster.HandleEvent (Var Event: TEvent);
  2119. VAR C: Char; I, S, Vh: Sw_Integer; Key: Word; Mouse: TPoint; Ts: PString;
  2120. PROCEDURE MoveSel;
  2121. BEGIN
  2122. If (I <= Strings.Count) Then Begin
  2123. Sel := S; { Set selected item }
  2124. MovedTo(Sel); { Move to selected }
  2125. DrawView; { Now draw changes }
  2126. End;
  2127. END;
  2128. BEGIN
  2129. Inherited HandleEvent(Event); { Call ancestor }
  2130. If ((Options AND ofSelectable) = 0) Then Exit; { Check selectable }
  2131. If (Event.What = evMouseDown) Then Begin { MOUSE EVENT }
  2132. MakeLocal(Event.Where, Mouse); { Make point local }
  2133. I := FindSel(Mouse); { Find selected item }
  2134. If (I <> -1) Then { Check in view }
  2135. If ButtonState(I) Then Sel := I; { If enabled select }
  2136. DrawView; { Now draw changes }
  2137. Repeat
  2138. MakeLocal(Event.Where, Mouse); { Make point local }
  2139. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse up }
  2140. MakeLocal(Event.Where, Mouse); { Make point local }
  2141. If (FindSel(Mouse) = Sel) AND ButtonState(Sel) { If valid/selected }
  2142. Then Begin
  2143. Press(Sel); { Call pressed }
  2144. DrawView; { Now draw changes }
  2145. End;
  2146. ClearEvent(Event); { Event was handled }
  2147. End Else If (Event.What = evKeyDown) Then Begin { KEY EVENT }
  2148. Vh := Size.Y; { View height }
  2149. S := Sel; { Hold current item }
  2150. Key := CtrlToArrow(Event.KeyCode); { Convert keystroke }
  2151. Case Key Of
  2152. kbUp, kbDown, kbRight, kbLeft:
  2153. If (State AND sfFocused <> 0) Then Begin { Focused key event }
  2154. I := 0; { Zero process count }
  2155. Repeat
  2156. Inc(I); { Inc process count }
  2157. Case Key Of
  2158. kbUp: Dec(S); { Next item up }
  2159. kbDown: Inc(S); { Next item down }
  2160. kbRight: Begin { Next column across }
  2161. Inc(S, Vh); { Move to next column }
  2162. If (S >= Strings.Count) Then { No next column check }
  2163. S := (S+1) MOD Vh; { Move to last column }
  2164. End;
  2165. kbLeft: Begin { Prior column across }
  2166. Dec(S, Vh); { Move to prior column }
  2167. If (S < 0) Then S := ((Strings.Count +
  2168. Vh - 1) DIV Vh) * Vh + S - 1; { No prior column check }
  2169. End;
  2170. End;
  2171. If (S >= Strings.Count) Then S := 0; { Roll up to top }
  2172. If (S < 0) Then S := Strings.Count - 1; { Roll down to bottom }
  2173. Until ButtonState(S) OR (I > Strings.Count); { Repeat until select }
  2174. MoveSel; { Move to selected }
  2175. ClearEvent(Event); { Event was handled }
  2176. End;
  2177. Else Begin { Not an arrow key }
  2178. For I := 0 To Strings.Count-1 Do Begin { Scan each item }
  2179. Ts := Strings.At(I); { Fetch string pointer }
  2180. If (Ts <> Nil) Then C := HotKey(Ts^) { Check for hotkey }
  2181. Else C := #0; { No valid string }
  2182. If (GetAltCode(C) = Event.KeyCode) OR { Hot key for item }
  2183. (((Owner^.Phase = phPostProcess) OR { Owner in post process }
  2184. (State AND sfFocused <> 0)) AND (C <> #0) { Non zero hotkey }
  2185. AND (UpCase(Event.CharCode) = C)) { Matches current key }
  2186. Then Begin
  2187. If ButtonState(I) Then Begin { Check mask enabled }
  2188. If Focus Then Begin { Check view focus }
  2189. Sel := I; { Set selected }
  2190. MovedTo(Sel); { Move to selected }
  2191. Press(Sel); { Call pressed }
  2192. DrawView; { Now draw changes }
  2193. End;
  2194. ClearEvent(Event); { Event was handled }
  2195. End;
  2196. Exit; { Now exit }
  2197. End;
  2198. End;
  2199. If (Event.CharCode = ' ') AND { Spacebar key }
  2200. (State AND sfFocused <> 0) AND { Check focused view }
  2201. ButtonState(Sel) Then Begin { Check item enabled }
  2202. Press(Sel); { Call pressed }
  2203. DrawView; { Now draw changes }
  2204. ClearEvent(Event); { Event was handled }
  2205. End;
  2206. End;
  2207. End;
  2208. End;
  2209. END;
  2210. {***************************************************************************}
  2211. { TCluster OBJECT PRIVATE METHODS }
  2212. {***************************************************************************}
  2213. {--TCluster-----------------------------------------------------------------}
  2214. { FindSel -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2215. {---------------------------------------------------------------------------}
  2216. FUNCTION TCluster.FindSel (P: TPoint): Sw_Integer;
  2217. VAR I, S, Vh: Sw_Integer; R: TRect;
  2218. BEGIN
  2219. GetExtent(R); { Get view extents }
  2220. If R.Contains(P) Then Begin { Point in view }
  2221. Vh := Size.Y; { View height }
  2222. I := 0; { Preset zero value }
  2223. While (P.X >= Column(I+Vh)) Do Inc(I, Vh); { Inc view size }
  2224. S := I + P.Y; { Line to select }
  2225. If ((S >= 0) AND (S < Strings.Count)) { Valid selection }
  2226. Then FindSel := S Else FindSel := -1; { Return selected item }
  2227. End Else FindSel := -1; { Point outside view }
  2228. END;
  2229. {--TCluster-----------------------------------------------------------------}
  2230. { Row -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2231. {---------------------------------------------------------------------------}
  2232. FUNCTION TCluster.Row (Item: Sw_Integer): Sw_Integer;
  2233. BEGIN
  2234. Row := Item MOD Size.Y; { Normal mod value }
  2235. END;
  2236. {--TCluster-----------------------------------------------------------------}
  2237. { Column -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2238. {---------------------------------------------------------------------------}
  2239. FUNCTION TCluster.Column (Item: Sw_Integer): Sw_Integer;
  2240. VAR I, Col, Width, L, Vh: Sw_Integer; Ts: PString;
  2241. BEGIN
  2242. Vh := Size.Y; { Vertical size }
  2243. If (Item >= Vh) Then Begin { Valid selection }
  2244. Width := 0; { Zero width }
  2245. Col := -6; { Start column at -6 }
  2246. For I := 0 To Item Do Begin { For each item }
  2247. If (I MOD Vh = 0) Then Begin { Start next column }
  2248. Inc(Col, Width + 6); { Add column width }
  2249. Width := 0; { Zero width }
  2250. End;
  2251. If (I < Strings.Count) Then Begin { Valid string }
  2252. Ts := Strings.At(I); { Transfer string }
  2253. If (Ts <> Nil) Then L := CStrLen(Ts^) { Length of string }
  2254. Else L := 0; { No string }
  2255. End;
  2256. If (L > Width) Then Width := L; { Hold longest string }
  2257. End;
  2258. Column := Col; { Return column }
  2259. End Else Column := 0; { Outside select area }
  2260. END;
  2261. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2262. { TRadioButtons OBJECT METHODS }
  2263. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2264. {--TRadioButtons------------------------------------------------------------}
  2265. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2266. {---------------------------------------------------------------------------}
  2267. FUNCTION TRadioButtons.Mark (Item: Sw_Integer): Boolean;
  2268. BEGIN
  2269. Mark := Item = Value; { True if item = value }
  2270. END;
  2271. {--TRadioButtons------------------------------------------------------------}
  2272. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2273. {---------------------------------------------------------------------------}
  2274. PROCEDURE TRadioButtons.Draw;
  2275. CONST Button = ' ( ) ';
  2276. BEGIN
  2277. Inherited Draw;
  2278. DrawMultiBox(Button, ' *'); { Redraw the text }
  2279. END;
  2280. {--TRadioButtons------------------------------------------------------------}
  2281. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2282. {---------------------------------------------------------------------------}
  2283. PROCEDURE TRadioButtons.Press (Item: Sw_Integer);
  2284. BEGIN
  2285. Value := Item; { Set value field }
  2286. Inherited Press(Item); { Call ancestor }
  2287. END;
  2288. {--TRadioButtons------------------------------------------------------------}
  2289. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2290. {---------------------------------------------------------------------------}
  2291. PROCEDURE TRadioButtons.MovedTo (Item: Sw_Integer);
  2292. BEGIN
  2293. Value := Item; { Set value to item }
  2294. If (Id <> 0) Then NewMessage(Owner, evCommand,
  2295. cmIdCommunicate, Id, Value, @Self); { Send new message }
  2296. END;
  2297. {--TRadioButtons------------------------------------------------------------}
  2298. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2299. {---------------------------------------------------------------------------}
  2300. PROCEDURE TRadioButtons.SetData (Var Rec);
  2301. BEGIN
  2302. Sel := Sw_word(Rec); { Set selection }
  2303. Inherited SetData(Rec); { Call ancestor }
  2304. END;
  2305. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2306. { TCheckBoxes OBJECT METHODS }
  2307. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2308. {--TCheckBoxes--------------------------------------------------------------}
  2309. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2310. {---------------------------------------------------------------------------}
  2311. FUNCTION TCheckBoxes.Mark(Item: Sw_Integer): Boolean;
  2312. BEGIN
  2313. If (Value AND (1 SHL Item) <> 0) Then { Check if item ticked }
  2314. Mark := True Else Mark := False; { Return result }
  2315. END;
  2316. {--TCheckBoxes--------------------------------------------------------------}
  2317. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2318. {---------------------------------------------------------------------------}
  2319. PROCEDURE TCheckBoxes.Draw;
  2320. CONST Button = ' [ ] ';
  2321. BEGIN
  2322. Inherited Draw;
  2323. DrawMultiBox(Button, ' X'); { Redraw the text }
  2324. END;
  2325. {--TCheckBoxes--------------------------------------------------------------}
  2326. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2327. {---------------------------------------------------------------------------}
  2328. PROCEDURE TCheckBoxes.Press (Item: Sw_Integer);
  2329. BEGIN
  2330. Value := Value XOR (1 SHL Item); { Flip the item mask }
  2331. Inherited Press(Item); { Call ancestor }
  2332. END;
  2333. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2334. { TMultiCheckBoxes OBJECT METHODS }
  2335. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2336. {--TMultiCheckBoxes---------------------------------------------------------}
  2337. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Jun98 LdB }
  2338. {---------------------------------------------------------------------------}
  2339. CONSTRUCTOR TMultiCheckBoxes.Init (Var Bounds: TRect; AStrings: PSItem;
  2340. ASelRange: Byte; AFlags: Word; Const AStates: String);
  2341. BEGIN
  2342. Inherited Init(Bounds, AStrings); { Call ancestor }
  2343. SelRange := ASelRange; { Hold select range }
  2344. Flags := AFlags; { Hold flags }
  2345. States := NewStr(AStates); { Hold string }
  2346. END;
  2347. {--TMultiCheckBoxes---------------------------------------------------------}
  2348. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2349. {---------------------------------------------------------------------------}
  2350. CONSTRUCTOR TMultiCheckBoxes.Load (Var S: TStream);
  2351. BEGIN
  2352. Inherited Load(S); { Call ancestor }
  2353. S.Read(SelRange, SizeOf(SelRange)); { Read select range }
  2354. S.Read(Flags, SizeOf(Flags)); { Read flags }
  2355. States := S.ReadStr; { Read strings }
  2356. END;
  2357. {--TMultiCheckBoxes---------------------------------------------------------}
  2358. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2359. {---------------------------------------------------------------------------}
  2360. DESTRUCTOR TMultiCheckBoxes.Done;
  2361. BEGIN
  2362. If (States <> Nil) Then DisposeStr(States); { Dispose strings }
  2363. Inherited Done; { Call ancestor }
  2364. END;
  2365. {--TMultiCheckBoxes---------------------------------------------------------}
  2366. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2367. {---------------------------------------------------------------------------}
  2368. FUNCTION TMultiCheckBoxes.DataSize: Sw_Word;
  2369. BEGIN
  2370. DataSize := SizeOf(LongInt); { Size to exchange }
  2371. END;
  2372. {--TMultiCheckBoxes---------------------------------------------------------}
  2373. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2374. {---------------------------------------------------------------------------}
  2375. FUNCTION TMultiCheckBoxes.MultiMark (Item: Sw_Integer): Byte;
  2376. BEGIN
  2377. MultiMark := (Value SHR (Word(Item) *
  2378. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Return mark state }
  2379. END;
  2380. {--TMultiCheckBoxes---------------------------------------------------------}
  2381. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2382. {---------------------------------------------------------------------------}
  2383. PROCEDURE TMultiCheckBoxes.Draw;
  2384. CONST Button = ' [ ] ';
  2385. BEGIN
  2386. Inherited Draw;
  2387. DrawMultiBox(Button, States^); { Draw the items }
  2388. END;
  2389. {--TMultiCheckBoxes---------------------------------------------------------}
  2390. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2391. {---------------------------------------------------------------------------}
  2392. PROCEDURE TMultiCheckBoxes.Press (Item: Sw_Integer);
  2393. VAR CurState: ShortInt;
  2394. BEGIN
  2395. CurState := (Value SHR (Word(Item) *
  2396. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Hold current state }
  2397. Dec(CurState); { One down }
  2398. If (CurState >= SelRange) OR (CurState < 0) Then
  2399. CurState := SelRange - 1; { Roll if needed }
  2400. Value := (Value AND NOT (LongInt(WordRec(Flags).Lo)
  2401. SHL (Word(Item) * WordRec(Flags).Hi))) OR
  2402. (LongInt(CurState) SHL (Word(Item) *
  2403. WordRec(Flags).Hi)); { Calculate value }
  2404. Inherited Press(Item); { Call ancestor }
  2405. END;
  2406. {--TMultiCheckBoxes---------------------------------------------------------}
  2407. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2408. {---------------------------------------------------------------------------}
  2409. PROCEDURE TMultiCheckBoxes.GetData (Var Rec);
  2410. BEGIN
  2411. Longint(Rec) := Value; { Return value }
  2412. END;
  2413. {--TMultiCheckBoxes---------------------------------------------------------}
  2414. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2415. {---------------------------------------------------------------------------}
  2416. PROCEDURE TMultiCheckBoxes.SetData (Var Rec);
  2417. BEGIN
  2418. Value := Longint(Rec); { Set value }
  2419. DrawView; { Redraw masked areas }
  2420. END;
  2421. {--TMultiCheckBoxes---------------------------------------------------------}
  2422. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2423. {---------------------------------------------------------------------------}
  2424. PROCEDURE TMultiCheckBoxes.Store (Var S: TStream);
  2425. BEGIN
  2426. TCluster.Store(S); { TCluster store called }
  2427. S.Write(SelRange, SizeOf(SelRange)); { Write select range }
  2428. S.Write(Flags, SizeOf(Flags)); { Write select flags }
  2429. S.WriteStr(States); { Write strings }
  2430. END;
  2431. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2432. { TListBox OBJECT METHODS }
  2433. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2434. TYPE
  2435. TListBoxRec = PACKED RECORD
  2436. List: PCollection; { List collection ptr }
  2437. Selection: sw_integer; { Selected item }
  2438. END;
  2439. {--TListBox-----------------------------------------------------------------}
  2440. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2441. {---------------------------------------------------------------------------}
  2442. CONSTRUCTOR TListBox.Init (Var Bounds: TRect; ANumCols: Sw_Word;
  2443. AScrollBar: PScrollBar);
  2444. BEGIN
  2445. Inherited Init(Bounds, ANumCols, Nil, AScrollBar); { Call ancestor }
  2446. SetRange(0); { Set range to zero }
  2447. END;
  2448. {--TListBox-----------------------------------------------------------------}
  2449. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2450. {---------------------------------------------------------------------------}
  2451. CONSTRUCTOR TListBox.Load (Var S: TStream);
  2452. BEGIN
  2453. Inherited Load(S); { Call ancestor }
  2454. List := PCollection(S.Get); { Fetch collection }
  2455. END;
  2456. {--TListBox-----------------------------------------------------------------}
  2457. { DataSize -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 06Jun98 LdB }
  2458. {---------------------------------------------------------------------------}
  2459. FUNCTION TListBox.DataSize: Sw_Word;
  2460. BEGIN
  2461. DataSize := SizeOf(TListBoxRec); { Xchg data size }
  2462. END;
  2463. {--TListBox-----------------------------------------------------------------}
  2464. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2465. {---------------------------------------------------------------------------}
  2466. FUNCTION TListBox.GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String;
  2467. VAR P: PString;
  2468. BEGIN
  2469. GetText := ''; { Preset return }
  2470. If (List <> Nil) Then Begin { A list exists }
  2471. P := PString(List^.At(Item)); { Get string ptr }
  2472. If (P <> Nil) Then GetText := P^; { Return string }
  2473. End;
  2474. END;
  2475. {--TListBox-----------------------------------------------------------------}
  2476. { NewList -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2477. {---------------------------------------------------------------------------}
  2478. PROCEDURE TListBox.NewList (AList: PCollection);
  2479. BEGIN
  2480. If (List <> Nil) Then Dispose(List, Done); { Dispose old list }
  2481. List := AList; { Hold new list }
  2482. If (AList <> Nil) Then SetRange(AList^.Count) { Set new item range }
  2483. Else SetRange(0); { Set zero range }
  2484. If (Range > 0) Then FocusItem(0); { Focus first item }
  2485. DrawView; { Redraw all view }
  2486. END;
  2487. {--TListBox-----------------------------------------------------------------}
  2488. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2489. {---------------------------------------------------------------------------}
  2490. PROCEDURE TListBox.GetData (Var Rec);
  2491. BEGIN
  2492. TListBoxRec(Rec).List := List; { Return current list }
  2493. TListBoxRec(Rec).Selection := Focused; { Return focused item }
  2494. END;
  2495. {--TListBox-----------------------------------------------------------------}
  2496. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2497. {---------------------------------------------------------------------------}
  2498. PROCEDURE TListBox.SetData (Var Rec);
  2499. BEGIN
  2500. NewList(TListBoxRec(Rec).List); { Hold new list }
  2501. FocusItem(TListBoxRec(Rec).Selection); { Focus selected item }
  2502. DrawView; { Redraw all view }
  2503. END;
  2504. {--TListBox-----------------------------------------------------------------}
  2505. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2506. {---------------------------------------------------------------------------}
  2507. PROCEDURE TListBox.Store (Var S: TStream);
  2508. BEGIN
  2509. TListViewer.Store(S); { TListViewer store }
  2510. S.Put(List); { Store list to stream }
  2511. END;
  2512. {****************************************************************************}
  2513. { TListBox.DeleteFocusedItem }
  2514. {****************************************************************************}
  2515. procedure TListBox.DeleteFocusedItem;
  2516. begin
  2517. DeleteItem(Focused);
  2518. end;
  2519. {****************************************************************************}
  2520. { TListBox.DeleteItem }
  2521. {****************************************************************************}
  2522. procedure TListBox.DeleteItem (Item : Sw_Integer);
  2523. begin
  2524. if (List <> nil) and (List^.Count > 0) and
  2525. ((Item < List^.Count) and (Item > -1)) then begin
  2526. if IsSelected(Item) and (Item > 0) then
  2527. FocusItem(Item - 1);
  2528. List^.AtDelete(Item);
  2529. SetRange(List^.Count);
  2530. end;
  2531. end;
  2532. {****************************************************************************}
  2533. { TListBox.FreeAll }
  2534. {****************************************************************************}
  2535. procedure TListBox.FreeAll;
  2536. begin
  2537. if (List <> nil) then
  2538. begin
  2539. List^.FreeAll;
  2540. SetRange(List^.Count);
  2541. end;
  2542. end;
  2543. {****************************************************************************}
  2544. { TListBox.FreeFocusedItem }
  2545. {****************************************************************************}
  2546. procedure TListBox.FreeFocusedItem;
  2547. begin
  2548. FreeItem(Focused);
  2549. end;
  2550. {****************************************************************************}
  2551. { TListBox.FreeItem }
  2552. {****************************************************************************}
  2553. procedure TListBox.FreeItem (Item : Sw_Integer);
  2554. begin
  2555. if (Item > -1) and (Item < Range) then
  2556. begin
  2557. List^.AtFree(Item);
  2558. if (Range > 1) and (Focused >= List^.Count) then
  2559. Dec(Focused);
  2560. SetRange(List^.Count);
  2561. end;
  2562. end;
  2563. {****************************************************************************}
  2564. { TListBox.SetFocusedItem }
  2565. {****************************************************************************}
  2566. procedure TListBox.SetFocusedItem (Item : Pointer);
  2567. begin
  2568. FocusItem(List^.IndexOf(Item));
  2569. end;
  2570. {****************************************************************************}
  2571. { TListBox.GetFocusedItem }
  2572. {****************************************************************************}
  2573. function TListBox.GetFocusedItem : Pointer;
  2574. begin
  2575. if (List = nil) or (List^.Count = 0) then
  2576. GetFocusedItem := nil
  2577. else GetFocusedItem := List^.At(Focused);
  2578. end;
  2579. {****************************************************************************}
  2580. { TListBox.Insert }
  2581. {****************************************************************************}
  2582. procedure TListBox.Insert (Item : Pointer);
  2583. begin
  2584. if (List <> nil) then
  2585. begin
  2586. List^.Insert(Item);
  2587. SetRange(List^.Count);
  2588. end;
  2589. end;
  2590. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2591. { TStaticText OBJECT METHODS }
  2592. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2593. {--TStaticText--------------------------------------------------------------}
  2594. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2595. {---------------------------------------------------------------------------}
  2596. CONSTRUCTOR TStaticText.Init (Var Bounds: TRect; Const AText: String);
  2597. BEGIN
  2598. Inherited Init(Bounds); { Call ancestor }
  2599. Text := NewStr(AText); { Create string ptr }
  2600. END;
  2601. {--TStaticText--------------------------------------------------------------}
  2602. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2603. {---------------------------------------------------------------------------}
  2604. CONSTRUCTOR TStaticText.Load (Var S: TStream);
  2605. BEGIN
  2606. Inherited Load(S); { Call ancestor }
  2607. Text := S.ReadStr; { Read text string }
  2608. END;
  2609. {--TStaticText--------------------------------------------------------------}
  2610. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2611. {---------------------------------------------------------------------------}
  2612. DESTRUCTOR TStaticText.Done;
  2613. BEGIN
  2614. If (Text <> Nil) Then DisposeStr(Text); { Dispose string }
  2615. Inherited Done; { Call ancestor }
  2616. END;
  2617. {--TStaticText--------------------------------------------------------------}
  2618. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2619. {---------------------------------------------------------------------------}
  2620. FUNCTION TStaticText.GetPalette: PPalette;
  2621. CONST P: String[Length(CStaticText)] = CStaticText; { Always normal string }
  2622. BEGIN
  2623. GetPalette := PPalette(@P); { Return palette }
  2624. END;
  2625. {--TStaticText--------------------------------------------------------------}
  2626. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2627. {---------------------------------------------------------------------------}
  2628. PROCEDURE TStaticText.Draw;
  2629. VAR Just: Byte; I, J, P, Y, L: Sw_Integer; S: String;
  2630. B : TDrawBuffer;
  2631. Color : Byte;
  2632. BEGIN
  2633. GetText(S); { Fetch text to write }
  2634. Color := GetColor(1);
  2635. P := 1; { X start position }
  2636. Y := 0; { Y start position }
  2637. L := Length(S); { Length of text }
  2638. While (Y < Size.Y) Do Begin
  2639. MoveChar(B, ' ', Color, Size.X);
  2640. if P <= L then
  2641. begin
  2642. Just := 0; { Default left justify }
  2643. If (S[P] = #2) Then Begin { Right justify char }
  2644. Just := 2; { Set right justify }
  2645. Inc(P); { Next character }
  2646. End;
  2647. If (S[P] = #3) Then Begin { Centre justify char }
  2648. Just := 1; { Set centre justify }
  2649. Inc(P); { Next character }
  2650. End;
  2651. I := P; { Start position }
  2652. repeat
  2653. J := P;
  2654. while (P <= L) and (S[P] = ' ') do
  2655. Inc(P);
  2656. while (P <= L) and (S[P] <> ' ') and (S[P] <> #13) do
  2657. Inc(P);
  2658. until (P > L) or (P >= I + Size.X) or (S[P] = #13);
  2659. If P > I + Size.X Then { Text to long }
  2660. If J > I Then
  2661. P := J
  2662. Else
  2663. P := I + Size.X;
  2664. Case Just Of
  2665. 0: J := 0; { Left justify }
  2666. 1: J := (Size.X - (P-I)) DIV 2; { Centre justify }
  2667. 2: J := Size.X - (P-I); { Right justify }
  2668. End;
  2669. MoveBuf(B[J], S[I], Color, P - I);
  2670. While (P <= L) AND (P-I <= Size.X) AND ((S[P] = #13) OR (S[P] = #10))
  2671. Do Inc(P); { Remove CR/LF }
  2672. End;
  2673. WriteLine(0, Y, Size.X, 1, B);
  2674. Inc(Y); { Next line }
  2675. End;
  2676. END;
  2677. {--TStaticText--------------------------------------------------------------}
  2678. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2679. {---------------------------------------------------------------------------}
  2680. PROCEDURE TStaticText.Store (Var S: TStream);
  2681. BEGIN
  2682. TView.Store(S); { Call TView store }
  2683. S.WriteStr(Text); { Write text string }
  2684. END;
  2685. {--TStaticText--------------------------------------------------------------}
  2686. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2687. {---------------------------------------------------------------------------}
  2688. PROCEDURE TStaticText.GetText (Var S: String);
  2689. BEGIN
  2690. If (Text <> Nil) Then S := Text^ { Copy text string }
  2691. Else S := ''; { Return empty string }
  2692. END;
  2693. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2694. { TParamText OBJECT METHODS }
  2695. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2696. {--TParamText---------------------------------------------------------------}
  2697. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2698. {---------------------------------------------------------------------------}
  2699. CONSTRUCTOR TParamText.Init (Var Bounds: TRect; Const AText: String;
  2700. AParamCount: Sw_Integer);
  2701. BEGIN
  2702. Inherited Init(Bounds, AText); { Call ancestor }
  2703. ParamCount := AParamCount; { Hold param count }
  2704. END;
  2705. {--TParamText---------------------------------------------------------------}
  2706. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2707. {---------------------------------------------------------------------------}
  2708. CONSTRUCTOR TParamText.Load (Var S: TStream);
  2709. VAR w: Word;
  2710. BEGIN
  2711. Inherited Load(S); { Call ancestor }
  2712. S.Read(w, SizeOf(w)); ParamCount:=w; { Read parameter count }
  2713. END;
  2714. {--TParamText---------------------------------------------------------------}
  2715. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2716. {---------------------------------------------------------------------------}
  2717. FUNCTION TParamText.DataSize: Sw_Word;
  2718. BEGIN
  2719. DataSize := ParamCount * SizeOf(Pointer); { Return data size }
  2720. END;
  2721. {--TParamText---------------------------------------------------------------}
  2722. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2723. {---------------------------------------------------------------------------}
  2724. PROCEDURE TParamText.GetData (Var Rec);
  2725. BEGIN
  2726. Pointer(Rec) := @ParamList; { Return parm ptr }
  2727. END;
  2728. {--TParamText---------------------------------------------------------------}
  2729. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2730. {---------------------------------------------------------------------------}
  2731. PROCEDURE TParamText.SetData (Var Rec);
  2732. BEGIN
  2733. ParamList := @Rec; { Fetch parameter list }
  2734. DrawView; { Redraw all the view }
  2735. END;
  2736. {--TParamText---------------------------------------------------------------}
  2737. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2738. {---------------------------------------------------------------------------}
  2739. PROCEDURE TParamText.Store (Var S: TStream);
  2740. VAR w: Word;
  2741. BEGIN
  2742. TStaticText.Store(S); { Statictext store }
  2743. w:=ParamCount;S.Write(w, SizeOf(w)); { Store param count }
  2744. END;
  2745. {--TParamText---------------------------------------------------------------}
  2746. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2747. {---------------------------------------------------------------------------}
  2748. PROCEDURE TParamText.GetText (Var S: String);
  2749. BEGIN
  2750. If (Text = Nil) Then S := '' Else { Return empty string }
  2751. FormatStr(S, Text^, ParamList^); { Return text string }
  2752. END;
  2753. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2754. { TLabel OBJECT METHODS }
  2755. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2756. {--TLabel-------------------------------------------------------------------}
  2757. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2758. {---------------------------------------------------------------------------}
  2759. CONSTRUCTOR TLabel.Init (Var Bounds: TRect; CONST AText: String; ALink: PView);
  2760. BEGIN
  2761. Inherited Init(Bounds, AText); { Call ancestor }
  2762. Link := ALink; { Hold link }
  2763. Options := Options OR (ofPreProcess+ofPostProcess);{ Set pre/post process }
  2764. EventMask := EventMask OR evBroadcast; { Sees broadcast events }
  2765. END;
  2766. {--TLabel-------------------------------------------------------------------}
  2767. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2768. {---------------------------------------------------------------------------}
  2769. CONSTRUCTOR TLabel.Load (Var S: TStream);
  2770. BEGIN
  2771. Inherited Load(S); { Call ancestor }
  2772. GetPeerViewPtr(S, Link); { Load link view }
  2773. END;
  2774. {--TLabel-------------------------------------------------------------------}
  2775. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2776. {---------------------------------------------------------------------------}
  2777. FUNCTION TLabel.GetPalette: PPalette;
  2778. CONST P: String[Length(CLabel)] = CLabel; { Always normal string }
  2779. BEGIN
  2780. GetPalette := PPalette(@P); { Return palette }
  2781. END;
  2782. {--TLabel-------------------------------------------------------------------}
  2783. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2784. {---------------------------------------------------------------------------}
  2785. PROCEDURE TLabel.Draw;
  2786. VAR SCOff: Byte; Color: Word; B: TDrawBuffer;
  2787. BEGIN
  2788. If Light Then Begin { Light colour select }
  2789. Color := GetColor($0402); { Choose light colour }
  2790. SCOff := 0; { Zero offset }
  2791. End Else Begin
  2792. Color := GetColor($0301); { Darker colour }
  2793. SCOff := 4; { Set offset }
  2794. End;
  2795. MoveChar(B[0], ' ', Byte(Color), Size.X); { Clear the buffer }
  2796. If (Text <> Nil) Then MoveCStr(B[1], Text^, Color);{ Transfer label text }
  2797. If ShowMarkers Then WordRec(B[0]).Lo := Byte(
  2798. SpecialChars[SCOff]); { Show marker if req }
  2799. WriteLine(0, 0, Size.X, 1, B); { Write the text }
  2800. END;
  2801. {--TLabel-------------------------------------------------------------------}
  2802. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2803. {---------------------------------------------------------------------------}
  2804. PROCEDURE TLabel.Store (Var S: TStream);
  2805. BEGIN
  2806. TStaticText.Store(S); { TStaticText.Store }
  2807. PutPeerViewPtr(S, Link); { Store link view }
  2808. END;
  2809. {--TLabel-------------------------------------------------------------------}
  2810. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2811. {---------------------------------------------------------------------------}
  2812. PROCEDURE TLabel.HandleEvent (Var Event: TEvent);
  2813. VAR C: Char;
  2814. PROCEDURE FocusLink;
  2815. BEGIN
  2816. If (Link <> Nil) AND (Link^.Options AND
  2817. ofSelectable <> 0) Then Link^.Focus; { Focus link view }
  2818. ClearEvent(Event); { Clear the event }
  2819. END;
  2820. BEGIN
  2821. Inherited HandleEvent(Event); { Call ancestor }
  2822. Case Event.What Of
  2823. evNothing: Exit; { Speed up exit }
  2824. evMouseDown: FocusLink; { Focus link view }
  2825. evKeyDown:
  2826. Begin
  2827. if assigned(text) then
  2828. begin
  2829. C := HotKey(Text^); { Check for hotkey }
  2830. If (GetAltCode(C) = Event.KeyCode) OR { Alt plus char }
  2831. ((C <> #0) AND (Owner^.Phase = phPostProcess) { Post process phase }
  2832. AND (UpCase(Event.CharCode) = C)) Then { Upper case match }
  2833. FocusLink; { Focus link view }
  2834. end;
  2835. end;
  2836. evBroadcast: If ((Event.Command = cmReceivedFocus)
  2837. OR (Event.Command = cmReleasedFocus)) AND { Focus state change }
  2838. (Link <> Nil) Then Begin
  2839. Light := Link^.State AND sfFocused <> 0; { Change light state }
  2840. DrawView; { Now redraw change }
  2841. End;
  2842. End;
  2843. END;
  2844. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2845. { THistoryViewer OBJECT METHODS }
  2846. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2847. {--THistoryViewer-----------------------------------------------------------}
  2848. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2849. {---------------------------------------------------------------------------}
  2850. CONSTRUCTOR THistoryViewer.Init (Var Bounds: TRect; AHScrollBar,
  2851. AVScrollBar: PScrollBar; AHistoryId: Word);
  2852. BEGIN
  2853. Inherited Init(Bounds, 1, AHScrollBar,
  2854. AVScrollBar); { Call ancestor }
  2855. HistoryId := AHistoryId; { Hold history id }
  2856. SetRange(HistoryCount(AHistoryId)); { Set history range }
  2857. If (Range > 1) Then FocusItem(1); { Set to item 1 }
  2858. If (HScrollBar <> Nil) Then
  2859. HScrollBar^.SetRange(1, HistoryWidth-Size.X + 3);{ Set scrollbar range }
  2860. END;
  2861. {--THistoryViewer-----------------------------------------------------------}
  2862. { HistoryWidth -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2863. {---------------------------------------------------------------------------}
  2864. FUNCTION THistoryViewer.HistoryWidth: Sw_Integer;
  2865. VAR Width, T, Count, I: Sw_Integer;
  2866. BEGIN
  2867. Width := 0; { Zero width variable }
  2868. Count := HistoryCount(HistoryId); { Hold count value }
  2869. For I := 0 To Count-1 Do Begin { For each item }
  2870. T := Length(HistoryStr(HistoryId, I)); { Get width of item }
  2871. If (T > Width) Then Width := T; { Set width to max }
  2872. End;
  2873. HistoryWidth := Width; { Return max item width }
  2874. END;
  2875. {--THistoryViewer-----------------------------------------------------------}
  2876. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2877. {---------------------------------------------------------------------------}
  2878. FUNCTION THistoryViewer.GetPalette: PPalette;
  2879. CONST P: String[Length(CHistoryViewer)] = CHistoryViewer;{ Always normal string }
  2880. BEGIN
  2881. GetPalette := PPalette(@P); { Return palette }
  2882. END;
  2883. {--THistoryViewer-----------------------------------------------------------}
  2884. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2885. {---------------------------------------------------------------------------}
  2886. FUNCTION THistoryViewer.GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String;
  2887. BEGIN
  2888. GetText := HistoryStr(HistoryId, Item); { Return history string }
  2889. END;
  2890. {--THistoryViewer-----------------------------------------------------------}
  2891. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2892. {---------------------------------------------------------------------------}
  2893. PROCEDURE THistoryViewer.HandleEvent (Var Event: TEvent);
  2894. BEGIN
  2895. If ((Event.What = evMouseDown) AND (Event.Double)) { Double click mouse }
  2896. OR ((Event.What = evKeyDown) AND
  2897. (Event.KeyCode = kbEnter)) Then Begin { Enter key press }
  2898. EndModal(cmOk); { End with cmOk }
  2899. ClearEvent(Event); { Event was handled }
  2900. End Else If ((Event.What = evKeyDown) AND
  2901. (Event.KeyCode = kbEsc)) OR { Esc key press }
  2902. ((Event.What = evCommand) AND
  2903. (Event.Command = cmCancel)) Then Begin { Cancel command }
  2904. EndModal(cmCancel); { End with cmCancel }
  2905. ClearEvent(Event); { Event was handled }
  2906. End Else Inherited HandleEvent(Event); { Call ancestor }
  2907. END;
  2908. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2909. { THistoryWindow OBJECT METHODS }
  2910. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2911. {--THistoryWindow-----------------------------------------------------------}
  2912. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2913. {---------------------------------------------------------------------------}
  2914. CONSTRUCTOR THistoryWindow.Init (Var Bounds: TRect; HistoryId: Word);
  2915. BEGIN
  2916. Inherited Init(Bounds, '', wnNoNumber); { Call ancestor }
  2917. Flags := wfClose; { Close flag only }
  2918. InitViewer(HistoryId); { Create list view }
  2919. END;
  2920. {--THistoryWindow-----------------------------------------------------------}
  2921. { GetSelection -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2922. {---------------------------------------------------------------------------}
  2923. FUNCTION THistoryWindow.GetSelection: String;
  2924. BEGIN
  2925. If (Viewer = Nil) Then GetSelection := '' Else { Return empty string }
  2926. GetSelection := Viewer^.GetText(Viewer^.Focused,
  2927. 255); { Get focused string }
  2928. END;
  2929. {--THistoryWindow-----------------------------------------------------------}
  2930. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2931. {---------------------------------------------------------------------------}
  2932. FUNCTION THistoryWindow.GetPalette: PPalette;
  2933. CONST P: String[Length(CHistoryWindow)] = CHistoryWindow;{ Always normal string }
  2934. BEGIN
  2935. GetPalette := PPalette(@P); { Return the palette }
  2936. END;
  2937. {--THistoryWindow-----------------------------------------------------------}
  2938. { InitViewer -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2939. {---------------------------------------------------------------------------}
  2940. PROCEDURE THistoryWindow.InitViewer(HistoryId: Word);
  2941. VAR R: TRect;
  2942. BEGIN
  2943. GetExtent(R); { Get extents }
  2944. R.Grow(-1,-1); { Grow inside }
  2945. Viewer := New(PHistoryViewer, Init(R,
  2946. StandardScrollBar(sbHorizontal + sbHandleKeyboard),
  2947. StandardScrollBar(sbVertical + sbHandleKeyboard),
  2948. HistoryId)); { Create the viewer }
  2949. If (Viewer <> Nil) Then Insert(Viewer); { Insert viewer }
  2950. END;
  2951. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2952. { THistory OBJECT METHODS }
  2953. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2954. {--THistory-----------------------------------------------------------------}
  2955. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2956. {---------------------------------------------------------------------------}
  2957. CONSTRUCTOR THistory.Init (Var Bounds: TRect; ALink: PInputLine;
  2958. AHistoryId: Word);
  2959. BEGIN
  2960. Inherited Init(Bounds); { Call ancestor }
  2961. Options := Options OR ofPostProcess; { Set post process }
  2962. EventMask := EventMask OR evBroadcast; { See broadcast events }
  2963. Link := ALink; { Hold link view }
  2964. HistoryId := AHistoryId; { Hold history id }
  2965. END;
  2966. {--THistory-----------------------------------------------------------------}
  2967. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2968. {---------------------------------------------------------------------------}
  2969. CONSTRUCTOR THistory.Load (Var S: TStream);
  2970. BEGIN
  2971. Inherited Load(S); { Call ancestor }
  2972. GetPeerViewPtr(S, Link); { Load link view }
  2973. S.Read(HistoryId, SizeOf(HistoryId)); { Read history id }
  2974. END;
  2975. {--THistory-----------------------------------------------------------------}
  2976. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2977. {---------------------------------------------------------------------------}
  2978. FUNCTION THistory.GetPalette: PPalette;
  2979. CONST P: String[Length(CHistory)] = CHistory; { Always normal string }
  2980. BEGIN
  2981. GetPalette := PPalette(@P); { Return the palette }
  2982. END;
  2983. {--THistory-----------------------------------------------------------------}
  2984. { InitHistoryWindow -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2985. {---------------------------------------------------------------------------}
  2986. FUNCTION THistory.InitHistoryWindow (Var Bounds: TRect): PHistoryWindow;
  2987. VAR P: PHistoryWindow;
  2988. BEGIN
  2989. P := New(PHistoryWindow, Init(Bounds, HistoryId)); { Create history window }
  2990. If (Link <> Nil) Then
  2991. P^.HelpCtx := Link^.HelpCtx; { Set help context }
  2992. InitHistoryWindow := P; { Return history window }
  2993. END;
  2994. PROCEDURE THistory.Draw;
  2995. VAR B: TDrawBuffer;
  2996. BEGIN
  2997. MoveCStr(B,#222'~v~'#221, GetColor($0102)); { Set buffer data }
  2998. WriteLine(0, 0, Size.X, Size.Y, B); { Write buffer }
  2999. END;
  3000. {--THistory-----------------------------------------------------------------}
  3001. { RecordHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  3002. {---------------------------------------------------------------------------}
  3003. PROCEDURE THistory.RecordHistory (CONST S: String);
  3004. BEGIN
  3005. HistoryAdd(HistoryId, S); { Add to history }
  3006. END;
  3007. {--THistory-----------------------------------------------------------------}
  3008. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  3009. {---------------------------------------------------------------------------}
  3010. PROCEDURE THistory.Store (Var S: TStream);
  3011. BEGIN
  3012. TView.Store(S); { TView.Store called }
  3013. PutPeerViewPtr(S, Link); { Store link view }
  3014. S.Write(HistoryId, SizeOf(HistoryId)); { Store history id }
  3015. END;
  3016. {--THistory-----------------------------------------------------------------}
  3017. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  3018. {---------------------------------------------------------------------------}
  3019. PROCEDURE THistory.HandleEvent (Var Event: TEvent);
  3020. VAR C: Word; Rslt: String; R, P: TRect; HistoryWindow: PHistoryWindow;
  3021. BEGIN
  3022. Inherited HandleEvent(Event); { Call ancestor }
  3023. If (Link = Nil) Then Exit; { No link view exits }
  3024. If (Event.What = evMouseDown) OR { Mouse down event }
  3025. ((Event.What = evKeyDown) AND
  3026. (CtrlToArrow(Event.KeyCode) = kbDown) AND { Down arrow key }
  3027. (Link^.State AND sfFocused <> 0)) Then Begin { Link view selected }
  3028. If NOT Link^.Focus Then Begin
  3029. ClearEvent(Event); { Event was handled }
  3030. Exit; { Now exit }
  3031. End;
  3032. RecordHistory(Link^.Data^); { Record current data }
  3033. Link^.GetBounds(R); { Get view bounds }
  3034. Dec(R.A.X); { One char in from us }
  3035. Inc(R.B.X); { One char short of us }
  3036. Inc(R.B.Y, 7); { Seven lines down }
  3037. Dec(R.A.Y,1); { One line below us }
  3038. Owner^.GetExtent(P); { Get owner extents }
  3039. R.Intersect(P); { Intersect views }
  3040. Dec(R.B.Y,1); { Shorten length by one }
  3041. HistoryWindow := InitHistoryWindow(R); { Create history window }
  3042. If (HistoryWindow <> Nil) Then Begin { Window crested okay }
  3043. C := Owner^.ExecView(HistoryWindow); { Execute this window }
  3044. If (C = cmOk) Then Begin { Result was okay }
  3045. Rslt := HistoryWindow^.GetSelection; { Get history selection }
  3046. If Length(Rslt) > Link^.MaxLen Then
  3047. SetLength(Rslt, Link^.MaxLen); { Hold new length }
  3048. Link^.Data^ := Rslt; { Hold new selection }
  3049. Link^.SelectAll(True); { Select all string }
  3050. Link^.DrawView; { Redraw link view }
  3051. End;
  3052. Dispose(HistoryWindow, Done); { Dispose of window }
  3053. End;
  3054. ClearEvent(Event); { Event was handled }
  3055. End Else If (Event.What = evBroadcast) Then { Broadcast event }
  3056. If ((Event.Command = cmReleasedFocus) AND
  3057. (Event.InfoPtr = Link)) OR
  3058. (Event.Command = cmRecordHistory) Then { Record command }
  3059. RecordHistory(Link^.Data^); { Record the history }
  3060. END;
  3061. {****************************************************************************}
  3062. { TBrowseButton Object }
  3063. {****************************************************************************}
  3064. {****************************************************************************}
  3065. { TBrowseButton.Init }
  3066. {****************************************************************************}
  3067. constructor TBrowseButton.Init(var Bounds: TRect; ATitle: TTitleStr;
  3068. ACommand: Word; AFlags: Byte; ALink: PBrowseInputLine);
  3069. begin
  3070. if not inherited Init(Bounds,ATitle,ACommand,AFlags) then
  3071. Fail;
  3072. Link := ALink;
  3073. end;
  3074. {****************************************************************************}
  3075. { TBrowseButton.Load }
  3076. {****************************************************************************}
  3077. constructor TBrowseButton.Load(var S: TStream);
  3078. begin
  3079. if not inherited Load(S) then
  3080. Fail;
  3081. GetPeerViewPtr(S,Link);
  3082. end;
  3083. {****************************************************************************}
  3084. { TBrowseButton.Press }
  3085. {****************************************************************************}
  3086. procedure TBrowseButton.Press;
  3087. var
  3088. E: TEvent;
  3089. begin
  3090. Message(Owner, evBroadcast, cmRecordHistory, nil);
  3091. if Flags and bfBroadcast <> 0 then
  3092. Message(Owner, evBroadcast, Command, Link) else
  3093. begin
  3094. E.What := evCommand;
  3095. E.Command := Command;
  3096. E.InfoPtr := Link;
  3097. PutEvent(E);
  3098. end;
  3099. end;
  3100. {****************************************************************************}
  3101. { TBrowseButton.Store }
  3102. {****************************************************************************}
  3103. procedure TBrowseButton.Store(var S: TStream);
  3104. begin
  3105. inherited Store(S);
  3106. PutPeerViewPtr(S,Link);
  3107. end;
  3108. {****************************************************************************}
  3109. { TBrowseInputLine Object }
  3110. {****************************************************************************}
  3111. {****************************************************************************}
  3112. { TBrowseInputLine.Init }
  3113. {****************************************************************************}
  3114. constructor TBrowseInputLine.Init(var Bounds: TRect; AMaxLen: Sw_Integer; AHistory: Sw_Word);
  3115. begin
  3116. if not inherited Init(Bounds,AMaxLen) then
  3117. Fail;
  3118. History := AHistory;
  3119. end;
  3120. {****************************************************************************}
  3121. { TBrowseInputLine.Load }
  3122. {****************************************************************************}
  3123. constructor TBrowseInputLine.Load(var S: TStream);
  3124. begin
  3125. if not inherited Load(S) then
  3126. Fail;
  3127. S.Read(History,SizeOf(History));
  3128. if (S.Status <> stOk) then
  3129. Fail;
  3130. end;
  3131. {****************************************************************************}
  3132. { TBrowseInputLine.DataSize }
  3133. {****************************************************************************}
  3134. function TBrowseInputLine.DataSize: Sw_Word;
  3135. begin
  3136. DataSize := SizeOf(TBrowseInputLineRec);
  3137. end;
  3138. {****************************************************************************}
  3139. { TBrowseInputLine.GetData }
  3140. {****************************************************************************}
  3141. procedure TBrowseInputLine.GetData(var Rec);
  3142. var
  3143. LocalRec: TBrowseInputLineRec absolute Rec;
  3144. begin
  3145. if (Validator = nil) or
  3146. (Validator^.Transfer(Data^,@LocalRec.Text, vtGetData) = 0) then
  3147. begin
  3148. FillChar(LocalRec.Text, DataSize, #0);
  3149. Move(Data^, LocalRec.Text, Length(Data^) + 1);
  3150. end;
  3151. LocalRec.History := History;
  3152. end;
  3153. {****************************************************************************}
  3154. { TBrowseInputLine.SetData }
  3155. {****************************************************************************}
  3156. procedure TBrowseInputLine.SetData(var Rec);
  3157. var
  3158. LocalRec: TBrowseInputLineRec absolute Rec;
  3159. begin
  3160. if (Validator = nil) or
  3161. (Validator^.Transfer(Data^, @LocalRec.Text, vtSetData) = 0) then
  3162. Move(LocalRec.Text, Data^[0], MaxLen + 1);
  3163. History := LocalRec.History;
  3164. SelectAll(True);
  3165. end;
  3166. {****************************************************************************}
  3167. { TBrowseInputLine.Store }
  3168. {****************************************************************************}
  3169. procedure TBrowseInputLine.Store(var S: TStream);
  3170. begin
  3171. inherited Store(S);
  3172. S.Write(History,SizeOf(History));
  3173. end;
  3174. {****************************************************************************}
  3175. { TCommandCheckBoxes Object }
  3176. {****************************************************************************}
  3177. {****************************************************************************}
  3178. { TCommandCheckBoxes.Init }
  3179. {****************************************************************************}
  3180. constructor TCommandCheckBoxes.Init (var Bounds : TRect;
  3181. ACommandStrings : PCommandSItem);
  3182. var StartSItem, S : PSItem;
  3183. CItems : PCommandSItem;
  3184. i : Sw_Integer;
  3185. begin
  3186. if ACommandStrings = nil then
  3187. Fail;
  3188. { set up string list }
  3189. StartSItem := NewSItem(ACommandStrings^.Value,nil);
  3190. S := StartSItem;
  3191. CItems := ACommandStrings^.Next;
  3192. while (CItems <> nil) do begin
  3193. S^.Next := NewSItem(CItems^.Value,nil);
  3194. S := S^.Next;
  3195. CItems := CItems^.Next;
  3196. end;
  3197. { construct check boxes }
  3198. if not TCheckBoxes.Init(Bounds,StartSItem) then begin
  3199. while (StartSItem <> nil) do begin
  3200. S := StartSItem;
  3201. StartSItem := StartSItem^.Next;
  3202. if (S^.Value <> nil) then
  3203. DisposeStr(S^.Value);
  3204. Dispose(S);
  3205. end;
  3206. Fail;
  3207. end;
  3208. { set up CommandList and dispose of memory used by ACommandList }
  3209. i := 0;
  3210. while (ACommandStrings <> nil) do begin
  3211. CommandList[i] := ACommandStrings^.Command;
  3212. CItems := ACommandStrings;
  3213. ACommandStrings := ACommandStrings^.Next;
  3214. Dispose(CItems);
  3215. Inc(i);
  3216. end;
  3217. end;
  3218. {****************************************************************************}
  3219. { TCommandCheckBoxes.Load }
  3220. {****************************************************************************}
  3221. constructor TCommandCheckBoxes.Load (var S : TStream);
  3222. begin
  3223. if not TCheckBoxes.Load(S) then
  3224. Fail;
  3225. S.Read(CommandList,SizeOf(CommandList));
  3226. if (S.Status <> stOk) then begin
  3227. TCheckBoxes.Done;
  3228. Fail;
  3229. end;
  3230. end;
  3231. {****************************************************************************}
  3232. { TCommandCheckBoxes.Press }
  3233. {****************************************************************************}
  3234. procedure TCommandCheckBoxes.Press (Item : Sw_Integer);
  3235. var Temp : Sw_Integer;
  3236. begin
  3237. Temp := Value;
  3238. TCheckBoxes.Press(Item);
  3239. if (Value <> Temp) then { value changed - notify peers }
  3240. Message(Owner,evCommand,CommandList[Item],@Value);
  3241. end;
  3242. {****************************************************************************}
  3243. { TCommandCheckBoxes.Store }
  3244. {****************************************************************************}
  3245. procedure TCommandCheckBoxes.Store (var S : TStream);
  3246. begin
  3247. TCheckBoxes.Store(S);
  3248. S.Write(CommandList,SizeOf(CommandList));
  3249. end;
  3250. {****************************************************************************}
  3251. { TCommandIcon Object }
  3252. {****************************************************************************}
  3253. {****************************************************************************}
  3254. { TCommandIcon.Init }
  3255. {****************************************************************************}
  3256. constructor TCommandIcon.Init (var Bounds : TRect; AText : String;
  3257. ACommand : Word);
  3258. begin
  3259. if not TStaticText.Init(Bounds,AText) then
  3260. Fail;
  3261. Options := Options or ofPostProcess;
  3262. Command := ACommand;
  3263. end;
  3264. {****************************************************************************}
  3265. { TCommandIcon.HandleEvent }
  3266. {****************************************************************************}
  3267. procedure TCommandIcon.HandleEvent (var Event : TEvent);
  3268. begin
  3269. if ((Event.What = evMouseDown) and MouseInView(MouseWhere)) then begin
  3270. ClearEvent(Event);
  3271. Message(Owner,evCommand,Command,nil);
  3272. end;
  3273. TStaticText.HandleEvent(Event);
  3274. end;
  3275. {****************************************************************************}
  3276. { TCommandInputLine Object }
  3277. {****************************************************************************}
  3278. {****************************************************************************}
  3279. { TCommandInputLine.Changed }
  3280. {****************************************************************************}
  3281. {procedure TCommandInputLine.Changed;
  3282. begin
  3283. Message(Owner,evBroadcast,cmInputLineChanged,@Self);
  3284. end; }
  3285. {****************************************************************************}
  3286. { TCommandInputLine.HandleEvent }
  3287. {****************************************************************************}
  3288. {procedure TCommandInputLine.HandleEvent (var Event : TEvent);
  3289. var E : TEvent;
  3290. begin
  3291. E := Event;
  3292. TBSDInputLine.HandleEvent(Event);
  3293. if ((E.What and evKeyBoard = evKeyBoard) and (Event.KeyCode = kbEnter))
  3294. then Changed;
  3295. end; }
  3296. {****************************************************************************}
  3297. { TCommandRadioButtons Object }
  3298. {****************************************************************************}
  3299. {****************************************************************************}
  3300. { TCommandRadioButtons.Init }
  3301. {****************************************************************************}
  3302. constructor TCommandRadioButtons.Init (var Bounds : TRect;
  3303. ACommandStrings : PCommandSItem);
  3304. var
  3305. StartSItem, S : PSItem;
  3306. CItems : PCommandSItem;
  3307. i : Sw_Integer;
  3308. begin
  3309. if ACommandStrings = nil
  3310. then Fail;
  3311. { set up string list }
  3312. StartSItem := NewSItem(ACommandStrings^.Value,nil);
  3313. S := StartSItem;
  3314. CItems := ACommandStrings^.Next;
  3315. while (CItems <> nil) do begin
  3316. S^.Next := NewSItem(CItems^.Value,nil);
  3317. S := S^.Next;
  3318. CItems := CItems^.Next;
  3319. end;
  3320. { construct check boxes }
  3321. if not TRadioButtons.Init(Bounds,StartSItem) then begin
  3322. while (StartSItem <> nil) do begin
  3323. S := StartSItem;
  3324. StartSItem := StartSItem^.Next;
  3325. if (S^.Value <> nil) then
  3326. DisposeStr(S^.Value);
  3327. Dispose(S);
  3328. end;
  3329. Fail;
  3330. end;
  3331. { set up command list }
  3332. i := 0;
  3333. while (ACommandStrings <> nil) do begin
  3334. CommandList[i] := ACommandStrings^.Command;
  3335. CItems := ACommandStrings;
  3336. ACommandStrings := ACommandStrings^.Next;
  3337. Dispose(CItems);
  3338. Inc(i);
  3339. end;
  3340. end;
  3341. {****************************************************************************}
  3342. { TCommandRadioButtons.Load }
  3343. {****************************************************************************}
  3344. constructor TCommandRadioButtons.Load (var S : TStream);
  3345. begin
  3346. if not TRadioButtons.Load(S) then
  3347. Fail;
  3348. S.Read(CommandList,SizeOf(CommandList));
  3349. if (S.Status <> stOk) then begin
  3350. TRadioButtons.Done;
  3351. Fail;
  3352. end;
  3353. end;
  3354. {****************************************************************************}
  3355. { TCommandRadioButtons.MoveTo }
  3356. {****************************************************************************}
  3357. procedure TCommandRadioButtons.MovedTo (Item : Sw_Integer);
  3358. var Temp : Sw_Integer;
  3359. begin
  3360. Temp := Value;
  3361. TRadioButtons.MovedTo(Item);
  3362. if (Value <> Temp) then { value changed - notify peers }
  3363. Message(Owner,evCommand,CommandList[Item],@Value);
  3364. end;
  3365. {****************************************************************************}
  3366. { TCommandRadioButtons.Press }
  3367. {****************************************************************************}
  3368. procedure TCommandRadioButtons.Press (Item : Sw_Integer);
  3369. var Temp : Sw_Integer;
  3370. begin
  3371. Temp := Value;
  3372. TRadioButtons.Press(Item);
  3373. if (Value <> Temp) then { value changed - notify peers }
  3374. Message(Owner,evCommand,CommandList[Item],@Value);
  3375. end;
  3376. {****************************************************************************}
  3377. { TCommandRadioButtons.Store }
  3378. {****************************************************************************}
  3379. procedure TCommandRadioButtons.Store (var S : TStream);
  3380. begin
  3381. TRadioButtons.Store(S);
  3382. S.Write(CommandList,SizeOf(CommandList));
  3383. end;
  3384. {****************************************************************************}
  3385. { TEditListBox Object }
  3386. {****************************************************************************}
  3387. {****************************************************************************}
  3388. { TEditListBox.Init }
  3389. {****************************************************************************}
  3390. constructor TEditListBox.Init (Bounds : TRect; ANumCols: Word;
  3391. AVScrollBar : PScrollBar);
  3392. begin
  3393. if not inherited Init(Bounds,ANumCols,AVScrollBar)
  3394. then Fail;
  3395. CurrentField := 1;
  3396. end;
  3397. {****************************************************************************}
  3398. { TEditListBox.Load }
  3399. {****************************************************************************}
  3400. constructor TEditListBox.Load (var S : TStream);
  3401. begin
  3402. if not inherited Load(S)
  3403. then Fail;
  3404. CurrentField := 1;
  3405. end;
  3406. {****************************************************************************}
  3407. { TEditListBox.EditField }
  3408. {****************************************************************************}
  3409. procedure TEditListBox.EditField (var Event : TEvent);
  3410. var R : TRect;
  3411. InputLine : PModalInputLine;
  3412. begin
  3413. R.Assign(StartColumn,(Origin.Y + Focused - TopItem),
  3414. (StartColumn + FieldWidth + 2),(Origin.Y + Focused - TopItem + 1));
  3415. Owner^.MakeGlobal(R.A,R.A);
  3416. Owner^.MakeGlobal(R.B,R.B);
  3417. InputLine := New(PModalInputLine,Init(R,FieldWidth));
  3418. InputLine^.SetValidator(FieldValidator);
  3419. if InputLine <> nil
  3420. then begin
  3421. { Use TInputLine^.SetData so that data validation occurs }
  3422. { because TInputLine.Data is allocated memory large enough }
  3423. { to hold a string of MaxLen. It is also faster. }
  3424. GetField(InputLine);
  3425. if (Application^.ExecView(InputLine) = cmOk)
  3426. then SetField(InputLine);
  3427. Dispose(InputLine,done);
  3428. end;
  3429. end;
  3430. {****************************************************************************}
  3431. { TEditListBox.FieldValidator }
  3432. {****************************************************************************}
  3433. function TEditListBox.FieldValidator : PValidator;
  3434. { In a multiple field listbox FieldWidth should return the width }
  3435. { appropriate for Field. The default is an inputline for editing }
  3436. { a string of length large enough to fill the listbox field. }
  3437. begin
  3438. FieldValidator := nil;
  3439. end;
  3440. {****************************************************************************}
  3441. { TEditListBox.FieldWidth }
  3442. {****************************************************************************}
  3443. function TEditListBox.FieldWidth : Integer;
  3444. { In a multiple field listbox FieldWidth should return the width }
  3445. { appropriate for CurrentField. }
  3446. begin
  3447. FieldWidth := Size.X - 2;
  3448. end;
  3449. {****************************************************************************}
  3450. { TEditListBox.GetField }
  3451. {****************************************************************************}
  3452. procedure TEditListBox.GetField (InputLine : PInputLine);
  3453. { Places a string appropriate to Field and Focused into InputLine that }
  3454. { will be edited. Override this method for complex data types. }
  3455. begin
  3456. InputLine^.SetData(PString(List^.At(Focused))^);
  3457. end;
  3458. {****************************************************************************}
  3459. { TEditListBox.GetPalette }
  3460. {****************************************************************************}
  3461. function TEditListBox.GetPalette : PPalette;
  3462. begin
  3463. GetPalette := inherited GetPalette;
  3464. end;
  3465. {****************************************************************************}
  3466. { TEditListBox.HandleEvent }
  3467. {****************************************************************************}
  3468. procedure TEditListBox.HandleEvent (var Event : TEvent);
  3469. begin
  3470. if (Event.What = evKeyboard) and (Event.KeyCode = kbAltE)
  3471. then begin { edit field }
  3472. EditField(Event);
  3473. DrawView;
  3474. ClearEvent(Event);
  3475. end;
  3476. inherited HandleEvent(Event);
  3477. end;
  3478. {****************************************************************************}
  3479. { TEditListBox.SetField }
  3480. {****************************************************************************}
  3481. procedure TEditListBox.SetField (InputLine : PInputLine);
  3482. { Override this method for field types other than PStrings. }
  3483. var Item : PString;
  3484. begin
  3485. Item := NewStr(InputLine^.Data^);
  3486. if Item <> nil
  3487. then begin
  3488. List^.AtFree(Focused);
  3489. List^.Insert(Item);
  3490. SetFocusedItem(Item);
  3491. end;
  3492. end;
  3493. {****************************************************************************}
  3494. { TEditListBox.StartColumn }
  3495. {****************************************************************************}
  3496. function TEditListBox.StartColumn : Integer;
  3497. begin
  3498. StartColumn := Origin.X;
  3499. end;
  3500. {****************************************************************************}
  3501. { TListDlg Object }
  3502. {****************************************************************************}
  3503. {****************************************************************************}
  3504. { TListDlg.Init }
  3505. {****************************************************************************}
  3506. constructor TListDlg.Init (ATitle : TTitleStr; Items:
  3507. String; AButtons: Word; AListBox: PListBox; AEditCommand, ANewCommand :
  3508. Word);
  3509. var
  3510. Bounds: TRect;
  3511. b: Byte;
  3512. ButtonCount: Byte;
  3513. i, j, Gap, Line: Integer;
  3514. Scrollbar: PScrollbar;
  3515. HasFrame: Boolean;
  3516. HasButtons: Boolean;
  3517. HasScrollBar: Boolean;
  3518. HasItems: Boolean;
  3519. begin
  3520. if AListBox = nil then
  3521. Fail
  3522. else
  3523. ListBox := AListBox;
  3524. HasFrame := ((AButtons and ldNoFrame) = 0);
  3525. HasButtons := ((AButtons and ldAllButtons) <> 0);
  3526. HasScrollBar := ((AButtons and ldNoScrollBar) = 0);
  3527. HasItems := (Items <> '');
  3528. ButtonCount := 2;
  3529. for b := 0 to 3 do
  3530. if (AButtons and ($0001 shl 1)) <> 0 then
  3531. Inc(ButtonCount);
  3532. { Make sure dialog is large enough for buttons }
  3533. ListBox^.GetExtent(Bounds);
  3534. Bounds.Move(ListBox^.Origin.X,ListBox^.Origin.Y);
  3535. if HasFrame then
  3536. begin
  3537. Inc(Bounds.B.X,2);
  3538. Inc(Bounds.B.Y,2);
  3539. end;
  3540. if HasButtons then
  3541. begin
  3542. Inc(Bounds.B.X,14);
  3543. if Bounds.B.Y < (ButtonCount * 2) + 4 then
  3544. Bounds.B.Y := (ButtonCount * 2) + 5;
  3545. end;
  3546. if HasItems then
  3547. Inc(Bounds.B.Y,1);
  3548. if not TDialog.Init(Bounds,ATitle) then
  3549. Fail;
  3550. NewCommand := ANewCommand;
  3551. EditCommand := AEditCommand;
  3552. Options := Options or ofNewEditDelete;
  3553. if (not HasFrame) and (Frame <> nil) then
  3554. begin
  3555. Delete(Frame);
  3556. Dispose(Frame,Done);
  3557. Frame := nil;
  3558. Options := Options and not ofFramed;
  3559. end;
  3560. HelpCtx := hcListDlg;
  3561. { position and insert ListBox }
  3562. ListBox := AListBox;
  3563. Insert(ListBox);
  3564. if HasItems then
  3565. if HasFrame then
  3566. ListBox^.MoveTo(2,2)
  3567. else ListBox^.MoveTo(0,2)
  3568. else
  3569. if HasFrame then
  3570. ListBox^.MoveTo(1,1)
  3571. else ListBox^.MoveTo(0,0);
  3572. if HasButtons then
  3573. if ListBox^.Size.Y < (ButtonCount * 2) then
  3574. ListBox^.GrowTo(ListBox^.Size.X,ButtonCount * 2);
  3575. { do Items }
  3576. if HasItems then
  3577. begin
  3578. Bounds.Assign(1,1,CStrLen(Items)+2,2);
  3579. Insert(New(PLabel,Init(Bounds,Items,ListBox)));
  3580. end;
  3581. { do scrollbar }
  3582. if HasScrollBar then
  3583. begin
  3584. Bounds.Assign(ListBox^.Size.X+ListBox^.Origin.X,ListBox^.Origin.Y,
  3585. ListBox^.Size.X + ListBox^.Origin.X + 1,
  3586. ListBox^.Size.Y + ListBox^.Origin.Y { origin });
  3587. ScrollBar := New(PScrollBar,Init(Bounds));
  3588. Bounds.Assign(Origin.X,Origin.Y,Origin.X + Size.X + 1, Origin.Y + Size.Y);
  3589. ChangeBounds(Bounds);
  3590. Insert(Scrollbar);
  3591. end;
  3592. if HasButtons then
  3593. begin { do buttons }
  3594. j := $0001;
  3595. Gap := 0;
  3596. for i := 0 to 3 do
  3597. if ((j shl i) and AButtons) <> 0 then
  3598. Inc(Gap);
  3599. Gap := ((Size.Y - 2) div (Gap + 2));
  3600. if Gap < 2 then
  3601. Gap := 2;
  3602. { Insert Buttons }
  3603. Line := 2;
  3604. if (AButtons and ldNew) = ldNew then
  3605. begin
  3606. Insert(NewButton(Size.X - 12,Line,10,2,'~N~ew',cmNew,hcInsert,bfNormal));
  3607. Inc(Line,Gap);
  3608. end;
  3609. if (AButtons and ldEdit) = ldEdit then
  3610. begin
  3611. Insert(NewButton(Size.X - 12,Line,10,2,'~E~dit',cmEdit,hcEdit,
  3612. bfNormal));
  3613. Inc(Line,Gap);
  3614. end;
  3615. if (AButtons and ldDelete) = ldDelete then
  3616. begin
  3617. Insert(NewButton(Size.X - 12,Line,10,2,'~D~elete',cmDelete,hcDelete,
  3618. bfNormal));
  3619. Inc(Line,Gap);
  3620. end;
  3621. Insert(NewButton(Size.X - 12,Line,10,2,'O~k~',cmOK,hcOk,bfDefault or
  3622. bfNormal));
  3623. Inc(Line,Gap);
  3624. Insert(NewButton(Size.X - 12,Line,10,2,'Cancel',cmCancel,hcCancel,
  3625. bfNormal));
  3626. if (AButtons and ldHelp) = ldHelp then
  3627. begin
  3628. Inc(Line,Gap);
  3629. Insert(NewButton(Size.X - 12,Line,10,2,'~H~elp',cmHelp,hcNoContext,
  3630. bfNormal));
  3631. end;
  3632. end;
  3633. if HasFrame and ((AButtons and ldAllIcons) <> 0) then
  3634. begin
  3635. Line := 2;
  3636. if (AButtons and ldNewIcon) = ldNewIcon then
  3637. begin
  3638. Bounds.Assign(Line,Size.Y-1,Line+5,Size.Y);
  3639. Insert(New(PCommandIcon,Init(Bounds,' Ins ',cmNew)));
  3640. Inc(Line,5);
  3641. if (AButtons and (ldEditIcon or ldDeleteIcon)) <> 0 then
  3642. begin
  3643. Bounds.Assign(Line,Size.Y-1,Line+1,Size.Y);
  3644. Insert(New(PStaticText,Init(Bounds,'/')));
  3645. Inc(Line,1);
  3646. end;
  3647. end;
  3648. if (AButtons and ldEditIcon) = ldEditIcon then
  3649. begin
  3650. Bounds.Assign(Line,Size.Y-1,Line+6,Size.Y);
  3651. Insert(New(PCommandIcon,Init(Bounds,' Edit ',cmEdit)));
  3652. Inc(Line,6);
  3653. if (AButtons and ldDeleteIcon) <> 0 then
  3654. begin
  3655. Bounds.Assign(Line,Size.Y-1,Line+1,Size.Y);
  3656. Insert(New(PStaticText,Init(Bounds,'/')));
  3657. Inc(Line,1);
  3658. end;
  3659. end;
  3660. if (AButtons and ldNewIcon) = ldNewIcon then
  3661. begin
  3662. Bounds.Assign(Line,Size.Y-1,Line+5,Size.Y);
  3663. Insert(New(PCommandIcon,Init(Bounds,' Del ',cmDelete)));
  3664. end;
  3665. end;
  3666. { Set focus to list boLine when dialog opens }
  3667. SelectNext(False);
  3668. end;
  3669. {****************************************************************************}
  3670. { TListDlg.Load }
  3671. {****************************************************************************}
  3672. constructor TListDlg.Load (var S : TStream);
  3673. begin
  3674. if not TDialog.Load(S) then
  3675. Fail;
  3676. S.Read(NewCommand,SizeOf(NewCommand));
  3677. S.Read(EditCommand,SizeOf(EditCommand));
  3678. GetSubViewPtr(S,ListBox);
  3679. end;
  3680. {****************************************************************************}
  3681. { TListDlg.HandleEvent }
  3682. {****************************************************************************}
  3683. procedure TListDlg.HandleEvent (var Event : TEvent);
  3684. const
  3685. TargetCommands: TCommandSet = [cmNew, cmEdit, cmDelete];
  3686. begin
  3687. if ((Event.What and evCommand) <> 0) and
  3688. (Event.Command in TargetCommands) then
  3689. case Event.Command of
  3690. cmDelete:
  3691. if Options and ofDelete = ofDelete then
  3692. begin
  3693. ListBox^.FreeFocusedItem;
  3694. ListBox^.DrawView;
  3695. ClearEvent(Event);
  3696. end;
  3697. cmNew:
  3698. if Options and ofNew = ofNew then
  3699. begin
  3700. Message(Application,evCommand,NewCommand,nil);
  3701. ListBox^.SetRange(ListBox^.List^.Count);
  3702. ListBox^.DrawView;
  3703. ClearEvent(Event);
  3704. end;
  3705. cmEdit:
  3706. if Options and ofEdit = ofEdit then
  3707. begin
  3708. Message(Application,evCommand,EditCommand,ListBox^.GetFocusedItem);
  3709. ListBox^.DrawView;
  3710. ClearEvent(Event);
  3711. end;
  3712. end;
  3713. if (Event.What and evBroadcast > 0) and
  3714. (Event.Command = cmListItemSelected) then
  3715. begin { use PutEvent instead of Message so that a window list box works }
  3716. Event.What := evCommand;
  3717. Event.Command := cmOk;
  3718. Event.InfoPtr := nil;
  3719. PutEvent(Event);
  3720. end;
  3721. TDialog.HandleEvent(Event);
  3722. end;
  3723. {****************************************************************************}
  3724. { TListDlg.Store }
  3725. {****************************************************************************}
  3726. procedure TListDlg.Store (var S : TStream);
  3727. begin
  3728. TDialog.Store(S);
  3729. S.Write(NewCommand,SizeOf(NewCommand));
  3730. S.Write(EditCommand,SizeOf(EditCommand));
  3731. PutSubViewPtr(S,ListBox);
  3732. end;
  3733. {****************************************************************************}
  3734. { TModalInputLine Object }
  3735. {****************************************************************************}
  3736. {****************************************************************************}
  3737. { TModalInputLine.Execute }
  3738. {****************************************************************************}
  3739. function TModalInputLine.Execute : Word;
  3740. var Event : TEvent;
  3741. begin
  3742. repeat
  3743. EndState := 0;
  3744. repeat
  3745. GetEvent(Event);
  3746. HandleEvent(Event);
  3747. if Event.What <> evNothing
  3748. then Owner^.EventError(Event); { may change this to ClearEvent }
  3749. until (EndState <> 0);
  3750. until Valid(EndState);
  3751. Execute := EndState;
  3752. end;
  3753. {****************************************************************************}
  3754. { TModalInputLine.HandleEvent }
  3755. {****************************************************************************}
  3756. procedure TModalInputLine.HandleEvent (var Event : TEvent);
  3757. begin
  3758. case Event.What of
  3759. evKeyboard : case Event.KeyCode of
  3760. kbUp, kbDown : EndModal(cmCancel);
  3761. kbEnter : EndModal(cmOk);
  3762. else inherited HandleEvent(Event);
  3763. end;
  3764. evMouse : if MouseInView(Event.Where)
  3765. then inherited HandleEvent(Event)
  3766. else EndModal(cmCancel);
  3767. else inherited HandleEvent(Event);
  3768. end;
  3769. end;
  3770. {****************************************************************************}
  3771. { TModalInputLine.SetState }
  3772. {****************************************************************************}
  3773. procedure TModalInputLine.SetState (AState : Word; Enable : Boolean);
  3774. var Pos : Integer;
  3775. begin
  3776. if (AState = sfSelected)
  3777. then begin
  3778. Pos := CurPos;
  3779. inherited SetState(AState,Enable);
  3780. CurPos := Pos;
  3781. SelStart := CurPos;
  3782. SelEnd := CurPos;
  3783. BlockCursor;
  3784. DrawView;
  3785. end
  3786. else inherited SetState(AState,Enable);
  3787. end;
  3788. {***************************************************************************}
  3789. { INTERFACE ROUTINES }
  3790. {***************************************************************************}
  3791. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3792. { ITEM STRING ROUTINES }
  3793. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3794. {---------------------------------------------------------------------------}
  3795. { NewSItem -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  3796. {---------------------------------------------------------------------------}
  3797. FUNCTION NewSItem (Const Str: String; ANext: PSItem): PSItem;
  3798. VAR Item: PSItem;
  3799. BEGIN
  3800. New(Item); { Allocate item }
  3801. Item^.Value := NewStr(Str); { Hold item string }
  3802. Item^.Next := ANext; { Chain the ptr }
  3803. NewSItem := Item; { Return item }
  3804. END;
  3805. {****************************************************************************}
  3806. { NewCommandSItem }
  3807. {****************************************************************************}
  3808. function NewCommandSItem (Str : String; ACommand : Word;
  3809. ANext : PCommandSItem) : PCommandSItem;
  3810. var Temp : PCommandSItem;
  3811. begin
  3812. New(Temp);
  3813. if (Temp <> nil) then
  3814. begin
  3815. Temp^.Value := Str;
  3816. Temp^.Command := ACommand;
  3817. Temp^.Next := ANext;
  3818. end;
  3819. NewCommandSItem := Temp;
  3820. end;
  3821. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3822. { DIALOG OBJECT REGISTRATION ROUTINES }
  3823. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3824. {---------------------------------------------------------------------------}
  3825. { RegisterDialogs -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB }
  3826. {---------------------------------------------------------------------------}
  3827. PROCEDURE RegisterDialogs;
  3828. BEGIN
  3829. RegisterType(RDialog); { Register dialog }
  3830. RegisterType(RInputLine); { Register inputline }
  3831. RegisterType(RButton); { Register button }
  3832. RegisterType(RCluster); { Register cluster }
  3833. RegisterType(RRadioButtons); { Register radiobutton }
  3834. RegisterType(RCheckBoxes); { Register check boxes }
  3835. RegisterType(RMultiCheckBoxes); { Register multi boxes }
  3836. RegisterType(RListBox); { Register list box }
  3837. RegisterType(RStaticText); { Register static text }
  3838. RegisterType(RLabel); { Register label }
  3839. RegisterType(RHistory); { Register history }
  3840. RegisterType(RParamText); { Register parm text }
  3841. RegisterType(RCommandCheckBoxes);
  3842. RegisterType(RCommandIcon);
  3843. RegisterType(RCommandRadioButtons);
  3844. RegisterType(REditListBox);
  3845. RegisterType(RModalInputLine);
  3846. RegisterType(RListDlg);
  3847. END;
  3848. END.