Recent

Author Topic: Is there a Bitfield control?  (Read 2398 times)

CM630

  • Hero Member
  • *****
  • Posts: 1076
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Is there a Bitfield control?
« on: April 20, 2018, 10:56:53 am »
I need a bitfield control/indicator.
What I need is to display a row of buttons/labels, so after clicking some of them they will convert indication to a number. Or when mouse is over any of them it could show a hint like "LE xx; BE yy".
Doing this should not be a hard task, but maybe someone has done and published it already?
Лазар 3,0 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

Zoran

  • Hero Member
  • *****
  • Posts: 1824
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Is there a Bitfield control?
« Reply #1 on: April 20, 2018, 12:12:35 pm »
I need a bitfield control/indicator.
What I need is to display a row of buttons/labels, so after clicking some of them they will convert indication to a number. Or when mouse is over any of them it could show a hint like "LE xx; BE yy".
Doing this should not be a hard task, but maybe someone has done and published it already?


What indication? What is this "indication" which you want to convert to a number?

CM630

  • Hero Member
  • *****
  • Posts: 1076
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Is there a Bitfield control?
« Reply #2 on: April 20, 2018, 12:54:10 pm »
Currently I only need indication.
But a control is also welcome.
Лазар 3,0 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:

Zoran

  • Hero Member
  • *****
  • Posts: 1824
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Is there a Bitfield control?
« Reply #4 on: April 20, 2018, 03:33:38 pm »
Currently I only need indication.
But a control is also welcome.

I still don't get it. You say you want indication, but indication of what?
As you said in your first post, there is something which you want to convert to number, right? What? You mention some labels or buttons, but from what you said, I still have no idea what you want to do with them.

Probably it's just me, perhaps others understand what you are talking about and can help...

You say:
Or when mouse is over any of them it could show a hint like "LE xx; BE yy".
Should the hint describe some byte? Which byte? What is LE, BE? Do you mean LO, HI? See the attached project, is this like something you ask for?

CM630

  • Hero Member
  • *****
  • Posts: 1076
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Is there a Bitfield control?
« Reply #5 on: April 21, 2018, 07:41:13 pm »

Roughly that is it:


Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   BitIndex: integer;
  4.   Labels: array of TLabel;
  5.   Value: QWord;
  6. begin
  7.   Value:=124132890341;
  8.   SetLength(Labels,64);
  9.   for BitIndex:=0 to high(Labels) do
  10.   begin
  11.      Labels[BitIndex]:= TLabel.Create(Self) ;
  12.      Labels[BitIndex].Parent:=Self;
  13.      Labels[BitIndex].Width:=10;
  14.      Labels[BitIndex].Top:=4;
  15.      Labels[BitIndex].ShowHint:=True;
  16.      Labels[BitIndex].Hint:='BitIndex =' + IntToStr(BitIndex) ;
  17.      if BitIndex=0
  18.        then Labels[bitindex].left:=4
  19.        else if (bitindex) mod 8 = 0
  20.             then Labels[BitIndex].Left:=Labels[BitIndex-1].BoundsRect.Right+6
  21.             else if (bitindex) mod 4 = 0
  22.                  then Labels[BitIndex].Left:=Labels[BitIndex-1].BoundsRect.Right+3
  23.                  else Labels[BitIndex].Left:=Labels[BitIndex-1].BoundsRect.Right+1;
  24.  
  25.  
  26.      if GetBit(value,bitindex) then Labels[BitIndex].Caption:='1' else  Labels[BitIndex].Caption:='0'; //This line is just to show the idea, calculation is wrong
  27.   end; //for BitIndex
  28. end;  
Лазар 3,0 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: Is there a Bitfield control?
« Reply #6 on: April 21, 2018, 07:59:38 pm »
Ah, now I see.... .

 101 binary bit display.., I suppose you want it active too?

 Is there any cookies and milk in it for me If I do it ?
The only true wisdom is knowing you know nothing

CM630

  • Hero Member
  • *****
  • Posts: 1076
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Is there a Bitfield control?
« Reply #7 on: April 21, 2018, 08:08:10 pm »
Thanks for the proposal, but no cookies, no milk.
If it is not done yet I will do it myself ;)
My idea was to reuse if available.
Лазар 3,0 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: Is there a Bitfield control?
« Reply #8 on: April 21, 2018, 08:13:33 pm »
you may want to look at the TFlowPanel control

 It kind of takes care of the house keeping for you..
 Or use a TDrawGrid...

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018