dialogs.pas 191 KB

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