Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 is currently offline  Klugier
Messages: 628
Registered: September 2012
Location: Poland, Kraków
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


Ultimate++ - one framework to rule them all.

[Updated on: Sun, 03 June 2018 22:48]

Report message to a moderator

Previous Topic: [BUG #1739, + PATCH]ArrayCtrl: in Multiselect mode, WhenSel is called 5 time each cursor change
Next Topic: Click problems in embedded controls in GTK mode
Goto Forum:
  


Current Time: Thu Oct 17 05:51:28 CEST 2019

Total time taken to generate the page: 0.01287 seconds