views.pas 272 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651
  1. { $Id$ }
  2. {********[ SOURCE FILE OF GRAPHICAL FREE VISION ]**********}
  3. { }
  4. { System independent GRAPHICAL clone of VIEWS.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 address }
  10. { [email protected] - backup e-mail address }
  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. { 16 and 32 Bit compilers }
  25. { DOS - Turbo Pascal 7.0 + (16 Bit) }
  26. { DPMI - Turbo Pascal 7.0 + (16 Bit) }
  27. { - FPC 0.9912+ (GO32V2) (32 Bit) }
  28. { WINDOWS - Turbo Pascal 7.0 + (16 Bit) }
  29. { - Delphi 1.0+ (16 Bit) }
  30. { WIN95/NT - Delphi 2.0+ (32 Bit) }
  31. { - Virtual Pascal 2.0+ (32 Bit) }
  32. { - Speedsoft Sybil 2.0+ (32 Bit) }
  33. { - FPC 0.9912+ (32 Bit) }
  34. { OS2 - Virtual Pascal 1.0+ (32 Bit) }
  35. { }
  36. {******************[ REVISION HISTORY ]********************}
  37. { Version Date Fix }
  38. { ------- --------- --------------------------------- }
  39. { 1.00 10 Nov 96 First multi platform release }
  40. { 1.10 29 Aug 97 Platform.inc sort added. }
  41. { 1.20 12 Sep 97 FPK pascal 0.92 conversion added. }
  42. { 1.30 10 Jun 98 Virtual pascal 2.0 code added. }
  43. { 1.40 10 Jul 99 Sybil 2.0 code added }
  44. { 1.41 03 Nov 99 FPC Windows support added. }
  45. { 1.50 26 Nov 99 Graphics stuff moved to GFVGraph }
  46. {**********************************************************}
  47. UNIT Views;
  48. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  49. INTERFACE
  50. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  51. {====Include file to sort compiler platform out =====================}
  52. {$I Platform.inc}
  53. {====================================================================}
  54. {==== Compiler directives ===========================================}
  55. {$X+} { Extended syntax is ok }
  56. {$R-} { Disable range checking }
  57. {$S-} { Disable Stack Checking }
  58. {$I-} { Disable IO Checking }
  59. {$Q-} { Disable Overflow Checking }
  60. {$V-} { Turn off strict VAR strings }
  61. {====================================================================}
  62. USES
  63. {$IFDEF OS_WINDOWS} { WIN/NT CODE }
  64. Windows, { Standard unit }
  65. {$ENDIF}
  66. {$IFDEF OS_OS2} { OS2 CODE }
  67. OS2Def, OS2Base, OS2PMAPI, { Standard units }
  68. {$ENDIF}
  69. GFVGraph, { GFV standard unit }
  70. Objects, FVCommon, Drivers; { GFV standard units }
  71. {***************************************************************************}
  72. { PUBLIC CONSTANTS }
  73. {***************************************************************************}
  74. {---------------------------------------------------------------------------}
  75. { TView STATE MASKS }
  76. {---------------------------------------------------------------------------}
  77. CONST
  78. sfVisible = $0001; { View visible mask }
  79. sfCursorVis = $0002; { Cursor visible }
  80. sfCursorIns = $0004; { Cursor insert mode }
  81. sfShadow = $0008; { View has shadow }
  82. sfActive = $0010; { View is active }
  83. sfSelected = $0020; { View is selected }
  84. sfFocused = $0040; { View is focused }
  85. sfDragging = $0080; { View is dragging }
  86. sfDisabled = $0100; { View is disabled }
  87. sfModal = $0200; { View is modal }
  88. sfDefault = $0400; { View is default }
  89. sfExposed = $0800; { View is exposed }
  90. sfIconised = $1000; { View is iconised }
  91. {---------------------------------------------------------------------------}
  92. { TView OPTION MASKS }
  93. {---------------------------------------------------------------------------}
  94. CONST
  95. ofSelectable = $0001; { View selectable }
  96. ofTopSelect = $0002; { Top selectable }
  97. ofFirstClick = $0004; { First click react }
  98. ofFramed = $0008; { View is framed }
  99. ofPreProcess = $0010; { Pre processes }
  100. ofPostProcess = $0020; { Post processes }
  101. ofBuffered = $0040; { View is buffered }
  102. ofTileable = $0080; { View is tileable }
  103. ofCenterX = $0100; { View centred on x }
  104. ofCenterY = $0200; { View centred on y }
  105. ofCentered = $0300; { View x,y centred }
  106. ofValidate = $0400; { View validates }
  107. ofVersion = $3000; { View TV version }
  108. ofVersion10 = $0000; { TV version 1 view }
  109. ofVersion20 = $1000; { TV version 2 view }
  110. ofGFVModeView = $4000; { View is in GFV mode }
  111. {---------------------------------------------------------------------------}
  112. { TView GROW MODE MASKS }
  113. {---------------------------------------------------------------------------}
  114. CONST
  115. gfGrowLoX = $01; { Left side grow }
  116. gfGrowLoY = $02; { Top side grow }
  117. gfGrowHiX = $04; { Right side grow }
  118. gfGrowHiY = $08; { Bottom side grow }
  119. gfGrowAll = $0F; { Grow on all sides }
  120. gfGrowRel = $10; { Grow relative }
  121. {---------------------------------------------------------------------------}
  122. { TView DRAG MODE MASKS }
  123. {---------------------------------------------------------------------------}
  124. CONST
  125. dmDragMove = $01; { Move view }
  126. dmDragGrow = $02; { Grow view }
  127. dmLimitLoX = $10; { Limit left side }
  128. dmLimitLoY = $20; { Limit top side }
  129. dmLimitHiX = $40; { Limit right side }
  130. dmLimitHiY = $80; { Limit bottom side }
  131. dmLimitAll = $F0; { Limit all sides }
  132. {---------------------------------------------------------------------------}
  133. { >> NEW << TView OPTION MASKS }
  134. {---------------------------------------------------------------------------}
  135. CONST
  136. goThickFramed = $0001; { Thick framed mask }
  137. goDrawFocus = $0002; { Draw focus mask }
  138. goTitled = $0004; { Draw titled mask }
  139. goTabSelect = $0008; { Tab selectable }
  140. goEveryKey = $0020; { Report every key }
  141. goEndModal = $0040; { End modal }
  142. goNoShadow = $0080; { Do not write shadows }
  143. goGraphView = $1000; { Raw graphic view }
  144. goGraphical = $2000; { Graphical view }
  145. goNativeClass = $4000; { Native class window }
  146. goNoDrawView = $8000; { View does not draw }
  147. {---------------------------------------------------------------------------}
  148. { >> NEW << TAB OPTION MASKS }
  149. {---------------------------------------------------------------------------}
  150. CONST
  151. tmTab = $01; { Tab move mask }
  152. tmShiftTab = $02; { Shift+tab move mask }
  153. tmEnter = $04; { Enter move mask }
  154. tmLeft = $08; { Left arrow move mask }
  155. tmRight = $10; { Right arrow move mask }
  156. tmUp = $20; { Up arrow move mask }
  157. tmDown = $40; { Down arrow move mask }
  158. {---------------------------------------------------------------------------}
  159. { >> NEW << VIEW DRAW MASKS }
  160. {---------------------------------------------------------------------------}
  161. CONST
  162. vdBackGnd = $01; { Draw backgound }
  163. vdInner = $02; { Draw inner detail }
  164. vdCursor = $04; { Draw cursor }
  165. vdBorder = $08; { Draw view border }
  166. vdFocus = $10; { Draw focus state }
  167. vdNoChild = $20; { Draw no children }
  168. vdShadow = $40;
  169. vdAll = vdBackGnd + vdInner + vdCursor + vdBorder + vdFocus + vdShadow;
  170. {---------------------------------------------------------------------------}
  171. { TView HELP CONTEXTS }
  172. {---------------------------------------------------------------------------}
  173. CONST
  174. hcNoContext = 0; { No view context }
  175. hcDragging = 1; { No drag context }
  176. {---------------------------------------------------------------------------}
  177. { TWindow FLAG MASKS }
  178. {---------------------------------------------------------------------------}
  179. CONST
  180. wfMove = $01; { Window can move }
  181. wfGrow = $02; { Window can grow }
  182. wfClose = $04; { Window can close }
  183. wfZoom = $08; { Window can zoom }
  184. {---------------------------------------------------------------------------}
  185. { TWindow PALETTES }
  186. {---------------------------------------------------------------------------}
  187. CONST
  188. wpBlueWindow = 0; { Blue palette }
  189. wpCyanWindow = 1; { Cyan palette }
  190. wpGrayWindow = 2; { Gray palette }
  191. {---------------------------------------------------------------------------}
  192. { COLOUR PALETTES }
  193. {---------------------------------------------------------------------------}
  194. CONST
  195. CFrame = #1#1#2#2#3; { Frame palette }
  196. CScrollBar = #4#5#5; { Scrollbar palette }
  197. CScroller = #6#7; { Scroller palette }
  198. CListViewer = #26#26#27#28#29; { Listviewer palette }
  199. CBlueWindow = #8#9#10#11#12#13#14#15; { Blue window palette }
  200. CCyanWindow = #16#17#18#19#20#21#22#23; { Cyan window palette }
  201. CGrayWindow = #24#25#26#27#28#29#30#31; { Grey window palette }
  202. {---------------------------------------------------------------------------}
  203. { TScrollBar PART CODES }
  204. {---------------------------------------------------------------------------}
  205. CONST
  206. sbLeftArrow = 0; { Left arrow part }
  207. sbRightArrow = 1; { Right arrow part }
  208. sbPageLeft = 2; { Page left part }
  209. sbPageRight = 3; { Page right part }
  210. sbUpArrow = 4; { Up arrow part }
  211. sbDownArrow = 5; { Down arrow part }
  212. sbPageUp = 6; { Page up part }
  213. sbPageDown = 7; { Page down part }
  214. sbIndicator = 8; { Indicator part }
  215. {---------------------------------------------------------------------------}
  216. { TScrollBar OPTIONS FOR TWindow.StandardScrollBar }
  217. {---------------------------------------------------------------------------}
  218. CONST
  219. sbHorizontal = $0000; { Horz scrollbar }
  220. sbVertical = $0001; { Vert scrollbar }
  221. sbHandleKeyboard = $0002; { Handle keyboard }
  222. {---------------------------------------------------------------------------}
  223. { STANDARD COMMAND CODES }
  224. {---------------------------------------------------------------------------}
  225. CONST
  226. cmValid = 0; { Valid command }
  227. cmQuit = 1; { Quit command }
  228. cmError = 2; { Error command }
  229. cmMenu = 3; { Menu command }
  230. cmClose = 4; { Close command }
  231. cmZoom = 5; { Zoom command }
  232. cmResize = 6; { Resize command }
  233. cmNext = 7; { Next view command }
  234. cmPrev = 8; { Prev view command }
  235. cmHelp = 9; { Help command }
  236. cmOK = 10; { Okay command }
  237. cmCancel = 11; { Cancel command }
  238. cmYes = 12; { Yes command }
  239. cmNo = 13; { No command }
  240. cmDefault = 14; { Default command }
  241. cmCut = 20; { Clipboard cut cmd }
  242. cmCopy = 21; { Clipboard copy cmd }
  243. cmPaste = 22; { Clipboard paste cmd }
  244. cmUndo = 23; { Clipboard undo cmd }
  245. cmClear = 24; { Clipboard clear cmd }
  246. cmTile = 25; { Tile subviews cmd }
  247. cmCascade = 26; { Cascade subviews cmd }
  248. cmReceivedFocus = 50; { Received focus }
  249. cmReleasedFocus = 51; { Released focus }
  250. cmCommandSetChanged = 52; { Commands changed }
  251. cmScrollBarChanged = 53; { Scrollbar changed }
  252. cmScrollBarClicked = 54; { Scrollbar clicked on }
  253. cmSelectWindowNum = 55; { Select window }
  254. cmListItemSelected = 56; { Listview item select }
  255. cmNotify = 27;
  256. cmIdCommunicate = 28; { Communicate via id }
  257. cmIdSelect = 29; { Select via id }
  258. {---------------------------------------------------------------------------}
  259. { TWindow NUMBER CONSTANTS }
  260. {---------------------------------------------------------------------------}
  261. CONST
  262. wnNoNumber = 0; { Window has no num }
  263. MaxViewWidth = 132; { Max view width }
  264. {***************************************************************************}
  265. { PUBLIC TYPE DEFINITIONS }
  266. {***************************************************************************}
  267. {---------------------------------------------------------------------------}
  268. { TWindow Title string }
  269. {---------------------------------------------------------------------------}
  270. TYPE
  271. TTitleStr = String[80]; { Window title string }
  272. {---------------------------------------------------------------------------}
  273. { COMMAND SET RECORD }
  274. {---------------------------------------------------------------------------}
  275. TYPE
  276. TCommandSet = SET OF Byte; { Command set record }
  277. PCommandSet = ^TCommandSet; { Ptr to command set }
  278. {---------------------------------------------------------------------------}
  279. { PALETTE RECORD }
  280. {---------------------------------------------------------------------------}
  281. TYPE
  282. TPalette = String; { Palette record }
  283. PPalette = ^TPalette; { Pointer to palette }
  284. {---------------------------------------------------------------------------}
  285. { TDrawBuffer RECORD }
  286. {---------------------------------------------------------------------------}
  287. TYPE
  288. TDrawBuffer = Array [0..MaxViewWidth - 1] Of Word; { Draw buffer record }
  289. PDrawBuffer = ^TDrawBuffer; { Ptr to draw buffer }
  290. {---------------------------------------------------------------------------}
  291. { TVideoBuffer RECORD }
  292. {---------------------------------------------------------------------------}
  293. TYPE
  294. TVideoBuf = ARRAY [0..3999] of Word; { Video buffer }
  295. PVideoBuf = ^TVideoBuf; { Pointer to buffer }
  296. {---------------------------------------------------------------------------}
  297. { TComplexArea RECORD }
  298. {---------------------------------------------------------------------------}
  299. TYPE
  300. PComplexArea = ^TComplexArea; { Complex area }
  301. TComplexArea = PACKED RECORD
  302. X1, Y1 : Sw_Integer; { Top left corner }
  303. X2, Y2 : Sw_Integer; { Lower right corner }
  304. NextArea: PComplexArea; { Next area pointer }
  305. END;
  306. {***************************************************************************}
  307. { PUBLIC OBJECT DEFINITIONS }
  308. {***************************************************************************}
  309. TYPE
  310. PGroup = ^TGroup; { Pointer to group }
  311. {---------------------------------------------------------------------------}
  312. { TView OBJECT - ANCESTOR VIEW OBJECT }
  313. {---------------------------------------------------------------------------}
  314. PView = ^TView;
  315. TView = OBJECT (TObject)
  316. GrowMode : Byte; { View grow mode }
  317. DragMode : Byte; { View drag mode }
  318. DrawMask : Byte; { Draw masks }
  319. TabMask : Byte; { Tab move masks }
  320. ColourOfs: Sw_Integer; { View palette offset }
  321. HelpCtx : Word; { View help context }
  322. State : Word; { View state masks }
  323. Options : Word; { View options masks }
  324. EventMask: Word; { View event masks }
  325. GOptions : Word; { Graphics options }
  326. Origin : TPoint; { View origin }
  327. Size : TPoint; { View size }
  328. Cursor : TPoint; { Cursor position }
  329. RawOrigin: TPoint; { View raw origin }
  330. RawSize : TPoint; { View raw size }
  331. Next : PView; { Next peerview }
  332. Owner : PGroup; { Owner group }
  333. HoldLimit: PComplexArea; { Hold limit values }
  334. RevCol : Boolean;
  335. CONSTRUCTOR Init (Var Bounds: TRect);
  336. CONSTRUCTOR Load (Var S: TStream);
  337. DESTRUCTOR Done; Virtual;
  338. FUNCTION Prev: PView;
  339. FUNCTION Execute: Word; Virtual;
  340. FUNCTION Focus: Boolean;
  341. FUNCTION DataSize: Sw_Word; Virtual;
  342. FUNCTION TopView: PView;
  343. FUNCTION PrevView: PView;
  344. FUNCTION NextView: PView;
  345. FUNCTION GetHelpCtx: Word; Virtual;
  346. FUNCTION EventAvail: Boolean;
  347. FUNCTION GetPalette: PPalette; Virtual;
  348. FUNCTION GetColor (Color: Word): Word;
  349. FUNCTION Valid (Command: Word): Boolean; Virtual;
  350. FUNCTION GetState (AState: Word): Boolean;
  351. FUNCTION TextWidth (Txt: String): Sw_Integer;
  352. FUNCTION MouseInView (Point: TPoint): Boolean;
  353. FUNCTION CommandEnabled (Command: Word): Boolean;
  354. FUNCTION OverLapsArea (X1, Y1, X2, Y2: Sw_Integer): Boolean;
  355. FUNCTION MouseEvent (Var Event: TEvent; Mask: Word): Boolean;
  356. PROCEDURE Hide;
  357. PROCEDURE Show;
  358. PROCEDURE Draw; Virtual;
  359. PROCEDURE ResetCursor; Virtual;
  360. PROCEDURE Select;
  361. PROCEDURE Awaken; Virtual;
  362. PROCEDURE DrawView;
  363. PROCEDURE MakeFirst;
  364. PROCEDURE DrawFocus; Virtual;
  365. PROCEDURE DrawCursor; Virtual;
  366. PROCEDURE DrawBorder; Virtual;
  367. PROCEDURE DrawShadow; Virtual;
  368. PROCEDURE HideCursor;
  369. PROCEDURE ShowCursor;
  370. PROCEDURE BlockCursor;
  371. PROCEDURE NormalCursor;
  372. PROCEDURE FocusFromTop; Virtual;
  373. PROCEDURE SetViewLimits;
  374. PROCEDURE DrawBackGround; Virtual;
  375. PROCEDURE ReleaseViewLimits;
  376. PROCEDURE MoveTo (X, Y: Sw_Integer);
  377. PROCEDURE GrowTo (X, Y: Sw_Integer);
  378. PROCEDURE SetDrawMask (Mask: Byte);
  379. PROCEDURE EndModal (Command: Word); Virtual;
  380. PROCEDURE SetCursor (X, Y: Sw_Integer);
  381. PROCEDURE PutInFrontOf (Target: PView);
  382. PROCEDURE DisplaceBy (Dx, Dy: Sw_Integer); Virtual;
  383. PROCEDURE SetCommands (Commands: TCommandSet);
  384. PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer); Virtual;
  385. PROCEDURE EnableCommands (Commands: TCommandSet);
  386. PROCEDURE DisableCommands (Commands: TCommandSet);
  387. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  388. PROCEDURE SetCmdState (Commands: TCommandSet; Enable: Boolean);
  389. PROCEDURE GetData (Var Rec); Virtual;
  390. PROCEDURE SetData (Var Rec); Virtual;
  391. PROCEDURE Store (Var S: TStream);
  392. PROCEDURE Locate (Var Bounds: TRect);
  393. PROCEDURE KeyEvent (Var Event: TEvent);
  394. PROCEDURE GetEvent (Var Event: TEvent); Virtual;
  395. PROCEDURE PutEvent (Var Event: TEvent); Virtual;
  396. PROCEDURE GetExtent (Var Extent: TRect);
  397. PROCEDURE GetBounds (Var Bounds: TRect);
  398. PROCEDURE SetBounds (Var Bounds: TRect);
  399. PROCEDURE GetClipRect (Var Clip: TRect);
  400. PROCEDURE ClearEvent (Var Event: TEvent);
  401. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  402. PROCEDURE ChangeBounds (Var Bounds: TRect); Virtual;
  403. PROCEDURE SizeLimits (Var Min, Max: TPoint); Virtual;
  404. PROCEDURE GetCommands (Var Commands: TCommandSet);
  405. PROCEDURE GetPeerViewPtr (Var S: TStream; Var P);
  406. PROCEDURE PutPeerViewPtr (Var S: TStream; P: PView);
  407. PROCEDURE CalcBounds (Var Bounds: TRect; Delta: TPoint); Virtual;
  408. FUNCTION Exposed: Boolean; { This needs help!!!!! }
  409. PROCEDURE GraphLine (X1, Y1, X2, Y2: Sw_Integer; Colour: Byte);
  410. PROCEDURE GraphRectangle (X1, Y1, X2, Y2: Sw_Integer; Colour: Byte);
  411. PROCEDURE ClearArea (X1, Y1, X2, Y2: Sw_Integer; Colour: Byte);
  412. PROCEDURE GraphArc (Xc, Yc: Sw_Integer; Sa, Ea: Real; XRad, YRad: Sw_Integer;
  413. Colour: Byte);
  414. PROCEDURE FilletArc (Xc, Yc: Sw_Integer; Sa, Ea: Real; XRad, YRad, Ht: Sw_Integer;
  415. Colour: Byte);
  416. PROCEDURE BicolorRectangle (X1, Y1, X2, Y2: Sw_Integer; Light, Dark: Byte;
  417. Down: Boolean);
  418. PROCEDURE WriteBuf (X, Y, W, H: Sw_Integer; Var Buf);
  419. PROCEDURE WriteLine (X, Y, W, H: Sw_Integer; Var Buf);
  420. PROCEDURE MakeLocal (Source: TPoint; Var Dest: TPoint);
  421. PROCEDURE MakeGlobal (Source: TPoint; Var Dest: TPoint);
  422. PROCEDURE WriteStr (X, Y: Sw_Integer; Str: String; Color: Byte);
  423. PROCEDURE WriteCStr (X, Y: Sw_Integer; Str: String; Color1, Color2 : Byte);
  424. PROCEDURE WriteChar (X, Y: Sw_Integer; C: Char; Color: Byte;
  425. Count: Sw_Integer);
  426. PROCEDURE DragView (Event: TEvent; Mode: Byte; Var Limits: TRect;
  427. MinSize, MaxSize: TPoint);
  428. PROCEDURE WriteAbs(X, Y, L :Sw_Integer;var Buf);
  429. PROCEDURE WriteShadow(X1, Y1, X2, Y2 : Sw_Integer);
  430. FUNCTION FontWidth: Sw_Integer;
  431. FUNCTION Fontheight: Sw_Integer;
  432. END;
  433. SelectMode = (NormalSelect, EnterSelect, LeaveSelect);
  434. {---------------------------------------------------------------------------}
  435. { TGroup OBJECT - GROUP OBJECT ANCESTOR }
  436. {---------------------------------------------------------------------------}
  437. TGroup = OBJECT (TView)
  438. Phase : (phFocused, phPreProcess, phPostProcess);
  439. EndState: Word; { Modal result }
  440. Current : PView; { Selected subview }
  441. Last : PView; { 1st view inserted }
  442. Buffer : PVideoBuf; { Speed up buffer }
  443. CONSTRUCTOR Init (Var Bounds: TRect);
  444. CONSTRUCTOR Load (Var S: TStream);
  445. DESTRUCTOR Done; Virtual;
  446. FUNCTION First: PView;
  447. FUNCTION Execute: Word; Virtual;
  448. FUNCTION GetHelpCtx: Word; Virtual;
  449. FUNCTION DataSize: Sw_Word; Virtual;
  450. FUNCTION ExecView (P: PView): Word; Virtual;
  451. FUNCTION FirstThat (P: Pointer): PView;
  452. FUNCTION Valid (Command: Word): Boolean; Virtual;
  453. FUNCTION FocusNext (Forwards: Boolean): Boolean;
  454. PROCEDURE Draw; Virtual;
  455. PROCEDURE DrawBackGround; Virtual;
  456. PROCEDURE Lock;
  457. PROCEDURE UnLock;
  458. PROCEDURE Awaken; Virtual;
  459. PROCEDURE ReDraw;
  460. PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer); Virtual;
  461. PROCEDURE SelectDefaultView;
  462. PROCEDURE Insert (P: PView);
  463. PROCEDURE Delete (P: PView);
  464. PROCEDURE ForEach (P: Pointer); Virtual;
  465. PROCEDURE EndModal (Command: Word); Virtual;
  466. PROCEDURE DisplaceBy (Dx, Dy: Sw_Integer); Virtual;
  467. PROCEDURE SelectNext (Forwards: Boolean);
  468. PROCEDURE InsertBefore (P, Target: PView);
  469. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  470. PROCEDURE GetData (Var Rec); Virtual;
  471. PROCEDURE SetData (Var Rec); Virtual;
  472. PROCEDURE Store (Var S: TStream);
  473. PROCEDURE EventError (Var Event: TEvent); Virtual;
  474. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  475. PROCEDURE ChangeBounds (Var Bounds: TRect); Virtual;
  476. PROCEDURE GetSubViewPtr (Var S: TStream; Var P);
  477. PROCEDURE PutSubViewPtr (Var S: TStream; P: PView);
  478. PRIVATE
  479. LockFlag: Byte;
  480. Clip : TRect;
  481. FUNCTION IndexOf (P: PView): Sw_Integer;
  482. FUNCTION FindNext (Forwards: Boolean): PView;
  483. FUNCTION FirstMatch (AState: Word; AOptions: Word): PView;
  484. PROCEDURE ResetCurrent;
  485. PROCEDURE RemoveView (P: PView);
  486. PROCEDURE InsertView (P, Target: PView);
  487. PROCEDURE SetCurrent (P: PView; Mode: SelectMode);
  488. END;
  489. {---------------------------------------------------------------------------}
  490. { TFrame OBJECT - FRAME VIEW OBJECT }
  491. {---------------------------------------------------------------------------}
  492. TYPE
  493. TFrame = OBJECT (TView)
  494. CONSTRUCTOR Init (Var Bounds: TRect);
  495. FUNCTION GetPalette: PPalette; Virtual;
  496. END;
  497. PFrame = ^TFrame;
  498. {---------------------------------------------------------------------------}
  499. { TScrollBar OBJECT - SCROLL BAR OBJECT }
  500. {---------------------------------------------------------------------------}
  501. TYPE
  502. TScrollChars = Array [0..4] of Char;
  503. TScrollBar = OBJECT (TView)
  504. Value : Sw_Integer; { Scrollbar value }
  505. Min : Sw_Integer; { Scrollbar minimum }
  506. Max : Sw_Integer; { Scrollbar maximum }
  507. PgStep: Sw_Integer; { One page step }
  508. ArStep: Sw_Integer; { One range step }
  509. Id : Sw_Integer; { Scrollbar ID }
  510. CONSTRUCTOR Init (Var Bounds: TRect);
  511. CONSTRUCTOR Load (Var S: TStream);
  512. FUNCTION GetPalette: PPalette; Virtual;
  513. FUNCTION ScrollStep (Part: Sw_Integer): Sw_Integer; Virtual;
  514. PROCEDURE Draw; Virtual;
  515. PROCEDURE ScrollDraw; Virtual;
  516. PROCEDURE DrawBackGround; Virtual;
  517. PROCEDURE SetValue (AValue: Sw_Integer);
  518. PROCEDURE SetRange (AMin, AMax: Sw_Integer);
  519. PROCEDURE SetStep (APgStep, AArStep: Sw_Integer);
  520. PROCEDURE SetParams (AValue, AMin, AMax, APgStep, AArStep: Sw_Integer);
  521. PROCEDURE Store (Var S: TStream);
  522. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  523. PRIVATE
  524. Chars: TScrollChars; { Scrollbar chars }
  525. FUNCTION GetPos: Sw_Integer;
  526. FUNCTION GetSize: Sw_Integer;
  527. PROCEDURE DrawPos (Pos: Sw_Integer);
  528. PROCEDURE ClearPos (Pos: Sw_Integer);
  529. END;
  530. PScrollBar = ^TScrollBar;
  531. {---------------------------------------------------------------------------}
  532. { TScroller OBJECT - SCROLLING VIEW ANCESTOR }
  533. {---------------------------------------------------------------------------}
  534. TYPE
  535. TScroller = OBJECT (TView)
  536. Delta : TPoint;
  537. Limit : TPoint;
  538. HScrollBar: PScrollBar; { Horz scroll bar }
  539. VScrollBar: PScrollBar; { Vert scroll bar }
  540. CONSTRUCTOR Init (Var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  541. CONSTRUCTOR Load (Var S: TStream);
  542. FUNCTION GetPalette: PPalette; Virtual;
  543. PROCEDURE ScrollDraw; Virtual;
  544. PROCEDURE SetLimit (X, Y: Sw_Integer);
  545. PROCEDURE ScrollTo (X, Y: Sw_Integer);
  546. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  547. PROCEDURE Store (Var S: TStream);
  548. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  549. PROCEDURE ChangeBounds (Var Bounds: TRect); Virtual;
  550. PRIVATE
  551. DrawFlag: Boolean;
  552. DrawLock: Byte;
  553. PROCEDURE CheckDraw;
  554. END;
  555. PScroller = ^TScroller;
  556. {---------------------------------------------------------------------------}
  557. { TListViewer OBJECT - LIST VIEWER OBJECT }
  558. {---------------------------------------------------------------------------}
  559. TYPE
  560. TListViewer = OBJECT (TView)
  561. NumCols : Sw_Integer; { Number of columns }
  562. TopItem : Sw_Integer; { Top most item }
  563. Focused : Sw_Integer; { Focused item }
  564. Range : Sw_Integer; { Range of listview }
  565. HScrollBar: PScrollBar; { Horz scrollbar }
  566. VScrollBar: PScrollBar; { Vert scrollbar }
  567. CONSTRUCTOR Init (Var Bounds: TRect; ANumCols: Sw_Word; AHScrollBar,
  568. AVScrollBar: PScrollBar);
  569. CONSTRUCTOR Load (Var S: TStream);
  570. FUNCTION GetPalette: PPalette; Virtual;
  571. FUNCTION IsSelected (Item: Sw_Integer): Boolean; Virtual;
  572. FUNCTION GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String; Virtual;
  573. PROCEDURE DrawFocus; Virtual;
  574. PROCEDURE DrawLoseFocus; Virtual;
  575. PROCEDURE DrawBackGround; Virtual;
  576. PROCEDURE FocusItem (Item: Sw_Integer); Virtual;
  577. PROCEDURE SetTopItem (Item: Sw_Integer);
  578. PROCEDURE SetRange (ARange: Sw_Integer);
  579. PROCEDURE SelectItem (Item: Sw_Integer); Virtual;
  580. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  581. PROCEDURE Store (Var S: TStream);
  582. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  583. PROCEDURE ChangeBounds (Var Bounds: TRect); Virtual;
  584. PROCEDURE FocusItemNum (Item: Sw_Integer); Virtual;
  585. END;
  586. PListViewer = ^TListViewer;
  587. {---------------------------------------------------------------------------}
  588. { TWindow OBJECT - WINDOW OBJECT ANCESTOR }
  589. {---------------------------------------------------------------------------}
  590. TYPE
  591. TWindow = OBJECT (TGroup)
  592. Flags : Byte; { Window flags }
  593. Number : Sw_Integer; { Window number }
  594. Palette : Sw_Integer; { Window palette }
  595. ZoomRect: TRect; { Zoom rectangle }
  596. Frame : PFrame; { Frame view object }
  597. Title : PString; { Title string }
  598. CONSTRUCTOR Init (Var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer);
  599. CONSTRUCTOR Load (Var S: TStream);
  600. DESTRUCTOR Done; Virtual;
  601. FUNCTION GetPalette: PPalette; Virtual;
  602. FUNCTION GetTitle (MaxSize: Sw_Integer): TTitleStr; Virtual;
  603. FUNCTION StandardScrollBar (AOptions: Word): PScrollBar;
  604. PROCEDURE Zoom; Virtual;
  605. PROCEDURE Close; Virtual;
  606. PROCEDURE InitFrame; Virtual;
  607. PROCEDURE DrawBorder; Virtual;
  608. PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
  609. PROCEDURE Store (Var S: TStream);
  610. PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
  611. PROCEDURE SizeLimits (Var Min, Max: TPoint); Virtual;
  612. END;
  613. PWindow = ^TWindow;
  614. {***************************************************************************}
  615. { INTERFACE ROUTINES }
  616. {***************************************************************************}
  617. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  618. { WINDOW MESSAGE ROUTINES }
  619. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  620. {-Message------------------------------------------------------------
  621. Message sets up an event record and calls Receiver^.HandleEvent to
  622. handle the event. Message returns nil if Receiver is nil, or if
  623. the event is not handled successfully.
  624. 12Sep97 LdB
  625. ---------------------------------------------------------------------}
  626. FUNCTION Message (Receiver: PView; What, Command: Word;
  627. InfoPtr: Pointer): Pointer;
  628. {-NewMessage---------------------------------------------------------
  629. NewMessage sets up an event record including the new fields and calls
  630. Receiver^.HandleEvent to handle the event. Message returns nil if
  631. Receiver is nil, or if the event is not handled successfully.
  632. 19Sep97 LdB
  633. ---------------------------------------------------------------------}
  634. FUNCTION NewMessage (P: PView; What, Command: Word; Id: Sw_Integer; Data: Real;
  635. InfoPtr: Pointer): Pointer;
  636. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  637. { VIEW OBJECT REGISTRATION ROUTINES }
  638. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  639. {-RegisterViews------------------------------------------------------
  640. This registers all the view type objects used in this unit.
  641. 11Aug99 LdB
  642. ---------------------------------------------------------------------}
  643. PROCEDURE RegisterViews;
  644. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  645. { NEW VIEW ROUTINES }
  646. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  647. {-CreateIdScrollBar--------------------------------------------------
  648. Creates and scrollbar object of the given size and direction and sets
  649. the scrollbar id number.
  650. 22Sep97 LdB
  651. ---------------------------------------------------------------------}
  652. FUNCTION CreateIdScrollBar (X, Y, Size, Id: Sw_Integer; Horz: Boolean): PScrollBar;
  653. {***************************************************************************}
  654. { INITIALIZED PUBLIC VARIABLES }
  655. {***************************************************************************}
  656. {---------------------------------------------------------------------------}
  657. { INITIALIZED DOS/DPMI/WIN/NT/OS2 VARIABLES }
  658. {---------------------------------------------------------------------------}
  659. CONST
  660. UseNativeClasses: Boolean = True; { Native class modes }
  661. CommandSetChanged: Boolean = False; { Command change flag }
  662. ShowMarkers: Boolean = False; { Show marker state }
  663. ErrorAttr: Byte = $CF; { Error colours }
  664. PositionalEvents: Word = evMouse; { Positional defined }
  665. FocusedEvents: Word = evKeyboard + evCommand; { Focus defined }
  666. MinWinSize: TPoint = (X: 16; Y: 6); { Minimum window size }
  667. ShadowSize: TPoint = (X: 2; Y: 1); { Shadow sizes }
  668. ShadowAttr: Byte = $08; { Shadow attribute }
  669. { Characters used for drawing selected and default items in }
  670. { monochrome color sets }
  671. SpecialChars: Array [0..5] Of Char = (#175, #174, #26, #27, ' ', ' ');
  672. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  673. { STREAM REGISTRATION RECORDS }
  674. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  675. {---------------------------------------------------------------------------}
  676. { TView STREAM REGISTRATION }
  677. {---------------------------------------------------------------------------}
  678. CONST
  679. RView: TStreamRec = (
  680. ObjType: 1; { Register id = 1 }
  681. {$IFDEF BP_VMTLink}
  682. VmtLink: Ofs(TypeOf(TView)^); { BP style VMT link }
  683. {$ELSE}
  684. VmtLink: TypeOf(TView); { Alt style VMT link }
  685. {$ENDIF}
  686. Load: @TView.Load; { Object load method }
  687. Store: @TView.Store { Object store method }
  688. );
  689. {---------------------------------------------------------------------------}
  690. { TFrame STREAM REGISTRATION }
  691. {---------------------------------------------------------------------------}
  692. CONST
  693. RFrame: TStreamRec = (
  694. ObjType: 2; { Register id = 2 }
  695. {$IFDEF BP_VMTLink}
  696. VmtLink: Ofs(TypeOf(TFrame)^); { BP style VMT link }
  697. {$ELSE}
  698. VmtLink: TypeOf(TFrame); { Alt style VMT link }
  699. {$ENDIF}
  700. Load: @TFrame.Load; { Frame load method }
  701. Store: @TFrame.Store { Frame store method }
  702. );
  703. {---------------------------------------------------------------------------}
  704. { TScrollBar STREAM REGISTRATION }
  705. {---------------------------------------------------------------------------}
  706. CONST
  707. RScrollBar: TStreamRec = (
  708. ObjType: 3; { Register id = 3 }
  709. {$IFDEF BP_VMTLink}
  710. VmtLink: Ofs(TypeOf(TScrollBar)^); { BP style VMT link }
  711. {$ELSE}
  712. VmtLink: TypeOf(TScrollBar); { Alt style VMT link }
  713. {$ENDIF}
  714. Load: @TScrollBar.Load; { Object load method }
  715. Store: @TScrollBar.Store { Object store method }
  716. );
  717. {---------------------------------------------------------------------------}
  718. { TScroller STREAM REGISTRATION }
  719. {---------------------------------------------------------------------------}
  720. CONST
  721. RScroller: TStreamRec = (
  722. ObjType: 4; { Register id = 4 }
  723. {$IFDEF BP_VMTLink}
  724. VmtLink: Ofs(TypeOf(TScroller)^); { BP style VMT link }
  725. {$ELSE}
  726. VmtLink: TypeOf(TScroller); { Alt style VMT link }
  727. {$ENDIF}
  728. Load: @TScroller.Load; { Object load method }
  729. Store: @TScroller.Store { Object store method }
  730. );
  731. {---------------------------------------------------------------------------}
  732. { TListViewer STREAM REGISTRATION }
  733. {---------------------------------------------------------------------------}
  734. CONST
  735. RListViewer: TStreamRec = (
  736. ObjType: 5; { Register id = 5 }
  737. {$IFDEF BP_VMTLink}
  738. VmtLink: Ofs(TypeOf(TListViewer)^); { BP style VMT link }
  739. {$ELSE}
  740. VmtLink: TypeOf(TListViewer); { Alt style VMT link }
  741. {$ENDIF}
  742. Load: @TListViewer.Load; { Object load method }
  743. Store: @TLIstViewer.Store { Object store method }
  744. );
  745. {---------------------------------------------------------------------------}
  746. { TGroup STREAM REGISTRATION }
  747. {---------------------------------------------------------------------------}
  748. CONST
  749. RGroup: TStreamRec = (
  750. ObjType: 6; { Register id = 6 }
  751. {$IFDEF BP_VMTLink}
  752. VmtLink: Ofs(TypeOf(TGroup)^); { BP style VMT link }
  753. {$ELSE}
  754. VmtLink: TypeOf(TGroup); { Alt style VMT link }
  755. {$ENDIF}
  756. Load: @TGroup.Load; { Object load method }
  757. Store: @TGroup.Store { Object store method }
  758. );
  759. {---------------------------------------------------------------------------}
  760. { TWindow STREAM REGISTRATION }
  761. {---------------------------------------------------------------------------}
  762. CONST
  763. RWindow: TStreamRec = (
  764. ObjType: 7; { Register id = 7 }
  765. {$IFDEF BP_VMTLink}
  766. VmtLink: Ofs(TypeOf(TWindow)^); { BP style VMT link }
  767. {$ELSE}
  768. VmtLink: TypeOf(TWindow); { Alt style VMT link }
  769. {$ENDIF}
  770. Load: @TWindow.Load; { Object load method }
  771. Store: @TWindow.Store { Object store method }
  772. );
  773. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  774. IMPLEMENTATION
  775. {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
  776. {$IFDEF USE_VIDEO_API}
  777. USES
  778. Video;
  779. {$ENDIF USE_VIDEO_API}
  780. {***************************************************************************}
  781. { PRIVATE TYPE DEFINITIONS }
  782. {***************************************************************************}
  783. {---------------------------------------------------------------------------}
  784. { TFixupList DEFINITION }
  785. {---------------------------------------------------------------------------}
  786. TYPE
  787. TFixupList = ARRAY [1..4096] Of Pointer; { Fix up ptr array }
  788. PFixupList = ^TFixupList; { Ptr to fix up list }
  789. {***************************************************************************}
  790. { PRIVATE INITIALIZED VARIABLES }
  791. {***************************************************************************}
  792. {---------------------------------------------------------------------------}
  793. { INITIALIZED DOS/DPMI/WIN/NT/OS2 PRIVATE VARIABLES }
  794. {---------------------------------------------------------------------------}
  795. CONST
  796. TheTopView : PView = Nil; { Top focused view }
  797. LimitsLocked: PView = Nil; { View locking limits }
  798. OwnerGroup : PGroup = Nil; { Used for loading }
  799. FixupList : PFixupList = Nil; { Used for loading }
  800. CurCommandSet: TCommandSet = ([0..255] -
  801. [cmZoom, cmClose, cmResize, cmNext, cmPrev]); { All active but these }
  802. vdInSetCursor = $80; { AVOID RECURSION IN SetCursor }
  803. {***************************************************************************}
  804. { PRIVATE INTERNAL ROUTINES }
  805. {***************************************************************************}
  806. function posidx(const substr,s : string;idx:sw_integer):sw_integer;
  807. var
  808. i,j : sw_integer;
  809. e : boolean;
  810. begin
  811. i:=idx;
  812. j:=0;
  813. e:=(length(SubStr)>0);
  814. while e and (i<=Length(s)-Length(SubStr)) do
  815. begin
  816. if (SubStr[1]=s[i]) and (Substr=Copy(s,i,Length(SubStr))) then
  817. begin
  818. j:=i;
  819. e:=false;
  820. end;
  821. inc(i);
  822. end;
  823. PosIdx:=j;
  824. end;
  825. procedure DrawScreenBuf;
  826. begin
  827. {$ifdef USE_VIDEO_API}
  828. if (GetLockScreenCount=0) then
  829. begin
  830. HideMouse;
  831. if TextModeGFV then
  832. UpdateScreen(false)
  833. else
  834. GraphUpdateScreen(false);
  835. ShowMouse;
  836. end;
  837. {$endif USE_VIDEO_API}
  838. end;
  839. {***************************************************************************}
  840. { OBJECT METHODS }
  841. {***************************************************************************}
  842. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  843. { TView OBJECT METHODS }
  844. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  845. {--TView--------------------------------------------------------------------}
  846. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 20Jun96 LdB }
  847. {---------------------------------------------------------------------------}
  848. CONSTRUCTOR TView.Init (Var Bounds: TRect);
  849. BEGIN
  850. Inherited Init; { Call ancestor }
  851. DragMode := dmLimitLoY; { Default drag mode }
  852. HelpCtx := hcNoContext; { Clear help context }
  853. State := sfVisible; { Default state }
  854. EventMask := evMouseDown + evKeyDown + evCommand; { Default event masks }
  855. GOptions := goTabSelect; { Set new options }
  856. SetBounds(Bounds); { Set view bounds }
  857. END;
  858. {--TView--------------------------------------------------------------------}
  859. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06May98 LdB }
  860. {---------------------------------------------------------------------------}
  861. { This load method will read old original TV data from a stream but the }
  862. { new options and tabmasks are not set so some NEW functionality is not }
  863. { supported but it should work as per original TV code. }
  864. {---------------------------------------------------------------------------}
  865. CONSTRUCTOR TView.Load (Var S: TStream);
  866. BEGIN
  867. Inherited Init; { Call ancestor }
  868. S.Read(Origin.X, 2); { Read origin x value }
  869. S.Read(Origin.Y, 2); { Read origin y value }
  870. S.Read(Size.X, 2); { Read view x size }
  871. S.Read(Size.Y, 2); { Read view y size }
  872. S.Read(Cursor.X, 2); { Read cursor x size }
  873. S.Read(Cursor.Y, 2); { Read cursor y size }
  874. S.Read(GrowMode, 1); { Read growmode flags }
  875. S.Read(DragMode, 1); { Read dragmode flags }
  876. S.Read(HelpCtx, 2); { Read help context }
  877. S.Read(State, 2); { Read state masks }
  878. S.Read(Options, 2); { Read options masks }
  879. S.Read(Eventmask, 2); { Read event masks }
  880. If (Options AND ofGFVModeView <> 0) Then Begin { STREAM HAS GFV TVIEW }
  881. S.Read(GOptions, 2); { Read new option masks }
  882. S.Read(TabMask, 1); { Read new tab masks }
  883. S.Read(RawOrigin.X, 2); { Read raw x origin point }
  884. S.Read(RawOrigin.Y, 2); { Read raw y origin point }
  885. S.Read(RawSize.X, 2); { Read raw x size }
  886. S.Read(RawSize.Y, 2); { Read raw y size }
  887. S.Read(ColourOfs, 2); { Read palette offset }
  888. End Else Begin { STREAM HAS OLD TView }
  889. RawOrigin.X := Origin.X * FontWidth; { Set x origin pt }
  890. RawOrigin.Y := Origin.Y * FontHeight; { Set y origin pt }
  891. RawSize.X := (Size.X * FontWidth) - 1; { Calc raw x size }
  892. RawSize.Y := (Size.Y * FontHeight) - 1; { Calc raw y size }
  893. End;
  894. END;
  895. {--TView--------------------------------------------------------------------}
  896. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Nov99 LdB }
  897. {---------------------------------------------------------------------------}
  898. DESTRUCTOR TView.Done;
  899. VAR P: PComplexArea;
  900. BEGIN
  901. Hide; { Hide the view }
  902. If (Owner <> Nil) Then Owner^.Delete(@Self); { Delete from owner }
  903. While (HoldLimit <> Nil) Do Begin { Free limit memory }
  904. P := HoldLimit^.NextArea; { Hold next pointer }
  905. FreeMem(HoldLimit, SizeOf(TComplexArea)); { Release memory }
  906. HoldLimit := P; { Shuffle to next }
  907. End;
  908. END;
  909. {--TView--------------------------------------------------------------------}
  910. { Prev -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  911. {---------------------------------------------------------------------------}
  912. FUNCTION TView.Prev: PView;
  913. VAR NP : PView;
  914. BEGIN
  915. Prev := @Self;
  916. NP := Next;
  917. While (NP <> Nil) AND (NP <> @Self) Do
  918. Begin
  919. Prev := NP; { Locate next view }
  920. NP := NP^.Next;
  921. End;
  922. END;
  923. {--TView--------------------------------------------------------------------}
  924. { Execute -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  925. {---------------------------------------------------------------------------}
  926. FUNCTION TView.Execute: Word;
  927. BEGIN
  928. Execute := cmCancel; { Return cancel }
  929. END;
  930. {--TView--------------------------------------------------------------------}
  931. { Focus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05May98 LdB }
  932. {---------------------------------------------------------------------------}
  933. FUNCTION TView.Focus: Boolean;
  934. VAR Res: Boolean;
  935. BEGIN
  936. Res := True; { Preset result }
  937. If (State AND (sfSelected + sfModal)=0) Then Begin { Not modal/selected }
  938. If (Owner <> Nil) Then Begin { View has an owner }
  939. Res := Owner^.Focus; { Return focus state }
  940. If Res Then { Owner has focus }
  941. If ((Owner^.Current = Nil) OR { No current view }
  942. (Owner^.Current^.Options AND ofValidate = 0) { Non validating view }
  943. OR (Owner^.Current^.Valid(cmReleasedFocus))) { Okay to drop focus }
  944. Then Select Else Res := False; { Then select us }
  945. End;
  946. End;
  947. Focus := Res; { Return focus result }
  948. END;
  949. {--TView--------------------------------------------------------------------}
  950. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  951. {---------------------------------------------------------------------------}
  952. FUNCTION TView.DataSize: Sw_Word;
  953. BEGIN
  954. DataSize := 0; { Transfer size }
  955. END;
  956. {--TView--------------------------------------------------------------------}
  957. { TopView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  958. {---------------------------------------------------------------------------}
  959. FUNCTION TView.TopView: PView;
  960. VAR P: PView;
  961. BEGIN
  962. If (TheTopView = Nil) Then Begin { Check topmost view }
  963. P := @Self; { Start with us }
  964. While (P <> Nil) AND (P^.State AND sfModal = 0) { Check if modal }
  965. Do P := P^.Owner; { Search each owner }
  966. TopView := P; { Return result }
  967. End Else TopView := TheTopView; { Return topview }
  968. END;
  969. {--TView--------------------------------------------------------------------}
  970. { PrevView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  971. {---------------------------------------------------------------------------}
  972. FUNCTION TView.PrevView: PView;
  973. BEGIN
  974. If (@Self = Owner^.First) Then PrevView := Nil { We are first view }
  975. Else PrevView := Prev; { Return our prior }
  976. END;
  977. {--TView--------------------------------------------------------------------}
  978. { NextView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  979. {---------------------------------------------------------------------------}
  980. FUNCTION TView.NextView: PView;
  981. BEGIN
  982. If (@Self = Owner^.Last) Then NextView := Nil { This is last view }
  983. Else NextView := Next; { Return our next }
  984. END;
  985. {--TView--------------------------------------------------------------------}
  986. { GetHelpCtx -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  987. {---------------------------------------------------------------------------}
  988. FUNCTION TView.GetHelpCtx: Word;
  989. BEGIN
  990. If (State AND sfDragging <> 0) Then { Dragging state check }
  991. GetHelpCtx := hcDragging Else { Return dragging }
  992. GetHelpCtx := HelpCtx; { Return help context }
  993. END;
  994. {--TView--------------------------------------------------------------------}
  995. { EventAvail -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  996. {---------------------------------------------------------------------------}
  997. FUNCTION TView.EventAvail: Boolean;
  998. VAR Event: TEvent;
  999. BEGIN
  1000. GetEvent(Event); { Get next event }
  1001. If (Event.What <> evNothing) Then PutEvent(Event); { Put it back }
  1002. EventAvail := (Event.What <> evNothing); { Return result }
  1003. END;
  1004. {--TView--------------------------------------------------------------------}
  1005. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1006. {---------------------------------------------------------------------------}
  1007. FUNCTION TView.GetPalette: PPalette;
  1008. BEGIN
  1009. GetPalette := Nil; { Return nil ptr }
  1010. END;
  1011. {--TView--------------------------------------------------------------------}
  1012. { GetColor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Jul99 LdB }
  1013. {---------------------------------------------------------------------------}
  1014. FUNCTION TView.GetColor (Color: Word): Word;
  1015. VAR Col: Byte; W: Word; P: PPalette; Q: PView;
  1016. BEGIN
  1017. W := 0; { Clear colour Sw_Word }
  1018. If (Hi(Color) > 0) Then Begin { High colour req }
  1019. Col := Hi(Color) + ColourOfs; { Initial offset }
  1020. Q := @Self; { Pointer to self }
  1021. Repeat
  1022. P := Q^.GetPalette; { Get our palette }
  1023. If (P <> Nil) Then Begin { Palette is valid }
  1024. If (Col <= Length(P^)) Then
  1025. Col := Ord(P^[Col]) Else { Return colour }
  1026. Col := ErrorAttr; { Error attribute }
  1027. End;
  1028. Q := Q^.Owner; { Move up to owner }
  1029. Until (Q = Nil); { Until no owner }
  1030. W := Col SHL 8; { Translate colour }
  1031. End;
  1032. If (Lo(Color) > 0) Then Begin
  1033. Col := Lo(Color) + ColourOfs; { Initial offset }
  1034. Q := @Self; { Pointer to self }
  1035. Repeat
  1036. P := Q^.GetPalette; { Get our palette }
  1037. If (P <> Nil) Then Begin { Palette is valid }
  1038. If (Col <= Length(P^)) Then
  1039. Col := Ord(P^[Col]) Else { Return colour }
  1040. Col := ErrorAttr; { Error attribute }
  1041. End;
  1042. Q := Q^.Owner; { Move up to owner }
  1043. Until (Q = Nil); { Until no owner }
  1044. End Else Col := ErrorAttr; { No colour found }
  1045. GetColor := W OR Col; { Return color }
  1046. END;
  1047. {--TView--------------------------------------------------------------------}
  1048. { Valid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1049. {---------------------------------------------------------------------------}
  1050. FUNCTION TView.Valid (Command: Word): Boolean;
  1051. BEGIN
  1052. Valid := True; { Simply return true }
  1053. END;
  1054. {--TView--------------------------------------------------------------------}
  1055. { GetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1056. {---------------------------------------------------------------------------}
  1057. FUNCTION TView.GetState (AState: Word): Boolean;
  1058. BEGIN
  1059. GetState := State AND AState = AState; { Check states equal }
  1060. END;
  1061. {--TView--------------------------------------------------------------------}
  1062. { TextWidth -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Nov99 LdB }
  1063. {---------------------------------------------------------------------------}
  1064. FUNCTION TView.TextWidth (Txt: String): Sw_Integer;
  1065. VAR I: Sw_Integer; S: String;
  1066. BEGIN
  1067. S := Txt; { Transfer text }
  1068. Repeat
  1069. I := Pos('~', S); { Check for tilde }
  1070. If (I <> 0) Then System.Delete(S, I, 1); { Remove the tilde }
  1071. Until (I = 0); { Remove all tildes }
  1072. TextWidth := Length(S) * SysFontWidth; { Calc text length }
  1073. END;
  1074. {--TView--------------------------------------------------------------------}
  1075. { MouseInView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1076. {---------------------------------------------------------------------------}
  1077. FUNCTION TView.MouseInView (Point: TPoint): Boolean;
  1078. BEGIN
  1079. MouseInView := False; { Preset false }
  1080. If (Point.X < RawOrigin.X) Then Exit; { Point to left }
  1081. If (Point.X > (RawOrigin.X+RawSize.X)) Then Exit; { Point to right }
  1082. If (Point.Y < RawOrigin.Y) Then Exit; { Point is above }
  1083. If (Point.Y > (RawOrigin.Y+RawSize.Y)) Then Exit; { Point is below }
  1084. MouseInView := True; { Return true }
  1085. END;
  1086. {--TView--------------------------------------------------------------------}
  1087. { CommandEnabled -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1088. {---------------------------------------------------------------------------}
  1089. FUNCTION TView.CommandEnabled(Command: Word): Boolean;
  1090. BEGIN
  1091. CommandEnabled := (Command > 255) OR
  1092. (Command IN CurCommandSet); { Check command }
  1093. END;
  1094. {--TView--------------------------------------------------------------------}
  1095. { OverLapsArea -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB }
  1096. {---------------------------------------------------------------------------}
  1097. FUNCTION TView.OverlapsArea (X1, Y1, X2, Y2: Sw_Integer): Boolean;
  1098. BEGIN
  1099. OverLapsArea := False; { Preset false }
  1100. If TextModeGFV then Begin
  1101. If (Origin.X > X2) Then Exit; { Area to the left }
  1102. If ((Origin.X + Size.X) < X1) Then Exit; { Area to the right }
  1103. If (Origin.Y > Y2) Then Exit; { Area is above }
  1104. If ((Origin.Y + Size.Y) < Y1) Then Exit; { Area is below }
  1105. End Else Begin
  1106. If (RawOrigin.X > X2) Then Exit; { Area to the left }
  1107. If ((RawOrigin.X + RawSize.X) < X1) Then Exit; { Area to the right }
  1108. If (RawOrigin.Y > Y2) Then Exit; { Area is above }
  1109. If ((RawOrigin.Y + RawSize.Y) < Y1) Then Exit; { Area is below }
  1110. End;
  1111. OverLapsArea := True; { Return true }
  1112. END;
  1113. {--TView--------------------------------------------------------------------}
  1114. { MouseEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1115. {---------------------------------------------------------------------------}
  1116. FUNCTION TView.MouseEvent (Var Event: TEvent; Mask: Word): Boolean;
  1117. BEGIN
  1118. Repeat
  1119. GetEvent(Event); { Get next event }
  1120. Until (Event.What AND (Mask OR evMouseUp) <> 0); { Wait till valid }
  1121. MouseEvent := Event.What <> evMouseUp; { Return result }
  1122. END;
  1123. {--TView--------------------------------------------------------------------}
  1124. { Hide -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1125. {---------------------------------------------------------------------------}
  1126. PROCEDURE TView.Hide;
  1127. BEGIN
  1128. If (State AND sfVisible <> 0) Then { View is visible }
  1129. SetState(sfVisible, False); { Hide the view }
  1130. END;
  1131. {--TView--------------------------------------------------------------------}
  1132. { Show -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1133. {---------------------------------------------------------------------------}
  1134. PROCEDURE TView.Show;
  1135. BEGIN
  1136. If (State AND sfVisible = 0) Then { View not visible }
  1137. SetState(sfVisible, True); { Show the view }
  1138. END;
  1139. {--TView--------------------------------------------------------------------}
  1140. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB }
  1141. {---------------------------------------------------------------------------}
  1142. PROCEDURE TView.Draw;
  1143. BEGIN { Abstract method }
  1144. END;
  1145. procedure TView.ResetCursor;
  1146. const
  1147. sfV_CV_F:word = sfVisible + sfCursorVis + sfFocused;
  1148. var
  1149. p,p2 : PView;
  1150. G : PGroup;
  1151. cur : TPoint;
  1152. function Check0:boolean;
  1153. var
  1154. res : byte;
  1155. begin
  1156. res:=0;
  1157. while res=0 do
  1158. begin
  1159. p:=p^.next;
  1160. if p=p2 then
  1161. begin
  1162. p:=P^.owner;
  1163. res:=1
  1164. end
  1165. else
  1166. if ((p^.state and sfVisible)<>0) and
  1167. (cur.x>=p^.origin.x) and
  1168. (cur.x<p^.size.x+p^.origin.x) and
  1169. (cur.y>=p^.origin.y) and
  1170. (cur.y<p^.size.y+p^.origin.y) then
  1171. res:=2;
  1172. end;
  1173. Check0:=res=2;
  1174. end;
  1175. begin
  1176. if (not TextModeGFV) and not UseFixedFont then
  1177. exit;
  1178. {$ifdef USE_VIDEO_API}
  1179. if ((state and sfV_CV_F) = sfV_CV_F) then
  1180. begin
  1181. p:=@Self;
  1182. cur:=cursor;
  1183. { in FVISION origin is always relative to screen corner
  1184. for inserted views PM }
  1185. inc(cur.X,p^.origin.X);
  1186. inc(cur.Y,p^.origin.Y);
  1187. while true do
  1188. begin
  1189. if (cur.x<p^.origin.x) or (cur.x>=p^.origin.x+p^.size.x) or
  1190. (cur.y<p^.origin.y) or (cur.y>=p^.origin.y+p^.size.y) then
  1191. break;
  1192. p2:=p;
  1193. G:=p^.owner;
  1194. if G=Nil then { top view }
  1195. begin
  1196. Video.SetCursorPos(cur.x,cur.y);
  1197. if (state and sfCursorIns)<>0 then
  1198. Video.SetCursorType(crBlock)
  1199. else
  1200. Video.SetCursorType(crUnderline);
  1201. exit;
  1202. end;
  1203. if (G^.state and sfVisible)=0 then
  1204. break;
  1205. p:=G^.Last;
  1206. if Check0 then
  1207. break;
  1208. end; { while }
  1209. end; { if }
  1210. Video.SetCursorType(crHidden);
  1211. {$endif USE_VIDEO_API}
  1212. end;
  1213. {--TView--------------------------------------------------------------------}
  1214. { Select -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05May98 LdB }
  1215. {---------------------------------------------------------------------------}
  1216. PROCEDURE TView.Select;
  1217. BEGIN
  1218. If (Options AND ofSelectable <> 0) Then { View is selectable }
  1219. If (Options AND ofTopSelect <> 0) Then MakeFirst { Top selectable }
  1220. Else If (Owner <> Nil) Then { Valid owner }
  1221. Owner^.SetCurrent(@Self, NormalSelect); { Make owners current }
  1222. END;
  1223. {--TView--------------------------------------------------------------------}
  1224. { Awaken -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  1225. {---------------------------------------------------------------------------}
  1226. PROCEDURE TView.Awaken;
  1227. BEGIN { Abstract method }
  1228. END;
  1229. {--TView--------------------------------------------------------------------}
  1230. { DrawView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06May98 LdB }
  1231. {---------------------------------------------------------------------------}
  1232. PROCEDURE TView.DrawView;
  1233. VAR ViewPort: ViewPortType; { Common variables }
  1234. Parent : PGroup;
  1235. BEGIN
  1236. If (State AND sfVisible <> 0) AND { View is visible }
  1237. (State AND sfExposed <> 0) AND { View is exposed }
  1238. (State AND sfIconised = 0) Then Begin { View not iconised }
  1239. SetViewLimits; { Set view limits }
  1240. GetViewSettings(ViewPort, TextModeGFV); { Get set viewport }
  1241. If OverlapsArea(ViewPort.X1, ViewPort.Y1,
  1242. ViewPort.X2, ViewPort.Y2) Then
  1243. Begin { Must be in area }
  1244. Parent:=Owner;
  1245. While Assigned(Parent) do Begin
  1246. If (Parent^.LockFlag>0) then
  1247. Begin
  1248. If (DrawMask = 0) OR (DrawMask = vdNoChild) then
  1249. SetDrawMask(vdAll);
  1250. exit;
  1251. End;
  1252. Parent:=Parent^.Owner;
  1253. End;
  1254. {$ifdef USE_VIDEO_API}
  1255. LockScreenUpdate; { don't update the screen yet }
  1256. {$endif USE_VIDEO_API}
  1257. HideMouseCursor; { Hide mouse cursor }
  1258. If (DrawMask = 0) OR (DrawMask = vdNoChild) { No special masks set }
  1259. { OR Assigned(LimitsLocked) }
  1260. Then Begin { Treat as a full redraw }
  1261. DrawBackGround; { Draw background }
  1262. Draw; { Draw interior }
  1263. If (GOptions AND goDrawFocus <> 0) Then
  1264. DrawFocus; { Draw focus }
  1265. If (State AND sfCursorVis <> 0) Then
  1266. DrawCursor; { Draw any cursor }
  1267. If (Options AND ofFramed <> 0) OR
  1268. (GOptions AND goThickFramed <> 0) { View has border }
  1269. Then DrawBorder; { Draw border }
  1270. {$ifndef NoShadow}
  1271. If ((State AND sfShadow) <> 0) AND
  1272. (GOptions And goNoShadow = 0) Then
  1273. DrawShadow;
  1274. {$endif ndef NoShadow}
  1275. End Else Begin { Masked draws only }
  1276. If (DrawMask AND vdBackGnd <> 0) Then { Chk background mask }
  1277. Begin
  1278. DrawMask := DrawMask and Not vdBackGnd;
  1279. DrawBackGround; { Draw background }
  1280. end;
  1281. If (DrawMask AND vdInner <> 0) Then { Check Inner mask }
  1282. Begin
  1283. DrawMask := DrawMask and Not vdInner;
  1284. Draw; { Draw interior }
  1285. End;
  1286. If (DrawMask AND vdFocus <> 0)
  1287. AND (GOptions AND goDrawFocus <> 0) then
  1288. Begin
  1289. DrawMask := DrawMask and Not vdFocus;
  1290. DrawFocus; { Check focus mask }
  1291. End;
  1292. if not TextModeGFV then
  1293. begin
  1294. If (DrawMask AND vdCursor <> 0) Then { Check cursor mask }
  1295. Begin
  1296. DrawMask := DrawMask and Not vdCursor;
  1297. DrawCursor; { Draw any cursor }
  1298. End;
  1299. end;
  1300. If (DrawMask AND vdBorder <> 0) Then { Check border mask }
  1301. Begin
  1302. DrawMask := DrawMask and Not vdBorder;
  1303. DrawBorder; { Draw border }
  1304. End;
  1305. {$ifndef NoShadow}
  1306. If ((State AND sfShadow) <> 0) AND
  1307. (DrawMask AND vdShadow <> 0) AND
  1308. (GOptions And goNoShadow = 0) AND
  1309. (not assigned(Owner) OR (Owner^.GOptions And goNoShadow = 0)) Then
  1310. Begin
  1311. DrawMask := DrawMask and Not vdShadow;
  1312. DrawShadow;
  1313. End;
  1314. {$endif ndef NoShadow}
  1315. End;
  1316. ShowMouseCursor; { Show mouse cursor }
  1317. {$ifdef USE_VIDEO_API}
  1318. UnlockScreenUpdate;
  1319. {$endif USE_VIDEO_API}
  1320. if TextModeGFV or UseFixedFont then
  1321. begin
  1322. DrawScreenBuf;
  1323. If (DrawMask AND vdCursor <> 0) Then { Check cursor mask }
  1324. Begin
  1325. DrawMask := DrawMask and Not vdCursor;
  1326. DrawCursor; { Draw any cursor }
  1327. End;
  1328. end;
  1329. End;
  1330. ReleaseViewLimits; { Release the limits }
  1331. End;
  1332. DrawMask := 0; { Clear the draw mask }
  1333. END;
  1334. {--TView--------------------------------------------------------------------}
  1335. { MakeFirst -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Sep99 LdB }
  1336. {---------------------------------------------------------------------------}
  1337. PROCEDURE TView.MakeFirst;
  1338. BEGIN
  1339. If (Owner <> Nil) Then Begin { Must have owner }
  1340. PutInFrontOf(Owner^.First); { Float to the top }
  1341. End;
  1342. END;
  1343. {--TView--------------------------------------------------------------------}
  1344. { DrawFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB }
  1345. {---------------------------------------------------------------------------}
  1346. PROCEDURE TView.DrawFocus;
  1347. BEGIN { Abstract method }
  1348. END;
  1349. {--TView--------------------------------------------------------------------}
  1350. { DrawCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB }
  1351. {---------------------------------------------------------------------------}
  1352. PROCEDURE TView.DrawCursor;
  1353. BEGIN { Abstract method }
  1354. if State and sfFocused <> 0 then
  1355. ResetCursor;
  1356. END;
  1357. {--TView--------------------------------------------------------------------}
  1358. { DrawBorder -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17May98 LdB }
  1359. {---------------------------------------------------------------------------}
  1360. PROCEDURE TView.DrawBorder;
  1361. BEGIN
  1362. If (TextModeGFV = FALSE) Then Begin { GRAPHICS GFV MODE }
  1363. BiColorRectangle(0, 0, RawSize.X, RawSize.Y,
  1364. White, DarkGray, False); { Draw 3d effect }
  1365. If (GOptions AND goThickFramed <> 0) Then Begin { Thick frame at work }
  1366. GraphRectangle(1, 1, RawSize.X-1, RawSize.Y-1,
  1367. LightGray); { Draw frame part 1 }
  1368. GraphRectangle(2, 2, RawSize.X-2, RawSize.Y-2,
  1369. LightGray); { Fraw frame part 2 }
  1370. BiColorRectangle(3, 3, RawSize.X-3, RawSize.Y-3,
  1371. White, DarkGray, True); { Draw highlights }
  1372. End;
  1373. End;
  1374. { TView DrawBorder is empty for TextModeGFV }
  1375. END;
  1376. PROCEDURE TView.DrawShadow;
  1377. VAR X1, Y1, X2, Y2 : Sw_Integer;
  1378. BEGIN
  1379. {$ifdef DEBUG}
  1380. if WriteDebugInfo then
  1381. Begin
  1382. Writeln(stderr,'TView(',hexstr(longint(@self),8),')');
  1383. Writeln(stderr,'Object Type(',hexstr(plongint(@self)^,8),')');
  1384. Writeln(stderr,'DrawShadow');
  1385. End;
  1386. {$endif DEBUG}
  1387. If not TextModeGFV then
  1388. exit;
  1389. If Assigned(Owner) Then Begin
  1390. X1:=RawOrigin.X+RawSize.X+1;
  1391. X2:=X1+ShadowSize.X*SysFontWidth;
  1392. Y1:=RawOrigin.Y+SysFontHeight;
  1393. Y2:=RawOrigin.Y+RawSize.Y+1+ShadowSize.Y*SysFontHeight;
  1394. GOptions := GOptions OR goNoShadow;
  1395. Owner^.GOptions := Owner^.GOptions OR goNoShadow;
  1396. Owner^.RedrawArea(X1,Y1,X2,Y2);
  1397. WriteShadow(X1 div SysFontWidth, Y1 div SysFontHeight,
  1398. X2 div SysFontWidth, Y2 div SysFontHeight);
  1399. X1:=RawOrigin.X+SysFontWidth;
  1400. X2:=RawOrigin.X+RawSize.X+1;
  1401. Y1:=RawOrigin.Y+RawSize.Y+1;
  1402. Y2:=RawOrigin.Y+RawSize.Y+1+ShadowSize.Y*SysFontHeight;
  1403. Owner^.RedrawArea(X1,Y1,X2,Y2);
  1404. WriteShadow(X1 div SysFontWidth, Y1 div SysFontHeight,
  1405. X2 div SysFontWidth, Y2 div SysFontHeight);
  1406. GOptions := GOptions AND not goNoShadow;
  1407. Owner^.GOptions := Owner^.GOptions AND not goNoShadow;
  1408. End;
  1409. END;
  1410. {--TView--------------------------------------------------------------------}
  1411. { HideCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  1412. {---------------------------------------------------------------------------}
  1413. PROCEDURE TView.HideCursor;
  1414. BEGIN
  1415. SetState(sfCursorVis , False); { Hide the cursor }
  1416. END;
  1417. {--TView--------------------------------------------------------------------}
  1418. { ShowCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  1419. {---------------------------------------------------------------------------}
  1420. PROCEDURE TView.ShowCursor;
  1421. BEGIN
  1422. SetState(sfCursorVis , True); { Show the cursor }
  1423. END;
  1424. {--TView--------------------------------------------------------------------}
  1425. { BlockCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  1426. {---------------------------------------------------------------------------}
  1427. PROCEDURE TView.BlockCursor;
  1428. BEGIN
  1429. SetState(sfCursorIns, True); { Set insert mode }
  1430. END;
  1431. {--TView--------------------------------------------------------------------}
  1432. { NormalCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  1433. {---------------------------------------------------------------------------}
  1434. PROCEDURE TView.NormalCursor;
  1435. BEGIN
  1436. SetState(sfCursorIns, False); { Clear insert mode }
  1437. END;
  1438. {--TView--------------------------------------------------------------------}
  1439. { FocusFromTop -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 11Aug99 LdB }
  1440. {---------------------------------------------------------------------------}
  1441. PROCEDURE TView.FocusFromTop;
  1442. BEGIN
  1443. If (Owner <> Nil) AND
  1444. (Owner^.State AND sfSelected = 0)
  1445. Then Owner^.Select;
  1446. If (State AND sfFocused = 0) Then Focus;
  1447. If (State AND sfSelected = 0) Then Select;
  1448. END;
  1449. {--TView--------------------------------------------------------------------}
  1450. { SetViewLimits -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Sep99 LdB }
  1451. {---------------------------------------------------------------------------}
  1452. PROCEDURE TView.SetViewLimits;
  1453. VAR X1, Y1, X2, Y2: Sw_Integer; P: PGroup; ViewPort: ViewPortType; Ca: PComplexArea;
  1454. BEGIN
  1455. {$ifndef PPC_FPC}
  1456. If (MaxAvail >= SizeOf(TComplexArea)) Then
  1457. {$endif}
  1458. Begin { Check enough memory }
  1459. GetMem(Ca, SizeOf(TComplexArea)); { Allocate memory }
  1460. GetViewSettings(ViewPort, TextModeGFV or UseFixedFont); { Fetch view port }
  1461. Ca^.X1 := ViewPort.X1; { Hold current X1 }
  1462. Ca^.Y1 := ViewPort.Y1; { Hold current Y1 }
  1463. Ca^.X2 := ViewPort.X2; { Hold current X2 }
  1464. Ca^.Y2 := ViewPort.Y2; { Hold current Y2 }
  1465. Ca^.NextArea := HoldLimit; { Pointer to next }
  1466. HoldLimit := Ca; { Move down chain }
  1467. X1 := RawOrigin.X; { Xfer x raw origin }
  1468. Y1 := RawOrigin.Y; { Xfer y raw origin }
  1469. X2 := X1 + RawSize.X; { Calc right value }
  1470. Y2 := Y1 + RawSize.Y; { Calc lower value }
  1471. P := Owner; { Start on owner }
  1472. While (P <> Nil) Do Begin { While owner valid }
  1473. If (X1 < P^.RawOrigin.X) Then
  1474. X1 := P^.RawOrigin.X; { X minimum contain }
  1475. If (Y1 < P^.RawOrigin.Y) Then
  1476. Y1 := P^.RawOrigin.Y; { Y minimum contain }
  1477. If (X2 > P^.RawOrigin.X + P^.RawSize.X)
  1478. Then X2 := P^.RawOrigin.X + P^.RawSize.X; { X maximum contain }
  1479. If (Y2 > P^.RawOrigin.Y + P^.RawSize.Y)
  1480. Then Y2 := P^.RawOrigin.Y + P^.RawSize.Y; { Y maximum contain }
  1481. P := P^.Owner; { Move to owners owner }
  1482. End;
  1483. If TextModeGFV or UseFixedFont then Begin
  1484. X1 := X1 div SysFontWidth;
  1485. X2 := (X2 +SysFontWidth - 1) div SysFontWidth;
  1486. Y1 := Y1 div SysFontHeight;
  1487. Y2 := (Y2 +SysFontHeight -1) div SysFontHeight;
  1488. End;
  1489. If (LimitsLocked <> Nil) Then Begin { Locked = area redraw }
  1490. If (X2 < ViewPort.X1) Then Exit; { View left of locked }
  1491. If (X1 > ViewPort.X2) Then Exit; { View right of locked }
  1492. If (Y2 < ViewPort.Y1) Then Exit; { View above locked }
  1493. If (Y1 > ViewPort.Y2) Then Exit; { View below locked }
  1494. If (X1 < ViewPort.X1) Then X1 := ViewPort.X1; { Adjust x1 to locked }
  1495. If (Y1 < ViewPort.Y1) Then Y1 := ViewPort.Y1; { Adjust y1 to locked }
  1496. If (X2 > ViewPort.X2) Then X2 := ViewPort.X2; { Adjust x2 to locked }
  1497. If (Y2 > ViewPort.Y2) Then Y2 := ViewPort.Y2; { Adjust y2 to locked }
  1498. End;
  1499. SetViewPort(X1, Y1, X2, Y2, ClipOn, TextModeGFV or UseFixedFont);{ Set new clip limits }
  1500. End;
  1501. END;
  1502. {--TView--------------------------------------------------------------------}
  1503. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 21Sep99 LdB }
  1504. {---------------------------------------------------------------------------}
  1505. PROCEDURE TView.DrawBackGround;
  1506. VAR Bc: Byte; X1, Y1, X2, Y2: Sw_Integer; ViewPort: ViewPortType;
  1507. X, Y: Sw_Integer;
  1508. Buf : TDrawBuffer;
  1509. BEGIN
  1510. If (GOptions AND goNoDrawView = 0) Then Begin { Non draw views exit }
  1511. If (State AND sfDisabled = 0) Then
  1512. Bc := GetColor(1) AND $F0 SHR 4 Else { Select back colour }
  1513. Bc := GetColor(4) AND $F0 SHR 4; { Disabled back colour }
  1514. GetViewSettings(ViewPort, TextModeGFV); { Get view settings }
  1515. If not TextModeGFV and not UseFixedFont Then Begin { GRAPHICS MODE GFV }
  1516. If (ViewPort.X1 <= RawOrigin.X) Then X1 := 0 { Right to left edge }
  1517. Else X1 := ViewPort.X1-RawOrigin.X; { Offset from left }
  1518. If (ViewPort.Y1 <= RawOrigin.Y) Then Y1 := 0 { Right to top edge }
  1519. Else Y1 := ViewPort.Y1-RawOrigin.Y; { Offset from top }
  1520. If (ViewPort.X2 >= RawOrigin.X+RawSize.X) Then
  1521. X2 := RawSize.X Else { Right to right edge }
  1522. X2 := ViewPort.X2-RawOrigin.X; { Offset from right }
  1523. If (ViewPort.Y2 >= RawOrigin.Y+RawSize.Y) Then
  1524. Y2 := RawSize.Y Else { Right to bottom edge }
  1525. Y2 := ViewPort.Y2-RawOrigin.Y; { Offset from bottom }
  1526. SetFillStyle(SolidFill, Bc); { Set fill colour }
  1527. Bar(0, 0, X2-X1, Y2-Y1); { Clear the area }
  1528. End Else Begin { TEXT MODE GFV }
  1529. If (ViewPort.X1 <= Origin.X) Then
  1530. X1 := Origin.X { Right to left edge }
  1531. Else X1 := ViewPort.X1; { Offset from left }
  1532. If (ViewPort.Y1 <= Origin.Y) Then
  1533. Y1 := Origin.Y { Right to top edge }
  1534. Else Y1 := ViewPort.Y1; { Offset from top }
  1535. If (ViewPort.X2 >= Origin.X+Size.X) Then
  1536. X2 := Origin.X + Size.X Else { Right to right edge }
  1537. X2 := ViewPort.X2; { Offset from right }
  1538. If (ViewPort.Y2 >= Origin.Y+Size.Y) Then
  1539. Y2 := Origin.Y + Size.Y Else { Right to bottom edge }
  1540. Y2 := ViewPort.Y2; { Offset from bottom }
  1541. If (State AND sfDisabled = 0) Then
  1542. Bc := GetColor(1) Else { Select back colour }
  1543. Bc := GetColor(4); { Disabled back colour }
  1544. For X := X1 To X2 Do Begin
  1545. Buf[X-X1]:=(Bc shl 8) or $20;
  1546. End;
  1547. For Y := Y1 To Y2 Do Begin
  1548. WriteAbs(X1,Y, X2-X1, Buf);
  1549. End;
  1550. DrawScreenBuf;
  1551. End;
  1552. End;
  1553. END;
  1554. {--TView--------------------------------------------------------------------}
  1555. { ReleaseViewLimits -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05May98 LdB }
  1556. {---------------------------------------------------------------------------}
  1557. PROCEDURE TView.ReleaseViewLimits;
  1558. VAR P: PComplexArea;
  1559. BEGIN
  1560. P := HoldLimit; { Transfer pointer }
  1561. If (P <> Nil) Then Begin { Valid complex area }
  1562. HoldLimit := P^.NextArea; { Move to prior area }
  1563. SetViewPort(P^.X1, P^.Y1, P^.X2, P^.Y2, ClipOn,
  1564. TextModeGFV or UseFixedFont); { Restore clip limits }
  1565. FreeMem(P, SizeOf(TComplexArea)); { Release memory }
  1566. End;
  1567. END;
  1568. {--TView--------------------------------------------------------------------}
  1569. { MoveTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1570. {---------------------------------------------------------------------------}
  1571. PROCEDURE TView.MoveTo (X, Y: Sw_Integer);
  1572. VAR R: TRect;
  1573. BEGIN
  1574. R.Assign(X, Y, X + Size.X, Y + Size.Y); { Assign area }
  1575. Locate(R); { Locate the view }
  1576. END;
  1577. {--TView--------------------------------------------------------------------}
  1578. { GrowTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1579. {---------------------------------------------------------------------------}
  1580. PROCEDURE TView.GrowTo (X, Y: Sw_Integer);
  1581. VAR R: TRect;
  1582. BEGIN
  1583. R.Assign(Origin.X, Origin.Y, Origin.X + X,
  1584. Origin.Y + Y); { Assign area }
  1585. Locate(R); { Locate the view }
  1586. END;
  1587. {--TView--------------------------------------------------------------------}
  1588. { SetDrawMask -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05Sep99 LdB }
  1589. {---------------------------------------------------------------------------}
  1590. PROCEDURE TView.SetDrawMask (Mask: Byte);
  1591. VAR
  1592. OldMask : byte;
  1593. BEGIN
  1594. If (Options AND ofFramed = 0) AND { Check for no frame }
  1595. (GOptions AND goThickFramed = 0) AND { Check no thick frame }
  1596. (GOptions AND goTitled = 0) Then { Check for title }
  1597. Mask := Mask AND NOT vdBorder; { Clear border draw }
  1598. If (State AND sfCursorVis = 0) Then { Check for no cursor }
  1599. Mask := Mask AND NOT vdCursor; { Clear cursor draw }
  1600. If (GOptions AND goDrawFocus = 0) Then { Check no focus draw }
  1601. Mask := Mask AND NOT vdFocus; { Clear focus draws }
  1602. OldMask:=DrawMask;
  1603. DrawMask := DrawMask OR Mask; { Set draw masks }
  1604. END;
  1605. {--TView--------------------------------------------------------------------}
  1606. { EndModal -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1607. {---------------------------------------------------------------------------}
  1608. PROCEDURE TView.EndModal (Command: Word);
  1609. VAR P: PView;
  1610. BEGIN
  1611. P := TopView; { Get top view }
  1612. If (P <> Nil) Then P^.EndModal(Command); { End modal operation }
  1613. END;
  1614. {--TView--------------------------------------------------------------------}
  1615. { SetCursor -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  1616. {---------------------------------------------------------------------------}
  1617. PROCEDURE TView.SetCursor (X, Y: Sw_Integer);
  1618. BEGIN
  1619. Cursor.X := X; { New x position }
  1620. Cursor.Y := Y; { New y position }
  1621. If ((DrawMask and vdInSetCursor)=0) and (State AND sfCursorVis <> 0) Then
  1622. Begin { Cursor visible }
  1623. if TextModeGFV then
  1624. ResetCursor
  1625. else
  1626. begin
  1627. SetDrawMask(vdCursor or vdInSetCursor); { Set draw mask }
  1628. DrawView; { Draw the cursor }
  1629. DrawMask:=DrawMask and not vdInSetCursor;
  1630. end;
  1631. End;
  1632. END;
  1633. {--TView--------------------------------------------------------------------}
  1634. { PutInFrontOf -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Sep99 LdB }
  1635. {---------------------------------------------------------------------------}
  1636. PROCEDURE TView.PutInFrontOf (Target: PView);
  1637. VAR P, LastView: PView;
  1638. BEGIN
  1639. If (Owner <> Nil) AND (Target <> @Self) AND
  1640. (Target <> NextView) AND ((Target = Nil) OR
  1641. (Target^.Owner = Owner)) Then { Check validity }
  1642. If (State AND sfVisible = 0) Then Begin { View not visible }
  1643. Owner^.RemoveView(@Self); { Remove from list }
  1644. Owner^.InsertView(@Self, Target); { Insert into list }
  1645. End Else Begin
  1646. LastView := NextView; { Hold next view }
  1647. If (LastView <> Nil) Then Begin { Lastview is valid }
  1648. P := Target; { P is target }
  1649. While (P <> Nil) AND (P <> LastView)
  1650. Do P := P^.NextView; { Find our next view }
  1651. If (P = Nil) Then LastView := Target; { Lastview is target }
  1652. End;
  1653. State := State AND NOT sfVisible; { Temp stop drawing }
  1654. If (LastView = Target) Then
  1655. If (Owner <> Nil) Then Owner^.ReDrawArea(
  1656. RawOrigin.X, RawOrigin.Y, RawOrigin.X + RawSize.X,
  1657. RawOrigin.Y + RawSize.Y); { Redraw old area }
  1658. Owner^.Lock;
  1659. Owner^.RemoveView(@Self); { Remove from list }
  1660. Owner^.InsertView(@Self, Target); { Insert into list }
  1661. State := State OR sfVisible; { Allow drawing again }
  1662. If (LastView <> Target) Then
  1663. Begin
  1664. SetDrawMask(vdAll);
  1665. DrawView; { Draw the view now }
  1666. End;
  1667. If (Options AND ofSelectable <> 0) Then { View is selectable }
  1668. If (Owner <> Nil) Then Owner^.ResetCurrent; { Reset current }
  1669. Owner^.Unlock;
  1670. End;
  1671. END;
  1672. { ******************************* REMARK ****************************** }
  1673. { The original TV origin data is only adjusted incase the user uses }
  1674. { the values directly. New views should rely only on RawOrigin values. }
  1675. { ****************************** END REMARK *** Leon de Boer, 15May98 * }
  1676. {--TView--------------------------------------------------------------------}
  1677. { DisplaceBy -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15May98 LdB }
  1678. {---------------------------------------------------------------------------}
  1679. PROCEDURE TView.DisplaceBy (Dx, Dy: Sw_Integer);
  1680. BEGIN
  1681. RawOrigin.X := RawOrigin.X + Dx; { Displace raw x }
  1682. RawOrigin.Y := RawOrigin.Y + Dy; { Displace raw y }
  1683. Origin.X := RawOrigin.X DIV FontWidth; { Calc new x origin }
  1684. Origin.Y := RawOrigin.Y DIV FontHeight; { Calc new y origin }
  1685. END;
  1686. {--TView--------------------------------------------------------------------}
  1687. { SetCommands -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1688. {---------------------------------------------------------------------------}
  1689. PROCEDURE TView.SetCommands (Commands: TCommandSet);
  1690. BEGIN
  1691. CommandSetChanged := CommandSetChanged OR
  1692. (CurCommandSet <> Commands); { Set change flag }
  1693. CurCommandSet := Commands; { Set command set }
  1694. END;
  1695. {--TView--------------------------------------------------------------------}
  1696. { ReDrawArea -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05May98 LdB }
  1697. {---------------------------------------------------------------------------}
  1698. PROCEDURE TView.ReDrawArea (X1, Y1, X2, Y2: Sw_Integer);
  1699. var
  1700. StoreDrawMask : Byte;
  1701. VAR HLimit: PView; ViewPort: ViewPortType;
  1702. BEGIN
  1703. {$ifdef DEBUG}
  1704. if WriteDebugInfo then
  1705. Begin
  1706. Writeln(stderr,'TView(',hexstr(longint(@self),8),')');
  1707. Writeln(stderr,'Object Type(',hexstr(plongint(@self)^,8),')');
  1708. Writeln(stderr,'ReDrawArea(',X1,',',Y1,',',X2,',',Y2,')');
  1709. End;
  1710. {$endif DEBUG}
  1711. GetViewSettings(ViewPort, TextModeGFV); { Hold view port }
  1712. If TextModeGFV then Begin
  1713. X1 := X1 div SysFontWidth;
  1714. X2 := (X2 +SysFontWidth - 1) div SysFontWidth;
  1715. Y1 := Y1 div SysFontHeight;
  1716. Y2 := (Y2 +SysFontHeight -1) div SysFontHeight;
  1717. End;
  1718. SetViewPort(X1, Y1, X2, Y2, ClipOn, TextModeGFV); { Set new clip limits }
  1719. HLimit := LimitsLocked; { Hold lock limits }
  1720. LimitsLocked := @Self; { We are the lock view }
  1721. StoreDrawMask:=DrawMask;
  1722. DrawMask:=vdAll;
  1723. DrawView; { Redraw the area }
  1724. DrawMask:=StoreDrawMask;
  1725. LimitsLocked := HLimit; { Release our lock }
  1726. SetViewPort(ViewPort.X1, ViewPort.Y1,
  1727. ViewPort.X2, ViewPort.Y2, ClipOn, TextModeGFV); { Reset old limits }
  1728. END;
  1729. {--TView--------------------------------------------------------------------}
  1730. { EnableCommands -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1731. {---------------------------------------------------------------------------}
  1732. PROCEDURE TView.EnableCommands (Commands: TCommandSet);
  1733. BEGIN
  1734. CommandSetChanged := CommandSetChanged OR
  1735. (CurCommandSet * Commands <> Commands); { Set changed flag }
  1736. CurCommandSet := CurCommandSet + Commands; { Update command set }
  1737. END;
  1738. {--TView--------------------------------------------------------------------}
  1739. { DisableCommands -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1740. {---------------------------------------------------------------------------}
  1741. PROCEDURE TView.DisableCommands (Commands: TCommandSet);
  1742. BEGIN
  1743. CommandSetChanged := CommandSetChanged OR
  1744. (CurCommandSet * Commands <> []); { Set changed flag }
  1745. CurCommandSet := CurCommandSet - Commands; { Update command set }
  1746. END;
  1747. {--TView--------------------------------------------------------------------}
  1748. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23Sep99 LdB }
  1749. {---------------------------------------------------------------------------}
  1750. PROCEDURE TView.SetState (AState: Word; Enable: Boolean);
  1751. VAR OldState, Command: Word;
  1752. ShouldDraw : Boolean;
  1753. BEGIN
  1754. OldState := State;
  1755. If Enable Then State := State OR AState { Set state mask }
  1756. Else State := State AND NOT AState; { Clear state mask }
  1757. ShouldDraw:=false;
  1758. If (AState AND sfVisible <> 0) Then Begin { Visibilty change }
  1759. If (Owner <> Nil) AND { valid owner }
  1760. (Owner^.State AND sfExposed <> 0) { If owner exposed }
  1761. Then SetState(sfExposed, Enable); { Expose this view }
  1762. If Enable Then DrawView Else { Draw the view }
  1763. If (Owner <> Nil) Then Owner^.ReDrawArea( { Owner valid }
  1764. RawOrigin.X, RawOrigin.Y,
  1765. RawOrigin.X + RawSize.X + ShadowSize.X*SysFontWidth,
  1766. RawOrigin.Y + RawSize.Y + ShadowSize.Y*SysFontHeight); { Owner redraws area }
  1767. If (Options AND ofSelectable <> 0) Then { View is selectable }
  1768. If (Owner <> Nil) Then Owner^.ResetCurrent; { Reset selected }
  1769. End;
  1770. If (AState AND sfFocused <> 0) Then Begin { Focus change }
  1771. If (Owner <> Nil) Then Begin { Owner valid }
  1772. If Enable Then Command := cmReceivedFocus { View gaining focus }
  1773. Else Command := cmReleasedFocus; { View losing focus }
  1774. Message(Owner, evBroadcast, Command, @Self); { Send out message }
  1775. SetDrawMask(vdBorder); { Set border draw mask }
  1776. ShouldDraw:=true;
  1777. End;
  1778. If (GOptions AND goDrawFocus <> 0) AND
  1779. (((AState XOR OldState) AND sfFocused) <> 0) Then Begin { Draw focus view }
  1780. SetDrawMask(vdFocus); { Set focus draw mask }
  1781. ShouldDraw:=true;
  1782. End;
  1783. End;
  1784. If (AState AND (sfCursorVis + sfCursorIns) <> 0) and { Change cursor state }
  1785. (OldState<>State)
  1786. Then Begin
  1787. if TextModeGFV then
  1788. ResetCursor
  1789. else
  1790. begin
  1791. SetDrawMask(vdCursor); { Set cursor draw mask }
  1792. ShouldDraw:=true;
  1793. end;
  1794. End;
  1795. If ShouldDraw then
  1796. begin
  1797. DrawView; { Redraw the border }
  1798. end;
  1799. END;
  1800. {--TView--------------------------------------------------------------------}
  1801. { SetCmdState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1802. {---------------------------------------------------------------------------}
  1803. PROCEDURE TView.SetCmdState (Commands: TCommandSet; Enable: Boolean);
  1804. BEGIN
  1805. If Enable Then EnableCommands(Commands) { Enable commands }
  1806. Else DisableCommands(Commands); { Disable commands }
  1807. END;
  1808. {--TView--------------------------------------------------------------------}
  1809. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1810. {---------------------------------------------------------------------------}
  1811. PROCEDURE TView.GetData (Var Rec);
  1812. BEGIN { Abstract method }
  1813. END;
  1814. {--TView--------------------------------------------------------------------}
  1815. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1816. {---------------------------------------------------------------------------}
  1817. PROCEDURE TView.SetData (Var Rec);
  1818. BEGIN { Abstract method }
  1819. END;
  1820. {--TView--------------------------------------------------------------------}
  1821. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06May98 LdB }
  1822. {---------------------------------------------------------------------------}
  1823. { You can save data to the stream compatable with the old original TV by }
  1824. { temporarily turning off the ofGFVModeView making the call to this store }
  1825. { routine and resetting the ofGFVModeView flag after the call. }
  1826. {---------------------------------------------------------------------------}
  1827. PROCEDURE TView.Store (Var S: TStream);
  1828. VAR SaveState: Word;
  1829. BEGIN
  1830. SaveState := State; { Hold current state }
  1831. State := State AND NOT (sfActive OR sfSelected OR
  1832. sfFocused OR sfExposed); { Clear flags }
  1833. S.Write(Origin.X, 2); { Write view x origin }
  1834. S.Write(Origin.Y, 2); { Write view y origin }
  1835. S.Write(Size.X, 2); { Write view x size }
  1836. S.Write(Size.Y, 2); { Write view y size }
  1837. S.Write(Cursor.X, 2); { Write cursor x size }
  1838. S.Write(Cursor.Y, 2); { Write cursor y size }
  1839. S.Write(GrowMode, 1); { Write growmode flags }
  1840. S.Write(DragMode, 1); { Write dragmode flags }
  1841. S.Write(HelpCtx, 2); { Write help context }
  1842. S.Write(State, 2); { Write state masks }
  1843. S.Write(Options, 2); { Write options masks }
  1844. S.Write(Eventmask, 2); { Write event masks }
  1845. If (Options AND ofGFVModeView <> 0) Then Begin { GFV GRAPHICAL TVIEW }
  1846. S.Write(GOptions, 2); { Write new option masks }
  1847. S.Write(TabMask, 1); { Write new tab masks }
  1848. S.Write(RawOrigin.X, 2); { Write raw origin x point }
  1849. S.Write(RawOrigin.Y, 2); { Write raw origin y point }
  1850. S.Write(RawSize.X, 2); { Write raw x size }
  1851. S.Write(RawSize.Y, 2); { Write raw y size }
  1852. S.Write(ColourOfs, 2); { Write Palette offset }
  1853. End;
  1854. State := SaveState; { Reset state masks }
  1855. END;
  1856. {--TView--------------------------------------------------------------------}
  1857. { Locate -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 24Sep99 LdB }
  1858. {---------------------------------------------------------------------------}
  1859. PROCEDURE TView.Locate (Var Bounds: TRect);
  1860. VAR
  1861. X1, Y1, X2, Y2: Sw_Integer;
  1862. Min, Max: TPoint; R: TRect;
  1863. FUNCTION Range(Val, Min, Max: Sw_Integer): Sw_Integer;
  1864. BEGIN
  1865. If (Val < Min) Then Range := Min Else { Value to small }
  1866. If (Val > Max) Then Range := Max Else { Value to large }
  1867. Range := Val; { Value is okay }
  1868. END;
  1869. BEGIN
  1870. X1 := RawOrigin.X; { Current x origin }
  1871. Y1 := RawOrigin.Y; { Current y origin }
  1872. X2 := RawOrigin.X + RawSize.X; { Current x size }
  1873. Y2 := RawOrigin.Y + RawSize.Y; { Current y size }
  1874. SizeLimits(Min, Max); { Get size limits }
  1875. Bounds.B.X := Bounds.A.X + Range(Bounds.B.X -
  1876. Bounds.A.X, Min.X, Max.X); { X bound limit }
  1877. Bounds.B.Y := Bounds.A.Y + Range(Bounds.B.Y
  1878. - Bounds.A.Y, Min.Y, Max.Y); { Y bound limit }
  1879. GetBounds(R); { Current bounds }
  1880. If NOT Bounds.Equals(R) Then Begin { Size has changed }
  1881. ChangeBounds(Bounds); { Change bounds }
  1882. If (State AND sfVisible <> 0) AND { View is visible }
  1883. (State AND sfExposed <> 0) AND (Owner <> Nil) { Check view exposed }
  1884. Then Owner^.ReDrawArea(X1, Y1, X2, Y2); { Owner redraw }
  1885. DrawView; { Redraw the view }
  1886. End;
  1887. END;
  1888. {--TView--------------------------------------------------------------------}
  1889. { KeyEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1890. {---------------------------------------------------------------------------}
  1891. PROCEDURE TView.KeyEvent (Var Event: TEvent);
  1892. BEGIN
  1893. Repeat
  1894. GetEvent(Event); { Get next event }
  1895. Until (Event.What = evKeyDown); { Wait till keydown }
  1896. END;
  1897. {--TView--------------------------------------------------------------------}
  1898. { GetEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1899. {---------------------------------------------------------------------------}
  1900. PROCEDURE TView.GetEvent (Var Event: TEvent);
  1901. BEGIN
  1902. If (Owner <> Nil) Then Owner^.GetEvent(Event); { Event from owner }
  1903. END;
  1904. {--TView--------------------------------------------------------------------}
  1905. { PutEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1906. {---------------------------------------------------------------------------}
  1907. PROCEDURE TView.PutEvent (Var Event: TEvent);
  1908. BEGIN
  1909. If (Owner <> Nil) Then Owner^.PutEvent(Event); { Put in owner }
  1910. END;
  1911. {--TView--------------------------------------------------------------------}
  1912. { GetExtent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1913. {---------------------------------------------------------------------------}
  1914. PROCEDURE TView.GetExtent (Var Extent: TRect);
  1915. BEGIN
  1916. Extent.A.X := 0; { Zero x field }
  1917. Extent.A.Y := 0; { Zero y field }
  1918. Extent.B.X := Size.X; { Return x size }
  1919. Extent.B.Y := Size.Y; { Return y size }
  1920. END;
  1921. {--TView--------------------------------------------------------------------}
  1922. { GetBounds -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1923. {---------------------------------------------------------------------------}
  1924. PROCEDURE TView.GetBounds (Var Bounds: TRect);
  1925. BEGIN
  1926. Bounds.A := Origin; { Get first corner }
  1927. Bounds.B.X := Origin.X + Size.X; { Calc corner x value }
  1928. Bounds.B.Y := Origin.Y + Size.Y; { Calc corner y value }
  1929. If (Owner <> Nil) Then
  1930. Bounds.Move(-Owner^.Origin.X, -Owner^.Origin.Y); { Sub owner offset }
  1931. END;
  1932. {--TView--------------------------------------------------------------------}
  1933. { SetBounds -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 24Sep99 LdB }
  1934. {---------------------------------------------------------------------------}
  1935. PROCEDURE TView.SetBounds (Var Bounds: TRect);
  1936. VAR D, COrigin: TPoint;
  1937. BEGIN
  1938. { Remove shadow first }
  1939. if (State and (sfShadow or sfVisible or sfExposed) =
  1940. (sfShadow or sfVisible or sfExposed)) and
  1941. assigned(Owner) then
  1942. begin
  1943. State:= State and not sfShadow;
  1944. Owner^.ReDrawArea(RawOrigin.X + RawSize.X, RawOrigin.Y,
  1945. RawOrigin.X + RawSize.X + ShadowSize.X*SysFontWidth,
  1946. RawOrigin.Y + RawSize.Y + ShadowSize.Y*SysFontHeight); { Owner redraws area }
  1947. Owner^.ReDrawArea(RawOrigin.X, RawOrigin.Y + RawSize.Y,
  1948. RawOrigin.X + RawSize.X + ShadowSize.X*SysFontWidth,
  1949. RawOrigin.Y + RawSize.Y + ShadowSize.Y*SysFontHeight); { Owner redraws area }
  1950. State:= State or sfShadow;
  1951. end;
  1952. If (Bounds.B.X > 0) AND (Bounds.B.Y > 0) { Normal text co-ords }
  1953. AND (GOptions AND goGraphView = 0) Then Begin { Normal text view }
  1954. If (Owner <> Nil) Then Begin { Owner is valid }
  1955. COrigin.X := Origin.X - Owner^.Origin.X; { Corrected x origin }
  1956. COrigin.Y := Origin.Y - Owner^.Origin.Y; { Corrected y origin }
  1957. D.X := Bounds.A.X - COrigin.X; { X origin disp }
  1958. D.Y := Bounds.A.Y - COrigin.Y; { Y origin disp }
  1959. If ((D.X <> 0) OR (D.Y <> 0)) Then
  1960. DisplaceBy(D.X*FontWidth, D.Y*FontHeight); { Offset the view }
  1961. End Else Origin := Bounds.A; { Hold as origin }
  1962. Size.X := Bounds.B.X-Bounds.A.X; { Hold view x size }
  1963. Size.Y := Bounds.B.Y-Bounds.A.Y; { Hold view y size }
  1964. RawOrigin.X := Origin.X * FontWidth; { Raw x origin }
  1965. RawOrigin.Y := Origin.Y * FontHeight; { Raw y origin }
  1966. RawSize.X := Size.X * FontWidth - 1; { Set raw x size }
  1967. RawSize.Y := Size.Y * FontHeight - 1; { Set raw y size }
  1968. End Else Begin { Graphical co-ords }
  1969. If (Owner <> Nil) Then Begin { Owner is valid }
  1970. COrigin.X := RawOrigin.X - Owner^.RawOrigin.X; { Corrected x origin }
  1971. COrigin.Y := RawOrigin.Y - Owner^.RawOrigin.Y; { Corrected y origin }
  1972. D.X := Bounds.A.X - COrigin.X; { X origin disp }
  1973. D.Y := Bounds.A.Y - COrigin.Y; { Y origin disp }
  1974. If ((D.X <> 0) OR (D.Y <> 0)) Then
  1975. DisplaceBy(D.X, D.Y); { Offset the view }
  1976. End Else RawOrigin := Bounds.A; { Hold as origin }
  1977. RawSize.X := Abs(Bounds.B.X) - Bounds.A.X; { Set raw x size }
  1978. RawSize.Y := Abs(Bounds.B.Y) - Bounds.A.Y; { Set raw y size }
  1979. Origin.X := RawOrigin.X DIV FontWidth; { Rough x position }
  1980. Origin.Y := RawOrigin.Y DIV FontHeight; { Rough y position }
  1981. Size.X := RawSize.X DIV FontWidth; { Rough x size }
  1982. Size.Y := RawSize.Y DIV FontHeight; { Rough y size }
  1983. End;
  1984. Options := Options OR ofGFVModeView; { Now in GFV mode }
  1985. END;
  1986. {--TView--------------------------------------------------------------------}
  1987. { GetClipRect -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1988. {---------------------------------------------------------------------------}
  1989. PROCEDURE TView.GetClipRect (Var Clip: TRect);
  1990. BEGIN
  1991. GetBounds(Clip); { Get current bounds }
  1992. If (Owner <> Nil) Then Clip.Intersect(Owner^.Clip);{ Intersect with owner }
  1993. Clip.Move(-Origin.X, -Origin.Y); { Sub owner origin }
  1994. END;
  1995. {--TView--------------------------------------------------------------------}
  1996. { ClearEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  1997. {---------------------------------------------------------------------------}
  1998. PROCEDURE TView.ClearEvent (Var Event: TEvent);
  1999. BEGIN
  2000. Event.What := evNothing; { Clear the event }
  2001. Event.InfoPtr := @Self; { Set us as handler }
  2002. END;
  2003. {--TView--------------------------------------------------------------------}
  2004. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2005. {---------------------------------------------------------------------------}
  2006. PROCEDURE TView.HandleEvent (Var Event: TEvent);
  2007. BEGIN
  2008. If (Event.What = evMouseDown) Then { Mouse down event }
  2009. If (State AND (sfSelected OR sfDisabled) = 0) { Not selected/disabled }
  2010. AND (Options AND ofSelectable <> 0) Then { View is selectable }
  2011. If (Focus = False) OR { Not view with focus }
  2012. (Options AND ofFirstClick = 0) { Not 1st click select }
  2013. Then ClearEvent(Event); { Handle the event }
  2014. If (Event.What = evKeyDown) AND { Key down event }
  2015. (Options OR ofGFVModeView <> 0) Then Begin { GFV mode view check }
  2016. If (Owner <> Nil) AND (TabMask <> 0) AND { Owner and tab masks }
  2017. (State AND sfFocused <> 0) Then Begin { View has focus }
  2018. Case Event.KeyCode Of
  2019. kbTab: If (TabMask AND tmTab <> 0) Then { Tab key mask set }
  2020. Owner^.FocusNext(False) Else Exit; { Focus next view }
  2021. kbEnter: If (TabMask AND tmEnter <> 0) Then { Enter key mask set }
  2022. Owner^.FocusNext(False) Else Exit; { Focus next view }
  2023. kbShiftTab: If (TabMask AND tmShiftTab <> 0) { Shit tab mask set }
  2024. Then Owner^.FocusNext(True) Else Exit; { Focus prior view }
  2025. kbLeft: If (TabMask AND tmLeft <> 0) Then { Left arrow mask set }
  2026. Owner^.FocusNext(True) Else Exit; { Focus prior view }
  2027. kbRight: If (TabMask AND tmRight <> 0) Then { Right arrow mask set }
  2028. Owner^.FocusNext(False) Else Exit; { Focus next view }
  2029. kbUp: If (TabMask AND tmUp <> 0) Then { Up arrow mask set }
  2030. Owner^.FocusNext(True) Else Exit; { Focus prior view }
  2031. kbDown: If (TabMask AND tmDown <> 0) Then { Down arrow mask set }
  2032. Owner^.FocusNext(False) Else Exit; { Focus next view }
  2033. Else Exit; { Not a tab key }
  2034. End;
  2035. ClearEvent(Event); { Clear handled events }
  2036. End;
  2037. End;
  2038. END;
  2039. {--TView--------------------------------------------------------------------}
  2040. { ChangeBounds -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2041. {---------------------------------------------------------------------------}
  2042. PROCEDURE TView.ChangeBounds (Var Bounds: TRect);
  2043. BEGIN
  2044. SetBounds(Bounds); { Set new bounds }
  2045. DrawView; { Draw the view }
  2046. END;
  2047. {--TView--------------------------------------------------------------------}
  2048. { SizeLimits -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2049. {---------------------------------------------------------------------------}
  2050. PROCEDURE TView.SizeLimits (Var Min, Max: TPoint);
  2051. BEGIN
  2052. Min.X := 0; { Zero x minimum }
  2053. Min.Y := 0; { Zero y minimum }
  2054. If (Owner = Nil) Then Begin
  2055. Max.X := $7FFF; { Max possible x size }
  2056. Max.Y := $7FFF; { Max possible y size }
  2057. End Else Max := Owner^.Size; { Max owner size }
  2058. END;
  2059. {--TView--------------------------------------------------------------------}
  2060. { GetCommands -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2061. {---------------------------------------------------------------------------}
  2062. PROCEDURE TView.GetCommands (Var Commands: TCommandSet);
  2063. BEGIN
  2064. Commands := CurCommandSet; { Return command set }
  2065. END;
  2066. {--TView--------------------------------------------------------------------}
  2067. { GetPeerViewPtr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2068. {---------------------------------------------------------------------------}
  2069. PROCEDURE TView.GetPeerViewPtr (Var S: TStream; Var P);
  2070. VAR Index: Sw_Integer;
  2071. BEGIN
  2072. Index := 0; { Zero index value }
  2073. S.Read(Index, 2); { Read view index }
  2074. If (Index = 0) OR (OwnerGroup = Nil) Then { Check for peer views }
  2075. Pointer(P) := Nil Else Begin { Return nil }
  2076. Pointer(P) := FixupList^[Index]; { New view ptr }
  2077. FixupList^[Index] := @P; { Patch this pointer }
  2078. End;
  2079. END;
  2080. {--TView--------------------------------------------------------------------}
  2081. { PutPeerViewPtr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2082. {---------------------------------------------------------------------------}
  2083. PROCEDURE TView.PutPeerViewPtr (Var S: TStream; P: PView);
  2084. VAR Index: Sw_Integer;
  2085. BEGIN
  2086. If (P = Nil) OR (OwnerGroup = Nil) Then Index := 0 { Return zero index }
  2087. Else Index := OwnerGroup^.IndexOf(P); { Return view index }
  2088. S.Write(Index, 2); { Write the index }
  2089. END;
  2090. {--TView--------------------------------------------------------------------}
  2091. { CalcBounds -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2092. {---------------------------------------------------------------------------}
  2093. PROCEDURE TView.CalcBounds (Var Bounds: Objects.TRect; Delta: TPoint);
  2094. VAR S, D: Sw_Integer; Min, Max: TPoint;
  2095. FUNCTION Range (Val, Min, Max: Sw_Integer): Sw_Integer;
  2096. BEGIN
  2097. If (Val < Min) Then Range := Min Else { Value below min }
  2098. If (Val > Max) Then Range := Max Else { Value above max }
  2099. Range := Val; { Accept value }
  2100. END;
  2101. PROCEDURE GrowI (Var I: Sw_Integer);
  2102. BEGIN
  2103. If (GrowMode AND gfGrowRel = 0) Then Inc(I, D)
  2104. Else I := (I * S + (S - D) SHR 1) DIV (S - D); { Calc grow value }
  2105. END;
  2106. BEGIN
  2107. GetBounds(Bounds); { Get bounds }
  2108. If (GrowMode = 0) Then Exit; { No grow flags exits }
  2109. S := Owner^.Size.X; { Set initial size }
  2110. D := Delta.X; { Set initial delta }
  2111. If (GrowMode AND gfGrowLoX <> 0) Then
  2112. GrowI(Bounds.A.X); { Grow left side }
  2113. If (GrowMode AND gfGrowHiX <> 0) Then
  2114. GrowI(Bounds.B.X); { Grow right side }
  2115. If (Bounds.B.X - Bounds.A.X > MaxViewWidth) Then
  2116. Bounds.B.X := Bounds.A.X + MaxViewWidth; { Check values }
  2117. S := Owner^.Size.Y; D := Delta.Y; { set initial values }
  2118. If (GrowMode AND gfGrowLoY <> 0) Then
  2119. GrowI(Bounds.A.Y); { Grow top side }
  2120. If (GrowMode AND gfGrowHiY <> 0) Then
  2121. GrowI(Bounds.B.Y); { grow lower side }
  2122. SizeLimits(Min, Max); { Check sizes }
  2123. Bounds.B.X := Bounds.A.X + Range(Bounds.B.X -
  2124. Bounds.A.X, Min.X, Max.X); { Set right side }
  2125. Bounds.B.Y := Bounds.A.Y + Range(Bounds.B.Y -
  2126. Bounds.A.Y, Min.Y, Max.Y); { Set lower side }
  2127. END;
  2128. {***************************************************************************}
  2129. { TView OBJECT PRIVATE METHODS }
  2130. {***************************************************************************}
  2131. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2132. { TGroup OBJECT METHODS }
  2133. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2134. {--TGroup-------------------------------------------------------------------}
  2135. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Jul99 LdB }
  2136. {---------------------------------------------------------------------------}
  2137. CONSTRUCTOR TGroup.Init (Var Bounds: TRect);
  2138. BEGIN
  2139. Inherited Init(Bounds); { Call ancestor }
  2140. Options := Options OR (ofSelectable + ofBuffered); { Set options }
  2141. GOptions := GOptions OR goNoDrawView; { Non drawing view }
  2142. GetExtent(Clip); { Get clip extents }
  2143. EventMask := $FFFF; { See all events }
  2144. GOptions := GOptions OR goTabSelect; { Set graphic options }
  2145. END;
  2146. {--TGroup-------------------------------------------------------------------}
  2147. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  2148. {---------------------------------------------------------------------------}
  2149. CONSTRUCTOR TGroup.Load (Var S: TStream);
  2150. VAR I, Count: Sw_Word; P, Q: ^Pointer; V: PView; OwnerSave: PGroup;
  2151. FixupSave: PFixupList;
  2152. BEGIN
  2153. Inherited Load(S); { Call ancestor }
  2154. GetExtent(Clip); { Get view extents }
  2155. OwnerSave := OwnerGroup; { Save current group }
  2156. OwnerGroup := @Self; { We are current group }
  2157. FixupSave := FixupList; { Save current list }
  2158. Count := 0; { Zero count value }
  2159. S.Read(Count, 2); { Read entry count }
  2160. If (MaxAvail >= Count*SizeOf(Pointer)) Then Begin { Memory available }
  2161. GetMem(FixupList, Count*SizeOf(Pointer)); { List size needed }
  2162. FillChar(FixUpList^, Count*SizeOf(Pointer), #0); { Zero all entries }
  2163. For I := 1 To Count Do Begin
  2164. V := PView(S.Get); { Get view off stream }
  2165. If (V <> Nil) Then InsertView(V, Nil); { Insert valid views }
  2166. End;
  2167. V := Last; { Start on last view }
  2168. For I := 1 To Count Do Begin
  2169. V := V^.Next; { Fetch next view }
  2170. P := FixupList^[I]; { Transfer pointer }
  2171. While (P <> Nil) Do Begin { If valid view }
  2172. Q := P; { Copy pointer }
  2173. P := P^; { Fetch pointer }
  2174. Q^ := V; { Transfer view ptr }
  2175. End;
  2176. End;
  2177. FreeMem(FixupList, Count*SizeOf(Pointer)); { Release fixup list }
  2178. End;
  2179. OwnerGroup := OwnerSave; { Reload current group }
  2180. FixupList := FixupSave; { Reload current list }
  2181. GetSubViewPtr(S, V); { Load any subviews }
  2182. SetCurrent(V, NormalSelect); { Select current view }
  2183. If (OwnerGroup = Nil) Then Awaken; { If topview activate }
  2184. END;
  2185. {--TGroup-------------------------------------------------------------------}
  2186. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2187. {---------------------------------------------------------------------------}
  2188. DESTRUCTOR TGroup.Done;
  2189. VAR P, T: PView;
  2190. BEGIN
  2191. Hide; { Hide the view }
  2192. P := Last; { Start on last }
  2193. If (P <> Nil) Then Begin { Subviews exist }
  2194. Repeat
  2195. P^.Hide; { Hide each view }
  2196. P := P^.Prev; { Prior view }
  2197. Until (P = Last); { Loop complete }
  2198. Repeat
  2199. T := P^.Prev; { Hold prior pointer }
  2200. Dispose(P, Done); { Dispose subview }
  2201. P := T; { Transfer pointer }
  2202. Until (Last = Nil); { Loop complete }
  2203. End;
  2204. Inherited Done; { Call ancestor }
  2205. END;
  2206. {--TGroup-------------------------------------------------------------------}
  2207. { First -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2208. {---------------------------------------------------------------------------}
  2209. FUNCTION TGroup.First: PView;
  2210. BEGIN
  2211. If (Last = Nil) Then First := Nil { No first view }
  2212. Else First := Last^.Next; { Return first view }
  2213. END;
  2214. {--TGroup-------------------------------------------------------------------}
  2215. { Execute -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2216. {---------------------------------------------------------------------------}
  2217. FUNCTION TGroup.Execute: Word;
  2218. VAR Event: TEvent;
  2219. BEGIN
  2220. Repeat
  2221. EndState := 0; { Clear end state }
  2222. Repeat
  2223. GetEvent(Event); { Get next event }
  2224. HandleEvent(Event); { Handle the event }
  2225. If (Event.What <> evNothing) Then
  2226. EventError(Event); { Event not handled }
  2227. Until (EndState <> 0); { Until command set }
  2228. Until Valid(EndState); { Repeat until valid }
  2229. Execute := EndState; { Return result }
  2230. EndState := 0; { Clear end state }
  2231. END;
  2232. {--TGroup-------------------------------------------------------------------}
  2233. { GetHelpCtx -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2234. {---------------------------------------------------------------------------}
  2235. FUNCTION TGroup.GetHelpCtx: Word;
  2236. VAR H: Word;
  2237. BEGIN
  2238. H := hcNoContext; { Preset no context }
  2239. If (Current <> Nil) Then H := Current^.GetHelpCtx; { Current context }
  2240. If (H=hcNoContext) Then H := Inherited GetHelpCtx; { Call ancestor }
  2241. GetHelpCtx := H; { Return result }
  2242. END;
  2243. {--TGroup-------------------------------------------------------------------}
  2244. { DataSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Jul98 LdB }
  2245. {---------------------------------------------------------------------------}
  2246. FUNCTION TGroup.DataSize: Sw_Word;
  2247. VAR Total: Word; P: PView;
  2248. BEGIN
  2249. Total := 0; { Zero totals count }
  2250. P := Last; { Start on last view }
  2251. If (P <> Nil) Then Begin { Subviews exist }
  2252. Repeat
  2253. P := P^.Next; { Move to next view }
  2254. Total := Total + P^.DataSize; { Add view size }
  2255. Until (P = Last); { Until last view }
  2256. End;
  2257. DataSize := Total; { Return data size }
  2258. END;
  2259. {--TGroup-------------------------------------------------------------------}
  2260. { ExecView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Jul99 LdB }
  2261. {---------------------------------------------------------------------------}
  2262. FUNCTION TGroup.ExecView (P: PView): Word;
  2263. VAR SaveOptions: Word; SaveTopView, SaveCurrent: PView; SaveOwner: PGroup;
  2264. SaveCommands: TCommandSet;
  2265. BEGIN
  2266. If (P<>Nil) Then Begin
  2267. SaveOptions := P^.Options; { Hold options }
  2268. SaveOwner := P^.Owner; { Hold owner }
  2269. SaveTopView := TheTopView; { Save topmost view }
  2270. SaveCurrent := Current; { Save current view }
  2271. GetCommands(SaveCommands); { Save commands }
  2272. TheTopView := P; { Set top view }
  2273. P^.Options := P^.Options AND NOT ofSelectable; { Not selectable }
  2274. P^.SetState(sfModal, True); { Make modal }
  2275. SetCurrent(P, EnterSelect); { Select next }
  2276. If (SaveOwner = Nil) Then Insert(P); { Insert view }
  2277. ExecView := P^.Execute; { Execute view }
  2278. If (SaveOwner = Nil) Then Delete(P); { Remove view }
  2279. SetCurrent(SaveCurrent, LeaveSelect); { Unselect current }
  2280. P^.SetState(sfModal, False); { Clear modal state }
  2281. P^.Options := SaveOptions; { Restore options }
  2282. TheTopView := SaveTopView; { Restore topview }
  2283. SetCommands(SaveCommands); { Restore commands }
  2284. End Else ExecView := cmCancel; { Return cancel }
  2285. END;
  2286. { ********************************* REMARK ******************************** }
  2287. { This call really is very COMPILER SPECIFIC and really can't be done }
  2288. { effectively any other way but assembler code as SELF & FRAMES need }
  2289. { to be put down in exact order and OPTIMIZERS make a mess of it. }
  2290. { ******************************** END REMARK *** Leon de Boer, 17Jul99 *** }
  2291. {--TGroup-------------------------------------------------------------------}
  2292. { FirstThat -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Jul99 LdB }
  2293. {---------------------------------------------------------------------------}
  2294. FUNCTION TGroup.FirstThat (P: Pointer): PView; ASSEMBLER;
  2295. ASM
  2296. MOVL 8(%EBP), %ESI; { Self pointer }
  2297. MOVL TGroup.Last(%ESI), %EAX; { Load last view }
  2298. ORL %EAX, %EAX; { Check for nil }
  2299. JZ .L_Exit; { No subviews exit }
  2300. MOVL %EAX, %ECX; { Hold last view }
  2301. MOVL P, %EBX; { Procedure to call }
  2302. .L_LoopPoint:
  2303. MOVL TView.Next(%EAX), %EAX; { Fetch next pointer }
  2304. PUSHL %ECX; { Save holdlast view }
  2305. PUSHL %EBX; { Save procedure address }
  2306. PUSHL %EAX; { Save for recovery }
  2307. PUSHL %EAX; { PView pushed }
  2308. MOVL (%EBP), %EAX; { Fetch self ptr }
  2309. PUSH %EAX; { Push self ptr }
  2310. CALL %EBX; { Call the procedure }
  2311. ORB %AL, %AL; { Test for true }
  2312. POPL %EAX; { Recover next PView }
  2313. POPL %EBX; { Restore procedure addr }
  2314. POPL %ECX; { Restore holdlast view }
  2315. JNZ .L_Exit; { Call returned true }
  2316. CMPL %ECX, %EAX; { Check if last view }
  2317. JNZ .L_LoopPoint; { Continue to last }
  2318. XOR %EAX, %EAX; { No views gave true }
  2319. .L_Exit:
  2320. {MOVL %EAX, __RESULT;not needed for assembler functions Return result }
  2321. END;
  2322. {--TGroup-------------------------------------------------------------------}
  2323. { Valid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2324. {---------------------------------------------------------------------------}
  2325. FUNCTION TGroup.Valid (Command: Word): Boolean;
  2326. FUNCTION IsInvalid (P: PView): Boolean; FAR;
  2327. BEGIN
  2328. IsInvalid := NOT P^.Valid(Command); { Check if valid }
  2329. END;
  2330. BEGIN
  2331. Valid := True; { Preset valid }
  2332. If (Command = cmReleasedFocus) Then Begin { Release focus cmd }
  2333. If (Current <> Nil) AND { Current view exists }
  2334. (Current^.Options AND ofValidate <> 0) Then { Validating view }
  2335. Valid := Current^.Valid(Command); { Validate command }
  2336. End Else Valid := FirstThat(@IsInvalid) = Nil; { Check first valid }
  2337. END;
  2338. {--TGroup-------------------------------------------------------------------}
  2339. { FocusNext -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2340. {---------------------------------------------------------------------------}
  2341. FUNCTION TGroup.FocusNext (Forwards: Boolean): Boolean;
  2342. VAR P: PView;
  2343. BEGIN
  2344. P := FindNext(Forwards); { Find next view }
  2345. FocusNext := True; { Preset true }
  2346. If (P <> Nil) Then FocusNext := P^.Focus; { Check next focus }
  2347. END;
  2348. {--TGroup-------------------------------------------------------------------}
  2349. { ReDraw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB }
  2350. {---------------------------------------------------------------------------}
  2351. PROCEDURE TGroup.ReDraw;
  2352. VAR P: PView;
  2353. BEGIN
  2354. If (DrawMask AND vdNoChild = 0) Then Begin { No draw child clear }
  2355. P := Last; { Start on Last }
  2356. While (P <> Nil) Do Begin
  2357. P^.DrawView; { Redraw each subview }
  2358. P := P^.PrevView; { Move to prior view }
  2359. End;
  2360. End;
  2361. END;
  2362. {--TGroup-------------------------------------------------------------------}
  2363. { ReDraw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB }
  2364. {---------------------------------------------------------------------------}
  2365. PROCEDURE TGroup.ReDrawArea (X1, Y1, X2, Y2: Sw_Integer);
  2366. VAR P: PView;
  2367. BEGIN
  2368. { redraw this }
  2369. inherited RedrawArea(X1,Y1,X2,Y2);
  2370. { redraw group members }
  2371. If (DrawMask AND vdNoChild = 0) and
  2372. (X1<RawOrigin.X+RawSize.X) and { No need to parse childs for Shadows }
  2373. (Y1<RawOrigin.Y+RawSize.Y) Then Begin { No draw child clear }
  2374. P := Last; { Start on Last }
  2375. While (P <> Nil) Do Begin
  2376. P^.ReDrawArea(X1, Y1, X2, Y2); { Redraw each subview }
  2377. P := P^.PrevView; { Move to prior view }
  2378. End;
  2379. End;
  2380. END;
  2381. {--TGroup-------------------------------------------------------------------}
  2382. { Awaken -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  2383. {---------------------------------------------------------------------------}
  2384. PROCEDURE TGroup.Awaken;
  2385. PROCEDURE DoAwaken (P: PView); FAR;
  2386. BEGIN
  2387. If (P <> Nil) Then P^.Awaken; { Awaken view }
  2388. END;
  2389. BEGIN
  2390. ForEach(@DoAwaken); { Awaken each view }
  2391. END;
  2392. {--TGroup-------------------------------------------------------------------}
  2393. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB }
  2394. {---------------------------------------------------------------------------}
  2395. PROCEDURE TGroup.Draw;
  2396. BEGIN
  2397. If Buffer=Nil then
  2398. ReDraw
  2399. else
  2400. WriteBuf(0,0,Size.X,Size.Y,Buffer);
  2401. END;
  2402. {--TGroup-------------------------------------------------------------------}
  2403. { DrawBackground }
  2404. {---------------------------------------------------------------------------}
  2405. PROCEDURE TGroup.DrawBackground;
  2406. var
  2407. P : PView;
  2408. BEGIN
  2409. Inherited DrawBackground;
  2410. P:=Last;
  2411. While (P <> Nil) Do Begin
  2412. If P^.Exposed then
  2413. P^.SetDrawMask(vdAll); { Redraw each exposed subview }
  2414. P := P^.PrevView; { Move to prior view }
  2415. End;
  2416. END;
  2417. {--TGroup-------------------------------------------------------------------}
  2418. { SelectDefaultView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Oct99 LdB }
  2419. {---------------------------------------------------------------------------}
  2420. PROCEDURE TGroup.SelectDefaultView;
  2421. VAR P: PView;
  2422. BEGIN
  2423. P := Last; { Start at last }
  2424. While (P <> Nil) Do Begin
  2425. If P^.GetState(sfDefault) Then Begin { Search 1st default }
  2426. P^.Select; { Select default view }
  2427. P := Nil; { Force kick out }
  2428. End Else P := P^.PrevView; { Prior subview }
  2429. End;
  2430. END;
  2431. {--TGroup-------------------------------------------------------------------}
  2432. { Insert -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Sep99 LdB }
  2433. {---------------------------------------------------------------------------}
  2434. PROCEDURE TGroup.Insert (P: PView);
  2435. BEGIN
  2436. If (P <> Nil) and assigned(P^.Owner) Then { View is valid and already inserted }
  2437. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  2438. P^.DisplaceBy(-P^.Owner^.RawOrigin.X,
  2439. -P^.Owner^.RawOrigin.Y) Else { We are in GFV mode }
  2440. P^.DisplaceBy(-P^.Owner^.Origin.X*FontWidth,
  2441. -P^.Owner^.Origin.Y*FontHeight); { Displace old view }
  2442. If (P <> Nil) Then { View is valid }
  2443. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  2444. P^.DisplaceBy(RawOrigin.X, RawOrigin.Y) Else { We are in GFV mode }
  2445. P^.DisplaceBy(Origin.X*FontWidth,
  2446. Origin.Y*FontHeight); { Displace old view }
  2447. InsertBefore(P, First); { Insert the view }
  2448. END;
  2449. {--TGroup-------------------------------------------------------------------}
  2450. { Delete -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2451. {---------------------------------------------------------------------------}
  2452. PROCEDURE TGroup.Delete (P: PView);
  2453. VAR SaveState: Word;
  2454. BEGIN
  2455. SaveState := P^.State; { Save state }
  2456. P^.Hide; { Hide the view }
  2457. RemoveView(P); { Remove the view }
  2458. P^.Owner := Nil; { Clear owner ptr }
  2459. P^.Next := Nil; { Clear next ptr }
  2460. { We need to recalculate correct position }
  2461. If (P <> Nil) Then { View is valid }
  2462. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  2463. P^.DisplaceBy(-RawOrigin.X, -RawOrigin.Y) Else { We are in GFV mode }
  2464. P^.DisplaceBy(-Origin.X*FontWidth,
  2465. -Origin.Y*FontHeight); { Displace old view }
  2466. If (SaveState AND sfVisible <> 0) Then P^.Show; { Show view }
  2467. END;
  2468. { ********************************* REMARK ******************************** }
  2469. { This call really is very COMPILER SPECIFIC and really can't be done }
  2470. { effectively any other way but assembler code as SELF & FRAMES need }
  2471. { to be put down in exact order and OPTIMIZERS make a mess of it. }
  2472. { ******************************** END REMARK *** Leon de Boer, 17Jul99 *** }
  2473. {--TGroup-------------------------------------------------------------------}
  2474. { ForEach -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Jul99 LdB }
  2475. {---------------------------------------------------------------------------}
  2476. PROCEDURE TGroup.ForEach (P: Pointer); ASSEMBLER;
  2477. {&USES EBX, ECX, EDI} {&FRAME-}
  2478. VAR HoldLast: Pointer;
  2479. ASM
  2480. MOVL 8(%EBP), %ESI; { Self pointer }
  2481. MOVL TGroup.Last(%ESI), %ECX; { Load last view }
  2482. ORL %ECX, %ECX; { Check for nil }
  2483. JZ .L_Exit; { No subviews exit }
  2484. MOVL %ECX, HOLDLAST; { Hold last view }
  2485. MOVL TView.Next(%ECX), %ECX; { Fetch next pointer }
  2486. .L_LoopPoint:
  2487. MOVL P, %EBX; { Fetch proc address }
  2488. CMPL HOLDLAST, %ECX; { Check if last view }
  2489. JZ .L_2; { Exit if last view }
  2490. MOVL TView.Next(%ECX), %EAX; { Fetch next pointer }
  2491. PUSHL %EAX; { Save next view ptr }
  2492. PUSHL %ECX; { Push view to do }
  2493. MOVL (%EBP), %EAX;
  2494. PUSH %EAX;
  2495. CALL %EBX; { Call the procedure }
  2496. POPL %ECX; { Recover next view }
  2497. JMP .L_LoopPoint; { Redo loop }
  2498. .L_2:
  2499. PUSHL %ECX; { Push view to do }
  2500. MOVL (%EBP), %EAX;
  2501. PUSH %EAX;
  2502. CALL %EBX; { Call the procedure }
  2503. .L_Exit:
  2504. END;
  2505. {--TGroup-------------------------------------------------------------------}
  2506. { EndModal -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2507. {---------------------------------------------------------------------------}
  2508. PROCEDURE TGroup.EndModal (Command: Word);
  2509. BEGIN
  2510. If (State AND sfModal <> 0) Then { This view is modal }
  2511. EndState := Command Else { Set endstate }
  2512. Inherited EndModal(Command); { Call ancestor }
  2513. END;
  2514. {--TGroup-------------------------------------------------------------------}
  2515. { DisplaceBy -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15May98 LdB }
  2516. {---------------------------------------------------------------------------}
  2517. PROCEDURE TGroup.DisplaceBy (Dx, Dy: Sw_Integer);
  2518. VAR P: PView;
  2519. BEGIN
  2520. P := First; { Get first view }
  2521. While (P <> Nil) Do Begin
  2522. P^.DisplaceBy(Dx, Dy); { Displace subviews }
  2523. P := P^.NextView; { Next view }
  2524. End;
  2525. Inherited DisplaceBy(Dx, Dy); { Call ancestor }
  2526. END;
  2527. {--TGroup-------------------------------------------------------------------}
  2528. { SelectNext -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  2529. {---------------------------------------------------------------------------}
  2530. PROCEDURE TGroup.SelectNext (Forwards: Boolean);
  2531. VAR P: PView;
  2532. BEGIN
  2533. P := FindNext(Forwards); { Find next view }
  2534. If (P <> Nil) Then P^.Select; { Select view }
  2535. END;
  2536. {--TGroup-------------------------------------------------------------------}
  2537. { InsertBefore -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Sep99 LdB }
  2538. {---------------------------------------------------------------------------}
  2539. PROCEDURE TGroup.InsertBefore (P, Target: PView);
  2540. VAR SaveState : Word; I: Sw_Word;
  2541. BEGIN
  2542. If (P <> Nil) AND (P^.Owner = Nil) AND { View valid }
  2543. ((Target = Nil) OR (Target^.Owner = @Self)) { Target valid }
  2544. Then Begin
  2545. If (P^.Options AND ofCenterX <> 0) Then Begin { Centre on x axis }
  2546. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  2547. I := RawSize.X Else I := Size.X * FontWidth; { Calc owner x size }
  2548. If (P^.Options AND ofGFVModeView <> 0) { GFV mode view check }
  2549. Then Begin
  2550. I := (I - P^.RawSize.X) DIV 2; { Calc view offset }
  2551. I := I - P^.RawOrigin.X; { Subtract x origin }
  2552. End Else Begin
  2553. I := (I - (P^.Size.X * FontWidth)) DIV 2; { Calc view offset }
  2554. I := I - (P^.Origin.X * FontWidth); { Subtract x origin }
  2555. End;
  2556. { make sure that I is a multiple of FontWidth }
  2557. if TextModeGFV then
  2558. I:= (I div FontWidth) * FontWidth;
  2559. P^.DisplaceBy(I, 0); { Displace the view }
  2560. End;
  2561. If (P^.Options AND ofCenterY <> 0) Then Begin { Centre on y axis }
  2562. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  2563. I := RawSize.Y Else I := Size.Y * FontHeight;{ Calc owner y size }
  2564. If (P^.Options AND ofGFVModeView <> 0) { GFV mode view check }
  2565. Then Begin
  2566. I := (I - P^.RawSize.Y) DIV 2; { Calc view offset }
  2567. I := I - P^.RawOrigin.Y; { Subtract y origin }
  2568. End Else Begin
  2569. I := (I - (P^.Size.Y * FontHeight)) DIV 2; { Calc view offset }
  2570. I := I - (P^.Origin.Y * FontHeight); { Subtract y origin }
  2571. End;
  2572. { make sure that I is a multiple of FontHeight }
  2573. if TextModeGFV then
  2574. I:= (I div FontHeight) * FontHeight;
  2575. P^.DisplaceBy(0, I); { Displace the view }
  2576. End;
  2577. SaveState := P^.State; { Save view state }
  2578. P^.Hide; { Make sure hidden }
  2579. InsertView(P, Target); { Insert into list }
  2580. If (SaveState AND sfVisible <> 0) Then P^.Show; { Show the view }
  2581. If (State AND sfActive <> 0) Then { Was active before }
  2582. P^.SetState(sfActive , True); { Make active again }
  2583. End;
  2584. END;
  2585. {--TGroup-------------------------------------------------------------------}
  2586. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2587. {---------------------------------------------------------------------------}
  2588. PROCEDURE TGroup.SetState (AState: Word; Enable: Boolean);
  2589. PROCEDURE DoSetState (P: PView); FAR;
  2590. BEGIN
  2591. If (P <> Nil) Then P^.SetState(AState, Enable); { Set subview state }
  2592. END;
  2593. PROCEDURE DoExpose (P: PView); FAR;
  2594. BEGIN
  2595. If (P <> Nil) Then Begin
  2596. If (P^.State AND sfVisible <> 0) Then { Check view visible }
  2597. P^.SetState(sfExposed, Enable); { Set exposed flag }
  2598. End;
  2599. END;
  2600. BEGIN
  2601. Inherited SetState(AState, Enable); { Call ancestor }
  2602. Case AState Of
  2603. sfActive, sfDragging: Begin
  2604. Lock; { Lock the view }
  2605. ForEach(@DoSetState); { Set each subview }
  2606. UnLock; { Unlock the view }
  2607. End;
  2608. sfFocused: Begin
  2609. If (Current <> Nil) Then
  2610. Current^.SetState(sfFocused, Enable); { Focus current view }
  2611. {If TextModeGFV then
  2612. SetDrawMask(vdBackGnd OR vdFocus OR vdInner OR vdBorder); Set redraw masks }
  2613. End;
  2614. sfExposed: Begin
  2615. ForEach(@DoExpose); { Expose each subview }
  2616. End;
  2617. End;
  2618. END;
  2619. {--TGroup-------------------------------------------------------------------}
  2620. { GetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Mar98 LdB }
  2621. {---------------------------------------------------------------------------}
  2622. PROCEDURE TGroup.GetData (Var Rec);
  2623. VAR Total: Sw_Word; P: PView;
  2624. BEGIN
  2625. Total := 0; { Clear total }
  2626. P := Last; { Start at last }
  2627. While (P <> Nil) Do Begin { Subviews exist }
  2628. P^.GetData(TByteArray(Rec)[Total]); { Get data }
  2629. Inc(Total, P^.DataSize); { Increase total }
  2630. P := P^.PrevView; { Previous view }
  2631. End;
  2632. END;
  2633. {--TGroup-------------------------------------------------------------------}
  2634. { SetData -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 29Mar98 LdB }
  2635. {---------------------------------------------------------------------------}
  2636. PROCEDURE TGroup.SetData (Var Rec);
  2637. VAR Total: Sw_Word; P: PView;
  2638. BEGIN
  2639. Total := 0; { Clear total }
  2640. P := Last; { Start at last }
  2641. While (P <> Nil) Do Begin { Subviews exist }
  2642. P^.SetData(TByteArray(Rec)[Total]); { Get data }
  2643. Inc(Total, P^.DataSize); { Increase total }
  2644. P := P^.PrevView; { Previous view }
  2645. End;
  2646. END;
  2647. {--TGroup-------------------------------------------------------------------}
  2648. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Mar98 LdB }
  2649. {---------------------------------------------------------------------------}
  2650. PROCEDURE TGroup.Store (Var S: TStream);
  2651. VAR Count: Sw_Integer; OwnerSave: PGroup;
  2652. PROCEDURE DoPut (P: PView); FAR;
  2653. BEGIN
  2654. S.Put(P); { Put view on stream }
  2655. END;
  2656. BEGIN
  2657. TView.Store(S); { Call view store }
  2658. OwnerSave := OwnerGroup; { Save ownergroup }
  2659. OwnerGroup := @Self; { Set as owner group }
  2660. Count := IndexOf(Last); { Subview count }
  2661. S.Write(Count, 2); { Write the count }
  2662. ForEach(@DoPut); { Put each in stream }
  2663. PutSubViewPtr(S, Current); { Current on stream }
  2664. OwnerGroup := OwnerSave; { Restore ownergroup }
  2665. END;
  2666. {--TGroup-------------------------------------------------------------------}
  2667. { EventError -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2668. {---------------------------------------------------------------------------}
  2669. PROCEDURE TGroup.EventError (Var Event: TEvent);
  2670. BEGIN
  2671. If (Owner <> Nil) Then Owner^.EventError(Event); { Event error }
  2672. END;
  2673. {--TGroup-------------------------------------------------------------------}
  2674. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2675. {---------------------------------------------------------------------------}
  2676. PROCEDURE TGroup.HandleEvent (Var Event: TEvent);
  2677. FUNCTION ContainsMouse (P: PView): Boolean; FAR;
  2678. BEGIN
  2679. ContainsMouse := (P^.State AND sfVisible <> 0) { Is view visible }
  2680. AND P^.MouseInView(Event.Where); { Is point in view }
  2681. END;
  2682. PROCEDURE DoHandleEvent (P: PView); FAR;
  2683. BEGIN
  2684. If (P = Nil) OR ((P^.State AND sfDisabled <> 0) AND
  2685. (Event.What AND(PositionalEvents OR FocusedEvents) <>0 ))
  2686. Then Exit; { Invalid/disabled }
  2687. Case Phase Of
  2688. phPreProcess: If (P^.Options AND ofPreProcess = 0)
  2689. Then Exit; { Not pre processing }
  2690. phPostProcess: If (P^.Options AND ofPostProcess = 0)
  2691. Then Exit; { Not post processing }
  2692. End;
  2693. If (Event.What AND P^.EventMask <> 0) Then { View handles event }
  2694. P^.HandleEvent(Event); { Pass to view }
  2695. END;
  2696. BEGIN
  2697. Inherited HandleEvent(Event); { Call ancestor }
  2698. If (Event.What = evNothing) Then Exit; { No valid event exit }
  2699. If (Event.What AND FocusedEvents <> 0) Then Begin { Focused event }
  2700. Phase := phPreProcess; { Set pre process }
  2701. ForEach(@DoHandleEvent); { Pass to each view }
  2702. Phase := phFocused; { Set focused }
  2703. DoHandleEvent(Current); { Pass to current }
  2704. Phase := phPostProcess; { Set post process }
  2705. ForEach(@DoHandleEvent); { Pass to each }
  2706. End Else Begin
  2707. Phase := phFocused; { Set focused }
  2708. If (Event.What AND PositionalEvents <> 0) Then { Positional event }
  2709. DoHandleEvent(FirstThat(@ContainsMouse)) { Pass to first }
  2710. Else ForEach(@DoHandleEvent); { Pass to all }
  2711. End;
  2712. END;
  2713. {--TGroup-------------------------------------------------------------------}
  2714. { ChangeBounds -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  2715. {---------------------------------------------------------------------------}
  2716. PROCEDURE TGroup.ChangeBounds (Var Bounds: TRect);
  2717. VAR D: TPoint;
  2718. PROCEDURE DoCalcChange (P: PView); FAR;
  2719. VAR R: TRect;
  2720. BEGIN
  2721. P^.CalcBounds(R, D); { Calc view bounds }
  2722. P^.ChangeBounds(R); { Change view bounds }
  2723. END;
  2724. BEGIN
  2725. D.X := Bounds.B.X - Bounds.A.X - Size.X; { Delta x value }
  2726. D.Y := Bounds.B.Y - Bounds.A.Y - Size.Y; { Delta y value }
  2727. If ((D.X=0) AND (D.Y=0)) Then Begin
  2728. SetBounds(Bounds); { Set new bounds }
  2729. DrawView; { Draw the view }
  2730. End Else Begin
  2731. SetBounds(Bounds); { Set new bounds }
  2732. GetExtent(Clip); { Get new clip extents }
  2733. Lock; { Lock drawing }
  2734. ForEach(@DoCalcChange); { Change each view }
  2735. UnLock; { Unlock drawing }
  2736. End;
  2737. END;
  2738. {--TGroup-------------------------------------------------------------------}
  2739. { GetSubViewPtr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 20May98 LdB }
  2740. {---------------------------------------------------------------------------}
  2741. PROCEDURE TGroup.GetSubViewPtr (Var S: TStream; Var P);
  2742. VAR Index, I: Sw_Word; Q: PView;
  2743. BEGIN
  2744. Index := 0; { Zero index value }
  2745. S.Read(Index, 2); { Read view index }
  2746. If (Index > 0) Then Begin { Valid index }
  2747. Q := Last; { Start on last }
  2748. For I := 1 To Index Do Q := Q^.Next; { Loop for count }
  2749. Pointer(P) := Q; { Return the view }
  2750. End Else Pointer(P) := Nil; { Return nil }
  2751. END;
  2752. {--TGroup-------------------------------------------------------------------}
  2753. { PutSubViewPtr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 20May98 LdB }
  2754. {---------------------------------------------------------------------------}
  2755. PROCEDURE TGroup.PutSubViewPtr (Var S: TStream; P: PView);
  2756. VAR Index: Sw_Word;
  2757. BEGIN
  2758. If (P = Nil) Then Index := 0 Else { Nil view, Index = 0 }
  2759. Index := IndexOf(P); { Calc view index }
  2760. S.Write(Index, 2); { Write the index }
  2761. END;
  2762. {***************************************************************************}
  2763. { TGroup OBJECT PRIVATE METHODS }
  2764. {***************************************************************************}
  2765. {--TGroup-------------------------------------------------------------------}
  2766. { IndexOf -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2767. {---------------------------------------------------------------------------}
  2768. FUNCTION TGroup.IndexOf (P: PView): Sw_Integer;
  2769. VAR I: Sw_Integer; Q: PView;
  2770. BEGIN
  2771. Q := Last; { Start on last view }
  2772. If (Q <> Nil) Then Begin { Subviews exist }
  2773. I := 1; { Preset value }
  2774. While (Q <> P) AND (Q^.Next <> Last) Do Begin
  2775. Q := Q^.Next; { Load next view }
  2776. Inc(I); { Increment count }
  2777. End;
  2778. If (Q <> P) Then IndexOf := 0 Else IndexOf := I; { Return index }
  2779. End Else IndexOf := 0; { Return zero }
  2780. END;
  2781. {--TGroup-------------------------------------------------------------------}
  2782. { FindNext -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23Sep99 LdB }
  2783. {---------------------------------------------------------------------------}
  2784. FUNCTION TGroup.FindNext (Forwards: Boolean): PView;
  2785. VAR P: PView;
  2786. BEGIN
  2787. FindNext := Nil; { Preset nil return }
  2788. If (Current <> Nil) Then Begin { Has current view }
  2789. P := Current; { Start on current }
  2790. Repeat
  2791. If Forwards Then P := P^.Next { Get next view }
  2792. Else P := P^.Prev; { Get prev view }
  2793. Until ((P^.State AND (sfVisible+sfDisabled) = sfVisible)
  2794. AND ((P^.Options AND ofSelectable <> 0) AND { Selectable }
  2795. (P^.GOptions AND goTabSelect <> 0))) OR { Tab selectable }
  2796. (P = Current); { Not singular select }
  2797. If (P <> Current) Then FindNext := P; { Return result }
  2798. End;
  2799. END;
  2800. {--TGroup-------------------------------------------------------------------}
  2801. { FirstMatch -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2802. {---------------------------------------------------------------------------}
  2803. FUNCTION TGroup.FirstMatch (AState: Word; AOptions: Word): PView;
  2804. FUNCTION Matches (P: PView): Boolean; FAR;
  2805. BEGIN
  2806. Matches := (P^.State AND AState = AState) AND
  2807. (P^.Options AND AOptions = AOptions); { Return match state }
  2808. END;
  2809. BEGIN
  2810. FirstMatch := FirstThat(@Matches); { Return first match }
  2811. END;
  2812. {--TGroup-------------------------------------------------------------------}
  2813. { ResetCurrent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2814. {---------------------------------------------------------------------------}
  2815. PROCEDURE TGroup.ResetCurrent;
  2816. BEGIN
  2817. SetCurrent(FirstMatch(sfVisible, ofSelectable),
  2818. NormalSelect); { Reset current view }
  2819. END;
  2820. {--TGroup-------------------------------------------------------------------}
  2821. { RemoveView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2822. {---------------------------------------------------------------------------}
  2823. PROCEDURE TGroup.RemoveView (P: PView);
  2824. VAR Q: PView;
  2825. BEGIN
  2826. If (P <> Nil) AND (Last <> Nil) Then Begin { Check view is valid }
  2827. Q := Last; { Start on last view }
  2828. While (Q^.Next <> P) AND (Q^.Next <> Last) Do
  2829. Q := Q^.Next; { Find prior view }
  2830. If (Q^.Next = P) Then Begin { View found }
  2831. If (Q^.Next <> Q) Then Begin { Not only view }
  2832. Q^.Next := P^.Next; { Rechain views }
  2833. If (P = Last) Then Last := P^.Next; { Fix if last removed }
  2834. End Else Last := Nil; { Only view }
  2835. End;
  2836. End;
  2837. END;
  2838. {--TGroup-------------------------------------------------------------------}
  2839. { InsertView -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  2840. {---------------------------------------------------------------------------}
  2841. PROCEDURE TGroup.InsertView (P, Target: PView);
  2842. BEGIN
  2843. If (P <> Nil) Then Begin { Check view is valid }
  2844. P^.Owner := @Self; { Views owner is us }
  2845. If (Target <> Nil) Then Begin { Valid target }
  2846. Target := Target^.Prev; { 1st part of chain }
  2847. P^.Next := Target^.Next; { 2nd part of chain }
  2848. Target^.Next := P; { Chain completed }
  2849. End Else Begin
  2850. If (Last <> Nil) Then Begin { Not first view }
  2851. P^.Next := Last^.Next; { 1st part of chain }
  2852. Last^.Next := P; { Completed chain }
  2853. End Else P^.Next := P; { 1st chain to self }
  2854. Last := P; { P is now last }
  2855. End;
  2856. End;
  2857. END;
  2858. {--TGroup-------------------------------------------------------------------}
  2859. { SetCurrent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23Sep99 LdB }
  2860. {---------------------------------------------------------------------------}
  2861. PROCEDURE TGroup.SetCurrent (P: PView; Mode: SelectMode);
  2862. PROCEDURE SelectView (P: PView; Enable: Boolean);
  2863. BEGIN
  2864. If (P <> Nil) Then { View is valid }
  2865. P^.SetState(sfSelected, Enable); { Select the view }
  2866. END;
  2867. PROCEDURE FocusView (P: PView; Enable: Boolean);
  2868. BEGIN
  2869. If (State AND sfFocused <> 0) AND (P <> Nil) { Check not focused }
  2870. Then P^.SetState(sfFocused, Enable); { Focus the view }
  2871. END;
  2872. BEGIN
  2873. If (Current<>P) Then Begin { Not already current }
  2874. Lock; { Stop drawing }
  2875. FocusView(Current, False); { Defocus current }
  2876. If (Mode <> EnterSelect) Then
  2877. SelectView(Current, False); { Deselect current }
  2878. If (Mode<>LeaveSelect) Then SelectView(P, True); { Select view P }
  2879. FocusView(P, True); { Focus view P }
  2880. Current := P; { Set as current view }
  2881. UnLock; { Redraw now }
  2882. End;
  2883. END;
  2884. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2885. { TFrame OBJECT METHODS }
  2886. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2887. {--TFrame-------------------------------------------------------------------}
  2888. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  2889. {---------------------------------------------------------------------------}
  2890. CONSTRUCTOR TFrame.Init (Var Bounds: TRect);
  2891. BEGIN
  2892. Inherited Init(Bounds); { Call ancestor }
  2893. GrowMode := gfGrowHiX + gfGrowHiY; { Set grow modes }
  2894. EventMask := EventMask OR evBroadcast; { See broadcasts }
  2895. END;
  2896. {--TFrame-------------------------------------------------------------------}
  2897. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  2898. {---------------------------------------------------------------------------}
  2899. FUNCTION TFrame.GetPalette: PPalette;
  2900. CONST P: String[Length(CFrame)] = CFrame; { Always normal string }
  2901. BEGIN
  2902. GetPalette := @P; { Return palette }
  2903. END;
  2904. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2905. { TScrollBar OBJECT METHODS }
  2906. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  2907. {--TScrollBar---------------------------------------------------------------}
  2908. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  2909. {---------------------------------------------------------------------------}
  2910. CONSTRUCTOR TScrollBar.Init (Var Bounds: TRect);
  2911. const
  2912. VChars: array[boolean] of TScrollChars =
  2913. (('^','V', #177, #254, #178),(#30, #31, #177, #254, #178));
  2914. HChars: array[boolean] of TScrollChars =
  2915. (('<','>', #177, #254, #178),(#17, #16, #177, #254, #178));
  2916. BEGIN
  2917. Inherited Init(Bounds); { Call ancestor }
  2918. PgStep := 1; { Page step size = 1 }
  2919. ArStep := 1; { Arrow step sizes = 1 }
  2920. If (Size.X = 1) Then Begin { Vertical scrollbar }
  2921. GrowMode := gfGrowLoX + gfGrowHiX + gfGrowHiY; { Grow vertically }
  2922. Chars := VChars[LowAscii]; { Vertical chars }
  2923. End Else Begin { Horizontal scrollbar }
  2924. GrowMode := gfGrowLoY + gfGrowHiX + gfGrowHiY; { Grow horizontal }
  2925. Chars := HChars[LowAscii]; { Horizontal chars }
  2926. End;
  2927. END;
  2928. {--TScrollBar---------------------------------------------------------------}
  2929. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  2930. {---------------------------------------------------------------------------}
  2931. { This load method will read old original TV data from a stream with the }
  2932. { scrollbar id set to zero. }
  2933. {---------------------------------------------------------------------------}
  2934. CONSTRUCTOR TScrollBar.Load (Var S: TStream);
  2935. BEGIN
  2936. Inherited Load(S); { Call ancestor }
  2937. S.Read(Value, 2); { Read current value }
  2938. S.Read(Min , 2); { Read min value }
  2939. S.Read(Max, 2); { Read max value }
  2940. S.Read(PgStep, 2); { Read page step size }
  2941. S.Read(ArStep, 2); { Read arrow step size }
  2942. S.Read(Chars, SizeOf(Chars)); { Read scroll chars }
  2943. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  2944. S.Read(Id, 2); { Read id }
  2945. END;
  2946. {--TScrollBar---------------------------------------------------------------}
  2947. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  2948. {---------------------------------------------------------------------------}
  2949. FUNCTION TScrollBar.GetPalette: PPalette;
  2950. CONST P: String[Length(CScrollBar)] = CScrollBar; { Always normal string }
  2951. BEGIN
  2952. GetPalette := @P; { Return palette }
  2953. END;
  2954. {--TScrollBar---------------------------------------------------------------}
  2955. { ScrollStep -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  2956. {---------------------------------------------------------------------------}
  2957. FUNCTION TScrollBar.ScrollStep (Part: Sw_Integer): Sw_Integer;
  2958. VAR Step: Sw_Integer;
  2959. BEGIN
  2960. If (Part AND $0002 = 0) Then Step := ArStep { Range step size }
  2961. Else Step := PgStep; { Page step size }
  2962. If (Part AND $0001 = 0) Then ScrollStep := -Step { Upwards move }
  2963. Else ScrollStep := Step; { Downwards move }
  2964. END;
  2965. {--TScrollBar---------------------------------------------------------------}
  2966. { Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27Oct99 LdB }
  2967. {---------------------------------------------------------------------------}
  2968. PROCEDURE TScrollBar.Draw;
  2969. BEGIN
  2970. If (GOptions AND goNativeClass = 0) Then
  2971. DrawPos(GetPos); { Draw position }
  2972. END;
  2973. {--TScrollBar---------------------------------------------------------------}
  2974. { ScrollDraw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  2975. {---------------------------------------------------------------------------}
  2976. PROCEDURE TScrollBar.ScrollDraw;
  2977. VAR P: PView;
  2978. BEGIN
  2979. If (Id <> 0) Then Begin
  2980. P := TopView; { Get topmost view }
  2981. NewMessage(P, evCommand, cmIdCommunicate, Id,
  2982. Value, @Self); { New Id style message }
  2983. End;
  2984. NewMessage(Owner, evBroadcast, cmScrollBarChanged,
  2985. Id, Value, @Self); { Old TV style message }
  2986. END;
  2987. {--TScrollBar---------------------------------------------------------------}
  2988. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  2989. {---------------------------------------------------------------------------}
  2990. PROCEDURE TScrollBar.DrawBackGround;
  2991. VAR Bc: Byte;
  2992. I : Longint;
  2993. B : TDrawBuffer;
  2994. BEGIN
  2995. If (GOptions AND goNativeClass = 0) Then Begin { Non natives draw }
  2996. Inherited DrawBackGround; { Call ancestor }
  2997. Bc := GetColor(1) AND $F0 SHR 4; { Background colour }
  2998. If TextModeGFV or UseFixedFont then
  2999. Begin
  3000. WriteChar(0,0,Chars[0],Bc,1);
  3001. If (Size.X = 1) Then Begin { Vertical scrollbar }
  3002. For i:=1 to Size.Y-2 do
  3003. WriteChar(0,i,Chars[2],Bc,1);
  3004. WriteChar(0,Size.Y-1,Chars[1],Bc,1);
  3005. End Else Begin
  3006. WriteChar(1,0,Chars[2],Bc,Size.X-2);
  3007. WriteChar(Size.X-1,0,Chars[1],Bc,1);
  3008. End;
  3009. End
  3010. else
  3011. Begin
  3012. ClearArea(0, 0, FontWidth-1, FontHeight-1, Bc); { Clear top/left area }
  3013. BiColorRectangle(0, 0, FontWidth-1, FontHeight-1,
  3014. 15, 0, False); { Draw 3d effect }
  3015. ClearArea(RawSize.X-FontWidth+1, RawSize.Y-
  3016. FontHeight+1, RawSize.X, RawSize.Y, Bc); { Clr right/lower area }
  3017. BiColorRectangle(RawSize.X-FontWidth+1,
  3018. RawSize.Y-FontHeight+1,RawSize.X, RawSize.Y,
  3019. 15, 0, False); { Draw 3d effect }
  3020. End;
  3021. End;
  3022. END;
  3023. {--TScrollBar---------------------------------------------------------------}
  3024. { SetValue -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 19May98 LdB }
  3025. {---------------------------------------------------------------------------}
  3026. PROCEDURE TScrollBar.SetValue (AValue: Sw_Integer);
  3027. BEGIN
  3028. SetParams(AValue, Min, Max, PgStep, ArStep); { Set value }
  3029. END;
  3030. {--TScrollBar---------------------------------------------------------------}
  3031. { SetRange -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 19May98 LdB }
  3032. {---------------------------------------------------------------------------}
  3033. PROCEDURE TScrollBar.SetRange (AMin, AMax: Sw_Integer);
  3034. BEGIN
  3035. SetParams(Value, AMin, AMax, PgStep, ArStep); { Set range }
  3036. END;
  3037. {--TScrollBar---------------------------------------------------------------}
  3038. { SetStep -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 19May98 LdB }
  3039. {---------------------------------------------------------------------------}
  3040. PROCEDURE TScrollBar.SetStep (APgStep, AArStep: Sw_Integer);
  3041. BEGIN
  3042. SetParams(Value, Min, Max, APgStep, AArStep); { Set step sizes }
  3043. END;
  3044. {--TScrollBar---------------------------------------------------------------}
  3045. { SetParams -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 21Jul99 LdB }
  3046. {---------------------------------------------------------------------------}
  3047. PROCEDURE TScrollBar.SetParams (AValue, AMin, AMax, APgStep, AArStep: Sw_Integer);
  3048. BEGIN
  3049. If (AMax < AMin) Then AMax := AMin; { Max below min fix up }
  3050. If (AValue < AMin) Then AValue := AMin; { Value below min fix }
  3051. If (AValue > AMax) Then AValue := AMax; { Value above max fix }
  3052. If (Value <> AValue) OR (Min <> AMin) OR
  3053. (Max <> AMax) Then Begin { Something changed }
  3054. If (Min <> AMin) OR (Max <> AMax) Then Begin { Range has changed }
  3055. If (GOptions AND goNativeClass = 0) Then
  3056. ClearPos(GetPos); { Clear old position }
  3057. Min := AMin; { Set new minimum }
  3058. Max := AMax; { Set new maximum }
  3059. { This was removed as found not needed but if you
  3060. change limits but value unchanged scrollbar is not redrawm..LdB }
  3061. {If (Value = AValue) AND (State and sfVisible <> 0)
  3062. Then ScrollDraw;} { Send message out }
  3063. End Else Begin
  3064. If (GOptions AND goNativeClass = 0) Then { Not in native mode }
  3065. ClearPos(GetPos); { Clear old position }
  3066. End;
  3067. If (Value <> AValue) Then Begin { Position moved }
  3068. Value := AValue; { Set new value }
  3069. If (GOptions AND goNativeClass = 0) Then Begin { Not in native mode }
  3070. SetDrawMask(vdInner); { Set draw masks }
  3071. DrawView; { Redraw changed }
  3072. End;
  3073. If (State AND sfVisible <> 0) Then ScrollDraw; { Send update message }
  3074. End;
  3075. End;
  3076. PgStep := APgStep; { Hold page step }
  3077. ArStep := AArStep; { Hold arrow step }
  3078. END;
  3079. {--TScrollBar---------------------------------------------------------------}
  3080. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  3081. {---------------------------------------------------------------------------}
  3082. { You can save data to the stream compatable with the old original TV by }
  3083. { temporarily turning off the ofGrafVersion making the call to this store }
  3084. { routine and resetting the ofGrafVersion flag after the call. }
  3085. {---------------------------------------------------------------------------}
  3086. PROCEDURE TScrollBar.Store (Var S: TStream);
  3087. BEGIN
  3088. TView.Store(S); { TView.Store called }
  3089. S.Write(Value, 2); { Write current value }
  3090. S.Write(Min, 2); { Write min value }
  3091. S.Write(Max, 2); { Write max value }
  3092. S.Write(PgStep, 2); { Write page step size }
  3093. S.Write(ArStep, 2); { Write arrow step size }
  3094. S.Write(Chars, SizeOf(Chars)); { Write scroll chars }
  3095. If (Options AND ofGFVModeView <> 0) Then { GFV mode view check }
  3096. S.Write(Id, 2); { Write scrollbar id }
  3097. END;
  3098. {--TScrollBar---------------------------------------------------------------}
  3099. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB }
  3100. {---------------------------------------------------------------------------}
  3101. PROCEDURE TScrollBar.HandleEvent (Var Event: TEvent);
  3102. VAR Tracking: Boolean; I, P, S, ClickPart, Iv: Sw_Integer;
  3103. Mouse: TPoint; Extent: TRect;
  3104. FUNCTION GetPartCode: Sw_Integer;
  3105. VAR Mark, Part, J: Sw_Integer;
  3106. BEGIN
  3107. Part := -1; { Preset failure }
  3108. If Extent.Contains(Mouse) Then Begin { Contains mouse }
  3109. If (Size.X = 1) Then Begin { Vertical scrollbar }
  3110. Mark := Mouse.Y - FontHeight; { Calc position }
  3111. J := FontHeight; { Font height }
  3112. End Else Begin { Horizontal bar }
  3113. Mark := Mouse.X - FontWidth; { Calc position }
  3114. J := FontWidth; { Font width }
  3115. End;
  3116. If (Mark >= P) AND (Mark < P+J) Then { Within thumbnail }
  3117. Part := sbIndicator; { Indicator part }
  3118. If (Part <> sbIndicator) Then Begin { Not indicator part }
  3119. If (Mark < 1) Then Part := sbLeftArrow Else { Left arrow part }
  3120. If (Mark < P) Then Part := sbPageLeft Else { Page left part }
  3121. If (Mark < S) Then Part := sbPageRight Else { Page right part }
  3122. Part := sbRightArrow; { Right arrow part }
  3123. If (Size.X = 1) Then Inc(Part, 4); { Correct for vertical }
  3124. End;
  3125. End;
  3126. GetPartCode := Part; { Return part code }
  3127. END;
  3128. PROCEDURE Clicked;
  3129. BEGIN
  3130. NewMessage(Owner, evBroadcast, cmScrollBarClicked,
  3131. Id, Value, @Self); { Old TV style message }
  3132. END;
  3133. BEGIN
  3134. Inherited HandleEvent(Event); { Call ancestor }
  3135. Case Event.What Of
  3136. evNothing: Exit; { Speed up exit }
  3137. evCommand: Begin { Command event }
  3138. If (Event.Command = cmIdCommunicate) AND { Id communication }
  3139. (Event.Id = Id) AND (Event.InfoPtr <> @Self) { Targeted to us }
  3140. Then Begin
  3141. SetValue(Round(Event.Data)); { Set scrollbar value }
  3142. ClearEvent(Event); { Event was handled }
  3143. End;
  3144. End;
  3145. evKeyDown:
  3146. If (State AND sfVisible <> 0) Then Begin { Scrollbar visible }
  3147. ClickPart := sbIndicator; { Preset result }
  3148. If (Size.Y = 1) Then { Horizontal bar }
  3149. Case CtrlToArrow(Event.KeyCode) Of
  3150. kbLeft: ClickPart := sbLeftArrow; { Left one item }
  3151. kbRight: ClickPart := sbRightArrow; { Right one item }
  3152. kbCtrlLeft: ClickPart := sbPageLeft; { One page left }
  3153. kbCtrlRight: ClickPart := sbPageRight; { One page right }
  3154. kbHome: I := Min; { Move to start }
  3155. kbEnd: I := Max; { Move to end }
  3156. Else Exit; { Not a valid key }
  3157. End
  3158. Else { Vertical bar }
  3159. Case CtrlToArrow(Event.KeyCode) Of
  3160. kbUp: ClickPart := sbUpArrow; { One item up }
  3161. kbDown: ClickPart := sbDownArrow; { On item down }
  3162. kbPgUp: ClickPart := sbPageUp; { One page up }
  3163. kbPgDn: ClickPart := sbPageDown; { One page down }
  3164. kbCtrlPgUp: I := Min; { Move to top }
  3165. kbCtrlPgDn: I := Max; { Move to bottom }
  3166. Else Exit; { Not a valid key }
  3167. End;
  3168. Clicked; { Send out message }
  3169. If (ClickPart <> sbIndicator) Then
  3170. I := Value + ScrollStep(ClickPart); { Calculate position }
  3171. SetValue(I); { Set new item }
  3172. ClearEvent(Event); { Event now handled }
  3173. End;
  3174. evMouseDown: Begin { Mouse press event }
  3175. Clicked; { Scrollbar clicked }
  3176. Mouse.X := Event.Where.X - RawOrigin.X; { Localize x value }
  3177. Mouse.Y := Event.Where.Y - RawOrigin.Y; { Localize y value }
  3178. Extent.A.X := 0; { Zero x extent value }
  3179. Extent.A.Y := 0; { Zero y extent value }
  3180. Extent.B.X := RawSize.X; { Set extent x value }
  3181. Extent.B.Y := RawSize.Y; { set extent y value }
  3182. P := GetPos; { Current position }
  3183. S := GetSize; { Initial size }
  3184. ClickPart := GetPartCode; { Get part code }
  3185. If (ClickPart <> sbIndicator) Then Begin { Not thumb nail }
  3186. Repeat
  3187. Mouse.X := Event.Where.X-RawOrigin.X; { Localize x value }
  3188. Mouse.Y := Event.Where.Y-RawOrigin.Y; { Localize y value }
  3189. If GetPartCode = ClickPart Then
  3190. SetValue(Value+ScrollStep(ClickPart)); { Same part repeat }
  3191. Until NOT MouseEvent(Event, evMouseAuto); { Until auto done }
  3192. Clicked; { Scrollbar clicked }
  3193. End Else Begin { Thumb nail move }
  3194. Iv := Value; { Initial value }
  3195. Repeat
  3196. Mouse.X := Event.Where.X - RawOrigin.X; { Localize x value }
  3197. Mouse.Y := Event.Where.Y - RawOrigin.Y; { Localize y value }
  3198. Tracking := Extent.Contains(Mouse); { Check contains }
  3199. If Tracking Then Begin { Tracking mouse }
  3200. If (Size.X=1) Then
  3201. I := Mouse.Y-FontHeight Else { Calc vert position }
  3202. I := Mouse.X-FontWidth; { Calc horz position }
  3203. If (I < 0) Then I := 0; { Check underflow }
  3204. If (I > S) Then I := S; { Check overflow }
  3205. End Else I := GetPos; { Get position }
  3206. If (I <> P) Then Begin
  3207. SetValue(LongInt((LongInt(I)*(Max-Min))
  3208. +(S SHR 1)) DIV S + Min); { Set new value }
  3209. P := I; { Hold new position }
  3210. End;
  3211. Until NOT MouseEvent(Event, evMouseMove); { Until not moving }
  3212. If Tracking AND (S > 0) Then { Tracking mouse }
  3213. SetValue(LongInt((LongInt(P)*(Max-Min))+
  3214. (S SHR 1)) DIV S + Min); { Set new value }
  3215. If (Iv <> Value) Then Clicked; { Scroll has moved }
  3216. End;
  3217. ClearEvent(Event); { Clear the event }
  3218. End;
  3219. End;
  3220. END;
  3221. {***************************************************************************}
  3222. { TScrollBar OBJECT PRIVATE METHODS }
  3223. {***************************************************************************}
  3224. {--TScrollBar---------------------------------------------------------------}
  3225. { GetPos -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23May98 LdB }
  3226. {---------------------------------------------------------------------------}
  3227. FUNCTION TScrollBar.GetPos: Sw_Integer;
  3228. VAR R: Sw_Integer;
  3229. BEGIN
  3230. R := Max - Min; { Get full range }
  3231. If (R = 0) Then GetPos := 0 Else { Return zero }
  3232. GetPos := LongInt((LongInt(Value-Min) * GetSize)
  3233. + (R SHR 1)) DIV R; { Calc position }
  3234. END;
  3235. {--TScrollBar---------------------------------------------------------------}
  3236. { GetSize -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23May98 LdB }
  3237. {---------------------------------------------------------------------------}
  3238. FUNCTION TScrollBar.GetSize: Sw_Integer;
  3239. VAR S: Sw_Integer;
  3240. BEGIN
  3241. If TextModeGFV then Begin
  3242. If Size.X = 1 Then
  3243. S:= (Size.Y-3)*FontHeight
  3244. else
  3245. S:= (Size.X-3)*FontWidth;
  3246. end else If (Size.X = 1) Then S := RawSize.Y-3*FontHeight+1 { Vertical bar }
  3247. Else S := RawSize.X-3*FontWidth+1; { Horizontal bar }
  3248. If (S < 1) Then S := 1; { Fix minimum size }
  3249. GetSize := S; { Return size }
  3250. END;
  3251. {--TScrollBar---------------------------------------------------------------}
  3252. { DrawPos -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27OctMay99 LdB }
  3253. {---------------------------------------------------------------------------}
  3254. { This could be called from a message handling event so it must check the }
  3255. { view is visible, exposed and not obstructed before drawing the thumbnail }
  3256. { square area. }
  3257. {---------------------------------------------------------------------------}
  3258. PROCEDURE TScrollBar.DrawPos (Pos: Sw_Integer);
  3259. VAR i, X1, Y1, X2, Y2: Sw_Integer; ViewPort: ViewPortType;
  3260. BEGIN
  3261. If (State AND sfVisible <> 0) AND { View is visible }
  3262. (State AND sfExposed <> 0) AND { View is exposed }
  3263. (Max <> Min) Then Begin { View has some size }
  3264. SetViewLimits; { Set view limits }
  3265. GetViewSettings(ViewPort, TextModeGFV); { Get set viewport }
  3266. If OverlapsArea(ViewPort.X1, ViewPort.Y1,
  3267. ViewPort.X2, ViewPort.Y2) Then Begin { Must be in area }
  3268. HideMouseCursor; { Hide the mouse }
  3269. X1 := 0; { Initial x position }
  3270. Y1 := 0; { Initial y position }
  3271. If TextModeGFV then Begin
  3272. If (Size.X = 1) Then Begin { Vertical scrollbar }
  3273. Pos:=Pos div FontHeight;
  3274. WriteChar(0,0,Chars[0],2,1);
  3275. For i:=1 to Size.Y-2 do
  3276. WriteChar(0,i,Chars[2],2,1);
  3277. WriteChar(0,Size.Y-1,Chars[1],2,1);
  3278. End Else Begin
  3279. Pos:=Pos div FontWidth;
  3280. WriteChar(0,0,Chars[0],2,1);
  3281. WriteChar(1,0,Chars[2],2,Size.X-2);
  3282. WriteChar(Size.X-1,0,Chars[1],2,1);
  3283. End;
  3284. If (Size.X=1) Then Y1 := Pos+1 { Vertical bar }
  3285. Else X1 := Pos+1; { Horizontal bar }
  3286. WriteChar(X1,Y1,Chars[3],2,1);
  3287. End Else Begin
  3288. If (Size.X=1) Then Y1 := Pos + FontHeight { Vertical bar }
  3289. Else X1 := Pos + FontWidth; { Horizontal bar }
  3290. X2 := X1 + FontWidth - 1; { Right side point }
  3291. Y2 := Y1 + FontHeight - 1; { Lower side point }
  3292. ClearArea(X1, Y1, X2, Y2, GetColor(2) AND $0F);{ Thumbnail back }
  3293. BiColorRectangle(X1, Y1, X2, Y2, 15, 8, False);{ Draw highlight }
  3294. Y1 := (Y2 + Y1) DIV 2; { Middle of thumb }
  3295. Y2 := Y1+1; { One line down }
  3296. Inc(X1, 1); { One in off left }
  3297. Dec(X2, 1); { One in off right }
  3298. BiColorRectangle(X1, Y1, X2, Y2, 15, 8, True); { Draw line marker }
  3299. End;
  3300. ShowMouseCursor; { Show the mouse }
  3301. End;
  3302. ReleaseViewLimits; { Release the limits }
  3303. End;
  3304. END;
  3305. {--TScrollBar---------------------------------------------------------------}
  3306. { ClearPos -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27Oct99 LdB }
  3307. {---------------------------------------------------------------------------}
  3308. { This could be called from a message handling event so it must check the }
  3309. { view is visible, exposed and not obstructed before clearing the old }
  3310. { thumbnail area. }
  3311. {---------------------------------------------------------------------------}
  3312. PROCEDURE TScrollBar.ClearPos (Pos: Sw_Integer);
  3313. VAR X, Y: Sw_Integer; ViewPort: ViewPortType;
  3314. BEGIN
  3315. If (State AND sfVisible <> 0) AND { View is visible }
  3316. (State AND sfExposed <> 0) Then Begin { View is exposed }
  3317. SetViewLimits; { Set view limits }
  3318. GetViewSettings(ViewPort, TextModeGFV); { Get set viewport }
  3319. If OverlapsArea(ViewPort.X1, ViewPort.Y1,
  3320. ViewPort.X2, ViewPort.Y2) Then Begin { Must be in area }
  3321. HideMouseCursor; { Hide the mouse }
  3322. X := 0; { Initial x position }
  3323. Y := 0; { Initial y position }
  3324. If (Size.X=1) Then Y := Pos + FontHeight { Vertical bar }
  3325. Else X := Pos + FontWidth; { Horizontal bar }
  3326. ClearArea(X, Y, X+FontWidth-1, Y+FontHeight-1,
  3327. GetColor(1) AND $F0 SHR 4); { Clear the area }
  3328. ShowMouseCursor; { Show the mouse }
  3329. End;
  3330. ReleaseViewLimits; { Release the limits }
  3331. End;
  3332. END;
  3333. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3334. { TScroller OBJECT METHODS }
  3335. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3336. {--TScroller----------------------------------------------------------------}
  3337. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3338. {---------------------------------------------------------------------------}
  3339. CONSTRUCTOR TScroller.Init (Var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  3340. BEGIN
  3341. Inherited Init(Bounds); { Call ancestor }
  3342. Options := Options OR ofSelectable; { View is selectable }
  3343. EventMask := EventMask OR evBroadcast; { See broadcasts }
  3344. HScrollBar := AHScrollBar; { Hold horz scrollbar }
  3345. VScrollBar := AVScrollBar; { Hold vert scrollbar }
  3346. END;
  3347. {--TScroller----------------------------------------------------------------}
  3348. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3349. {---------------------------------------------------------------------------}
  3350. { This load method will read old original TV data from a stream as well }
  3351. { as the new graphical scroller views. }
  3352. {---------------------------------------------------------------------------}
  3353. CONSTRUCTOR TScroller.Load (Var S: TStream);
  3354. BEGIN
  3355. Inherited Load(S); { Call ancestor }
  3356. GetPeerViewPtr(S, HScrollBar); { Load horz scrollbar }
  3357. GetPeerViewPtr(S, VScrollBar); { Load vert scrollbar }
  3358. S.Read(Delta.X, 2); { Read delta x value }
  3359. S.Read(Delta.Y, 2); { Read delta y value }
  3360. S.Read(Limit.X, 2); { Read limit x value }
  3361. S.Read(Limit.Y, 2); { Read limit y value }
  3362. END;
  3363. {--TScroller----------------------------------------------------------------}
  3364. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3365. {---------------------------------------------------------------------------}
  3366. FUNCTION TScroller.GetPalette: PPalette;
  3367. CONST P: String[Length(CScroller)] = CScroller; { Always normal string }
  3368. BEGIN
  3369. GetPalette := @P; { Scroller palette }
  3370. END;
  3371. {--TScroller----------------------------------------------------------------}
  3372. { ScrollTo -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  3373. {---------------------------------------------------------------------------}
  3374. PROCEDURE TScroller.ScrollTo (X, Y: Sw_Integer);
  3375. BEGIN
  3376. Inc(DrawLock); { Set draw lock }
  3377. If (HScrollBar<>Nil) Then HScrollBar^.SetValue(X); { Set horz scrollbar }
  3378. If (VScrollBar<>Nil) Then VScrollBar^.SetValue(Y); { Set vert scrollbar }
  3379. Dec(DrawLock); { Release draw lock }
  3380. CheckDraw; { Check need to draw }
  3381. END;
  3382. {--TScroller----------------------------------------------------------------}
  3383. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  3384. {---------------------------------------------------------------------------}
  3385. PROCEDURE TScroller.SetState (AState: Word; Enable: Boolean);
  3386. PROCEDURE ShowSBar (SBar: PScrollBar);
  3387. BEGIN
  3388. If (SBar <> Nil) Then { Scroll bar valid }
  3389. If GetState(sfActive + sfSelected) Then { Check state masks }
  3390. SBar^.Show Else SBar^.Hide; { Draw appropriately }
  3391. END;
  3392. BEGIN
  3393. Inherited SetState(AState, Enable); { Call ancestor }
  3394. If (AState AND (sfActive + sfSelected) <> 0) { Active/select change }
  3395. Then Begin
  3396. ShowSBar(HScrollBar); { Redraw horz scrollbar }
  3397. ShowSBar(VScrollBar); { Redraw vert scrollbar }
  3398. End;
  3399. END;
  3400. {--TScroller----------------------------------------------------------------}
  3401. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3402. {---------------------------------------------------------------------------}
  3403. { The scroller is saved to the stream compatable with the old TV object. }
  3404. {---------------------------------------------------------------------------}
  3405. PROCEDURE TScroller.Store (Var S: TStream);
  3406. BEGIN
  3407. TView.Store(S); { Call TView explicitly }
  3408. PutPeerViewPtr(S, HScrollBar); { Store horz bar }
  3409. PutPeerViewPtr(S, VScrollBar); { Store vert bar }
  3410. S.Write(Delta.X, 2); { Write delta x value }
  3411. S.Write(Delta.Y, 2); { Write delta y value }
  3412. S.Write(Limit.X, 2); { Write limit x value }
  3413. S.Write(Limit.Y, 2); { Write limit y value }
  3414. END;
  3415. {--TScroller----------------------------------------------------------------}
  3416. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  3417. {---------------------------------------------------------------------------}
  3418. PROCEDURE TScroller.HandleEvent (Var Event: TEvent);
  3419. BEGIN
  3420. Inherited HandleEvent(Event); { Call ancestor }
  3421. If (Event.What = evBroadcast) AND
  3422. (Event.Command = cmScrollBarChanged) AND { Scroll bar change }
  3423. ((Event.InfoPtr = HScrollBar) OR { Our scrollbar? }
  3424. (Event.InfoPtr = VScrollBar)) Then ScrollDraw; { Redraw scroller }
  3425. END;
  3426. {--TScroller----------------------------------------------------------------}
  3427. { ChangeBounds -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  3428. {---------------------------------------------------------------------------}
  3429. PROCEDURE TScroller.ChangeBounds (Var Bounds: TRect);
  3430. BEGIN
  3431. SetBounds(Bounds); { Set new bounds }
  3432. Inc(DrawLock); { Set draw lock }
  3433. SetLimit(Limit.X, Limit.Y); { Adjust limits }
  3434. Dec(DrawLock); { Release draw lock }
  3435. DrawFlag := False; { Clear draw flag }
  3436. DrawView; { Redraw now }
  3437. END;
  3438. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3439. { TListViewer OBJECT METHODS }
  3440. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3441. CONST TvListViewerName = 'LISTBOX'; { Native name }
  3442. {--TListViewer--------------------------------------------------------------}
  3443. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  3444. {---------------------------------------------------------------------------}
  3445. CONSTRUCTOR TListViewer.Init (Var Bounds: TRect; ANumCols: Sw_Word; AHScrollBar,
  3446. AVScrollBar: PScrollBar);
  3447. VAR ArStep, PgStep: Sw_Integer;
  3448. BEGIN
  3449. Inherited Init(Bounds); { Call ancestor }
  3450. Options := Options OR (ofFirstClick+ofSelectable); { Set options }
  3451. EventMask := EventMask OR evBroadcast; { Set event mask }
  3452. NumCols := ANumCols; { Hold column number }
  3453. If (AVScrollBar <> Nil) Then Begin { Chk vert scrollbar }
  3454. If (NumCols = 1) Then Begin { Only one column }
  3455. PgStep := Size.Y -1; { Set page size }
  3456. ArStep := 1; { Set step size }
  3457. End Else Begin { Multiple columns }
  3458. PgStep := Size.Y * NumCols; { Set page size }
  3459. ArStep := Size.Y; { Set step size }
  3460. End;
  3461. AVScrollBar^.SetStep(PgStep, ArStep); { Set scroll values }
  3462. End;
  3463. If (AHScrollBar <> Nil) Then
  3464. AHScrollBar^.SetStep(Size.X DIV NumCols, 1); { Set step size }
  3465. HScrollBar := AHScrollBar; { Horz scrollbar held }
  3466. VScrollBar := AVScrollBar; { Vert scrollbar held }
  3467. GOptions := GOptions OR goDrawFocus; { Draw focus changes }
  3468. END;
  3469. {--TListViewer--------------------------------------------------------------}
  3470. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  3471. {---------------------------------------------------------------------------}
  3472. CONSTRUCTOR TListViewer.Load (Var S: TStream);
  3473. BEGIN
  3474. Inherited Load(S); { Call ancestor }
  3475. GetPeerViewPtr(S, HScrollBar); { Get horz scrollbar }
  3476. GetPeerViewPtr(S, VScrollBar); { Get vert scrollbar }
  3477. S.Read(NumCols, 2); { Read column number }
  3478. S.Read(TopItem, 2); { Read top most item }
  3479. S.Read(Focused, 2); { Read focused item }
  3480. S.Read(Range, 2); { Read listview range }
  3481. END;
  3482. {--TListViewer--------------------------------------------------------------}
  3483. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  3484. {---------------------------------------------------------------------------}
  3485. FUNCTION TListViewer.GetPalette: PPalette;
  3486. CONST P: String[Length(CListViewer)] = CListViewer; { Always normal string }
  3487. BEGIN
  3488. GetPalette := @P; { Return palette }
  3489. END;
  3490. {--TListViewer--------------------------------------------------------------}
  3491. { IsSelected -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  3492. {---------------------------------------------------------------------------}
  3493. FUNCTION TListViewer.IsSelected (Item: Sw_Integer): Boolean;
  3494. BEGIN
  3495. If (Item = Focused) Then IsSelected := True Else
  3496. IsSelected := False; { Selected item }
  3497. END;
  3498. {--TListViewer--------------------------------------------------------------}
  3499. { GetText -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May98 LdB }
  3500. {---------------------------------------------------------------------------}
  3501. FUNCTION TListViewer.GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String;
  3502. BEGIN { Abstract method }
  3503. GetText := ''; { Return empty }
  3504. END;
  3505. {--TListViewer--------------------------------------------------------------}
  3506. { DrawBackGround -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27Oct99 LdB }
  3507. {---------------------------------------------------------------------------}
  3508. PROCEDURE TListViewer.DrawBackGround;
  3509. VAR I, J, ColWidth, Item, Indent, CurCol: Sw_Integer; Color: Word;
  3510. Text: String; B: TDrawBuffer;
  3511. BEGIN
  3512. ColWidth := Size.X DIV NumCols + 1; { Calc column width }
  3513. If (HScrollBar = Nil) Then Indent := 0 Else { Set indent to zero }
  3514. Indent := HScrollBar^.Value; { Fetch any indent }
  3515. Inherited DrawBackGround; { Call ancestor }
  3516. Color := GetColor(2); { Normal colour }
  3517. For I := 0 To Size.Y - 1 Do Begin { For each line }
  3518. For J := 0 To NumCols-1 Do Begin { For each column }
  3519. Item := J*Size.Y + I + TopItem; { Process this item }
  3520. CurCol := J*ColWidth; { Current column }
  3521. MoveChar(B[CurCol], ' ', Color, ColWidth); { Clear buffer }
  3522. If (Item < Range) Then Begin { Within text range }
  3523. Text := GetText(Item, ColWidth + Indent); { Fetch text }
  3524. Text := Copy(Text, Indent, ColWidth); { Select right bit }
  3525. MoveStr(B[CurCol+1], Text, Color); { Transfer to buffer }
  3526. If ShowMarkers Then Begin
  3527. WordRec(B[CurCol]).Lo := Byte(
  3528. SpecialChars[4]); { Set marker character }
  3529. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(
  3530. SpecialChars[5]); { Set marker character }
  3531. End;
  3532. End;
  3533. MoveChar(B[CurCol+ColWidth-1], #179,
  3534. GetColor(5), 1); { Put centre line marker }
  3535. End;
  3536. WriteLine(0, I, Size.X-1, 1, B); { Write line to screen }
  3537. End;
  3538. END;
  3539. {--TListViewer--------------------------------------------------------------}
  3540. { DrawFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27Oct99 LdB }
  3541. {---------------------------------------------------------------------------}
  3542. PROCEDURE TListViewer.DrawFocus;
  3543. VAR DrawIt: Boolean; SCOff: Byte; I, J, Item, CurCol, ColWidth: Sw_Integer;
  3544. Color: Word;
  3545. Indent: Sw_Integer;
  3546. B: TDrawBuffer;
  3547. Text: String;
  3548. BEGIN
  3549. ColWidth := Size.X DIV NumCols + 1; { Calc column width }
  3550. If (HScrollBar = Nil) Then Indent := 0 Else { Set indent to zero }
  3551. Indent := HScrollBar^.Value; { Fetch any indent }
  3552. For I := 0 To Size.Y - 1 Do Begin { For each line }
  3553. For J := 0 To NumCols-1 Do Begin { For each column }
  3554. Item := J*Size.Y + I + TopItem; { Process this item }
  3555. CurCol := J*ColWidth; { Current column }
  3556. DrawIt := False; { Preset false }
  3557. If (State AND (sfSelected + sfActive) =
  3558. (sfSelected + sfActive)) AND (Focused = Item) { Focused item }
  3559. AND (Range > 0) Then Begin
  3560. DrawIt := True; { Draw this item }
  3561. Color := GetColor(3); { Focused colour }
  3562. SetCursor(CurCol+1,I); { Set the cursor }
  3563. SCOff := 0; { Zero colour offset }
  3564. End Else If (Item < Range) AND IsSelected(Item){ Selected item }
  3565. Then Begin
  3566. DrawIt := True; { Draw this item }
  3567. If (State AND sfActive <> 0) Then
  3568. Color := GetColor(4) Else { Selected colour }
  3569. Color := GetColor(2); { Remove focus }
  3570. SCOff := 2; { Colour offset=2 }
  3571. End;
  3572. If DrawIt Then Begin { We are drawing item }
  3573. ClearArea(CurCol*FontWidth, I*FontHeight, (CurCol+ColWidth-1)*FontWidth,
  3574. (I+1)*FontHeight-1, Color AND $F0 SHR 4); { Draw the bar }
  3575. MoveChar(B[CurCol], ' ', Color, ColWidth);
  3576. if Item < Range then begin
  3577. Text := GetText(Item, ColWidth + Indent);
  3578. Text := Copy(Text,Indent,ColWidth);
  3579. MoveStr(B[CurCol+1], Text, Color);
  3580. if ShowMarkers then begin
  3581. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  3582. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  3583. end;
  3584. end;
  3585. { MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);}
  3586. WriteLine(CurCol, I, Min(Size.X-1,CurCol+ColWidth-2), 1, B[CurCol]);
  3587. End;
  3588. End;
  3589. End;
  3590. END;
  3591. {--TListViewer--------------------------------------------------------------}
  3592. { DrawLoseFocus -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27Oct99 LdB }
  3593. {---------------------------------------------------------------------------}
  3594. PROCEDURE TListViewer.DrawLoseFocus;
  3595. VAR DrawIt: Boolean; SCOff: Byte; I, J, Item, CurCol, ColWidth: Sw_Integer;
  3596. Color: Word;
  3597. Indent: Sw_Integer;
  3598. B: TDrawBuffer;
  3599. Text: String;
  3600. BEGIN
  3601. ColWidth := Size.X DIV NumCols + 1; { Calc column width }
  3602. If (HScrollBar = Nil) Then Indent := 0 Else { Set indent to zero }
  3603. Indent := HScrollBar^.Value; { Fetch any indent }
  3604. For I := 0 To Size.Y - 1 Do Begin { For each line }
  3605. For J := 0 To NumCols-1 Do Begin { For each column }
  3606. Item := J*Size.Y + I + TopItem; { Process this item }
  3607. CurCol := J*ColWidth; { Current column }
  3608. DrawIt := False; { Preset false }
  3609. If (State AND (sfSelected + sfActive) =
  3610. (sfSelected + sfActive)) AND (Focused = Item) { Focused item }
  3611. AND (Range > 0) Then Begin
  3612. DrawIt := True; { Draw this item }
  3613. Color := GetColor(2); { Focused colour }
  3614. SetCursor(CurCol+1,I); { Set the cursor }
  3615. SCOff := 2; { Zero colour offset }
  3616. End Else If (Item < Range) AND IsSelected(Item){ Selected item }
  3617. Then Begin
  3618. DrawIt := True; { Draw this item }
  3619. Color := GetColor(2); { Remove focus }
  3620. SCOff := 2; { Colour offset=2 }
  3621. End;
  3622. If DrawIt Then Begin { We are drawing item }
  3623. ClearArea(CurCol*FontWidth, I*FontHeight, (CurCol+ColWidth-1)*FontWidth,
  3624. (I+1)*FontHeight-1, Color AND $F0 SHR 4); { Draw the bar }
  3625. MoveChar(B[CurCol], ' ', Color, ColWidth);
  3626. if Item < Range then begin
  3627. Text := GetText(Item, ColWidth + Indent);
  3628. Text := Copy(Text,Indent,ColWidth);
  3629. MoveStr(B[CurCol+1], Text, Color);
  3630. if ShowMarkers then begin
  3631. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  3632. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  3633. end;
  3634. end;
  3635. { MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);}
  3636. WriteLine(CurCol, I, Min(Size.X-1,CurCol+ColWidth-2), 1, B[CurCol]);
  3637. End;
  3638. End;
  3639. End;
  3640. END;
  3641. {--TListViewer--------------------------------------------------------------}
  3642. { FocusItem -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3643. {---------------------------------------------------------------------------}
  3644. PROCEDURE TListViewer.FocusItem (Item: Sw_Integer);
  3645. BEGIN
  3646. If Focused<>Item then
  3647. DrawLoseFocus;
  3648. Focused := Item; { Set focus to item }
  3649. If (VScrollBar <> Nil) Then
  3650. VScrollBar^.SetValue(Item); { Scrollbar to value }
  3651. If (Item < TopItem) Then { Item above top item }
  3652. If (NumCols = 1) Then TopItem := Item { Set top item }
  3653. Else TopItem := Item - Item MOD Size.Y { Set top item }
  3654. Else If (Item >= TopItem + (Size.Y*NumCols)) Then { Item below bottom }
  3655. If (NumCols = 1) Then TopItem := Item-Size.Y+1 { Set new top item }
  3656. Else TopItem := Item - Item MOD Size.Y -
  3657. (Size.Y*(NumCols-1)); { Set new top item }
  3658. END;
  3659. {--TListViewer--------------------------------------------------------------}
  3660. { SetTopItem -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06Aug99 LdB }
  3661. {---------------------------------------------------------------------------}
  3662. PROCEDURE TListViewer.SetTopItem (Item: Sw_Integer);
  3663. BEGIN
  3664. TopItem := Item; { Set the top item }
  3665. END;
  3666. {--TListViewer--------------------------------------------------------------}
  3667. { SetRange -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3668. {---------------------------------------------------------------------------}
  3669. PROCEDURE TListViewer.SetRange (ARange: Sw_Integer);
  3670. BEGIN
  3671. Range := ARange; { Set new range }
  3672. If (VScrollBar <> Nil) Then Begin { Vertical scrollbar }
  3673. If (Focused > ARange) Then Focused := 0; { Clear focused }
  3674. VScrollBar^.SetParams(Focused, 0, ARange - 1,
  3675. VScrollBar^.PgStep, VScrollBar^.ArStep); { Set parameters }
  3676. End;
  3677. END;
  3678. {--TListViewer--------------------------------------------------------------}
  3679. { SelectItem -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3680. {---------------------------------------------------------------------------}
  3681. PROCEDURE TListViewer.SelectItem (Item: Sw_Integer);
  3682. BEGIN
  3683. Message(Owner, evBroadcast, cmListItemSelected,
  3684. @Self); { Send message }
  3685. END;
  3686. {--TListViewer--------------------------------------------------------------}
  3687. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27Oct99 LdB }
  3688. {---------------------------------------------------------------------------}
  3689. PROCEDURE TListViewer.SetState (AState: Word; Enable: Boolean);
  3690. PROCEDURE ShowSBar(SBar: PScrollBar);
  3691. BEGIN
  3692. If (SBar <> Nil) Then { Valid scrollbar }
  3693. If GetState(sfActive) AND GetState(sfVisible) { Check states }
  3694. Then SBar^.Show Else SBar^.Hide; { Show or hide }
  3695. END;
  3696. PROCEDURE LoseFocus;
  3697. VAR Cs: Sw_Integer;
  3698. BEGIN
  3699. If (GOptions AND goNativeClass = 0) Then Begin { Not in native mode }
  3700. Cs := State; { Hold current state }
  3701. State := State AND NOT sfActive; { Must remove focus }
  3702. SetDrawmask(vdFocus); { Set focus mask }
  3703. DrawView; { Remove focus box }
  3704. State := Cs; { Reset state masks }
  3705. End;
  3706. END;
  3707. BEGIN
  3708. Inherited SetState(AState, Enable); { Call ancestor }
  3709. If (AState AND sfFocused <> 0) Then { Focus change }
  3710. If NOT Enable Then LoseFocus; { Redraw drop focus }
  3711. If (AState AND (sfSelected + sfActive + sfVisible) <> 0)
  3712. Then Begin { Check states }
  3713. SetDrawMask(vdFocus);
  3714. DrawView; { Draw the view }
  3715. ShowSBar(HScrollBar); { Show horz scrollbar }
  3716. ShowSBar(VScrollBar); { Show vert scrollbar }
  3717. End;
  3718. END;
  3719. {--TListViewer--------------------------------------------------------------}
  3720. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3721. {---------------------------------------------------------------------------}
  3722. PROCEDURE TListViewer.Store (Var S: TStream);
  3723. BEGIN
  3724. TView.Store(S); { Call TView explicitly }
  3725. PutPeerViewPtr(S, HScrollBar); { Put horz scrollbar }
  3726. PutPeerViewPtr(S, VScrollBar); { Put vert scrollbar }
  3727. S.Write(NumCols, 2); { Write column number }
  3728. S.Write(TopItem, 2); { Write top most item }
  3729. S.Write(Focused, 2); { Write focused item }
  3730. S.Write(Range, 2); { Write listview range }
  3731. END;
  3732. {--TListViewer--------------------------------------------------------------}
  3733. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 27Oct99 LdB }
  3734. {---------------------------------------------------------------------------}
  3735. PROCEDURE TListViewer.HandleEvent (Var Event: TEvent);
  3736. CONST MouseAutosToSkip = 4;
  3737. VAR Oi, Ni: Sw_Integer; Ct, Cw: Word; Mouse: TPoint;
  3738. PROCEDURE MoveFocus (Req: Sw_Integer);
  3739. VAR Ti, Cs: Sw_Integer;
  3740. BEGIN
  3741. If (GOptions AND goNativeClass = 0) Then Begin { Not in native mode }
  3742. Ti := TopItem; { Hold top item }
  3743. Cs := State; { Hold current state }
  3744. State := State AND NOT sfActive; { Must remove focus }
  3745. SetDrawmask(vdFocus); { Set focus mask }
  3746. DrawView; { Remove focus box }
  3747. State := Cs; { Reset state masks }
  3748. End;
  3749. FocusItemNum(Req); { Focus req item }
  3750. If (GOptions AND goNativeClass = 0) Then Begin { Not in native mode }
  3751. If (Ti <> TopItem) Then DrawView Else Begin { Redraw all view }
  3752. SetDrawmask(vdFocus); { Set focus mask }
  3753. DrawView; { Redraw focus box }
  3754. End;
  3755. End;
  3756. END;
  3757. BEGIN
  3758. Inherited HandleEvent(Event); { Call ancestor }
  3759. Case Event.What Of
  3760. evNothing: Exit; { Speed up exit }
  3761. evKeyDown: Begin { Key down event }
  3762. If (Event.CharCode = ' ') AND (Focused < Range){ Spacebar select }
  3763. Then Begin
  3764. SelectItem(Focused); { Select focused item }
  3765. Ni := Focused; { Hold new item }
  3766. End Else Case CtrlToArrow(Event.KeyCode) Of
  3767. kbUp: Ni := Focused - 1; { One item up }
  3768. kbDown: Ni := Focused + 1; { One item down }
  3769. kbRight: If (NumCols > 1) Then
  3770. Ni := Focused + Size.Y Else Exit; { One column right }
  3771. kbLeft: If (NumCols > 1) Then
  3772. Ni := Focused - Size.Y Else Exit; { One column left }
  3773. kbPgDn: Ni := Focused + Size.Y * NumCols; { One page down }
  3774. kbPgUp: Ni := Focused - Size.Y * NumCols; { One page up }
  3775. kbHome: Ni := TopItem; { Move to top }
  3776. kbEnd: Ni := TopItem + (Size.Y*NumCols)-1; { Move to bottom }
  3777. kbCtrlPgDn: Ni := Range - 1; { Move to last item }
  3778. kbCtrlPgUp: Ni := 0; { Move to first item }
  3779. Else Exit;
  3780. End;
  3781. MoveFocus(Ni); { Move the focus }
  3782. ClearEvent(Event); { Event was handled }
  3783. End;
  3784. evBroadcast: Begin { Broadcast event }
  3785. If (Options AND ofSelectable <> 0) Then { View is selectable }
  3786. If (Event.Command = cmScrollBarClicked) AND { Scrollbar click }
  3787. ((Event.InfoPtr = HScrollBar) OR
  3788. (Event.InfoPtr = VScrollBar)) Then Select { Scrollbar selects us }
  3789. Else If (Event.Command = cmScrollBarChanged) { Scrollbar changed }
  3790. Then Begin
  3791. If (VScrollBar = Event.InfoPtr) Then Begin
  3792. MoveFocus(VScrollBar^.Value); { Focus us to item }
  3793. End Else If (HScrollBar = Event.InfoPtr)
  3794. Then DrawView; { Redraw the view }
  3795. End;
  3796. End;
  3797. evMouseDown: Begin { Mouse down event }
  3798. Cw := Size.X DIV NumCols + 1; { Column width }
  3799. Oi := Focused; { Hold focused item }
  3800. MakeLocal(Event.Where, Mouse); { Localize mouse }
  3801. If MouseInView(Event.Where) Then Ni := Mouse.Y
  3802. + (Size.Y*(Mouse.X DIV Cw))+TopItem { Calc item to focus }
  3803. Else Ni := Oi; { Focus old item }
  3804. Ct := 0; { Clear count value }
  3805. Repeat
  3806. If (Ni <> Oi) Then Begin { Item is different }
  3807. MoveFocus(Ni); { Move the focus }
  3808. Oi := Focused; { Hold as focused item }
  3809. End;
  3810. MakeLocal(Event.Where, Mouse); { Localize mouse }
  3811. If NOT MouseInView(Event.Where) Then Begin
  3812. If (Event.What = evMouseAuto) Then Inc(Ct);{ Inc auto count }
  3813. If (Ct = MouseAutosToSkip) Then Begin
  3814. Ct := 0; { Reset count }
  3815. If (NumCols = 1) Then Begin { Only one column }
  3816. If (Mouse.Y < 0) Then Ni := Focused-1; { Move up one item }
  3817. If (Mouse.Y >= Size.Y) Then
  3818. Ni := Focused+1; { Move down one item }
  3819. End Else Begin { Multiple columns }
  3820. If (Mouse.X < 0) Then { Mouse x below zero }
  3821. Ni := Focused-Size.Y; { Move down 1 column }
  3822. If (Mouse.X >= Size.X) Then { Mouse x above width }
  3823. Ni := Focused+Size.Y; { Move up 1 column }
  3824. If (Mouse.Y < 0) Then { Mouse y below zero }
  3825. Ni := Focused-Focused MOD Size.Y; { Move up one item }
  3826. If (Mouse.Y > Size.Y) Then { Mouse y above height }
  3827. Ni := Focused-Focused MOD
  3828. Size.Y+Size.Y-1; { Move down one item }
  3829. End;
  3830. End;
  3831. End Else Ni := Mouse.Y + (Size.Y*(Mouse.X
  3832. DIV Cw))+TopItem; { New item to focus }
  3833. Until NOT MouseEvent(Event, evMouseMove +
  3834. evMouseAuto); { Mouse stopped }
  3835. If (Oi <> Ni) Then MoveFocus(Ni); { Focus moved again }
  3836. If (Event.Double AND (Range > Focused)) Then
  3837. SelectItem(Focused); { Select the item }
  3838. ClearEvent(Event); { Event was handled }
  3839. End;
  3840. End;
  3841. END;
  3842. {--TListViewer--------------------------------------------------------------}
  3843. { ChangeBounds -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  3844. {---------------------------------------------------------------------------}
  3845. PROCEDURE TListViewer.ChangeBounds (Var Bounds: TRect);
  3846. BEGIN
  3847. Inherited ChangeBounds(Bounds); { Call ancestor }
  3848. If (HScrollBar <> Nil) Then { Valid horz scrollbar }
  3849. HScrollBar^.SetStep(Size.X DIV NumCols,
  3850. HScrollBar^.ArStep); { Update horz bar }
  3851. If (VScrollBar <> Nil) Then { Valid vert scrollbar }
  3852. VScrollBar^.SetStep(Size.Y * NumCols,
  3853. VScrollBar^.ArStep); { Update vert bar }
  3854. END;
  3855. {***************************************************************************}
  3856. { TListViewer OBJECT PRIVATE METHODS }
  3857. {***************************************************************************}
  3858. {--TListViewer--------------------------------------------------------------}
  3859. { FocusItemNum -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 26Jul99 LdB }
  3860. {---------------------------------------------------------------------------}
  3861. PROCEDURE TListViewer.FocusItemNum (Item: Sw_Integer);
  3862. BEGIN
  3863. If (Item < 0) Then Item := 0 Else { Restrain underflow }
  3864. If (Item >= Range) AND (Range > 0) Then
  3865. Item := Range-1; { Restrain overflow }
  3866. If (Range <> 0) Then FocusItem(Item); { Set focus value }
  3867. END;
  3868. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3869. { TWindow OBJECT METHODS }
  3870. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3871. {--TWindow------------------------------------------------------------------}
  3872. { Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  3873. {---------------------------------------------------------------------------}
  3874. CONSTRUCTOR TWindow.Init (Var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer);
  3875. BEGIN
  3876. Inherited Init(Bounds); { Call ancestor }
  3877. State := State OR sfShadow; { View is shadowed }
  3878. Options := Options OR (ofSelectable+ofTopSelect); { Select options set }
  3879. GrowMode := gfGrowAll + gfGrowRel; { Set growmodes }
  3880. Flags := wfMove + wfGrow + wfClose + wfZoom; { Set flags }
  3881. Title := NewStr(ATitle); { Hold title }
  3882. Number := ANumber; { Hold number }
  3883. Palette := wpBlueWindow; { Default palette }
  3884. GOptions := GOptions OR goThickFramed; { Thick frame }
  3885. GOptions := GOptions OR goTitled; { Title window }
  3886. GOptions := GOptions AND NOT goNoDrawView; { View does draw self }
  3887. InitFrame; { Initialize frame }
  3888. If (Frame <> Nil) Then Insert(Frame); { Insert any frame }
  3889. GetBounds(ZoomRect); { Default zoom rect }
  3890. END;
  3891. {--TWindow------------------------------------------------------------------}
  3892. { Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  3893. {---------------------------------------------------------------------------}
  3894. { This load method will read old original TV data from a stream however }
  3895. { although a frame view is read for compatability it is disposed of. }
  3896. {---------------------------------------------------------------------------}
  3897. CONSTRUCTOR TWindow.Load (Var S: TStream);
  3898. BEGIN
  3899. Inherited Load(S); { Call ancestor }
  3900. S.Read(Flags, 1); { Read window flags }
  3901. S.Read(Number, 2); { Read window number }
  3902. S.Read(Palette, 2); { Read window palette }
  3903. S.Read(ZoomRect.A.X, 2); { Read zoom area x1 }
  3904. S.Read(ZoomRect.A.Y, 2); { Read zoom area y1 }
  3905. S.Read(ZoomRect.B.X, 2); { Read zoom area x2 }
  3906. S.Read(ZoomRect.B.Y, 2); { Read zoom area y2 }
  3907. GetSubViewPtr(S, Frame); { Now read frame object }
  3908. If (Frame <> Nil) Then Begin
  3909. Dispose(Frame, Done); { Kill we don't use it }
  3910. Frame := Nil; { Clear the pointer }
  3911. End;
  3912. Title := S.ReadStr; { Read title }
  3913. END;
  3914. {--TWindow------------------------------------------------------------------}
  3915. { Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  3916. {---------------------------------------------------------------------------}
  3917. DESTRUCTOR TWindow.Done;
  3918. BEGIN
  3919. Inherited Done; { Call ancestor }
  3920. If (Title <> Nil) Then DisposeStr(Title); { Dispose title }
  3921. END;
  3922. {--TWindow------------------------------------------------------------------}
  3923. { GetPalette -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  3924. {---------------------------------------------------------------------------}
  3925. FUNCTION TWindow.GetPalette: PPalette;
  3926. CONST P: ARRAY [wpBlueWindow..wpGrayWindow] Of String[Length(CBlueWindow)] =
  3927. (CBlueWindow, CCyanWindow, CGrayWindow); { Always normal string }
  3928. BEGIN
  3929. GetPalette := @P[Palette]; { Return palette }
  3930. END;
  3931. {--TWindow------------------------------------------------------------------}
  3932. { GetTitle -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  3933. {---------------------------------------------------------------------------}
  3934. FUNCTION TWindow.GetTitle (MaxSize: Sw_Integer): TTitleStr;
  3935. VAR S: String;
  3936. BEGIN
  3937. If (Number <> 0) Then begin { Valid window number }
  3938. Str(Number, S); { Window number }
  3939. S := '(' + S + ') '; { Insert in brackets }
  3940. End Else S := ''; { Empty string }
  3941. If (Title <> Nil) Then GetTitle := S + Title^
  3942. Else GetTitle := S; { Return title }
  3943. END;
  3944. {--TWindow------------------------------------------------------------------}
  3945. { StandardScrollBar -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  3946. {---------------------------------------------------------------------------}
  3947. FUNCTION TWindow.StandardScrollBar (AOptions: Word): PScrollBar;
  3948. VAR R: TRect; S: PScrollBar;
  3949. BEGIN
  3950. GetExtent(R); { View extents }
  3951. If (AOptions AND sbVertical = 0) Then
  3952. R.Assign(R.A.X+2, R.B.Y-1, R.B.X-2, R.B.Y) { Horizontal scrollbar }
  3953. Else R.Assign(R.B.X-1, R.A.Y+1, R.B.X, R.B.Y-1); { Vertical scrollbar }
  3954. S := New(PScrollBar, Init(R)); { Create scrollbar }
  3955. Insert(S); { Insert scrollbar }
  3956. If (AOptions AND sbHandleKeyboard <> 0) Then
  3957. S^.Options := S^.Options or ofPostProcess; { Post process }
  3958. StandardScrollBar := S; { Return scrollbar }
  3959. END;
  3960. {--TWindow------------------------------------------------------------------}
  3961. { Zoom -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23Sep97 LdB }
  3962. {---------------------------------------------------------------------------}
  3963. PROCEDURE TWindow.Zoom;
  3964. VAR R: TRect; Max, Min: TPoint;
  3965. BEGIN
  3966. SizeLimits(Min, Max); { Return size limits }
  3967. If ((Size.X <> Max.X) OR (Size.Y <> Max.Y)) { Larger size possible }
  3968. Then Begin
  3969. GetBounds(ZoomRect); { Get zoom bounds }
  3970. R.A.X := 0; { Zero x origin }
  3971. R.A.Y := 0; { Zero y origin }
  3972. R.B := Max; { Bounds to max size }
  3973. Locate(R); { Locate the view }
  3974. End Else Locate(ZoomRect); { Move to zoom rect }
  3975. END;
  3976. {--TWindow------------------------------------------------------------------}
  3977. { Close -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 23Sep97 LdB }
  3978. {---------------------------------------------------------------------------}
  3979. PROCEDURE TWindow.Close;
  3980. BEGIN
  3981. If Valid(cmClose) Then Free; { Dispose of self }
  3982. END;
  3983. {--TWindow------------------------------------------------------------------}
  3984. { InitFrame -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Jul99 LdB }
  3985. {---------------------------------------------------------------------------}
  3986. PROCEDURE TWindow.InitFrame;
  3987. BEGIN { Compatability only }
  3988. END;
  3989. {--TWindow------------------------------------------------------------------}
  3990. { SetState -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Mar98 LdB }
  3991. {---------------------------------------------------------------------------}
  3992. PROCEDURE TWindow.SetState (AState: Word; Enable: Boolean);
  3993. VAR WindowCommands: TCommandSet;
  3994. BEGIN
  3995. Inherited SetState(AState, Enable); { Call ancestor }
  3996. If (AState = sfSelected) Then
  3997. SetState(sfActive, Enable); { Set active state }
  3998. If (AState = sfSelected) OR ((AState = sfExposed)
  3999. AND (State AND sfSelected <> 0)) Then Begin { View is selected }
  4000. WindowCommands := [cmNext, cmPrev]; { Set window commands }
  4001. If (Flags AND (wfGrow + wfMove) <> 0) Then
  4002. WindowCommands := WindowCommands + [cmResize]; { Add resize command }
  4003. If (Flags AND wfClose <> 0) Then
  4004. WindowCommands := WindowCommands + [cmClose]; { Add close command }
  4005. If (Flags AND wfZoom <> 0) Then
  4006. WindowCommands := WindowCommands + [cmZoom]; { Add zoom command }
  4007. If Enable Then EnableCommands(WindowCommands) { Enable commands }
  4008. Else DisableCommands(WindowCommands); { Disable commands }
  4009. End;
  4010. END;
  4011. {--TWindow------------------------------------------------------------------}
  4012. { Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Mar98 LdB }
  4013. {---------------------------------------------------------------------------}
  4014. { You can save data to the stream compatable with the old original TV by }
  4015. { temporarily turning off the ofGrafVersion making the call to this store }
  4016. { routine and resetting the ofGrafVersion flag after the call. }
  4017. {---------------------------------------------------------------------------}
  4018. PROCEDURE TWindow.Store (Var S: TStream);
  4019. BEGIN
  4020. TGroup.Store(S); { Call group store }
  4021. S.Write(Flags, 1); { Write window flags }
  4022. S.Write(Number, 2); { Write window number }
  4023. S.Write(Palette, 2); { Write window palette }
  4024. S.Write(ZoomRect.A.X, 2); { Write zoom area x1 }
  4025. S.Write(ZoomRect.A.Y, 2); { Write zoom area y1 }
  4026. S.Write(ZoomRect.B.X, 2); { Write zoom area x2 }
  4027. S.Write(ZoomRect.B.Y, 2); { Write zoom area y2 }
  4028. PutSubViewPtr(S, Frame); { Write any frame }
  4029. S.WriteStr(Title); { Write title string }
  4030. END;
  4031. {--TWindow------------------------------------------------------------------}
  4032. { HandleEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 11Aug99 LdB }
  4033. {---------------------------------------------------------------------------}
  4034. PROCEDURE TWindow.HandleEvent (Var Event: TEvent);
  4035. VAR I, J: Sw_Integer;
  4036. Min, Max: TPoint; Limits: TRect;
  4037. PROCEDURE DragWindow (Mode: Byte);
  4038. VAR Limits: TRect; Min, Max: TPoint;
  4039. BEGIN
  4040. Owner^.GetExtent(Limits); { Get owner extents }
  4041. SizeLimits(Min, Max); { Restrict size }
  4042. DragView(Event, DragMode OR Mode, Limits, Min,
  4043. Max); { Drag the view }
  4044. ClearEvent(Event); { Clear the event }
  4045. END;
  4046. BEGIN
  4047. Inherited HandleEvent(Event); { Call ancestor }
  4048. Case Event.What Of
  4049. evNothing: Exit; { Speeds up exit }
  4050. evCommand: { COMMAND EVENT }
  4051. Case Event.Command Of { Command type case }
  4052. cmResize: { RESIZE COMMAND }
  4053. If (Flags AND (wfMove + wfGrow) <> 0) { Window can resize }
  4054. AND (Owner <> Nil) Then Begin { Valid owner }
  4055. Owner^.GetExtent(Limits); { Owners extents }
  4056. SizeLimits(Min, Max); { Check size limits }
  4057. DragView(Event, DragMode OR (Flags AND
  4058. (wfMove + wfGrow)), Limits, Min, Max); { Drag the view }
  4059. ClearEvent(Event); { Clear the event }
  4060. End;
  4061. cmClose: { CLOSE COMMAND }
  4062. If (Flags AND wfClose <> 0) AND { Close flag set }
  4063. ((Event.InfoPtr = Nil) OR { None specific close }
  4064. (Event.InfoPtr = @Self)) Then Begin { Close to us }
  4065. ClearEvent(Event); { Clear the event }
  4066. If (State AND sfModal = 0) Then Close { Non modal so close }
  4067. Else Begin { Modal window }
  4068. Event.What := evCommand; { Command event }
  4069. Event.Command := cmCancel; { Cancel command }
  4070. PutEvent(Event); { Place on queue }
  4071. ClearEvent(Event); { Clear the event }
  4072. End;
  4073. End;
  4074. cmZoom: { ZOOM COMMAND }
  4075. If (Flags AND wfZoom <> 0) AND { Zoom flag set }
  4076. ((Event.InfoPtr = Nil) OR { No specific zoom }
  4077. (Event.InfoPtr = @Self)) Then Begin
  4078. Zoom; { Zoom our window }
  4079. ClearEvent(Event); { Clear the event }
  4080. End;
  4081. End;
  4082. evBroadcast: { BROADCAST EVENT }
  4083. If (Event.Command = cmSelectWindowNum) AND
  4084. (Event.InfoInt = Number) AND { Select our number }
  4085. (Options AND ofSelectable <> 0) Then Begin { Is view selectable }
  4086. Select; { Select our view }
  4087. ClearEvent(Event); { Clear the event }
  4088. End;
  4089. evKeyDown: Begin { KEYDOWN EVENT }
  4090. Case Event.KeyCode Of
  4091. kbTab: Begin { TAB KEY }
  4092. FocusNext(False); { Select next view }
  4093. ClearEvent(Event); { Clear the event }
  4094. End;
  4095. kbShiftTab: Begin { SHIFT TAB KEY }
  4096. FocusNext(True); { Select prior view }
  4097. ClearEvent(Event); { Clear the event }
  4098. End;
  4099. End;
  4100. End;
  4101. evMouseDown: { MOUSE DOWN EVENT }
  4102. If (GOptions AND goTitled <> 0) Then Begin { Must have title area }
  4103. If TextModeGFV then
  4104. I:=0 Else
  4105. If (GOptions AND goThickFramed <> 0) Then
  4106. I := 5 Else { Thick frame adjust }
  4107. If (Options AND ofFramed <> 0) Then I := 1 { Frame adjust }
  4108. Else I := 0; { No frame size }
  4109. If (Event.Where.Y >= (RawOrigin.Y + I)) AND
  4110. (Event.Where.Y < RawOrigin.Y+FontHeight+I)
  4111. Then Begin { Within top line }
  4112. If (Current <> Nil) AND
  4113. (Current^.Options AND ofSelectable <> 0)
  4114. Then Current^.FocusFromTop Else
  4115. FocusFromTop;
  4116. If (Flags AND wfClose <> 0) Then Begin { Has close icon }
  4117. J := I + 2*FontWidth; { Set X value }
  4118. If (Event.Where.X >= RawOrigin.X+J) AND
  4119. (Event.Where.X < RawOrigin.X+J+3*FontWidth)
  4120. Then Begin { In close area }
  4121. Event.What := evCommand; { Command event }
  4122. Event.Command := cmClose; { Close command }
  4123. Event.InfoPtr := Nil; { Clear pointer }
  4124. PutEvent(Event); { Put event on queue }
  4125. ClearEvent(Event); { Clear the event }
  4126. Exit; { Now exit }
  4127. End;
  4128. End;
  4129. If (Owner <> Nil) AND (Flags AND wfMove <> 0)
  4130. Then DragWindow(dmDragMove); { Drag the window }
  4131. End Else If (Event.Where.X >= RawOrigin.X + RawSize.X-2*FontWidth) AND
  4132. (Event.Where.Y >= RawOrigin.Y + RawSize.Y - FontHeight)
  4133. Then If (Flags AND wfGrow <> 0) Then { Check grow flags }
  4134. DragWindow(dmDragGrow); { Change window size }
  4135. End;
  4136. End; { Event.What case end }
  4137. END;
  4138. {--TWindow------------------------------------------------------------------}
  4139. { SizeLimits -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB }
  4140. {---------------------------------------------------------------------------}
  4141. PROCEDURE TWindow.SizeLimits (Var Min, Max: TPoint);
  4142. BEGIN
  4143. Inherited SizeLimits(Min, Max); { View size limits }
  4144. Min.X := MinWinSize.X; { Set min x size }
  4145. Min.Y := MinWinSize.Y; { Set min y size }
  4146. END;
  4147. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  4148. { UNCOMPLETED OBJECT METHODS }
  4149. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  4150. {--TView--------------------------------------------------------------------}
  4151. { Exposed -> Platforms DOS/DPMI/WIN/OS2 - Checked 17Sep97 LdB }
  4152. {---------------------------------------------------------------------------}
  4153. { This needs big help!!!!! }
  4154. FUNCTION TView.Exposed: Boolean;
  4155. VAR ViewPort: ViewPortType;
  4156. BEGIN
  4157. GetViewSettings(ViewPort, TextModeGFV); { Fetch viewport }
  4158. If (State AND sfVisible<>0) AND { View visible }
  4159. (State AND sfExposed<>0) AND { View exposed }
  4160. OverlapsArea(ViewPort.X1, ViewPort.Y1,
  4161. ViewPort.X2, ViewPort.Y2) Then Exposed := True { Must be exposed }
  4162. Else Exposed := False; { Is hidden }
  4163. END;
  4164. {--TView--------------------------------------------------------------------}
  4165. { GraphLine -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22Sep99 LdB }
  4166. {---------------------------------------------------------------------------}
  4167. PROCEDURE TView.GraphLine (X1, Y1, X2, Y2: Sw_Integer; Colour: Byte);
  4168. VAR ViewPort: ViewPortType;
  4169. BEGIN
  4170. GetViewSettings(ViewPort, TextModeGFV); { Get viewport settings }
  4171. If (TextModeGFV <> TRUE) Then Begin
  4172. SetColor(Colour); { Set line colour }
  4173. Line(RawOrigin.X + X1 - ViewPort.X1,
  4174. RawOrigin.Y + Y1 - ViewPort.Y1, RawOrigin.X + X2
  4175. - ViewPort.X1, RawOrigin.Y + Y2-ViewPort.Y1); { Draw the line }
  4176. End Else Begin { LEON???? }
  4177. End;
  4178. END;
  4179. PROCEDURE TView.GraphRectangle (X1, Y1, X2, Y2: Sw_Integer; Colour: Byte);
  4180. VAR ViewPort: ViewPortType;
  4181. BEGIN
  4182. If (TextModeGFV <> TRUE) Then Begin { GRAPHICS MODE GFV }
  4183. SetColor(Colour); { Set line colour }
  4184. GetViewSettings(ViewPort, TextModeGFV);
  4185. Rectangle(RawOrigin.X + X1 - ViewPort.X1, RawOrigin.Y + Y1
  4186. - ViewPort.Y1, RawOrigin.X + X2 - ViewPort.X1,
  4187. RawOrigin.Y+Y2-ViewPort.Y1); { Draw a rectangle }
  4188. End Else Begin { LEON???? }
  4189. End;
  4190. END;
  4191. {--TView--------------------------------------------------------------------}
  4192. { ClearArea -> Platforms DOS/DPMI/WIN/OS2 - Checked 19Sep97 LdB }
  4193. {---------------------------------------------------------------------------}
  4194. PROCEDURE TView.ClearArea (X1, Y1, X2, Y2: Sw_Integer; Colour: Byte);
  4195. VAR
  4196. X, Y: Sw_Integer; ViewPort: ViewPortType;
  4197. Buf : TDrawBuffer;
  4198. BEGIN
  4199. GetViewSettings(ViewPort, TextModeGFV); { Get viewport }
  4200. If not TextModeGFV and not UseFixedFont Then Begin { GRAPHICAL GFV MODE }
  4201. SetFillStyle(SolidFill, Colour); { Set colour up }
  4202. Bar(RawOrigin.X+X1-ViewPort.X1, RawOrigin.Y+Y1-
  4203. ViewPort.Y1, RawOrigin.X+X2-ViewPort.X1,
  4204. RawOrigin.Y+Y2-ViewPort.Y1); { Clear the area }
  4205. End Else Begin { TEXT MODE GFV }
  4206. X1 := (RawOrigin.X+X1) DIV SysFontWidth;
  4207. Y1 := (RawOrigin.Y+Y1) DIV SysFontHeight;
  4208. X2 := (RawOrigin.X+X2-1) DIV SysFontWidth;
  4209. Y2 := (RawOrigin.Y+Y2-1) DIV SysFontHeight;
  4210. For X := X1 To X2 Do Begin
  4211. Buf[X-X1]:=(Colour shl 12) or $20;
  4212. End;
  4213. For Y := Y1 To Y2 Do
  4214. WriteAbs(X1,Y, X2-X1, Buf);
  4215. DrawScreenBuf;
  4216. End;
  4217. END;
  4218. PROCEDURE TView.GraphArc (Xc, Yc: Sw_Integer; Sa, Ea: Real; XRad, YRad: Sw_Integer;
  4219. Colour: Byte);
  4220. CONST RadConv = 57.2957795130823229; { Degrees per radian }
  4221. VAR X1, Y1, X2, Y2, X3, Y3: Sw_Integer; {$IFDEF OS_WINDOWS} ODc: hDc; {$ENDIF}
  4222. BEGIN
  4223. {$IFDEF NOT_IMPLEMENTED}
  4224. {$IFDEF OS_WINDOWS}
  4225. Xc := Xc - FrameSize;
  4226. Yc := Yc - CaptSize;
  4227. {$ENDIF}
  4228. While (Ea < -360) Do Ea := Ea + 360; { Max of a full circle }
  4229. While (Ea > 360) Do Ea := Ea - 360; { Max of a full circle }
  4230. Sa := Sa/RadConv; { Convert to radians }
  4231. Ea := Ea/RadConv; { Convert to radians }
  4232. X1 := Xc + Round(Sin(Sa)*XRad); { Calc 1st x value }
  4233. Y1 := Yc - Round(Cos(Sa)*YRad); { Calc 1st y value }
  4234. X2 := Xc + Round(Sin(Sa+Ea)*XRad); { Calc 2nd x value }
  4235. Y2 := Yc - Round(Cos(Sa+Ea)*YRad); { Calc 2nd y value }
  4236. X3 := X2; { Use X2 value }
  4237. Y3 := Y2; { Use Y2 value }
  4238. If (Abs(Ea) > Pi) Then Begin
  4239. X3 := Xc + Round(Sin(Sa+Pi)*XRad); { Calc 3rd x value }
  4240. Y3 := Yc - Round(Cos(Sa+Pi)*YRad); { Calc 3rd y value }
  4241. End;
  4242. {$IFDEF OS_WINDOWS}
  4243. If (HWindow <> 0) Then Begin { Valid window }
  4244. ODc := Dc; { Hold device context }
  4245. If (Dc = 0) Then Dc := GetDC(HWindow); { Create a context }
  4246. SelectObject(Dc, ColPen[Colour]); { Pen colour }
  4247. If (Abs(X1-X3) > 1) OR (Abs(Y1-Y3) > 1) { Must exceed 2x2 arc }
  4248. Then Begin
  4249. If (Ea < 0) Then
  4250. Arc(Dc, Xc-XRad, Yc-YRad, Xc+XRad, Yc+YRad,
  4251. X1, Y1, X2, Y2) Else { Draw c/clkwise arc }
  4252. Arc(Dc, Xc-XRad, Yc-YRad, Xc+XRad, Yc+YRad,
  4253. X2, Y2, X1, Y1); { Draw clockwise arc }
  4254. End;
  4255. If (ODc = 0) Then ReleaseDC(HWindow, Dc); { Release context }
  4256. Dc := ODc; { Reset held context }
  4257. End;
  4258. {$ENDIF}
  4259. {$ENDIF NOT_IMPLEMENTED}
  4260. END;
  4261. PROCEDURE TView.FilletArc (Xc, Yc: Sw_Integer; Sa, Ea: Real; XRad, YRad, Ht: Sw_Integer;
  4262. Colour: Byte);
  4263. CONST RadConv = 57.2957795130823229; { Degrees per radian }
  4264. {$IFDEF OS_WINDOWS} VAR X1, Y1, X2, Y2, X3, Y3, X4, Y4: Sw_Integer; ODc: hDc; {$ENDIF}
  4265. BEGIN
  4266. {$IFDEF NOT_IMPLEMENTED}
  4267. {$IFDEF OS_WINDOWS}
  4268. If (HWindow <> 0) Then Begin { Valid window }
  4269. Xc := Xc - FrameSize;
  4270. Yc := Yc - CaptSize;
  4271. ODc := Dc; { Hold device context }
  4272. If (Dc = 0) Then Dc := GetDC(HWindow); { Create a context }
  4273. Ea := (Ea-Sa);
  4274. While (Ea<-360) Do Ea := Ea+360; { One lap only }
  4275. While (Ea>360) Do Ea := Ea-360; { One lap only }
  4276. X1 := Round(Sin(Sa/RadConv)*XRad);
  4277. Y1 := -Round(Cos(Sa/RadConv)*YRad); { Calc 1st values }
  4278. X2 := Round(Sin((Sa+Ea)/RadConv)*XRad);
  4279. Y2 := -Round(Cos((Sa+Ea)/RadConv)*YRad); { Calc 2nd values }
  4280. X3 := Round(Sin(Sa/RadConv)*(XRad+Ht));
  4281. Y3 := -Round(Cos(Sa/RadConv)*(YRad+Ht)); { Calc 3rd values }
  4282. X4 := Round(Sin((Sa+Ea)/RadConv)*(XRad+Ht));
  4283. Y4 := -Round(Cos((Sa+Ea)/RadConv)*(YRad+Ht)); { Calc 4th values }
  4284. SelectObject(Dc, ColPen[Colour]); { Pen colour }
  4285. {$IFDEF WIN32}
  4286. MoveToEx(Dc, Xc+X1, Yc+Y1, Nil); { Move to first point }
  4287. {$ELSE}
  4288. WinProcs.MoveTo(Dc, Xc+X1, Yc+Y1); { Move to first point }
  4289. {$ENDIF}
  4290. LineTo(Dc, Xc+X3, Yc+Y3);
  4291. {$IFDEF WIN32}
  4292. MoveToEx(Dc, Xc+X2, Yc+Y2, Nil);
  4293. {$ELSE}
  4294. WinProcs.MoveTo(Dc, Xc+X2, Yc+Y2);
  4295. {$ENDIF}
  4296. LineTo(Dc, Xc+X4, Yc+Y4);
  4297. If (Ea < 0) Then
  4298. Arc(Dc, Xc-XRad-Ht, Yc-YRad-Ht, Xc+XRad+Ht, Yc+YRad+Ht,
  4299. Xc+X1, Yc+Y1, Xc+X2, Yc+Y2) Else
  4300. Arc(Dc, Xc-XRad-Ht, Yc-YRad-Ht, Xc+XRad+Ht, Yc+YRad+Ht,
  4301. Xc+X2, Yc+Y2, Xc+X1, Yc+Y1); { Draw arc }
  4302. If (Ea < 0) Then
  4303. Arc(Dc, Xc-XRad, Yc-YRad, Xc+XRad, Yc+YRad,
  4304. Xc+X3, Yc+Y3, Xc+X4, Yc+Y4) Else
  4305. Arc(Dc, Xc-XRad, Yc-YRad, Xc+XRad, Yc+YRad,
  4306. Xc+X4, Yc+Y4, Xc+X3, Yc+Y3); { Draw arc }
  4307. If (ODc = 0) Then ReleaseDC(HWindow, Dc); { Release context }
  4308. Dc := ODc; { Reset held context }
  4309. End;
  4310. {$ENDIF}
  4311. {$ENDIF NOT_IMPLEMENTED}
  4312. END;
  4313. {--TView--------------------------------------------------------------------}
  4314. { BiColorRectangle -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 06May98 LdB }
  4315. {---------------------------------------------------------------------------}
  4316. PROCEDURE TView.BicolorRectangle (X1, Y1, X2, Y2: Sw_Integer; Light, Dark: Byte;
  4317. Down: Boolean);
  4318. VAR UpperLeft, RightDown: Byte;
  4319. BEGIN
  4320. If Down Then Begin
  4321. UpperLeft := Dark; { Dark upper left }
  4322. RightDown := Light; { Light down }
  4323. End Else Begin
  4324. UpperLeft := Light; { Light upper left }
  4325. RightDown := Dark; { Dark down }
  4326. End;
  4327. GraphLine(X1, Y1, X1, Y2, UpperLeft); { Draw left side }
  4328. GraphLine(X1, Y1, X2, Y1, UpperLeft); { Draw top line }
  4329. GraphLine(X1, Y2, X2, Y2, RightDown); { Draw bottom line }
  4330. GraphLine(X2, Y1, X2, Y2, RightDown); { Draw right line }
  4331. END;
  4332. PROCEDURE TView.WriteBuf (X, Y, W, H: Sw_Integer; Var Buf);
  4333. VAR I, J, K, L, CW: Sw_Integer; P: PDrawBuffer;
  4334. Tix, Tiy: Sw_Integer; ViewPort: ViewPortType;
  4335. BEGIN
  4336. If (State AND sfVisible <> 0) AND { View is visible }
  4337. (State AND sfIconised = 0) AND { View is not icon}
  4338. (State AND sfExposed <> 0) AND (W > 0) AND (H > 0) { View is exposed }
  4339. then begin
  4340. P := @TDrawBuffer(Buf); { Set draw buffer ptr }
  4341. L := 0; { Set buffer position }
  4342. If (X >= 0) AND (Y >= 0) AND ((GOptions and (goGraphical or goGraphView))=0) Then Begin
  4343. X := RawOrigin.X+X*FontWidth; { X position }
  4344. Y := RawOrigin.Y+Y*FontHeight; { Y position }
  4345. End Else Begin
  4346. X := RawOrigin.X + Abs(X);
  4347. Y := RawOrigin.Y + Abs(Y);
  4348. End;
  4349. If TextModeGFV or UseFixedFont then Begin
  4350. X := X DIV SysFontWidth;
  4351. Y := Y DIV SysFontHeight;
  4352. End;
  4353. GetViewSettings(ViewPort, TextModeGFV); { Get current viewport }
  4354. If not TextModeGFV and not UseFixedFont then Begin
  4355. X := X - ViewPort.X1; { Calc x position }
  4356. Y := Y - ViewPort.Y1; { Calc y position }
  4357. End;
  4358. For J := 1 To H Do Begin { For each line }
  4359. If (TextModeGFV) or UseFixedFont Then Begin { TEXT MODE GFV }
  4360. WriteAbs(X,Y,W,P^[L]);
  4361. Inc(Y);
  4362. Inc(L,W);
  4363. End Else Begin
  4364. K := X; { Reset x position }
  4365. For I := 0 To (W-1) Do Begin { For each character }
  4366. Cw := TextWidth(Chr(Lo(P^[L]))); { Width of this char }
  4367. SetFillStyle(SolidFill, Hi(P^[L]) AND
  4368. $F0 SHR 4); { Set back colour }
  4369. SetColor(Hi(P^[L]) AND $0F); { Set text colour }
  4370. Bar(K, Y, K+Cw, Y+FontHeight-1); { Clear text backing }
  4371. OutTextXY(K, Y+2, Chr(Lo(P^[L]))); { Write text char }
  4372. Inc(K,Cw);
  4373. Inc(L); { Next character }
  4374. End;
  4375. Y := Y + SysFontHeight; { Next line down }
  4376. end;
  4377. DrawScreenBuf;
  4378. End;
  4379. end;
  4380. END;
  4381. PROCEDURE TView.WriteLine (X, Y, W, H: Sw_Integer; Var Buf);
  4382. VAR I, J, K, Cw: Sw_Integer; P: PDrawBuffer;
  4383. Tix, Tiy: Sw_Integer; ViewPort: ViewPortType;
  4384. BEGIN
  4385. If (State AND sfVisible <> 0) AND { View is visible }
  4386. (State AND sfIconised = 0) AND { View is not icon}
  4387. (State AND sfExposed <> 0) AND (W > 0) AND (H > 0) { View is exposed }
  4388. then begin
  4389. P := @TDrawBuffer(Buf); { Set draw buffer ptr }
  4390. If (X >= 0) AND (Y >= 0) AND ((GOptions and (goGraphical or goGraphView))=0) Then Begin
  4391. X := RawOrigin.X+X*FontWidth; { X position }
  4392. Y := RawOrigin.Y+Y*FontHeight; { Y position }
  4393. End Else Begin
  4394. X := RawOrigin.X + Abs(X);
  4395. Y := RawOrigin.Y + Abs(Y);
  4396. End;
  4397. If TextModeGFV or UseFixedFont then Begin
  4398. X := X DIV SysFontWidth;
  4399. Y := Y DIV SysFontHeight;
  4400. End;
  4401. GetViewSettings(ViewPort, TextModeGFV); { Get current viewport }
  4402. If not TextModeGFV and not UseFixedFont then Begin
  4403. X := X - ViewPort.X1; { Calc x position }
  4404. Y := Y - ViewPort.Y1; { Calc y position }
  4405. End;
  4406. For J := 1 To H Do Begin { For each line }
  4407. If (TextModeGFV) or UseFixedFont Then Begin { TEXT MODE GFV }
  4408. WriteAbs(X,Y,W,P^);
  4409. Inc(Y);
  4410. End Else Begin
  4411. K := X; { Reset x position }
  4412. For I := 0 To (W-1) Do Begin { For each character }
  4413. Cw := TextWidth(Chr(Lo(P^[I]))); { Width of this char }
  4414. SetFillStyle(SolidFill, Hi(P^[I]) AND
  4415. $F0 SHR 4); { Set back colour }
  4416. SetColor(Hi(P^[I]) AND $0F); { Set text colour }
  4417. Bar(K, Y, K+Cw, Y+FontHeight-1); { Clear text backing }
  4418. OutTextXY(K, Y+2, Chr(Lo(P^[I]))); { Write text char }
  4419. Inc(K,Cw);
  4420. End;
  4421. Y := Y + SysFontHeight; { Next line down }
  4422. End;
  4423. end;
  4424. If TextModeGFV or UseFixedFont then
  4425. DrawScreenBuf;
  4426. End;
  4427. END;
  4428. {--TView--------------------------------------------------------------------}
  4429. { MakeLocal -> Platforms DOS/DPMI/WIN/OS2 - Checked 12Sep97 LdB }
  4430. {---------------------------------------------------------------------------}
  4431. PROCEDURE TView.MakeLocal (Source: TPoint; Var Dest: TPoint);
  4432. BEGIN
  4433. If (Options AND ofGFVModeView <> 0) Then Begin { GFV MODE TVIEW }
  4434. Dest.X := (Source.X-RawOrigin.X) DIV FontWidth; { Local x value }
  4435. Dest.Y := (Source.Y-RawOrigin.Y) DIV FontHeight; { Local y value }
  4436. End Else Begin { OLD MODE TVIEW }
  4437. Dest.X := Source.X - Origin.X; { Local x value }
  4438. Dest.Y := Source.Y - Origin.Y; { Local y value }
  4439. End;
  4440. END;
  4441. {--TView--------------------------------------------------------------------}
  4442. { MakeGlobal -> Platforms DOS/DPMI/WIN/OS2 - Checked 12Sep97 LdB }
  4443. {---------------------------------------------------------------------------}
  4444. PROCEDURE TView.MakeGlobal (Source: TPoint; Var Dest: TPoint);
  4445. BEGIN
  4446. If (Options AND ofGFVModeView <> 0) Then Begin { GFV MODE TVIEW }
  4447. Dest.X := Source.X*FontWidth + RawOrigin.X; { Global x value }
  4448. Dest.Y := Source.Y*FontHeight + RawOrigin.Y; { Global y value }
  4449. End Else Begin { OLD MODE TVIEW }
  4450. Dest.X := Source.X + Origin.X; { Global x value }
  4451. Dest.Y := Source.Y + Origin.Y; { Global y value }
  4452. End;
  4453. END;
  4454. PROCEDURE TView.WriteCStr (X, Y: Sw_Integer; Str: String; Color1, Color2 : Byte);
  4455. VAR I, J, Fc, Bc, B: Byte; X1, Y1, X2, Y2: Sw_Integer;
  4456. Xw, Yw, TiBuf, Tix, Tiy, Ti: Sw_Integer; ViewPort: ViewPortType;
  4457. Buf : TDrawBuffer;
  4458. FoundSwap : boolean;
  4459. BEGIN
  4460. If (State AND sfVisible <> 0) AND { View is visible }
  4461. (State AND sfExposed <> 0) AND { View is exposed }
  4462. (State AND sfIconised = 0) AND { View not iconized }
  4463. (Length(Str) > 0) Then Begin { String is valid }
  4464. j:=1;
  4465. repeat
  4466. FoundSwap:=false;
  4467. i:=PosIdx('~',Str,j);
  4468. if i>0 then
  4469. FoundSwap:=true
  4470. else
  4471. i:=Length(Str)+1;
  4472. Fc := GetColor(Color1); { Get view color }
  4473. Bc := Fc AND $F0 SHR 4; { Calc back colour }
  4474. Fc := Fc AND $0F; { Calc text colour }
  4475. If RevCol Then Begin
  4476. B := Bc;
  4477. Bc := Fc;
  4478. Fc := B;
  4479. End;
  4480. If (X >= 0) AND (Y >= 0) AND ((GOptions and goGraphView)=0) Then Begin
  4481. Xw := RawOrigin.X+X*FontWidth; { X position }
  4482. Yw := RawOrigin.Y+Y*FontHeight; { Y position }
  4483. End Else Begin
  4484. Xw := RawOrigin.X + Abs(X);
  4485. Yw := RawOrigin.Y + Abs(Y);
  4486. End;
  4487. GetViewSettings(ViewPort, TextModeGFV);
  4488. If not TextModeGFV and not UseFixedFont Then Begin { GRAPHICAL MODE GFV }
  4489. SetFillStyle(SolidFill, Bc); { Set fill style }
  4490. Bar(Xw-ViewPort.X1, Yw-ViewPort.Y1,
  4491. Xw-ViewPort.X1+Length(Str)*FontWidth,
  4492. Yw-ViewPort.Y1+FontHeight-1);
  4493. SetColor(Fc);
  4494. OutTextXY(Xw-ViewPort.X1, Yw-ViewPort.Y1+2, Copy(Str,j,i-j));{ Write text char }
  4495. End Else Begin { TEXT MODE GFV }
  4496. Tix := Xw DIV SysFontWidth;
  4497. Tiy := Yw DIV SysFontHeight;
  4498. TiBuf := 0;
  4499. For Ti := j To i-1 Do Begin
  4500. Buf[TiBuf]:=((Fc or (Bc shl 4)) shl 8) or Ord(Str[Ti]);
  4501. inc(TiBuf);
  4502. end;
  4503. WriteAbs(Tix,TiY,i-j,Buf);
  4504. End;
  4505. { increase position on screen }
  4506. inc(X,(i-j));
  4507. { Swap colors }
  4508. if FoundSwap then
  4509. begin
  4510. { Swap color1 and color2 }
  4511. B := Color1;
  4512. Color1 := Color2;
  4513. Color2 := B;
  4514. { increase position in string }
  4515. j:=i+1;
  4516. { we're at the last char }
  4517. if (j>length(Str)) then
  4518. break;
  4519. end;
  4520. until not FoundSwap;
  4521. If TextModeGFV then
  4522. DrawScreenBuf;
  4523. End;
  4524. END;
  4525. PROCEDURE TView.WriteStr (X, Y: Sw_Integer; Str: String; Color: Byte);
  4526. VAR Fc, Bc, B: Byte; X1, Y1, X2, Y2: Sw_Integer;
  4527. Tix, Tiy, Ti: Sw_Integer; ViewPort: ViewPortType;
  4528. Buf : TDrawBuffer;
  4529. BEGIN
  4530. If (State AND sfVisible <> 0) AND { View is visible }
  4531. (State AND sfExposed <> 0) AND { View is exposed }
  4532. (State AND sfIconised = 0) AND { View not iconized }
  4533. (Length(Str) > 0) Then Begin { String is valid }
  4534. Fc := GetColor(Color); { Get view color }
  4535. Bc := Fc AND $F0 SHR 4; { Calc back colour }
  4536. Fc := Fc AND $0F; { Calc text colour }
  4537. If RevCol Then Begin
  4538. B := Bc;
  4539. Bc := Fc;
  4540. Fc := B;
  4541. End;
  4542. If (X >= 0) AND (Y >= 0) AND ((GOptions and goGraphView)=0) Then Begin
  4543. X := RawOrigin.X+X*FontWidth; { X position }
  4544. Y := RawOrigin.Y+Y*FontHeight; { Y position }
  4545. End Else Begin
  4546. X := RawOrigin.X + Abs(X);
  4547. Y := RawOrigin.Y + Abs(Y);
  4548. End;
  4549. GetViewSettings(ViewPort, TextModeGFV);
  4550. If not TextModeGFV and not UseFixedFont Then Begin { GRAPHICAL MODE GFV }
  4551. SetFillStyle(SolidFill, Bc); { Set fill style }
  4552. Bar(X-ViewPort.X1, Y-ViewPort.Y1,
  4553. X-ViewPort.X1+Length(Str)*FontWidth,
  4554. Y-ViewPort.Y1+FontHeight-1);
  4555. SetColor(Fc);
  4556. OutTextXY(X-ViewPort.X1, Y-ViewPort.Y1+2, Str);{ Write text char }
  4557. End Else Begin { TEXT MODE GFV }
  4558. Tix := X DIV SysFontWidth;
  4559. Tiy := Y DIV SysFontHeight;
  4560. For Ti := 1 To length(Str) Do Begin
  4561. Buf[Ti-1]:=(GetColor(Color) shl 8) or Ord(Str[Ti]);
  4562. end;
  4563. WriteAbs(Tix,TiY,Length(Str),Buf);
  4564. End;
  4565. If TextModeGFV or UseFixedFont then
  4566. DrawScreenBuf;
  4567. End;
  4568. END;
  4569. PROCEDURE TView.WriteChar (X, Y: Sw_Integer; C: Char; Color: Byte;
  4570. Count: Sw_Integer);
  4571. VAR Fc, Bc: Byte; I, Ti, Tix, Tiy: Sw_Integer; Col: Word; S: String; ViewPort: ViewPortType;
  4572. Buf : TDrawBuffer;
  4573. BEGIN
  4574. If (State AND sfVisible <> 0) AND { View visible }
  4575. (State AND sfExposed <> 0) Then Begin { View exposed }
  4576. GetViewSettings(ViewPort, TextModeGFV);
  4577. Col := GetColor(Color); { Get view color }
  4578. Fc := Col AND $0F; { Foreground colour }
  4579. Bc := Col AND $F0 SHR 4; { Background colour }
  4580. If (X >= 0) AND (Y >= 0) AND ((GOptions and goGraphView)=0) Then Begin
  4581. X := RawOrigin.X+X*FontWidth; { X position }
  4582. Y := RawOrigin.Y+Y*FontHeight; { Y position }
  4583. End Else Begin
  4584. X := RawOrigin.X + Abs(X);
  4585. Y := RawOrigin.Y + Abs(Y);
  4586. End;
  4587. FillChar(S[1], 255, C); { Fill the string }
  4588. While (Count>0) Do Begin
  4589. If (Count>Size.X) Then I := Size.X Else I := Count; { Size to make }
  4590. S[0] := Chr(I); { Set string length }
  4591. If not TextModeGFV and not UseFixedFont Then Begin { GRAPHICAL MODE GFV }
  4592. SetFillStyle(SolidFill, Bc); { Set fill style }
  4593. Bar(X-ViewPort.X1, Y-ViewPort.Y1,
  4594. X-ViewPort.X1+I*FontWidth,
  4595. Y-ViewPort.Y1+FontHeight-1);
  4596. SetColor(Fc);
  4597. OutTextXY(X-ViewPort.X1, Y-ViewPort.Y1, S); { Write text char }
  4598. End Else Begin { TEXT MODE GFV }
  4599. Tix := X DIV SysFontWidth;
  4600. Tiy := Y DIV SysFontHeight;
  4601. For Ti := 1 To I Do Begin
  4602. Buf[Ti-1]:=(GetColor(Color) shl 8) or Ord(S[Ti]);
  4603. End;
  4604. WriteAbs(TiX,TiY,Length(S),Buf);
  4605. End;
  4606. Count := Count - I; { Subtract count }
  4607. If TextModeGFV or UseFixedFont then
  4608. X := X + I { Move x position }
  4609. else
  4610. X := X + I*FontWidth; { Move x position }
  4611. End;
  4612. If TextModeGFV or UseFixedFont then
  4613. DrawScreenBuf;
  4614. End;
  4615. END;
  4616. PROCEDURE TView.WriteAbs(X, Y, L : Sw_Integer; Var Buf);
  4617. VAR
  4618. P: PGroup;
  4619. PrevP,PP : PView;
  4620. CurOrigin : TPoint;
  4621. I,XI : longint;
  4622. ViewPort : ViewPortType;
  4623. Skip : boolean;
  4624. BEGIN
  4625. {$ifdef DEBUG}
  4626. if WriteDebugInfo then
  4627. Begin
  4628. Writeln(stderr,'TView(',hexstr(longint(@self),8),')');
  4629. Writeln(stderr,'Object Type(',hexstr(plongint(@self)^,8),')');
  4630. Writeln(stderr,'WriteAbs(',X,',',Y,',',L,',',hexstr(longint(@Buf),8),')');
  4631. End;
  4632. {$endif DEBUG}
  4633. { Direct wrong method }
  4634. GetViewSettings(ViewPort, TextModeGFV or UseFixedFont); { Get set viewport }
  4635. { Pedestrian character method }
  4636. { Must be in area }
  4637. If (X+L<ViewPort.X1) OR (Y<ViewPort.Y1) OR
  4638. (X>=ViewPort.X2) OR (Y>=ViewPort.Y2) Then
  4639. Exit;
  4640. For I:=0 to L-1 do Begin
  4641. P:=Owner;
  4642. PrevP :=@Self;
  4643. XI:=X+I;
  4644. { Must be in area }
  4645. If (XI<ViewPort.X1) OR
  4646. (XI>=ViewPort.X2) Then
  4647. Continue;
  4648. Skip:=false;
  4649. While Assigned(P) do Begin
  4650. { If parent not visible or
  4651. position outside parent's limit then skip }
  4652. if not assigned(P^.Buffer) AND
  4653. (((P^.State AND sfVisible) = 0) OR
  4654. (XI<P^.Origin.X) OR (XI>=P^.Origin.X+P^.Size.X) OR
  4655. (Y<P^.Origin.Y) OR (Y>=P^.Origin.Y+P^.Size.Y)) then
  4656. Begin
  4657. Skip:=true;
  4658. Break;
  4659. End;
  4660. { Here we must check if X,Y is exposed for this view }
  4661. PP:=P^.Last;
  4662. { move to first }
  4663. If Assigned(PP) then
  4664. PP:=PP^.Next;
  4665. While Assigned(PP) and (PP<>P^.Last) and (PP<>PrevP) do Begin
  4666. { If position is owned by another view that is before self
  4667. then skip }
  4668. If ((PP^.State AND sfVisible) <> 0) AND
  4669. (XI>=PP^.Origin.X) AND
  4670. (XI<PP^.Origin.X+PP^.Size.X) AND
  4671. (Y>=PP^.Origin.Y) AND
  4672. (Y<PP^.Origin.Y+PP^.Size.Y) then
  4673. Begin
  4674. Skip:=true;
  4675. break;
  4676. End;
  4677. PP:=PP^.Next;
  4678. End;
  4679. If Not Skip and Assigned(P^.Buffer) then Begin
  4680. P^.Buffer^[(Y-P^.Origin.Y)*P^.size.X+(XI-P^.Origin.X)]:=TDrawBuffer(Buf)[I];
  4681. End;
  4682. PrevP:=P;
  4683. If Skip then
  4684. P:=Nil
  4685. else
  4686. P:=P^.Owner;
  4687. End;
  4688. End;
  4689. END;
  4690. {define DirectWriteShadow}
  4691. PROCEDURE TView.WriteShadow(X1, Y1, X2, Y2 : Sw_Integer);
  4692. VAR
  4693. P: PGroup;
  4694. PrevP,PP : PView;
  4695. CurOrigin : TPoint;
  4696. I,J : longint;
  4697. B : Word;
  4698. ViewPort : ViewPortType;
  4699. Skip : boolean;
  4700. BEGIN
  4701. { Direct wrong method }
  4702. GetViewSettings(ViewPort, TextModeGFV); { Get set viewport }
  4703. {$ifdef DirectWriteShadow}
  4704. For J:=Y1 to Y2-1 do Begin
  4705. For i:=X1 to X2-1 do Begin
  4706. { if (I>=ViewPort.X1) AND (J>=ViewPort.Y1) AND
  4707. (I<ViewPort.X2) AND (J<ViewPort.Y2) Then }
  4708. Begin
  4709. B:=VideoBuf^[J*ScreenWidth+i];
  4710. VideoBuf^[J*ScreenWidth+i]:= (B and $7FF);
  4711. End;
  4712. End;
  4713. End;
  4714. {$else not DirectWriteShadow}
  4715. { Pedestrian character method }
  4716. { Must be in area }
  4717. {If (X+L<ViewPort.X1) OR (Y<ViewPort.Y1) OR
  4718. (X>=ViewPort.X2) OR (Y>=ViewPort.Y2) Then
  4719. Exit;}
  4720. For J:=Y1 to Y2-1 do Begin
  4721. For i:=X1 to X2-1 do Begin
  4722. P:=Owner;
  4723. PrevP :=@Self;
  4724. { Must be in area
  4725. If (XI<ViewPort.X1) OR
  4726. (XI>=ViewPort.X2) Then
  4727. Continue; }
  4728. Skip:=false;
  4729. While Assigned(P) do Begin
  4730. if not assigned(P^.Buffer) AND
  4731. (((P^.State AND sfVisible) = 0) OR
  4732. (I<P^.Origin.X) OR (I>=P^.Origin.X+P^.Size.X) OR
  4733. (J<P^.Origin.Y) OR (J>=P^.Origin.Y+P^.Size.Y)) then
  4734. Begin
  4735. Skip:=true;
  4736. Break;
  4737. End;
  4738. { Here we must check if X,Y is exposed for this view }
  4739. PP:=P^.Last;
  4740. { move to first }
  4741. If Assigned(PP) then
  4742. PP:=PP^.Next;
  4743. While Assigned(PP) and (PP<>P^.Last) and (PP<>PrevP) do Begin
  4744. If ((PP^.State AND sfVisible) <> 0) AND
  4745. (I>=PP^.Origin.X) AND
  4746. (I<PP^.Origin.X+PP^.Size.X) AND
  4747. (J>=PP^.Origin.Y) AND
  4748. (J<PP^.Origin.Y+PP^.Size.Y) then
  4749. Begin
  4750. Skip:=true;
  4751. Break;
  4752. End;
  4753. PP:=PP^.Next;
  4754. End;
  4755. If not Skip and Assigned(P^.Buffer) then Begin
  4756. B:=P^.Buffer^[(J-P^.Origin.Y)*P^.size.X+(I-P^.Origin.X)];
  4757. P^.Buffer^[(J-P^.Origin.Y)*P^.size.X+(I-P^.Origin.X)]:= (B and $FFF);
  4758. End;
  4759. PrevP:=P;
  4760. If Skip then
  4761. P:=Nil
  4762. else
  4763. P:=P^.Owner;
  4764. End;
  4765. End;
  4766. End;
  4767. {$endif not DirectWriteShadow}
  4768. END;
  4769. PROCEDURE TView.DragView (Event: TEvent; Mode: Byte; Var Limits: TRect;
  4770. MinSize, MaxSize: TPoint);
  4771. VAR PState: Word; Mouse, Q, R, P, S, Op1, Op2: TPoint; SaveBounds: TRect;
  4772. PROCEDURE MoveGrow (P, S: TPoint);
  4773. VAR R: TRect;
  4774. BEGIN
  4775. S.X := Min(Max(S.X, MinSize.X), MaxSize.X); { Minimum S.X value }
  4776. S.Y := Min(Max(S.Y, MinSize.Y), MaxSize.Y); { Minimum S.Y value }
  4777. P.X := Min(Max(P.X, Limits.A.X - S.X + 1),
  4778. Limits.B.X - 1); { Minimum P.X value }
  4779. P.Y := Min(Max(P.Y, Limits.A.Y - S.Y + 1),
  4780. Limits.B.Y - 1); { Mimimum P.Y value }
  4781. If (Mode AND dmLimitLoX <> 0) Then
  4782. P.X := Max(P.X, Limits.A.X); { Left side move }
  4783. If (Mode AND dmLimitLoY <> 0) Then
  4784. P.Y := Max(P.Y, Limits.A.Y); { Top side move }
  4785. If (Mode AND dmLimitHiX <> 0) Then
  4786. P.X := Min(P.X, Limits.B.X - S.X); { Right side move }
  4787. If (Mode AND dmLimitHiY <> 0) Then
  4788. P.Y := Min(P.Y, Limits.B.Y - S.Y); { Bottom side move }
  4789. R.Assign(P.X, P.Y, P.X + S.X, P.Y + S.Y); { Assign area }
  4790. Locate(R); { Locate view }
  4791. END;
  4792. PROCEDURE Change (DX, DY: Sw_Integer);
  4793. BEGIN
  4794. If (Mode AND dmDragMove <> 0) AND
  4795. (GetShiftState AND $03 = 0) Then Begin
  4796. Inc(P.X, DX); Inc(P.Y, DY); { Adjust values }
  4797. End Else If (Mode AND dmDragGrow <> 0) AND
  4798. (GetShiftState AND $03 <> 0) Then Begin
  4799. Inc(S.X, DX); Inc(S.Y, DY); { Adjust values }
  4800. End;
  4801. END;
  4802. PROCEDURE Update (X, Y: Sw_Integer);
  4803. BEGIN
  4804. If (Mode AND dmDragMove <> 0) Then Begin
  4805. P.X := X; P.Y := Y; { Adjust values }
  4806. End;
  4807. END;
  4808. BEGIN
  4809. SetState(sfDragging, True); { Set drag state }
  4810. If (Event.What = evMouseDown) Then Begin { Mouse down event }
  4811. Q.X := Event.Where.X DIV FontWidth - Origin.X; { Offset mouse x origin }
  4812. Q.Y := Event.Where.Y DIV FontHeight - Origin.Y; { Offset mouse y origin }
  4813. Op1.X := RawOrigin.X; Op1.Y := RawOrigin.Y; { Hold origin point }
  4814. Op2.X := RawOrigin.X+RawSize.X; { Right side x value }
  4815. Op2.Y := RawOrigin.Y+RawSize.Y; { Right side y value }
  4816. PState := State; { Hold current state }
  4817. if not TextModeGFV then
  4818. State := State AND NOT sfVisible; { Temp not visible }
  4819. HideMouseCursor; { Hide the mouse }
  4820. SetWriteMode(XORPut, TextModeGFV);
  4821. GraphRectangle(0, 0, RawSize.X, RawSize.Y, Red);
  4822. SetWriteMode(NormalPut, TextModeGFV);
  4823. ShowMouseCursor; { Show the mouse }
  4824. Repeat
  4825. Mouse.X := Round(Event.Where.X/FontWidth)-Q.X; { New x origin point }
  4826. Mouse.Y := Round(Event.Where.Y/FontHeight)-Q.Y;{ New y origin point }
  4827. If (Mode AND dmDragMove<>0) Then Begin
  4828. If (Owner<>Nil) Then Begin
  4829. Dec(Mouse.X, Owner^.Origin.X); { Sub owner x origin }
  4830. Dec(Mouse.Y, Owner^.Origin.Y); { Sub owner y origin }
  4831. End;
  4832. R := Mouse; Mouse := Size; { Exchange values }
  4833. End Else Begin
  4834. R := Origin; { Start at origin }
  4835. If (Owner<>Nil) Then Begin
  4836. Dec(R.X, Owner^.Origin.X); { Sub owner x origin }
  4837. Dec(R.Y, Owner^.Origin.Y); { Sub owner y origin }
  4838. End;
  4839. Mouse.X := Mouse.X+Q.X-Origin.X;
  4840. Mouse.Y := Mouse.Y+Q.Y-Origin.Y;
  4841. End;
  4842. HideMouseCursor; { Hide the mouse }
  4843. if not TextModeGFV then
  4844. begin
  4845. SetWriteMode(XORPut, TextModeGFV);
  4846. GraphRectangle(0, 0, RawSize.X, RawSize.Y, Red);
  4847. SetWriteMode(NormalPut, TextModeGFV);
  4848. MoveGrow(R, Mouse); { Resize the view }
  4849. SetWriteMode(XORPut, TextModeGFV);
  4850. GraphRectangle(0, 0, RawSize.X, RawSize.Y, Red);
  4851. SetWriteMode(NormalPut, TextModeGFV);
  4852. end
  4853. else
  4854. begin
  4855. MoveGrow(R, Mouse); { Resize the view }
  4856. end;
  4857. ShowMouseCursor; { Show the mouse }
  4858. Until NOT MouseEvent(Event, evMouseMove); { Finished moving }
  4859. State := PState; { Restore view state }
  4860. If (Owner<>Nil) Then
  4861. Owner^.ReDrawArea(Op1.X, Op1.Y, Op2.X, Op2.Y); { Redraw old area }
  4862. SetState(sfDragging, False); { Clr dragging flag }
  4863. DrawView; { Now redraw the view }
  4864. End Else Begin
  4865. GetBounds(SaveBounds); { Get current bounds }
  4866. Repeat
  4867. P := Origin; S := Size; { Set values }
  4868. If Assigned(Owner) then
  4869. Begin
  4870. Dec(P.X,Owner^.Origin.X);
  4871. Dec(P.Y,Owner^.Origin.Y);
  4872. End;
  4873. KeyEvent(Event); { Get key event }
  4874. Case Event.KeyCode AND $FF00 Of
  4875. kbLeft: Change(-1, 0); { Move left }
  4876. kbRight: Change(1, 0); { Move right }
  4877. kbUp: Change(0, -1); { Move up }
  4878. kbDown: Change(0, 1); { Move down }
  4879. kbCtrlLeft: Change(-8, 0);
  4880. kbCtrlRight: Change(8, 0);
  4881. kbHome: Update(Limits.A.X, P.Y);
  4882. kbEnd: Update(Limits.B.X - S.X, P.Y);
  4883. kbPgUp: Update(P.X, Limits.A.Y);
  4884. kbPgDn: Update(P.X, Limits.B.Y - S.Y);
  4885. End;
  4886. MoveGrow(P, S); { Now move the view }
  4887. Until (Event.KeyCode = kbEnter) OR
  4888. (Event.KeyCode = kbEsc);
  4889. If (Event.KeyCode=kbEsc) Then Locate(SaveBounds);{ Restore original }
  4890. End;
  4891. SetState(sfDragging, False); { Clr dragging flag }
  4892. END;
  4893. FUNCTION TView.FontWidth: Sw_Integer;
  4894. BEGIN
  4895. FontWidth := SysFontWidth;
  4896. END;
  4897. FUNCTION TView.FontHeight: Sw_Integer;
  4898. BEGIN
  4899. FontHeight := SysFontHeight;
  4900. END;
  4901. {***************************************************************************}
  4902. { TScroller OBJECT METHODS }
  4903. {***************************************************************************}
  4904. PROCEDURE TScroller.ScrollDraw;
  4905. VAR D: TPoint;
  4906. BEGIN
  4907. If (HScrollBar<>Nil) Then D.X := HScrollBar^.Value
  4908. Else D.X := 0; { Horz scroll value }
  4909. If (VScrollBar<>Nil) Then D.Y := VScrollBar^.Value
  4910. Else D.Y := 0; { Vert scroll value }
  4911. If (D.X<>Delta.X) OR (D.Y<>Delta.Y) Then Begin { View has moved }
  4912. SetCursor(Cursor.X+Delta.X-D.X,
  4913. Cursor.Y+Delta.Y-D.Y); { Move the cursor }
  4914. Delta := D; { Set new delta }
  4915. If (DrawLock<>0) Then DrawFlag := True { Draw will need draw }
  4916. Else DrawView; { Redraw the view }
  4917. End;
  4918. END;
  4919. PROCEDURE TScroller.SetLimit (X, Y: Sw_Integer);
  4920. VAR PState: Word;
  4921. BEGIN
  4922. Limit.X := X; { Hold x limit }
  4923. Limit.Y := Y; { Hold y limit }
  4924. Inc(DrawLock); { Set draw lock }
  4925. If (HScrollBar<>Nil) Then Begin
  4926. PState := HScrollBar^.State; { Hold bar state }
  4927. HScrollBar^.State := PState AND NOT sfVisible; { Temp not visible }
  4928. HScrollBar^.SetParams(HScrollBar^.Value, 0,
  4929. X-Size.X, Size.X-1, HScrollBar^.ArStep); { Set horz scrollbar }
  4930. HScrollBar^.State := PState; { Restore bar state }
  4931. End;
  4932. If (VScrollBar<>Nil) Then Begin
  4933. PState := VScrollBar^.State; { Hold bar state }
  4934. VScrollBar^.State := PState AND NOT sfVisible; { Temp not visible }
  4935. VScrollBar^.SetParams(VScrollBar^.Value, 0,
  4936. Y-Size.Y, Size.Y-1, VScrollBar^.ArStep); { Set vert scrollbar }
  4937. VScrollBar^.State := PState; { Restore bar state }
  4938. End;
  4939. Dec(DrawLock); { Release draw lock }
  4940. CheckDraw; { Check need to draw }
  4941. END;
  4942. {***************************************************************************}
  4943. { TScroller OBJECT PRIVATE METHODS }
  4944. {***************************************************************************}
  4945. PROCEDURE TScroller.CheckDraw;
  4946. BEGIN
  4947. If (DrawLock = 0) AND DrawFlag Then Begin { Clear & draw needed }
  4948. DrawFlag := False; { Clear draw flag }
  4949. DrawView; { Draw now }
  4950. End;
  4951. END;
  4952. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  4953. { TGroup OBJECT METHODS }
  4954. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  4955. {--TGroup-------------------------------------------------------------------}
  4956. { Lock -> Platforms DOS/DPMI/WIN/OS2 - Checked 23Sep97 LdB }
  4957. {---------------------------------------------------------------------------}
  4958. {$ifndef NoLock}
  4959. {$define UseLock}
  4960. {$endif ndef NoLock}
  4961. PROCEDURE TGroup.Lock;
  4962. BEGIN
  4963. {$ifdef UseLock}
  4964. {If (Buffer <> Nil) OR (LockFlag <> 0)
  4965. Then} Inc(LockFlag); { Increment count }
  4966. {$endif UseLock}
  4967. END;
  4968. {--TGroup-------------------------------------------------------------------}
  4969. { UnLock -> Platforms DOS/DPMI/WIN/OS2 - Checked 23Sep97 LdB }
  4970. {---------------------------------------------------------------------------}
  4971. PROCEDURE TGroup.Unlock;
  4972. BEGIN
  4973. {$ifdef UseLock}
  4974. If (LockFlag <> 0) Then Begin
  4975. Dec(LockFlag); { Decrement count }
  4976. If (LockFlag = 0) Then DrawView; { Lock release draw }
  4977. End;
  4978. {$endif UseLock}
  4979. END;
  4980. PROCEDURE TWindow.DrawBorder;
  4981. const
  4982. LargeC:array[boolean] of char=('^',#24);
  4983. RestoreC:array[boolean] of char=('|',#18);
  4984. ClickC:array[boolean] of char=('*',#15);
  4985. VAR Fc, Bc: Byte; X, Y: Sw_Integer; S: String;
  4986. ViewPort: ViewPortType;
  4987. I : Sw_Integer;
  4988. LeftUpCorner,
  4989. RightUpCorner,
  4990. HorizontalBar,
  4991. VerticalBar,
  4992. LeftLowCorner,
  4993. RightLowCorner,C : Char;
  4994. Color : Byte;
  4995. Focused : Boolean;
  4996. Min, Max: TPoint;
  4997. BEGIN
  4998. Fc := GetColor(2) AND $0F; { Foreground colour }
  4999. Bc := (GetColor(2) AND $70) SHR 4; { Background colour }
  5000. If TextModeGFV then
  5001. Y:=0 else
  5002. begin
  5003. If (Options AND ofFramed<>0) Then Y := 1
  5004. Else Y := 0; { Initial value }
  5005. If (GOptions AND goThickFramed<>0) Then Inc(Y, 3); { Adjust position }
  5006. end;
  5007. ClearArea(0, Y, RawSize.X, Y+FontHeight, Bc); { Clear background }
  5008. If not TextModeGFV then
  5009. Inherited DrawBorder
  5010. Else Begin { TEXT GFV MODE }
  5011. Focused:=(State AND (sfSelected + sfModal)<>0);
  5012. if Assigned(Owner) then
  5013. Focused := Focused AND (@Self = Owner^.First);
  5014. If not Focused or (GOptions AND goThickFramed = 0) then
  5015. begin
  5016. LeftUpCorner:='Ú';
  5017. RightUpCorner:='¿';
  5018. HorizontalBar:='Ä';
  5019. VerticalBar:='³';
  5020. LeftLowCorner:='À';
  5021. RightLowCorner:='Ù';
  5022. end
  5023. else
  5024. begin
  5025. LeftUpCorner:='É';
  5026. RightUpCorner:='»';
  5027. HorizontalBar:='Í';
  5028. VerticalBar:='º';
  5029. LeftLowCorner:='È';
  5030. RightLowCorner:='¼';
  5031. end;
  5032. if (State AND sfDragging)<>0 then
  5033. Color := 5
  5034. else if Focused then
  5035. Color := 2
  5036. else
  5037. Color := 1;
  5038. WriteChar(0,0,LeftUpCorner,Color,1);
  5039. WriteChar(1,0,HorizontalBar,Color,Size.X-2);
  5040. WriteChar(Size.X-1,0,RightUpcorner,Color,1);
  5041. For i:=1 to Size.Y -1 do
  5042. begin
  5043. WriteChar(0,i,VerticalBar,Color,1);
  5044. WriteChar(Size.X-1,i,VerticalBar,Color,1);
  5045. end;
  5046. WriteChar(0,Size.Y-1,LeftLowCorner,Color,1);
  5047. WriteChar(1,Size.Y-1,HorizontalBar,Color,Size.X-2);
  5048. WriteChar(Size.X-1,Size.Y-1,RightLowCorner,Color,1);
  5049. End;
  5050. If (Title<>Nil) AND (GOptions AND goTitled<>0)
  5051. Then Begin { View has a title }
  5052. GetViewSettings(ViewPort, TextModeGFV);
  5053. X := (RawSize.X DIV 2); { Half way point }
  5054. X := X - ((Length(Title^)+2)*FontWidth) DIV 2; { Calc start point }
  5055. If (TextModeGFV <> TRUE) Then Begin { GRAPHICS MODE GFV }
  5056. SetColor(Fc);
  5057. OutTextXY(RawOrigin.X+X-ViewPort.X1,
  5058. RawOrigin.Y+Y+1-ViewPort.Y1+2, ' '+Title^+' '); { Write the title }
  5059. End Else Begin { LEON??? }
  5060. WriteStr(X div SysFontWidth,0,' '+Title^+' ',Color);
  5061. End;
  5062. End;
  5063. If (Number>0) AND (Number<10) Then Begin { Valid number }
  5064. Str(Number, S); { Make number string }
  5065. If (TextModeGFV <> True) Then Begin { GRAPHICS MODE GFV }
  5066. SetColor(GetColor(2) AND $0F);
  5067. OutTextXY(RawOrigin.X+RawSize.X-2*FontWidth-ViewPort.X1,
  5068. RawOrigin.Y+Y+1-ViewPort.Y1+2, S); { Write number }
  5069. End Else Begin { LEON ????? }
  5070. If (Flags and wfZoom)<>0 then
  5071. I:=7
  5072. else
  5073. I:=3;
  5074. WriteCStr(Size.X-I,0,S,1,Color);
  5075. End;
  5076. End;
  5077. If Focused and (Flags AND wfClose<>0) Then Begin { Close icon request }
  5078. If (TextModeGFV <> True) Then Begin { GRAPHICS MODE GFV }
  5079. SetColor(Fc);
  5080. OutTextXY(RawOrigin.X+Y+FontWidth-ViewPort.X1,
  5081. RawOrigin.Y+Y+1-ViewPort.Y1+2, '[*]'); { Write close icon }
  5082. End Else Begin { LEON??? }
  5083. WriteCStr(2,0,'[~'+ClickC[LowAscii]+'~]', 2, 3);
  5084. End;
  5085. End;
  5086. If Focused and (Flags AND wfZoom<>0) Then Begin
  5087. if assigned(Owner) and
  5088. (Size.X=Owner^.Size.X) and (Size.Y=Owner^.Size.Y) then
  5089. C:=RestoreC[LowAscii]
  5090. else
  5091. C:=LargeC[LowAscii];
  5092. If (TextModeGFV <> True) Then Begin { GRAPHICS MODE GFV }
  5093. SetColor(GetColor(2) AND $0F);
  5094. OutTextXY(RawOrigin.X+RawSize.X-4*FontWidth-Y-ViewPort.X1,
  5095. RawOrigin.Y+Y+1-ViewPort.Y1+2, '['+C+']'); { Write zoom icon }
  5096. End Else Begin { LEON??? }
  5097. WriteCStr(Size.X-5,0,'[~'+C+'~]', 2, 3);
  5098. WriteCStr(Size.X-2,Size.Y-1,'~ÄÙ~',2, 3);
  5099. End;
  5100. End;
  5101. If not TextModeGFV then
  5102. begin
  5103. BiColorRectangle(Y+1, Y+1, RawSize.X-Y-1, Y+FontHeight,
  5104. White, DarkGray, False); { Draw 3d effect }
  5105. BiColorRectangle(Y+1, Y+1, RawSize.X-Y-2, Y+FontHeight-1,
  5106. White, DarkGray, False); { Draw 3d effect }
  5107. end;
  5108. END;
  5109. {***************************************************************************}
  5110. { INTERFACE ROUTINES }
  5111. {***************************************************************************}
  5112. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  5113. { WINDOW MESSAGE ROUTINES }
  5114. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  5115. {---------------------------------------------------------------------------}
  5116. { Message -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB }
  5117. {---------------------------------------------------------------------------}
  5118. FUNCTION Message (Receiver: PView; What, Command: Word;
  5119. InfoPtr: Pointer): Pointer;
  5120. VAR Event: TEvent;
  5121. BEGIN
  5122. Message := Nil; { Preset nil }
  5123. If (Receiver <> Nil) Then Begin { Valid receiver }
  5124. Event.What := What; { Set what }
  5125. Event.Command := Command; { Set command }
  5126. Event.Id := 0; { Zero id field }
  5127. Event.Data := 0; { Zero data field }
  5128. Event.InfoPtr := InfoPtr; { Set info ptr }
  5129. Receiver^.HandleEvent(Event); { Pass to handler }
  5130. If (Event.What = evNothing) Then
  5131. Message := Event.InfoPtr; { Return handler }
  5132. End;
  5133. END;
  5134. {---------------------------------------------------------------------------}
  5135. { NewMessage -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 19Sep97 LdB }
  5136. {---------------------------------------------------------------------------}
  5137. FUNCTION NewMessage (P: PView; What, Command: Word; Id: Sw_Integer;
  5138. Data: Real; InfoPtr: Pointer): Pointer;
  5139. VAR Event: TEvent;
  5140. BEGIN
  5141. NewMessage := Nil; { Preset failure }
  5142. If (P <> Nil) Then Begin
  5143. Event.What := What; { Set what }
  5144. Event.Command := Command; { Set event command }
  5145. Event.Id := Id; { Set up Id }
  5146. Event.Data := Data; { Set up data }
  5147. Event.InfoPtr := InfoPtr; { Set up event ptr }
  5148. P^.HandleEvent(Event); { Send to view }
  5149. If (Event.What = evNothing) Then
  5150. NewMessage := Event.InfoPtr; { Return handler }
  5151. End;
  5152. END;
  5153. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  5154. { NEW VIEW ROUTINES }
  5155. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  5156. {---------------------------------------------------------------------------}
  5157. { CreateIdScrollBar -> Platforms DOS/DPMI/WIN/NT/OS2 - Checked 22May97 LdB }
  5158. {---------------------------------------------------------------------------}
  5159. FUNCTION CreateIdScrollBar (X, Y, Size, Id: Sw_Integer; Horz: Boolean): PScrollBar;
  5160. VAR R: TRect; P: PScrollBar;
  5161. BEGIN
  5162. If Horz Then R.Assign(X, Y, X+Size, Y+1) Else { Horizontal bar }
  5163. R.Assign(X, Y, X+1, Y+Size); { Vertical bar }
  5164. P := New(PScrollBar, Init(R)); { Create scrollbar }
  5165. If (P <> Nil) Then Begin
  5166. P^.Id := Id; { Set scrollbar id }
  5167. P^.Options := P^.Options OR ofPostProcess; { Set post processing }
  5168. End;
  5169. CreateIdScrollBar := P; { Return scrollbar }
  5170. END;
  5171. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  5172. { OBJECT REGISTRATION PROCEDURES }
  5173. {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  5174. {---------------------------------------------------------------------------}
  5175. { RegisterViews -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 28May97 LdB }
  5176. {---------------------------------------------------------------------------}
  5177. PROCEDURE RegisterViews;
  5178. BEGIN
  5179. RegisterType(RView); { Register views }
  5180. RegisterType(RFrame); { Register frame }
  5181. RegisterType(RScrollBar); { Register scrollbar }
  5182. RegisterType(RScroller); { Register scroller }
  5183. RegisterType(RListViewer); { Register listview }
  5184. RegisterType(RGroup); { Register group }
  5185. RegisterType(RWindow); { Register window }
  5186. END;
  5187. END.
  5188. {
  5189. $Log$
  5190. Revision 1.26 2002-05-29 19:36:52 pierre
  5191. * fix UseFixedFont related code
  5192. Revision 1.25 2002/05/28 19:15:16 pierre
  5193. * adapt to new GraphUpdateScreen function
  5194. Revision 1.24 2002/05/25 23:30:47 pierre
  5195. * partly fix the scrollbar behavior
  5196. Revision 1.23 2002/05/24 13:16:11 pierre
  5197. * add window number and resize handle
  5198. Revision 1.22 2002/05/23 10:27:12 pierre
  5199. * avoid problems with shadows when moving or resizing a window
  5200. Revision 1.21 2002/05/23 09:06:01 pierre
  5201. * force views to have raworigin multiples of cell width and height
  5202. Revision 1.20 2002/05/21 11:47:36 pierre
  5203. * avoid infinite recursions in graphic mode
  5204. Revision 1.19 2002/05/16 21:23:34 pierre
  5205. * fix some display problems
  5206. Revision 1.18 2001/10/02 16:35:51 pierre
  5207. * fix several problems, try to get the graph version to compile
  5208. Revision 1.17 2001/08/05 23:54:33 pierre
  5209. * some improovements for TListViewer
  5210. Revision 1.16 2001/08/05 02:03:14 peter
  5211. * view redrawing and small cursor updates
  5212. * merged some more FV extensions
  5213. Revision 1.15 2001/08/04 19:14:33 peter
  5214. * Added Makefiles
  5215. * added FV specific units and objects from old FV
  5216. Revision 1.14 2001/06/01 16:01:20 pierre
  5217. TScrollBar Drawing and TView.DragView corrected
  5218. Revision 1.13 2001/05/31 12:14:06 pierre
  5219. * fix problems for multiple insert/delete and use Redraw for hild drawing like TV
  5220. Revision 1.12 2001/05/30 13:26:18 pierre
  5221. * fix border problems for views and menus
  5222. Revision 1.11 2001/05/30 10:22:25 pierre
  5223. * fix Shadow bugs
  5224. Revision 1.10 2001/05/10 16:46:28 pierre
  5225. + some improovements made
  5226. Revision 1.9 2001/05/07 23:36:35 pierre
  5227. NO_WINDOW cond removed
  5228. Revision 1.8 2001/05/04 15:43:46 pierre
  5229. * several more fixes
  5230. Revision 1.7 2001/05/04 10:46:03 pierre
  5231. * various fixes for win32 api mode
  5232. Revision 1.6 2001/05/04 08:42:56 pierre
  5233. * some corrections for linux
  5234. Revision 1.5 2001/05/03 22:32:52 pierre
  5235. new bunch of changes, displays something for dos at least
  5236. Revision 1.4 2001/04/10 21:57:56 pierre
  5237. + first adds for Use_API define
  5238. Revision 1.3 2001/04/10 21:29:55 pierre
  5239. * import of Leon de Boer's files
  5240. Revision 1.2 2000/08/24 12:00:22 marco
  5241. * CVS log and ID tags
  5242. }