dialogs.pas 183 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170
  1. {********[ SOURCE FILE OF GRAPHICAL FREE VISION ]**********}
  2. { }
  3. { System independent GRAPHICAL clone of DIALOGS.PAS }
  4. { }
  5. { Interface Copyright (c) 1992 Borland International }
  6. { }
  7. { Copyright (c) 1996, 1997, 1998, 1999 by Leon de Boer }
  8. { [email protected] - primary e-mail addr }
  9. { [email protected] - backup e-mail addr }
  10. { }
  11. {****************[ THIS CODE IS FREEWARE ]*****************}
  12. { }
  13. { This sourcecode is released for the purpose to }
  14. { promote the pascal language on all platforms. You may }
  15. { redistribute it and/or modify with the following }
  16. { DISCLAIMER. }
  17. { }
  18. { This SOURCE CODE is distributed "AS IS" WITHOUT }
  19. { WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR }
  20. { ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. }
  21. { }
  22. {*****************[ SUPPORTED PLATFORMS ]******************}
  23. { }
  24. { Only Free Pascal Compiler supported }
  25. { }
  26. {**********************************************************}
  27. UNIT Dialogs;
  28. {$CODEPAGE cp437}
  29. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  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: idDialog; { 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: idInputLine; { 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: idButton; { 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: idCluster; { 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: idRadioButtons; { 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: idCheckBoxes; { 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: idMultiCheckBoxes; { 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: idListBox; { 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: idStaticText; { 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: idLabel; { 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: idHistory; { 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: idParamText; { 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. resourcestring slCancel='Cancel';
  907. slOk='O~k~';
  908. slYes='~Y~es';
  909. slNo='~N~o';
  910. slHelp='~H~elp';
  911. slName='~N~ame';
  912. slOpen='~O~pen';
  913. slClose='~C~lose';
  914. slCloseAll='Cl~o~se all';
  915. slSave='~S~ave';
  916. slSaveAll='Save a~l~l';
  917. slSaveAs='S~a~ve as...';
  918. slSaveFileAs='~S~ave file as';
  919. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  920. IMPLEMENTATION
  921. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  922. USES App,HistList; { Standard GFV unit }
  923. {***************************************************************************}
  924. { PRIVATE DEFINED CONSTANTS }
  925. {***************************************************************************}
  926. {---------------------------------------------------------------------------}
  927. { LEFT AND RIGHT ARROW CHARACTER CONSTANTS }
  928. {---------------------------------------------------------------------------}
  929. CONST LeftArr = '<'; RightArr = '>';
  930. {---------------------------------------------------------------------------}
  931. { TButton MESSAGES }
  932. {---------------------------------------------------------------------------}
  933. CONST
  934. cmGrabDefault = 61; { Grab default }
  935. cmReleaseDefault = 62; { Release default }
  936. {---------------------------------------------------------------------------}
  937. { IsBlank -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  938. {---------------------------------------------------------------------------}
  939. FUNCTION IsBlank (Ch: Char): Boolean;
  940. BEGIN
  941. IsBlank := (Ch = ' ') OR (Ch = #13) OR (Ch = #10); { Check for characters }
  942. END;
  943. {---------------------------------------------------------------------------}
  944. { HotKey -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 08Jun98 LdB }
  945. {---------------------------------------------------------------------------}
  946. FUNCTION HotKey (Const S: String): Char;
  947. VAR I: Sw_Word;
  948. BEGIN
  949. HotKey := #0; { Preset fail }
  950. If (S <> '') Then Begin { Valid string }
  951. I := Pos('~', S); { Search for tilde }
  952. If (I <> 0) Then HotKey := UpCase(S[I+1]); { Return hotkey }
  953. End;
  954. END;
  955. {***************************************************************************}
  956. { OBJECT METHODS }
  957. {***************************************************************************}
  958. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  959. { TDialog OBJECT METHODS }
  960. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  961. {--TDialog------------------------------------------------------------------}
  962. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  963. {---------------------------------------------------------------------------}
  964. CONSTRUCTOR TDialog.Init (Var Bounds: TRect; ATitle: TTitleStr);
  965. BEGIN
  966. Inherited Init(Bounds, ATitle, wnNoNumber); { Call ancestor }
  967. Options := Options OR ofVersion20; { Version two dialog }
  968. GrowMode := 0; { Clear grow mode }
  969. Flags := wfMove + wfClose; { Close/moveable flags }
  970. Palette := dpGrayDialog; { Default gray colours }
  971. END;
  972. {--TDialog------------------------------------------------------------------}
  973. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  974. {---------------------------------------------------------------------------}
  975. CONSTRUCTOR TDialog.Load (Var S: TStream);
  976. BEGIN
  977. Inherited Load(S); { Call ancestor }
  978. If (Options AND ofVersion = ofVersion10) Then Begin
  979. Palette := dpGrayDialog; { Set gray palette }
  980. Options := Options OR ofVersion20; { Update version flag }
  981. End;
  982. END;
  983. {--TDialog------------------------------------------------------------------}
  984. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  985. {---------------------------------------------------------------------------}
  986. FUNCTION TDialog.GetPalette: PPalette;
  987. CONST P: Array[dpBlueDialog..dpGrayDialog] Of String[Length(CBlueDialog)] =
  988. (CBlueDialog, CCyanDialog, CGrayDialog); { Always normal string }
  989. BEGIN
  990. GetPalette := PPalette(@P[Palette]); { Return palette }
  991. END;
  992. {--TDialog------------------------------------------------------------------}
  993. { Valid -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 25Apr98 LdB }
  994. {---------------------------------------------------------------------------}
  995. FUNCTION TDialog.Valid (Command: Word): Boolean;
  996. BEGIN
  997. If (Command = cmCancel) Then Valid := True { Cancel returns true }
  998. Else Valid := TGroup.Valid(Command); { Call group ancestor }
  999. END;
  1000. {--TDialog------------------------------------------------------------------}
  1001. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1002. {---------------------------------------------------------------------------}
  1003. PROCEDURE TDialog.HandleEvent (Var Event: TEvent);
  1004. BEGIN
  1005. Inherited HandleEvent(Event); { Call ancestor }
  1006. Case Event.What Of
  1007. evNothing: Exit; { Speed up exit }
  1008. evKeyDown: { Key down event }
  1009. Case Event.KeyCode Of
  1010. kbEsc: Begin { Escape key press }
  1011. Event.What := evCommand; { Command event }
  1012. Event.Command := cmCancel; { cancel command }
  1013. Event.InfoPtr := Nil; { Clear info ptr }
  1014. PutEvent(Event); { Put event on queue }
  1015. ClearEvent(Event); { Clear the event }
  1016. End;
  1017. kbEnter: Begin { Enter key press }
  1018. Event.What := evBroadcast; { Broadcast event }
  1019. Event.Command := cmDefault; { Default command }
  1020. Event.InfoPtr := Nil; { Clear info ptr }
  1021. PutEvent(Event); { Put event on queue }
  1022. ClearEvent(Event); { Clear the event }
  1023. End;
  1024. End;
  1025. evCommand: { Command event }
  1026. Case Event.Command Of
  1027. cmOk, cmCancel, cmYes, cmNo: { End dialog cmds }
  1028. If (State AND sfModal <> 0) Then Begin { View is modal }
  1029. EndModal(Event.Command); { End modal state }
  1030. ClearEvent(Event); { Clear the event }
  1031. End;
  1032. End;
  1033. End;
  1034. END;
  1035. {****************************************************************************}
  1036. { TDialog.Cancel }
  1037. {****************************************************************************}
  1038. procedure TDialog.Cancel (ACommand : Word);
  1039. begin
  1040. if State and sfModal = sfModal then
  1041. EndModal(ACommand)
  1042. else Close;
  1043. end;
  1044. {****************************************************************************}
  1045. { TDialog.ChangeTitle }
  1046. {****************************************************************************}
  1047. procedure TDialog.ChangeTitle (ANewTitle : TTitleStr);
  1048. begin
  1049. if (Title <> nil) then
  1050. DisposeStr(Title);
  1051. Title := NewStr(ANewTitle);
  1052. Frame^.DrawView;
  1053. end;
  1054. {****************************************************************************}
  1055. { TDialog.FreeSubView }
  1056. {****************************************************************************}
  1057. procedure TDialog.FreeSubView (ASubView : PView);
  1058. begin
  1059. if IsSubView(ASubView) then begin
  1060. Delete(ASubView);
  1061. Dispose(ASubView,Done);
  1062. DrawView;
  1063. end;
  1064. end;
  1065. {****************************************************************************}
  1066. { TDialog.FreeAllSubViews }
  1067. {****************************************************************************}
  1068. procedure TDialog.FreeAllSubViews;
  1069. var
  1070. P : PView;
  1071. begin
  1072. P := First;
  1073. repeat
  1074. P := First;
  1075. if (P <> nil) then begin
  1076. Delete(P);
  1077. Dispose(P,Done);
  1078. end;
  1079. until (P = nil);
  1080. DrawView;
  1081. end;
  1082. {****************************************************************************}
  1083. { TDialog.IsSubView }
  1084. {****************************************************************************}
  1085. function TDialog.IsSubView (AView : PView) : Boolean;
  1086. var P : PView;
  1087. begin
  1088. P := First;
  1089. while (P <> nil) and (P <> AView) do
  1090. P := P^.NextView;
  1091. IsSubView := ((P <> nil) and (P = AView));
  1092. end;
  1093. {****************************************************************************}
  1094. { TDialog.NewButton }
  1095. {****************************************************************************}
  1096. function TDialog.NewButton (X, Y, W, H : Sw_Integer; ATitle : TTitleStr;
  1097. ACommand, AHelpCtx : Word;
  1098. AFlags : Byte) : PButton;
  1099. var
  1100. B : PButton;
  1101. R : TRect;
  1102. begin
  1103. R.Assign(X,Y,X+W,Y+H);
  1104. B := New(PButton,Init(R,ATitle,ACommand,AFlags));
  1105. if (B <> nil) then begin
  1106. B^.HelpCtx := AHelpCtx;
  1107. Insert(B);
  1108. end;
  1109. NewButton := B;
  1110. end;
  1111. {****************************************************************************}
  1112. { TDialog.NewInputLine }
  1113. {****************************************************************************}
  1114. function TDialog.NewInputLine (X, Y, W, AMaxLen : Sw_Integer; AHelpCtx : Word
  1115. ; AValidator : PValidator) : PInputLine;
  1116. var
  1117. P : PInputLine;
  1118. R : TRect;
  1119. begin
  1120. R.Assign(X,Y,X+W,Y+1);
  1121. P := New(PInputLine,Init(R,AMaxLen));
  1122. if (P <> nil) then begin
  1123. P^.SetValidator(AValidator);
  1124. P^.HelpCtx := AHelpCtx;
  1125. Insert(P);
  1126. end;
  1127. NewInputLine := P;
  1128. end;
  1129. {****************************************************************************}
  1130. { TDialog.NewLabel }
  1131. {****************************************************************************}
  1132. function TDialog.NewLabel (X, Y : Sw_Integer; AText : String;
  1133. ALink : PView) : PLabel;
  1134. var
  1135. P : PLabel;
  1136. R : TRect;
  1137. begin
  1138. R.Assign(X,Y,X+CStrLen(AText)+1,Y+1);
  1139. P := New(PLabel,Init(R,AText,ALink));
  1140. if (P <> nil) then
  1141. Insert(P);
  1142. NewLabel := P;
  1143. end;
  1144. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1145. { TInputLine OBJECT METHODS }
  1146. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1147. {--TInputLine---------------------------------------------------------------}
  1148. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1149. {---------------------------------------------------------------------------}
  1150. CONSTRUCTOR TInputLine.Init (Var Bounds: TRect; AMaxLen: Sw_Integer);
  1151. BEGIN
  1152. Inherited Init(Bounds); { Call ancestor }
  1153. State := State OR sfCursorVis; { Cursor visible }
  1154. Options := Options OR (ofSelectable + ofFirstClick
  1155. + ofVersion20); { Set options }
  1156. If (MaxAvail > AMaxLen + 1) Then Begin { Check enough memory }
  1157. GetMem(Data, AMaxLen + 1); { Allocate memory }
  1158. Data^ := ''; { Data = empty string }
  1159. End;
  1160. MaxLen := AMaxLen; { Hold maximum length }
  1161. END;
  1162. {--TInputLine---------------------------------------------------------------}
  1163. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1164. {---------------------------------------------------------------------------}
  1165. CONSTRUCTOR TInputLine.Load (Var S: TStream);
  1166. VAR B: Byte;
  1167. W: Word;
  1168. BEGIN
  1169. Inherited Load(S); { Call ancestor }
  1170. S.Read(W, sizeof(w)); MaxLen:=W; { Read max length }
  1171. S.Read(W, sizeof(w)); CurPos:=w; { Read cursor position }
  1172. S.Read(W, sizeof(w)); FirstPos:=w; { Read first position }
  1173. S.Read(W, sizeof(w)); SelStart:=w; { Read selected start }
  1174. S.Read(W, sizeof(w)); SelEnd:=w; { Read selected end }
  1175. S.Read(B, SizeOf(B)); { Read string length }
  1176. GetMem(Data, B + 1); { Allocate memory }
  1177. S.Read(Data^[1], B); { Read string data }
  1178. SetLength(Data^, B); { Xfer string length }
  1179. If (Options AND ofVersion >= ofVersion20) Then { Version 2 or above }
  1180. Validator := PValidator(S.Get); { Get any validator }
  1181. Options := Options OR ofVersion20; { Set version 2 flag }
  1182. END;
  1183. {--TInputLine---------------------------------------------------------------}
  1184. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1185. {---------------------------------------------------------------------------}
  1186. DESTRUCTOR TInputLine.Done;
  1187. BEGIN
  1188. If (Data <> Nil) Then FreeMem(Data, MaxLen + 1); { Release any memory }
  1189. SetValidator(Nil); { Clear any validator }
  1190. Inherited Done; { Call ancestor }
  1191. END;
  1192. {--TInputLine---------------------------------------------------------------}
  1193. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1194. {---------------------------------------------------------------------------}
  1195. FUNCTION TInputLine.DataSize: Sw_Word;
  1196. VAR DSize: Sw_Word;
  1197. BEGIN
  1198. DSize := 0; { Preset zero datasize }
  1199. If (Validator <> Nil) AND (Data <> Nil) Then
  1200. DSize := Validator^.Transfer(Data^, Nil,
  1201. vtDataSize); { Add validator size }
  1202. If (DSize <> 0) Then DataSize := DSize { Use validtor size }
  1203. Else DataSize := MaxLen + 1; { No validator use size }
  1204. END;
  1205. {--TInputLine---------------------------------------------------------------}
  1206. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1207. {---------------------------------------------------------------------------}
  1208. FUNCTION TInputLine.GetPalette: PPalette;
  1209. CONST P: String[Length(CInputLine)] = CInputLine; { Always normal string }
  1210. BEGIN
  1211. GetPalette := PPalette(@P); { Return palette }
  1212. END;
  1213. {--TInputLine---------------------------------------------------------------}
  1214. { Valid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1215. {---------------------------------------------------------------------------}
  1216. FUNCTION TInputLine.Valid (Command: Word): Boolean;
  1217. FUNCTION AppendError (AValidator: PValidator): Boolean;
  1218. BEGIN
  1219. AppendError := False; { Preset false }
  1220. If (Data <> Nil) Then
  1221. With AValidator^ Do
  1222. If (Options AND voOnAppend <> 0) AND { Check options }
  1223. (CurPos <> Length(Data^)) AND { Exceeds max length }
  1224. NOT IsValidInput(Data^, True) Then Begin { Check data valid }
  1225. Error; { Call error }
  1226. AppendError := True; { Return true }
  1227. End;
  1228. END;
  1229. BEGIN
  1230. Valid := Inherited Valid(Command); { Call ancestor }
  1231. If (Validator <> Nil) AND (Data <> Nil) AND { Validator present }
  1232. (State AND sfDisabled = 0) Then { Not disabled }
  1233. If (Command = cmValid) Then { Valid command }
  1234. Valid := Validator^.Status = vsOk { Validator result }
  1235. Else If (Command <> cmCancel) Then { Not cancel command }
  1236. If AppendError(Validator) OR { Append any error }
  1237. NOT Validator^.Valid(Data^) Then Begin { Check validator }
  1238. Select; { Reselect view }
  1239. Valid := False; { Return false }
  1240. End;
  1241. END;
  1242. {--TInputLine---------------------------------------------------------------}
  1243. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1244. {---------------------------------------------------------------------------}
  1245. PROCEDURE TInputLine.Draw;
  1246. VAR Color: Byte; L, R: Sw_Integer;
  1247. B : TDrawBuffer;
  1248. BEGIN
  1249. if Options and ofSelectable = 0 then
  1250. Color := GetColor(5)
  1251. else
  1252. If (State AND sfFocused = 0) Then
  1253. Color := GetColor(1) { Not focused colour }
  1254. Else
  1255. Color := GetColor(2); { Focused colour }
  1256. MoveChar(B, ' ', Color, Size.X);
  1257. MoveStr(B[1], Copy(Data^, FirstPos + 1, Size.X - 2), Color);
  1258. if CanScroll(1) then
  1259. MoveChar(B[Size.X - 1], RightArr, GetColor(4), 1);
  1260. if (State and sfFocused <> 0) and
  1261. (Options and ofSelectable <> 0) then
  1262. begin
  1263. if CanScroll(-1) then
  1264. MoveChar(B[0], LeftArr, GetColor(4), 1);
  1265. { Highlighted part }
  1266. L := SelStart - FirstPos;
  1267. R := SelEnd - FirstPos;
  1268. if L < 0 then
  1269. L := 0;
  1270. if R > Size.X - 2 then
  1271. R := Size.X - 2;
  1272. if L < R then
  1273. MoveChar(B[L + 1], #0, GetColor(3), R - L);
  1274. SetCursor(CurPos - FirstPos + 1, 0);
  1275. end;
  1276. WriteLine(0, 0, Size.X, Size.Y, B);
  1277. end;
  1278. {--TInputLine---------------------------------------------------------------}
  1279. { DrawCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Oct99 LdB }
  1280. {---------------------------------------------------------------------------}
  1281. PROCEDURE TInputLine.DrawCursor;
  1282. BEGIN
  1283. If (State AND sfFocused <> 0) Then
  1284. Begin { Focused window }
  1285. Cursor.Y:=0;
  1286. Cursor.X:=CurPos-FirstPos+1;
  1287. ResetCursor;
  1288. end;
  1289. END;
  1290. {--TInputLine---------------------------------------------------------------}
  1291. { SelectAll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1292. {---------------------------------------------------------------------------}
  1293. PROCEDURE TInputLine.SelectAll (Enable: Boolean);
  1294. BEGIN
  1295. CurPos := 0; { Cursor to start }
  1296. FirstPos := 0; { First pos to start }
  1297. SelStart := 0; { Selected at start }
  1298. If Enable AND (Data <> Nil) Then
  1299. SelEnd := Length(Data^) Else SelEnd := 0; { Selected which end }
  1300. DrawView; { Now redraw the view }
  1301. END;
  1302. {--TInputLine---------------------------------------------------------------}
  1303. { SetValidator -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1304. {---------------------------------------------------------------------------}
  1305. PROCEDURE TInputLine.SetValidator (AValid: PValidator);
  1306. BEGIN
  1307. If (Validator <> Nil) Then Validator^.Free; { Release validator }
  1308. Validator := AValid; { Set new validator }
  1309. END;
  1310. {--TInputLine---------------------------------------------------------------}
  1311. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1312. {---------------------------------------------------------------------------}
  1313. PROCEDURE TInputLine.SetState (AState: Word; Enable: Boolean);
  1314. BEGIN
  1315. Inherited SetState(AState, Enable); { Call ancestor }
  1316. If (AState = sfSelected) OR ((AState = sfActive)
  1317. AND (State and sfSelected <> 0)) Then
  1318. SelectAll(Enable) Else { Call select all }
  1319. If (AState = sfFocused) Then DrawView; { Redraw for focus }
  1320. END;
  1321. {--TInputLine---------------------------------------------------------------}
  1322. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1323. {---------------------------------------------------------------------------}
  1324. PROCEDURE TInputLine.GetData (Var Rec);
  1325. BEGIN
  1326. If (Data <> Nil) Then Begin { Data ptr valid }
  1327. If (Validator = Nil) OR (Validator^.Transfer(Data^,
  1328. @Rec, vtGetData) = 0) Then Begin { No validator/data }
  1329. FillChar(Rec, DataSize, #0); { Clear the data area }
  1330. Move(Data^, Rec, Length(Data^) + 1); { Transfer our data }
  1331. End;
  1332. End Else FillChar(Rec, DataSize, #0); { Clear the data area }
  1333. END;
  1334. {--TInputLine---------------------------------------------------------------}
  1335. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1336. {---------------------------------------------------------------------------}
  1337. PROCEDURE TInputLine.SetData (Var Rec);
  1338. BEGIN
  1339. If (Data <> Nil) Then Begin { Data ptr valid }
  1340. If (Validator = Nil) OR (Validator^.Transfer(
  1341. Data^, @Rec, vtSetData) = 0) Then { No validator/data }
  1342. Move(Rec, Data^[0], DataSize); { Set our data }
  1343. End;
  1344. SelectAll(True); { Now select all }
  1345. END;
  1346. {--TInputLine---------------------------------------------------------------}
  1347. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1348. {---------------------------------------------------------------------------}
  1349. PROCEDURE TInputLine.Store (Var S: TStream);
  1350. VAR w: Word;
  1351. BEGIN
  1352. TView.Store(S); { Implict TView.Store }
  1353. w:=MaxLen;S.Write(w, SizeOf(w)); { Read max length }
  1354. w:=CurPos;S.Write(w, SizeOf(w)); { Read cursor position }
  1355. w:=FirstPos;S.Write(w, SizeOf(w)); { Read first position }
  1356. w:=SelStart;S.Write(w, SizeOf(w)); { Read selected start }
  1357. w:=SelEnd;S.Write(w, SizeOf(w)); { Read selected end }
  1358. S.WriteStr(Data); { Write the data }
  1359. S.Put(Validator); { Write any validator }
  1360. END;
  1361. {--TInputLine---------------------------------------------------------------}
  1362. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1363. {---------------------------------------------------------------------------}
  1364. PROCEDURE TInputLine.HandleEvent (Var Event: TEvent);
  1365. CONST PadKeys = [$47, $4B, $4D, $4F, $73, $74];
  1366. VAR WasAppending: Boolean; ExtendBlock: Boolean; OldData: String;
  1367. Delta, Anchor, OldCurPos, OldFirstPos, OldSelStart, OldSelEnd: Sw_Integer;
  1368. FUNCTION MouseDelta: Sw_Integer;
  1369. VAR Mouse : TPOint;
  1370. BEGIN
  1371. MakeLocal(Event.Where, Mouse);
  1372. if Mouse.X <= 0 then
  1373. MouseDelta := -1
  1374. else if Mouse.X >= Size.X - 1 then
  1375. MouseDelta := 1
  1376. else
  1377. MouseDelta := 0;
  1378. END;
  1379. FUNCTION MousePos: Sw_Integer;
  1380. VAR Pos: Sw_Integer;
  1381. Mouse : TPoint;
  1382. BEGIN
  1383. MakeLocal(Event.Where, Mouse);
  1384. if Mouse.X < 1 then Mouse.X := 1;
  1385. Pos := Mouse.X + FirstPos - 1;
  1386. if Pos < 0 then Pos := 0;
  1387. if Pos > Length(Data^) then Pos := Length(Data^);
  1388. MousePos := Pos;
  1389. END;
  1390. PROCEDURE DeleteSelect;
  1391. BEGIN
  1392. If (SelStart <> SelEnd) Then Begin { An area selected }
  1393. If (Data <> Nil) Then
  1394. Delete(Data^, SelStart+1, SelEnd-SelStart); { Delete the text }
  1395. CurPos := SelStart; { Set cursor position }
  1396. End;
  1397. END;
  1398. PROCEDURE AdjustSelectBlock;
  1399. BEGIN
  1400. If (CurPos < Anchor) Then Begin { Selection backwards }
  1401. SelStart := CurPos; { Start of select }
  1402. SelEnd := Anchor; { End of select }
  1403. End Else Begin
  1404. SelStart := Anchor; { Start of select }
  1405. SelEnd := CurPos; { End of select }
  1406. End;
  1407. END;
  1408. PROCEDURE SaveState;
  1409. BEGIN
  1410. If (Validator <> Nil) Then Begin { Check for validator }
  1411. If (Data <> Nil) Then OldData := Data^; { Hold data }
  1412. OldCurPos := CurPos; { Hold cursor position }
  1413. OldFirstPos := FirstPos; { Hold first position }
  1414. OldSelStart := SelStart; { Hold select start }
  1415. OldSelEnd := SelEnd; { Hold select end }
  1416. If (Data = Nil) Then WasAppending := True { Invalid data ptr }
  1417. Else WasAppending := Length(Data^) = CurPos; { Hold appending state }
  1418. End;
  1419. END;
  1420. PROCEDURE RestoreState;
  1421. BEGIN
  1422. If (Validator <> Nil) Then Begin { Validator valid }
  1423. If (Data <> Nil) Then Data^ := OldData; { Restore data }
  1424. CurPos := OldCurPos; { Restore cursor pos }
  1425. FirstPos := OldFirstPos; { Restore first pos }
  1426. SelStart := OldSelStart; { Restore select start }
  1427. SelEnd := OldSelEnd; { Restore select end }
  1428. End;
  1429. END;
  1430. FUNCTION CheckValid (NoAutoFill: Boolean): Boolean;
  1431. VAR OldLen: Sw_Integer; NewData: String;
  1432. BEGIN
  1433. If (Validator <> Nil) Then Begin { Validator valid }
  1434. CheckValid := False; { Preset false return }
  1435. If (Data <> Nil) Then OldLen := Length(Data^); { Hold old length }
  1436. If (Validator^.Options AND voOnAppend = 0) OR
  1437. (WasAppending AND (CurPos = OldLen)) Then Begin
  1438. If (Data <> Nil) Then NewData := Data^ { Hold current data }
  1439. Else NewData := ''; { Set empty string }
  1440. If NOT Validator^.IsValidInput(NewData,
  1441. NoAutoFill) Then RestoreState Else Begin
  1442. If (Length(NewData) > MaxLen) Then { Exceeds maximum }
  1443. SetLength(NewData, MaxLen); { Set string length }
  1444. If (Data <> Nil) Then Data^ := NewData; { Set data value }
  1445. If (Data <> Nil) AND (CurPos >= OldLen) { Cursor beyond end }
  1446. AND (Length(Data^) > OldLen) Then { Cursor beyond string }
  1447. CurPos := Length(Data^); { Set cursor position }
  1448. CheckValid := True; { Return true result }
  1449. End;
  1450. End Else Begin
  1451. CheckValid := True; { Preset true return }
  1452. If (CurPos = OldLen) AND (Data <> Nil) Then { Lengths match }
  1453. If NOT Validator^.IsValidInput(Data^,
  1454. False) Then Begin { Check validator }
  1455. Validator^.Error; { Call error }
  1456. CheckValid := False; { Return false result }
  1457. End;
  1458. End;
  1459. End Else CheckValid := True; { No validator }
  1460. END;
  1461. BEGIN
  1462. Inherited HandleEvent(Event); { Call ancestor }
  1463. If (State AND sfSelected <> 0) Then Begin { View is selected }
  1464. Case Event.What Of
  1465. evNothing: Exit; { Speed up exit }
  1466. evMouseDown: Begin { Mouse down event }
  1467. Delta := MouseDelta; { Calc scroll value }
  1468. If CanScroll(Delta) Then Begin { Can scroll }
  1469. Repeat
  1470. If CanScroll(Delta) Then Begin { Still can scroll }
  1471. Inc(FirstPos, Delta); { Move start position }
  1472. DrawView; { Redraw the view }
  1473. End;
  1474. Until NOT MouseEvent(Event, evMouseAuto); { Until no mouse auto }
  1475. End Else If Event.Double Then { Double click }
  1476. SelectAll(True) Else Begin { Select whole text }
  1477. Anchor := MousePos; { Start of selection }
  1478. Repeat
  1479. If (Event.What = evMouseAuto) { Mouse auto event }
  1480. Then Begin
  1481. Delta := MouseDelta; { New position }
  1482. If CanScroll(Delta) Then { If can scroll }
  1483. Inc(FirstPos, Delta);
  1484. End;
  1485. CurPos := MousePos; { Set cursor position }
  1486. AdjustSelectBlock; { Adjust selected }
  1487. DrawView; { Redraw the view }
  1488. Until NOT MouseEvent(Event, evMouseMove
  1489. + evMouseAuto); { Until mouse released }
  1490. End;
  1491. ClearEvent(Event); { Clear the event }
  1492. End;
  1493. evKeyDown: Begin
  1494. SaveState; { Save state of view }
  1495. Event.KeyCode := CtrlToArrow(Event.KeyCode); { Convert keycode }
  1496. If (Event.ScanCode IN PadKeys) AND
  1497. (GetShiftState AND $03 <> 0) Then Begin { Mark selection active }
  1498. Event.CharCode := #0; { Clear char code }
  1499. If (CurPos = SelEnd) Then { Find if at end }
  1500. Anchor := SelStart Else { Anchor from start }
  1501. Anchor := SelEnd; { Anchor from end }
  1502. ExtendBlock := True; { Extended block true }
  1503. End Else ExtendBlock := False; { No extended block }
  1504. Case Event.KeyCode Of
  1505. kbLeft: If (CurPos > 0) Then Dec(CurPos); { Move cursor left }
  1506. kbRight: If (Data <> Nil) AND { Move right cursor }
  1507. (CurPos < Length(Data^)) Then Begin { Check not at end }
  1508. Inc(CurPos); { Move cursor }
  1509. CheckValid(True); { Check if valid }
  1510. End;
  1511. kbHome: CurPos := 0; { Move to line start }
  1512. kbEnd: Begin { Move to line end }
  1513. If (Data = Nil) Then CurPos := 0 { Invalid data ptr }
  1514. Else CurPos := Length(Data^); { Set cursor position }
  1515. CheckValid(True); { Check if valid }
  1516. End;
  1517. kbBack: If (Data <> Nil) AND (CurPos > 0) { Not at line start }
  1518. Then Begin
  1519. Delete(Data^, CurPos, 1); { Backspace over char }
  1520. Dec(CurPos); { Move cursor back one }
  1521. If (FirstPos > 0) Then Dec(FirstPos); { Move first position }
  1522. CheckValid(True); { Check if valid }
  1523. End;
  1524. kbDel: If (Data <> Nil) Then Begin { Delete character }
  1525. If (SelStart = SelEnd) Then { Select all on }
  1526. If (CurPos < Length(Data^)) Then Begin { Cursor not at end }
  1527. SelStart := CurPos; { Set select start }
  1528. SelEnd := CurPos + 1; { Set select end }
  1529. End;
  1530. DeleteSelect; { Deselect selection }
  1531. CheckValid(True); { Check if valid }
  1532. End;
  1533. kbIns: SetState(sfCursorIns, State AND
  1534. sfCursorIns = 0); { Flip insert state }
  1535. Else Case Event.CharCode Of
  1536. ' '..#255: If (Data <> Nil) Then Begin { Character key }
  1537. If (State AND sfCursorIns <> 0) Then
  1538. Delete(Data^, CurPos + 1, 1) Else { Overwrite character }
  1539. DeleteSelect; { Deselect selected }
  1540. If CheckValid(True) Then Begin { Check data valid }
  1541. If (Length(Data^) < MaxLen) Then { Must not exceed maxlen }
  1542. Begin
  1543. If (FirstPos > CurPos) Then
  1544. FirstPos := CurPos; { Advance first position }
  1545. Inc(CurPos); { Increment cursor }
  1546. Insert(Event.CharCode, Data^,
  1547. CurPos); { Insert the character }
  1548. End;
  1549. CheckValid(False); { Check data valid }
  1550. End;
  1551. End;
  1552. ^Y: If (Data <> Nil) Then Begin { Clear all data }
  1553. Data^ := ''; { Set empty string }
  1554. CurPos := 0; { Cursor to start }
  1555. End;
  1556. Else Exit; { Unused key }
  1557. End
  1558. End;
  1559. If ExtendBlock Then AdjustSelectBlock { Extended block }
  1560. Else Begin
  1561. SelStart := CurPos; { Set select start }
  1562. SelEnd := CurPos; { Set select end }
  1563. End;
  1564. If (FirstPos > CurPos) Then
  1565. FirstPos := CurPos; { Advance first pos }
  1566. If (Data <> Nil) Then OldData := Copy(Data^,
  1567. FirstPos+1, CurPos-FirstPos) { Text area string }
  1568. Else OldData := ''; { Empty string }
  1569. Delta := 1; { Safety = 1 char }
  1570. While (TextWidth(OldData) > (Size.X-Delta)
  1571. - TextWidth(LeftArr) - TextWidth(RightArr)) { Check text fits }
  1572. Do Begin
  1573. Inc(FirstPos); { Advance first pos }
  1574. OldData := Copy(Data^, FirstPos+1,
  1575. CurPos-FirstPos) { Text area string }
  1576. End;
  1577. DrawView; { Redraw the view }
  1578. ClearEvent(Event); { Clear the event }
  1579. End;
  1580. End;
  1581. End;
  1582. END;
  1583. {***************************************************************************}
  1584. { TInputLine OBJECT PRIVATE METHODS }
  1585. {***************************************************************************}
  1586. {--TInputLine---------------------------------------------------------------}
  1587. { CanScroll -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1588. {---------------------------------------------------------------------------}
  1589. FUNCTION TInputLine.CanScroll (Delta: Sw_Integer): Boolean;
  1590. VAR S: String;
  1591. BEGIN
  1592. If (Delta < 0) Then CanScroll := FirstPos > 0 { Check scroll left }
  1593. Else If (Delta > 0) Then Begin
  1594. If (Data = Nil) Then S := '' Else { Data ptr invalid }
  1595. S := Copy(Data^, FirstPos+1, Length(Data^)
  1596. - FirstPos); { Fetch max string }
  1597. CanScroll := (TextWidth(S)) > (Size.X -
  1598. TextWidth(LeftArr) - TextWidth(RightArr)); { Check scroll right }
  1599. End Else CanScroll := False; { Zero so no scroll }
  1600. END;
  1601. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1602. { TButton OBJECT METHODS }
  1603. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1604. {--TButton------------------------------------------------------------------}
  1605. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1606. {---------------------------------------------------------------------------}
  1607. CONSTRUCTOR TButton.Init (Var Bounds: TRect; ATitle: TTitleStr;
  1608. ACommand: Word; AFlags: Word);
  1609. BEGIN
  1610. Inherited Init(Bounds); { Call ancestor }
  1611. EventMask := EventMask OR evBroadcast; { Handle broadcasts }
  1612. Options := Options OR (ofSelectable + ofFirstClick
  1613. + ofPreProcess + ofPostProcess); { Set option flags }
  1614. If NOT CommandEnabled(ACommand) Then
  1615. State := State OR sfDisabled; { Check command state }
  1616. Flags := AFlags; { Hold flags }
  1617. If (AFlags AND bfDefault <> 0) Then AmDefault := True
  1618. Else AmDefault := False; { Check if default }
  1619. Title := NewStr(ATitle); { Hold title string }
  1620. Command := ACommand; { Hold button command }
  1621. TabMask := TabMask OR (tmLeft + tmRight +
  1622. tmTab + tmShiftTab + tmUp + tmDown); { Set tab masks }
  1623. END;
  1624. {--TButton------------------------------------------------------------------}
  1625. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1626. {---------------------------------------------------------------------------}
  1627. CONSTRUCTOR TButton.Load (Var S: TStream);
  1628. BEGIN
  1629. Inherited Load(S); { Call ancestor }
  1630. Title := S.ReadStr; { Read title }
  1631. S.Read(Command, SizeOf(Command)); { Read command }
  1632. S.Read(Flags, SizeOf(Flags)); { Read flags }
  1633. S.Read(AmDefault, SizeOf(AmDefault)); { Read if default }
  1634. If NOT CommandEnabled(Command) Then { Check command state }
  1635. State := State OR sfDisabled Else { Command disabled }
  1636. State := State AND NOT sfDisabled; { Command enabled }
  1637. END;
  1638. {--TButton------------------------------------------------------------------}
  1639. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1640. {---------------------------------------------------------------------------}
  1641. DESTRUCTOR TButton.Done;
  1642. BEGIN
  1643. If (Title <> Nil) Then DisposeStr(Title); { Dispose title }
  1644. Inherited Done; { Call ancestor }
  1645. END;
  1646. {--TButton------------------------------------------------------------------}
  1647. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Apr98 LdB }
  1648. {---------------------------------------------------------------------------}
  1649. FUNCTION TButton.GetPalette: PPalette;
  1650. CONST P: String[Length(CButton)] = CButton; { Always normal string }
  1651. BEGIN
  1652. GetPalette := PPalette(@P); { Get button palette }
  1653. END;
  1654. {--TButton------------------------------------------------------------------}
  1655. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Apr98 LdB }
  1656. {---------------------------------------------------------------------------}
  1657. PROCEDURE TButton.Press;
  1658. VAR E: TEvent;
  1659. BEGIN
  1660. Message(Owner, evBroadcast, cmRecordHistory, Nil); { Message for history }
  1661. If (Flags AND bfBroadcast <> 0) Then { Broadcasting button }
  1662. Message(Owner, evBroadcast, Command, @Self) { Send message }
  1663. Else Begin
  1664. E.What := evCommand; { Command event }
  1665. E.Command := Command; { Set command value }
  1666. E.InfoPtr := @Self; { Pointer to self }
  1667. PutEvent(E); { Put event on queue }
  1668. End;
  1669. END;
  1670. {--TButton------------------------------------------------------------------}
  1671. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1672. {---------------------------------------------------------------------------}
  1673. PROCEDURE TButton.Draw;
  1674. VAR I, J, Pos: Sw_Integer;
  1675. Bc: Word; Db: TDrawBuffer;
  1676. C : char;
  1677. BEGIN
  1678. If (State AND sfDisabled <> 0) Then { Button disabled }
  1679. Bc := GetColor($0404) Else Begin { Disabled colour }
  1680. Bc := GetColor($0501); { Set normal colour }
  1681. If (State AND sfActive <> 0) Then { Button is active }
  1682. If (State AND sfSelected <> 0) Then
  1683. Bc := GetColor($0703) Else { Set selected colour }
  1684. If AmDefault Then Bc := GetColor($0602); { Set is default colour }
  1685. End;
  1686. if title=nil then
  1687. begin
  1688. MoveChar(Db[0],' ',GetColor(8),1);
  1689. {No title, draw an empty button.}
  1690. for j:=sw_integer(downflag) to size.x-2 do
  1691. MoveChar(Db[j],' ',Bc,1);
  1692. end
  1693. else
  1694. {We have a title.}
  1695. begin
  1696. If (Flags AND bfLeftJust = 0) Then Begin { Not left set title }
  1697. I := CTextWidth(Title^); { Fetch title width }
  1698. I := (Size.X - I) DIV 2; { Centre in button }
  1699. End
  1700. Else
  1701. I := 1; { Left edge of button }
  1702. If DownFlag then
  1703. begin
  1704. MoveChar(Db[0],' ',GetColor(8),1);
  1705. Pos:=1;
  1706. end
  1707. else
  1708. pos:=0;
  1709. For j:=0 to I-1 do
  1710. MoveChar(Db[pos+j],' ',Bc,1);
  1711. MoveCStr(Db[I+pos], Title^, Bc); { Move title to buffer }
  1712. For j:=pos+CStrLen(Title^)+I to size.X-2 do
  1713. MoveChar(Db[j],' ',Bc,1);
  1714. end;
  1715. If not DownFlag then
  1716. Bc:=GetColor(8);
  1717. MoveChar(Db[Size.X-1],' ',Bc,1);
  1718. WriteLine(0, 0, Size.X,1, Db); { Write the title }
  1719. If Size.Y>1 then Begin
  1720. Bc:=GetColor(8);
  1721. if not DownFlag then
  1722. begin
  1723. c:='Ü';
  1724. MoveChar(Db,c,Bc,1);
  1725. WriteLine(Size.X-1, 0, 1, 1, Db);
  1726. end;
  1727. MoveChar(Db,' ',Bc,1);
  1728. if DownFlag then c:=' '
  1729. else c:='ß';
  1730. MoveChar(Db[1],c,Bc,Size.X-1);
  1731. WriteLine(0, 1, Size.X, 1, Db);
  1732. End;
  1733. END;
  1734. {--TButton------------------------------------------------------------------}
  1735. { DrawState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1736. {---------------------------------------------------------------------------}
  1737. PROCEDURE TButton.DrawState (Down: Boolean);
  1738. BEGIN
  1739. DownFlag := Down; { Set down flag }
  1740. DrawView; { Redraw the view }
  1741. END;
  1742. {--TButton------------------------------------------------------------------}
  1743. { MakeDefault -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1744. {---------------------------------------------------------------------------}
  1745. PROCEDURE TButton.MakeDefault (Enable: Boolean);
  1746. VAR C: Word;
  1747. BEGIN
  1748. If (Flags AND bfDefault=0) Then Begin { Not default }
  1749. If Enable Then C := cmGrabDefault
  1750. Else C := cmReleaseDefault; { Change default }
  1751. Message(Owner, evBroadcast, C, @Self); { Message to owner }
  1752. AmDefault := Enable; { Set default flag }
  1753. DrawView; { Now redraw button }
  1754. End;
  1755. END;
  1756. {--TButton------------------------------------------------------------------}
  1757. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Oct99 LdB }
  1758. {---------------------------------------------------------------------------}
  1759. PROCEDURE TButton.SetState (AState: Word; Enable: Boolean);
  1760. BEGIN
  1761. Inherited SetState(AState, Enable); { Call ancestor }
  1762. If (AState AND (sfSelected + sfActive) <> 0) { Changing select }
  1763. Then DrawView; { Redraw required }
  1764. If (AState AND sfFocused <> 0) Then
  1765. MakeDefault(Enable); { Check for default }
  1766. END;
  1767. {--TButton------------------------------------------------------------------}
  1768. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  1769. {---------------------------------------------------------------------------}
  1770. PROCEDURE TButton.Store (Var S: TStream);
  1771. BEGIN
  1772. TView.Store(S); { Implict TView.Store }
  1773. S.WriteStr(Title); { Store title string }
  1774. S.Write(Command, SizeOf(Command)); { Store command }
  1775. S.Write(Flags, SizeOf(Flags)); { Store flags }
  1776. S.Write(AmDefault, SizeOf(AmDefault)); { Store default flag }
  1777. END;
  1778. {--TButton------------------------------------------------------------------}
  1779. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Sep99 LdB }
  1780. {---------------------------------------------------------------------------}
  1781. PROCEDURE TButton.HandleEvent (Var Event: TEvent);
  1782. VAR Down: Boolean; C: Char; ButRect: TRect;
  1783. Mouse : TPoint;
  1784. BEGIN
  1785. ButRect.A.X := 0; { Get origin point }
  1786. ButRect.A.Y := 0; { Get origin point }
  1787. ButRect.B.X := Size.X + 2; { Calc right side }
  1788. ButRect.B.Y := Size.Y + 1; { Calc bottom }
  1789. If (Event.What = evMouseDown) Then Begin { Mouse down event }
  1790. MakeLocal(Event.Where, Mouse);
  1791. If NOT ButRect.Contains(Mouse) Then Begin { If point not in view }
  1792. ClearEvent(Event); { Clear the event }
  1793. Exit; { Speed up exit }
  1794. End;
  1795. End;
  1796. If (Flags AND bfGrabFocus <> 0) Then { Check focus grab }
  1797. Inherited HandleEvent(Event); { Call ancestor }
  1798. Case Event.What Of
  1799. evNothing: Exit; { Speed up exit }
  1800. evMouseDown: Begin
  1801. If (State AND sfDisabled = 0) Then Begin { Button not disabled }
  1802. Down := False; { Clear down flag }
  1803. Repeat
  1804. MakeLocal(Event.Where, Mouse);
  1805. If (Down <> ButRect.Contains(Mouse)) { State has changed }
  1806. Then Begin
  1807. Down := NOT Down; { Invert down flag }
  1808. DrawState(Down); { Redraw button }
  1809. End;
  1810. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse move }
  1811. If Down Then Begin { Button is down }
  1812. Press; { Send out command }
  1813. DrawState(False); { Draw button up }
  1814. End;
  1815. End;
  1816. ClearEvent(Event); { Event was handled }
  1817. End;
  1818. evKeyDown: Begin
  1819. If (Title <> Nil) Then C := HotKey(Title^) { Key title hotkey }
  1820. Else C := #0; { Invalid title }
  1821. If (Event.KeyCode = GetAltCode(C)) OR { Alt char }
  1822. (Owner^.Phase = phPostProcess) AND (C <> #0)
  1823. AND (Upcase(Event.CharCode) = C) OR { Matches hotkey }
  1824. (State AND sfFocused <> 0) AND { View focused }
  1825. ((Event.CharCode = ' ') OR { Space bar }
  1826. (Event.KeyCode=kbEnter)) Then Begin { Enter key }
  1827. DrawState(True); { Draw button down }
  1828. Press; { Send out command }
  1829. ClearEvent(Event); { Clear the event }
  1830. DrawState(False); { Draw button up }
  1831. End;
  1832. End;
  1833. evBroadcast:
  1834. Case Event.Command of
  1835. cmDefault: If AmDefault AND { Default command }
  1836. (State AND sfDisabled = 0) Then Begin { Button enabled }
  1837. Press; { Send out command }
  1838. ClearEvent(Event); { Clear the event }
  1839. End;
  1840. cmGrabDefault, cmReleaseDefault: { Grab and release cmd }
  1841. If (Flags AND bfDefault <> 0) Then Begin { Change button state }
  1842. AmDefault := Event.Command = cmReleaseDefault;
  1843. DrawView; { Redraw the view }
  1844. End;
  1845. cmCommandSetChanged: Begin { Command set changed }
  1846. SetState(sfDisabled, NOT
  1847. CommandEnabled(Command)); { Set button state }
  1848. DrawView; { Redraw the view }
  1849. End;
  1850. End;
  1851. End;
  1852. END;
  1853. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1854. { TCluster OBJECT METHODS }
  1855. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  1856. CONST TvClusterClassName = 'TVCLUSTER';
  1857. {--TCluster-----------------------------------------------------------------}
  1858. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  1859. {---------------------------------------------------------------------------}
  1860. CONSTRUCTOR TCluster.Init (Var Bounds: TRect; AStrings: PSItem);
  1861. VAR I: Sw_Integer; P: PSItem;
  1862. BEGIN
  1863. Inherited Init(Bounds); { Call ancestor }
  1864. Options := Options OR (ofSelectable + ofFirstClick
  1865. + ofPreProcess + ofPostProcess + ofVersion20); { Set option masks }
  1866. I := 0; { Zero string count }
  1867. P := AStrings; { First item }
  1868. While (P <> Nil) Do Begin
  1869. Inc(I); { Count 1 item }
  1870. P := P^.Next; { Move to next item }
  1871. End;
  1872. Strings.Init(I, 0); { Create collection }
  1873. While (AStrings <> Nil) Do Begin
  1874. P := AStrings; { Transfer item ptr }
  1875. Strings.AtInsert(Strings.Count, AStrings^.Value);{ Insert string }
  1876. AStrings := AStrings^.Next; { Move to next item }
  1877. Dispose(P); { Dispose prior item }
  1878. End;
  1879. Sel := 0;
  1880. SetCursor(2,0);
  1881. ShowCursor;
  1882. EnableMask := Sw_Integer($FFFFFFFF); { Enable bit masks }
  1883. END;
  1884. {--TCluster-----------------------------------------------------------------}
  1885. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Oct99 LdB }
  1886. {---------------------------------------------------------------------------}
  1887. CONSTRUCTOR TCluster.Load (Var S: TStream);
  1888. VAR w: word;
  1889. BEGIN
  1890. Inherited Load(S); { Call ancestor }
  1891. If ((Options AND ofVersion) >= ofVersion20) Then { Version 2 TV view }
  1892. Begin
  1893. S.Read(Value, SizeOf(Value)); { Read value }
  1894. S.Read(Sel, Sizeof(Sel)); { Read select item }
  1895. S.Read(EnableMask, SizeOf(EnableMask)) { Read enable masks }
  1896. End
  1897. Else
  1898. Begin
  1899. w:=Value;
  1900. S.Read(w, SizeOf(w)); Value:=w; { Read value }
  1901. S.Read(Sel, SizeOf(Sel)); { Read select item }
  1902. EnableMask := Sw_integer($FFFFFFFF); { Enable all masks }
  1903. Options := Options OR ofVersion20; { Set version 2 mask }
  1904. End;
  1905. Strings.Load(S); { Load string data }
  1906. SetButtonState(0, True); { Set button state }
  1907. END;
  1908. {--TCluster-----------------------------------------------------------------}
  1909. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  1910. {---------------------------------------------------------------------------}
  1911. DESTRUCTOR TCluster.Done;
  1912. BEGIN
  1913. Strings.Done; { Dispose of strings }
  1914. Inherited Done; { Call ancestor }
  1915. END;
  1916. {--TCluster-----------------------------------------------------------------}
  1917. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1918. {---------------------------------------------------------------------------}
  1919. FUNCTION TCluster.DataSize: Sw_Word;
  1920. BEGIN
  1921. DataSize := SizeOf(Sw_Word); { Exchanges a word }
  1922. END;
  1923. {--TCluster-----------------------------------------------------------------}
  1924. { GetHelpCtx -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1925. {---------------------------------------------------------------------------}
  1926. FUNCTION TCluster.GetHelpCtx: Word;
  1927. BEGIN
  1928. If (HelpCtx = hcNoContext) Then { View has no help }
  1929. GetHelpCtx := hcNoContext Else { No help context }
  1930. GetHelpCtx := HelpCtx + Sel; { Help of selected }
  1931. END;
  1932. {--TCluster-----------------------------------------------------------------}
  1933. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  1934. {---------------------------------------------------------------------------}
  1935. FUNCTION TCluster.GetPalette: PPalette;
  1936. CONST P: String[Length(CCluster)] = CCluster; { Always normal string }
  1937. BEGIN
  1938. GetPalette := PPalette(@P); { Cluster palette }
  1939. END;
  1940. {--TCluster-----------------------------------------------------------------}
  1941. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1942. {---------------------------------------------------------------------------}
  1943. FUNCTION TCluster.Mark (Item: Sw_Integer): Boolean;
  1944. BEGIN
  1945. Mark := False; { Default false }
  1946. END;
  1947. {--TCluster-----------------------------------------------------------------}
  1948. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  1949. {---------------------------------------------------------------------------}
  1950. FUNCTION TCluster.MultiMark (Item: Sw_Integer): Byte;
  1951. BEGIN
  1952. MultiMark := Byte(Mark(Item) = True); { Return multi mark }
  1953. END;
  1954. {--TCluster-----------------------------------------------------------------}
  1955. { ButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1956. {---------------------------------------------------------------------------}
  1957. FUNCTION TCluster.ButtonState (Item: Sw_Integer): Boolean;
  1958. BEGIN
  1959. If (Item > 31) Then ButtonState := False Else { Impossible item }
  1960. ButtonState := ((1 SHL Item) AND EnableMask)<>0; { Return true/false }
  1961. END;
  1962. {--TCluster-----------------------------------------------------------------}
  1963. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Jul99 LdB }
  1964. {---------------------------------------------------------------------------}
  1965. PROCEDURE TCluster.Draw;
  1966. BEGIN
  1967. END;
  1968. {--TCluster-----------------------------------------------------------------}
  1969. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1970. {---------------------------------------------------------------------------}
  1971. PROCEDURE TCluster.Press (Item: Sw_Integer);
  1972. VAR P: PView;
  1973. BEGIN
  1974. P := TopView;
  1975. If (Id <> 0) AND (P <> Nil) Then NewMessage(P,
  1976. evCommand, cmIdCommunicate, Id, Value, @Self); { Send new message }
  1977. END;
  1978. {--TCluster-----------------------------------------------------------------}
  1979. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1980. {---------------------------------------------------------------------------}
  1981. PROCEDURE TCluster.MovedTo (Item: Sw_Integer);
  1982. BEGIN { Abstract method }
  1983. END;
  1984. {--TCluster-----------------------------------------------------------------}
  1985. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  1986. {---------------------------------------------------------------------------}
  1987. PROCEDURE TCluster.SetState (AState: Word; Enable: Boolean);
  1988. BEGIN
  1989. Inherited SetState(AState, Enable); { Call ancestor }
  1990. If (AState AND sfFocused <> 0) Then Begin
  1991. DrawView; { Redraw masked areas }
  1992. End;
  1993. END;
  1994. {--TCluster-----------------------------------------------------------------}
  1995. { DrawMultiBox -> Platforms DOS/DPMI/WIN/NT - Updated 05Jun98 LdB }
  1996. {---------------------------------------------------------------------------}
  1997. PROCEDURE TCluster.DrawMultiBox (Const Icon, Marker: String);
  1998. VAR I, J, Cur, Col: Sw_Integer; CNorm, CSel, CDis, Color: Word; B: TDrawBuffer;
  1999. BEGIN
  2000. CNorm := GetColor($0301); { Normal colour }
  2001. CSel := GetColor($0402); { Selected colour }
  2002. CDis := GetColor($0505); { Disabled colour }
  2003. For I := 0 To Size.Y-1 Do Begin { For each line }
  2004. MoveChar(B, ' ', Byte(CNorm), Size.X); { Fill buffer }
  2005. For J := 0 To (Strings.Count - 1) DIV Size.Y + 1
  2006. Do Begin
  2007. Cur := J*Size.Y + I; { Current line }
  2008. If (Cur < Strings.Count) Then Begin
  2009. Col := Column(Cur); { Calc column }
  2010. If (Col + CStrLen(PString(Strings.At(Cur))^)+
  2011. 5 < Sizeof(TDrawBuffer) DIV SizeOf(Word))
  2012. AND (Col < Size.X) Then Begin { Text fits in column }
  2013. If NOT ButtonState(Cur) Then
  2014. Color := CDis Else If (Cur = Sel) AND { Disabled colour }
  2015. (State and sfFocused <> 0) Then
  2016. Color := CSel Else { Selected colour }
  2017. Color := CNorm; { Normal colour }
  2018. MoveChar(B[Col], ' ', Byte(Color),
  2019. Size.X-Col); { Set this colour }
  2020. MoveStr(B[Col], Icon, Byte(Color)); { Transfer icon string }
  2021. WordRec(B[Col+2]).Lo := Byte(Marker[
  2022. MultiMark(Cur) + 1]); { Transfer marker }
  2023. MoveCStr(B[Col+5], PString(Strings.At(
  2024. Cur))^, Color); { Transfer item string }
  2025. If ShowMarkers AND (State AND sfFocused <> 0)
  2026. AND (Cur = Sel) Then Begin { Current is selected }
  2027. WordRec(B[Col]).Lo := Byte(SpecialChars[0]);
  2028. WordRec(B[Column(Cur+Size.Y)-1]).Lo
  2029. := Byte(SpecialChars[1]); { Set special character }
  2030. End;
  2031. End;
  2032. End;
  2033. End;
  2034. WriteBuf(0, I, Size.X, 1, B); { Write buffer }
  2035. End;
  2036. SetCursor(Column(Sel)+2,Row(Sel));
  2037. END;
  2038. {--TCluster-----------------------------------------------------------------}
  2039. { DrawBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2040. {---------------------------------------------------------------------------}
  2041. PROCEDURE TCluster.DrawBox (Const Icon: String; Marker: Char);
  2042. BEGIN
  2043. DrawMultiBox(Icon, ' '+Marker); { Call draw routine }
  2044. END;
  2045. {--TCluster-----------------------------------------------------------------}
  2046. { SetButtonState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2047. {---------------------------------------------------------------------------}
  2048. PROCEDURE TCluster.SetButtonState (AMask: Longint; Enable: Boolean);
  2049. VAR I: Sw_Integer; M: Longint;
  2050. BEGIN
  2051. If Enable Then EnableMask := EnableMask OR AMask { Set enable bit mask }
  2052. Else EnableMask := EnableMask AND NOT AMask; { Disable bit mask }
  2053. If (Strings.Count <= 32) Then Begin { Valid string number }
  2054. M := 1; { Preset bit masks }
  2055. For I := 1 To Strings.Count Do Begin { For each item string }
  2056. If ((M AND EnableMask) <> 0) Then Begin { Bit enabled }
  2057. Options := Options OR ofSelectable; { Set selectable option }
  2058. Exit; { Now exit }
  2059. End;
  2060. M := M SHL 1; { Create newbit mask }
  2061. End;
  2062. Options := Options AND NOT ofSelectable; { Make not selectable }
  2063. End;
  2064. END;
  2065. {--TCluster-----------------------------------------------------------------}
  2066. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2067. {---------------------------------------------------------------------------}
  2068. PROCEDURE TCluster.GetData (Var Rec);
  2069. BEGIN
  2070. sw_Word(Rec) := Value; { Return current value }
  2071. END;
  2072. {--TCluster-----------------------------------------------------------------}
  2073. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2074. {---------------------------------------------------------------------------}
  2075. PROCEDURE TCluster.SetData (Var Rec);
  2076. BEGIN
  2077. Value :=sw_Word(Rec); { Set current value }
  2078. DrawView; { Redraw masked areas }
  2079. END;
  2080. {--TCluster-----------------------------------------------------------------}
  2081. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2082. {---------------------------------------------------------------------------}
  2083. PROCEDURE TCluster.Store (Var S: TStream);
  2084. var
  2085. w : word;
  2086. BEGIN
  2087. TView.Store(S); { TView.Store called }
  2088. If ((Options AND ofVersion) >= ofVersion20) { Version 2 TV view }
  2089. Then Begin
  2090. S.Write(Value, SizeOf(Value)); { Write value }
  2091. S.Write(Sel, SizeOf(Sel)); { Write select item }
  2092. S.Write(EnableMask, SizeOf(EnableMask)); { Write enable masks }
  2093. End Else Begin
  2094. w:=Value;
  2095. S.Write(w, SizeOf(Word)); { Write value }
  2096. S.Write(Sel, SizeOf(Sel)); { Write select item }
  2097. End;
  2098. Strings.Store(S); { Store strings }
  2099. END;
  2100. {--TCluster-----------------------------------------------------------------}
  2101. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04Jun98 LdB }
  2102. {---------------------------------------------------------------------------}
  2103. PROCEDURE TCluster.HandleEvent (Var Event: TEvent);
  2104. VAR C: Char; I, S, Vh: Sw_Integer; Key: Word; Mouse: TPoint; Ts: PString;
  2105. PROCEDURE MoveSel;
  2106. BEGIN
  2107. If (I <= Strings.Count) Then Begin
  2108. Sel := S; { Set selected item }
  2109. MovedTo(Sel); { Move to selected }
  2110. DrawView; { Now draw changes }
  2111. End;
  2112. END;
  2113. BEGIN
  2114. Inherited HandleEvent(Event); { Call ancestor }
  2115. If ((Options AND ofSelectable) = 0) Then Exit; { Check selectable }
  2116. If (Event.What = evMouseDown) Then Begin { MOUSE EVENT }
  2117. MakeLocal(Event.Where, Mouse); { Make point local }
  2118. I := FindSel(Mouse); { Find selected item }
  2119. If (I <> -1) Then { Check in view }
  2120. If ButtonState(I) Then Sel := I; { If enabled select }
  2121. DrawView; { Now draw changes }
  2122. Repeat
  2123. MakeLocal(Event.Where, Mouse); { Make point local }
  2124. Until NOT MouseEvent(Event, evMouseMove); { Wait for mouse up }
  2125. MakeLocal(Event.Where, Mouse); { Make point local }
  2126. If (FindSel(Mouse) = Sel) AND ButtonState(Sel) { If valid/selected }
  2127. Then Begin
  2128. Press(Sel); { Call pressed }
  2129. DrawView; { Now draw changes }
  2130. End;
  2131. ClearEvent(Event); { Event was handled }
  2132. End Else If (Event.What = evKeyDown) Then Begin { KEY EVENT }
  2133. Vh := Size.Y; { View height }
  2134. S := Sel; { Hold current item }
  2135. Key := CtrlToArrow(Event.KeyCode); { Convert keystroke }
  2136. Case Key Of
  2137. kbUp, kbDown, kbRight, kbLeft:
  2138. If (State AND sfFocused <> 0) Then Begin { Focused key event }
  2139. I := 0; { Zero process count }
  2140. Repeat
  2141. Inc(I); { Inc process count }
  2142. Case Key Of
  2143. kbUp: Dec(S); { Next item up }
  2144. kbDown: Inc(S); { Next item down }
  2145. kbRight: Begin { Next column across }
  2146. Inc(S, Vh); { Move to next column }
  2147. If (S >= Strings.Count) Then { No next column check }
  2148. S := (S+1) MOD Vh; { Move to last column }
  2149. End;
  2150. kbLeft: Begin { Prior column across }
  2151. Dec(S, Vh); { Move to prior column }
  2152. If (S < 0) Then S := ((Strings.Count +
  2153. Vh - 1) DIV Vh) * Vh + S - 1; { No prior column check }
  2154. End;
  2155. End;
  2156. If (S >= Strings.Count) Then S := 0; { Roll up to top }
  2157. If (S < 0) Then S := Strings.Count - 1; { Roll down to bottom }
  2158. Until ButtonState(S) OR (I > Strings.Count); { Repeat until select }
  2159. MoveSel; { Move to selected }
  2160. ClearEvent(Event); { Event was handled }
  2161. End;
  2162. Else Begin { Not an arrow key }
  2163. For I := 0 To Strings.Count-1 Do Begin { Scan each item }
  2164. Ts := Strings.At(I); { Fetch string pointer }
  2165. If (Ts <> Nil) Then C := HotKey(Ts^) { Check for hotkey }
  2166. Else C := #0; { No valid string }
  2167. If (GetAltCode(C) = Event.KeyCode) OR { Hot key for item }
  2168. (((Owner^.Phase = phPostProcess) OR { Owner in post process }
  2169. (State AND sfFocused <> 0)) AND (C <> #0) { Non zero hotkey }
  2170. AND (UpCase(Event.CharCode) = C)) { Matches current key }
  2171. Then Begin
  2172. If ButtonState(I) Then Begin { Check mask enabled }
  2173. If Focus Then Begin { Check view focus }
  2174. Sel := I; { Set selected }
  2175. MovedTo(Sel); { Move to selected }
  2176. Press(Sel); { Call pressed }
  2177. DrawView; { Now draw changes }
  2178. End;
  2179. ClearEvent(Event); { Event was handled }
  2180. End;
  2181. Exit; { Now exit }
  2182. End;
  2183. End;
  2184. If (Event.CharCode = ' ') AND { Spacebar key }
  2185. (State AND sfFocused <> 0) AND { Check focused view }
  2186. ButtonState(Sel) Then Begin { Check item enabled }
  2187. Press(Sel); { Call pressed }
  2188. DrawView; { Now draw changes }
  2189. ClearEvent(Event); { Event was handled }
  2190. End;
  2191. End;
  2192. End;
  2193. End;
  2194. END;
  2195. {***************************************************************************}
  2196. { TCluster OBJECT PRIVATE METHODS }
  2197. {***************************************************************************}
  2198. {--TCluster-----------------------------------------------------------------}
  2199. { FindSel -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2200. {---------------------------------------------------------------------------}
  2201. FUNCTION TCluster.FindSel (P: TPoint): Sw_Integer;
  2202. VAR I, S, Vh: Sw_Integer; R: TRect;
  2203. BEGIN
  2204. GetExtent(R); { Get view extents }
  2205. If R.Contains(P) Then Begin { Point in view }
  2206. Vh := Size.Y; { View height }
  2207. I := 0; { Preset zero value }
  2208. While (P.X >= Column(I+Vh)) Do Inc(I, Vh); { Inc view size }
  2209. S := I + P.Y; { Line to select }
  2210. If ((S >= 0) AND (S < Strings.Count)) { Valid selection }
  2211. Then FindSel := S Else FindSel := -1; { Return selected item }
  2212. End Else FindSel := -1; { Point outside view }
  2213. END;
  2214. {--TCluster-----------------------------------------------------------------}
  2215. { Row -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2216. {---------------------------------------------------------------------------}
  2217. FUNCTION TCluster.Row (Item: Sw_Integer): Sw_Integer;
  2218. BEGIN
  2219. Row := Item MOD Size.Y; { Normal mod value }
  2220. END;
  2221. {--TCluster-----------------------------------------------------------------}
  2222. { Column -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 03Jun98 LdB }
  2223. {---------------------------------------------------------------------------}
  2224. FUNCTION TCluster.Column (Item: Sw_Integer): Sw_Integer;
  2225. VAR I, Col, Width, L, Vh: Sw_Integer; Ts: PString;
  2226. BEGIN
  2227. Vh := Size.Y; { Vertical size }
  2228. If (Item >= Vh) Then Begin { Valid selection }
  2229. Width := 0; { Zero width }
  2230. Col := -6; { Start column at -6 }
  2231. For I := 0 To Item Do Begin { For each item }
  2232. If (I MOD Vh = 0) Then Begin { Start next column }
  2233. Inc(Col, Width + 6); { Add column width }
  2234. Width := 0; { Zero width }
  2235. End;
  2236. If (I < Strings.Count) Then Begin { Valid string }
  2237. Ts := Strings.At(I); { Transfer string }
  2238. If (Ts <> Nil) Then L := CStrLen(Ts^) { Length of string }
  2239. Else L := 0; { No string }
  2240. End;
  2241. If (L > Width) Then Width := L; { Hold longest string }
  2242. End;
  2243. Column := Col; { Return column }
  2244. End Else Column := 0; { Outside select area }
  2245. END;
  2246. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2247. { TRadioButtons OBJECT METHODS }
  2248. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2249. {--TRadioButtons------------------------------------------------------------}
  2250. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2251. {---------------------------------------------------------------------------}
  2252. FUNCTION TRadioButtons.Mark (Item: Sw_Integer): Boolean;
  2253. BEGIN
  2254. Mark := Item = Value; { True if item = value }
  2255. END;
  2256. {--TRadioButtons------------------------------------------------------------}
  2257. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2258. {---------------------------------------------------------------------------}
  2259. PROCEDURE TRadioButtons.Draw;
  2260. CONST Button = ' ( ) ';
  2261. BEGIN
  2262. Inherited Draw;
  2263. DrawMultiBox(Button, ' *'); { Redraw the text }
  2264. END;
  2265. {--TRadioButtons------------------------------------------------------------}
  2266. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2267. {---------------------------------------------------------------------------}
  2268. PROCEDURE TRadioButtons.Press (Item: Sw_Integer);
  2269. BEGIN
  2270. Value := Item; { Set value field }
  2271. Inherited Press(Item); { Call ancestor }
  2272. END;
  2273. {--TRadioButtons------------------------------------------------------------}
  2274. { MovedTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2275. {---------------------------------------------------------------------------}
  2276. PROCEDURE TRadioButtons.MovedTo (Item: Sw_Integer);
  2277. BEGIN
  2278. Value := Item; { Set value to item }
  2279. If (Id <> 0) Then NewMessage(Owner, evCommand,
  2280. cmIdCommunicate, Id, Value, @Self); { Send new message }
  2281. END;
  2282. {--TRadioButtons------------------------------------------------------------}
  2283. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2284. {---------------------------------------------------------------------------}
  2285. PROCEDURE TRadioButtons.SetData (Var Rec);
  2286. BEGIN
  2287. Sel := Sw_word(Rec); { Set selection }
  2288. Inherited SetData(Rec); { Call ancestor }
  2289. END;
  2290. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2291. { TCheckBoxes OBJECT METHODS }
  2292. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2293. {--TCheckBoxes--------------------------------------------------------------}
  2294. { Mark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2295. {---------------------------------------------------------------------------}
  2296. FUNCTION TCheckBoxes.Mark(Item: Sw_Integer): Boolean;
  2297. BEGIN
  2298. If (Value AND (1 SHL Item) <> 0) Then { Check if item ticked }
  2299. Mark := True Else Mark := False; { Return result }
  2300. END;
  2301. {--TCheckBoxes--------------------------------------------------------------}
  2302. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 04May98 LdB }
  2303. {---------------------------------------------------------------------------}
  2304. PROCEDURE TCheckBoxes.Draw;
  2305. CONST Button = ' [ ] ';
  2306. BEGIN
  2307. Inherited Draw;
  2308. DrawMultiBox(Button, ' X'); { Redraw the text }
  2309. END;
  2310. {--TCheckBoxes--------------------------------------------------------------}
  2311. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Apr98 LdB }
  2312. {---------------------------------------------------------------------------}
  2313. PROCEDURE TCheckBoxes.Press (Item: Sw_Integer);
  2314. BEGIN
  2315. Value := Value XOR (1 SHL Item); { Flip the item mask }
  2316. Inherited Press(Item); { Call ancestor }
  2317. END;
  2318. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2319. { TMultiCheckBoxes OBJECT METHODS }
  2320. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2321. {--TMultiCheckBoxes---------------------------------------------------------}
  2322. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Jun98 LdB }
  2323. {---------------------------------------------------------------------------}
  2324. CONSTRUCTOR TMultiCheckBoxes.Init (Var Bounds: TRect; AStrings: PSItem;
  2325. ASelRange: Byte; AFlags: Word; Const AStates: String);
  2326. BEGIN
  2327. Inherited Init(Bounds, AStrings); { Call ancestor }
  2328. SelRange := ASelRange; { Hold select range }
  2329. Flags := AFlags; { Hold flags }
  2330. States := NewStr(AStates); { Hold string }
  2331. END;
  2332. {--TMultiCheckBoxes---------------------------------------------------------}
  2333. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2334. {---------------------------------------------------------------------------}
  2335. CONSTRUCTOR TMultiCheckBoxes.Load (Var S: TStream);
  2336. BEGIN
  2337. Inherited Load(S); { Call ancestor }
  2338. S.Read(SelRange, SizeOf(SelRange)); { Read select range }
  2339. S.Read(Flags, SizeOf(Flags)); { Read flags }
  2340. States := S.ReadStr; { Read strings }
  2341. END;
  2342. {--TMultiCheckBoxes---------------------------------------------------------}
  2343. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2344. {---------------------------------------------------------------------------}
  2345. DESTRUCTOR TMultiCheckBoxes.Done;
  2346. BEGIN
  2347. If (States <> Nil) Then DisposeStr(States); { Dispose strings }
  2348. Inherited Done; { Call ancestor }
  2349. END;
  2350. {--TMultiCheckBoxes---------------------------------------------------------}
  2351. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2352. {---------------------------------------------------------------------------}
  2353. FUNCTION TMultiCheckBoxes.DataSize: Sw_Word;
  2354. BEGIN
  2355. DataSize := SizeOf(LongInt); { Size to exchange }
  2356. END;
  2357. {--TMultiCheckBoxes---------------------------------------------------------}
  2358. { MultiMark -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2359. {---------------------------------------------------------------------------}
  2360. FUNCTION TMultiCheckBoxes.MultiMark (Item: Sw_Integer): Byte;
  2361. BEGIN
  2362. MultiMark := (Value SHR (Word(Item) *
  2363. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Return mark state }
  2364. END;
  2365. {--TMultiCheckBoxes---------------------------------------------------------}
  2366. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2367. {---------------------------------------------------------------------------}
  2368. PROCEDURE TMultiCheckBoxes.Draw;
  2369. CONST Button = ' [ ] ';
  2370. BEGIN
  2371. Inherited Draw;
  2372. DrawMultiBox(Button, States^); { Draw the items }
  2373. END;
  2374. {--TMultiCheckBoxes---------------------------------------------------------}
  2375. { Press -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2376. {---------------------------------------------------------------------------}
  2377. PROCEDURE TMultiCheckBoxes.Press (Item: Sw_Integer);
  2378. VAR CurState: ShortInt;
  2379. BEGIN
  2380. CurState := (Value SHR (Word(Item) *
  2381. WordRec(Flags).Hi)) AND WordRec(Flags).Lo; { Hold current state }
  2382. Dec(CurState); { One down }
  2383. If (CurState >= SelRange) OR (CurState < 0) Then
  2384. CurState := SelRange - 1; { Roll if needed }
  2385. Value := (Value AND NOT (LongInt(WordRec(Flags).Lo)
  2386. SHL (Word(Item) * WordRec(Flags).Hi))) OR
  2387. (LongInt(CurState) SHL (Word(Item) *
  2388. WordRec(Flags).Hi)); { Calculate value }
  2389. Inherited Press(Item); { Call ancestor }
  2390. END;
  2391. {--TMultiCheckBoxes---------------------------------------------------------}
  2392. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2393. {---------------------------------------------------------------------------}
  2394. PROCEDURE TMultiCheckBoxes.GetData (Var Rec);
  2395. BEGIN
  2396. Longint(Rec) := Value; { Return value }
  2397. END;
  2398. {--TMultiCheckBoxes---------------------------------------------------------}
  2399. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2400. {---------------------------------------------------------------------------}
  2401. PROCEDURE TMultiCheckBoxes.SetData (Var Rec);
  2402. BEGIN
  2403. Value := Longint(Rec); { Set value }
  2404. DrawView; { Redraw masked areas }
  2405. END;
  2406. {--TMultiCheckBoxes---------------------------------------------------------}
  2407. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2408. {---------------------------------------------------------------------------}
  2409. PROCEDURE TMultiCheckBoxes.Store (Var S: TStream);
  2410. BEGIN
  2411. TCluster.Store(S); { TCluster store called }
  2412. S.Write(SelRange, SizeOf(SelRange)); { Write select range }
  2413. S.Write(Flags, SizeOf(Flags)); { Write select flags }
  2414. S.WriteStr(States); { Write strings }
  2415. END;
  2416. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2417. { TListBox OBJECT METHODS }
  2418. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2419. TYPE
  2420. TListBoxRec = PACKED RECORD
  2421. List: PCollection; { List collection ptr }
  2422. Selection: sw_integer; { Selected item }
  2423. END;
  2424. {--TListBox-----------------------------------------------------------------}
  2425. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2426. {---------------------------------------------------------------------------}
  2427. CONSTRUCTOR TListBox.Init (Var Bounds: TRect; ANumCols: Sw_Word;
  2428. AScrollBar: PScrollBar);
  2429. BEGIN
  2430. Inherited Init(Bounds, ANumCols, Nil, AScrollBar); { Call ancestor }
  2431. SetRange(0); { Set range to zero }
  2432. END;
  2433. {--TListBox-----------------------------------------------------------------}
  2434. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2435. {---------------------------------------------------------------------------}
  2436. CONSTRUCTOR TListBox.Load (Var S: TStream);
  2437. BEGIN
  2438. Inherited Load(S); { Call ancestor }
  2439. List := PCollection(S.Get); { Fetch collection }
  2440. END;
  2441. {--TListBox-----------------------------------------------------------------}
  2442. { DataSize -> Platforms DOS/DPMI/WIN/NT/Os2 - Updated 06Jun98 LdB }
  2443. {---------------------------------------------------------------------------}
  2444. FUNCTION TListBox.DataSize: Sw_Word;
  2445. BEGIN
  2446. DataSize := SizeOf(TListBoxRec); { Xchg data size }
  2447. END;
  2448. {--TListBox-----------------------------------------------------------------}
  2449. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2450. {---------------------------------------------------------------------------}
  2451. FUNCTION TListBox.GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String;
  2452. VAR P: PString;
  2453. BEGIN
  2454. GetText := ''; { Preset return }
  2455. If (List <> Nil) Then Begin { A list exists }
  2456. P := PString(List^.At(Item)); { Get string ptr }
  2457. If (P <> Nil) Then GetText := P^; { Return string }
  2458. End;
  2459. END;
  2460. {--TListBox-----------------------------------------------------------------}
  2461. { NewList -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2462. {---------------------------------------------------------------------------}
  2463. PROCEDURE TListBox.NewList (AList: PCollection);
  2464. BEGIN
  2465. If (List <> Nil) Then Dispose(List, Done); { Dispose old list }
  2466. List := AList; { Hold new list }
  2467. If (AList <> Nil) Then SetRange(AList^.Count) { Set new item range }
  2468. Else SetRange(0); { Set zero range }
  2469. If (Range > 0) Then FocusItem(0); { Focus first item }
  2470. DrawView; { Redraw all view }
  2471. END;
  2472. {--TListBox-----------------------------------------------------------------}
  2473. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2474. {---------------------------------------------------------------------------}
  2475. PROCEDURE TListBox.GetData (Var Rec);
  2476. BEGIN
  2477. TListBoxRec(Rec).List := List; { Return current list }
  2478. TListBoxRec(Rec).Selection := Focused; { Return focused item }
  2479. END;
  2480. {--TListBox-----------------------------------------------------------------}
  2481. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2482. {---------------------------------------------------------------------------}
  2483. PROCEDURE TListBox.SetData (Var Rec);
  2484. BEGIN
  2485. NewList(TListBoxRec(Rec).List); { Hold new list }
  2486. FocusItem(TListBoxRec(Rec).Selection); { Focus selected item }
  2487. DrawView; { Redraw all view }
  2488. END;
  2489. {--TListBox-----------------------------------------------------------------}
  2490. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2491. {---------------------------------------------------------------------------}
  2492. PROCEDURE TListBox.Store (Var S: TStream);
  2493. BEGIN
  2494. TListViewer.Store(S); { TListViewer store }
  2495. S.Put(List); { Store list to stream }
  2496. END;
  2497. {****************************************************************************}
  2498. { TListBox.DeleteFocusedItem }
  2499. {****************************************************************************}
  2500. procedure TListBox.DeleteFocusedItem;
  2501. begin
  2502. DeleteItem(Focused);
  2503. end;
  2504. {****************************************************************************}
  2505. { TListBox.DeleteItem }
  2506. {****************************************************************************}
  2507. procedure TListBox.DeleteItem (Item : Sw_Integer);
  2508. begin
  2509. if (List <> nil) and (List^.Count > 0) and
  2510. ((Item < List^.Count) and (Item > -1)) then begin
  2511. if IsSelected(Item) and (Item > 0) then
  2512. FocusItem(Item - 1);
  2513. List^.AtDelete(Item);
  2514. SetRange(List^.Count);
  2515. end;
  2516. end;
  2517. {****************************************************************************}
  2518. { TListBox.FreeAll }
  2519. {****************************************************************************}
  2520. procedure TListBox.FreeAll;
  2521. begin
  2522. if (List <> nil) then
  2523. begin
  2524. List^.FreeAll;
  2525. SetRange(List^.Count);
  2526. end;
  2527. end;
  2528. {****************************************************************************}
  2529. { TListBox.FreeFocusedItem }
  2530. {****************************************************************************}
  2531. procedure TListBox.FreeFocusedItem;
  2532. begin
  2533. FreeItem(Focused);
  2534. end;
  2535. {****************************************************************************}
  2536. { TListBox.FreeItem }
  2537. {****************************************************************************}
  2538. procedure TListBox.FreeItem (Item : Sw_Integer);
  2539. begin
  2540. if (Item > -1) and (Item < Range) then
  2541. begin
  2542. List^.AtFree(Item);
  2543. if (Range > 1) and (Focused >= List^.Count) then
  2544. Dec(Focused);
  2545. SetRange(List^.Count);
  2546. end;
  2547. end;
  2548. {****************************************************************************}
  2549. { TListBox.SetFocusedItem }
  2550. {****************************************************************************}
  2551. procedure TListBox.SetFocusedItem (Item : Pointer);
  2552. begin
  2553. FocusItem(List^.IndexOf(Item));
  2554. end;
  2555. {****************************************************************************}
  2556. { TListBox.GetFocusedItem }
  2557. {****************************************************************************}
  2558. function TListBox.GetFocusedItem : Pointer;
  2559. begin
  2560. if (List = nil) or (List^.Count = 0) then
  2561. GetFocusedItem := nil
  2562. else GetFocusedItem := List^.At(Focused);
  2563. end;
  2564. {****************************************************************************}
  2565. { TListBox.Insert }
  2566. {****************************************************************************}
  2567. procedure TListBox.Insert (Item : Pointer);
  2568. begin
  2569. if (List <> nil) then
  2570. begin
  2571. List^.Insert(Item);
  2572. SetRange(List^.Count);
  2573. end;
  2574. end;
  2575. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2576. { TStaticText OBJECT METHODS }
  2577. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2578. {--TStaticText--------------------------------------------------------------}
  2579. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2580. {---------------------------------------------------------------------------}
  2581. CONSTRUCTOR TStaticText.Init (Var Bounds: TRect; Const AText: String);
  2582. BEGIN
  2583. Inherited Init(Bounds); { Call ancestor }
  2584. Text := NewStr(AText); { Create string ptr }
  2585. END;
  2586. {--TStaticText--------------------------------------------------------------}
  2587. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2588. {---------------------------------------------------------------------------}
  2589. CONSTRUCTOR TStaticText.Load (Var S: TStream);
  2590. BEGIN
  2591. Inherited Load(S); { Call ancestor }
  2592. Text := S.ReadStr; { Read text string }
  2593. END;
  2594. {--TStaticText--------------------------------------------------------------}
  2595. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2596. {---------------------------------------------------------------------------}
  2597. DESTRUCTOR TStaticText.Done;
  2598. BEGIN
  2599. If (Text <> Nil) Then DisposeStr(Text); { Dispose string }
  2600. Inherited Done; { Call ancestor }
  2601. END;
  2602. {--TStaticText--------------------------------------------------------------}
  2603. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2604. {---------------------------------------------------------------------------}
  2605. FUNCTION TStaticText.GetPalette: PPalette;
  2606. CONST P: String[Length(CStaticText)] = CStaticText; { Always normal string }
  2607. BEGIN
  2608. GetPalette := PPalette(@P); { Return palette }
  2609. END;
  2610. {--TStaticText--------------------------------------------------------------}
  2611. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2612. {---------------------------------------------------------------------------}
  2613. PROCEDURE TStaticText.Draw;
  2614. VAR Just: Byte; I, J, P, Y, L: Sw_Integer; S: String;
  2615. B : TDrawBuffer;
  2616. Color : Byte;
  2617. BEGIN
  2618. GetText(S); { Fetch text to write }
  2619. Color := GetColor(1);
  2620. P := 1; { X start position }
  2621. Y := 0; { Y start position }
  2622. L := Length(S); { Length of text }
  2623. While (Y < Size.Y) Do Begin
  2624. MoveChar(B, ' ', Color, Size.X);
  2625. if P <= L then
  2626. begin
  2627. Just := 0; { Default left justify }
  2628. If (S[P] = #2) Then Begin { Right justify char }
  2629. Just := 2; { Set right justify }
  2630. Inc(P); { Next character }
  2631. End;
  2632. If (S[P] = #3) Then Begin { Centre justify char }
  2633. Just := 1; { Set centre justify }
  2634. Inc(P); { Next character }
  2635. End;
  2636. I := P; { Start position }
  2637. repeat
  2638. J := P;
  2639. while (P <= L) and (S[P] = ' ') do
  2640. Inc(P);
  2641. while (P <= L) and (S[P] <> ' ') and (S[P] <> #13) do
  2642. Inc(P);
  2643. until (P > L) or (P >= I + Size.X) or (S[P] = #13);
  2644. If P > I + Size.X Then { Text to long }
  2645. If J > I Then
  2646. P := J
  2647. Else
  2648. P := I + Size.X;
  2649. Case Just Of
  2650. 0: J := 0; { Left justify }
  2651. 1: J := (Size.X - (P-I)) DIV 2; { Centre justify }
  2652. 2: J := Size.X - (P-I); { Right justify }
  2653. End;
  2654. MoveBuf(B[J], S[I], Color, P - I);
  2655. While (P <= L) AND (P-I <= Size.X) AND ((S[P] = #13) OR (S[P] = #10))
  2656. Do Inc(P); { Remove CR/LF }
  2657. End;
  2658. WriteLine(0, Y, Size.X, 1, B);
  2659. Inc(Y); { Next line }
  2660. End;
  2661. END;
  2662. {--TStaticText--------------------------------------------------------------}
  2663. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2664. {---------------------------------------------------------------------------}
  2665. PROCEDURE TStaticText.Store (Var S: TStream);
  2666. BEGIN
  2667. TView.Store(S); { Call TView store }
  2668. S.WriteStr(Text); { Write text string }
  2669. END;
  2670. {--TStaticText--------------------------------------------------------------}
  2671. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2672. {---------------------------------------------------------------------------}
  2673. PROCEDURE TStaticText.GetText (Var S: String);
  2674. BEGIN
  2675. If (Text <> Nil) Then S := Text^ { Copy text string }
  2676. Else S := ''; { Return empty string }
  2677. END;
  2678. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2679. { TParamText OBJECT METHODS }
  2680. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2681. {--TParamText---------------------------------------------------------------}
  2682. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2683. {---------------------------------------------------------------------------}
  2684. CONSTRUCTOR TParamText.Init (Var Bounds: TRect; Const AText: String;
  2685. AParamCount: Sw_Integer);
  2686. BEGIN
  2687. Inherited Init(Bounds, AText); { Call ancestor }
  2688. ParamCount := AParamCount; { Hold param count }
  2689. END;
  2690. {--TParamText---------------------------------------------------------------}
  2691. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2692. {---------------------------------------------------------------------------}
  2693. CONSTRUCTOR TParamText.Load (Var S: TStream);
  2694. VAR w: Word;
  2695. BEGIN
  2696. Inherited Load(S); { Call ancestor }
  2697. S.Read(w, SizeOf(w)); ParamCount:=w; { Read parameter count }
  2698. END;
  2699. {--TParamText---------------------------------------------------------------}
  2700. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2701. {---------------------------------------------------------------------------}
  2702. FUNCTION TParamText.DataSize: Sw_Word;
  2703. BEGIN
  2704. DataSize := ParamCount * SizeOf(Pointer); { Return data size }
  2705. END;
  2706. {--TParamText---------------------------------------------------------------}
  2707. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2708. {---------------------------------------------------------------------------}
  2709. PROCEDURE TParamText.GetData (Var Rec);
  2710. BEGIN
  2711. Pointer(Rec) := @ParamList; { Return parm ptr }
  2712. END;
  2713. {--TParamText---------------------------------------------------------------}
  2714. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Jun98 LdB }
  2715. {---------------------------------------------------------------------------}
  2716. PROCEDURE TParamText.SetData (Var Rec);
  2717. BEGIN
  2718. ParamList := @Rec; { Fetch parameter list }
  2719. DrawView; { Redraw all the view }
  2720. END;
  2721. {--TParamText---------------------------------------------------------------}
  2722. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2723. {---------------------------------------------------------------------------}
  2724. PROCEDURE TParamText.Store (Var S: TStream);
  2725. VAR w: Word;
  2726. BEGIN
  2727. TStaticText.Store(S); { Statictext store }
  2728. w:=ParamCount;S.Write(w, SizeOf(w)); { Store param count }
  2729. END;
  2730. {--TParamText---------------------------------------------------------------}
  2731. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  2732. {---------------------------------------------------------------------------}
  2733. PROCEDURE TParamText.GetText (Var S: String);
  2734. BEGIN
  2735. If (Text = Nil) Then S := '' Else { Return empty string }
  2736. FormatStr(S, Text^, ParamList^); { Return text string }
  2737. END;
  2738. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2739. { TLabel OBJECT METHODS }
  2740. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2741. {--TLabel-------------------------------------------------------------------}
  2742. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2743. {---------------------------------------------------------------------------}
  2744. CONSTRUCTOR TLabel.Init (Var Bounds: TRect; CONST AText: String; ALink: PView);
  2745. BEGIN
  2746. Inherited Init(Bounds, AText); { Call ancestor }
  2747. Link := ALink; { Hold link }
  2748. Options := Options OR (ofPreProcess+ofPostProcess);{ Set pre/post process }
  2749. EventMask := EventMask OR evBroadcast; { Sees broadcast events }
  2750. END;
  2751. {--TLabel-------------------------------------------------------------------}
  2752. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2753. {---------------------------------------------------------------------------}
  2754. CONSTRUCTOR TLabel.Load (Var S: TStream);
  2755. BEGIN
  2756. Inherited Load(S); { Call ancestor }
  2757. GetPeerViewPtr(S, Link); { Load link view }
  2758. END;
  2759. {--TLabel-------------------------------------------------------------------}
  2760. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2761. {---------------------------------------------------------------------------}
  2762. FUNCTION TLabel.GetPalette: PPalette;
  2763. CONST P: String[Length(CLabel)] = CLabel; { Always normal string }
  2764. BEGIN
  2765. GetPalette := PPalette(@P); { Return palette }
  2766. END;
  2767. {--TLabel-------------------------------------------------------------------}
  2768. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2769. {---------------------------------------------------------------------------}
  2770. PROCEDURE TLabel.Draw;
  2771. VAR SCOff: Byte; Color: Word; B: TDrawBuffer;
  2772. BEGIN
  2773. If Light Then Begin { Light colour select }
  2774. Color := GetColor($0402); { Choose light colour }
  2775. SCOff := 0; { Zero offset }
  2776. End Else Begin
  2777. Color := GetColor($0301); { Darker colour }
  2778. SCOff := 4; { Set offset }
  2779. End;
  2780. MoveChar(B[0], ' ', Byte(Color), Size.X); { Clear the buffer }
  2781. If (Text <> Nil) Then MoveCStr(B[1], Text^, Color);{ Transfer label text }
  2782. If ShowMarkers Then WordRec(B[0]).Lo := Byte(
  2783. SpecialChars[SCOff]); { Show marker if req }
  2784. WriteLine(0, 0, Size.X, 1, B); { Write the text }
  2785. END;
  2786. {--TLabel-------------------------------------------------------------------}
  2787. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2788. {---------------------------------------------------------------------------}
  2789. PROCEDURE TLabel.Store (Var S: TStream);
  2790. BEGIN
  2791. TStaticText.Store(S); { TStaticText.Store }
  2792. PutPeerViewPtr(S, Link); { Store link view }
  2793. END;
  2794. {--TLabel-------------------------------------------------------------------}
  2795. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2796. {---------------------------------------------------------------------------}
  2797. PROCEDURE TLabel.HandleEvent (Var Event: TEvent);
  2798. VAR C: Char;
  2799. PROCEDURE FocusLink;
  2800. BEGIN
  2801. If (Link <> Nil) AND (Link^.Options AND
  2802. ofSelectable <> 0) Then Link^.Focus; { Focus link view }
  2803. ClearEvent(Event); { Clear the event }
  2804. END;
  2805. BEGIN
  2806. Inherited HandleEvent(Event); { Call ancestor }
  2807. Case Event.What Of
  2808. evNothing: Exit; { Speed up exit }
  2809. evMouseDown: FocusLink; { Focus link view }
  2810. evKeyDown:
  2811. Begin
  2812. if assigned(text) then
  2813. begin
  2814. C := HotKey(Text^); { Check for hotkey }
  2815. If (GetAltCode(C) = Event.KeyCode) OR { Alt plus char }
  2816. ((C <> #0) AND (Owner^.Phase = phPostProcess) { Post process phase }
  2817. AND (UpCase(Event.CharCode) = C)) Then { Upper case match }
  2818. FocusLink; { Focus link view }
  2819. end;
  2820. end;
  2821. evBroadcast: If ((Event.Command = cmReceivedFocus)
  2822. OR (Event.Command = cmReleasedFocus)) AND { Focus state change }
  2823. (Link <> Nil) Then Begin
  2824. Light := Link^.State AND sfFocused <> 0; { Change light state }
  2825. DrawView; { Now redraw change }
  2826. End;
  2827. End;
  2828. END;
  2829. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2830. { THistoryViewer OBJECT METHODS }
  2831. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2832. {--THistoryViewer-----------------------------------------------------------}
  2833. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2834. {---------------------------------------------------------------------------}
  2835. CONSTRUCTOR THistoryViewer.Init (Var Bounds: TRect; AHScrollBar,
  2836. AVScrollBar: PScrollBar; AHistoryId: Word);
  2837. BEGIN
  2838. Inherited Init(Bounds, 1, AHScrollBar,
  2839. AVScrollBar); { Call ancestor }
  2840. HistoryId := AHistoryId; { Hold history id }
  2841. SetRange(HistoryCount(AHistoryId)); { Set history range }
  2842. If (Range > 1) Then FocusItem(1); { Set to item 1 }
  2843. If (HScrollBar <> Nil) Then
  2844. HScrollBar^.SetRange(1, HistoryWidth-Size.X + 3);{ Set scrollbar range }
  2845. END;
  2846. {--THistoryViewer-----------------------------------------------------------}
  2847. { HistoryWidth -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2848. {---------------------------------------------------------------------------}
  2849. FUNCTION THistoryViewer.HistoryWidth: Sw_Integer;
  2850. VAR Width, T, Count, I: Sw_Integer;
  2851. BEGIN
  2852. Width := 0; { Zero width variable }
  2853. Count := HistoryCount(HistoryId); { Hold count value }
  2854. For I := 0 To Count-1 Do Begin { For each item }
  2855. T := Length(HistoryStr(HistoryId, I)); { Get width of item }
  2856. If (T > Width) Then Width := T; { Set width to max }
  2857. End;
  2858. HistoryWidth := Width; { Return max item width }
  2859. END;
  2860. {--THistoryViewer-----------------------------------------------------------}
  2861. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2862. {---------------------------------------------------------------------------}
  2863. FUNCTION THistoryViewer.GetPalette: PPalette;
  2864. CONST P: String[Length(CHistoryViewer)] = CHistoryViewer;{ Always normal string }
  2865. BEGIN
  2866. GetPalette := PPalette(@P); { Return palette }
  2867. END;
  2868. {--THistoryViewer-----------------------------------------------------------}
  2869. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2870. {---------------------------------------------------------------------------}
  2871. FUNCTION THistoryViewer.GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String;
  2872. BEGIN
  2873. GetText := HistoryStr(HistoryId, Item); { Return history string }
  2874. END;
  2875. {--THistoryViewer-----------------------------------------------------------}
  2876. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2877. {---------------------------------------------------------------------------}
  2878. PROCEDURE THistoryViewer.HandleEvent (Var Event: TEvent);
  2879. BEGIN
  2880. If ((Event.What = evMouseDown) AND (Event.Double)) { Double click mouse }
  2881. OR ((Event.What = evKeyDown) AND
  2882. (Event.KeyCode = kbEnter)) Then Begin { Enter key press }
  2883. EndModal(cmOk); { End with cmOk }
  2884. ClearEvent(Event); { Event was handled }
  2885. End Else If ((Event.What = evKeyDown) AND
  2886. (Event.KeyCode = kbEsc)) OR { Esc key press }
  2887. ((Event.What = evCommand) AND
  2888. (Event.Command = cmCancel)) Then Begin { Cancel command }
  2889. EndModal(cmCancel); { End with cmCancel }
  2890. ClearEvent(Event); { Event was handled }
  2891. End Else Inherited HandleEvent(Event); { Call ancestor }
  2892. END;
  2893. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2894. { THistoryWindow OBJECT METHODS }
  2895. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2896. {--THistoryWindow-----------------------------------------------------------}
  2897. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2898. {---------------------------------------------------------------------------}
  2899. CONSTRUCTOR THistoryWindow.Init (Var Bounds: TRect; HistoryId: Word);
  2900. BEGIN
  2901. Inherited Init(Bounds, '', wnNoNumber); { Call ancestor }
  2902. Flags := wfClose; { Close flag only }
  2903. InitViewer(HistoryId); { Create list view }
  2904. END;
  2905. {--THistoryWindow-----------------------------------------------------------}
  2906. { GetSelection -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2907. {---------------------------------------------------------------------------}
  2908. FUNCTION THistoryWindow.GetSelection: String;
  2909. BEGIN
  2910. If (Viewer = Nil) Then GetSelection := '' Else { Return empty string }
  2911. GetSelection := Viewer^.GetText(Viewer^.Focused,
  2912. 255); { Get focused string }
  2913. END;
  2914. {--THistoryWindow-----------------------------------------------------------}
  2915. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2916. {---------------------------------------------------------------------------}
  2917. FUNCTION THistoryWindow.GetPalette: PPalette;
  2918. CONST P: String[Length(CHistoryWindow)] = CHistoryWindow;{ Always normal string }
  2919. BEGIN
  2920. GetPalette := PPalette(@P); { Return the palette }
  2921. END;
  2922. {--THistoryWindow-----------------------------------------------------------}
  2923. { InitViewer -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2924. {---------------------------------------------------------------------------}
  2925. PROCEDURE THistoryWindow.InitViewer(HistoryId: Word);
  2926. VAR R: TRect;
  2927. BEGIN
  2928. GetExtent(R); { Get extents }
  2929. R.Grow(-1,-1); { Grow inside }
  2930. Viewer := New(PHistoryViewer, Init(R,
  2931. StandardScrollBar(sbHorizontal + sbHandleKeyboard),
  2932. StandardScrollBar(sbVertical + sbHandleKeyboard),
  2933. HistoryId)); { Create the viewer }
  2934. If (Viewer <> Nil) Then Insert(Viewer); { Insert viewer }
  2935. END;
  2936. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2937. { THistory OBJECT METHODS }
  2938. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2939. {--THistory-----------------------------------------------------------------}
  2940. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2941. {---------------------------------------------------------------------------}
  2942. CONSTRUCTOR THistory.Init (Var Bounds: TRect; ALink: PInputLine;
  2943. AHistoryId: Word);
  2944. BEGIN
  2945. Inherited Init(Bounds); { Call ancestor }
  2946. Options := Options OR ofPostProcess; { Set post process }
  2947. EventMask := EventMask OR evBroadcast; { See broadcast events }
  2948. Link := ALink; { Hold link view }
  2949. HistoryId := AHistoryId; { Hold history id }
  2950. END;
  2951. {--THistory-----------------------------------------------------------------}
  2952. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2953. {---------------------------------------------------------------------------}
  2954. CONSTRUCTOR THistory.Load (Var S: TStream);
  2955. BEGIN
  2956. Inherited Load(S); { Call ancestor }
  2957. GetPeerViewPtr(S, Link); { Load link view }
  2958. S.Read(HistoryId, SizeOf(HistoryId)); { Read history id }
  2959. END;
  2960. {--THistory-----------------------------------------------------------------}
  2961. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2962. {---------------------------------------------------------------------------}
  2963. FUNCTION THistory.GetPalette: PPalette;
  2964. CONST P: String[Length(CHistory)] = CHistory; { Always normal string }
  2965. BEGIN
  2966. GetPalette := PPalette(@P); { Return the palette }
  2967. END;
  2968. {--THistory-----------------------------------------------------------------}
  2969. { InitHistoryWindow -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2970. {---------------------------------------------------------------------------}
  2971. FUNCTION THistory.InitHistoryWindow (Var Bounds: TRect): PHistoryWindow;
  2972. VAR P: PHistoryWindow;
  2973. BEGIN
  2974. P := New(PHistoryWindow, Init(Bounds, HistoryId)); { Create history window }
  2975. If (Link <> Nil) Then
  2976. P^.HelpCtx := Link^.HelpCtx; { Set help context }
  2977. InitHistoryWindow := P; { Return history window }
  2978. END;
  2979. PROCEDURE THistory.Draw;
  2980. VAR B: TDrawBuffer;
  2981. BEGIN
  2982. MoveCStr(B,#222'~v~'#221, GetColor($0102)); { Set buffer data }
  2983. WriteLine(0, 0, Size.X, Size.Y, B); { Write buffer }
  2984. END;
  2985. {--THistory-----------------------------------------------------------------}
  2986. { RecordHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2987. {---------------------------------------------------------------------------}
  2988. PROCEDURE THistory.RecordHistory (CONST S: String);
  2989. BEGIN
  2990. HistoryAdd(HistoryId, S); { Add to history }
  2991. END;
  2992. {--THistory-----------------------------------------------------------------}
  2993. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  2994. {---------------------------------------------------------------------------}
  2995. PROCEDURE THistory.Store (Var S: TStream);
  2996. BEGIN
  2997. TView.Store(S); { TView.Store called }
  2998. PutPeerViewPtr(S, Link); { Store link view }
  2999. S.Write(HistoryId, SizeOf(HistoryId)); { Store history id }
  3000. END;
  3001. {--THistory-----------------------------------------------------------------}
  3002. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Oct99 LdB }
  3003. {---------------------------------------------------------------------------}
  3004. PROCEDURE THistory.HandleEvent (Var Event: TEvent);
  3005. VAR C: Word; Rslt: String; R, P: TRect; HistoryWindow: PHistoryWindow;
  3006. BEGIN
  3007. Inherited HandleEvent(Event); { Call ancestor }
  3008. If (Link = Nil) Then Exit; { No link view exits }
  3009. If (Event.What = evMouseDown) OR { Mouse down event }
  3010. ((Event.What = evKeyDown) AND
  3011. (CtrlToArrow(Event.KeyCode) = kbDown) AND { Down arrow key }
  3012. (Link^.State AND sfFocused <> 0)) Then Begin { Link view selected }
  3013. If NOT Link^.Focus Then Begin
  3014. ClearEvent(Event); { Event was handled }
  3015. Exit; { Now exit }
  3016. End;
  3017. RecordHistory(Link^.Data^); { Record current data }
  3018. Link^.GetBounds(R); { Get view bounds }
  3019. Dec(R.A.X); { One char in from us }
  3020. Inc(R.B.X); { One char short of us }
  3021. Inc(R.B.Y, 7); { Seven lines down }
  3022. Dec(R.A.Y,1); { One line below us }
  3023. Owner^.GetExtent(P); { Get owner extents }
  3024. R.Intersect(P); { Intersect views }
  3025. Dec(R.B.Y,1); { Shorten length by one }
  3026. HistoryWindow := InitHistoryWindow(R); { Create history window }
  3027. If (HistoryWindow <> Nil) Then Begin { Window crested okay }
  3028. C := Owner^.ExecView(HistoryWindow); { Execute this window }
  3029. If (C = cmOk) Then Begin { Result was okay }
  3030. Rslt := HistoryWindow^.GetSelection; { Get history selection }
  3031. If Length(Rslt) > Link^.MaxLen Then
  3032. SetLength(Rslt, Link^.MaxLen); { Hold new length }
  3033. Link^.Data^ := Rslt; { Hold new selection }
  3034. Link^.SelectAll(True); { Select all string }
  3035. Link^.DrawView; { Redraw link view }
  3036. End;
  3037. Dispose(HistoryWindow, Done); { Dispose of window }
  3038. End;
  3039. ClearEvent(Event); { Event was handled }
  3040. End Else If (Event.What = evBroadcast) Then { Broadcast event }
  3041. If ((Event.Command = cmReleasedFocus) AND
  3042. (Event.InfoPtr = Link)) OR
  3043. (Event.Command = cmRecordHistory) Then { Record command }
  3044. RecordHistory(Link^.Data^); { Record the history }
  3045. END;
  3046. {****************************************************************************}
  3047. { TBrowseButton Object }
  3048. {****************************************************************************}
  3049. {****************************************************************************}
  3050. { TBrowseButton.Init }
  3051. {****************************************************************************}
  3052. constructor TBrowseButton.Init(var Bounds: TRect; ATitle: TTitleStr;
  3053. ACommand: Word; AFlags: Byte; ALink: PBrowseInputLine);
  3054. begin
  3055. if not inherited Init(Bounds,ATitle,ACommand,AFlags) then
  3056. Fail;
  3057. Link := ALink;
  3058. end;
  3059. {****************************************************************************}
  3060. { TBrowseButton.Load }
  3061. {****************************************************************************}
  3062. constructor TBrowseButton.Load(var S: TStream);
  3063. begin
  3064. if not inherited Load(S) then
  3065. Fail;
  3066. GetPeerViewPtr(S,Link);
  3067. end;
  3068. {****************************************************************************}
  3069. { TBrowseButton.Press }
  3070. {****************************************************************************}
  3071. procedure TBrowseButton.Press;
  3072. var
  3073. E: TEvent;
  3074. begin
  3075. Message(Owner, evBroadcast, cmRecordHistory, nil);
  3076. if Flags and bfBroadcast <> 0 then
  3077. Message(Owner, evBroadcast, Command, Link) else
  3078. begin
  3079. E.What := evCommand;
  3080. E.Command := Command;
  3081. E.InfoPtr := Link;
  3082. PutEvent(E);
  3083. end;
  3084. end;
  3085. {****************************************************************************}
  3086. { TBrowseButton.Store }
  3087. {****************************************************************************}
  3088. procedure TBrowseButton.Store(var S: TStream);
  3089. begin
  3090. inherited Store(S);
  3091. PutPeerViewPtr(S,Link);
  3092. end;
  3093. {****************************************************************************}
  3094. { TBrowseInputLine Object }
  3095. {****************************************************************************}
  3096. {****************************************************************************}
  3097. { TBrowseInputLine.Init }
  3098. {****************************************************************************}
  3099. constructor TBrowseInputLine.Init(var Bounds: TRect; AMaxLen: Sw_Integer; AHistory: Sw_Word);
  3100. begin
  3101. if not inherited Init(Bounds,AMaxLen) then
  3102. Fail;
  3103. History := AHistory;
  3104. end;
  3105. {****************************************************************************}
  3106. { TBrowseInputLine.Load }
  3107. {****************************************************************************}
  3108. constructor TBrowseInputLine.Load(var S: TStream);
  3109. begin
  3110. if not inherited Load(S) then
  3111. Fail;
  3112. S.Read(History,SizeOf(History));
  3113. if (S.Status <> stOk) then
  3114. Fail;
  3115. end;
  3116. {****************************************************************************}
  3117. { TBrowseInputLine.DataSize }
  3118. {****************************************************************************}
  3119. function TBrowseInputLine.DataSize: Sw_Word;
  3120. begin
  3121. DataSize := SizeOf(TBrowseInputLineRec);
  3122. end;
  3123. {****************************************************************************}
  3124. { TBrowseInputLine.GetData }
  3125. {****************************************************************************}
  3126. procedure TBrowseInputLine.GetData(var Rec);
  3127. var
  3128. LocalRec: TBrowseInputLineRec absolute Rec;
  3129. begin
  3130. if (Validator = nil) or
  3131. (Validator^.Transfer(Data^,@LocalRec.Text, vtGetData) = 0) then
  3132. begin
  3133. FillChar(LocalRec.Text, DataSize, #0);
  3134. Move(Data^, LocalRec.Text, Length(Data^) + 1);
  3135. end;
  3136. LocalRec.History := History;
  3137. end;
  3138. {****************************************************************************}
  3139. { TBrowseInputLine.SetData }
  3140. {****************************************************************************}
  3141. procedure TBrowseInputLine.SetData(var Rec);
  3142. var
  3143. LocalRec: TBrowseInputLineRec absolute Rec;
  3144. begin
  3145. if (Validator = nil) or
  3146. (Validator^.Transfer(Data^, @LocalRec.Text, vtSetData) = 0) then
  3147. Move(LocalRec.Text, Data^[0], MaxLen + 1);
  3148. History := LocalRec.History;
  3149. SelectAll(True);
  3150. end;
  3151. {****************************************************************************}
  3152. { TBrowseInputLine.Store }
  3153. {****************************************************************************}
  3154. procedure TBrowseInputLine.Store(var S: TStream);
  3155. begin
  3156. inherited Store(S);
  3157. S.Write(History,SizeOf(History));
  3158. end;
  3159. {****************************************************************************}
  3160. { TCommandCheckBoxes Object }
  3161. {****************************************************************************}
  3162. {****************************************************************************}
  3163. { TCommandCheckBoxes.Init }
  3164. {****************************************************************************}
  3165. constructor TCommandCheckBoxes.Init (var Bounds : TRect;
  3166. ACommandStrings : PCommandSItem);
  3167. var StartSItem, S : PSItem;
  3168. CItems : PCommandSItem;
  3169. i : Sw_Integer;
  3170. begin
  3171. if ACommandStrings = nil then
  3172. Fail;
  3173. { set up string list }
  3174. StartSItem := NewSItem(ACommandStrings^.Value,nil);
  3175. S := StartSItem;
  3176. CItems := ACommandStrings^.Next;
  3177. while (CItems <> nil) do begin
  3178. S^.Next := NewSItem(CItems^.Value,nil);
  3179. S := S^.Next;
  3180. CItems := CItems^.Next;
  3181. end;
  3182. { construct check boxes }
  3183. if not TCheckBoxes.Init(Bounds,StartSItem) then begin
  3184. while (StartSItem <> nil) do begin
  3185. S := StartSItem;
  3186. StartSItem := StartSItem^.Next;
  3187. if (S^.Value <> nil) then
  3188. DisposeStr(S^.Value);
  3189. Dispose(S);
  3190. end;
  3191. Fail;
  3192. end;
  3193. { set up CommandList and dispose of memory used by ACommandList }
  3194. i := 0;
  3195. while (ACommandStrings <> nil) do begin
  3196. CommandList[i] := ACommandStrings^.Command;
  3197. CItems := ACommandStrings;
  3198. ACommandStrings := ACommandStrings^.Next;
  3199. Dispose(CItems);
  3200. Inc(i);
  3201. end;
  3202. end;
  3203. {****************************************************************************}
  3204. { TCommandCheckBoxes.Load }
  3205. {****************************************************************************}
  3206. constructor TCommandCheckBoxes.Load (var S : TStream);
  3207. begin
  3208. if not TCheckBoxes.Load(S) then
  3209. Fail;
  3210. S.Read(CommandList,SizeOf(CommandList));
  3211. if (S.Status <> stOk) then begin
  3212. TCheckBoxes.Done;
  3213. Fail;
  3214. end;
  3215. end;
  3216. {****************************************************************************}
  3217. { TCommandCheckBoxes.Press }
  3218. {****************************************************************************}
  3219. procedure TCommandCheckBoxes.Press (Item : Sw_Integer);
  3220. var Temp : Sw_Integer;
  3221. begin
  3222. Temp := Value;
  3223. TCheckBoxes.Press(Item);
  3224. if (Value <> Temp) then { value changed - notify peers }
  3225. Message(Owner,evCommand,CommandList[Item],@Value);
  3226. end;
  3227. {****************************************************************************}
  3228. { TCommandCheckBoxes.Store }
  3229. {****************************************************************************}
  3230. procedure TCommandCheckBoxes.Store (var S : TStream);
  3231. begin
  3232. TCheckBoxes.Store(S);
  3233. S.Write(CommandList,SizeOf(CommandList));
  3234. end;
  3235. {****************************************************************************}
  3236. { TCommandIcon Object }
  3237. {****************************************************************************}
  3238. {****************************************************************************}
  3239. { TCommandIcon.Init }
  3240. {****************************************************************************}
  3241. constructor TCommandIcon.Init (var Bounds : TRect; AText : String;
  3242. ACommand : Word);
  3243. begin
  3244. if not TStaticText.Init(Bounds,AText) then
  3245. Fail;
  3246. Options := Options or ofPostProcess;
  3247. Command := ACommand;
  3248. end;
  3249. {****************************************************************************}
  3250. { TCommandIcon.HandleEvent }
  3251. {****************************************************************************}
  3252. procedure TCommandIcon.HandleEvent (var Event : TEvent);
  3253. begin
  3254. if ((Event.What = evMouseDown) and MouseInView(MouseWhere)) then begin
  3255. ClearEvent(Event);
  3256. Message(Owner,evCommand,Command,nil);
  3257. end;
  3258. TStaticText.HandleEvent(Event);
  3259. end;
  3260. {****************************************************************************}
  3261. { TCommandInputLine Object }
  3262. {****************************************************************************}
  3263. {****************************************************************************}
  3264. { TCommandInputLine.Changed }
  3265. {****************************************************************************}
  3266. {procedure TCommandInputLine.Changed;
  3267. begin
  3268. Message(Owner,evBroadcast,cmInputLineChanged,@Self);
  3269. end; }
  3270. {****************************************************************************}
  3271. { TCommandInputLine.HandleEvent }
  3272. {****************************************************************************}
  3273. {procedure TCommandInputLine.HandleEvent (var Event : TEvent);
  3274. var E : TEvent;
  3275. begin
  3276. E := Event;
  3277. TBSDInputLine.HandleEvent(Event);
  3278. if ((E.What and evKeyBoard = evKeyBoard) and (Event.KeyCode = kbEnter))
  3279. then Changed;
  3280. end; }
  3281. {****************************************************************************}
  3282. { TCommandRadioButtons Object }
  3283. {****************************************************************************}
  3284. {****************************************************************************}
  3285. { TCommandRadioButtons.Init }
  3286. {****************************************************************************}
  3287. constructor TCommandRadioButtons.Init (var Bounds : TRect;
  3288. ACommandStrings : PCommandSItem);
  3289. var
  3290. StartSItem, S : PSItem;
  3291. CItems : PCommandSItem;
  3292. i : Sw_Integer;
  3293. begin
  3294. if ACommandStrings = nil
  3295. then Fail;
  3296. { set up string list }
  3297. StartSItem := NewSItem(ACommandStrings^.Value,nil);
  3298. S := StartSItem;
  3299. CItems := ACommandStrings^.Next;
  3300. while (CItems <> nil) do begin
  3301. S^.Next := NewSItem(CItems^.Value,nil);
  3302. S := S^.Next;
  3303. CItems := CItems^.Next;
  3304. end;
  3305. { construct check boxes }
  3306. if not TRadioButtons.Init(Bounds,StartSItem) then begin
  3307. while (StartSItem <> nil) do begin
  3308. S := StartSItem;
  3309. StartSItem := StartSItem^.Next;
  3310. if (S^.Value <> nil) then
  3311. DisposeStr(S^.Value);
  3312. Dispose(S);
  3313. end;
  3314. Fail;
  3315. end;
  3316. { set up command list }
  3317. i := 0;
  3318. while (ACommandStrings <> nil) do begin
  3319. CommandList[i] := ACommandStrings^.Command;
  3320. CItems := ACommandStrings;
  3321. ACommandStrings := ACommandStrings^.Next;
  3322. Dispose(CItems);
  3323. Inc(i);
  3324. end;
  3325. end;
  3326. {****************************************************************************}
  3327. { TCommandRadioButtons.Load }
  3328. {****************************************************************************}
  3329. constructor TCommandRadioButtons.Load (var S : TStream);
  3330. begin
  3331. if not TRadioButtons.Load(S) then
  3332. Fail;
  3333. S.Read(CommandList,SizeOf(CommandList));
  3334. if (S.Status <> stOk) then begin
  3335. TRadioButtons.Done;
  3336. Fail;
  3337. end;
  3338. end;
  3339. {****************************************************************************}
  3340. { TCommandRadioButtons.MoveTo }
  3341. {****************************************************************************}
  3342. procedure TCommandRadioButtons.MovedTo (Item : Sw_Integer);
  3343. var Temp : Sw_Integer;
  3344. begin
  3345. Temp := Value;
  3346. TRadioButtons.MovedTo(Item);
  3347. if (Value <> Temp) then { value changed - notify peers }
  3348. Message(Owner,evCommand,CommandList[Item],@Value);
  3349. end;
  3350. {****************************************************************************}
  3351. { TCommandRadioButtons.Press }
  3352. {****************************************************************************}
  3353. procedure TCommandRadioButtons.Press (Item : Sw_Integer);
  3354. var Temp : Sw_Integer;
  3355. begin
  3356. Temp := Value;
  3357. TRadioButtons.Press(Item);
  3358. if (Value <> Temp) then { value changed - notify peers }
  3359. Message(Owner,evCommand,CommandList[Item],@Value);
  3360. end;
  3361. {****************************************************************************}
  3362. { TCommandRadioButtons.Store }
  3363. {****************************************************************************}
  3364. procedure TCommandRadioButtons.Store (var S : TStream);
  3365. begin
  3366. TRadioButtons.Store(S);
  3367. S.Write(CommandList,SizeOf(CommandList));
  3368. end;
  3369. {****************************************************************************}
  3370. { TEditListBox Object }
  3371. {****************************************************************************}
  3372. {****************************************************************************}
  3373. { TEditListBox.Init }
  3374. {****************************************************************************}
  3375. constructor TEditListBox.Init (Bounds : TRect; ANumCols: Word;
  3376. AVScrollBar : PScrollBar);
  3377. begin
  3378. if not inherited Init(Bounds,ANumCols,AVScrollBar)
  3379. then Fail;
  3380. CurrentField := 1;
  3381. end;
  3382. {****************************************************************************}
  3383. { TEditListBox.Load }
  3384. {****************************************************************************}
  3385. constructor TEditListBox.Load (var S : TStream);
  3386. begin
  3387. if not inherited Load(S)
  3388. then Fail;
  3389. CurrentField := 1;
  3390. end;
  3391. {****************************************************************************}
  3392. { TEditListBox.EditField }
  3393. {****************************************************************************}
  3394. procedure TEditListBox.EditField (var Event : TEvent);
  3395. var R : TRect;
  3396. InputLine : PModalInputLine;
  3397. begin
  3398. R.Assign(StartColumn,(Origin.Y + Focused - TopItem),
  3399. (StartColumn + FieldWidth + 2),(Origin.Y + Focused - TopItem + 1));
  3400. Owner^.MakeGlobal(R.A,R.A);
  3401. Owner^.MakeGlobal(R.B,R.B);
  3402. InputLine := New(PModalInputLine,Init(R,FieldWidth));
  3403. InputLine^.SetValidator(FieldValidator);
  3404. if InputLine <> nil
  3405. then begin
  3406. { Use TInputLine^.SetData so that data validation occurs }
  3407. { because TInputLine.Data is allocated memory large enough }
  3408. { to hold a string of MaxLen. It is also faster. }
  3409. GetField(InputLine);
  3410. if (Application^.ExecView(InputLine) = cmOk)
  3411. then SetField(InputLine);
  3412. Dispose(InputLine,done);
  3413. end;
  3414. end;
  3415. {****************************************************************************}
  3416. { TEditListBox.FieldValidator }
  3417. {****************************************************************************}
  3418. function TEditListBox.FieldValidator : PValidator;
  3419. { In a multiple field listbox FieldWidth should return the width }
  3420. { appropriate for Field. The default is an inputline for editing }
  3421. { a string of length large enough to fill the listbox field. }
  3422. begin
  3423. FieldValidator := nil;
  3424. end;
  3425. {****************************************************************************}
  3426. { TEditListBox.FieldWidth }
  3427. {****************************************************************************}
  3428. function TEditListBox.FieldWidth : Integer;
  3429. { In a multiple field listbox FieldWidth should return the width }
  3430. { appropriate for CurrentField. }
  3431. begin
  3432. FieldWidth := Size.X - 2;
  3433. end;
  3434. {****************************************************************************}
  3435. { TEditListBox.GetField }
  3436. {****************************************************************************}
  3437. procedure TEditListBox.GetField (InputLine : PInputLine);
  3438. { Places a string appropriate to Field and Focused into InputLine that }
  3439. { will be edited. Override this method for complex data types. }
  3440. begin
  3441. InputLine^.SetData(PString(List^.At(Focused))^);
  3442. end;
  3443. {****************************************************************************}
  3444. { TEditListBox.GetPalette }
  3445. {****************************************************************************}
  3446. function TEditListBox.GetPalette : PPalette;
  3447. begin
  3448. GetPalette := inherited GetPalette;
  3449. end;
  3450. {****************************************************************************}
  3451. { TEditListBox.HandleEvent }
  3452. {****************************************************************************}
  3453. procedure TEditListBox.HandleEvent (var Event : TEvent);
  3454. begin
  3455. if (Event.What = evKeyboard) and (Event.KeyCode = kbAltE)
  3456. then begin { edit field }
  3457. EditField(Event);
  3458. DrawView;
  3459. ClearEvent(Event);
  3460. end;
  3461. inherited HandleEvent(Event);
  3462. end;
  3463. {****************************************************************************}
  3464. { TEditListBox.SetField }
  3465. {****************************************************************************}
  3466. procedure TEditListBox.SetField (InputLine : PInputLine);
  3467. { Override this method for field types other than PStrings. }
  3468. var Item : PString;
  3469. begin
  3470. Item := NewStr(InputLine^.Data^);
  3471. if Item <> nil
  3472. then begin
  3473. List^.AtFree(Focused);
  3474. List^.Insert(Item);
  3475. SetFocusedItem(Item);
  3476. end;
  3477. end;
  3478. {****************************************************************************}
  3479. { TEditListBox.StartColumn }
  3480. {****************************************************************************}
  3481. function TEditListBox.StartColumn : Integer;
  3482. begin
  3483. StartColumn := Origin.X;
  3484. end;
  3485. {****************************************************************************}
  3486. { TListDlg Object }
  3487. {****************************************************************************}
  3488. {****************************************************************************}
  3489. { TListDlg.Init }
  3490. {****************************************************************************}
  3491. constructor TListDlg.Init (ATitle : TTitleStr; Items:
  3492. String; AButtons: Word; AListBox: PListBox; AEditCommand, ANewCommand :
  3493. Word);
  3494. var
  3495. Bounds: TRect;
  3496. b: Byte;
  3497. ButtonCount: Byte;
  3498. i, j, Gap, Line: Integer;
  3499. Scrollbar: PScrollbar;
  3500. HasFrame: Boolean;
  3501. HasButtons: Boolean;
  3502. HasScrollBar: Boolean;
  3503. HasItems: Boolean;
  3504. begin
  3505. if AListBox = nil then
  3506. Fail
  3507. else
  3508. ListBox := AListBox;
  3509. HasFrame := ((AButtons and ldNoFrame) = 0);
  3510. HasButtons := ((AButtons and ldAllButtons) <> 0);
  3511. HasScrollBar := ((AButtons and ldNoScrollBar) = 0);
  3512. HasItems := (Items <> '');
  3513. ButtonCount := 2;
  3514. for b := 0 to 3 do
  3515. if (AButtons and ($0001 shl 1)) <> 0 then
  3516. Inc(ButtonCount);
  3517. { Make sure dialog is large enough for buttons }
  3518. ListBox^.GetExtent(Bounds);
  3519. Bounds.Move(ListBox^.Origin.X,ListBox^.Origin.Y);
  3520. if HasFrame then
  3521. begin
  3522. Inc(Bounds.B.X,2);
  3523. Inc(Bounds.B.Y,2);
  3524. end;
  3525. if HasButtons then
  3526. begin
  3527. Inc(Bounds.B.X,14);
  3528. if Bounds.B.Y < (ButtonCount * 2) + 4 then
  3529. Bounds.B.Y := (ButtonCount * 2) + 5;
  3530. end;
  3531. if HasItems then
  3532. Inc(Bounds.B.Y,1);
  3533. if not TDialog.Init(Bounds,ATitle) then
  3534. Fail;
  3535. NewCommand := ANewCommand;
  3536. EditCommand := AEditCommand;
  3537. Options := Options or ofNewEditDelete;
  3538. if (not HasFrame) and (Frame <> nil) then
  3539. begin
  3540. Delete(Frame);
  3541. Dispose(Frame,Done);
  3542. Frame := nil;
  3543. Options := Options and not ofFramed;
  3544. end;
  3545. HelpCtx := hcListDlg;
  3546. { position and insert ListBox }
  3547. ListBox := AListBox;
  3548. Insert(ListBox);
  3549. if HasItems then
  3550. if HasFrame then
  3551. ListBox^.MoveTo(2,2)
  3552. else ListBox^.MoveTo(0,2)
  3553. else
  3554. if HasFrame then
  3555. ListBox^.MoveTo(1,1)
  3556. else ListBox^.MoveTo(0,0);
  3557. if HasButtons then
  3558. if ListBox^.Size.Y < (ButtonCount * 2) then
  3559. ListBox^.GrowTo(ListBox^.Size.X,ButtonCount * 2);
  3560. { do Items }
  3561. if HasItems then
  3562. begin
  3563. Bounds.Assign(1,1,CStrLen(Items)+2,2);
  3564. Insert(New(PLabel,Init(Bounds,Items,ListBox)));
  3565. end;
  3566. { do scrollbar }
  3567. if HasScrollBar then
  3568. begin
  3569. Bounds.Assign(ListBox^.Size.X+ListBox^.Origin.X,ListBox^.Origin.Y,
  3570. ListBox^.Size.X + ListBox^.Origin.X + 1,
  3571. ListBox^.Size.Y + ListBox^.Origin.Y { origin });
  3572. ScrollBar := New(PScrollBar,Init(Bounds));
  3573. Bounds.Assign(Origin.X,Origin.Y,Origin.X + Size.X + 1, Origin.Y + Size.Y);
  3574. ChangeBounds(Bounds);
  3575. Insert(Scrollbar);
  3576. end;
  3577. if HasButtons then
  3578. begin { do buttons }
  3579. j := $0001;
  3580. Gap := 0;
  3581. for i := 0 to 3 do
  3582. if ((j shl i) and AButtons) <> 0 then
  3583. Inc(Gap);
  3584. Gap := ((Size.Y - 2) div (Gap + 2));
  3585. if Gap < 2 then
  3586. Gap := 2;
  3587. { Insert Buttons }
  3588. Line := 2;
  3589. if (AButtons and ldNew) = ldNew then
  3590. begin
  3591. Insert(NewButton(Size.X - 12,Line,10,2,'~N~ew',cmNew,hcInsert,bfNormal));
  3592. Inc(Line,Gap);
  3593. end;
  3594. if (AButtons and ldEdit) = ldEdit then
  3595. begin
  3596. Insert(NewButton(Size.X - 12,Line,10,2,'~E~dit',cmEdit,hcEdit,
  3597. bfNormal));
  3598. Inc(Line,Gap);
  3599. end;
  3600. if (AButtons and ldDelete) = ldDelete then
  3601. begin
  3602. Insert(NewButton(Size.X - 12,Line,10,2,'~D~elete',cmDelete,hcDelete,
  3603. bfNormal));
  3604. Inc(Line,Gap);
  3605. end;
  3606. Insert(NewButton(Size.X - 12,Line,10,2,'O~k~',cmOK,hcOk,bfDefault or
  3607. bfNormal));
  3608. Inc(Line,Gap);
  3609. Insert(NewButton(Size.X - 12,Line,10,2,'Cancel',cmCancel,hcCancel,
  3610. bfNormal));
  3611. if (AButtons and ldHelp) = ldHelp then
  3612. begin
  3613. Inc(Line,Gap);
  3614. Insert(NewButton(Size.X - 12,Line,10,2,'~H~elp',cmHelp,hcNoContext,
  3615. bfNormal));
  3616. end;
  3617. end;
  3618. if HasFrame and ((AButtons and ldAllIcons) <> 0) then
  3619. begin
  3620. Line := 2;
  3621. if (AButtons and ldNewIcon) = ldNewIcon then
  3622. begin
  3623. Bounds.Assign(Line,Size.Y-1,Line+5,Size.Y);
  3624. Insert(New(PCommandIcon,Init(Bounds,' Ins ',cmNew)));
  3625. Inc(Line,5);
  3626. if (AButtons and (ldEditIcon or ldDeleteIcon)) <> 0 then
  3627. begin
  3628. Bounds.Assign(Line,Size.Y-1,Line+1,Size.Y);
  3629. Insert(New(PStaticText,Init(Bounds,'/')));
  3630. Inc(Line,1);
  3631. end;
  3632. end;
  3633. if (AButtons and ldEditIcon) = ldEditIcon then
  3634. begin
  3635. Bounds.Assign(Line,Size.Y-1,Line+6,Size.Y);
  3636. Insert(New(PCommandIcon,Init(Bounds,' Edit ',cmEdit)));
  3637. Inc(Line,6);
  3638. if (AButtons and ldDeleteIcon) <> 0 then
  3639. begin
  3640. Bounds.Assign(Line,Size.Y-1,Line+1,Size.Y);
  3641. Insert(New(PStaticText,Init(Bounds,'/')));
  3642. Inc(Line,1);
  3643. end;
  3644. end;
  3645. if (AButtons and ldNewIcon) = ldNewIcon then
  3646. begin
  3647. Bounds.Assign(Line,Size.Y-1,Line+5,Size.Y);
  3648. Insert(New(PCommandIcon,Init(Bounds,' Del ',cmDelete)));
  3649. end;
  3650. end;
  3651. { Set focus to list boLine when dialog opens }
  3652. SelectNext(False);
  3653. end;
  3654. {****************************************************************************}
  3655. { TListDlg.Load }
  3656. {****************************************************************************}
  3657. constructor TListDlg.Load (var S : TStream);
  3658. begin
  3659. if not TDialog.Load(S) then
  3660. Fail;
  3661. S.Read(NewCommand,SizeOf(NewCommand));
  3662. S.Read(EditCommand,SizeOf(EditCommand));
  3663. GetSubViewPtr(S,ListBox);
  3664. end;
  3665. {****************************************************************************}
  3666. { TListDlg.HandleEvent }
  3667. {****************************************************************************}
  3668. procedure TListDlg.HandleEvent (var Event : TEvent);
  3669. const
  3670. TargetCommands: TCommandSet = [cmNew, cmEdit, cmDelete];
  3671. begin
  3672. if ((Event.What and evCommand) <> 0) and
  3673. (Event.Command in TargetCommands) then
  3674. case Event.Command of
  3675. cmDelete:
  3676. if Options and ofDelete = ofDelete then
  3677. begin
  3678. ListBox^.FreeFocusedItem;
  3679. ListBox^.DrawView;
  3680. ClearEvent(Event);
  3681. end;
  3682. cmNew:
  3683. if Options and ofNew = ofNew then
  3684. begin
  3685. Message(Application,evCommand,NewCommand,nil);
  3686. ListBox^.SetRange(ListBox^.List^.Count);
  3687. ListBox^.DrawView;
  3688. ClearEvent(Event);
  3689. end;
  3690. cmEdit:
  3691. if Options and ofEdit = ofEdit then
  3692. begin
  3693. Message(Application,evCommand,EditCommand,ListBox^.GetFocusedItem);
  3694. ListBox^.DrawView;
  3695. ClearEvent(Event);
  3696. end;
  3697. end;
  3698. if (Event.What and evBroadcast > 0) and
  3699. (Event.Command = cmListItemSelected) then
  3700. begin { use PutEvent instead of Message so that a window list box works }
  3701. Event.What := evCommand;
  3702. Event.Command := cmOk;
  3703. Event.InfoPtr := nil;
  3704. PutEvent(Event);
  3705. end;
  3706. TDialog.HandleEvent(Event);
  3707. end;
  3708. {****************************************************************************}
  3709. { TListDlg.Store }
  3710. {****************************************************************************}
  3711. procedure TListDlg.Store (var S : TStream);
  3712. begin
  3713. TDialog.Store(S);
  3714. S.Write(NewCommand,SizeOf(NewCommand));
  3715. S.Write(EditCommand,SizeOf(EditCommand));
  3716. PutSubViewPtr(S,ListBox);
  3717. end;
  3718. {****************************************************************************}
  3719. { TModalInputLine Object }
  3720. {****************************************************************************}
  3721. {****************************************************************************}
  3722. { TModalInputLine.Execute }
  3723. {****************************************************************************}
  3724. function TModalInputLine.Execute : Word;
  3725. var Event : TEvent;
  3726. begin
  3727. repeat
  3728. EndState := 0;
  3729. repeat
  3730. GetEvent(Event);
  3731. HandleEvent(Event);
  3732. if Event.What <> evNothing
  3733. then Owner^.EventError(Event); { may change this to ClearEvent }
  3734. until (EndState <> 0);
  3735. until Valid(EndState);
  3736. Execute := EndState;
  3737. end;
  3738. {****************************************************************************}
  3739. { TModalInputLine.HandleEvent }
  3740. {****************************************************************************}
  3741. procedure TModalInputLine.HandleEvent (var Event : TEvent);
  3742. begin
  3743. case Event.What of
  3744. evKeyboard : case Event.KeyCode of
  3745. kbUp, kbDown : EndModal(cmCancel);
  3746. kbEnter : EndModal(cmOk);
  3747. else inherited HandleEvent(Event);
  3748. end;
  3749. evMouse : if MouseInView(Event.Where)
  3750. then inherited HandleEvent(Event)
  3751. else EndModal(cmCancel);
  3752. else inherited HandleEvent(Event);
  3753. end;
  3754. end;
  3755. {****************************************************************************}
  3756. { TModalInputLine.SetState }
  3757. {****************************************************************************}
  3758. procedure TModalInputLine.SetState (AState : Word; Enable : Boolean);
  3759. var Pos : Integer;
  3760. begin
  3761. if (AState = sfSelected)
  3762. then begin
  3763. Pos := CurPos;
  3764. inherited SetState(AState,Enable);
  3765. CurPos := Pos;
  3766. SelStart := CurPos;
  3767. SelEnd := CurPos;
  3768. BlockCursor;
  3769. DrawView;
  3770. end
  3771. else inherited SetState(AState,Enable);
  3772. end;
  3773. {***************************************************************************}
  3774. { INTERFACE ROUTINES }
  3775. {***************************************************************************}
  3776. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3777. { ITEM STRING ROUTINES }
  3778. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3779. {---------------------------------------------------------------------------}
  3780. { NewSItem -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28Apr98 LdB }
  3781. {---------------------------------------------------------------------------}
  3782. FUNCTION NewSItem (Const Str: String; ANext: PSItem): PSItem;
  3783. VAR Item: PSItem;
  3784. BEGIN
  3785. New(Item); { Allocate item }
  3786. Item^.Value := NewStr(Str); { Hold item string }
  3787. Item^.Next := ANext; { Chain the ptr }
  3788. NewSItem := Item; { Return item }
  3789. END;
  3790. {****************************************************************************}
  3791. { NewCommandSItem }
  3792. {****************************************************************************}
  3793. function NewCommandSItem (Str : String; ACommand : Word;
  3794. ANext : PCommandSItem) : PCommandSItem;
  3795. var Temp : PCommandSItem;
  3796. begin
  3797. New(Temp);
  3798. if (Temp <> nil) then
  3799. begin
  3800. Temp^.Value := Str;
  3801. Temp^.Command := ACommand;
  3802. Temp^.Next := ANext;
  3803. end;
  3804. NewCommandSItem := Temp;
  3805. end;
  3806. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3807. { DIALOG OBJECT REGISTRATION ROUTINES }
  3808. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3809. {---------------------------------------------------------------------------}
  3810. { RegisterDialogs -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB }
  3811. {---------------------------------------------------------------------------}
  3812. PROCEDURE RegisterDialogs;
  3813. BEGIN
  3814. RegisterType(RDialog); { Register dialog }
  3815. RegisterType(RInputLine); { Register inputline }
  3816. RegisterType(RButton); { Register button }
  3817. RegisterType(RCluster); { Register cluster }
  3818. RegisterType(RRadioButtons); { Register radiobutton }
  3819. RegisterType(RCheckBoxes); { Register check boxes }
  3820. RegisterType(RMultiCheckBoxes); { Register multi boxes }
  3821. RegisterType(RListBox); { Register list box }
  3822. RegisterType(RStaticText); { Register static text }
  3823. RegisterType(RLabel); { Register label }
  3824. RegisterType(RHistory); { Register history }
  3825. RegisterType(RParamText); { Register parm text }
  3826. RegisterType(RCommandCheckBoxes);
  3827. RegisterType(RCommandIcon);
  3828. RegisterType(RCommandRadioButtons);
  3829. RegisterType(REditListBox);
  3830. RegisterType(RModalInputLine);
  3831. RegisterType(RListDlg);
  3832. END;
  3833. END.