ChrisS85 / CGUI

An object-oriented GUI library for AutoHotkey
22 stars 19 forks source link

Register control classes #51

Closed maul-esel closed 12 years ago

maul-esel commented 12 years ago

Instead of relying on a control class' name (inflexible) and hardcoding classes which implement several controls (even more inflexible), control classes are now registered:

CGUI provides a (static) RegisterControl(name, class) method which adds name and class to an object. AddControl() then checks that object for the class corresponding to the requested control type.

This allows:

The RegisterControl() method is now called by the control classes from a static field initialization, but could theoretically be called at any point - from which on the control type is immediately available to the user.

ChrisS85 commented 12 years ago

Good idea. I'm not sure if references to the controls are the best option or if the class names should be used instead. I don't think it causes any particular issue right now, but I'm a bit concerned with circular links breaking reference counting.

maul-esel commented 12 years ago

I had the same thought, which was why I changed it to use a method instead of object-access as in the first commit. I thought it might be better that way however, as it allows a larger variety: one could use any object, probably dynamically created, or an instance of a class.

However, if you think it should be changed, this wouldn't be a problem to me.

maul-esel commented 12 years ago

So should I change it?

ChrisS85 commented 12 years ago

Should be good I think.