dialogs.inc 197 KB

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