WMInspectionComponents.Mod 112 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945
  1. MODULE WMInspectionComponents; (** AUTHOR "staubesv"; PURPOSE "Components for component inspection"; *)
  2. (**
  3. This module implements some components that are used by component inspection tools.
  4. PropertyPanel
  5. StandardProperties(ComponentElement)
  6. ExtendedProperties(ComponentElement)
  7. EventSources(ComponentElement)
  8. EventListeners(ComponentElement)
  9. whereas
  10. StandardProperties displays all properties common to all components and visual components
  11. ExtendedProperties is a property sheet the displays all other properties
  12. EventSources displays the event sources of a component
  13. EventListeners displays the event listeners of a component
  14. The ExtendedProperties component is a automatically generated property sheet consisting of
  15. BooleanPropertyView, Int32PropertyView, RectanglePropertyView, StringPropertyView and ColorPropertyView components
  16. RepositoryPanel
  17. Displays the repository the component is bound to (if any)
  18. Offers a button to bind the component to a repository
  19. *)
  20. IMPORT
  21. SYSTEM,
  22. Modules, Kernel, KernelLog, Strings, Inputs, Files, XML, XMLObjects, Repositories, Types, Models, WMDialogs, WMUtilities,
  23. WMMessages, WMWindowManager,
  24. WMRectangles, WMGraphics, WMEvents, WMProperties, WMComponents, WMStandardComponents,
  25. WMEditors, WMColorComponents, WMDropDownLists, WMTabComponents, WMScrollableComponents, Raster, D:= Debugging,
  26. Streams, WMDropTarget, Commands;
  27. CONST
  28. Ok = 0;
  29. CannotHandle = 1;
  30. LineHeight = 20;
  31. LineBearing = 2;
  32. NameWidth = 80;
  33. (** maximum number of property sheet cache entries per instance *)
  34. MaxNofCacheEntries = 20;
  35. ModelWindowWidth = 320; ModelWindowHeight = 80;
  36. TYPE
  37. SetStringProcedure = PROCEDURE {DELEGATE} (CONST string : ARRAY OF CHAR; position : LONGINT; VAR res : LONGINT);
  38. DropTarget = OBJECT(WMDropTarget.DropTarget)
  39. VAR
  40. originator : ANY;
  41. setString : SetStringProcedure;
  42. position : LONGINT;
  43. PROCEDURE &Init(originator : ANY; setString : SetStringProcedure; position : LONGINT);
  44. BEGIN
  45. ASSERT(setString # NIL);
  46. SELF.originator := originator;
  47. SELF.setString := setString;
  48. SELF.position := position;
  49. END Init;
  50. PROCEDURE GetInterface(type : LONGINT) : WMDropTarget.DropInterface;
  51. VAR sdi : DropString;
  52. BEGIN
  53. IF (type = WMDropTarget.TypeString) THEN
  54. NEW(sdi, originator, setString, position); RETURN sdi;
  55. ELSE
  56. RETURN NIL;
  57. END;
  58. END GetInterface;
  59. END DropTarget;
  60. DropString = OBJECT(WMDropTarget.DropString)
  61. VAR
  62. originator : ANY;
  63. setString : SetStringProcedure;
  64. position : LONGINT;
  65. PROCEDURE &Init(originator : ANY; setString : SetStringProcedure; position : LONGINT);
  66. BEGIN
  67. ASSERT(setString # NIL);
  68. SELF.originator := originator;
  69. SELF.setString := setString;
  70. SELF.position := position;
  71. END Init;
  72. PROCEDURE Set(CONST string : ARRAY OF CHAR; VAR res : LONGINT);
  73. BEGIN
  74. setString(string, position, res);
  75. END Set;
  76. END DropString;
  77. (** Base class of property view classes used by ExtendedProperties component *)
  78. PropertyView = OBJECT(WMComponents.VisualComponent)
  79. VAR
  80. property : WMProperties.Property;
  81. name, info : Strings.String;
  82. type : ARRAY 32 OF CHAR;
  83. ofsName, ofsInfo : LONGINT;
  84. lastTimestamp : LONGINT;
  85. next : PropertyView;
  86. nameLabel, infoLabel, adrLabel : WMStandardComponents.Label;
  87. PROCEDURE &Init*;
  88. BEGIN
  89. Init^;
  90. SetNameAsString(Strings.NewString("PropertyView"));
  91. property := NIL;
  92. ofsName := 0; ofsInfo := 200;
  93. alignment.Set(WMComponents.AlignTop);
  94. bounds.SetHeight(LineHeight);
  95. bearing.Set(WMRectangles.MakeRect(LineBearing, LineBearing, LineBearing, LineBearing));
  96. next := NIL;
  97. NEW(nameLabel); nameLabel.alignment.Set(WMComponents.AlignLeft);
  98. nameLabel.bounds.SetWidth(NameWidth);
  99. nameLabel.fillColor.Set(0);
  100. nameLabel.bearing.Set(WMRectangles.MakeRect(2, 0, 2, 0));
  101. AddContent(nameLabel);
  102. nameLabel.onStartDrag.Add(InfoLabelStartDrag); (* trick to make popup *)
  103. nameLabel.SetExtPointerMoveHandler(InfoLabelMove);
  104. NEW(infoLabel); infoLabel.alignment.Set(WMComponents.AlignLeft);
  105. infoLabel.bounds.SetWidth(20);
  106. infoLabel.fillColor.Set(0);
  107. infoLabel.alignH.Set(WMGraphics.AlignCenter);
  108. AddContent(infoLabel);
  109. infoLabel.onStartDrag.Add(InfoLabelStartDrag); (* trick to make popup *)
  110. infoLabel.SetExtPointerMoveHandler(InfoLabelMove);
  111. NEW(adrLabel); adrLabel.alignment.Set(WMComponents.AlignLeft);
  112. adrLabel.bounds.SetWidth(40);
  113. adrLabel.fillColor.Set(0CCCCFFFFH);
  114. adrLabel.bearing.Set(WMRectangles.MakeRect(2, 0, 2, 0));
  115. AddContent(adrLabel);
  116. adrLabel.onStartDrag.Add(MyStartDrag);
  117. adrLabel.SetExtPointerMoveHandler(AdrLabelMove);
  118. adrLabel.SetExtDragDroppedHandler(MyDragDropped);
  119. END Init;
  120. PROCEDURE UpdateAdrLabel(object : XML.Element);
  121. VAR string : Types.String32; res : LONGINT; nbrStr : ARRAY 17 OF CHAR; t: Modules.TypeDesc;
  122. BEGIN
  123. IF (object # NIL) THEN
  124. t := Modules.TypeOf(object);
  125. COPY(t.name, nbrStr);
  126. adrLabel.caption.SetAOC(nbrStr);
  127. adrLabel.fillColor.Set(0CCFFH);
  128. adrLabel.textColor.Set(WMGraphics.White);
  129. ELSE
  130. adrLabel.caption.SetAOC("NIL");
  131. adrLabel.fillColor.Set(0CCCCFFFFH);
  132. adrLabel.textColor.Set(WMGraphics.Black);
  133. END;
  134. END UpdateAdrLabel;
  135. PROCEDURE AdrLabelMove(x, y : LONGINT; keys : SET; VAR handled : BOOLEAN);
  136. VAR dx, dy, dp, d : LONGINT; f : REAL; tmax, tmin : LONGINT;
  137. BEGIN
  138. IF keys = {0} THEN adrLabel.AutoStartDrag END;
  139. END AdrLabelMove;
  140. PROCEDURE MyStartDrag(sender, data: ANY);
  141. VAR w,h: LONGINT; img: WMGraphics.Image; canvas: WMGraphics.BufferCanvas;
  142. BEGIN
  143. NEW(img);
  144. adrLabel.bounds.GetExtents(w,h);
  145. Raster.Create(img, w,h, Raster.BGRA8888);
  146. NEW(canvas,img);
  147. adrLabel.Draw(canvas);
  148. IF StartDrag(property.GetLink(),img,0,0,NIL,NIL) THEN END;
  149. END MyStartDrag;
  150. PROCEDURE InfoLabelMove(x, y : LONGINT; keys : SET; VAR handled : BOOLEAN);
  151. VAR dx, dy, dp, d : LONGINT; f : REAL; tmax, tmin : LONGINT;
  152. BEGIN
  153. IF keys = {0} THEN infoLabel.AutoStartDrag END;
  154. END InfoLabelMove;
  155. PROCEDURE InfoLabelStartDrag(sender, data: ANY);
  156. VAR w,h: LONGINT; img: WMGraphics.Image; canvas: WMGraphics.BufferCanvas; font: WMGraphics.Font; string: Strings.String;
  157. BEGIN
  158. IF info # NIL THEN string := info
  159. ELSIF name # NIL THEN string := name
  160. ELSE RETURN
  161. END;
  162. IF string = NIL THEN RETURN END;
  163. NEW(img);
  164. font := GetFont();
  165. font.GetStringSize(string^,w,h);
  166. INC(w,20); INC(h,5);
  167. Raster.Create(img, w,h, Raster.BGRA8888);
  168. NEW(canvas,img);
  169. canvas.SetFont(font);
  170. canvas.SetColor(LONGINT(0FFFFFFFFH));
  171. canvas.Fill(WMRectangles.MakeRect(0, 0, w, h), LONGINT(0333333FFH), WMGraphics.ModeCopy);
  172. WMGraphics.DrawStringInRect(canvas, WMRectangles.MakeRect(0, 0, w, h), FALSE, 1, 1, string^);
  173. IF StartDrag(NIL,img,0,0,NIL,NIL) THEN END;
  174. END InfoLabelStartDrag;
  175. PROCEDURE MyDragDropped(x,y: LONGINT; dragInfo: WMWindowManager.DragInfo; VAR handled: BOOLEAN);
  176. VAR ref,sender: ANY; dt: DropTarget; pos: LONGINT;
  177. BEGIN
  178. ref := dragInfo.data;
  179. sender := dragInfo.sender;
  180. IF (ref # NIL) & (ref IS Repositories.Component) THEN
  181. property.SetLink(ref(Repositories.Component));
  182. handled := TRUE;
  183. UpdateAdrLabel(property.GetLink());
  184. ELSIF ref = NIL THEN
  185. property.SetLink(NIL);
  186. handled := TRUE;
  187. UpdateAdrLabel(property.GetLink());
  188. NEW(dt, SELF, SetDroppedString, pos);
  189. dragInfo.data := dt;
  190. ConfirmDrag(TRUE, dragInfo);
  191. ELSE HALT(100);
  192. END;
  193. END MyDragDropped;
  194. PROCEDURE SetDroppedString( CONST string : ARRAY OF CHAR; position : LONGINT; VAR res : LONGINT);
  195. VAR object: ANY; gen: XML.GeneratorProcedure; moduleName, procedureName ,msg: Modules.Name; element: XML.Element;
  196. BEGIN
  197. Commands.Split(string, moduleName, procedureName, res, msg);
  198. IF (res = Commands.Ok) THEN
  199. GETPROCEDURE(moduleName, procedureName, gen);
  200. END;
  201. IF gen # NIL THEN
  202. element := gen();
  203. IF (element # NIL) & (element IS Repositories.Component) THEN
  204. property.SetLink(element(Repositories.Component));
  205. res := 1;
  206. RETURN
  207. END;
  208. END;
  209. property.SetLinkAsString(string);
  210. object := property.GetLink();
  211. res := 1; (* to avoid removal of source *)
  212. END SetDroppedString;
  213. (* Apply the settings of the view to the property *)
  214. PROCEDURE Apply(force : BOOLEAN);
  215. END Apply;
  216. PROCEDURE Synchronize(force : BOOLEAN);
  217. BEGIN
  218. IF property # NIL THEN
  219. UpdateAdrLabel(property.GetLink())
  220. END;
  221. END Synchronize;
  222. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  223. END IsCompatible;
  224. PROCEDURE Enable;
  225. END Enable;
  226. PROCEDURE Disable;
  227. END Disable;
  228. PROCEDURE Draw(canvas : WMGraphics.Canvas);
  229. BEGIN
  230. Draw^(canvas);
  231. (*
  232. IF (ofsName >= 0) THEN
  233. IF (name # NIL) THEN
  234. canvas.DrawString(ofsName, 14, name^);
  235. ELSE
  236. canvas.DrawString(ofsName, 14, "NoName");
  237. END;
  238. END;
  239. IF (ofsInfo >= 0) THEN
  240. IF (info # NIL) THEN
  241. canvas.DrawString(ofsInfo, 14, info^);
  242. ELSE
  243. canvas.DrawString(ofsInfo, 14, "NoDescription");
  244. END;
  245. END;
  246. *)
  247. END Draw;
  248. PROCEDURE SetProperty(property : WMProperties.Property);
  249. BEGIN
  250. SELF.property := property;
  251. IF (property # NIL) THEN
  252. GetPropertyType(property, type);
  253. name := property.GetName();
  254. info := property.GetInfo();
  255. lastTimestamp := property.GetTimestamp() - 1;
  256. IF (info # NIL) & (info^ # "") THEN
  257. infoLabel.caption.SetAOC("i");
  258. infoLabel.fillColor.Set(0FFFF88FFH);
  259. ELSE
  260. infoLabel.caption.SetAOC("");
  261. infoLabel.fillColor.Set(0);
  262. END;
  263. IF name # NIL THEN
  264. nameLabel.caption.SetAOC(name^);
  265. nameLabel.fillColor.Set(0FFFF88FFH);
  266. ELSE
  267. nameLabel.caption.SetAOC("Unnamed");
  268. nameLabel.fillColor.Set(0);
  269. END;
  270. ELSE
  271. nameLabel.caption.SetAOC("");
  272. infoLabel.caption.SetAOC("");
  273. nameLabel.fillColor.Set(0);
  274. infoLabel.fillColor.Set(0);
  275. name := NIL;
  276. info := NIL;
  277. END;
  278. END SetProperty;
  279. END PropertyView;
  280. TYPE
  281. EnumeratorProc = PROCEDURE {DELEGATE} (p : PropertyView; force : BOOLEAN);
  282. PropertyViewArray = POINTER TO ARRAY OF PropertyView;
  283. PropertyViewList = OBJECT
  284. VAR
  285. head, tail : PropertyView;
  286. nofElements : LONGINT;
  287. PROCEDURE &Init;
  288. BEGIN
  289. head := NIL; tail := NIL;
  290. nofElements := 0;
  291. END Init;
  292. PROCEDURE Add(p : PropertyView);
  293. BEGIN {EXCLUSIVE}
  294. ASSERT((p # NIL) & (p.next = NIL));
  295. IF (head = NIL) THEN
  296. ASSERT(tail = NIL);
  297. head := p; tail := p;
  298. ELSE
  299. tail.next := p;
  300. tail := p;
  301. END;
  302. INC(nofElements);
  303. END Add;
  304. PROCEDURE RemoveAll;
  305. BEGIN {EXCLUSIVE}
  306. head := NIL; tail := NIL;
  307. nofElements := 0;
  308. END RemoveAll;
  309. PROCEDURE Enumerate(enumeratorProc : EnumeratorProc; force : BOOLEAN);
  310. VAR p : PropertyView;
  311. BEGIN {EXCLUSIVE}
  312. ASSERT(enumeratorProc # NIL);
  313. p := head;
  314. WHILE (p # NIL) DO
  315. enumeratorProc(p, force);
  316. IF (p.next # NIL) THEN
  317. p := p.next (PropertyView);
  318. ELSE
  319. p := NIL;
  320. END;
  321. END;
  322. END Enumerate;
  323. PROCEDURE GetAll() : PropertyViewArray;
  324. VAR pva : PropertyViewArray; cur : PropertyView; i : LONGINT;
  325. BEGIN
  326. IF (nofElements > 0) THEN
  327. NEW(pva, nofElements);
  328. cur := head;
  329. FOR i := 0 TO nofElements - 1 DO
  330. pva[i] := cur; cur := cur.next;
  331. END;
  332. ELSE
  333. pva := NIL;
  334. END;
  335. RETURN pva;
  336. END GetAll;
  337. END PropertyViewList;
  338. TYPE
  339. BooleanPropertyView = OBJECT(PropertyView)
  340. VAR
  341. boolean : WMProperties.BooleanProperty;
  342. checkbox : WMStandardComponents.Checkbox;
  343. PROCEDURE &Init;
  344. BEGIN
  345. Init^;
  346. SetNameAsString(StrBooleanPropertyView);
  347. NEW(checkbox); checkbox.alignment.Set(WMComponents.AlignLeft);
  348. checkbox.bounds.SetWidth(LineHeight);
  349. checkbox.onClick.Add(CheckboxClicked);
  350. AddContent(checkbox);
  351. END Init;
  352. PROCEDURE Apply(force : BOOLEAN);
  353. VAR boolean : WMProperties.BooleanProperty; value : BOOLEAN; state : LONGINT;
  354. BEGIN
  355. boolean := SELF.boolean;
  356. IF (boolean # NIL) THEN
  357. state := checkbox.state.Get();
  358. value := boolean.Get();
  359. IF force OR ((value & (state # WMStandardComponents.Checked)) OR (~value & (state # WMStandardComponents.Unchecked))) THEN
  360. IF (state = WMStandardComponents.Checked) THEN
  361. boolean.Set(TRUE);
  362. ELSIF (state = WMStandardComponents.Unchecked) THEN
  363. boolean.Set(FALSE);
  364. ELSE
  365. HALT(99);
  366. END;
  367. END;
  368. END;
  369. END Apply;
  370. PROCEDURE Synchronize(force : BOOLEAN);
  371. VAR boolean : WMProperties.BooleanProperty; state : LONGINT;
  372. BEGIN
  373. Synchronize^(force);
  374. boolean := SELF.boolean;
  375. IF (boolean # NIL) & (force OR (lastTimestamp # boolean.GetTimestamp())) THEN
  376. lastTimestamp := boolean.GetTimestamp();
  377. IF (boolean.Get()) THEN
  378. state := WMStandardComponents.Checked;
  379. ELSE
  380. state := WMStandardComponents.Unchecked;
  381. END;
  382. checkbox.state.Set(state);
  383. END;
  384. END Synchronize;
  385. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  386. BEGIN
  387. RETURN (property # NIL) & (property IS WMProperties.BooleanProperty);
  388. END IsCompatible;
  389. PROCEDURE Enable;
  390. BEGIN
  391. checkbox.enabled.Set(TRUE);
  392. END Enable;
  393. PROCEDURE Disable;
  394. BEGIN
  395. checkbox.enabled.Set(FALSE);
  396. END Disable;
  397. PROCEDURE SetProperty(property : WMProperties.Property);
  398. BEGIN
  399. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.BooleanProperty)));
  400. SetProperty^(property);
  401. IF (property # NIL) THEN
  402. SELF.boolean := property (WMProperties.BooleanProperty);
  403. ELSE
  404. SELF.boolean := NIL;
  405. checkbox.state.Set(WMStandardComponents.Unchecked);
  406. END;
  407. END SetProperty;
  408. PROCEDURE CheckboxClicked(sender, data : ANY);
  409. BEGIN
  410. Apply(FALSE);
  411. END CheckboxClicked;
  412. END BooleanPropertyView;
  413. TYPE
  414. Int32PropertyView = OBJECT(PropertyView)
  415. VAR
  416. int32 : WMProperties.Int32Property;
  417. editor : WMEditors.TextField;
  418. outOfDate : BOOLEAN;
  419. PROCEDURE &Init;
  420. BEGIN
  421. Init^;
  422. SetNameAsString(StrInt32PropertyView);
  423. outOfDate := FALSE;
  424. NEW(editor); editor.alignment.Set(WMComponents.AlignLeft);
  425. editor.type.Set(WMEditors.Decimal);
  426. editor.bounds.SetWidth(80);
  427. editor.onEnter.Add(EnterPressed);
  428. editor.onChanged.Add(EditorContentChanged);
  429. AddContent(editor);
  430. END Init;
  431. PROCEDURE Apply(force : BOOLEAN);
  432. VAR int32 : WMProperties.Int32Property; string : ARRAY 256 OF CHAR; value : LONGINT;
  433. BEGIN
  434. int32 := SELF.int32;
  435. IF (int32 # NIL) THEN
  436. editor.GetAsString(string);
  437. Strings.StrToInt(string, value);
  438. IF force OR (value # int32.Get()) THEN
  439. int32.Set(value);
  440. ELSE
  441. SetOutOfDate(FALSE);
  442. END;
  443. END;
  444. END Apply;
  445. PROCEDURE Synchronize(force : BOOLEAN);
  446. VAR int32 : WMProperties.Int32Property; value : LONGINT; string : ARRAY 256 OF CHAR;
  447. BEGIN
  448. Synchronize^(force);
  449. int32 := SELF.int32;
  450. IF (int32 # NIL) & (force OR (lastTimestamp # int32.GetTimestamp())) THEN
  451. lastTimestamp := int32.GetTimestamp();
  452. value := int32.Get();
  453. Strings.IntToStr(value, string);
  454. editor.SetAsString(string);
  455. SetOutOfDate(FALSE);
  456. END;
  457. END Synchronize;
  458. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  459. BEGIN
  460. RETURN (property # NIL) & (property IS WMProperties.Int32Property);
  461. END IsCompatible;
  462. PROCEDURE Enable;
  463. BEGIN
  464. editor.enabled.Set(TRUE);
  465. END Enable;
  466. PROCEDURE Disable;
  467. BEGIN
  468. editor.enabled.Set(FALSE);
  469. END Disable;
  470. PROCEDURE SetProperty(property : WMProperties.Property);
  471. BEGIN
  472. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.Int32Property)));
  473. SetProperty^(property);
  474. IF (property # NIL) THEN
  475. SELF.int32 := property (WMProperties.Int32Property);
  476. ELSE
  477. SELF.int32 := NIL;
  478. editor.SetAsString("");
  479. END;
  480. END SetProperty;
  481. PROCEDURE SetOutOfDate(value : BOOLEAN);
  482. BEGIN
  483. IF (outOfDate # value) THEN
  484. outOfDate := value;
  485. IF outOfDate THEN
  486. editor.fillColor.Set(LONGINT(0FFFF0099H));
  487. ELSE
  488. editor.fillColor.Set(WMGraphics.White);
  489. END;
  490. END;
  491. END SetOutOfDate;
  492. PROCEDURE EditorContentChanged(sender, data : ANY);
  493. BEGIN
  494. SetOutOfDate(TRUE);
  495. END EditorContentChanged;
  496. PROCEDURE EnterPressed(sender, data : ANY);
  497. BEGIN
  498. Apply(FALSE);
  499. END EnterPressed;
  500. END Int32PropertyView;
  501. TYPE
  502. RealPropertyView = OBJECT(PropertyView)
  503. VAR
  504. real : WMProperties.RealProperty;
  505. editor : WMEditors.TextField;
  506. outOfDate : BOOLEAN;
  507. PROCEDURE &Init;
  508. BEGIN
  509. Init^;
  510. SetNameAsString(StrRealPropertyView);
  511. outOfDate := FALSE;
  512. NEW(editor); editor.alignment.Set(WMComponents.AlignLeft);
  513. editor.type.Set(WMEditors.Ascii);
  514. editor.bounds.SetWidth(80);
  515. editor.onEnter.Add(EnterPressed);
  516. editor.onChanged.Add(EditorContentChanged);
  517. AddContent(editor);
  518. END Init;
  519. PROCEDURE Apply(force : BOOLEAN);
  520. VAR real : WMProperties.RealProperty; string : ARRAY 256 OF CHAR; value : LONGREAL;
  521. BEGIN
  522. real := SELF.real;
  523. IF (real # NIL) THEN
  524. editor.GetAsString(string);
  525. Strings.StrToFloat(string, value);
  526. IF force OR (value # real.Get()) THEN
  527. real.Set(value);
  528. ELSE
  529. SetOutOfDate(FALSE);
  530. END;
  531. END;
  532. END Apply;
  533. PROCEDURE Synchronize(force : BOOLEAN);
  534. VAR real : WMProperties.RealProperty; value : LONGREAL; string : ARRAY 256 OF CHAR; sw: Streams.StringWriter;
  535. BEGIN
  536. Synchronize^(force);
  537. real := SELF.real;
  538. IF (real # NIL) & (force OR (lastTimestamp # real.GetTimestamp())) THEN
  539. lastTimestamp := real.GetTimestamp();
  540. value := real.Get();
  541. (*Strings.FloatToStr(value, 0, 16, 0, string);*) (*PH2012*)(*! to do: this string procedure is not suited for exponents*)
  542. (*workaround: *)
  543. NEW(sw, 30);
  544. sw.Float(value,24);
  545. sw.Get(string);
  546. editor.SetAsString(string);
  547. SetOutOfDate(FALSE);
  548. END;
  549. END Synchronize;
  550. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  551. BEGIN
  552. RETURN (property # NIL) & (property IS WMProperties.RealProperty);
  553. END IsCompatible;
  554. PROCEDURE Enable;
  555. BEGIN
  556. editor.enabled.Set(TRUE);
  557. END Enable;
  558. PROCEDURE Disable;
  559. BEGIN
  560. editor.enabled.Set(FALSE);
  561. END Disable;
  562. PROCEDURE SetProperty(property : WMProperties.Property);
  563. BEGIN
  564. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.RealProperty)));
  565. SetProperty^(property);
  566. IF (property # NIL) THEN
  567. SELF.real := property (WMProperties.RealProperty);
  568. ELSE
  569. SELF.real := NIL;
  570. editor.SetAsString("");
  571. END;
  572. END SetProperty;
  573. PROCEDURE SetOutOfDate(value : BOOLEAN);
  574. BEGIN
  575. IF (outOfDate # value) THEN
  576. outOfDate := value;
  577. IF outOfDate THEN
  578. editor.fillColor.Set(LONGINT(0FFFF0099H));
  579. ELSE
  580. editor.fillColor.Set(WMGraphics.White);
  581. END;
  582. END;
  583. END SetOutOfDate;
  584. PROCEDURE EditorContentChanged(sender, data : ANY);
  585. BEGIN
  586. SetOutOfDate(TRUE);
  587. END EditorContentChanged;
  588. PROCEDURE EnterPressed(sender, data : ANY);
  589. BEGIN
  590. Apply(FALSE);
  591. END EnterPressed;
  592. END RealPropertyView;
  593. TYPE
  594. RectanglePropertyView = OBJECT(PropertyView)
  595. VAR
  596. rectangle : WMProperties.RectangleProperty;
  597. editLeft, editTop, editRight, editBottom, editWidth, editHeight : WMEditors.TextField;
  598. enabled, outOfDate : SET;
  599. PROCEDURE &New(wh : BOOLEAN);
  600. BEGIN
  601. Init;
  602. SetNameAsString(StrRectanglePropertyView);
  603. ofsInfo := -1;
  604. CreateEditor("Left:", editLeft, 0);
  605. CreateEditor("Top:", editTop, 0);
  606. CreateEditor("Right: ", editRight, 0);
  607. CreateEditor("Bottom:", editBottom, 0);
  608. IF wh THEN
  609. CreateEditor("Width: ", editWidth, 0);
  610. CreateEditor("Height:", editHeight, 0);
  611. END;
  612. enabled := {0..5};
  613. outOfDate := {};
  614. END New;
  615. PROCEDURE UpdateEditorStates;
  616. PROCEDURE UpdateState(editor : WMEditors.TextField; number: LONGINT);
  617. BEGIN
  618. IF (number IN enabled) THEN
  619. editor.enabled.Set(TRUE);
  620. IF (number IN outOfDate) THEN
  621. editor.fillColor.Set(LONGINT(0FFFF0099H));
  622. ELSE
  623. editor.fillColor.Set(WMGraphics.White);
  624. END;
  625. ELSE
  626. editor.enabled.Set(FALSE);
  627. editor.fillColor.Set(0CCCCCCCCH);
  628. END;
  629. END UpdateState;
  630. BEGIN
  631. UpdateState(editLeft, 0);
  632. UpdateState(editTop, 1);
  633. UpdateState(editRight, 2);
  634. UpdateState(editBottom, 3);
  635. IF (editWidth # NIL) THEN UpdateState(editWidth, 4); END;
  636. IF (editHeight # NIL) THEN UpdateState(editHeight, 5); END;
  637. END UpdateEditorStates;
  638. PROCEDURE Apply(force : BOOLEAN);
  639. VAR rectangle : WMProperties.RectangleProperty; rect, r : WMRectangles.Rectangle; string : ARRAY 32 OF CHAR;
  640. width, height: LONGINT;
  641. BEGIN
  642. rectangle := SELF.rectangle;
  643. IF (rectangle # NIL) THEN
  644. editLeft.GetAsString(string); Strings.StrToInt(string, rect.l);
  645. editTop.GetAsString(string); Strings.StrToInt(string, rect.t);
  646. editRight.GetAsString(string); Strings.StrToInt(string, rect.r);
  647. editBottom.GetAsString(string); Strings.StrToInt(string, rect.b);
  648. IF editWidth # NIL THEN editWidth.GetAsString(string); Strings.StrToInt(string, width) ELSE width := rect.r-rect.l END;
  649. IF editHeight # NIL THEN editHeight.GetAsString(string); Strings.StrToInt(string, height) ELSE height := rect.t- rect.b END;
  650. IF 5 IN outOfDate THEN rect.t := rect.b - height END;
  651. IF 4 IN outOfDate THEN rect.r := rect.l + width END;
  652. r := rectangle.Get();
  653. IF force OR ~WMRectangles.IsEqual(r, rect) THEN
  654. rectangle.Set(rect);
  655. ELSE
  656. SetOutOfDate({});
  657. END;
  658. END;
  659. END Apply;
  660. PROCEDURE Synchronize(force : BOOLEAN);
  661. VAR rectangle : WMProperties.RectangleProperty; rect : WMRectangles.Rectangle; string : ARRAY 32 OF CHAR;
  662. BEGIN
  663. Synchronize^(force);
  664. rectangle := SELF.rectangle;
  665. IF (rectangle # NIL) & (force OR (lastTimestamp # rectangle.GetTimestamp())) THEN
  666. lastTimestamp := rectangle.GetTimestamp();
  667. rect := rectangle.Get();
  668. Strings.IntToStr(rect.l, string); editLeft.SetAsString(string);
  669. Strings.IntToStr(rect.t, string); editTop.SetAsString(string);
  670. Strings.IntToStr(rect.r, string); editRight.SetAsString(string);
  671. Strings.IntToStr(rect.b, string); editBottom.SetAsString(string);
  672. IF (editWidth # NIL) & (editHeight # NIL) THEN
  673. Strings.IntToStr(rect.r - rect.l, string); editWidth.SetAsString(string);
  674. Strings.IntToStr(rect.b - rect.t, string); editHeight.SetAsString(string);
  675. END;
  676. SetOutOfDate({});
  677. END;
  678. END Synchronize;
  679. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  680. BEGIN
  681. RETURN (property # NIL) & (property IS WMProperties.RectangleProperty);
  682. END IsCompatible;
  683. PROCEDURE Enable;
  684. BEGIN
  685. UpdateEditorStates;
  686. END Enable;
  687. PROCEDURE Disable;
  688. BEGIN
  689. editLeft.enabled.Set(FALSE); editTop.enabled.Set(FALSE); editRight.enabled.Set(FALSE); editBottom.enabled.Set(FALSE);
  690. IF (editWidth # NIL) THEN editWidth.enabled.Set(FALSE); END;
  691. IF (editHeight # NIL) THEN editHeight.enabled.Set(FALSE); END;
  692. END Disable;
  693. PROCEDURE SetProperty(property : WMProperties.Property);
  694. BEGIN
  695. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.RectangleProperty)));
  696. SetProperty^(property);
  697. IF (property # NIL) THEN
  698. SELF.rectangle := property (WMProperties.RectangleProperty);
  699. ELSE
  700. SELF.rectangle := NIL;
  701. editLeft.SetAsString(""); editTop.SetAsString(""); editRight.SetAsString(""); editBottom.SetAsString("");
  702. IF (editWidth # NIL) & (editHeight # NIL) THEN editWidth.SetAsString(""); editHeight.SetAsString(""); END;
  703. END;
  704. END SetProperty;
  705. PROCEDURE SetEnabled(value : SET);
  706. BEGIN
  707. IF (value # enabled) THEN
  708. enabled := value;
  709. UpdateEditorStates;
  710. END;
  711. END SetEnabled;
  712. PROCEDURE SetOutOfDate(value : SET);
  713. BEGIN
  714. IF (outOfDate # value) THEN
  715. outOfDate := value;
  716. UpdateEditorStates;
  717. END;
  718. END SetOutOfDate;
  719. PROCEDURE EditorContentChanged(sender, data : ANY);
  720. VAR s : SET;
  721. BEGIN
  722. s := outOfDate;
  723. IF (sender = editLeft) THEN INCL(s, 0);
  724. ELSIF (sender = editTop) THEN INCL(s, 1);
  725. ELSIF (sender = editRight) THEN INCL(s, 2);
  726. ELSIF (sender = editBottom) THEN INCL(s, 3);
  727. ELSIF (sender = editWidth) THEN INCL(s, 4);
  728. ELSIF (sender = editHeight) THEN INCL(s, 5);
  729. END;
  730. SetOutOfDate(s);
  731. END EditorContentChanged;
  732. PROCEDURE EnterPressed(sender, data : ANY);
  733. BEGIN
  734. Apply(FALSE);
  735. END EnterPressed;
  736. PROCEDURE CreateEditor(CONST caption : ARRAY OF CHAR; VAR editor : WMEditors.TextField; leftBearing : LONGINT);
  737. VAR label : WMStandardComponents.Label;
  738. BEGIN
  739. NEW(label); label.alignment.Set(WMComponents.AlignLeft);
  740. label.bounds.SetWidth(50);
  741. label.alignH.Set(WMGraphics.AlignCenter);
  742. label.caption.SetAOC(caption);
  743. IF (leftBearing # 0) THEN
  744. label.bearing.Set(WMRectangles.MakeRect(leftBearing, 0, 0, 0));
  745. END;
  746. AddContent(label);
  747. NEW(editor); editor.alignment.Set(WMComponents.AlignLeft);
  748. editor.bounds.SetWidth(40);
  749. editor.onEnter.Add(EnterPressed);
  750. editor.onChanged.Add(EditorContentChanged);
  751. editor.type.Set(WMEditors.Decimal);
  752. AddContent(editor);
  753. END CreateEditor;
  754. END RectanglePropertyView;
  755. TYPE
  756. PointPropertyView = OBJECT(PropertyView)
  757. VAR
  758. point : WMProperties.PointProperty;
  759. editX, editY : WMEditors.TextField;
  760. enabled, outOfDate : SET;
  761. PROCEDURE &New(wh : BOOLEAN);
  762. BEGIN
  763. Init;
  764. SetNameAsString(StrPointPropertyView);
  765. ofsInfo := -1;
  766. CreateEditor("X:", editX, 0);
  767. CreateEditor("Y:", editY, 0);
  768. enabled := {0..5};
  769. outOfDate := {};
  770. END New;
  771. PROCEDURE UpdateEditorStates;
  772. PROCEDURE UpdateState(editor : WMEditors.TextField; number: LONGINT);
  773. BEGIN
  774. IF (number IN enabled) THEN
  775. editor.enabled.Set(TRUE);
  776. IF (number IN outOfDate) THEN
  777. editor.fillColor.Set(LONGINT(0FFFF0099H));
  778. ELSE
  779. editor.fillColor.Set(WMGraphics.White);
  780. END;
  781. ELSE
  782. editor.enabled.Set(FALSE);
  783. editor.fillColor.Set(0CCCCCCCCH);
  784. END;
  785. END UpdateState;
  786. BEGIN
  787. UpdateState(editX, 0);
  788. UpdateState(editY, 1);
  789. END UpdateEditorStates;
  790. PROCEDURE Apply(force : BOOLEAN);
  791. VAR point : WMProperties.PointProperty; pnt, p : WMGraphics.Point2d; string : ARRAY 32 OF CHAR;
  792. BEGIN
  793. point := SELF.point;
  794. IF (point # NIL) THEN
  795. editX.GetAsString(string); Strings.StrToInt(string, pnt.x);
  796. editY.GetAsString(string); Strings.StrToInt(string, pnt.y);
  797. p := point.Get();
  798. IF force OR (p.x#pnt.x) OR (p.y#pnt.y) THEN
  799. point.Set(pnt);
  800. ELSE
  801. SetOutOfDate({});
  802. END;
  803. END;
  804. END Apply;
  805. PROCEDURE Synchronize(force : BOOLEAN);
  806. VAR point : WMProperties.PointProperty; pnt : WMGraphics.Point2d; string : ARRAY 32 OF CHAR;
  807. BEGIN
  808. Synchronize^(force);
  809. point := SELF.point;
  810. IF (point # NIL) & (force OR (lastTimestamp # point.GetTimestamp())) THEN
  811. lastTimestamp := point.GetTimestamp();
  812. pnt := point.Get();
  813. Strings.IntToStr(pnt.x, string); editX.SetAsString(string);
  814. Strings.IntToStr(pnt.y, string); editY.SetAsString(string);
  815. SetOutOfDate({});
  816. END;
  817. END Synchronize;
  818. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  819. BEGIN
  820. RETURN (property # NIL) & (property IS WMProperties.PointProperty);
  821. END IsCompatible;
  822. PROCEDURE Enable;
  823. BEGIN
  824. UpdateEditorStates;
  825. END Enable;
  826. PROCEDURE Disable;
  827. BEGIN
  828. editX.enabled.Set(FALSE); editY.enabled.Set(FALSE);
  829. END Disable;
  830. PROCEDURE SetProperty(property : WMProperties.Property);
  831. BEGIN
  832. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.PointProperty)));
  833. SetProperty^(property);
  834. IF (property # NIL) THEN
  835. SELF.point := property (WMProperties.PointProperty);
  836. ELSE
  837. SELF.point := NIL;
  838. editX.SetAsString(""); editY.SetAsString("");
  839. END;
  840. END SetProperty;
  841. PROCEDURE SetEnabled(value : SET);
  842. BEGIN
  843. IF (value # enabled) THEN
  844. enabled := value;
  845. UpdateEditorStates;
  846. END;
  847. END SetEnabled;
  848. PROCEDURE SetOutOfDate(value : SET);
  849. BEGIN
  850. IF (outOfDate # value) THEN
  851. outOfDate := value;
  852. UpdateEditorStates;
  853. END;
  854. END SetOutOfDate;
  855. PROCEDURE EditorContentChanged(sender, data : ANY);
  856. VAR s : SET;
  857. BEGIN
  858. s := outOfDate;
  859. IF (sender = editX) THEN INCL(s, 0);
  860. ELSIF (sender = editY) THEN INCL(s, 1);
  861. END;
  862. SetOutOfDate(s);
  863. END EditorContentChanged;
  864. PROCEDURE EnterPressed(sender, data : ANY);
  865. BEGIN
  866. Apply(FALSE);
  867. END EnterPressed;
  868. PROCEDURE CreateEditor(CONST caption : ARRAY OF CHAR; VAR editor : WMEditors.TextField; leftBearing : LONGINT);
  869. VAR label : WMStandardComponents.Label;
  870. BEGIN
  871. NEW(label); label.alignment.Set(WMComponents.AlignLeft);
  872. label.bounds.SetWidth(50);
  873. label.alignH.Set(WMGraphics.AlignCenter);
  874. label.caption.SetAOC(caption);
  875. IF (leftBearing # 0) THEN
  876. label.bearing.Set(WMRectangles.MakeRect(leftBearing, 0, 0, 0));
  877. END;
  878. AddContent(label);
  879. NEW(editor); editor.alignment.Set(WMComponents.AlignLeft);
  880. editor.bounds.SetWidth(40);
  881. editor.onEnter.Add(EnterPressed);
  882. editor.onChanged.Add(EditorContentChanged);
  883. editor.type.Set(WMEditors.Decimal);
  884. AddContent(editor);
  885. END CreateEditor;
  886. END PointPropertyView;
  887. TYPE
  888. StringPropertyView = OBJECT(PropertyView)
  889. VAR
  890. string : WMProperties.StringProperty;
  891. editor : WMEditors.TextField;
  892. outOfDate : BOOLEAN;
  893. PROCEDURE &Init;
  894. BEGIN
  895. Init^;
  896. SetNameAsString(StrStringPropertyView);
  897. ofsInfo := -1;
  898. NEW(editor); editor.alignment.Set(WMComponents.AlignClient);
  899. editor.onChanged.Add(EditorContentChanged);
  900. editor.onEnter.Add(EnterPressed);
  901. AddContent(editor);
  902. outOfDate := FALSE;
  903. END Init;
  904. PROCEDURE Apply(force : BOOLEAN);
  905. VAR string : WMProperties.StringProperty; value, oldValue : ARRAY 1024 OF CHAR;
  906. BEGIN
  907. string := SELF.string;
  908. IF (string # NIL) THEN
  909. editor.GetAsString(value);
  910. string.GetAOC(oldValue);
  911. IF force OR (value # oldValue) THEN
  912. string.SetAOC(value);
  913. ELSE
  914. SetOutOfDate(FALSE);
  915. END;
  916. END;
  917. END Apply;
  918. PROCEDURE Synchronize(force : BOOLEAN);
  919. VAR string : WMProperties.StringProperty; value : Strings.String;
  920. BEGIN
  921. Synchronize^(force);
  922. string := SELF.string;
  923. IF (string # NIL) & (force OR (lastTimestamp # string.GetTimestamp())) THEN
  924. lastTimestamp := string.GetTimestamp();
  925. value := string.Get();
  926. IF (value # NIL) THEN editor.SetAsString(value^); ELSE editor.SetAsString(""); END;
  927. SetOutOfDate(FALSE);
  928. END;
  929. END Synchronize;
  930. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  931. BEGIN
  932. RETURN (property # NIL) & (property IS WMProperties.StringProperty);
  933. END IsCompatible;
  934. PROCEDURE Enable;
  935. BEGIN
  936. editor.enabled.Set(TRUE);
  937. END Enable;
  938. PROCEDURE Disable;
  939. BEGIN
  940. editor.enabled.Set(FALSE);
  941. END Disable;
  942. PROCEDURE SetProperty(property : WMProperties.Property);
  943. BEGIN
  944. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.StringProperty)));
  945. SetProperty^(property);
  946. IF (property # NIL) THEN
  947. SELF.string := property (WMProperties.StringProperty);
  948. ELSE
  949. SELF.string := NIL;
  950. editor.SetAsString("");
  951. END;
  952. END SetProperty;
  953. PROCEDURE SetOutOfDate(value : BOOLEAN);
  954. BEGIN
  955. IF (outOfDate # value) THEN
  956. outOfDate := value;
  957. IF outOfDate THEN
  958. editor.fillColor.Set(LONGINT(0FFFF0099H));
  959. ELSE
  960. editor.fillColor.Set(WMGraphics.White);
  961. END;
  962. END;
  963. END SetOutOfDate;
  964. PROCEDURE EditorContentChanged(sender, data : ANY);
  965. BEGIN
  966. SetOutOfDate(TRUE);
  967. END EditorContentChanged;
  968. PROCEDURE EnterPressed(sender, data : ANY);
  969. BEGIN
  970. Apply(FALSE);
  971. END EnterPressed;
  972. END StringPropertyView;
  973. TYPE
  974. ColorPropertyView = OBJECT(PropertyView)
  975. VAR
  976. color : WMProperties.ColorProperty;
  977. editor : WMEditors.TextField;
  978. colorPot : WMColorComponents.ColorPot;
  979. res : LONGINT;
  980. outOfDate : BOOLEAN;
  981. PROCEDURE &Init;
  982. BEGIN
  983. Init^;
  984. SetNameAsString(StrColorPropertyView);
  985. outOfDate := FALSE;
  986. NEW(colorPot); colorPot.alignment.Set(WMComponents.AlignLeft);
  987. colorPot.bounds.SetWidth(20);
  988. colorPot.SetExternalColorChangeHandler(ColorDropped);
  989. AddContent(colorPot);
  990. NEW(editor); editor.alignment.Set(WMComponents.AlignLeft);
  991. editor.type.Set(WMEditors.Hex);
  992. editor.bounds.SetWidth(70);
  993. editor.onEnter.Add(EnterPressed);
  994. editor.onChanged.Add(EditorContentChanged);
  995. AddContent(editor);
  996. END Init;
  997. PROCEDURE Apply(force : BOOLEAN);
  998. VAR color : WMProperties.ColorProperty; string : ARRAY 16 OF CHAR; value : LONGINT;
  999. BEGIN
  1000. color := SELF.color;
  1001. IF (color # NIL) THEN
  1002. editor.GetAsString(string);
  1003. Strings.HexStrToInt(string, value, res);
  1004. IF force OR (value # color.Get()) THEN
  1005. color.Set(value);
  1006. colorPot.fillColor.Set(value);
  1007. ELSE
  1008. SetOutOfDate(FALSE);
  1009. END;
  1010. END;
  1011. END Apply;
  1012. PROCEDURE Synchronize(force : BOOLEAN);
  1013. VAR color : WMProperties.ColorProperty; string : ARRAY 16 OF CHAR; value : LONGINT;
  1014. BEGIN
  1015. Synchronize^(force);
  1016. color := SELF.color;
  1017. IF (color # NIL) & (force OR (lastTimestamp # color.GetTimestamp())) THEN
  1018. lastTimestamp := color.GetTimestamp();
  1019. value := color.Get();
  1020. Strings.IntToHexStr(value, 8, string);
  1021. editor.SetAsString(string);
  1022. colorPot.fillColor.Set(value);
  1023. SetOutOfDate(FALSE);
  1024. END;
  1025. END Synchronize;
  1026. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  1027. BEGIN
  1028. RETURN (property # NIL) & (property IS WMProperties.ColorProperty);
  1029. END IsCompatible;
  1030. PROCEDURE Enable;
  1031. BEGIN
  1032. editor.enabled.Set(TRUE); colorPot.enabled.Set(TRUE);
  1033. END Enable;
  1034. PROCEDURE Disable;
  1035. BEGIN
  1036. editor.enabled.Set(FALSE); colorPot.enabled.Set(FALSE);
  1037. END Disable;
  1038. PROCEDURE SetProperty(property : WMProperties.Property);
  1039. BEGIN
  1040. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.ColorProperty)));
  1041. SetProperty^(property);
  1042. IF (property # NIL) THEN
  1043. SELF.color := property (WMProperties.ColorProperty);
  1044. ELSE
  1045. SELF.color := NIL;
  1046. editor.SetAsString("");
  1047. colorPot.fillColor.Set(0);
  1048. END;
  1049. END SetProperty;
  1050. PROCEDURE SetOutOfDate(value : BOOLEAN);
  1051. BEGIN
  1052. IF (outOfDate # value) THEN
  1053. outOfDate := value;
  1054. IF outOfDate THEN
  1055. editor.fillColor.Set(LONGINT(0FFFF0099H));
  1056. ELSE
  1057. editor.fillColor.Set(WMGraphics.White);
  1058. END;
  1059. END;
  1060. END SetOutOfDate;
  1061. PROCEDURE EditorContentChanged(sender, data : ANY);
  1062. BEGIN
  1063. SetOutOfDate(TRUE);
  1064. END EditorContentChanged;
  1065. PROCEDURE EnterPressed(sender, data : ANY);
  1066. BEGIN
  1067. Apply(FALSE);
  1068. END EnterPressed;
  1069. PROCEDURE ColorDropped(sender, data : ANY);
  1070. VAR color : WMProperties.ColorProperty;
  1071. BEGIN
  1072. color := SELF.color;
  1073. IF (color # NIL) & (data # NIL) & (data IS WMColorComponents.Color) THEN
  1074. color.Set(data(WMColorComponents.Color).value);
  1075. END;
  1076. END ColorDropped;
  1077. END ColorPropertyView;
  1078. TYPE
  1079. FontPropertyView = OBJECT(PropertyView)
  1080. VAR
  1081. font : WMProperties.FontProperty;
  1082. editName, editSize, editStyle : WMEditors.TextField;
  1083. outOfDate : SET;
  1084. PROCEDURE &New;
  1085. BEGIN
  1086. Init;
  1087. SetNameAsString(StrFontPropertyView);
  1088. ofsInfo := -1;
  1089. NEW(editName); editName.alignment.Set(WMComponents.AlignLeft);
  1090. editName.bounds.SetWidth(80);
  1091. editName.onEnter.Add(EnterPressed);
  1092. editName.onChanged.Add(EditorContentChanged);
  1093. editName.type.Set(WMEditors.Unicode);
  1094. AddContent(editName);
  1095. CreateEditor("Size:", editSize, 0);
  1096. CreateEditor("Style: ", editStyle, 0);
  1097. editStyle.SetAsString("{}");
  1098. outOfDate := {};
  1099. END New;
  1100. PROCEDURE UpdateEditorStates;
  1101. PROCEDURE UpdateState(editor : WMEditors.TextField; number: LONGINT);
  1102. BEGIN
  1103. IF (number IN outOfDate) THEN
  1104. editor.fillColor.Set(LONGINT(0FFFF0099H));
  1105. ELSE
  1106. editor.fillColor.Set(WMGraphics.White);
  1107. END;
  1108. END UpdateState;
  1109. BEGIN
  1110. UpdateState(editName, 0);
  1111. UpdateState(editSize, 1);
  1112. UpdateState(editStyle, 2);
  1113. END UpdateEditorStates;
  1114. PROCEDURE Apply(force : BOOLEAN);
  1115. VAR font : WMProperties.FontProperty; f : WMGraphics.Font; temp, name : ARRAY 32 OF CHAR; size : LONGINT; style : SET;
  1116. BEGIN
  1117. font := SELF.font;
  1118. IF (font # NIL) THEN
  1119. editName.GetAsString(name);
  1120. editSize.GetAsString(temp); Strings.StrToInt(temp, size);
  1121. editStyle.GetAsString(temp); Strings.StrToSet(temp, style);
  1122. f := WMGraphics.GetFont(name, size, style);
  1123. IF (f = NIL) THEN f := WMGraphics.GetDefaultFont(); END;
  1124. IF force OR ~(f = font.Get()) THEN
  1125. font.Set(f);
  1126. ELSE
  1127. SetOutOfDate({});
  1128. END;
  1129. END;
  1130. END Apply;
  1131. PROCEDURE Synchronize(force : BOOLEAN);
  1132. VAR font : WMProperties.FontProperty; name, temp : ARRAY 32 OF CHAR; size : LONGINT; style : SET;
  1133. BEGIN
  1134. Synchronize^(force);
  1135. font := SELF.font;
  1136. IF (font # NIL) & (force OR (lastTimestamp # font.GetTimestamp())) THEN
  1137. lastTimestamp := font.GetTimestamp();
  1138. font.GetFont(name, size, style);
  1139. editName.SetAsString(name);
  1140. Strings.IntToStr(size, temp); editSize.SetAsString(temp);
  1141. Strings.SetToStr(style, temp); editStyle.SetAsString(temp);
  1142. SetOutOfDate({});
  1143. END;
  1144. END Synchronize;
  1145. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  1146. BEGIN
  1147. RETURN (property # NIL) & (property IS WMProperties.FontProperty);
  1148. END IsCompatible;
  1149. PROCEDURE Enable;
  1150. BEGIN
  1151. editName.enabled.Set(TRUE); editSize.enabled.Set(TRUE); editStyle.enabled.Set(TRUE);
  1152. END Enable;
  1153. PROCEDURE Disable;
  1154. BEGIN
  1155. editName.enabled.Set(FALSE); editSize.enabled.Set(FALSE); editStyle.enabled.Set(FALSE);
  1156. END Disable;
  1157. PROCEDURE SetProperty(property : WMProperties.Property);
  1158. BEGIN
  1159. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.FontProperty)));
  1160. SetProperty^(property);
  1161. IF (property # NIL) THEN
  1162. SELF.font := property (WMProperties.FontProperty);
  1163. ELSE
  1164. SELF.font := NIL;
  1165. editName.SetAsString(""); editSize.SetAsString(""); editStyle.SetAsString("{}");
  1166. END;
  1167. END SetProperty;
  1168. PROCEDURE SetOutOfDate(value : SET);
  1169. BEGIN
  1170. IF (outOfDate # value) THEN
  1171. outOfDate := value;
  1172. UpdateEditorStates;
  1173. END;
  1174. END SetOutOfDate;
  1175. PROCEDURE EditorContentChanged(sender, data : ANY);
  1176. VAR s : SET;
  1177. BEGIN
  1178. s := outOfDate;
  1179. IF (sender = editName) THEN INCL(s, 0);
  1180. ELSIF (sender = editSize) THEN INCL(s, 1);
  1181. ELSIF (sender = editStyle) THEN INCL(s, 2);
  1182. END;
  1183. SetOutOfDate(s);
  1184. END EditorContentChanged;
  1185. PROCEDURE EnterPressed(sender, data : ANY);
  1186. BEGIN
  1187. Apply(FALSE);
  1188. END EnterPressed;
  1189. PROCEDURE CreateEditor(CONST caption : ARRAY OF CHAR; VAR editor : WMEditors.TextField; leftBearing : LONGINT);
  1190. VAR label : WMStandardComponents.Label;
  1191. BEGIN
  1192. NEW(label); label.alignment.Set(WMComponents.AlignLeft);
  1193. label.bounds.SetWidth(50);
  1194. label.alignH.Set(WMGraphics.AlignCenter);
  1195. label.caption.SetAOC(caption);
  1196. IF (leftBearing # 0) THEN
  1197. label.bearing.Set(WMRectangles.MakeRect(leftBearing, 0, 0, 0));
  1198. END;
  1199. AddContent(label);
  1200. NEW(editor); editor.alignment.Set(WMComponents.AlignLeft);
  1201. editor.bounds.SetWidth(40);
  1202. editor.onEnter.Add(EnterPressed);
  1203. editor.onChanged.Add(EditorContentChanged);
  1204. editor.type.Set(WMEditors.Ascii);
  1205. AddContent(editor);
  1206. END CreateEditor;
  1207. END FontPropertyView;
  1208. TYPE
  1209. ReferencePropertyView = OBJECT(PropertyView)
  1210. VAR
  1211. reference : WMProperties.ReferenceProperty;
  1212. object : XML.Element;
  1213. editor : WMEditors.TextField;
  1214. button : WMStandardComponents.Button;
  1215. outOfDate : BOOLEAN;
  1216. PROCEDURE &Init;
  1217. BEGIN
  1218. Init^;
  1219. SetNameAsString(StrReferencePropertyView);
  1220. ofsInfo := -1;
  1221. reference := NIL;
  1222. object := NIL;
  1223. (*
  1224. NEW(adrLabel); adrLabel.alignment.Set(WMComponents.AlignLeft);
  1225. adrLabel.bounds.SetWidth(60);
  1226. adrLabel.fillColor.Set(0CCCCCCCH);
  1227. AddContent(adrLabel);
  1228. adrLabel.onStartDrag.Add(MyStartDrag);
  1229. adrLabel.SetExtPointerMoveHandler(AdrLabelMove);
  1230. adrLabel.SetExtDragDroppedHandler(MyDragDropped);
  1231. *)
  1232. NEW(button); button.alignment.Set(WMComponents.AlignRight);
  1233. button.bounds.SetWidth(60);
  1234. button.fillColor.Set(WMGraphics.Red);
  1235. button.enabled.Set(FALSE);
  1236. button.onClick.Add(HandleButton);
  1237. AddContent(button);
  1238. NEW(editor); editor.alignment.Set(WMComponents.AlignClient);
  1239. editor.type.Set(WMEditors.Ascii);
  1240. editor.onEnter.Add(EnterPressed);
  1241. editor.onChanged.Add(EditorContentChanged);
  1242. AddContent(editor);
  1243. outOfDate := FALSE;
  1244. END Init;
  1245. PROCEDURE AdrLabelMove(x, y : LONGINT; keys : SET; VAR handled : BOOLEAN);
  1246. VAR dx, dy, dp, d : LONGINT; f : REAL; tmax, tmin : LONGINT;
  1247. BEGIN
  1248. IF keys = {0} THEN adrLabel.AutoStartDrag END;
  1249. END AdrLabelMove;
  1250. PROCEDURE MyStartDrag(sender, data: ANY);
  1251. VAR w,h: LONGINT; img: WMGraphics.Image; canvas: WMGraphics.BufferCanvas;
  1252. BEGIN
  1253. NEW(img);
  1254. adrLabel.bounds.GetExtents(w,h);
  1255. Raster.Create(img, w,h, Raster.BGRA8888);
  1256. NEW(canvas,img);
  1257. adrLabel.Draw(canvas);
  1258. IF StartDrag(reference.Get(),img,0,0,NIL,NIL) THEN END;
  1259. END MyStartDrag;
  1260. PROCEDURE HandleButton(sender, data : ANY);
  1261. VAR object : XML.Element; modelView : ModelView; window : Window; propertyPanel: PropertyPanel;
  1262. BEGIN
  1263. object := SELF.object;
  1264. IF (object # NIL) & (object IS Models.Model) THEN
  1265. NEW(modelView); modelView.SetModel(object(Models.Model));
  1266. modelView.bounds.SetExtents(ModelWindowWidth, ModelWindowHeight);
  1267. modelView.fillColor.Set(WMGraphics.White);
  1268. NEW(window, modelView);
  1269. END;
  1270. IF (object # NIL) & (object IS WMComponents.Component) THEN
  1271. NEW(propertyPanel);
  1272. propertyPanel.bounds.SetExtents(300,300);
  1273. propertyPanel.fillColor.Set(WMGraphics.Yellow);
  1274. NEW(window, propertyPanel);
  1275. propertyPanel.SetComponent(SELF,object);
  1276. END;
  1277. END HandleButton;
  1278. PROCEDURE Apply(force : BOOLEAN);
  1279. VAR reference : WMProperties.ReferenceProperty; string, oldString : ARRAY 256 OF CHAR; stringType: Types.String256; res: LONGINT;
  1280. BEGIN
  1281. reference := SELF.reference;
  1282. IF (reference # NIL) THEN
  1283. editor.GetAsString(string);
  1284. object := reference.Get();
  1285. IF object # NIL THEN
  1286. IF (object IS Models.Model) THEN
  1287. COPY(string, stringType.value);
  1288. object(Models.Model).SetGeneric(stringType, res);
  1289. SetOutOfDate(FALSE);
  1290. END;
  1291. ELSE
  1292. reference.GetAsString(oldString);
  1293. IF force OR (string # oldString) THEN
  1294. reference.SetAsString(string);
  1295. object := reference.Get();
  1296. UpdateButton(object);
  1297. ELSE
  1298. SetOutOfDate(FALSE);
  1299. END;
  1300. END
  1301. END;
  1302. END Apply;
  1303. PROCEDURE Synchronize(force : BOOLEAN);
  1304. VAR reference : WMProperties.ReferenceProperty;string : ARRAY 256 OF CHAR; stringType: Types.String256; res: LONGINT;
  1305. BEGIN
  1306. reference := SELF.reference;
  1307. IF (reference # NIL) & (force OR (lastTimestamp # reference.GetTimestamp())) THEN
  1308. lastTimestamp := reference.GetTimestamp();
  1309. reference.GetAsString(string);
  1310. object := reference.Get();
  1311. UpdateButton(object);
  1312. UpdateAdrLabel(object);
  1313. IF (object # NIL) & (object IS Models.Model) THEN
  1314. object(Models.Model).GetGeneric(stringType,res);
  1315. IF res = Models.Ok THEN COPY(stringType.value, string) END;
  1316. END;
  1317. editor.SetAsString(string);
  1318. SetOutOfDate(FALSE);
  1319. END;
  1320. END Synchronize;
  1321. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  1322. BEGIN
  1323. RETURN (property # NIL) & (property IS WMProperties.ReferenceProperty);
  1324. END IsCompatible;
  1325. PROCEDURE Enable;
  1326. BEGIN
  1327. editor.enabled.Set(TRUE);
  1328. END Enable;
  1329. PROCEDURE Disable;
  1330. BEGIN
  1331. editor.enabled.Set(FALSE);
  1332. END Disable;
  1333. PROCEDURE UpdateButton(object : XML.Element);
  1334. VAR string : Types.String32; res : LONGINT; nbrStr : ARRAY 17 OF CHAR; t: Modules.TypeDesc;
  1335. BEGIN
  1336. IF (object # NIL) THEN
  1337. button.fillColor.Set(WMGraphics.Green);
  1338. IF (object IS Models.Model) THEN
  1339. button.enabled.Set(TRUE);
  1340. object(Models.Model).GetGeneric(string, res);
  1341. IF (res = Models.Ok) THEN
  1342. button.caption.SetAOC(string.value);
  1343. ELSE
  1344. button.caption.Set(StrNoCaption);
  1345. END;
  1346. ELSIF (object IS WMComponents.Component) THEN
  1347. button.enabled.Set(TRUE);
  1348. button.caption.SetAOC("(component)");
  1349. ELSE
  1350. button.enabled.Set(FALSE);
  1351. button.caption.Set(StrNoCaption);
  1352. END;
  1353. ELSE
  1354. button.enabled.Set(FALSE);
  1355. button.fillColor.Set(WMGraphics.Red);
  1356. button.caption.Set(StrNoCaption);
  1357. END;
  1358. END UpdateButton;
  1359. PROCEDURE SetProperty(property : WMProperties.Property);
  1360. BEGIN
  1361. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.ReferenceProperty)));
  1362. SetProperty^(property);
  1363. IF (property # NIL) THEN
  1364. SELF.reference := property (WMProperties.ReferenceProperty);
  1365. SELF.object := NIL;
  1366. ELSE
  1367. SELF.reference := NIL;
  1368. SELF.object := NIL;
  1369. editor.SetAsString("");
  1370. END;
  1371. UpdateButton(SELF.object);
  1372. UpdateAdrLabel(SELF.object);
  1373. END SetProperty;
  1374. PROCEDURE SetOutOfDate(value : BOOLEAN);
  1375. BEGIN
  1376. IF (outOfDate # value) THEN
  1377. outOfDate := value;
  1378. IF outOfDate THEN
  1379. editor.fillColor.Set(LONGINT(0FFFF0099H));
  1380. ELSE
  1381. editor.fillColor.Set(WMGraphics.White);
  1382. END;
  1383. END;
  1384. END SetOutOfDate;
  1385. PROCEDURE EditorContentChanged(sender, data : ANY);
  1386. BEGIN
  1387. SetOutOfDate(TRUE);
  1388. END EditorContentChanged;
  1389. PROCEDURE EnterPressed(sender, data : ANY);
  1390. BEGIN
  1391. Apply(FALSE);
  1392. END EnterPressed;
  1393. END ReferencePropertyView;
  1394. TYPE
  1395. AlignmentPropertyView = OBJECT(PropertyView)
  1396. VAR
  1397. int32 : WMProperties.Int32Property;
  1398. alignment_chooser : WMDropDownLists.DropDownList;
  1399. PROCEDURE &Init;
  1400. VAR res : LONGINT;
  1401. BEGIN
  1402. Init^;
  1403. SetNameAsString(StrAlignmentPropertyView);
  1404. ofsInfo := -1;
  1405. NEW(alignment_chooser);
  1406. alignment_chooser.alignment.Set(WMComponents.AlignLeft);
  1407. alignment_chooser.maxGridHeight.Set(200);
  1408. alignment_chooser.bounds.SetWidth(100);
  1409. alignment_chooser.mode.Set(WMDropDownLists.Mode_SelectOnly);
  1410. alignment_chooser.model.Acquire;
  1411. alignment_chooser.model.Add(WMComponents.AlignNone, "None", res); ASSERT(res = WMDropDownLists.Ok);
  1412. alignment_chooser.model.Add(WMComponents.AlignLeft, "Left", res); ASSERT(res = WMDropDownLists.Ok);
  1413. alignment_chooser.model.Add(WMComponents.AlignTop, "Top", res); ASSERT(res = WMDropDownLists.Ok);
  1414. alignment_chooser.model.Add(WMComponents.AlignRight, "Right", res); ASSERT(res = WMDropDownLists.Ok);
  1415. alignment_chooser.model.Add(WMComponents.AlignBottom, "Bottom", res); ASSERT(res = WMDropDownLists.Ok);
  1416. alignment_chooser.model.Add(WMComponents.AlignClient, "Client", res); ASSERT(res = WMDropDownLists.Ok);
  1417. alignment_chooser.model.Add(WMComponents.AlignRelative, "Relative", res); ASSERT(res = WMDropDownLists.Ok);
  1418. alignment_chooser.model.Release;
  1419. alignment_chooser.onSelect.Add(AlignmentSelected);
  1420. AddContent(alignment_chooser);
  1421. END Init;
  1422. PROCEDURE Apply(force : BOOLEAN);
  1423. VAR int32 : WMProperties.Int32Property; e : WMDropDownLists.Entry;
  1424. BEGIN
  1425. int32 := SELF.int32;
  1426. IF (int32 # NIL) THEN
  1427. e := alignment_chooser.GetSelection();
  1428. IF (e # NIL) & (force OR (e.key # int32.Get())) THEN
  1429. int32.Set(e.key);
  1430. END;
  1431. END;
  1432. END Apply;
  1433. PROCEDURE Synchronize(force : BOOLEAN);
  1434. VAR int32 : WMProperties.Int32Property;
  1435. BEGIN
  1436. Synchronize^(force);
  1437. int32 := SELF.int32;
  1438. IF (int32 # NIL) & (force OR (lastTimestamp # int32.GetTimestamp())) THEN
  1439. lastTimestamp := int32.GetTimestamp();
  1440. alignment_chooser.SelectKey(int32.Get());
  1441. END;
  1442. END Synchronize;
  1443. PROCEDURE SetProperty(property : WMProperties.Property);
  1444. BEGIN
  1445. ASSERT((property = NIL) OR ((property # NIL) & (property IS WMProperties.Int32Property)));
  1446. SetProperty^(property);
  1447. IF (property # NIL) THEN
  1448. SELF.int32 := property (WMProperties.Int32Property);
  1449. ELSE
  1450. SELF.int32 := NIL;
  1451. alignment_chooser.SetSelection(NIL);
  1452. END;
  1453. END SetProperty;
  1454. PROCEDURE AlignmentSelected(sender, data : ANY);
  1455. BEGIN
  1456. Apply(FALSE);
  1457. END AlignmentSelected;
  1458. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  1459. BEGIN
  1460. RETURN FALSE; (* only to be used by VisualComponentView *)
  1461. END IsCompatible;
  1462. PROCEDURE Enable;
  1463. BEGIN
  1464. alignment_chooser.enabled.Set(TRUE);
  1465. END Enable;
  1466. PROCEDURE Disable;
  1467. BEGIN
  1468. alignment_chooser.enabled.Set(FALSE);
  1469. END Disable;
  1470. END AlignmentPropertyView;
  1471. TYPE
  1472. UnknownPropertyView = OBJECT(PropertyView)
  1473. PROCEDURE Apply(force : BOOLEAN);
  1474. BEGIN
  1475. (* do nothing *)
  1476. END Apply;
  1477. PROCEDURE Synchronize(force : BOOLEAN);
  1478. BEGIN
  1479. (* do nothing *)
  1480. END Synchronize;
  1481. PROCEDURE IsCompatible(property : WMProperties.Property) : BOOLEAN;
  1482. BEGIN
  1483. RETURN (property # NIL);
  1484. END IsCompatible;
  1485. PROCEDURE &Init;
  1486. VAR label : WMStandardComponents.Label;
  1487. BEGIN
  1488. Init^;
  1489. SetNameAsString(StrUnknownPropertyView);
  1490. NEW(label); label.alignment.Set(WMComponents.AlignLeft);
  1491. label.bounds.SetWidth(70);
  1492. label.fillColor.Set(WMGraphics.Red);
  1493. label.caption.SetAOC("Unknown");
  1494. label.alignH.Set(WMGraphics.AlignCenter);
  1495. label.bearing.Set(WMRectangles.MakeRect(NameWidth, 0, 0, 0));
  1496. AddContent(label);
  1497. END Init;
  1498. END UnknownPropertyView;
  1499. TYPE
  1500. EventSourceView = OBJECT(WMComponents.VisualComponent)
  1501. VAR
  1502. event : WMEvents.EventSource;
  1503. PROCEDURE &Init;
  1504. BEGIN
  1505. Init^;
  1506. SetNameAsString(StrEventSourceView);
  1507. alignment.Set(WMComponents.AlignTop);
  1508. bounds.SetHeight(LineHeight);
  1509. fillColor.Set(WMGraphics.White);
  1510. END Init;
  1511. PROCEDURE Apply;
  1512. BEGIN
  1513. KernelLog.String("Not Implemented"); KernelLog.Ln;
  1514. END Apply;
  1515. PROCEDURE Refresh;
  1516. BEGIN
  1517. KernelLog.String("Not Implemented"); KernelLog.Ln;
  1518. END Refresh;
  1519. PROCEDURE SetEventSource(event : WMEvents.EventSource);
  1520. VAR
  1521. nameLabel, infoLabel : WMStandardComponents.Label;
  1522. BEGIN
  1523. ASSERT(event # NIL);
  1524. SELF.event := event;
  1525. NEW(nameLabel); nameLabel.alignment.Set(WMComponents.AlignLeft);
  1526. nameLabel.bounds.SetWidth(80);
  1527. nameLabel.textColor.Set(WMGraphics.Black);
  1528. nameLabel.caption.Set(event.GetName());
  1529. AddContent(nameLabel);
  1530. NEW(infoLabel); infoLabel.alignment.Set(WMComponents.AlignClient);
  1531. infoLabel.textColor.Set(WMGraphics.Black);
  1532. infoLabel.caption.Set(event.GetInfo());
  1533. AddContent(infoLabel);
  1534. END SetEventSource;
  1535. END EventSourceView;
  1536. TYPE
  1537. EventListenerView = OBJECT(WMComponents.VisualComponent)
  1538. VAR
  1539. event : WMEvents.EventListenerInfo;
  1540. PROCEDURE &Init;
  1541. BEGIN
  1542. Init^;
  1543. SetNameAsString(StrEventListenerView);
  1544. alignment.Set(WMComponents.AlignTop);
  1545. bounds.SetHeight(LineHeight);
  1546. END Init;
  1547. PROCEDURE Apply;
  1548. BEGIN
  1549. KernelLog.String("Not Implemented"); KernelLog.Ln;
  1550. END Apply;
  1551. PROCEDURE Refresh;
  1552. BEGIN
  1553. KernelLog.String("Not Implemented"); KernelLog.Ln;
  1554. END Refresh;
  1555. PROCEDURE SetEventListener(event : WMEvents.EventListenerInfo);
  1556. VAR
  1557. nameLabel, infoLabel : WMStandardComponents.Label;
  1558. BEGIN
  1559. ASSERT(event # NIL);
  1560. SELF.event := event;
  1561. NEW(nameLabel); nameLabel.alignment.Set(WMComponents.AlignClient);
  1562. nameLabel.textColor.Set(WMGraphics.Black);
  1563. nameLabel.caption.Set(event.GetName());
  1564. AddContent(nameLabel);
  1565. NEW(infoLabel); infoLabel.alignment.Set(WMComponents.AlignLeft);
  1566. infoLabel.bounds.SetWidth(200);
  1567. infoLabel.textColor.Set(WMGraphics.Black);
  1568. infoLabel.caption.Set(event.GetInfo());
  1569. AddContent(infoLabel);
  1570. END SetEventListener;
  1571. END EventListenerView;
  1572. TYPE
  1573. ComponentView = OBJECT(WMComponents.VisualComponent)
  1574. VAR
  1575. initializedView: BooleanPropertyView;
  1576. idView, uidView : StringPropertyView;
  1577. enabledView : BooleanPropertyView;
  1578. PROCEDURE &Init;
  1579. BEGIN
  1580. Init^;
  1581. SetNameAsString(Strings.NewString("ComponentView"));
  1582. NEW(initializedView); AddContent(initializedView);
  1583. NEW(idView); AddContent(idView);
  1584. NEW(uidView); AddContent(uidView);
  1585. NEW(enabledView); AddContent(enabledView);
  1586. bounds.SetHeight(initializedView.bounds.GetHeight() + idView.bounds.GetHeight() + uidView.bounds.GetHeight() + enabledView.bounds.GetHeight() + 6 * LineBearing);
  1587. END Init;
  1588. PROCEDURE ResetProperties;
  1589. BEGIN
  1590. initializedView.SetProperty(NIL);
  1591. idView.SetProperty(NIL);
  1592. uidView.SetProperty(NIL);
  1593. enabledView.SetProperty(NIL);
  1594. END ResetProperties;
  1595. PROCEDURE SetProperty(property : WMProperties.Property; VAR res : LONGINT);
  1596. VAR name : Strings.String;
  1597. BEGIN
  1598. res := Ok;
  1599. name := property.GetName();
  1600. IF (name # NIL) THEN
  1601. IF (name^ = "Initialized") & (property IS WMProperties.BooleanProperty) THEN
  1602. initializedView.SetProperty(property);
  1603. ELSIF (name^ = "ID") & (property IS WMProperties.StringProperty) THEN
  1604. idView.SetProperty(property);
  1605. ELSIF (name^ = "UID") & (property IS WMProperties.StringProperty) THEN
  1606. uidView.SetProperty(property);
  1607. ELSIF (name^ = "Enabled") & (property IS WMProperties.BooleanProperty) THEN
  1608. enabledView.SetProperty(property);
  1609. ELSE
  1610. res := CannotHandle;
  1611. END;
  1612. ELSE
  1613. res := CannotHandle;
  1614. END;
  1615. END SetProperty;
  1616. PROCEDURE Apply;
  1617. BEGIN
  1618. initializedView.Apply(FALSE); (*not editable*)
  1619. idView.Apply(FALSE);
  1620. uidView.Apply(FALSE);
  1621. enabledView.Apply(FALSE);
  1622. END Apply;
  1623. PROCEDURE Synchronize(force : BOOLEAN);
  1624. BEGIN
  1625. initializedView.Synchronize(force);
  1626. idView.Synchronize(force);
  1627. uidView.Synchronize(force);
  1628. enabledView.Synchronize(force);
  1629. END Synchronize;
  1630. PROCEDURE Enable;
  1631. BEGIN
  1632. (*initializedView.Enable;*)
  1633. idView.Enable;
  1634. uidView.Enable;
  1635. enabledView.Enable;
  1636. END Enable;
  1637. PROCEDURE Disable;
  1638. BEGIN
  1639. (*initializedView.Disable;*)
  1640. idView.Disable;
  1641. uidView.Disable;
  1642. enabledView.Disable;
  1643. END Disable;
  1644. END ComponentView;
  1645. TYPE
  1646. VisualComponentView = OBJECT(WMComponents.VisualComponent)
  1647. VAR
  1648. alignmentView : AlignmentPropertyView;
  1649. boundsView : RectanglePropertyView;
  1650. bearingView : RectanglePropertyView;
  1651. fillColorView : ColorPropertyView;
  1652. visibleView, takesFocusView, needsTabView, editModeView : BooleanPropertyView;
  1653. focusNextView, focusPrevView : StringPropertyView;
  1654. PROCEDURE &Init;
  1655. BEGIN
  1656. Init^;
  1657. SetNameAsString(Strings.NewString("VisualComponentView"));
  1658. NEW(alignmentView); AddContent(alignmentView);
  1659. NEW(boundsView, TRUE); AddContent(boundsView);
  1660. NEW(bearingView, FALSE); AddContent(bearingView);
  1661. NEW(fillColorView); AddContent(fillColorView);
  1662. NEW(visibleView); AddContent(visibleView);
  1663. NEW(editModeView); AddContent(editModeView);
  1664. NEW(needsTabView); AddContent(needsTabView);
  1665. NEW(takesFocusView); AddContent(takesFocusView);
  1666. NEW(focusPrevView); AddContent(focusPrevView);
  1667. NEW(focusNextView); AddContent(focusNextView);
  1668. bounds.SetHeight(18 * LineBearing +
  1669. alignmentView.bounds.GetHeight() +
  1670. boundsView.bounds.GetHeight() + bearingView.bounds.GetHeight() +
  1671. fillColorView.bounds.GetHeight() + visibleView.bounds.GetHeight() +
  1672. takesFocusView.bounds.GetHeight() + needsTabView.bounds.GetHeight() +
  1673. focusPrevView.bounds.GetHeight() + focusNextView.bounds.GetHeight() + editModeView.bounds.GetHeight()
  1674. );
  1675. END Init;
  1676. PROCEDURE ResetProperties;
  1677. BEGIN
  1678. alignmentView.SetProperty(NIL);
  1679. boundsView.SetProperty(NIL);
  1680. bearingView.SetProperty(NIL);
  1681. fillColorView.SetProperty(NIL);
  1682. visibleView.SetProperty(NIL);
  1683. takesFocusView.SetProperty(NIL);
  1684. needsTabView.SetProperty(NIL);
  1685. focusPrevView.SetProperty(NIL);
  1686. focusNextView.SetProperty(NIL);
  1687. editModeView.SetProperty(NIL);
  1688. END ResetProperties;
  1689. PROCEDURE SetAlignment(alignmentMode : LONGINT);
  1690. VAR s : SET;
  1691. BEGIN
  1692. IF (alignmentMode < WMComponents.AlignNone) OR (WMComponents.AlignClient < alignmentMode) THEN
  1693. alignmentMode := WMComponents.AlignNone;
  1694. END;
  1695. CASE alignmentMode OF
  1696. |WMComponents.AlignNone: s := {0..5};
  1697. |WMComponents.AlignLeft: s := {4};
  1698. |WMComponents.AlignRight: s := {4};
  1699. |WMComponents.AlignTop: s := {5};
  1700. |WMComponents.AlignBottom: s := {5};
  1701. |WMComponents.AlignClient: s := {};
  1702. |WMComponents.AlignRelative: s := {}
  1703. ELSE
  1704. HALT(99);
  1705. END;
  1706. boundsView.SetEnabled(s);
  1707. END SetAlignment;
  1708. PROCEDURE SetProperty(property : WMProperties.Property; VAR res : LONGINT);
  1709. VAR name : Strings.String;
  1710. BEGIN
  1711. res := Ok;
  1712. name := property.GetName();
  1713. IF (name # NIL) THEN
  1714. IF (name^ = "Bounds") & (property IS WMProperties.RectangleProperty) THEN
  1715. boundsView.SetProperty(property);
  1716. ELSIF (name^ = "Bearing") & (property IS WMProperties.RectangleProperty) THEN
  1717. bearingView.SetProperty(property);
  1718. ELSIF (name ^ = "Alignment") & (property IS WMProperties.Int32Property) THEN
  1719. alignmentView.SetProperty(property);
  1720. ELSIF (name^ = "FillColor") & (property IS WMProperties.ColorProperty) THEN
  1721. fillColorView.SetProperty(property);
  1722. ELSIF (name^ = "Visible") & (property IS WMProperties.BooleanProperty) THEN
  1723. visibleView.SetProperty(property);
  1724. ELSIF (name^ = "NeedsTab") & (property IS WMProperties.BooleanProperty) THEN
  1725. needsTabView.SetProperty(property);
  1726. ELSIF (name^ = "TakesFocus") & (property IS WMProperties.BooleanProperty) THEN
  1727. takesFocusView.SetProperty(property);
  1728. ELSIF (name^ = "FocusPrevious") & (property IS WMProperties.StringProperty) THEN
  1729. focusPrevView.SetProperty(property);
  1730. ELSIF (name^ = "FocusNext") & (property IS WMProperties.StringProperty) THEN
  1731. focusNextView.SetProperty(property);
  1732. ELSIF (name^ = "EditMode") & (property IS WMProperties.BooleanProperty) THEN
  1733. editModeView.SetProperty(property)
  1734. ELSE
  1735. res := CannotHandle;
  1736. END;
  1737. ELSE
  1738. res := CannotHandle;
  1739. END;
  1740. END SetProperty;
  1741. PROCEDURE Apply;
  1742. BEGIN
  1743. alignmentView.Apply(FALSE);
  1744. IF alignmentView.int32 # NIL THEN SetAlignment(alignmentView.int32.Get()); END;
  1745. boundsView.Apply(FALSE);
  1746. bearingView.Apply(FALSE);
  1747. fillColorView.Apply(FALSE);
  1748. visibleView.Apply(FALSE);
  1749. needsTabView.Apply(FALSE);
  1750. takesFocusView.Apply(FALSE);
  1751. focusPrevView.Apply(FALSE);
  1752. focusNextView.Apply(FALSE);
  1753. editModeView.Apply(FALSE);
  1754. END Apply;
  1755. PROCEDURE Synchronize(force : BOOLEAN);
  1756. BEGIN
  1757. alignmentView.Synchronize(force);
  1758. IF (alignmentView.int32 # NIL) THEN SetAlignment(alignmentView.int32.Get()); END;
  1759. boundsView.Synchronize(force);
  1760. bearingView.Synchronize(force);
  1761. fillColorView.Synchronize(force);
  1762. visibleView.Synchronize(force);
  1763. needsTabView.Synchronize(force);
  1764. takesFocusView.Synchronize(force);
  1765. focusPrevView.Synchronize(force);
  1766. focusNextView.Synchronize(force);
  1767. editModeView.Synchronize(force);
  1768. END Synchronize;
  1769. PROCEDURE Enable;
  1770. BEGIN
  1771. alignmentView.Enable;
  1772. IF (alignmentView.int32 # NIL) THEN SetAlignment(alignmentView.int32.Get()); END;
  1773. boundsView.Enable;
  1774. bearingView.Enable;
  1775. fillColorView.Enable;
  1776. visibleView.Enable;
  1777. needsTabView.Enable;
  1778. takesFocusView.Enable;
  1779. focusPrevView.Enable;
  1780. focusNextView.Enable;
  1781. editModeView.Enable;
  1782. END Enable;
  1783. PROCEDURE Disable;
  1784. BEGIN
  1785. alignmentView.Disable;
  1786. boundsView.Disable;
  1787. bearingView.Disable;
  1788. fillColorView.Disable;
  1789. visibleView.Disable;
  1790. needsTabView.Disable;
  1791. takesFocusView.Disable;
  1792. focusPrevView.Disable;
  1793. focusNextView.Disable;
  1794. editModeView.Disable;
  1795. END Disable;
  1796. END VisualComponentView;
  1797. TYPE
  1798. ComponentElement* = OBJECT(WMComponents.VisualComponent)
  1799. VAR
  1800. component : WMComponents.Component;
  1801. nofElements : LONGINT;
  1802. PROCEDURE &Init*;
  1803. BEGIN
  1804. Init^;
  1805. SetNameAsString(Strings.NewString("ComponentElement"));
  1806. component := NIL;
  1807. nofElements := 0;
  1808. END Init;
  1809. PROCEDURE CountNofElements(component : WMComponents.Component);
  1810. END CountNofElements;
  1811. PROCEDURE GetNofElements*() : LONGINT;
  1812. BEGIN
  1813. RETURN nofElements;
  1814. END GetNofElements;
  1815. PROCEDURE SetComponent*(component : WMComponents.Component);
  1816. BEGIN
  1817. HALT(301);
  1818. END SetComponent;
  1819. PROCEDURE Apply*;
  1820. BEGIN
  1821. HALT(301);
  1822. END Apply;
  1823. PROCEDURE Synchronize*(force : BOOLEAN);
  1824. BEGIN
  1825. HALT(301);
  1826. END Synchronize;
  1827. END ComponentElement;
  1828. TYPE
  1829. (** Displays and edits all properties that are common to Component and VisualComponent classes *)
  1830. StandardProperties* = OBJECT(ComponentElement)
  1831. VAR
  1832. componentView : ComponentView;
  1833. visualComponentView : VisualComponentView;
  1834. PROCEDURE &Init*;
  1835. BEGIN
  1836. Init^;
  1837. SetNameAsString(StrStandardProperties);
  1838. NEW(componentView); componentView.alignment.Set(WMComponents.AlignTop);
  1839. AddContent(componentView);
  1840. NEW(visualComponentView); visualComponentView.alignment.Set(WMComponents.AlignTop);
  1841. AddContent(visualComponentView);
  1842. fillColor.Set(WMGraphics.Blue);
  1843. bounds.SetHeight(componentView.bounds.GetHeight() + visualComponentView.bounds.GetHeight() + 2 * LineBearing);
  1844. END Init;
  1845. PROCEDURE CountNofElements(component : WMComponents.Component);
  1846. VAR propertyArray : WMProperties.PropertyArray; i : LONGINT;
  1847. BEGIN
  1848. nofElements := 0;
  1849. IF (component # NIL) THEN
  1850. propertyArray := component.properties.Enumerate();
  1851. IF (propertyArray # NIL) THEN
  1852. FOR i := 0 TO LEN(propertyArray) - 1 DO
  1853. IF IsComponentProperty(propertyArray[i]) OR IsVisualComponentProperty(propertyArray[i]) THEN
  1854. INC(nofElements);
  1855. END;
  1856. END;
  1857. END;
  1858. END;
  1859. END CountNofElements;
  1860. PROCEDURE SetProperties(component : WMComponents.Component);
  1861. VAR propertyArray : WMProperties.PropertyArray; res, i : LONGINT;
  1862. init:WMProperties.BooleanProperty;
  1863. BEGIN
  1864. ASSERT(component # NIL);
  1865. NEW(init, WMProperties.NewBoolean(), Strings.NewString("Initialized"), Strings.NewString("component is initialized (readonly field). Required for proper function. "));
  1866. init.Set(component.initialized);
  1867. componentView.SetProperty(init, res);
  1868. componentView.initializedView.Disable; (*! currently readonly. tbd: allow modification by inspector *)
  1869. nofElements := 0;
  1870. propertyArray := component.properties.Enumerate();
  1871. IF (propertyArray # NIL) THEN
  1872. FOR i := 0 TO LEN(propertyArray)-1 DO
  1873. IF IsComponentProperty(propertyArray[i]) THEN
  1874. componentView.SetProperty(propertyArray[i], res);
  1875. ASSERT(res = Ok);
  1876. INC(nofElements);
  1877. ELSIF IsVisualComponentProperty(propertyArray[i]) THEN
  1878. visualComponentView.SetProperty(propertyArray[i], res);
  1879. ASSERT(res = Ok);
  1880. INC(nofElements);
  1881. END;
  1882. END;
  1883. END;
  1884. END SetProperties;
  1885. PROCEDURE SetComponent*(component : WMComponents.Component);
  1886. BEGIN
  1887. IF (component # SELF.component) THEN
  1888. DisableUpdate;
  1889. Acquire;
  1890. SELF.component := component;
  1891. componentView.ResetProperties;
  1892. visualComponentView.ResetProperties;
  1893. IF (component # NIL) THEN
  1894. SetProperties(component);
  1895. componentView.visible.Set(TRUE);
  1896. IF (component IS WMComponents.VisualComponent) THEN
  1897. visualComponentView.visible.Set(TRUE);
  1898. ELSE
  1899. visualComponentView.visible.Set(FALSE);
  1900. END;
  1901. ELSE
  1902. nofElements := 0;
  1903. componentView.visible.Set(FALSE);
  1904. visualComponentView.visible.Set(FALSE);
  1905. END;
  1906. Release;
  1907. Synchronize(TRUE);
  1908. EnableUpdate;
  1909. Invalidate;
  1910. END;
  1911. END SetComponent;
  1912. PROCEDURE Apply*;
  1913. BEGIN
  1914. Acquire;
  1915. IF (componentView.visible.Get()) THEN componentView.Apply; END;
  1916. IF (visualComponentView.visible.Get()) THEN visualComponentView.Apply; END;
  1917. Release;
  1918. END Apply;
  1919. PROCEDURE Synchronize*(force : BOOLEAN);
  1920. BEGIN
  1921. Acquire;
  1922. IF (componentView.visible.Get()) THEN componentView.Synchronize(force); END;
  1923. IF (visualComponentView.visible.Get()) THEN visualComponentView.Synchronize(force); END;
  1924. Release;
  1925. Invalidate;
  1926. END Synchronize;
  1927. PROCEDURE Enable;
  1928. BEGIN
  1929. componentView.Enable;
  1930. visualComponentView.Enable;
  1931. END Enable;
  1932. PROCEDURE Disable;
  1933. BEGIN
  1934. componentView.Disable;
  1935. visualComponentView.Disable;
  1936. END Disable;
  1937. END StandardProperties;
  1938. TYPE
  1939. CacheEntry = POINTER TO RECORD
  1940. ps : ExtendedProperties;
  1941. milliTimer : Kernel.MilliTimer;
  1942. next : CacheEntry;
  1943. END;
  1944. PropertySheetCache = OBJECT
  1945. VAR
  1946. entries : CacheEntry;
  1947. nofEntries : LONGINT;
  1948. PROCEDURE &Init;
  1949. BEGIN
  1950. entries := NIL;
  1951. nofEntries := 0;
  1952. END Init;
  1953. PROCEDURE Find(component : WMComponents.Component) : ExtendedProperties;
  1954. VAR result : ExtendedProperties; e : CacheEntry;
  1955. BEGIN
  1956. ASSERT(component # NIL);
  1957. result := NIL;
  1958. e := entries;
  1959. WHILE (e # NIL) & ~e.ps.IsCompatible(component) DO e := e.next; END;
  1960. IF (e # NIL) THEN
  1961. result := e.ps;
  1962. Kernel.SetTimer(e.milliTimer, 0);
  1963. ASSERT(result.GetParent() # NIL);
  1964. END;
  1965. RETURN result;
  1966. END Find;
  1967. PROCEDURE FindLRU() : CacheEntry;
  1968. VAR age, currentAge : LONGINT; lru, e : CacheEntry;
  1969. BEGIN
  1970. age := 0;
  1971. lru := NIL;
  1972. e := entries;
  1973. WHILE (e # NIL) DO
  1974. currentAge := Kernel.Elapsed(e.milliTimer);
  1975. IF (currentAge > age) THEN
  1976. age := currentAge;
  1977. lru := e;
  1978. END;
  1979. e := e.next;
  1980. END;
  1981. RETURN lru;
  1982. END FindLRU;
  1983. PROCEDURE Add(ps : ExtendedProperties);
  1984. VAR e : CacheEntry; parent : XML.Element;
  1985. BEGIN
  1986. ASSERT((ps # NIL) & (ps.GetParent() # NIL));
  1987. IF (nofEntries < MaxNofCacheEntries) THEN
  1988. NEW(e); e.ps := ps;
  1989. e.next := entries; entries := e;
  1990. ELSE
  1991. e := FindLRU();
  1992. ASSERT((e # NIL) & (e.ps.GetParent() # NIL));
  1993. parent := e.ps.GetParent();
  1994. parent.RemoveContent(e.ps);
  1995. e.ps := ps;
  1996. END;
  1997. INC(nofEntries);
  1998. Kernel.SetTimer(e.milliTimer, 0);
  1999. END Add;
  2000. END PropertySheetCache;
  2001. TYPE
  2002. ExtendedPropertiesView = OBJECT(ComponentElement)
  2003. VAR
  2004. cache : PropertySheetCache;
  2005. current : ExtendedProperties;
  2006. PROCEDURE &Init;
  2007. BEGIN
  2008. Init^;
  2009. SetNameAsString(StrExtendedPropertiesView);
  2010. NEW(cache);
  2011. current := NIL;
  2012. END Init;
  2013. PROCEDURE CountNofElements(component : WMComponents.Component);
  2014. BEGIN
  2015. nofElements := CountExtendedProperties(component);
  2016. END CountNofElements;
  2017. PROCEDURE SetComponent(component : WMComponents.Component);
  2018. VAR ps : ExtendedProperties; generateNew : BOOLEAN;
  2019. BEGIN
  2020. DisableUpdate;
  2021. IF (component # NIL) THEN
  2022. IF (current # NIL) THEN
  2023. current.visible.Set(FALSE);
  2024. current.ClearProperties;
  2025. END;
  2026. ps := cache.Find(component);
  2027. IF (ps # NIL) THEN
  2028. current := ps;
  2029. generateNew := ~current.UpdateProperties(component);
  2030. IF ~generateNew THEN
  2031. current.Synchronize(TRUE);
  2032. current.visible.Set(TRUE);
  2033. ELSE
  2034. current.visible.Set(FALSE);
  2035. END;
  2036. ELSE
  2037. generateNew := TRUE;
  2038. END;
  2039. IF generateNew THEN
  2040. NEW(ps);
  2041. ps.SetComponent(component);
  2042. ps.alignment.Set(WMComponents.AlignTop);
  2043. AddContent(ps);
  2044. current := ps;
  2045. cache.Add(ps);
  2046. END;
  2047. ASSERT(current # NIL);
  2048. bounds.SetHeight(current.bounds.GetHeight());
  2049. nofElements := current.nofElements;
  2050. ELSE
  2051. nofElements := 0;
  2052. IF (current # NIL) THEN
  2053. current.visible.Set(FALSE);
  2054. current.ClearProperties;
  2055. END;
  2056. END;
  2057. EnableUpdate;
  2058. Invalidate;
  2059. END SetComponent;
  2060. PROCEDURE Apply;
  2061. BEGIN
  2062. IF (current # NIL) THEN current.Apply; END;
  2063. END Apply;
  2064. PROCEDURE Synchronize(force : BOOLEAN);
  2065. BEGIN
  2066. IF (current # NIL) THEN current.Synchronize(force); END;
  2067. END Synchronize;
  2068. PROCEDURE Enable;
  2069. BEGIN
  2070. IF (current # NIL) THEN current.Enable; END;
  2071. END Enable;
  2072. PROCEDURE Disable;
  2073. BEGIN
  2074. IF (current # NIL) THEN current.Disable; END;
  2075. END Disable;
  2076. END ExtendedPropertiesView;
  2077. TYPE
  2078. ExtendedProperties* = OBJECT(ComponentElement)
  2079. VAR
  2080. list : PropertyViewList;
  2081. content : WMStandardComponents.Panel;
  2082. PROCEDURE &Init*;
  2083. BEGIN
  2084. Init^;
  2085. SetNameAsString(StrExtendedProperties);
  2086. NEW(list);
  2087. content := NIL;
  2088. END Init;
  2089. PROCEDURE CountNofElements(component : WMComponents.Component);
  2090. BEGIN
  2091. nofElements := CountExtendedProperties(component);
  2092. END CountNofElements;
  2093. PROCEDURE ClearProperty(pv : PropertyView; ignore : BOOLEAN);
  2094. BEGIN
  2095. pv.SetProperty(NIL);
  2096. END ClearProperty;
  2097. PROCEDURE ClearProperties;
  2098. BEGIN
  2099. list.Enumerate(ClearProperty, TRUE);
  2100. END ClearProperties;
  2101. PROCEDURE IsCompatible(component : WMComponents.Component) : BOOLEAN;
  2102. VAR pa : WMProperties.PropertyArray; pva : PropertyViewArray; i, j : LONGINT; compatible : BOOLEAN;
  2103. BEGIN
  2104. pva := list.GetAll();
  2105. IF (component # NIL) THEN pa := component.properties.Enumerate(); ELSE pa := NIL; END;
  2106. IF (pva = NIL) & (pa = NIL) THEN
  2107. compatible := TRUE;
  2108. ELSIF (pa # NIL) & (pva = NIL) THEN
  2109. compatible := TRUE;
  2110. i := 0;
  2111. WHILE compatible & (i < LEN(pa)) DO
  2112. compatible := IsComponentProperty(pa[i]) OR IsVisualComponentProperty(pa[i]);
  2113. INC(i);
  2114. END;
  2115. ELSIF (pa # NIL) & (pva # NIL) & (LEN(pa) >= LEN(pva)) THEN
  2116. compatible := TRUE;
  2117. i := 0; j := 0;
  2118. WHILE compatible & (i < LEN(pa)) & (j < LEN(pva)) DO
  2119. IF ~IsComponentProperty(pa[i]) & ~IsVisualComponentProperty(pa[i]) THEN
  2120. compatible := pva[j].IsCompatible(pa[i]);
  2121. INC(j);
  2122. END;
  2123. INC(i);
  2124. END;
  2125. compatible := compatible & (i = LEN(pa)) & (j = LEN(pva));
  2126. ELSE
  2127. compatible := FALSE;
  2128. END;
  2129. RETURN compatible;
  2130. END IsCompatible;
  2131. PROCEDURE UpdateProperties(component : WMComponents.Component) : BOOLEAN;
  2132. VAR pa : WMProperties.PropertyArray; pva : PropertyViewArray; i, j : LONGINT; ok : BOOLEAN;
  2133. BEGIN
  2134. ASSERT(component # NIL);
  2135. pa := component.properties.Enumerate();
  2136. pva := list.GetAll();
  2137. IF (pa = NIL) & (pva = NIL) THEN
  2138. ok := TRUE;
  2139. ELSIF (pa # NIL) & (pva = NIL) THEN
  2140. ok := TRUE;
  2141. i := 0;
  2142. WHILE ok & (i < LEN(pa)) DO
  2143. ok := IsComponentProperty(pa[i]) OR IsVisualComponentProperty(pa[i]);
  2144. INC(i);
  2145. END;
  2146. ELSIF (pa # NIL) & (pva # NIL) & (LEN(pa) >= LEN(pva)) THEN
  2147. ok := TRUE;
  2148. i := 0; j := 0;
  2149. WHILE ok & (i < LEN(pa)) & (j < LEN(pva)) DO
  2150. IF ~IsComponentProperty(pa[i]) & ~IsVisualComponentProperty(pa[i]) THEN
  2151. ok := pva[j].IsCompatible(pa[i]);
  2152. IF ok THEN
  2153. pva[j].SetProperty(pa[i]);
  2154. INC(j);
  2155. END;
  2156. END;
  2157. INC(i);
  2158. END;
  2159. ok := ok & (i = LEN(pa)) & (j = LEN(pva));
  2160. ELSE
  2161. ok := FALSE;
  2162. END;
  2163. RETURN ok;
  2164. END UpdateProperties;
  2165. PROCEDURE SetProperties(component : WMComponents.Component);
  2166. VAR
  2167. propertyArray : WMProperties.PropertyArray;
  2168. property : WMProperties.Property;
  2169. booleanView : BooleanPropertyView;
  2170. int32View : Int32PropertyView;
  2171. realView : RealPropertyView;
  2172. referenceView : ReferencePropertyView;
  2173. fontView : FontPropertyView;
  2174. rectangleView : RectanglePropertyView;
  2175. pointView: PointPropertyView;
  2176. stringView : StringPropertyView;
  2177. colorView : ColorPropertyView;
  2178. unknownView : UnknownPropertyView;
  2179. height, i : LONGINT;
  2180. BEGIN
  2181. ASSERT(component # NIL);
  2182. list.RemoveAll;
  2183. height := 0;
  2184. propertyArray := component.properties.Enumerate();
  2185. IF (propertyArray # NIL) & (LEN(propertyArray) > 0) THEN
  2186. NEW(content); content.alignment.Set(WMComponents.AlignClient);
  2187. FOR i := 0 TO LEN(propertyArray)-1 DO
  2188. property := propertyArray[i];
  2189. IF ~IsComponentProperty(property) & ~ IsVisualComponentProperty(property) THEN
  2190. INC(height, 2*LineBearing);
  2191. IF (property IS WMProperties.BooleanProperty) THEN
  2192. NEW(booleanView); booleanView.SetProperty(property (WMProperties.BooleanProperty));
  2193. content.AddContent(booleanView);
  2194. list.Add(booleanView);
  2195. INC(height, booleanView.bounds.GetHeight());
  2196. INC(nofElements);
  2197. ELSIF (property IS WMProperties.Int32Property) THEN
  2198. NEW(int32View); int32View.SetProperty(property (WMProperties.Int32Property));
  2199. content.AddContent(int32View);
  2200. list.Add(int32View);
  2201. INC(height, int32View.bounds.GetHeight());
  2202. INC(nofElements);
  2203. ELSIF (property IS WMProperties.RealProperty) THEN
  2204. NEW(realView); realView.SetProperty(property (WMProperties.RealProperty));
  2205. content.AddContent(realView);
  2206. list.Add(realView);
  2207. INC(height, realView.bounds.GetHeight());
  2208. INC(nofElements);
  2209. ELSIF (property IS WMProperties.StringProperty) THEN
  2210. NEW(stringView); stringView.SetProperty(property (WMProperties.StringProperty));
  2211. content.AddContent(stringView);
  2212. list.Add(stringView);
  2213. INC(height, stringView.bounds.GetHeight());
  2214. INC(nofElements);
  2215. ELSIF (property IS WMProperties.RectangleProperty) THEN
  2216. NEW(rectangleView, TRUE); rectangleView.SetProperty(property (WMProperties.RectangleProperty));
  2217. content.AddContent(rectangleView);
  2218. list.Add(rectangleView);
  2219. INC(height, rectangleView.bounds.GetHeight());
  2220. INC(nofElements);
  2221. ELSIF (property IS WMProperties.PointProperty) THEN
  2222. NEW(pointView, TRUE); pointView.SetProperty(property (WMProperties.PointProperty));
  2223. content.AddContent(pointView);
  2224. list.Add(pointView);
  2225. INC(height, pointView.bounds.GetHeight());
  2226. INC(nofElements);
  2227. ELSIF (property IS WMProperties.ColorProperty) THEN
  2228. NEW(colorView); colorView.SetProperty(property (WMProperties.ColorProperty));
  2229. content.AddContent(colorView);
  2230. list.Add(colorView);
  2231. INC(height, colorView.bounds.GetHeight());
  2232. INC(nofElements);
  2233. ELSIF (property IS WMProperties.FontProperty) THEN
  2234. NEW(fontView); fontView.SetProperty(property (WMProperties.FontProperty));
  2235. content.AddContent(fontView);
  2236. list.Add(fontView);
  2237. INC(height, fontView.bounds.GetHeight());
  2238. INC(nofElements);
  2239. ELSIF (property IS WMProperties.ReferenceProperty) THEN
  2240. NEW(referenceView); referenceView.SetProperty(property (WMProperties.ReferenceProperty));
  2241. content.AddContent(referenceView);
  2242. list.Add(referenceView);
  2243. INC(height, referenceView.bounds.GetHeight());
  2244. INC(nofElements);
  2245. ELSE
  2246. NEW(unknownView); unknownView.SetProperty(property);
  2247. content.AddContent(unknownView);
  2248. INC(height, unknownView.bounds.GetHeight());
  2249. INC(nofElements);
  2250. END;
  2251. END;
  2252. END;
  2253. AddContent(content);
  2254. END;
  2255. bounds.SetHeight(height);
  2256. END SetProperties;
  2257. PROCEDURE SetComponent*(component : WMComponents.Component);
  2258. BEGIN
  2259. IF (component # SELF.component) THEN
  2260. Acquire;
  2261. SELF.component := component;
  2262. nofElements := 0;
  2263. IF (content # NIL) THEN RemoveContent(content); END;
  2264. IF (component # NIL) THEN
  2265. SetProperties(component);
  2266. END;
  2267. Release;
  2268. Synchronize(TRUE);
  2269. END;
  2270. END SetComponent;
  2271. PROCEDURE ApplyToView(p : PropertyView; force : BOOLEAN);
  2272. BEGIN
  2273. ASSERT(p # NIL);
  2274. p.Apply(FALSE);
  2275. END ApplyToView;
  2276. PROCEDURE SynchronizeToModel(p : PropertyView; force : BOOLEAN);
  2277. BEGIN
  2278. ASSERT(p # NIL);
  2279. p.Synchronize(force);
  2280. END SynchronizeToModel;
  2281. PROCEDURE Apply*;
  2282. BEGIN
  2283. Acquire;
  2284. list.Enumerate(ApplyToView, FALSE);
  2285. Release;
  2286. END Apply;
  2287. PROCEDURE Synchronize*(force : BOOLEAN);
  2288. BEGIN
  2289. Acquire;
  2290. list.Enumerate(SynchronizeToModel, force);
  2291. Release;
  2292. END Synchronize;
  2293. PROCEDURE SetEnabled(p : PropertyView; enabled : BOOLEAN);
  2294. BEGIN
  2295. ASSERT(p # NIL);
  2296. IF enabled THEN p.Enable; ELSE p.Disable; END;
  2297. END SetEnabled;
  2298. PROCEDURE Enable;
  2299. BEGIN
  2300. Acquire;
  2301. list.Enumerate(SetEnabled, TRUE);
  2302. Release;
  2303. END Enable;
  2304. PROCEDURE Disable;
  2305. BEGIN
  2306. Acquire;
  2307. list.Enumerate(SetEnabled, FALSE);
  2308. Release;
  2309. END Disable;
  2310. END ExtendedProperties;
  2311. TYPE
  2312. EventSources* = OBJECT(ComponentElement)
  2313. VAR
  2314. content : WMStandardComponents.Panel;
  2315. PROCEDURE &Init*;
  2316. BEGIN
  2317. Init^;
  2318. SetNameAsString(StrEventSources);
  2319. alignment.Set(WMComponents.AlignTop);
  2320. content := NIL;
  2321. END Init;
  2322. PROCEDURE CountNofElements(component : WMComponents.Component);
  2323. VAR eventsArray : WMEvents.EventSourceArray;
  2324. BEGIN
  2325. nofElements := 0;
  2326. IF (component # NIL) THEN
  2327. eventsArray := component.events.Enumerate();
  2328. IF (eventsArray # NIL) THEN
  2329. nofElements := LEN(eventsArray);
  2330. END;
  2331. END;
  2332. END CountNofElements;
  2333. PROCEDURE SetComponent*(component : WMComponents.Component);
  2334. VAR eventsArray : WMEvents.EventSourceArray; source : EventSourceView; height, i : LONGINT;
  2335. BEGIN
  2336. IF (component # SELF.component) THEN
  2337. height := 0; nofElements := 0;
  2338. Acquire;
  2339. SELF.component := component;
  2340. IF (content # NIL) THEN RemoveContent(content); END;
  2341. IF (component # NIL) THEN
  2342. eventsArray := component.events.Enumerate();
  2343. IF (eventsArray # NIL) THEN
  2344. NEW(content); content.alignment.Set(WMComponents.AlignClient);
  2345. FOR i := 0 TO LEN(eventsArray)-1 DO
  2346. NEW(source); source.SetEventSource(eventsArray[i]);
  2347. content.AddContent(source);
  2348. INC(height, source.bounds.GetHeight()+ 2*LineBearing);
  2349. END;
  2350. nofElements := LEN(eventsArray);
  2351. AddContent(content);
  2352. END;
  2353. END;
  2354. bounds.SetHeight(height);
  2355. Release;
  2356. END;
  2357. END SetComponent;
  2358. PROCEDURE Apply*;
  2359. BEGIN
  2360. END Apply;
  2361. PROCEDURE Synchronize*(force : BOOLEAN);
  2362. BEGIN
  2363. END Synchronize;
  2364. END EventSources;
  2365. TYPE
  2366. EventListeners* = OBJECT(ComponentElement)
  2367. VAR
  2368. content : WMStandardComponents.Panel;
  2369. PROCEDURE &Init*;
  2370. BEGIN
  2371. Init^;
  2372. SetNameAsString(StrEventListeners);
  2373. alignment.Set(WMComponents.AlignTop);
  2374. content := NIL;
  2375. END Init;
  2376. PROCEDURE CountNofElements(component : WMComponents.Component);
  2377. VAR eventsArray : WMEvents.EventListenerArray;
  2378. BEGIN
  2379. nofElements := 0;
  2380. IF (component # NIL) THEN
  2381. eventsArray := component.eventListeners.Enumerate();
  2382. IF (eventsArray # NIL) THEN
  2383. nofElements := LEN(eventsArray);
  2384. END;
  2385. END;
  2386. END CountNofElements;
  2387. PROCEDURE SetComponent*(component : WMComponents.Component);
  2388. VAR eventsArray : WMEvents.EventListenerArray; listener : EventListenerView; height, i : LONGINT;
  2389. BEGIN
  2390. IF (component # SELF.component) THEN
  2391. height := 0; nofElements := 0;
  2392. Acquire;
  2393. SELF.component := component;
  2394. IF (content # NIL) THEN RemoveContent(content); END;
  2395. IF (component # NIL) THEN
  2396. eventsArray := component.eventListeners.Enumerate();
  2397. IF (eventsArray # NIL) THEN
  2398. NEW(content); content.alignment.Set(WMComponents.AlignClient);
  2399. FOR i := 0 TO LEN(eventsArray)-1 DO
  2400. NEW(listener); listener.SetEventListener(eventsArray[i]);
  2401. content.AddContent(listener);
  2402. INC(height, listener.bounds.GetHeight() + 2*LineBearing);
  2403. END;
  2404. nofElements := LEN(eventsArray);
  2405. AddContent(content);
  2406. END;
  2407. END;
  2408. bounds.SetHeight(height);
  2409. Release;
  2410. END;
  2411. END SetComponent;
  2412. PROCEDURE Apply*;
  2413. BEGIN
  2414. END Apply;
  2415. PROCEDURE Synchronize*(force : BOOLEAN);
  2416. BEGIN
  2417. END Synchronize;
  2418. END EventListeners;
  2419. TYPE
  2420. AttributeView = OBJECT(WMComponents.VisualComponent)
  2421. VAR
  2422. attribute : XML.Attribute; element : XML.Element;
  2423. outOfDate : BOOLEAN;
  2424. editor : WMEditors.TextField;
  2425. next : AttributeView;
  2426. PROCEDURE &Init;
  2427. BEGIN
  2428. Init^;
  2429. SetNameAsString(Strings.NewString("AttributeView"));
  2430. attribute := NIL; element := NIL;
  2431. outOfDate := FALSE;
  2432. alignment.Set(WMComponents.AlignTop);
  2433. bounds.SetHeight(LineHeight);
  2434. bearing.Set(WMRectangles.MakeRect(LineBearing, LineBearing, LineBearing, LineBearing));
  2435. NEW(editor); editor.alignment.Set(WMComponents.AlignClient);
  2436. editor.type.Set(WMEditors.Ascii);
  2437. editor.bearing.Set(WMRectangles.MakeRect(NameWidth, 0, 0, 0));
  2438. editor.onEnter.Add(EnterPressed);
  2439. editor.onChanged.Add(EditorContentChanged);
  2440. AddContent(editor);
  2441. next := NIL;
  2442. END Init;
  2443. PROCEDURE SetAttribute(attribute : XML.Attribute);
  2444. BEGIN
  2445. SELF.attribute := attribute;
  2446. END SetAttribute;
  2447. PROCEDURE Apply;
  2448. VAR attribute : XML.Attribute; string : ARRAY 1024 OF CHAR;
  2449. BEGIN
  2450. attribute := SELF.attribute;
  2451. IF (attribute # NIL) THEN
  2452. editor.GetAsString(string);
  2453. attribute.SetValue(string);
  2454. SetOutOfDate(FALSE);
  2455. END;
  2456. END Apply;
  2457. PROCEDURE Synchronize;
  2458. VAR attribute : XML.Attribute; value : Strings.String;
  2459. BEGIN
  2460. attribute := SELF.attribute;
  2461. IF (attribute # NIL) THEN
  2462. value := attribute.GetValue();
  2463. IF (value # NIL) THEN
  2464. editor.SetAsString(value^);
  2465. ELSE
  2466. editor.SetAsString("");
  2467. END;
  2468. ELSE
  2469. editor.SetAsString("");
  2470. END;
  2471. SetOutOfDate(FALSE);
  2472. END Synchronize;
  2473. PROCEDURE SetOutOfDate(value : BOOLEAN);
  2474. BEGIN
  2475. IF (outOfDate # value) THEN
  2476. outOfDate := value;
  2477. IF outOfDate THEN
  2478. editor.fillColor.Set(LONGINT(0FFFF0099H));
  2479. ELSE
  2480. editor.fillColor.Set(WMGraphics.White);
  2481. END;
  2482. END;
  2483. END SetOutOfDate;
  2484. PROCEDURE EnterPressed(sender, data : ANY);
  2485. BEGIN
  2486. Apply;
  2487. END EnterPressed;
  2488. PROCEDURE EditorContentChanged(sender, data : ANY);
  2489. BEGIN
  2490. SetOutOfDate(TRUE);
  2491. END EditorContentChanged;
  2492. PROCEDURE DrawForeground(canvas : WMGraphics.Canvas);
  2493. VAR attribute : XML.Attribute; name : Strings.String;
  2494. BEGIN
  2495. DrawForeground^(canvas);
  2496. attribute := SELF.attribute;
  2497. IF (attribute # NIL) THEN
  2498. name := attribute.GetName();
  2499. canvas.DrawString(0, 14, name^);
  2500. ELSE
  2501. canvas.DrawString(0, 14, "NoName");
  2502. END;
  2503. END DrawForeground;
  2504. END AttributeView;
  2505. TYPE
  2506. Attributes* = OBJECT(ComponentElement)
  2507. VAR
  2508. (* add/remove attributes *)
  2509. controlPanel : WMStandardComponents.Panel;
  2510. nameEditor, valueEditor : WMEditors.TextField;
  2511. removeBtn, addBtn : WMStandardComponents.Button;
  2512. (* display attributes *)
  2513. views : AttributeView;
  2514. PROCEDURE &Init*;
  2515. BEGIN
  2516. Init^;
  2517. SetNameAsString(Strings.NewString("Attributes"));
  2518. NEW(controlPanel); controlPanel.alignment.Set(WMComponents.AlignTop);
  2519. controlPanel.bounds.SetHeight(LineHeight);
  2520. controlPanel.bearing.Set(WMRectangles.MakeRect(LineBearing, LineBearing, LineBearing, LineBearing));
  2521. AddContent(controlPanel);
  2522. NEW(removeBtn); removeBtn.alignment.Set(WMComponents.AlignRight);
  2523. removeBtn.caption.SetAOC("Remove");
  2524. removeBtn.onClick.Add(RemoveAttributeHandler);
  2525. controlPanel.AddContent(removeBtn);
  2526. NEW(addBtn); addBtn.alignment.Set(WMComponents.AlignRight);
  2527. addBtn.caption.SetAOC("Add");
  2528. addBtn.onClick.Add(AddAttributeHandler);
  2529. controlPanel.AddContent(addBtn);
  2530. NEW(nameEditor); nameEditor.alignment.Set(WMComponents.AlignLeft);
  2531. nameEditor.bounds.SetWidth(NameWidth);
  2532. nameEditor.type.Set(WMEditors.Ascii);
  2533. nameEditor.onEnter.Add(EnterPressed);
  2534. nameEditor.uid.SetAOC("nameEditor");
  2535. nameEditor.focusPrevious.SetAOC("&valueEditor");
  2536. nameEditor.focusNext.SetAOC("&valueEditor");
  2537. controlPanel.AddContent(nameEditor);
  2538. NEW(valueEditor); valueEditor.alignment.Set(WMComponents.AlignClient);
  2539. valueEditor.type.Set(WMEditors.Ascii);
  2540. valueEditor.onEnter.Add(EnterPressed);
  2541. valueEditor.uid.SetAOC("valueEditor");
  2542. valueEditor.focusPrevious.SetAOC("&nameEditor");
  2543. valueEditor.focusNext.SetAOC("&nameEditor");
  2544. controlPanel.AddContent(valueEditor);
  2545. bounds.SetHeight(controlPanel.bounds.GetHeight() + 2*LineBearing);
  2546. views := NewAttributeView();
  2547. END Init;
  2548. PROCEDURE EnterPressed(sender, data : ANY);
  2549. BEGIN
  2550. AddAttributeHandler(sender, data);
  2551. END EnterPressed;
  2552. PROCEDURE RemoveAttributeHandler(sender, data : ANY);
  2553. VAR attributeName : ARRAY 256 OF CHAR;
  2554. BEGIN
  2555. nameEditor.GetAsString(attributeName);
  2556. Strings.TrimWS(attributeName);
  2557. IF (component # NIL) THEN
  2558. component.RemoveAttribute(attributeName);
  2559. Synchronize(TRUE);
  2560. END;
  2561. END RemoveAttributeHandler;
  2562. PROCEDURE AddAttributeHandler(sender, data : ANY);
  2563. VAR attributeName, attributeValue : ARRAY 256 OF CHAR;
  2564. BEGIN
  2565. IF (component # NIL) THEN
  2566. nameEditor.GetAsString(attributeName);
  2567. Strings.TrimWS(attributeName);
  2568. IF (attributeName # "") THEN
  2569. valueEditor.GetAsString(attributeValue);
  2570. component.SetAttributeValue(attributeName, attributeValue);
  2571. Synchronize(TRUE);
  2572. END;
  2573. END;
  2574. END AddAttributeHandler;
  2575. PROCEDURE NewAttributeView() : AttributeView;
  2576. VAR v : AttributeView;
  2577. BEGIN
  2578. NEW(v); v.alignment.Set(WMComponents.AlignTop);
  2579. v.bounds.SetHeight(LineHeight);
  2580. v.bearing.Set(WMRectangles.MakeRect(LineBearing, LineBearing, LineBearing, LineBearing));
  2581. AddContent(v);
  2582. RETURN v;
  2583. END NewAttributeView;
  2584. PROCEDURE CountNofElements(component : WMComponents.Component);
  2585. VAR enumerator : XMLObjects.Enumerator; ignore : ANY;
  2586. BEGIN
  2587. nofElements := 0;
  2588. IF (component # NIL) THEN
  2589. enumerator := component.GetAttributes();
  2590. WHILE enumerator.HasMoreElements() DO
  2591. ignore := enumerator.GetNext();
  2592. INC(nofElements);
  2593. END;
  2594. END;
  2595. END CountNofElements;
  2596. PROCEDURE SetAttributes(element : XML.Element);
  2597. VAR
  2598. v, last : AttributeView; enumerator : XMLObjects.Enumerator; ptr : ANY;
  2599. height : LONGINT;
  2600. BEGIN
  2601. Acquire;
  2602. height := LineHeight + 2*LineBearing; (* add/remove panel *)
  2603. v := views;
  2604. WHILE (v # NIL) DO
  2605. v.SetAttribute(NIL); v.visible.Set(FALSE);
  2606. v := v.next;
  2607. END;
  2608. nofElements := 0;
  2609. IF (element # NIL) THEN
  2610. v := views; last := views;
  2611. enumerator := element.GetAttributes();
  2612. WHILE enumerator.HasMoreElements() DO
  2613. ptr := enumerator.GetNext();
  2614. IF (ptr IS XML.Attribute) THEN
  2615. INC(nofElements);
  2616. IF (v = NIL) THEN
  2617. v := NewAttributeView();
  2618. last.next := v;
  2619. END;
  2620. v.SetAttribute(ptr(XML.Attribute));
  2621. v.visible.Set(TRUE);
  2622. v.Synchronize;
  2623. height := height + v.bounds.GetHeight() + 2*LineBearing;
  2624. last := v;
  2625. v := v.next;
  2626. END;
  2627. END;
  2628. END;
  2629. Release;
  2630. bounds.SetHeight(height);
  2631. Reset(NIL, NIL);
  2632. Invalidate;
  2633. END SetAttributes;
  2634. PROCEDURE SetComponent*(component : WMComponents.Component);
  2635. BEGIN
  2636. IF (component # SELF.component) THEN
  2637. DisableUpdate;
  2638. Acquire;
  2639. SELF.component := component;
  2640. controlPanel.visible.Set(component # NIL);
  2641. SetAttributes(component);
  2642. Release;
  2643. EnableUpdate;
  2644. Invalidate;
  2645. END;
  2646. END SetComponent;
  2647. PROCEDURE Apply*;
  2648. VAR v : AttributeView;
  2649. BEGIN
  2650. v := views;
  2651. WHILE (v # NIL) DO v.Apply; v := v.next; END;
  2652. END Apply;
  2653. PROCEDURE Synchronize*(force : BOOLEAN);
  2654. BEGIN
  2655. SetAttributes(SELF.component);
  2656. END Synchronize;
  2657. END Attributes;
  2658. CONST
  2659. (* PropertyPanel.state *)
  2660. State_Waiting = 0;
  2661. State_Synchronize = 1;
  2662. State_SynchronizeForce = 2;
  2663. State_Terminating = 99;
  2664. State_Terminated = 100;
  2665. NofTabs = 5;
  2666. TYPE
  2667. PropertyPanel* = OBJECT(WMComponents.VisualComponent)
  2668. VAR
  2669. component : WMComponents.Component;
  2670. standardProperties : StandardProperties;
  2671. extendedProperties : ExtendedPropertiesView;
  2672. eventListeners : EventListeners;
  2673. eventSources : EventSources;
  2674. attributes : Attributes;
  2675. autoRefreshBtn, refreshBtn, applyBtn : WMStandardComponents.Button;
  2676. autoRefresh : BOOLEAN;
  2677. tabs : WMTabComponents.Tabs;
  2678. tabList : ARRAY NofTabs OF WMTabComponents.Tab;
  2679. tabPanels : ARRAY NofTabs OF ComponentElement;
  2680. tabNofElements : ARRAY NofTabs OF LONGINT;
  2681. tabCaptions : ARRAY NofTabs OF ARRAY 128 OF CHAR;
  2682. tabPanel : WMScrollableComponents.ScrollableContainer;
  2683. curTabPanel : ComponentElement;
  2684. curTab : WMTabComponents.Tab;
  2685. (* active body *)
  2686. state, internalState : LONGINT;
  2687. timer : Kernel.Timer;
  2688. PROCEDURE &Init*;
  2689. VAR panel, toolbar : WMStandardComponents.Panel; i : LONGINT;
  2690. BEGIN
  2691. Init^;
  2692. SetNameAsString(Strings.NewString("PropertyPanel"));
  2693. state := State_Waiting; internalState := state;
  2694. NEW(timer);
  2695. NEW(panel); panel.alignment.Set(WMComponents.AlignClient);
  2696. NEW(tabs); tabs.bounds.SetHeight(20); tabs.alignment.Set(WMComponents.AlignTop);
  2697. tabs.onSelectTab.Add(TabSelected);
  2698. panel.AddContent(tabs);
  2699. NEW(toolbar); toolbar.alignment.Set(WMComponents.AlignBottom);
  2700. toolbar.bounds.SetHeight(20);
  2701. toolbar.bearing.Set(WMRectangles.MakeRect(2*LineBearing, LineBearing, 2*LineBearing, LineBearing));
  2702. panel.AddContent(toolbar);
  2703. NEW(applyBtn); applyBtn.alignment.Set(WMComponents.AlignRight);
  2704. applyBtn.caption.SetAOC("Apply");
  2705. applyBtn.onClick.Add(ButtonHandler);
  2706. toolbar.AddContent(applyBtn);
  2707. NEW(refreshBtn); refreshBtn.alignment.Set(WMComponents.AlignRight);
  2708. refreshBtn.caption.SetAOC("Refresh");
  2709. refreshBtn.onClick.Add(ButtonHandler);
  2710. toolbar.AddContent(refreshBtn);
  2711. NEW(autoRefreshBtn); autoRefreshBtn.alignment.Set(WMComponents.AlignLeft);
  2712. autoRefreshBtn.caption.SetAOC("AutoRefresh");
  2713. autoRefreshBtn.isToggle.Set(TRUE);
  2714. autoRefreshBtn.SetPressed(TRUE);
  2715. autoRefreshBtn.onClick.Add(ButtonHandler);
  2716. autoRefreshBtn.bounds.SetWidth(80);
  2717. toolbar.AddContent(autoRefreshBtn);
  2718. autoRefresh := autoRefreshBtn.GetPressed();
  2719. NEW(tabPanel); tabPanel.alignment.Set(WMComponents.AlignClient);
  2720. panel.AddContent(tabPanel);
  2721. NEW(standardProperties); tabPanels[0] := standardProperties;
  2722. NEW(extendedProperties); tabPanels[1] := extendedProperties;
  2723. NEW(eventSources); tabPanels[2] := eventSources;
  2724. NEW(eventListeners); tabPanels[3] := eventListeners;
  2725. NEW(attributes); tabPanels[4] := attributes;
  2726. FOR i := 0 TO NofTabs-1 DO
  2727. tabNofElements[i] := -1; (* force update *)
  2728. tabPanels[i].alignment.Set(WMComponents.AlignTop);
  2729. tabPanel.AddContent(tabPanels[i]);
  2730. tabPanels[i].visible.Set(FALSE);
  2731. tabPanels[i].fillColor.Set(WMGraphics.White);
  2732. tabPanels[i].bearing.Set(WMRectangles.MakeRect(10, 10, 10, 10));
  2733. tabList[i] := tabs.NewTab(); tabs.AddTab(tabList[i]);
  2734. CASE i OF
  2735. |0: tabCaptions[i] := "Standard Properties";
  2736. |1: tabCaptions[i] := "Extended Properties";
  2737. |2: tabCaptions[i] := "Event Sources";
  2738. |3: tabCaptions[i] := "Event Listeners";
  2739. |4: tabCaptions[i] := "Attributes";
  2740. ELSE
  2741. HALT(99);
  2742. END;
  2743. tabs.SetTabData(tabList[i], tabPanels[i]);
  2744. END;
  2745. UpdateTabCaptions;
  2746. curTabPanel := standardProperties; curTab := tabList[0]; curTabPanel.visible.Set(TRUE);
  2747. AddContent(panel);
  2748. END Init;
  2749. PROCEDURE UpdateTabCaptions;
  2750. VAR caption : ARRAY 128 OF CHAR; nbr : ARRAY 8 OF CHAR; nofElements, i : LONGINT;
  2751. BEGIN
  2752. FOR i := 0 TO NofTabs - 1 DO
  2753. CASE i OF
  2754. |0: nofElements := standardProperties.GetNofElements();
  2755. |1: nofElements := extendedProperties.GetNofElements();
  2756. |2: nofElements := eventSources.GetNofElements();
  2757. |3: nofElements := eventListeners.GetNofElements();
  2758. |4: nofElements := attributes.GetNofElements();
  2759. ELSE
  2760. HALT(99);
  2761. END;
  2762. IF (nofElements # tabNofElements[i]) THEN
  2763. tabNofElements[i] := nofElements;
  2764. COPY(tabCaptions[i], caption);
  2765. Strings.Append(caption, " (");
  2766. Strings.IntToStr(nofElements, nbr); Strings.Append(caption, nbr);
  2767. Strings.Append(caption, ")");
  2768. tabs.SetTabCaption(tabList[i], Strings.NewString(caption));
  2769. END;
  2770. END;
  2771. END UpdateTabCaptions;
  2772. PROCEDURE SetState(state : LONGINT);
  2773. BEGIN {EXCLUSIVE}
  2774. IF (SELF.state < State_Terminating) THEN
  2775. SELF.state := state;
  2776. END;
  2777. END SetState;
  2778. PROCEDURE PropertyListChanged(sender, data : ANY);
  2779. BEGIN
  2780. SetState(State_Synchronize);
  2781. END PropertyListChanged;
  2782. PROCEDURE LinkChanged(sender, data : ANY);
  2783. BEGIN
  2784. SetState(State_SynchronizeForce);
  2785. END LinkChanged;
  2786. PROCEDURE SetComponent*(sender, component : ANY);
  2787. BEGIN
  2788. IF ~IsCallFromSequencer() THEN
  2789. sequencer.ScheduleEvent(SELF.SetComponent, sender, component)
  2790. ELSE
  2791. IF (component # NIL) & (component IS WMComponents.Component) THEN
  2792. SetComponentInternal(component(WMComponents.Component));
  2793. ELSE
  2794. SetComponentInternal(NIL);
  2795. END;
  2796. END;
  2797. END SetComponent;
  2798. PROCEDURE Enable;
  2799. BEGIN
  2800. standardProperties.Enable;
  2801. extendedProperties.Enable;
  2802. END Enable;
  2803. PROCEDURE Disable;
  2804. BEGIN
  2805. standardProperties.Disable;
  2806. extendedProperties.Disable;
  2807. END Disable;
  2808. PROCEDURE SetComponentInternal*(component : WMComponents.Component);
  2809. VAR vc : WMComponents.VisualComponent;
  2810. BEGIN
  2811. ASSERT(IsCallFromSequencer());
  2812. IF (component # SELF.component) THEN
  2813. IF (SELF.component # NIL) THEN
  2814. SELF.component.properties.onPropertyChanged.Remove(PropertyListChanged);
  2815. SELF.component.properties.onLinkChanged.Remove(LinkChanged)
  2816. END;
  2817. SELF.component := component;
  2818. vc := curTabPanel;
  2819. IF (vc = standardProperties) THEN standardProperties.SetComponent(component);
  2820. ELSE standardProperties.CountNofElements(component);
  2821. END;
  2822. IF (vc = extendedProperties) THEN extendedProperties.SetComponent(component);
  2823. ELSE extendedProperties.CountNofElements(component);
  2824. END;
  2825. IF (vc = eventSources) THEN eventSources.SetComponent(component);
  2826. ELSE eventSources.CountNofElements(component);
  2827. END;
  2828. IF (vc = eventListeners) THEN eventListeners.SetComponent(component);
  2829. ELSE eventListeners.CountNofElements(component);
  2830. END;
  2831. IF (vc = attributes) THEN attributes.SetComponent(component);
  2832. ELSE attributes.CountNofElements(component);
  2833. END;
  2834. IF (component # NIL) THEN
  2835. component.properties.onPropertyChanged.Add(PropertyListChanged);
  2836. component.properties.onLinkChanged.Add(LinkChanged);
  2837. END;
  2838. DisableUpdate;
  2839. UpdateTabCaptions;
  2840. vc.Resized;
  2841. tabPanel.Reset(NIL, NIL);
  2842. IF (component # NIL) THEN
  2843. IF component.IsLocked() THEN Disable; ELSE Enable; END;
  2844. END;
  2845. EnableUpdate;
  2846. Invalidate;
  2847. END;
  2848. END SetComponentInternal;
  2849. PROCEDURE TabSelected(sender, data : ANY);
  2850. VAR tab : WMTabComponents.Tab;
  2851. BEGIN
  2852. IF (data # NIL) & (data IS WMTabComponents.Tab) THEN
  2853. DisableUpdate;
  2854. tab := data(WMTabComponents.Tab);
  2855. IF (tab.data # NIL) & (tab.data IS WMComponents.VisualComponent) THEN
  2856. curTabPanel.visible.Set(FALSE);
  2857. curTab := tab;
  2858. curTabPanel := tab.data(ComponentElement);
  2859. IF (curTabPanel = standardProperties) THEN
  2860. standardProperties.SetComponent(component);
  2861. ELSIF (curTabPanel = extendedProperties) THEN
  2862. extendedProperties.SetComponent(component);
  2863. ELSIF (curTabPanel = eventSources) THEN
  2864. eventSources.SetComponent(component);
  2865. ELSIF (curTabPanel = eventListeners) THEN
  2866. eventListeners.SetComponent(component);
  2867. ELSIF (curTabPanel = attributes) THEN
  2868. attributes.SetComponent(component);
  2869. END;
  2870. curTabPanel.visible.Set(TRUE);
  2871. tabPanel.Reset(SELF, NIL);
  2872. END;
  2873. EnableUpdate;
  2874. tabPanel.Invalidate;
  2875. END;
  2876. END TabSelected;
  2877. PROCEDURE ButtonHandler(sender, data : ANY);
  2878. BEGIN
  2879. IF (sender = refreshBtn) THEN
  2880. SetState(State_SynchronizeForce);
  2881. timer.Wakeup;
  2882. ELSIF (sender = applyBtn) THEN
  2883. curTabPanel.Apply;
  2884. ELSIF (sender = autoRefreshBtn) THEN
  2885. autoRefresh := autoRefreshBtn.GetPressed();
  2886. IF autoRefresh THEN
  2887. SetState(State_SynchronizeForce);
  2888. timer.Wakeup;
  2889. END;
  2890. END;
  2891. END ButtonHandler;
  2892. PROCEDURE Finalize;
  2893. BEGIN
  2894. Finalize^;
  2895. IF (component # NIL) THEN
  2896. component.properties.onPropertyChanged.Remove(PropertyListChanged);
  2897. component.properties.onLinkChanged.Remove(LinkChanged);
  2898. END;
  2899. BEGIN {EXCLUSIVE} state := State_Terminating; END;
  2900. BEGIN {EXCLUSIVE} AWAIT(state = State_Terminated); END;
  2901. END Finalize;
  2902. PROCEDURE Synchronize(force : BOOLEAN);
  2903. BEGIN
  2904. IF autoRefresh THEN
  2905. standardProperties.Synchronize(force);
  2906. extendedProperties.Synchronize(force);
  2907. attributes.Synchronize(force);
  2908. END;
  2909. END Synchronize;
  2910. BEGIN {ACTIVE}
  2911. WHILE (state < State_Terminating) DO
  2912. BEGIN {EXCLUSIVE}
  2913. AWAIT(state # State_Waiting);
  2914. internalState := state;
  2915. IF (state < State_Terminating) THEN state := State_Waiting; END;
  2916. END;
  2917. IF (internalState = State_Synchronize) THEN
  2918. Synchronize(FALSE);
  2919. ELSIF (internalState = State_SynchronizeForce) THEN
  2920. Synchronize(TRUE);
  2921. ELSIF (internalState # State_Terminating) THEN
  2922. timer.Sleep(30);
  2923. END;
  2924. END;
  2925. BEGIN {EXCLUSIVE} state := State_Terminated; END;
  2926. END PropertyPanel;
  2927. TYPE
  2928. RepositoryPanel* = OBJECT(WMComponents.VisualComponent)
  2929. VAR
  2930. component : Repositories.Component;
  2931. lastTimestamp : LONGINT;
  2932. repositoryName : WMStandardComponents.Label;
  2933. editor : WMEditors.TextField;
  2934. storeBtn, unbindBtn, removeBtn, updateBtn : WMStandardComponents.Button;
  2935. state : LONGINT;
  2936. timer : Kernel.Timer;
  2937. PROCEDURE &Init*;
  2938. BEGIN
  2939. Init^;
  2940. SetNameAsString(Strings.NewString("RepositoryPanel"));
  2941. state := State_Waiting;
  2942. NEW(timer);
  2943. CreateContent;
  2944. END Init;
  2945. PROCEDURE CreateContent;
  2946. VAR line : WMStandardComponents.Panel;
  2947. BEGIN
  2948. line := CreateLine();
  2949. line.AddContent(CreateLabel("Repository:", 80, WMComponents.AlignLeft));
  2950. NEW(updateBtn); updateBtn.alignment.Set(WMComponents.AlignRight);
  2951. updateBtn.caption.SetAOC("Update");
  2952. updateBtn.onClick.Add(HandleUpdateButton);
  2953. line.AddContent(updateBtn);
  2954. NEW(removeBtn); removeBtn.alignment.Set(WMComponents.AlignRight);
  2955. removeBtn.caption.SetAOC("Remove");
  2956. removeBtn.onClick.Add(HandleRemoveButton);
  2957. line.AddContent(removeBtn);
  2958. NEW(unbindBtn); unbindBtn.alignment.Set(WMComponents.AlignRight);
  2959. unbindBtn.caption.SetAOC("Unbind");
  2960. unbindBtn.onClick.Add(HandleUnbindButton);
  2961. line.AddContent(unbindBtn);
  2962. NEW(repositoryName); repositoryName.alignment.Set(WMComponents.AlignClient);
  2963. line.AddContent(repositoryName);
  2964. AddContent(line);
  2965. line := CreateLine();
  2966. NEW(storeBtn); storeBtn.alignment.Set(WMComponents.AlignLeft);
  2967. storeBtn.bounds.SetWidth(80);
  2968. storeBtn.caption.SetAOC("Store into:");
  2969. storeBtn.onClick.Add(HandleStoreButton);
  2970. line.AddContent(storeBtn);
  2971. NEW(editor); editor.alignment.Set(WMComponents.AlignClient);
  2972. editor.type.Set(WMEditors.Ascii);
  2973. editor.fillColor.Set(WMGraphics.White);
  2974. line.AddContent(editor);
  2975. AddContent(line);
  2976. END CreateContent;
  2977. PROCEDURE HandleStoreButton(sender, data : ANY);
  2978. VAR
  2979. component : Repositories.Component; repository : Repositories.Repository;
  2980. name, repositoryName, componentName : ARRAY 256 OF CHAR; id, res : LONGINT;
  2981. filename : Files.FileName;
  2982. BEGIN
  2983. component := SELF.component;
  2984. IF (component # NIL) THEN
  2985. editor.GetAsString(name);
  2986. IF Repositories.SplitName(name, repositoryName, componentName, id) THEN
  2987. repository := Repositories.ThisRepository(repositoryName);
  2988. IF (repository = NIL) THEN
  2989. res := WMDialogs.Message(WMDialogs.TQuestion, "Question", "Repository not found, create new repository?", {WMDialogs.ResYes, WMDialogs.ResNo});
  2990. IF (res = WMDialogs.ResYes) THEN
  2991. COPY(repositoryName, filename); Strings.Append(filename, "."); Strings.Append(filename, Repositories.DefaultFileExtension);
  2992. Repositories.CreateRepository(filename, res);
  2993. IF (res = Repositories.Ok) THEN
  2994. repository := Repositories.ThisRepository(repositoryName);
  2995. IF (repository = NIL) THEN
  2996. WMDialogs.Error("Error", "Could not load just created repository");
  2997. END;
  2998. ELSE
  2999. WMDialogs.Error("Error", "Could not create repository");
  3000. END;
  3001. END;
  3002. END;
  3003. IF (repository # NIL) THEN
  3004. repository.PutComponent(component, componentName, id, res);
  3005. IF (res # Repositories.Ok) THEN
  3006. WMDialogs.Error("Error", "Could not put component into repository");
  3007. END;
  3008. END;
  3009. ELSE
  3010. WMDialogs.Error("Error", "Invalid repository:component:refnum value");
  3011. END;
  3012. END;
  3013. END HandleStoreButton;
  3014. PROCEDURE HandleRemoveButton(sender, data : ANY);
  3015. VAR component : Repositories.Component; ignore : Repositories.Name; repository : Repositories.Repository; refNum, res : LONGINT;
  3016. BEGIN
  3017. component := SELF.component;
  3018. IF (component # NIL) THEN
  3019. component.GetRepository(repository, ignore, refNum);
  3020. IF (repository # NIL) THEN
  3021. repository.Remove(component, res);
  3022. IF (res # Repositories.Ok) THEN
  3023. WMDialogs.Error("Error", "Component removal failed");
  3024. END;
  3025. ELSE
  3026. WMDialogs.Error("Error", "Component is not bound to a repository");
  3027. END;
  3028. END;
  3029. END HandleRemoveButton;
  3030. PROCEDURE HandleUpdateButton(sender, data : ANY);
  3031. VAR component : Repositories.Component; ignore : Repositories.Name; repository : Repositories.Repository; refNum, res : LONGINT;
  3032. BEGIN
  3033. component := SELF.component;
  3034. IF (component # NIL) THEN
  3035. component.GetRepository(repository, ignore, refNum);
  3036. IF (repository # NIL) THEN
  3037. repository.Store(res);
  3038. IF (res # Repositories.Ok) THEN
  3039. WMDialogs.Error("Error", "Could not store repository");
  3040. END;
  3041. ELSE
  3042. WMDialogs.Error("Error", "Component is not bound to a repository");
  3043. END;
  3044. END;
  3045. END HandleUpdateButton;
  3046. PROCEDURE HandleUnbindButton(sender, data : ANY);
  3047. VAR component : Repositories.Component; ignore : Repositories.Name; repository : Repositories.Repository; refNum : LONGINT;
  3048. BEGIN
  3049. component := SELF.component;
  3050. IF (component # NIL) THEN
  3051. component.GetRepository(repository, ignore, refNum);
  3052. IF (repository # NIL) THEN
  3053. repository.Unbind(component);
  3054. ELSE
  3055. WMDialogs.Error("Error", "Component is not bound to a repository");
  3056. END;
  3057. END;
  3058. END HandleUnbindButton;
  3059. PROCEDURE SetComponent*(component : WMComponents.Component);
  3060. BEGIN
  3061. SELF.component := component;
  3062. IF (component # NIL) THEN lastTimestamp := component.timestamp - 1; ELSE lastTimestamp := -1; END;
  3063. timer.Wakeup; (* force update *)
  3064. END SetComponent;
  3065. PROCEDURE Finalize;
  3066. BEGIN
  3067. Finalize^;
  3068. BEGIN {EXCLUSIVE} state := State_Terminating; END;
  3069. timer.Wakeup;
  3070. BEGIN {EXCLUSIVE} AWAIT(state = State_Terminated); END;
  3071. END Finalize;
  3072. PROCEDURE Update;
  3073. VAR
  3074. component : Repositories.Component; repository : Repositories.Repository; cname : Repositories.Name;
  3075. caption : Strings.String; refNum : LONGINT;
  3076. BEGIN
  3077. component := SELF.component;
  3078. IF (component # NIL) THEN
  3079. IF (lastTimestamp # component.timestamp) THEN
  3080. lastTimestamp := component.timestamp;
  3081. component.GetRepository(repository, cname, refNum);
  3082. IF (repository # NIL) THEN
  3083. caption := Repositories.NewJoinName(repository.name, cname, refNum);
  3084. repositoryName.caption.Set(caption);
  3085. ELSE
  3086. repositoryName.caption.SetAOC("");
  3087. END;
  3088. END;
  3089. ELSIF (lastTimestamp = -1) THEN
  3090. lastTimestamp := 0;
  3091. repositoryName.caption.SetAOC("");
  3092. END;
  3093. END Update;
  3094. BEGIN {ACTIVE}
  3095. WHILE (state < State_Terminating) DO
  3096. Update;
  3097. timer.Sleep(200);
  3098. END;
  3099. BEGIN {EXCLUSIVE} state := State_Terminated; END;
  3100. END RepositoryPanel;
  3101. TYPE
  3102. XMLPanel* = OBJECT(WMComponents.VisualComponent)
  3103. VAR
  3104. component : Repositories.Component;
  3105. showBtn : WMStandardComponents.Button;
  3106. PROCEDURE &Init*;
  3107. BEGIN
  3108. Init^;
  3109. SetNameAsString(Strings.NewString("XMLPanel"));
  3110. component := NIL;
  3111. NEW(showBtn); showBtn.alignment.Set(WMComponents.AlignLeft);
  3112. showBtn.bounds.SetWidth(80);
  3113. showBtn.caption.SetAOC("Show XML");
  3114. showBtn.onClick.Add(HandleShowBtn);
  3115. showBtn.enabled.Set(FALSE);
  3116. AddContent(showBtn);
  3117. END Init;
  3118. PROCEDURE HandleShowBtn(sender, data : ANY);
  3119. VAR component : Repositories.Component; writer : WMUtilities.WindowWriter; name : Strings.String;
  3120. BEGIN
  3121. component := SELF.component;
  3122. IF (component # NIL) THEN
  3123. name := component.GetName();
  3124. IF (name = NIL) THEN name := Strings.NewString("NoName"); END;
  3125. NEW(writer, name^, 640, 480, FALSE);
  3126. component.Write(writer,NIL, 0);
  3127. writer.Update;
  3128. END;
  3129. END HandleShowBtn;
  3130. PROCEDURE SetComponent*(component : WMComponents.Component);
  3131. BEGIN
  3132. SELF.component := component;
  3133. showBtn.enabled.Set(component # NIL);
  3134. END SetComponent;
  3135. END XMLPanel;
  3136. TYPE
  3137. ModelView* = OBJECT(WMComponents.VisualComponent)
  3138. VAR
  3139. model : Models.Model;
  3140. typeLabel : WMStandardComponents.Label;
  3141. editor : WMEditors.Editor;
  3142. autoRefreshBtn : WMStandardComponents.Button;
  3143. autoRefresh : BOOLEAN;
  3144. PROCEDURE &Init*;
  3145. VAR panel : WMStandardComponents.Panel; label : WMStandardComponents.Label;
  3146. BEGIN
  3147. Init^;
  3148. SetNameAsString(StrModelView);
  3149. model := NIL;
  3150. bearing.Set(WMRectangles.MakeRect(LineBearing, LineBearing, LineBearing, LineBearing));
  3151. autoRefresh := FALSE;
  3152. NEW(panel); panel.alignment.Set(WMComponents.AlignTop);
  3153. panel.bounds.SetHeight(LineHeight);
  3154. AddInternalComponent(panel);
  3155. NEW(label); label.alignment.Set(WMComponents.AlignLeft);
  3156. label.bounds.SetWidth(80);
  3157. label.caption.Set(StrType);
  3158. panel.AddInternalComponent(label);
  3159. NEW(typeLabel); typeLabel.alignment.Set(WMComponents.AlignClient);
  3160. typeLabel.caption.Set(StrNoCaption);
  3161. panel.AddInternalComponent(typeLabel);
  3162. NEW(autoRefreshBtn); autoRefreshBtn.alignment.Set(WMComponents.AlignBottom);
  3163. autoRefreshBtn.bounds.SetHeight(20);
  3164. autoRefreshBtn.caption.SetAOC("AutoRefresh");
  3165. autoRefreshBtn.isToggle.Set(TRUE);
  3166. autoRefreshBtn.SetPressed(autoRefresh);
  3167. autoRefreshBtn.onClick.Add(HandleAutoRefreshBtn);
  3168. AddInternalComponent(autoRefreshBtn);
  3169. NEW(editor);
  3170. editor.alignment.Set(WMComponents.AlignClient);
  3171. editor.tv.showBorder.Set(TRUE);
  3172. editor.tv.borders.Set(WMRectangles.MakeRect(1, 1, 1, 1));
  3173. editor.tv.SetExtKeyEventHandler(EditorKeyEvent);
  3174. AddInternalComponent(editor);
  3175. END Init;
  3176. PROCEDURE HandleAutoRefreshBtn(sender, data : ANY);
  3177. BEGIN
  3178. IF autoRefresh THEN
  3179. autoRefresh := FALSE;
  3180. ELSE
  3181. autoRefresh := TRUE;
  3182. ModelChanged(NIL, NIL);
  3183. END;
  3184. END HandleAutoRefreshBtn;
  3185. PROCEDURE EditorKeyEvent(ucs : LONGINT; flags : SET; VAR keySym : LONGINT; VAR handled : BOOLEAN);
  3186. BEGIN
  3187. IF (keySym = Inputs.KsReturn) & (Inputs.Shift * flags # {}) THEN
  3188. HandleShiftReturn;
  3189. handled := TRUE;
  3190. ELSIF (keySym = Inputs.KsEscape) THEN
  3191. ModelChanged(NIL, NIL);
  3192. handled := TRUE;
  3193. ELSE
  3194. editor.KeyPressed(ucs, flags, keySym, handled);
  3195. END;
  3196. END EditorKeyEvent;
  3197. PROCEDURE HandleShiftReturn;
  3198. VAR model : Models.Model; string : Types.DynamicString; length, res : LONGINT;
  3199. BEGIN
  3200. model := SELF.model;
  3201. IF (model # NIL) THEN
  3202. string := Types.NewString();
  3203. editor.text.AcquireRead;
  3204. length := editor.text.GetLength();
  3205. Types.EnsureLength(string, 5*length); (* UTF8 uses at most 5 bytes for encoding Unicode characters *)
  3206. editor.GetAsString(string.value^);
  3207. editor.text.ReleaseRead;
  3208. model.SetGeneric(string, res);
  3209. ELSE
  3210. editor.SetAsString("");
  3211. END;
  3212. END HandleShiftReturn;
  3213. PROCEDURE SetModel*(model : Models.Model);
  3214. VAR string : Types.DynamicString; res : LONGINT;
  3215. BEGIN
  3216. Acquire;
  3217. IF (SELF.model # NIL) THEN SELF.model.onChanged.Remove(ModelChanged); END;
  3218. SELF.model := model;
  3219. IF (SELF.model # NIL) THEN
  3220. SELF.model.onChanged.Add(ModelChanged);
  3221. typeLabel.caption.Set(GetModelTypeString(SELF.model));
  3222. IF model IS Models.Text THEN
  3223. editor.SetText(model(Models.Text).Get());
  3224. ELSE
  3225. string := Types.NewString();
  3226. SELF.model.GetGeneric(string, res);
  3227. IF (res = Types.Ok) THEN
  3228. editor.SetAsString(string.value^);
  3229. ELSE
  3230. editor.SetAsString("<ERROR>");
  3231. END;
  3232. END;
  3233. ELSE
  3234. typeLabel.caption.Set(StrNoCaption);
  3235. editor.SetAsString("");
  3236. END;
  3237. Release;
  3238. Invalidate;
  3239. END SetModel;
  3240. PROCEDURE ModelChanged(sender, data : ANY);
  3241. VAR model : Models.Model; string : Types.String256; res : LONGINT;
  3242. BEGIN
  3243. IF autoRefresh THEN
  3244. model := SELF.model;
  3245. IF (model # NIL) THEN
  3246. model.GetGeneric(string, res);
  3247. IF (res = Types.Ok) THEN
  3248. editor.SetAsString(string.value);
  3249. ELSE
  3250. editor.SetAsString("[ERROR]");
  3251. END;
  3252. ELSE
  3253. editor.SetAsString("");
  3254. END;
  3255. END;
  3256. END ModelChanged;
  3257. PROCEDURE Finalize;
  3258. BEGIN
  3259. Finalize^;
  3260. IF (model # NIL) THEN model.onChanged.Remove(ModelChanged); END;
  3261. END Finalize;
  3262. END ModelView;
  3263. TYPE
  3264. KillerMsg = OBJECT END KillerMsg;
  3265. Window* = OBJECT(WMComponents.FormWindow)
  3266. PROCEDURE &New*(vc : WMComponents.VisualComponent);
  3267. BEGIN
  3268. ASSERT((vc # NIL) & (vc.bounds.GetWidth() > 0) & (vc.bounds.GetHeight() > 0));
  3269. Init(vc.bounds.GetWidth(), vc.bounds.GetHeight(), FALSE);
  3270. vc.alignment.Set(WMComponents.AlignClient);
  3271. SetTitle(StrWindowTitle);
  3272. SetContent(vc);
  3273. IncCount;
  3274. WMWindowManager.DefaultAddWindow(SELF);
  3275. END New;
  3276. PROCEDURE Close;
  3277. BEGIN
  3278. Close^;
  3279. DecCount
  3280. END Close;
  3281. PROCEDURE Handle(VAR x : WMMessages.Message);
  3282. BEGIN
  3283. IF (x.msgType = WMMessages.MsgExt) & (x.ext # NIL) & (x.ext IS KillerMsg) THEN Close;
  3284. ELSE Handle^(x)
  3285. END
  3286. END Handle;
  3287. END Window;
  3288. VAR
  3289. nofWindows : LONGINT;
  3290. StrNotAvailable, StrNoCaption, StrType,
  3291. StrComponentInfo, StrStandardProperties, StrExtendedProperties, StrExtendedPropertiesView, StrEventListeners, StrEventSources,
  3292. StrBooleanPropertyView, StrInt32PropertyView, StrRealPropertyView, StrRectanglePropertyView, StrPointPropertyView,
  3293. StrStringPropertyView,
  3294. StrColorPropertyView, StrEventSourceView, StrEventListenerView, StrUnknownPropertyView,
  3295. StrFontPropertyView, StrReferencePropertyView, StrAlignmentPropertyView, StrModelView : Strings.String;
  3296. StrBoolean, StrInteger, StrBoundedInteger, StrReal, StrLongreal, StrChar,
  3297. StrString, StrSet, StrText, StrContainer, StrCustom, StrNil : Strings.String;
  3298. StrWindowTitle : Strings.String;
  3299. PROCEDURE GetModelTypeString(model : Models.Model) : Strings.String;
  3300. VAR string : Strings.String;
  3301. BEGIN
  3302. IF (model = NIL) THEN string := StrNil;
  3303. ELSIF (model IS Models.Boolean) THEN string := StrBoolean;
  3304. ELSIF (model IS Models.Integer) THEN string := StrInteger;
  3305. ELSIF (model IS Models.Real) THEN string := StrReal;
  3306. ELSIF (model IS Models.Longreal) THEN string := StrLongreal;
  3307. ELSIF (model IS Models.Char) THEN string := StrChar;
  3308. ELSIF (model IS Models.String) THEN string := StrString;
  3309. ELSIF (model IS Models.Set) THEN string := StrSet;
  3310. ELSIF (model IS Models.Text) THEN string := StrText;
  3311. ELSIF (model IS Models.Container) THEN string := StrContainer;
  3312. ELSE string := StrCustom;
  3313. END;
  3314. ASSERT(string # NIL);
  3315. RETURN string;
  3316. END GetModelTypeString;
  3317. PROCEDURE IsComponentProperty(property : WMProperties.Property) : BOOLEAN;
  3318. VAR name : Strings.String;
  3319. BEGIN
  3320. ASSERT(property # NIL);
  3321. name := property.GetName();
  3322. RETURN (name # NIL) & (
  3323. ((name^ = "ID") & (property IS WMProperties.StringProperty)) OR
  3324. ((name^ = "UID") & (property IS WMProperties.StringProperty)) OR
  3325. ((name^ = "Enabled") & (property IS WMProperties.BooleanProperty))
  3326. );
  3327. END IsComponentProperty;
  3328. PROCEDURE IsVisualComponentProperty(property : WMProperties.Property) : BOOLEAN;
  3329. VAR name : Strings.String;
  3330. BEGIN
  3331. ASSERT(property # NIL);
  3332. name := property.GetName();
  3333. RETURN (name # NIL) & (
  3334. ((name^ = "Bounds") & (property IS WMProperties.RectangleProperty)) OR
  3335. ((name^ = "Bearing") & (property IS WMProperties.RectangleProperty)) OR
  3336. ((name ^ = "Alignment") & (property IS WMProperties.Int32Property)) OR
  3337. ((name^ = "FillColor") & (property IS WMProperties.ColorProperty)) OR
  3338. ((name^ = "Visible") & (property IS WMProperties.BooleanProperty)) OR
  3339. ((name^ = "TakesFocus") & (property IS WMProperties.BooleanProperty)) OR
  3340. ((name^ = "NeedsTab") & (property IS WMProperties.BooleanProperty)) OR
  3341. ((name^ = "FocusNext") & (property IS WMProperties.StringProperty)) OR
  3342. ((name^ = "FocusPrevious") & (property IS WMProperties.StringProperty)) OR
  3343. ((name^ = "EditMode") & (property IS WMProperties.BooleanProperty))
  3344. );
  3345. END IsVisualComponentProperty;
  3346. PROCEDURE CountExtendedProperties(component : WMComponents.Component) : LONGINT;
  3347. VAR propertyArray : WMProperties.PropertyArray; nofElements, i : LONGINT;
  3348. BEGIN
  3349. nofElements := 0;
  3350. IF (component # NIL) THEN
  3351. propertyArray := component.properties.Enumerate();
  3352. IF (propertyArray # NIL) THEN
  3353. FOR i := 0 TO LEN(propertyArray) - 1 DO
  3354. IF ~IsComponentProperty(propertyArray[i]) & ~IsVisualComponentProperty(propertyArray[i]) THEN
  3355. INC(nofElements);
  3356. END;
  3357. END;
  3358. END;
  3359. END;
  3360. RETURN nofElements;
  3361. END CountExtendedProperties;
  3362. PROCEDURE CreateLine*() : WMStandardComponents.Panel;
  3363. VAR panel : WMStandardComponents.Panel;
  3364. BEGIN
  3365. NEW(panel); panel.alignment.Set(WMComponents.AlignTop);
  3366. panel.bounds.SetHeight(LineHeight);
  3367. panel.bearing.Set(WMRectangles.MakeRect(LineBearing, LineBearing, LineBearing, LineBearing));
  3368. RETURN panel;
  3369. END CreateLine;
  3370. PROCEDURE CreateLabel*(CONST caption : ARRAY OF CHAR; width, alignment : LONGINT) : WMStandardComponents.Label;
  3371. VAR label : WMStandardComponents.Label;
  3372. BEGIN
  3373. NEW(label); label.alignment.Set(WMComponents.AlignLeft);
  3374. label.caption.SetAOC(caption);
  3375. label.bounds.SetWidth(width);
  3376. label.alignH.Set(alignment);
  3377. RETURN label;
  3378. END CreateLabel;
  3379. PROCEDURE CreateEditor*(width : LONGINT) : WMEditors.TextField;
  3380. VAR editor : WMEditors.TextField;
  3381. BEGIN
  3382. NEW(editor); editor.alignment.Set(WMComponents.AlignLeft);
  3383. editor.bounds.SetWidth(width);
  3384. RETURN editor;
  3385. END CreateEditor;
  3386. PROCEDURE GetPropertyType(property : WMProperties.Property; VAR string : ARRAY OF CHAR);
  3387. BEGIN
  3388. ASSERT(property # NIL);
  3389. IF (property IS WMProperties .BooleanProperty) THEN string := "Boolean";
  3390. ELSIF (property IS WMProperties.Int32Property) THEN string := "Integer";
  3391. ELSIF (property IS WMProperties.StringProperty) THEN string := "String";
  3392. ELSIF (property IS WMProperties.RectangleProperty) THEN string := "Rectangle";
  3393. ELSIF (property IS WMProperties.PointProperty) THEN string := "Point";
  3394. ELSIF (property IS WMProperties.ColorProperty) THEN string := "Color";
  3395. ELSE
  3396. string := "Other";
  3397. END;
  3398. END GetPropertyType;
  3399. PROCEDURE IncCount;
  3400. BEGIN {EXCLUSIVE}
  3401. INC(nofWindows)
  3402. END IncCount;
  3403. PROCEDURE DecCount;
  3404. BEGIN {EXCLUSIVE}
  3405. DEC(nofWindows)
  3406. END DecCount;
  3407. PROCEDURE Cleanup;
  3408. VAR die : KillerMsg;
  3409. msg : WMMessages.Message;
  3410. m : WMWindowManager.WindowManager;
  3411. BEGIN {EXCLUSIVE}
  3412. NEW(die);
  3413. msg.ext := die;
  3414. msg.msgType := WMMessages.MsgExt;
  3415. m := WMWindowManager.GetDefaultManager();
  3416. m.Broadcast(msg);
  3417. AWAIT(nofWindows = 0)
  3418. END Cleanup;
  3419. PROCEDURE InitStrings;
  3420. BEGIN
  3421. StrNoCaption := Strings.NewString("");
  3422. StrNotAvailable := Strings.NewString("<n/a>");
  3423. StrType := Strings.NewString("Type : ");
  3424. StrComponentInfo := Strings.NewString("ComponentInfo");
  3425. StrStandardProperties := Strings.NewString("StandardProperties");
  3426. StrExtendedProperties := Strings.NewString("ExtendedProperties");
  3427. StrExtendedPropertiesView := Strings.NewString("ExtendedPropertiesView");
  3428. StrEventListeners := Strings.NewString("EventListeners");
  3429. StrEventSources := Strings.NewString("EventSources");
  3430. StrBooleanPropertyView := Strings.NewString("BooleanPropertyView");
  3431. StrInt32PropertyView := Strings.NewString("Int32PropertyView");
  3432. StrRealPropertyView := Strings.NewString("RealPropertyView");
  3433. StrRectanglePropertyView := Strings.NewString("RectanglePropertyView");
  3434. StrPointPropertyView := Strings.NewString("PointPropertyView");
  3435. StrStringPropertyView := Strings.NewString("StringPropertyView");
  3436. StrColorPropertyView := Strings.NewString("ColorPropertyView");
  3437. StrFontPropertyView := Strings.NewString("FontPropertyView");
  3438. StrEventSourceView := Strings.NewString("EventSourceView");
  3439. StrEventListenerView := Strings.NewString("EventListenerView");
  3440. StrUnknownPropertyView := Strings.NewString("UnknownPropertyView");
  3441. StrReferencePropertyView := Strings.NewString("ReferencePropertyView");
  3442. StrAlignmentPropertyView := Strings.NewString("AlignmentPropertyView");
  3443. StrModelView := Strings.NewString("ModelView");
  3444. StrBoolean := Strings.NewString("Boolean");
  3445. StrInteger := Strings.NewString("Integer");
  3446. StrBoundedInteger := Strings.NewString("Bounded Integer");
  3447. StrReal := Strings.NewString("Real");
  3448. StrLongreal := Strings.NewString("Longreal");
  3449. StrChar := Strings.NewString("Char");
  3450. StrString := Strings.NewString("String");
  3451. StrSet := Strings.NewString("Set");
  3452. StrText := Strings.NewString("Text");
  3453. StrContainer := Strings.NewString("Container");
  3454. StrCustom := Strings.NewString("Userdefined");
  3455. StrNil := Strings.NewString("NIL");
  3456. StrWindowTitle := Strings.NewString("Reference");
  3457. END InitStrings;
  3458. BEGIN
  3459. nofWindows := 0;
  3460. InitStrings;
  3461. Modules.InstallTermHandler(Cleanup);
  3462. END WMInspectionComponents.
  3463. SystemTools.FreeDownTo WMInspectionComponents ~