dialogs.pas 183 KB

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