Detecting if plugins are present

I want to add support for plugin custom controls in RubberViews, but want to minimize the fuss for the user. I have just verified I was able to correctly address them and their properties, but my idea is to provide the class as usual, without requiring too much of manipulations from the user.

As it stands, I have found a way to avoid the dreaded “there is no class by that name” upon compile while the class does contain the proper code.

I can have the customer add a constant to the project, say “dtPlugins”, so RubberViews know it can manage these classes. But what would be really nice is if I could detect the plugins at runtime.

At the moment the best I found is to look in the Mac Framework folder of the bundle for the dylib, or in the Windows Lib folder for the DLL. Is this the right way to go or is there another way ?

There isn’t
I’d encourage you to not rely on specific names for control classes if possible.
But I have no idea how you have coded this
Introspection might prove to be a suitable alternative

there is a feedback case for having #if testing for existence of things like plugins or classes.

see case 9018.

I also think it should not be too hard to have a compile time function, which would simply check the identifier list in compiler and decide.

In the mean time, create a constant that the end user can change like

UseMBS as Boolean = False

Then wrap MBS specific code like this

#if UseMBS ...DO SOMETHING SPECIFIC TO MONKEYBREAD... #endif

Thank you both. Actually, I just found the solution : since my class looks at all the controls on the page and knows their class name with Introspection, all I need to do is to set a property when I meet a plugin class.

By definition, I am not the one who should check if the proper plugins are in the plugins folder, but the user is. All I need to do is to make sure to support the custom controls when they are seen.

As long as they are rect controls they have the required height width top & left properties.
What you can’t tell without some kind of hard coded map is whether they are allowed to resize vertically and horizontally.
But thats not unique to plugin controls.

[quote=181807:@Norman Palardy]As long as they are rect controls they have the required height width top & left properties.
What you can’t tell without some kind of hard coded map is whether they are allowed to resize vertically and horizontally.
But thats not unique to plugin controls.[/quote]

Indeed already RubberViews manages all custom controls as Rectcontrol fine.

What I want to do is to also manage the content size like I do for normal controls, TextSize and pictures, eventually RowHeight for grids or other aspects particular to these classes. That is not possible as a rectcontrol, so I need to cast the rectcontrol as the class.
The issue I had is that when the plugin is not present Xojo refuses to compile and says “no class by that name”. I solved that with conditional compilation, so now I can take into account all properties of custom controls.

Now indeed, there are controls that do not resize vertically, most notoriously some Cocoa button styles including the standard Push one. This is already managed.

The next version of RubberViews will be able to manage Einhugur, dtPlugins, MBS at least. That will be a lot of work identifying all the properties, and coding all the casting, since casting has to be hardcoded.

Oh you want to scale the text size in a list box, button, etc ?
Like zooming in.
You could use introspection to get at properties but that might be just as much work
However it can be done without the plugin present.
Casting can’t as that marks the type “used” and if the plugin isn’t there it won’t compile

You might look deeper into introspection for this
It might mean no conditional compilation is required

[quote=181818:@Norman Palardy]Oh you want to scale the text size in a list box, button, etc ?
Like zooming in.[/quote]

Yes. That is what RubberViews does already with regular controls. Text grows as controls grow, same thing for backdrop images, bevelbuttons pictures.

I want to do the same for, say, Einhugur PictureButton.

Well, I guess so far the best bet is what Greg suggested. It allows the class to compile if the plugins are not present, which is what I want.