Ok. Now I see. A NSTextField is more than a label, is suitable of an IupText.
So you have to configure it so it will behave like a label, with no borders, no margins. Actually margins in a IupLabel is handle by the PADDING attribute, but the default value is "0x0". When that is fixed the size will be right, no need for sizeToFit. Font metrics is essential in IUP layout computation. The iup*_font.c module is one of the most important driver module. Without iupdrvFontGetStringWidth, iupdrvFontGetCharSize, and iupdrvFontGetMultiLineStringSize IUP will simply not work. The dialog layout is automatically calculated, you just have to implement the drivers methods. Best, Scuri On Wed, Aug 12, 2015 at 10:33 AM, Eric Wing <ewmail...@gmail.com> wrote: > On 8/11/15, Antonio Scuri <sc...@tecgraf.puc-rio.br> wrote: > > It seems that the font module is not returning the correct size for the > > text. The iup*_font.c module is essential for a correct layout. Try > > different FONT attributes to see how this size difference behaves. > > > > I have something that is starting to work, but feels like I have an > impedance mismatch. The 2010 code I was trying to get working did a > lot to manually calculate font metrics based on raw strings. I fixed > it up so it could compile and run, but in a real world use case where > I'm trying to draw an IupLabel (which is a non-editable NSTextField in > Cocoa), the raw font metrics don't account for the extra margins > expected to support the NSTextField so the region was too small and > got clipped. > > My solution is to not compute the raw font metrics but use a > 'sizeToFit' which resizes the widget to the smallest possible value > that still fits everything, and then return that resulting dimension. > This technique will work with most Cocoa widgets, and seems to work > okay in my basic cases so far. However, I'm a little concerned that > this is not what Iup really expects. > > (I also have a secondary problem that there is an API for a default > system font (with size). But I noticed that the default system font > for Cocoa is point size 13, but the default NSTextField font is size > 12 and the code seems to imply these are expected to be the same.) > > > > Anyway, moving forward to the next item, can you explain how the > IupDialog sets its initial size to fit the contents? Right now I have > a hardcoded window size so when it first gets created/displayed, it is > the wrong size. > > > Thanks, > Eric > > > ------------------------------------------------------------------------------ > _______________________________________________ > Iup-users mailing list > Iup-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/iup-users > >
------------------------------------------------------------------------------
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users