dialogs.pas 183 KB

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