dialogs.pas 183 KB

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