
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include "GraphicToolbox.h"

@implementation NSScrollView (theme)

- (void) drawRect: (NSRect)rect
{
  NSRectClip(rect);
  [[_window backgroundColor] set];
  NSRectFill(rect);
 // [self setBackgroundColor: [NSColor whiteColor]];
 // [[self documentView] setBackgroundColor: [NSColor whiteColor]];
  //NSGraphicsContext *ctxt = GSCurrentContext();

  Class c = [self superview];

  NSLog (@"superview de scrollview: %@", [c className]);
 
  switch (_borderType)
    {
//      case NSNoBorder:

  //      break;

//      case NSLineBorder:
//        [[NSColor controlDarkShadowColor] set];
//        NSFrameRect(_bounds);
//        break;

 //     case NSBezelBorder:
 //       NSDrawGrayBezel(_bounds, rect);
 //       break;

 //     case NSGrooveBorder:
 //       NSDrawGroove(_bounds, rect);
//        break;

//	default:


    }

	NSBezierPath* path = [NSBezierPath bezierPath];
	NSRect mrect = NSMakeRect (rect.origin.x + 1, rect.origin.y + 1, rect.size.width - 2, rect.size.height - 2);
	[path appendBezierPathWithRect: mrect];
/*	if ([self hasHorizontalScroller] && [self hasVerticalScroller])
	{
        	//[path appendBezierPathWithLeftAndBottomRoundedCorners: mrect withRadius: 8.0];
		if ([self isFlipped])
		{
        		[path appendBezierPathWithTopRoundedCorners: mrect withRadius: 8.0];	
		}
		else
		{	
        		[path appendBezierPathWithBottomRoundedCorners: mrect withRadius: 8.0];	
		}
	}
	else if ([self hasHorizontalScroller])
	{
		if ([self isFlipped])
		{
        		[path appendBezierPathWithTopRoundedCorners: mrect withRadius: 8.0];	
		}
		else
		{	
        		[path appendBezierPathWithBottomRoundedCorners: mrect withRadius: 8.0];	
		}
	}
	else if ([self hasVerticalScroller])
	{
        	[path appendBezierPathWithLeftRoundedCorners: mrect withRadius: 8.0];
	}
*/
        //[path appendBezierPathWithLeftRoundedCorners: mrect withRadius: 8.0];
	//[path appendBezierPathWithRoundedRectangle: mrect withRadius: 8.0];
	[[NSColor colorWithCalibratedRed: 0.5 green: 0.5 blue: 0.5 alpha: 1.0] set];
	[[NSColor blackColor] set];
	[path setLineWidth: 1.5];
	[path stroke];
	

/*
  [[NSColor controlDarkShadowColor] set];
  DPSsetlinewidth(ctxt, 1);

  if (_hasVertScroller)
    {
      DPSmoveto(ctxt, [_vertScroller frame].origin.x + [NSScroller scrollerWidth],
                [_vertScroller frame].origin.y - 1);
      DPSrlineto(ctxt, 0, [_vertScroller frame].size.height + 1);
      DPSstroke(ctxt);
    }

  if (_hasHorizScroller)
    {
      float ypos;
      float scrollerY = [_horizScroller frame].origin.y;

      if (_rFlags.flipped_view)
        {
          ypos = scrollerY - 1;
        }
      else
        {
          ypos = scrollerY + [NSScroller scrollerWidth] + 1;
        }

      DPSmoveto(ctxt, [_horizScroller frame].origin.x - 1, ypos);
      DPSrlineto(ctxt, [_horizScroller frame].size.width + 1, 0);
      DPSstroke(ctxt);
    }
*/
}
@end
