Forum > LCL

TWSButton descendance

<< < (2/2)

Martin_fr:
I do say however it should probably be renamed to TWSCustomButton, and then there needs to be no TWSButton.

After all, it is registered by/for the TCustomButton

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function RegisterCustomButton: Boolean; alias : 'WSRegisterCustomButton';begin  RegisterWSComponent(TCustomButton, TWin32WSButton);  Result := True;end; 
Whereas TButton itself does not register anything. So no need for a TWsButton.

lagprogramming:

--- Quote from: Martin_fr on December 08, 2023, 12:54:13 pm ---The question is, does it cause a problem? And if so, what problem.

--- End quote ---
The point is to have a single idiom, if possible. It's hard to learn and especially to debug something big as the LCL when objects that should behave similar have unnecessary different code implementations. In this example, using linux-customdrawn, I put a button on a form and a bitbtn. The TButton doesn't show it's caption, the TBitbtn shows it. I look at the code to see what's different at TButton in comparison with TBitbtn. After seeing what code looks simmilar and what's different I start having additional questions. So I compare the code of the buttons with the code of other objects that work fine and I start noticing some idioms. I learn from those idioms but because TWSButton is not a descendant of TWSCustombutton, the code looks a bit different so I start having additional questions. These additional questions can be avoided if a single idiom would have been used. In this particular example, if TWSButton would have been a descendant of TWSCustomButton, because it would follow the same idiom used when implementing objects like TWSCheckBox(which is a descendant of TWSCustomCheckBox), TWSEdit(which is a descendant of TWSCustomEdit) or TWSMemo(which is a descendant of TWSCustomMemo).
Anyway, I'll present a patch for fixing the TButton caption in a different forum post, patch that would modify as little code as possible.

Marc:

--- Quote from: Martin_fr on December 08, 2023, 12:54:13 pm ---
But in the TWS.... classes, there is no such thing as publishing properties. (there is published, but not sure why... where it is used / there should be no need to un-publish).


--- End quote ---

IIRC,
At runtime the class hierarchy of the WS classes is modified. The specific WS implementation classes are inserted in the hierarchy. To be able to do this, virtual methods need to be resolved. RTTI is needed for that and is only available for published members.

NOTE: This mechanism is made before the fpc 1.0 times.  If at that time interfaces would have worked reliable, I would have used that.

Navigation

[0] Message Index

[*] Previous page

Go to full version