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 #57988 is a reply to message #57987] Mon, 10 January 2022 02:00 Go to previous messageGo to previous message
Lance is currently offline  Lance
Messages: 527
Registered: March 2007
Contributor
Great. For WithSpin<> which in turn contains SpinButtons, this can roughly reduce the object size by 2*sizeof(Button) - sizeof(Ctrl). That's a great achievement with minimal impact on existing code. It will just work.(Well, SpinButtons exposed Button inc, dec; but it should not be referenced much except in the library implementation anyways).

And it's a generic solution. No matter how many buttons it fakes, it will take up room of only sizeof(Ctrl).

For WithSpin in particular, another route I was considering (I am not versed with Upp enough to know whether it will work) is to start from EditField. Basically add 2 bitfield bool
class EditField:....
{
....
public:
      void Paint(Draw& d)override{
           PaintSpinButtons();
           DoOriginalEditFieldPaintOnReducedSize();
      }
      void LeftDown(Point p, dword f)override{
           if(p not in SpinPart)
                Parent::LeftDown(p,f);
           else if(p in UpperPart of Spin)
                WhenSpin(false);
           else// (p in LowerPart of Spin)
                WhenSpin(true);
      }
      void LeftRepeat(Point p, dword f)override{
           LeftDown(p,f);
      }
      Image CursorImage(Point p, dword)override{
          // Image according to part of the Ctrl
      }
      //... maybe more to be override'd or rewrite to take care of Fake SpinButton part.

      Event<bool> WhenSpin;
private:
      bool with_spin : 1;
      bool spin_visible : 1;

      Size GetReducedSize(){
            Size sz=GetSize(); 
            if(with_spin && spin_visible)
                 reduce_size_to_leave_room_for_spin_buttons(sz);
     }
}


Then in actual types(EditIntWithSpin, EditInt64WithSpin, etc) that needs SpinButtons, we just turn the flags on in respective constructors, and connect to WhenSpin event.


I am not sure if we claim part of EditField as Frame without actully AddFrame, etc, will work as wished.

If you figure this route is worth considering, I can do a preliminary implementation. Otherwise (if you prefer the more normal Buttons route), I will wait and see. Razz

[Updated on: Mon, 10 January 2022 02:29]

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: Sat May 04 00:52:52 CEST 2024

Total time taken to generate the page: 0.02021 seconds