Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Display API for ArrayCtrl is too difficult - too much parameters
Display API for ArrayCtrl is too difficult - too much parameters [message #49905] |
Sun, 03 June 2018 22:45 |
 |
Klugier
Messages: 1099 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello,
I just noticed that Display API of CtrlLib is difficult. The main reason for that is that we have six parameters. It is a lot considering the fact that well designed method/function should have maximum three parameters. The other problem with that method is that you need to split it to maintain readability. This is not good also for the general code clearness.
So, my proposition looks like this. We replace following construction:
struct FolderDisplay : public Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
};
Can be replaced with:
struct FolderDisplay : public Display {
void Paint(DisplayPaintCtx& ctx) const override {
// ctx.GetDraw() or ctx.draw...
// ctx.GetRect() or ctx.rect...
// ctx.GetValue() or ctx.value... (v is too general for an outsider)
// etc...
// You do not need to extract all values for example style is not used in 90% of cases.
}
// The above method is super easy to override, the same as overriding Draw method in Ctrl...
};
Sincerely,
Klugier
U++ - one framework to rule them all.
[Updated on: Sun, 03 June 2018 22:48] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 25 12:37:17 CEST 2025
Total time taken to generate the page: 0.03007 seconds
|