Hi,

This patch fixes the following problems:

GSToolbarView:
- the generated menus for toolbars were given entries for unlabelled
  standard items: separators, spaces and flexible spaces

NSCell:
- whenever the cell type would change, the _contents ivar would be set
  to @"title". I changed it to do that only when _contents is unset.
  Besides, I was not sure if setting @"title" was very useful but I let
  it that way in case there was a reason. This fixes the case where
  NSToolbar with displayMode set to LabelOnly would redefine the item
  labels to "title".

NSToolbarItem:
- in GSToolbarButton's layout method:
  the size for the cell of labelled toolbar items would take the label
  size into account even when the toolbar display mode was set to
  IconOnly.
- in NSToolbarItem's initWithItemIdentifier: method:
  a double negation in the test on itemIdentifier was causing the item
  never to be reinited to a GSToolbarSeparatorItem.



Wolfgang
-- 
"An eye for an eye only makes the world blind." (Gandhi)
Seulement dans Source/: config.h
diff -u Source.old/GSToolbarView.m Source/GSToolbarView.m
--- Source.old/GSToolbarView.m  2005-01-24 06:25:42.000000000 -0500
+++ Source/GSToolbarView.m      2005-11-30 16:29:19.000000000 -0500
@@ -282,6 +282,7 @@
   NSEnumerator *e;
   id item;
   NSArray *visibleItems;
+  NSString *itId;
   
   AUTORELEASE(menu);
   
@@ -290,15 +291,19 @@
   e = [[_toolbar items] objectEnumerator];
   while ((item = [e nextObject]) != nil)
     {
-      if (![visibleItems containsObject: item])
+      itId = [item itemIdentifier];
+      if (![visibleItems containsObject: item]
+          && !([itId isEqual: NSToolbarSeparatorItemIdentifier]
+               || [itId isEqual: NSToolbarSpaceItemIdentifier]
+               || [itId isEqual: NSToolbarFlexibleSpaceItemIdentifier]))
         {
           id menuItem;
       
-         menuItem = [item menuFormRepresentation];
+          menuItem = [item menuFormRepresentation];
           if (menuItem == nil)
-           menuItem = [item _defaultMenuFormRepresentation];
+            menuItem = [item _defaultMenuFormRepresentation];
            
-         if (menuItem != nil)
+          if (menuItem != nil)
             [menu addItem: menuItem];
         }
     }
