views.pas 269 KB

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