Changeset 1327

Show
Ignore:
Timestamp:
05/23/04 16:13:44 (5 years ago)
Author:
morris
Message:

box has to exceed current size by at least 50% if we are to make a new line

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/NSTextFieldAdditions.m

    r1320 r1327  
    1 /* $Id: NSTextFieldAdditions.m,v 1.6 2004/05/23 13:33:29 morris Exp $ */ 
     1/* $Id: NSTextFieldAdditions.m,v 1.7 2004/05/23 14:13:44 morris Exp $ */ 
    22 
    33/* 
     
    3535        NSRect          rect, controlRect; 
    3636        NSSize          size; 
    37         int                     width, height, factor
     37        int                     width, height, factor = 1
    3838         
    3939        // --- default offset 
     
    4141                *offset = 18; 
    4242         
    43         // --- set frame of self 
     43        // --- get string bounding box 
    4444        rect = [self frame]; 
    4545        size = [[self font] sizeOfString:[self stringValue]]; 
    46         width = (int) (size.width / rect.size.width) + 1; 
    47         height = (int) (size.height / rect.size.height) + 1; 
    48         factor = width > height ? width : height; 
    4946         
     47        // --- has to exceed current size by at least 50% if we are to make a new line 
     48        if(size.width >= 1.5 * rect.size.width || 
     49           size.height >= 1.5 * rect.size.height) { 
     50                width = (int) (size.width / rect.size.width) + 1; 
     51                height = (int) (size.height / rect.size.height) + 1; 
     52                factor = width > height ? width : height; 
     53        } 
     54         
     55        // --- set frame of self 
    5056        rect.origin.y = *offset + 2; 
    5157        rect.size.height *= factor;