Author Topic: PJSR: column width/layout with TreeBox  (Read 4817 times)

Offline kwiechen

  • PixInsight Addict
  • ***
  • Posts: 186
PJSR: column width/layout with TreeBox
« on: 2012 March 11 11:12:41 »
Hi,

I am trying to add OSC support to the CalibrateAlign script. The necessary image meta data is different from mono CCD data and I have tried to switch between sets of FITS keywords using a
checkbox. The TreeBox and column headers display is OK for the first time but when the box is checked or unchecked the column width is not set correctly. The test code is separated because of the length of the script.


// 1 - global vars

var FrameTypeMono = new Array();
FrameTypeMono[Imagetype.BIAS] = ["XBINNING"];
FrameTypeMono[Imagetype.DARK] = ["XBINNING", "EXPTIME"];
FrameTypeMono[Imagetype.FLAT] = ["XBINNING", "FILTER"];
FrameTypeMono[Imagetype.LIGHT] = ["XBINNING", "FILTER"];

var FrameTypeOSC = new Array();
FrameTypeOSC[Imagetype.BIAS] = ["XBINNING"];
FrameTypeOSC[Imagetype.DARK] = ["XBINNING", "EXPTIME"];
FrameTypeOSC[Imagetype.FLAT] = ["XBINNING"];
FrameTypeOSC[Imagetype.LIGHT] = ["XBINNING"];

var FrameType;


// 2 - GUI control

 this.useOSCCheckBox = new CheckBox(this);
 this.useOSCCheckBox.text = "OSC/DSLR support";
 this.useOSCCheckBox.toolTip = "<p>Use OSC/DSLR support</p>";
 this.useOSCCheckBox.onCheck = function(checked)
 {   
  for(var j = 0; j <= Imagetype.LIGHT; ++j)
    this.dialog.clearTab(j);

  if(checked == true)
    FrameType = FrameTypeOSC;
  else
    FrameType = FrameTypeMono;

  this.dialog.refreshTreeBoxes();
 };


// 3 - refresh TreeBoxes

// added for OSC support - (re)calculate table headers
// calculate number of columns and set column headers

for(var i = 0; i <= Imagetype.LIGHT; ++i)
{
   this.dialog.tabBox.pageControlByIndex(i).treeBox.numberOfColumns = FrameType.length;

   for(var j = 0; j < FrameType.length; ++j)
         {
           this.dialog.tabBox.pageControlByIndex(i).treeBox.setHeaderAlignment(j, Align_Left);
            this.dialog.tabBox.pageControlByIndex(i).treeBox.setColumnWidth(j, trim(FrameType[j]).length * 10); // monospace 10 font set
            this.dialog.tabBox.pageControlByIndex(i).treeBox.setHeaderText(j, trim(FrameType[j]));
         }
         this.dialog.tabBox.pageControlByIndex(i).treeBox.setColumnWidth(j + 1, 10 * 20); // 20 characters * 10 font size
         this.dialog.tabBox.pageControlByIndex(i).treeBox.setHeaderText(FrameType.length, "Filename");
}

Best,

Kai

 

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: PJSR: column width/layout with TreeBox
« Reply #1 on: 2012 March 11 11:29:54 »
Did you define additional column at right side? GUI use last column for stretch.
You must show this "stretch" column when you setColumnWidth of other columns in TreeBox.  And you can Hide() "stretch" column after that.

Offline kwiechen

  • PixInsight Addict
  • ***
  • Posts: 186
Re: PJSR: column width/layout with TreeBox
« Reply #2 on: 2012 March 11 11:56:56 »
Thank you very much! This solves the problem.

Best,

Kai