Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reconciling Properties Concept to Fields Concept
Message
De
15/02/2006 10:40:57
 
 
À
15/02/2006 04:14:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01096402
Message ID:
01096473
Vues:
9
Hello, Olaf!

Thank you for the reply. I was using "field" in the OO sense. Data members have been referred to in a variety of ways over the years.

You're reply was most helpful--it sparked an idea. I think I'm going to encapsulate the properties in the following mannger:
Define Class SOME_CLASS As CUSTOM

   Hidden ui_context
      ui_context = .null.

   Protected title_bar_region
      title_bar_region = .null.

   Procedure init
      Lparameters p_ui_context

      *!* This assertion guarantees that a ui_context exists and the type of the ui_context conforms to CONTAINER
      Assert Parameters()=1
      Assert Inlist(p_ui_context.Class, 'grid', 'container', ...) Message 'Supplied ;
         ui_context does not conform to type CONTAINER.'
      Assert Inlist(p_ui_context.ParentClass, 'grid', 'container', ...) Message 'Supplied ; 
         ui_context does not conform to type CONTAINER.'

      This.ui_context = p_ui_context
      This.ui_context.AddObject('vo_title_bar_region', 'CONTAINER')

      This.title_bar_region = CreateObject('EMPTY')
      With this.title_bar_region
         .AddProperty('back_color', This.vo_title_bar_region.BackColor)
         .AddProperty('back_style', This.vo_title_bar_region.BackStyle)
      Endwith
   Endproc

EndDefine 
I stopped at two properties in the EMPTY class. In practice, there will be many more. This would allow me to expose only those properties of the visual object that I wish to expose, and at the same time control the visibility of those properties. Since ui_context is hidden, so are all of its contained visual objects, so the consumer of my class wouldn't be able to directly manipulate those objects. If only VFP allowed methods and events in the EMPTY class, a lot of problems would be solved.

Does the code above make sense? A ui_context is passed, which must conform to type CONTAINER, which is then hidden. A visual object named vo_title_bar_region is added to it. A properties "container" is created, called title_bar_region, which contains properties that point to those of the visual object. This properties container is protected, so it has visibility to base classes (it could just as easily be public if you wanted to expose the properties directly to the consumer in a concrete class). Since ui_context is hidden, there's no way to set the properties of its contained objects directly: ui_context.vo_title_bar_region.BackColor = 0 would be forbidden in the consumer and in base classes. You would have to use this.title_bar_region.back_color = 0.

Would this be considered appropriate technique in VFP?

Thanks.

Eric
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform