Author Topic: PCL CheckBox.Width() == wrong width  (Read 3300 times)

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
PCL CheckBox.Width() == wrong width
« on: 2012 January 17 21:32:10 »
Hi Juan,
Add to SandBox one code:
Code: [Select]
Console().WriteLn( String( ParameterThree_CheckBox.Width() ) );
I see result in Console "640".
It's bug or not? And how to get real size of CheckBox ?

Best regards,
Nikolay.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PCL CheckBox.Width() == wrong width
« Reply #1 on: 2012 January 18 09:36:11 »
Hi Nikolay,

Quote
how to get real size of CheckBox ?

If you refer to the size of the checkbox square, the answer is "you cannot". The size of a control is style- and platform-dependent; there is no (portable) way to predict it.

The 640 pixels reported probably refer to a CheckBox control that has been stretched into a Sizer, and if the control has a nonempty Text() property then the reported Width() includes it. There is no bug AFAIK.

What are you exactly trying to do (something nonportable, I guess!) ?
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: PCL CheckBox.Width() == wrong width
« Reply #2 on: 2012 January 22 03:20:25 »
What are you exactly trying to do (something nonportable, I guess!) ?
I want add to GUI a CheckBox to NumericControl. Between Label and NumericEdit.
Best regards,
Nikolay.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PCL CheckBox.Width() == wrong width
« Reply #3 on: 2012 January 26 00:06:19 »
Quote
add to GUI a CheckBox to NumericControl. Between Label and NumericEdit

Define a CheckBox control with an empty Text() (it is already empty by default) and insert it at the right place in NumericControl::sizer. That should work reasonably well on all platforms, but cross your fingers to have it working properly on Mac OS X:

NumericControl foo;
CheckBox bar;
foo.sizer.Insert( 1, bar ); // index one is between label and edit

If instead of NumericControl it were NumericEdit, an additional stretching space woud be required at the end of NumericEdit::sizer:

NumericEdit foo;
CheckBox bar;
foo.sizer.Insert( 1, bar ); // index one is between label and edit
foo.sizer.AddStretch(); // force CheckBox to occupy the minimum possible space

In the case of NumericControl this isn't necessary because NumericControl::slider already has a 100% stretching factor.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: PCL CheckBox.Width() == wrong width
« Reply #4 on: 2012 January 26 00:38:46 »
Thanks!