Oups, and here are the attached files

Le 29/04/2019 à 10:39, Bertrand Dekoninck a écrit :
Hi, everyone on the list.

I'm facing an issue here and I don't find a solution.

I have a warning compiling the class RikScrollerArrowCell from the rik theme. I've got two warnings that causes an error with gcc (without libobjc2) but only one warning and no error with clang+libobjc2.

Here are the build logs :

with gcc :

RikScrollerArrowCell.m: In function ‘-[RikScrollerArrowCell drawBezelWithFrame:inView:]’: RikScrollerArrowCell.m:13:3: warning: ‘RikScrollerArrowCell’ may not respond to
‘-themeControlState’
   GSThemeControlState buttonState = [self themeControlState];
   ^
RikScrollerArrowCell.m:13:3: warning: (Messages without a matching method signature RikScrollerArrowCell.m:13:3: warning: will be assumed to return ‘id’ and accept
RikScrollerArrowCell.m:13:3: warning: ‘...’ as arguments.)
RikScrollerArrowCell.m:13:37: error: incompatible types when initializing type ‘GSThemeControlState’ using type ‘id’
   GSThemeControlState buttonState = [self themeControlState];
                                     ^
RikScrollerArrowCell.m:14:3: warning: ‘RikScrollerArrowCell’ may not respond to
‘-pathForFrame:’
   NSBezierPath * path = [self pathForFrame: cellFrame];
   ^
make[3]: *** [obj/Rik.obj/RikScrollerArrowCell.m.o] Error 1
make[2]: *** [internal-bundle-run-compile-submake] Error 2
make[1]: *** [Rik.all.bundle.variables] Error 2
make: *** [internal-all] Error 2


And with clang+libobjc2 :

Compiling file RikScrollerArrowCell.m ...
RikScrollerArrowCell.m:13:43: warning: instance method '-themeControlState' not
      found (return type defaults to 'id') [-Wobjc-method-access]
  GSThemeControlState buttonState = [self themeControlState];
                                          ^~~~~~~~~~~~~~~~~
./RikScrollerArrowCell.h:10:12: note: receiver is instance of class declared here
@interface RikScrollerArrowCell : NSButtonCell
           ^
RikScrollerArrowCell.m:13:23: warning: incompatible pointer to integer conversion
      initializing 'GSThemeControlState' with an expression of type 'id'
      [-Wint-conversion]
  GSThemeControlState buttonState = [self themeControlState];
                      ^             ~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
 Compiling file NSBrowserCell+Rik.m ...


I don't think it's an objc2 vs objc1 issue. RikScrollerArrowCell is a NSButtonCell subclass. Should'nt it respond to themeControlState ? The best would be to get rid of the warning and I don't understand why it occurs.

Here are attached RikScrollerArrowCell.m and RikScrollerArrowCell.h.


Any idea ?

Bertrand



_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

#import <AppKit/NSButtonCell.h>

typedef enum {
  RikScrollerArrowLeft,
  RikScrollerArrowRight,
  RikScrollerArrowUp,
  RikScrollerArrowDown
} RikScrollerArrowType;

@interface RikScrollerArrowCell : NSButtonCell
{
  RikScrollerArrowType scroller_arrow_type;
}
-(void) setArrowType: (RikScrollerArrowType) t;
@end

#include <AppKit/AppKit.h>
#include "RikScrollerArrowCell.h"
#include "Rik.h"

@implementation RikScrollerArrowCell

- (void) setArrowType: (RikScrollerArrowType) t
{
  scroller_arrow_type = t;
}
- (void) drawBezelWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{
  GSThemeControlState buttonState = [self themeControlState];
  NSBezierPath * path = [self pathForFrame: cellFrame];
  [(Rik*)[GSTheme theme] drawPathButton: path
                               in: self
                            state: buttonState];
}
- (NSBezierPath*) pathForFrame: (NSRect)cellFrame
{

  CGFloat r = 3;
  cellFrame = NSInsetRect(cellFrame, 1, 1);
  cellFrame.origin.x += 0.5;
  cellFrame.origin.y += 0.5;
  NSRect innerRect = NSInsetRect(cellFrame, r, r);
  NSBezierPath* path = [NSBezierPath bezierPath];
  switch(scroller_arrow_type)
    {
      case RikScrollerArrowLeft:
        cellFrame.origin.x += 1.0;
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMinY(innerRect))
                                         radius: r
                                     startAngle: 180
                                       endAngle: 270];
        [path lineToPoint: NSMakePoint(NSMaxX(cellFrame), NSMinY(cellFrame))];
        [path lineToPoint: NSMakePoint(NSMaxX(cellFrame), NSMaxY(cellFrame))];
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMaxY(innerRect))
                                         radius: r
                                     startAngle: 90
                                       endAngle: 180];
        [path closePath];
        break;
      case RikScrollerArrowRight:
        cellFrame.origin.x -= 1.0;
        [path moveToPoint: NSMakePoint(NSMinX(cellFrame), NSMinY(cellFrame))];
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMinY(innerRect))
                                         radius: r
                                     startAngle: 270
                                       endAngle: 360];
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMaxY(innerRect))
                                         radius: r
                                     startAngle: 0
                                       endAngle: 90];
        [path lineToPoint: NSMakePoint(NSMinX(cellFrame), NSMaxY(cellFrame))];
        break;
      case RikScrollerArrowDown:
        cellFrame.origin.y -= 1.0;
        [path moveToPoint: NSMakePoint(NSMinX(cellFrame), NSMinY(cellFrame))];
        [path moveToPoint: NSMakePoint(NSMaxX(cellFrame), NSMinY(cellFrame))];
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMaxY(innerRect))
                                         radius: r
                                     startAngle: 0
                                       endAngle: 90];
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMaxY(innerRect))
                                         radius: r
                                     startAngle: 90
                                       endAngle: 180];
        [path lineToPoint: NSMakePoint(NSMinX(cellFrame), NSMinY(cellFrame))];
        break;
      case RikScrollerArrowUp:
        cellFrame.origin.y += 1.0;
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMinX(innerRect), NSMinY(innerRect))
                                         radius: r
                                     startAngle: 180
                                       endAngle: 270];
        [path appendBezierPathWithArcWithCenter: NSMakePoint(NSMaxX(innerRect), NSMinY(innerRect))
                                         radius: r
                                     startAngle: 270
                                       endAngle: 360];
        [path lineToPoint: NSMakePoint(NSMaxX(cellFrame), NSMaxY(cellFrame))];
        [path lineToPoint: NSMakePoint(NSMinX(cellFrame), NSMaxY(cellFrame))];
        [path closePath];
        break;
    }
    return path;
}
@end
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to