Seulement dans Source/: GSToolbarView.m~
Seulement dans Source/: Info-gnustep.plist
diff -u Source.old/NSCell.m Source/NSCell.m
--- Source.old/NSCell.m 2005-02-20 19:59:32.000000000 -0500
+++ Source/NSCell.m     2005-11-30 15:51:45.000000000 -0500
@@ -550,7 +550,8 @@
     {
       case NSTextCellType:
        {
-         ASSIGN (_contents, @"title");
+          if (!_contents)
+            ASSIGN (_contents, @"title");
          _cell.contents_is_attributed_string = NO;
          /* Doc says we have to reset the font too. */
          ASSIGN (_font, [fontClass systemFontOfSize: 0]);
diff -u Source.old/NSToolbarItem.m Source/NSToolbarItem.m
--- Source.old/NSToolbarItem.m  2004-12-30 09:02:00.000000000 -0500
+++ Source/NSToolbarItem.m      2005-11-30 16:43:37.000000000 -0500
@@ -181,37 +181,39 @@
   NSFont *font;
   unsigned int borderMask = [[[_toolbarItem toolbar] _toolbarView] borderMask];
   NSString *label = [_toolbarItem label];
+  NSToolbarDisplayMode displayMode;
   
   // Adjust the layout in accordance with NSToolbarSizeMode
   
   font = NormalFont;
+  displayMode = [[_toolbarItem toolbar] displayMode];
   
   switch ([[_toolbarItem toolbar] sizeMode])
     {
-      case NSToolbarSizeModeDefault:
-       layoutedWidth = ItemBackViewDefaultWidth;
-       layoutedHeight = ItemBackViewDefaultHeight;
-       [[_toolbarItem image] setSize: NSMakeSize(32, 32)];
-       break;
-      case NSToolbarSizeModeRegular:
-        layoutedWidth = ItemBackViewRegularWidth;
-        layoutedHeight = ItemBackViewRegularHeight;
-       [[_toolbarItem image] setSize: NSMakeSize(32, 32)];
-       break;
-      case NSToolbarSizeModeSmall:
-        layoutedWidth = ItemBackViewSmallWidth;
-       layoutedHeight = ItemBackViewSmallHeight;
-       [[_toolbarItem image] setSize: NSMakeSize(24, 24)];
-       /* Not use [self image] here because it can return nil, when image 
-          position is set to NSNoImage. Even if NSToolbarDisplayModeTextOnly 
-          is not true anymore -setImagePosition: is only called below, then 
-          [self image] can still returns nil. */
-       font = SmallFont;
-       break;
-      default:
-       ; // Invalid
+    case NSToolbarSizeModeDefault:
+      layoutedWidth = ItemBackViewDefaultWidth;
+      layoutedHeight = ItemBackViewDefaultHeight;
+      [[_toolbarItem image] setSize: NSMakeSize(32, 32)];
+      break;
+    case NSToolbarSizeModeRegular:
+      layoutedWidth = ItemBackViewRegularWidth;
+      layoutedHeight = ItemBackViewRegularHeight;
+      [[_toolbarItem image] setSize: NSMakeSize(32, 32)];
+      break;
+    case NSToolbarSizeModeSmall:
+      layoutedWidth = ItemBackViewSmallWidth;
+      layoutedHeight = ItemBackViewSmallHeight;
+      [[_toolbarItem image] setSize: NSMakeSize(24, 24)];
+      /* Not use [self image] here because it can return nil, when image 
+         position is set to NSNoImage. Even if NSToolbarDisplayModeTextOnly 
+         is not true anymore -setImagePosition: is only called below, then 
+         [self image] can still returns nil. */
+      font = SmallFont;
+      break;
+    default:
+      ; // Invalid
     }
-    
+
   [[self cell] setFont: font];
   
   // Adjust the layout in accordance with the border
@@ -236,12 +238,13 @@
   attrStr = [[NSAttributedString alloc] initWithString: label attributes: 
attr];
       
   textWidth = [attrStr size].width + 2 * InsetItemTextX;
-  if (layoutedWidth != -1 && textWidth > layoutedWidth) 
-     layoutedWidth = textWidth;
-     
+  if (layoutedWidth != -1 && textWidth > layoutedWidth
+      && displayMode != NSToolbarDisplayModeIconOnly)
+    layoutedWidth = textWidth;
+
   // Adjust the layout in accordance with NSToolbarDisplayMode
   
-  switch ([[_toolbarItem toolbar] displayMode])
+  switch (displayMode)
     {
       case NSToolbarDisplayModeDefault:
         [self setImagePosition: NSImageAbove];
@@ -252,10 +255,11 @@
       case NSToolbarDisplayModeIconOnly:
         [self setImagePosition: NSImageOnly];
         layoutedHeight -= [attrStr size].height + InsetItemTextY;
-       layoutedWidth -= [attrStr size].height + InsetItemTextY;
+       layoutedWidth -= [attrStr size].width + InsetItemTextX;
        break;
       case NSToolbarDisplayModeLabelOnly:
         [self setImagePosition: NSNoImage];
+        layoutedWidth = textWidth;
         layoutedHeight = [attrStr size].height + InsetItemTextY * 2;
        break;
       default:
@@ -266,7 +270,6 @@
   // Set the frame size to use the new layout
   
   [self setFrameSize: NSMakeSize(layoutedWidth, layoutedHeight)];
-   
 }
 
 /*
@@ -1012,14 +1015,14 @@
 {
   GSToolbarButton *button;
   NSButtonCell *cell;
-  
+
   if ((self = [super init]) != nil)
     {   
     
       // GNUstep predefined toolbar items
        
-      if ([itemIdentifier isEqualToString: 
@"NSToolbarSeparatorItemIdentifier"] 
-        && ![self isKindOfClass:[GSToolbarSeparatorItem class]] == NO)
+      if ([itemIdentifier isEqualToString: NSToolbarSeparatorItemIdentifier] 
+        && [self isKindOfClass:[GSToolbarSeparatorItem class]] == NO)
         {
           [self release];
           self = [[GSToolbarSeparatorItem alloc] 
Seulement dans Source/: NSToolbarItem.m~
Seulement dans Source/: obj
Seulement dans Source/: shared_obj
_______________________________________________
Bug-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to