views.pas 271 KB

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