|
|
Home » Developing U++ » U++ Developers corner » Know what you're using. Size of some common types.
Re: Know what you're using. Size of some common types. [message #57996 is a reply to message #57995] |
Tue, 11 January 2022 22:07   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
If ArrayCtrl limits children to Fake Ctrls only, SyncLineCtrls etc will be dispensible.
Back to Buttons, some chain of thoughts. Instead of inheriting from Ctrl, it should be leave as an interface (no data members); concrete Ctrls will decide whether to inherit from Ctrl, ArrayCtrl, EditField or other Ctrl derivatives and implementing the interface to use the Ctrl's Paint & other virtual functions to fake out Buttons.
This will add a cost of sizeof(void *) (pointer to interface vtbl) to each object of Classes that implement the interface. Why not add the interface (a set of virtual functions) to Ctrl directly to save this vtble pointer?
class Ctrl : public ...
{
public:
virtual void Paint(Draw& w)
{
for(int i = 0; i < GetFakeCtrlsCount(); ++i)
{
Rect r=GetFakeCtrlsRect(i);
w.Clipoff(r);
PaintFakeCtrls(w, i);
w.End();
}
}
virtual void LeftDown(Point p, dword flag)
{
for(int i = 0; i < GetFakeCtrlsCount(); ++i)
{
Rect r=GetFakeCtrlsRect(i);
if( MouseInRect(r) )
{
p.x -= r.left; p.y -= r.top;
FakeCtrlsLeftDown(p, flag, i);
break;
}
}
}
...
// added to support fake Ctrls
virtual int GetFakeCtrlsCount()const{ return 0; }
virtual void PaintFakeCtrls(Draw& w, int index){}
virtual void FakeCtrlsLeftDown(Point p, dword flag, int index){}
... and some more virtual function of Ctrl with an extra parameter index.
};
This way we don't explicitly limit the type of fake Ctrls (Not even by a non-restrictive but suggestive name "Buttons"). It's totally up to each derivative that actually implements the interface to decide what Ctrls it wants to fake.
------------
PS: instead of repeatedly calling multiple virtual functions to Paint each fake Ctrl, it make sense to instead
class Ctrl: ...
{
public:
...
virtual void PaintFakeCtrls(Draw& w);
...
Then the PaintFakeCtrls() will be quite like ScollBar::Paint(). I don't know, let's see how you do it clearly and efficiently.
[Updated on: Tue, 11 January 2022 22:46] Report message to a moderator
|
|
|
 |
|
Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 19:33
|
 |
|
Re: Know what you're using. Size of some common types.
By: Klugier on Mon, 27 December 2021 19:58
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 20:32
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 20:37
|
 |
|
Re: Know what you're using. Size of some common types.
By: Klugier on Mon, 27 December 2021 21:42
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 28 December 2021 02:29
|
 |
|
Re: Know what you're using. Size of some common types.
By: Novo on Tue, 28 December 2021 05:17
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 28 December 2021 20:27
|
 |
|
Re: Know what you're using. Size of some common types.
By: Novo on Tue, 28 December 2021 23:49
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Wed, 29 December 2021 01:42
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Thu, 30 December 2021 02:39
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 19:51
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 20:20
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 20:28
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Wed, 05 January 2022 10:47
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 17:25
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 17:44
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 18:34
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 19:01
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 19:26
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 22:22
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Sun, 09 January 2022 20:36
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Mon, 10 January 2022 01:07
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 10 January 2022 02:00
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 10 January 2022 21:43
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 02:29
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Tue, 11 January 2022 13:41
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 15:19
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 17:40
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 22:07
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 22:25
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Wed, 11 May 2022 09:42
|
 |
|
Re: Know what you're using. Size of some common types.
By: Novo on Thu, 12 May 2022 08:26
|
 |
|
Re: Know what you're using. Size of some common types.
By: Lance on Sat, 14 May 2022 21:30
|
 |
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 18:32
|
Goto Forum:
Current Time: Wed Jul 02 17:19:34 CEST 2025
Total time taken to generate the page: 0.03982 seconds
|
|
|