dialogs.pas 191 KB

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