09-23-2005 10:03 AM
Solved! Go to Solution.
09-23-2005 03:11 PM
09-26-2005 04:11 AM
09-26-2005 11:06 AM
Petri,
A metafont is a font that has all of its attributes specified: a typeface, a size, and properties such as bold, italics, etc. The GetTextDisplaySize requires a metafont, so that it can tell you how much space a string requires, based on all of the characteristics of a font, especially the point size.
What you have to do is to "ask" the table for all those characteristics -- not just the font name, but the size, the italics, etc... there is one attribute for each of those characteristics. Once you have all of those values, you should create your own metafont by passing them to the CreateMetaFont function -- name the metafont whatever you like -- and then pass this new name to the GetTextDisplaySize function.
Hope this helps.
Luis
NI
10-15-2009 02:26 AM
I forget to say thanks.
I had to modify this old project for other reasons and therefore I tried to improve this source because it never worked perfectly when resizing the table columns...
I attach a sample project which shows how the column width is set for all columns, but still the last column is out of the table boundaries. What goes wrong ?
/petri
10-16-2009 02:10 PM
Petri,
The table width includes the "zero-th" column where you had labeled "Antenna Input", "f[MHz]",
"Channel ID", and "BER". If you count this column, there are actually 11 columns in your table.
However, the function GetNumTableColumns(summary, SUMMARY_SUMMARYTABLE, &cols)
only returns 10 to the variable "cols". Just modify "(width-maxLabelWidth-35)/cols" and
change it to "(width-maxLabelWidth-35)/(cols+1)". It'll solve your problem.
10-19-2009 03:42 AM
thanks!
I changed according to your advise and even removed the constant, with other words to '(width-maxLabelWidth)/(cols+1)'. It seems that still the table has somekind of automatic mechanism to adjust itself. If the number of columns is such a few, e.g. 3, the width of the columns will not fill the whole table width area. I can't know the number of columns in forhand, but it's better now than before...
The same applies for the height of the rows. I'm wondering why the command SetTableRowAttribute (summary, SUMMARY_SUMMARYTABLE, -1, ATTR_ROW_HEIGHT, (height/rows)); will not fulfill the whole heigth of the area...
regards,
petri
10-19-2009 04:24 PM
I wonder myesef, too.
Hope someone from NI can asnser this question.......
10-21-2009 02:44 PM
Hi Petri,
The mistake you're making is in assuming that the width of the row label column is equivalent to the width of the widest row label string. The width of this column, in your program, has a fixed size which is set in the .uir file and is not affected by the text labels that you are using.
You also need to take into account the scroll bar width and the frame width. There is no attribute that returns the frame width, but for this style of table, you can hardcode it to 6 (3 for the left edge + 3 for the right edge).
This code should get you a lot closer:
if (cols>0)
{
GetCtrlAttribute (summary, SUMMARY_SUMMARYTABLE, ATTR_ROW_LABELS_WIDTH, &rowLabelsWidth);
GetCtrlAttribute (summary, SUMMARY_SUMMARYTABLE, ATTR_SCROLL_BAR_SIZE, &sbSize);
SetTableColumnAttribute (summary, SUMMARY_SUMMARYTABLE,
-1, ATTR_COLUMN_WIDTH, (width-rowLabelsWidth-sbSize-6)/cols);
}
The reason I said "closer" is because you will most likely not get an exact match. The reason is because (width-rowLabelsWidth-sbSize-6) is probably not a nice multiple of cols and therefore, the division will create a truncation error which will result in a gap.
Fortunately, there's a much simpler solution for what you want to do, as long as you're willing to size the table to match the column widths, rather than size the column widths to size the table. Use the function call below, either instead of the code above, or following the code above (if you still want to adjust the column width, and then remove the round-off error):
SetCtrlAttribute (summary, SUMMARY_SUMMARYTABLE, ATTR_NUM_VISIBLE_COLUMNS, cols);
You can also do this in the User Interface Editor instead:
Edit Table>>Size/Scroll Options
Hope this helps.
Luis
10-22-2009 09:18 AM
thanks Luis!
that helped me with the width of the columns. those attributes were new for me... I want to resize the columns to static table area.
what would be the reason why heights of the rows are not fulfilling the table height area ?
regards,
petri