dialogs.pas 184 KB

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