/* simplewebkit
WebHTMLDocumentView.m
Copyright (C) 2007 Free Software Foundation, Inc.
Author: Dr. H. Nikolaus Schaller
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#import "Private.h"
#import
#import "WebHTMLDocumentView.h"
@implementation _WebHTMLDocumentView
// NSView overrides
- (id) initWithFrame:(NSRect) rect;
{
if((self=[super initWithFrame:rect]))
{ // set other attributes (selectable, editable etc.)
[self setEditable:NO];
[self setSelectable:YES];
[self setVerticallyResizable:YES];
[self setHorizontallyResizable:NO]; // for proper line breaks
[self setTextContainerInset:NSMakeSize(2.0, 4.0)]; // leave some margin
[[self textContainer] setWidthTracksTextView:YES];
[[self textContainer] setHeightTracksTextView:NO];
[self setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)];
// [self setLinkTextAttributes:blue ]
// [self setMarkedTextAttributes: ]
// attach a defalt context menu (Back, Forward etc.) for HTML pages
}
return self;
}
- (void) drawRect:(NSRect) rect;
{
#if 0
NSLog(@"%@ drawRect:%@", self, NSStringFromRect(rect));
#endif
if(_needsLayout)
[self layout];
if(_backgroundImage)
; // draw
[super drawRect:rect];
}
// @protocol WebDocumentView
- (void) dataSourceUpdated:(WebDataSource *) source;
{
#if 0
NSLog(@"dataSourceUpdated: %@", source);
#endif
#if 0 // show view hierarchy
while(self)
NSLog(@"%p: %@", self, self), self=(_WebHTMLDocumentView *) [self superview];
#endif
}
- (void) layout;
{ // do the layout of subviews - NOTE: this is called from within drawRect!
DOMHTMLHtmlElement *html=(DOMHTMLHtmlElement *) [[[_dataSource webFrame] DOMDocument] firstChild];
DOMHTMLElement *body=(DOMHTMLElement *) [html lastChild]; // either or could be a