dialogs.pas 192 KB

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