discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Two gui changes


From: Andreas Höschler
Subject: Two gui changes
Date: Wed, 14 Nov 2007 22:29:25 +0100

Hi all,

I modified gui as follows today:

The following change to NSAlert.m inserts linefeeds if a message is too long to fit into one row.

NSAlert.m:
==========
NSRunAlertPanel(
  NSString *title,
  NSString *msg,
  NSString *defaultButton,
  NSString *alternateButton,
  NSString *otherButton, ...)
{
...
        if ([message length] > 50)
    {
     NSArray *words = [message componentsSeparatedByString:@" "];
     NSMutableArray *lines = [NSMutableArray array];
     NSMutableString *line = [NSMutableString string];
     NSEnumerator *enumerator = [words objectEnumerator];
     NSString *word;
     while (word = [enumerator nextObject])
       {
        if ([line length] > 0) [line appendString:@" "];
        [line appendString:word];
        if ([line length] > 50)
          {
           [lines addObject:line];
           line = [NSMutableString string];
          }
       }
     if ([line length] > 0)
       {
        [lines addObject:line];
       }
     message = [lines componentsJoinedByString:@"\n"];
    }
...
}


This NSAssert killed a presentation today! :-( My application died with an uncaught exception while trying to show a message with NSRunAlterPanel. What is this NSAssert good for?

NSView:
========
- (NSRect) convertRect: (NSRect)aRect toView: (NSView*)aView
{
  NSAffineTransform *matrix1, *matrix2;

  if (aView == nil)
    {
      aView = [[_window contentView] superview];
    }
  if (aView == self || aView == nil)
    {
      return aRect;
    }
// NSAssert(_window == [aView window], NSInvalidArgumentException); // <------ what is this good for?

  if (_coordinates_valid)
    {
      matrix1 = _matrixToWindow;
    }
  else
    {
      matrix1 = [self _matrixToWindow];
    }

  matrix2 = [aView _matrixFromWindow];

  return convert_rect_using_matrices(aRect, matrix1, matrix2);
}

Regards,

  Andreas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]