Concept for Custom Container and Control Framework

Looking for some help and knowledge sharing. I am working on a concept for a custom container framework a while now. I am wondering if there is a proven concept in the XOJO universe for the following topics:

  1. Intercommunication between controls
  2. Generalization of Parameters and State of controls
  3. Style/Inspector Object’s

I am aware of some concept’s but was wondering if there are established concepts specific to XOJO (or you may know one from other environments, would be helpful too). As i know some of you working with XOJO for ages, thought i shout the question here.

As a picture often explains easier then words, this will hopefully explain my circumstances for the questions:

Any hint/remark or direction is highly welcome and appreciated, thanks in advance.

You might want to look in the Examples at the Design Patterns projects. The Design Patterns are common things that happen in apps like a user selects something and it notifies any listeners, or sends a command out. There are more than what’s in the directory but I’d say look at those first.

Thanks Bob,
i saw all these design pattern examples and concepts and the different ideas. I found even MVC implementations with XOJO.
My question was less about design patterns but more about an abstraction framework. Sorry if my english is confusing, but let me try to describe what i am looking for:

Just as an example: As all controls have different methods and properties (beside some common ones) the framework should archive a independency between a Listbox, Grid or ComboBox, like the MVC concept. Does that makes sense?

This depends on what you want to do and how complicated your framework is going to become. You can subclass all UI controls. And then define the communication between those controls.

In practice I haven’t used this very much. I’ve got a database application. The controls are subclassed to get the data from the database. Then I handle the extra communication that the controls need via event raising in the window where the controls live. So far this worked pretty well.


Grüße nach Frankfurt.

Beatrix (Guten morgen und Grüße nach Heidesheim),
thx for your Feedback.

That’s exactly how i add new controls to the framework and implement the interface to them.

Currently i use predefined events in the superclass, match and fire them by the subclass and use AddHandler/Delegates/Introspection in the framework itself. Seems that’s the normal and common way in xoxo.

Here you go, that’s exactly the point i try to address. To be more precise: In my case it’s not a database but some C++ dylib’s with a C wrapper, XML Streams and files the controls interact with or display data from. I have different App’s for a typical Client/Server scenario, some fronted app’s just need to use other GUI elements for the same kind of data or situation. I was just wondering if there is a common concept to abstract the ‘extra communication’ which is typically developed in the window the control lives in.

I used Paul’s example of the Observer Pattern to do update fields from a database which sounds similar. Here’s a video and example file.

There is nothing common that I’ve seen.

MVC can be done in Xojo but most do not do it because the event model combines the View and Controller into a convenient package. MVC tends to be more work in Xojo, in my opinion, than it’s worth since you end up duplicating a lot of stuff but if you’re comfortable with MVC there’s nothing stopping you.

You might want to look at Interfaces because they are a way to create common interfaces between wildly disparate objects. If your model requires all of the controls to have Load, Save, Validate methods you could put those in the subclass but then you have the issue that they’re all separate classes. If, however, you add an interface to all your subclasses they are all of the same interface class and life becomes easier in some respects.

Bob, you just confirmed my observations. Thx!

With using Subclassing and Interfaces the whole approach would be a nightmare, i also use the Observer pattern but via TCP and IPC for App to App communication and to keep Thread’s clean.

Observer’s are just a Dictionary with Instances of Objects and a kind of message bus (select case) with event or message calls. Delegates can be helpful there as well. I was looking for a generic ‘common’ way /framework) how this messages can carry a bit more than just a ‘switch’ and what is a ‘common’ way of creating a Superclass who is in charge for the heavy lifting. Basically you need to wrap each object in something generic. Currently i use ContainerControl’s to wrap RectControl’s and a BaseClass for own classes. That’s a bit of work and i was wondering if there was a better approach.