Commit 60bddac0 authored by kocienda's avatar kocienda

A large set of changes:

	- I did a pass over all .mm files in WebCore/src/kwq, adding
	actual return values for all functions that return something
	(there were *many* cases where callers were left dangling).
	- I added numerous log statements throughout the code.
	- I made the log statement system configurable at runtime, so the
	amount of logging can be increased or decreased as desired.
	- I added an implementation for QVariant.
	- I cleaned up the implementations of QBrush and QPen.
	- I made general fixups and cleanups in various places.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@423 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f09ea93a
......@@ -450,6 +450,7 @@ acronym {
}
:focus { outline: 1px dotted invert }
a:link { color: blue; text-decoration: underline; }
a:link:active { color: red; outline: 1px dotted invert; }
a:visited:active { color: red; outline: 1px dotted invert; }
......
......@@ -5,5 +5,6 @@ Makefile.in
*.dep
*.moc
*.gperf
testecma
export-objects
export-headers
......@@ -107,7 +107,7 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
int width = m_width;
if( begin )
width -= p->paddingLeft() + p->borderLeft();
width -= p->paddingLeft() + p->borderLeft();
if ( end )
width -= p->paddingRight() + p->borderRight();
......@@ -115,6 +115,11 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
int underlineOffset = ( pt->fontMetrics().height() + m_baseline ) / 2;
if(underlineOffset <= m_baseline) underlineOffset = m_baseline+1;
// FIXME: [kocienda]
// This hack gets the underline in a better place but we should be
// doing something better.
underlineOffset+=2;
if(deco & UNDERLINE)
pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
if(deco & OVERLINE)
......
......@@ -22,6 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kwqdebug.h>
#include <qapplication.h>
#include <qpalette.h>
......@@ -30,6 +31,7 @@
// FIXME:
static QPalette DEFAULT_PALETTE = QPalette();
static QSize DEFAULT_SIZE = QSize(0,0);
QPalette QApplication::palette(const QWidget *p)
{
......@@ -39,46 +41,46 @@ QPalette QApplication::palette(const QWidget *p)
QWidget *QApplication::desktop()
{
NSLog (@"ERROR %s:%s:%d (NOT IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
_logNotYetImplemented();
return 0;
}
int QApplication::startDragDistance()
{
NSLog (@"ERROR %s:%s:%d (NOT IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
_logNotYetImplemented();
return 2;
}
QSize QApplication::globalStrut()
{
static QSize *structSize = new QSize(0,0);
NSLog (@"ERROR %s:%s:%d (NOT IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
return *structSize;
_logNotYetImplemented();
return DEFAULT_SIZE;
}
void QApplication::setOverrideCursor(const QCursor &c)
{
NSLog (@"ERROR %s:%s:%d (NOT IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
_logNotYetImplemented();
}
void QApplication::restoreOverrideCursor()
{
NSLog (@"ERROR %s:%s:%d (NOT IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
_logNotYetImplemented();
}
bool QApplication::sendEvent(QObject *o, QEvent *e)
{
NSLog (@"ERROR %s:%s:%d (NOT IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
_logNotYetImplemented();
return FALSE;
}
void QApplication::sendPostedEvents(QObject *receiver, int event_type)
{
NSLog (@"ERROR %s:%s:%d (NOT IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
_logNotYetImplemented();
}
......
......@@ -23,35 +23,43 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kwqdebug.h>
#include <qbitmap.h>
QBitmap::QBitmap()
{
_logNotYetImplemented();
}
QBitmap::QBitmap(int,int)
{
_logNotYetImplemented();
}
QBitmap::QBitmap(const QBitmap &)
{
_logNotYetImplemented();
}
QBitmap &QBitmap::operator=(const QBitmap &)
{
_logNotYetImplemented();
return *this;
}
QBitmap &QBitmap::operator=(const QPixmap &)
{
_logNotYetImplemented();
return *this;
}
QBitmap &QBitmap::operator=(const QImage &)
{
_logNotYetImplemented();
return *this;
}
......@@ -33,6 +33,8 @@
#include "qcolor.h"
#include "qnamespace.h"
class QBrushPrivate;
// class QBrush ================================================================
class QBrush : public Qt {
......@@ -48,6 +50,7 @@ public:
QBrush();
QBrush(const QColor &);
QBrush::QBrush(const QColor &c, BrushStyle style);
QBrush(const QBrush &);
QBrush &operator=(const QBrush &);
~QBrush();
......@@ -56,6 +59,8 @@ public:
const QColor &color() const;
void setColor(const QColor &);
BrushStyle style() const;
void setStyle(BrushStyle);
// operators ---------------------------------------------------------------
......@@ -64,8 +69,14 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
QColor qcolor;
BrushStyle qbrushstyle;
private:
void init(const QColor &, BrushStyle);
QBrush copy() const;
void detach();
struct QBrushData : public QShared {
BrushStyle brushStyle;
QColor color;
} *data;
}; // class QBrush =============================================================
......
......@@ -25,52 +25,91 @@
#include <qbrush.h>
void QBrush::init(const QColor &color, BrushStyle style)
{
data = new QBrushData();
data->color = color;
data->brushStyle = style;
}
QBrush::QBrush()
{
qcolor = Qt::black;
qbrushstyle = SolidPattern;
init(Qt::black, SolidPattern);
}
QBrush::QBrush(const QColor &c)
{
qcolor = c;
qbrushstyle = SolidPattern;
init(c, SolidPattern);
}
QBrush::QBrush(const QColor &c, BrushStyle style)
{
init(c, style);
}
QBrush::QBrush(const QBrush &copyFrom)
{
qcolor = copyFrom.qcolor;
qbrushstyle = copyFrom.qbrushstyle;
data = copyFrom.data;
data->ref();
}
QBrush &QBrush::operator=(const QBrush &assignFrom)
{
qcolor = assignFrom.qcolor;
qbrushstyle = assignFrom.qbrushstyle;
assignFrom.data->ref();
if (data->deref()) {
delete data;
}
data = assignFrom.data;
return *this;
}
QBrush::~QBrush()
{
if (data->deref()) {
delete data;
}
}
QBrush QBrush::copy() const
{
return QBrush(data->color, data->brushStyle);
}
void QBrush::detach()
{
if (data->count != 1) {
*this = copy();
}
}
const QColor &QBrush::color() const
{
return qcolor;
return data->color;
}
void QBrush::setColor(const QColor &c)
{
qcolor = c;
detach();
data->color = c;
}
Qt::BrushStyle QBrush::style() const
{
return data->brushStyle;
}
void QBrush::setStyle(Qt::BrushStyle bs)
{
detach();
data->brushStyle = bs;
}
bool QBrush::operator==(const QBrush &compareTo) const
{
return qcolor == compareTo.qcolor;
return (compareTo.data == data) ||
(compareTo.data->brushStyle == data->brushStyle &&
compareTo.data->color == data->color);
}
......
......@@ -49,10 +49,13 @@ QColor::QColor()
QColor::QColor(int r, int g, int b)
{
if ( !globals_init )
initGlobalColors();
else
color = nil;
if (!globals_init) {
initGlobalColors();
}
else {
_initialize (r, g, b);
}
}
QColor::QColor(const QString &name)
......@@ -85,14 +88,12 @@ QColor::~QColor(){
QColor::QColor(const QColor &copyFrom)
{
if (color == copyFrom.color)
return;
//if (color != nil)
// [color release];
if (copyFrom.color != nil)
if (copyFrom.color != nil) {
color = [copyFrom.color retain];
else
}
else {
color = nil;
}
}
QString QColor::name() const
......@@ -241,9 +242,41 @@ void QColor::setRgb(int rgb)
}
void QColor::hsv(int *, int *, int *) const
void QColor::hsv(int *h, int *s, int *v) const
{
_logNotYetImplemented();
int r = red();
int g = green();
int b = blue();
int i, w, x, f;
x = w = r;
if (g > x) {
x = g;
}
if (g < w) {
w = g;
}
if (b > x) {
x = b;
}
if (b < w) {
w = b;
}
if (w == x) {
*h = -1;
*s = 0;
*v = w;
}
else {
f = (r == x) ? g - b : ((g == x) ? b - r : r - g);
i = (r == x) ? 3 : ((g == x) ? 5 : 1);
*h = i - f /(w - x);
*s = (w - x)/w;
*v = w;
}
}
QColor QColor::light(int f = 150) const
......
......@@ -22,6 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kwqdebug.h>
#include <qpalette.h>
#include <qcolor.h>
......@@ -64,8 +65,6 @@ private:
QBrush *brushes;
};
#include <kwqdebug.h>
QColorGroup::QColorGroup()
{
d = new QColorGroupPrivate();
......
......@@ -68,6 +68,7 @@ int QComboBox::count() const
QListBox *QComboBox::listBox() const
{
_logNotYetImplemented();
return 0L;
}
......@@ -80,6 +81,7 @@ void QComboBox::popup()
bool QComboBox::eventFilter(QObject *object, QEvent *event)
{
_logNotYetImplemented();
return FALSE;
}
......
......@@ -23,34 +23,36 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kwqdebug.h>
#include <KWQCompletion.h>
KCompletion::KCompletion()
{
_logNotYetImplemented();
}
KCompletion::~KCompletion()
{
_logNotYetImplemented();
}
void KCompletion::setItems(const QStringList &)
{
_logNotYetImplemented();
}
KCompletionBase::KCompletionBase()
{
_logNotYetImplemented();
}
KCompletionBase::~KCompletionBase()
{
_logNotYetImplemented();
}
KCompletion *KCompletionBase::completionObject(bool hsig = true)
{
_logNotYetImplemented();
return 0L;
}
......@@ -23,6 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kwqdebug.h>
#include <qcursor.h>
const QCursor & Qt::sizeAllCursor = QCursor();
......@@ -31,27 +32,32 @@ const QCursor & Qt::splitVCursor = QCursor();
QCursor::QCursor()
{
_logNotYetImplemented();
}
QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY)
{
}
QPoint QCursor::pos()
{
_logNotYetImplemented();
}
QCursor::QCursor(const QCursor &)
{
_logNotYetImplemented();
}
QCursor::~QCursor()
{
_logNotYetImplemented();
}
QPoint QCursor::pos()
{
_logNotYetImplemented();
return QPoint();
}
QCursor &QCursor::operator=(const QCursor &)
{
_logNotYetImplemented();
return *this;
}
......@@ -23,11 +23,82 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kwqdebug.h>
#include <qdrawutil.h>
void qDrawShadePanel(QPainter *, int, int, int, int, const QColorGroup &, bool
sunken = FALSE, int lineWidth = 1, const QBrush *fill = 0)
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool
sunken = FALSE, int lineWidth, const QBrush *fill)
{
NSLog (@"WARNING %s:%s:%d (NOT YET IMPLEMENTED)\n", __FILE__, __FUNCTION__, __LINE__);
if ( w == 0 || h == 0 ) {
return;
}
QPen oldPen = p->pen(); // save pen
QPointArray a(4 * lineWidth);
if (sunken) {
p->setPen(g.dark());
}
else {
p->setPen(g.light());
}
int x1, y1, x2, y2;
int i;
int n = 0;
x1 = x;
y1 = y2 = y;
x2 = x+w-2;
for (i = 0; i < lineWidth; i++) { // top shadow
a.setPoint(n++, x1, y1++);
a.setPoint(n++, x2--, y2++);
}
x2 = x1;
y1 = y+h-2;
for (i = 0; i < lineWidth; i++) { // left shadow
a.setPoint(n++, x1++, y1);
a.setPoint(n++, x2++, y2--);
}
p->drawLineSegments(a);
n = 0;
if (sunken) {
p->setPen(g.light());
}
else {
p->setPen(g.dark());
}
x1 = x;
y1 = y2 = y+h-1;
x2 = x+w-1;
for (i = 0; i < lineWidth; i++) { // bottom shadow
a.setPoint(n++, x1++, y1--);
a.setPoint(n++, x2, y2--);
}
x1 = x2;
y1 = y;
y2 = y+h-lineWidth-1;
for (i = 0; i < lineWidth; i++) { // right shadow
a.setPoint(n++, x1--, y1++);
a.setPoint(n++, x2--, y2);
}
p->drawLineSegments(a);
if (fill) { // fill with fill color
QBrush oldBrush = p->brush();