Commit 947d78cf authored by rjw's avatar rjw

More rendering/forms fixes.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d70e5c04
......@@ -22,7 +22,6 @@
*
* $Id$
*/
#include <kdebug.h>
#include <kurl.h>
#include <klocale.h>
......@@ -942,6 +941,7 @@ void RenderSelect::layout( )
QSize s(m_widget->sizeHint());
setIntrinsicWidth( s.width() );
setIntrinsicHeight( s.height() );
fprintf (stderr, "select box size w %d, h %d\n", s.width(), s.height());
}
/// uuh, ignore the following line..
......@@ -1155,12 +1155,21 @@ void RenderTextArea::calcMinMaxWidth()
TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
HTMLTextAreaElementImpl* f = static_cast<HTMLTextAreaElementImpl*>(m_element);
QFontMetrics m = fontMetrics(style()->font());
#ifdef _KWQ_
QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
w->verticalScrollBarWidth(),
QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
(w->wordWrap() == QMultiLineEdit::NoWrap ?
w->horizontalScrollBarHeight() : 0)
);
#else
QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
w->verticalScrollBar()->sizeHint().width(),
QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
(w->wordWrap() == QMultiLineEdit::NoWrap ?
w->horizontalScrollBar()->sizeHint().height() : 0)
);
#endif
setIntrinsicWidth( size.width() );
setIntrinsicHeight( size.height() );
......
......@@ -98,7 +98,6 @@ private:
void *globalPool;
#endif
}; // class QApplication =======================================================
#endif
......@@ -58,6 +58,7 @@ public:
void insertItem(const QString &text, int index=-1);
void clear();
virtual void setCurrentItem(int);
QSize sizeHint() const;
// operators ---------------------------------------------------------------
......
......@@ -33,13 +33,13 @@ static const QPoint ORIGIN(0,0);
QEvent::QEvent(Type)
{
_logNotYetImplemented();
//_logNotYetImplemented();
}
QEvent::~QEvent()
{
_logNotYetImplemented();
//_logNotYetImplemented();
}
......
......@@ -77,7 +77,7 @@ void KCharsets::setQFont(QFont &font, QFont::CharSet) const
// FIXME: do we need a real implementation here?
// [kocienda: 2001-11-05] I don't think we need to implement this
// do nothing
_logNeverImplemented();
// _logNeverImplemented();
}
void KCharsets::setQFont(QFont &, QString) const
......@@ -85,7 +85,7 @@ void KCharsets::setQFont(QFont &, QString) const
// FIXME: do we need a real implementation here?
// [kocienda: 2001-11-05] I don't think we need to implement this
// do nothing
_logNeverImplemented();
// _logNeverImplemented();
}
QString KCharsets::name(QFont::CharSet)
......
......@@ -45,7 +45,7 @@ bool Event::test(const QEvent *, const char *)
Event::Event(const char *)
{
_logNotYetImplemented();
//_logNotYetImplemented();
}
} // namespace KParts
......@@ -923,6 +923,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheDataAvailable: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheDataAvailable: Received notication, %@", notificationName);
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
......@@ -936,6 +937,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheFinished: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheFinished: Received notication, %@", notificationName);
// FIXME: need an implementation for this
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
......
......@@ -923,6 +923,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheDataAvailable: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheDataAvailable: Received notication, %@", notificationName);
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
......@@ -936,6 +937,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheFinished: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheFinished: Received notication, %@", notificationName);
// FIXME: need an implementation for this
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
......
......@@ -923,6 +923,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheDataAvailable: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheDataAvailable: Received notication, %@", notificationName);
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
......@@ -936,6 +937,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheFinished: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheFinished: Received notication, %@", notificationName);
// FIXME: need an implementation for this
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
......
......@@ -50,6 +50,7 @@ class QPainterPrivate;
class QWMatrix {
friend QPainter;
friend QPixmap;
public:
// typedefs ----------------------------------------------------------------
......
......@@ -380,18 +380,9 @@ void QPainter::drawPixmap(const QPoint &p, const QPixmap &pix, const QRect &r)
void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
int sx, int sy, int sw, int sh )
{
NSSize originalSize;
_lockFocus();
if (pixmap.nsimage != nil){
if (pixmap.xmatrix.empty == FALSE){
originalSize = [pixmap.nsimage size];
[pixmap.nsimage setScalesWhenResized: YES];
[pixmap.nsimage setSize: NSMakeSize (originalSize.width * pixmap.xmatrix.sx,
originalSize.height * pixmap.xmatrix.sy)];
}
if (sw == -1)
sw = (int)[pixmap.nsimage size].width;
if (sh == -1)
......@@ -400,9 +391,6 @@ void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
fromRect: NSMakeRect(sx, sy, sw, sh)
operation: NSCompositeSourceOver // Renders transparency correctly
fraction: 1.0];
if (pixmap.xmatrix.empty == FALSE)
[pixmap.nsimage setSize: originalSize];
}
_unlockFocus();
......
......@@ -93,7 +93,6 @@ public:
#else
void *nsimage;
#endif
QWMatrix xmatrix;
#endif
}; // class QPixmap ============================================================
......
......@@ -66,7 +66,13 @@ QPixmap::QPixmap(const QByteArray&bytes)
//NSData *nsdata = [[[NSData alloc] initWithBytesNoCopy: bytes.data() length: bytes.size()] autorelease];
NSData *nsdata = [[[NSData alloc] initWithBytes: bytes.data() length: bytes.size() copy:NO freeWhenDone:NO bytesAreVM:NO] autorelease];
nsimage = [[NSImage alloc] initWithData: nsdata];
if (nsimage == nil){
NSLog (@"unable to create image");
} else {
NSLog (@"image created");
}
[nsimage setFlipped: YES];
[nsimage setScalesWhenResized: YES];
}
......@@ -78,11 +84,13 @@ QPixmap::QPixmap(int w, int h)
QPixmap::QPixmap(const QPixmap &copyFrom)
{
if (copyFrom.nsimage != nil)
nsimage = [copyFrom.nsimage retain];
if (copyFrom.nsimage != nil){
// Do a deep copy of the image. This is required because the image
// may be transformed, i.e. scaled.
nsimage = [copyFrom.nsimage copyWithZone: [copyFrom.nsimage zone]];
}
else
nsimage = nil;
xmatrix = copyFrom.xmatrix;
}
......@@ -155,8 +163,14 @@ void QPixmap::resize(int w, int h) {
QPixmap QPixmap::xForm(const QWMatrix &xmatrix) const
{
// This function is only called when an image needs to be scaled.
// We can depend on render_image.cpp to call resize AFTER
// creating a copy of the image to be scaled. So, this
// implementation simply returns a copy of the image. Note,
// this implementation depends on the implementation of
// RenderImage::printObject.
QPixmap xPix = *this;
xPix.xmatrix = xmatrix;
[xPix.nsimage setScalesWhenResized: YES];
return xPix;
}
......@@ -173,7 +187,6 @@ QPixmap &QPixmap::operator=(const QPixmap &assignFrom)
return *this;
[nsimage release];
nsimage = [assignFrom.nsimage retain];
xmatrix = assignFrom.xmatrix;
return *this;
}
......@@ -187,6 +187,18 @@ void QMultiLineEdit::selectAll()
[textView selectAll];
}
int QMultiLineEdit::verticalScrollBarWidth() const
{
return (int)[NSScroller scrollerWidth];
}
int QMultiLineEdit::horizontalScrollBarHeight() const
{
return (int)[NSScroller scrollerWidth];
}
KEdit::KEdit()
{
......
......@@ -69,6 +69,7 @@ class KHTMLPart;
}
- initWithFrame: (NSRect)r widget: (QWidget *)w;
- (void)setIsFlipped: (bool)flag;
- (void)setNeedsLayout: (bool)flag;
@end
......
......@@ -91,6 +91,11 @@
}
- (void)setNeedsLayout: (bool)flag
{
needsLayout = flag;
}
// This should eventually be removed.
- (void)drawRect:(NSRect)rect {
if (widget != 0l){
......@@ -103,7 +108,7 @@
((KHTMLView *)widget)->part()->xmlDocImpl()->renderer()){
if (needsLayout){
((KHTMLView *)widget)->layout(TRUE);
needsLayout = NO;
//needsLayout = NO;
}
}
......
......@@ -23,6 +23,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
subs = [containerView subviews];
htmlView = (KWQHTMLView *)[[subs objectAtIndex: 0] documentView];
[htmlView setURL: url];
[htmlView setNeedsLayout: YES];
[containerView setNeedsDisplay: YES];
return self;
......
......@@ -125,6 +125,12 @@ public:
int numLines() const;
void selectAll();
#ifdef _KWQ_
int verticalScrollBarWidth() const;
int horizontalScrollBarHeight() const;
#endif
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
......
......@@ -98,7 +98,6 @@ private:
void *globalPool;
#endif
}; // class QApplication =======================================================
#endif
......@@ -58,6 +58,7 @@ public:
void insertItem(const QString &text, int index=-1);
void clear();
virtual void setCurrentItem(int);
QSize sizeHint() const;
// operators ---------------------------------------------------------------
......
......@@ -50,6 +50,7 @@ class QPainterPrivate;
class QWMatrix {
friend QPainter;
friend QPixmap;
public:
// typedefs ----------------------------------------------------------------
......
......@@ -93,7 +93,6 @@ public:
#else
void *nsimage;
#endif
QWMatrix xmatrix;
#endif
}; // class QPixmap ============================================================
......
......@@ -22,7 +22,6 @@
*
* $Id$
*/
#include <kdebug.h>
#include <kurl.h>
#include <klocale.h>
......@@ -942,6 +941,7 @@ void RenderSelect::layout( )
QSize s(m_widget->sizeHint());
setIntrinsicWidth( s.width() );
setIntrinsicHeight( s.height() );
fprintf (stderr, "select box size w %d, h %d\n", s.width(), s.height());
}
/// uuh, ignore the following line..
......@@ -1155,12 +1155,21 @@ void RenderTextArea::calcMinMaxWidth()
TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
HTMLTextAreaElementImpl* f = static_cast<HTMLTextAreaElementImpl*>(m_element);
QFontMetrics m = fontMetrics(style()->font());
#ifdef _KWQ_
QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
w->verticalScrollBarWidth(),
QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
(w->wordWrap() == QMultiLineEdit::NoWrap ?
w->horizontalScrollBarHeight() : 0)
);
#else
QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
w->verticalScrollBar()->sizeHint().width(),
QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
(w->wordWrap() == QMultiLineEdit::NoWrap ?
w->horizontalScrollBar()->sizeHint().height() : 0)
);
#endif
setIntrinsicWidth( size.width() );
setIntrinsicHeight( size.height() );
......
......@@ -33,13 +33,13 @@ static const QPoint ORIGIN(0,0);
QEvent::QEvent(Type)
{
_logNotYetImplemented();
//_logNotYetImplemented();
}
QEvent::~QEvent()
{
_logNotYetImplemented();
//_logNotYetImplemented();
}
......
......@@ -77,7 +77,7 @@ void KCharsets::setQFont(QFont &font, QFont::CharSet) const
// FIXME: do we need a real implementation here?
// [kocienda: 2001-11-05] I don't think we need to implement this
// do nothing
_logNeverImplemented();
// _logNeverImplemented();
}
void KCharsets::setQFont(QFont &, QString) const
......@@ -85,7 +85,7 @@ void KCharsets::setQFont(QFont &, QString) const
// FIXME: do we need a real implementation here?
// [kocienda: 2001-11-05] I don't think we need to implement this
// do nothing
_logNeverImplemented();
// _logNeverImplemented();
}
QString KCharsets::name(QFont::CharSet)
......
......@@ -45,7 +45,7 @@ bool Event::test(const QEvent *, const char *)
Event::Event(const char *)
{
_logNotYetImplemented();
//_logNotYetImplemented();
}
} // namespace KParts
......@@ -923,6 +923,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheDataAvailable: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheDataAvailable: Received notication, %@", notificationName);
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
......@@ -936,6 +937,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSLog (@"cacheFinished: Received invalid notication, %@", notificationName);
}
else {
NSLog (@"cacheFinished: Received notication, %@", notificationName);
// FIXME: need an implementation for this
id <WCURICacheData> data = [notification object];
KIO::Job *job = static_cast<KIO::Job *>([data userData]);
......
......@@ -380,18 +380,9 @@ void QPainter::drawPixmap(const QPoint &p, const QPixmap &pix, const QRect &r)
void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
int sx, int sy, int sw, int sh )
{
NSSize originalSize;
_lockFocus();
if (pixmap.nsimage != nil){
if (pixmap.xmatrix.empty == FALSE){
originalSize = [pixmap.nsimage size];
[pixmap.nsimage setScalesWhenResized: YES];
[pixmap.nsimage setSize: NSMakeSize (originalSize.width * pixmap.xmatrix.sx,
originalSize.height * pixmap.xmatrix.sy)];
}
if (sw == -1)
sw = (int)[pixmap.nsimage size].width;
if (sh == -1)
......@@ -400,9 +391,6 @@ void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
fromRect: NSMakeRect(sx, sy, sw, sh)
operation: NSCompositeSourceOver // Renders transparency correctly
fraction: 1.0];
if (pixmap.xmatrix.empty == FALSE)
[pixmap.nsimage setSize: originalSize];
}
_unlockFocus();
......
......@@ -66,7 +66,13 @@ QPixmap::QPixmap(const QByteArray&bytes)
//NSData *nsdata = [[[NSData alloc] initWithBytesNoCopy: bytes.data() length: bytes.size()] autorelease];
NSData *nsdata = [[[NSData alloc] initWithBytes: bytes.data() length: bytes.size() copy:NO freeWhenDone:NO bytesAreVM:NO] autorelease];
nsimage = [[NSImage alloc] initWithData: nsdata];
if (nsimage == nil){
NSLog (@"unable to create image");
} else {
NSLog (@"image created");
}
[nsimage setFlipped: YES];
[nsimage setScalesWhenResized: YES];
}
......@@ -78,11 +84,13 @@ QPixmap::QPixmap(int w, int h)
QPixmap::QPixmap(const QPixmap &copyFrom)
{
if (copyFrom.nsimage != nil)
nsimage = [copyFrom.nsimage retain];
if (copyFrom.nsimage != nil){
// Do a deep copy of the image. This is required because the image
// may be transformed, i.e. scaled.
nsimage = [copyFrom.nsimage copyWithZone: [copyFrom.nsimage zone]];
}
else
nsimage = nil;
xmatrix = copyFrom.xmatrix;
}
......@@ -155,8 +163,14 @@ void QPixmap::resize(int w, int h) {
QPixmap QPixmap::xForm(const QWMatrix &xmatrix) const
{
// This function is only called when an image needs to be scaled.
// We can depend on render_image.cpp to call resize AFTER
// creating a copy of the image to be scaled. So, this
// implementation simply returns a copy of the image. Note,
// this implementation depends on the implementation of
// RenderImage::printObject.
QPixmap xPix = *this;
xPix.xmatrix = xmatrix;
[xPix.nsimage setScalesWhenResized: YES];
return xPix;
}
......@@ -173,7 +187,6 @@ QPixmap &QPixmap::operator=(const QPixmap &assignFrom)
return *this;
[nsimage release];
nsimage = [assignFrom.nsimage retain];
xmatrix = assignFrom.xmatrix;
return *this;
}
......@@ -187,6 +187,18 @@ void QMultiLineEdit::selectAll()
[textView selectAll];
}
int QMultiLineEdit::verticalScrollBarWidth() const
{
return (int)[NSScroller scrollerWidth];
}
int QMultiLineEdit::horizontalScrollBarHeight() const
{
return (int)[NSScroller scrollerWidth];
}
KEdit::KEdit()
{
......
......@@ -69,6 +69,7 @@ class KHTMLPart;
}
- initWithFrame: (NSRect)r widget: (QWidget *)w;
- (void)setIsFlipped: (bool)flag;
- (void)setNeedsLayout: (bool)flag;
@end
......
......@@ -91,6 +91,11 @@
}
- (void)setNeedsLayout: (bool)flag
{
needsLayout = flag;
}
// This should eventually be removed.
- (void)drawRect:(NSRect)rect {
if (widget != 0l){
......@@ -103,7 +108,7 @@
((KHTMLView *)widget)->part()->xmlDocImpl()->renderer()){
if (needsLayout){
((KHTMLView *)widget)->layout(TRUE);
needsLayout = NO;
//needsLayout = NO;
}
}
......
......@@ -23,6 +23,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
subs = [containerView subviews];
htmlView = (KWQHTMLView *)[[subs objectAtIndex: 0] documentView];
[htmlView setURL: url];
[htmlView setNeedsLayout: YES];
[containerView setNeedsDisplay: YES];
return self;
......
......@@ -125,6 +125,12 @@ public:
int numLines() const;
void selectAll();
#ifdef _KWQ_
int verticalScrollBarWidth() const;
int horizontalScrollBarHeight() const;
#endif
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
......
......@@ -98,7 +98,6 @@ private:
void *globalPool;
#endif
}; // class QApplication =======================================================
#endif
......@@ -58,6 +58,7 @@ public:
void insertItem(const QString &text, int index=-1);
void clear();
virtual void setCurrentItem(int);
QSize sizeHint() const;
// operators ---------------------------------------------------------------
......
......@@ -50,6 +50,7 @@ class QPainterPrivate;
class QWMatrix {
friend QPainter;
friend QPixmap;
public: