Hi,

What is the recommended way to determine the optimal size of the subviews
of a window, and of the window containing the subviews, in a GNUstep GUI?
For the Java aware: What is the equivalent of java.awt.LayoutManager?

I'm asking because I'm writing a sample hello-world that demonstrates
the internationalization features of GNU gettext in the context of GNUstep,
and code like the one below with absolute positioning of labels doesn't
work if the translation of a string is larger/longer than the English
original: The size of the label has to adapt, and the size of the window
too.

Bruno


===============================================================================
- (void)createUI
{
  NSView *cview;

  window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0,0,400,70)
                             styleMask: (NSTitledWindowMask | NSClosableWindowMask | 
NSMiniaturizableWindowMask)
                             backing: NSBackingStoreBuffered
                             defer: NO];
  [window setDelegate: self];
  [window setTitle: @"Hello example"];
  [window setMinSize: NSMakeSize(400,70)];
  [window setReleasedWhenClosed: NO];
  cview = [window contentView];
  
  label1 = [[NSTextField alloc] initWithFrame: NSMakeRect(10,51,380,21)];
  [label1 setStringValue: _(@"Hello, world!")];
  [label1 setAlignment: NSLeftTextAlignment];
  [label1 setBordered: NO];
  [label1 setEditable: NO];
  [label1 setBezeled: NO];
  [label1 setDrawsBackground: NO];
  [cview addSubview: label1];
  AUTORELEASE (label1);

  label2 = [[NSTextField alloc] initWithFrame: NSMakeRect(10,28,380,21)];
  [label2 setStringValue: [NSString stringWithFormat: _(@"This program is running as 
process number %d."), [[NSProcessInfo processInfo] processIdentifier]]];
  [label2 setAlignment: NSLeftTextAlignment];
  [label2 setBordered: NO];
  [label2 setEditable: NO];
  [label2 setBezeled: NO];
  [label2 setDrawsBackground: NO];
  [cview addSubview: label2];
  AUTORELEASE (label2);

  okButton = [[NSButton alloc] initWithFrame: NSMakeRect(300,4,60,22)];
  [okButton setTitle: @"OK"];
  [okButton setTarget: self];
  [okButton setAction: @selector(done)];
  [cview addSubview: okButton];
  AUTORELEASE (okButton);
}



_______________________________________________
Help-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-gnustep

Reply via email to