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 » 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 Go to previous messageGo to previous message
Lance is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [SOLVED][Question] Is anyone able to build UPP and Binaries based upon it as 32-Bit?
Next Topic: Source Code Efficiency Minor Issue
Goto Forum:
  


Current Time: Wed Jul 02 17:19:34 CEST 2025

Total time taken to generate the page: 0.03982 seconds