[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:13:42 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit b74fdd7f84f7aefe331b9ed97bd34f23a5f7a013
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun May 19 16:02:40 2002 +0000
* khtml/rendering/render_object.cpp: (RenderObject::drawBorder):
Add missing break statement so borders don't draw strangely.
* khtml/rendering/render_style.h: Remove unneeded QColor workaround,
now that we handle invalid colors properly.
* kwq/KWQColor.mm:
(createStaticConstructorAutoreleasePool): New solution to the problem
of autorelease at static constructor time.
(getNamedColors): Function that creates this dictionary when needed
rather than creating it inside an init function.
(QColor::QColor): Share code with setRgb, get rid of _initialize.
(hex2int): Return -1 for bad digit rather than 0.
(decodeColorFromHexColorString): Make more robust and simpler.
(QColor::setNamedColor): Set color to invalid rather than black when
the passed in name is empty or unrecognized.
(QColor::red), (QColor::green), (QColor::blue): Round instead of truncating.
(QColor::setRgb): Set color to invalid if r, g, or b is out of range.
(QColor::operator=): Simplify.
(QColor::operator==): Handle invalid colors correctly.
(QColor::getNSColor): Return black of invalid colors.
* kwq/KWQCursor.mm: Simplify cursor globals.
* kwq/KWQPainter.mm:
(QPainter::_setColorFromBrush): Use getNSColor() to handle invalid colors correctly.
(QPainter::_setColorFromPen): Use getNSColor() to handle invalid colors correctly.
(QPainter::drawLine): Add code to respect style and width and handle endpoints in a
way that will make the lines look like Qt users expect.
(QPainter::drawText): Use getNSColor() to handle invalid colors correctly.
(QPainter::drawUnderlineForText): Use getNSColor() to handle invalid colors correctly.
(QPainter::fillRect): Use getNSColor() to handle invalid colors correctly.
* kwq/KWQPen.mm: (QPen::QPen): (QPen::setStyle): Remove use of MPenStyle.
* kwq/KWQPixmap.mm: (QPixmap::QPixmap): Add comments.
* kwq/qt/qcolor.h: Simplify ifdefs, remove cname, _initialize, globals_init, and
initGlobalColors.
* kwq/qt/qnamespace.h: Remove AlignTop, AlignBottom, SingleLine, ExpandTabs, DontPrint,
DashDotLine, DashDotDotLine, MPenStyle, WResizeNoRease, WRepaintNoErase, color0, color1,
darkRed, darkGreen, darkBlue, darkCyan, darkMagenta, darkYellow. Simplify the QColor
and QCursor globals.
* kwq/qt/qpen.h: QPainter is no longer a friend class. Remove linest.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 9f63399..d95840c 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,52 @@
+2002-05-19 Darin Adler <darin at apple.com>
+
+ * khtml/rendering/render_object.cpp: (RenderObject::drawBorder):
+ Add missing break statement so borders don't draw strangely.
+
+ * khtml/rendering/render_style.h: Remove unneeded QColor workaround,
+ now that we handle invalid colors properly.
+
+ * kwq/KWQColor.mm:
+ (createStaticConstructorAutoreleasePool): New solution to the problem
+ of autorelease at static constructor time.
+ (getNamedColors): Function that creates this dictionary when needed
+ rather than creating it inside an init function.
+ (QColor::QColor): Share code with setRgb, get rid of _initialize.
+ (hex2int): Return -1 for bad digit rather than 0.
+ (decodeColorFromHexColorString): Make more robust and simpler.
+ (QColor::setNamedColor): Set color to invalid rather than black when
+ the passed in name is empty or unrecognized.
+ (QColor::red), (QColor::green), (QColor::blue): Round instead of truncating.
+ (QColor::setRgb): Set color to invalid if r, g, or b is out of range.
+ (QColor::operator=): Simplify.
+ (QColor::operator==): Handle invalid colors correctly.
+ (QColor::getNSColor): Return black of invalid colors.
+
+ * kwq/KWQCursor.mm: Simplify cursor globals.
+
+ * kwq/KWQPainter.mm:
+ (QPainter::_setColorFromBrush): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::_setColorFromPen): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::drawLine): Add code to respect style and width and handle endpoints in a
+ way that will make the lines look like Qt users expect.
+ (QPainter::drawText): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::drawUnderlineForText): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::fillRect): Use getNSColor() to handle invalid colors correctly.
+
+ * kwq/KWQPen.mm: (QPen::QPen): (QPen::setStyle): Remove use of MPenStyle.
+
+ * kwq/KWQPixmap.mm: (QPixmap::QPixmap): Add comments.
+
+ * kwq/qt/qcolor.h: Simplify ifdefs, remove cname, _initialize, globals_init, and
+ initGlobalColors.
+
+ * kwq/qt/qnamespace.h: Remove AlignTop, AlignBottom, SingleLine, ExpandTabs, DontPrint,
+ DashDotLine, DashDotDotLine, MPenStyle, WResizeNoRease, WRepaintNoErase, color0, color1,
+ darkRed, darkGreen, darkBlue, darkCyan, darkMagenta, darkYellow. Simplify the QColor
+ and QCursor globals.
+
+ * kwq/qt/qpen.h: QPainter is no longer a friend class. Remove linest.
+
2002-05-17 Darin Adler <darin at apple.com>
* khtml/rendering/render_list.cpp: (RenderListItem::setStyle):
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 9f63399..d95840c 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,52 @@
+2002-05-19 Darin Adler <darin at apple.com>
+
+ * khtml/rendering/render_object.cpp: (RenderObject::drawBorder):
+ Add missing break statement so borders don't draw strangely.
+
+ * khtml/rendering/render_style.h: Remove unneeded QColor workaround,
+ now that we handle invalid colors properly.
+
+ * kwq/KWQColor.mm:
+ (createStaticConstructorAutoreleasePool): New solution to the problem
+ of autorelease at static constructor time.
+ (getNamedColors): Function that creates this dictionary when needed
+ rather than creating it inside an init function.
+ (QColor::QColor): Share code with setRgb, get rid of _initialize.
+ (hex2int): Return -1 for bad digit rather than 0.
+ (decodeColorFromHexColorString): Make more robust and simpler.
+ (QColor::setNamedColor): Set color to invalid rather than black when
+ the passed in name is empty or unrecognized.
+ (QColor::red), (QColor::green), (QColor::blue): Round instead of truncating.
+ (QColor::setRgb): Set color to invalid if r, g, or b is out of range.
+ (QColor::operator=): Simplify.
+ (QColor::operator==): Handle invalid colors correctly.
+ (QColor::getNSColor): Return black of invalid colors.
+
+ * kwq/KWQCursor.mm: Simplify cursor globals.
+
+ * kwq/KWQPainter.mm:
+ (QPainter::_setColorFromBrush): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::_setColorFromPen): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::drawLine): Add code to respect style and width and handle endpoints in a
+ way that will make the lines look like Qt users expect.
+ (QPainter::drawText): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::drawUnderlineForText): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::fillRect): Use getNSColor() to handle invalid colors correctly.
+
+ * kwq/KWQPen.mm: (QPen::QPen): (QPen::setStyle): Remove use of MPenStyle.
+
+ * kwq/KWQPixmap.mm: (QPixmap::QPixmap): Add comments.
+
+ * kwq/qt/qcolor.h: Simplify ifdefs, remove cname, _initialize, globals_init, and
+ initGlobalColors.
+
+ * kwq/qt/qnamespace.h: Remove AlignTop, AlignBottom, SingleLine, ExpandTabs, DontPrint,
+ DashDotLine, DashDotDotLine, MPenStyle, WResizeNoRease, WRepaintNoErase, color0, color1,
+ darkRed, darkGreen, darkBlue, darkCyan, darkMagenta, darkYellow. Simplify the QColor
+ and QCursor globals.
+
+ * kwq/qt/qpen.h: QPainter is no longer a friend class. Remove linest.
+
2002-05-17 Darin Adler <darin at apple.com>
* khtml/rendering/render_list.cpp: (RenderListItem::setStyle):
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 9f63399..d95840c 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,52 @@
+2002-05-19 Darin Adler <darin at apple.com>
+
+ * khtml/rendering/render_object.cpp: (RenderObject::drawBorder):
+ Add missing break statement so borders don't draw strangely.
+
+ * khtml/rendering/render_style.h: Remove unneeded QColor workaround,
+ now that we handle invalid colors properly.
+
+ * kwq/KWQColor.mm:
+ (createStaticConstructorAutoreleasePool): New solution to the problem
+ of autorelease at static constructor time.
+ (getNamedColors): Function that creates this dictionary when needed
+ rather than creating it inside an init function.
+ (QColor::QColor): Share code with setRgb, get rid of _initialize.
+ (hex2int): Return -1 for bad digit rather than 0.
+ (decodeColorFromHexColorString): Make more robust and simpler.
+ (QColor::setNamedColor): Set color to invalid rather than black when
+ the passed in name is empty or unrecognized.
+ (QColor::red), (QColor::green), (QColor::blue): Round instead of truncating.
+ (QColor::setRgb): Set color to invalid if r, g, or b is out of range.
+ (QColor::operator=): Simplify.
+ (QColor::operator==): Handle invalid colors correctly.
+ (QColor::getNSColor): Return black of invalid colors.
+
+ * kwq/KWQCursor.mm: Simplify cursor globals.
+
+ * kwq/KWQPainter.mm:
+ (QPainter::_setColorFromBrush): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::_setColorFromPen): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::drawLine): Add code to respect style and width and handle endpoints in a
+ way that will make the lines look like Qt users expect.
+ (QPainter::drawText): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::drawUnderlineForText): Use getNSColor() to handle invalid colors correctly.
+ (QPainter::fillRect): Use getNSColor() to handle invalid colors correctly.
+
+ * kwq/KWQPen.mm: (QPen::QPen): (QPen::setStyle): Remove use of MPenStyle.
+
+ * kwq/KWQPixmap.mm: (QPixmap::QPixmap): Add comments.
+
+ * kwq/qt/qcolor.h: Simplify ifdefs, remove cname, _initialize, globals_init, and
+ initGlobalColors.
+
+ * kwq/qt/qnamespace.h: Remove AlignTop, AlignBottom, SingleLine, ExpandTabs, DontPrint,
+ DashDotLine, DashDotDotLine, MPenStyle, WResizeNoRease, WRepaintNoErase, color0, color1,
+ darkRed, darkGreen, darkBlue, darkCyan, darkMagenta, darkYellow. Simplify the QColor
+ and QCursor globals.
+
+ * kwq/qt/qpen.h: QPainter is no longer a friend class. Remove linest.
+
2002-05-17 Darin Adler <darin at apple.com>
* khtml/rendering/render_list.cpp: (RenderListItem::setStyle):
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 9641299..580e484 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -241,6 +241,9 @@ void RenderObject::drawBorder(QPainter *p, int x1, int y1, int x2, int y2,
case BSBottom:
case BSTop:
p->drawLine(x1, (y1+y2)/2, x2, (y1+y2)/2);
+#ifdef APPLE_CHANGES
+ break;
+#endif
case BSRight:
case BSLeft:
p->drawLine((x1+x2)/2, y1, (x1+x2)/2, y2);
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index ed76862..121ce30 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -198,9 +198,6 @@ public:
{
width = 3; // medium is default value
style = BNONE;
-#ifdef APPLE_CHANGES
- color = Qt::black;
-#endif /* APPLE_CHANGES */
}
QColor color;
unsigned short width : 12;
diff --git a/WebCore/kwq/KWQColor.h b/WebCore/kwq/KWQColor.h
index d3d5d37..5dd6583 100644
--- a/WebCore/kwq/KWQColor.h
+++ b/WebCore/kwq/KWQColor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,35 +26,21 @@
#ifndef QCOLOR_H_
#define QCOLOR_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qnamespace.h>
#include <qstring.h>
#ifdef __OBJC__
-#import <Cocoa/Cocoa.h>
+ at class NSColor;
+#else
+typedef void NSColor;
#endif
-
typedef unsigned int QRgb; // RGB triplet
QRgb qRgb(int r, int g, int b);
QRgb qRgba(int r, int g, int b, int a);
-// class QColor ================================================================
-
class QColor {
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QColor();
QColor(int,int,int);
QColor(const QString &);
@@ -63,8 +49,6 @@ public:
~QColor();
- // member functions --------------------------------------------------------
-
QString name() const;
void setNamedColor(const QString&);
@@ -83,35 +67,14 @@ public:
QColor light(int f = 150) const;
QColor dark(int f = 200) const;
- // operators ---------------------------------------------------------------
-
QColor &operator=(const QColor &);
bool operator==(const QColor &x) const;
bool operator!=(const QColor &x) const;
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
- static bool globals_init;
+ NSColor *getNSColor() const;
- void initGlobalColors();
-
-#ifdef _KWQ_
- void _initialize(int,int,int);
-
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSColor *getNSColor();
-#else
- void *getNSColor();
-#endif
-
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+private:
NSColor *color;
-#else
- void *color;
-#endif
- QString cname;
-#endif
-
-}; // class QColor =============================================================
+};
#endif
diff --git a/WebCore/kwq/KWQColor.mm b/WebCore/kwq/KWQColor.mm
index 8a8b417..12d7149 100644
--- a/WebCore/kwq/KWQColor.mm
+++ b/WebCore/kwq/KWQColor.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,42 +24,211 @@
*/
#include <qcolor.h>
-#include <qstring.h>
+#include <qnamespace.h>
+#include <qstring.h>
#include <kwqdebug.h>
-static NSDictionary *namedColors = NULL;
+static void createStaticConstructorAutoreleasePool()
+{
+ static bool created;
+ if (created)
+ return;
+ created = true;
+ [[NSAutoreleasePool alloc] init];
+ // FIXME: It would be great if there was some way to release this
+ // without help from the application.
+}
-#define ROUND_TO_INT(f) ((int)rint((f)))
+const QColor Qt::black (0x00, 0x00, 0x00);
+const QColor Qt::white (0xFF, 0xFF, 0xFF);
+const QColor Qt::darkGray (0x80, 0x80, 0x80);
+const QColor Qt::gray (0xA0, 0xA0, 0xA0);
+const QColor Qt::lightGray(0xC0, 0xC0, 0xC0);
+const QColor Qt::red (0xFF, 0x00, 0x00);
+const QColor Qt::green (0x00, 0xFF, 0x00);
+const QColor Qt::blue (0x00, 0x00, 0xFF);
+const QColor Qt::cyan (0x00, 0xFF, 0xFF);
+const QColor Qt::magenta (0xFF, 0x00, 0xFF);
+const QColor Qt::yellow (0xFF, 0xFF, 0x00);
+
+static NSDictionary *getNamedColors()
+{
+ static NSDictionary *namedColors;
+
+ if (namedColors)
+ return namedColors;
+
+ namedColors = [[NSDictionary alloc] initWithObjectsAndKeys:
+ @"#f0f8ff", @"aliceblue",
+ @"#faebd7", @"antiquewhite",
+ @"#00ffff", @"aqua",
+ @"#7fffd4", @"aquamarine",
+ @"#f0ffff", @"azure",
+ @"#f5f5dc", @"beige",
+ @"#ffe4c4", @"bisque",
+ @"#000000", @"black",
+ @"#ffebcd", @"blanchedalmond",
+ @"#0000ff", @"blue",
+ @"#8a2be2", @"blueviolet",
+ @"#a52a2a", @"brown",
+ @"#deb887", @"burlywood",
+ @"#5f9ea0", @"cadetblue",
+ @"#7fff00", @"chartreuse",
+ @"#d2691e", @"chocolate",
+ @"#ff7f50", @"coral",
+ @"#6495ed", @"cornflowerblue",
+ @"#fff8dc", @"cornsilk",
+ @"#dc143c", @"crimson",
+ @"#00ffff", @"cyan",
+ @"#00008b", @"darkblue",
+ @"#008b8b", @"darkcyan",
+ @"#b8860b", @"darkgoldenrod",
+ @"#a9a9a9", @"darkgray",
+ @"#006400", @"darkgreen",
+ @"#bdb76b", @"darkkhaki",
+ @"#8b008b", @"darkmagenta",
+ @"#556b2f", @"darkolivegreen",
+ @"#ff8c00", @"darkorange",
+ @"#9932cc", @"darkorchid",
+ @"#8b0000", @"darkred",
+ @"#e9967a", @"darksalmon",
+ @"#8fbc8f", @"darkseagreen",
+ @"#483d8b", @"darkslateblue",
+ @"#2f4f4f", @"darkslategray",
+ @"#00ced1", @"darkturquoise",
+ @"#9400d3", @"darkviolet",
+ @"#ff1493", @"deeppink",
+ @"#00bfff", @"deepskyblue",
+ @"#696969", @"dimgray",
+ @"#1e90ff", @"dodgerblue",
+ @"#b22222", @"firebrick",
+ @"#fffaf0", @"floralwhite",
+ @"#228b22", @"forestgreen",
+ @"#ff00ff", @"fuchsia",
+ @"#dcdcdc", @"gainsboro",
+ @"#f8f8ff", @"ghostwhite",
+ @"#ffd700", @"gold",
+ @"#daa520", @"goldenrod",
+ @"#808080", @"gray",
+ @"#008000", @"green",
+ @"#adff2f", @"greenyellow",
+ @"#f0fff0", @"honeydew",
+ @"#ff69b4", @"hotpink",
+ @"#cd5c5c", @"indianred ",
+ @"#4b0082", @"indigo ",
+ @"#fffff0", @"ivory",
+ @"#f0e68c", @"khaki",
+ @"#e6e6fa", @"lavender",
+ @"#fff0f5", @"lavenderblush",
+ @"#7cfc00", @"lawngreen",
+ @"#fffacd", @"lemonchiffon",
+ @"#add8e6", @"lightblue",
+ @"#f08080", @"lightcoral",
+ @"#e0ffff", @"lightcyan",
+ @"#fafad2", @"lightgoldenrodyellow",
+ @"#d3d3d3", @"lightgray",
+ @"#90ee90", @"lightgreen",
+ @"#ffb6c1", @"lightpink",
+ @"#ffa07a", @"lightsalmon",
+ @"#20b2aa", @"lightseagreen",
+ @"#87cefa", @"lightskyblue",
+ @"#8470ff", @"lightslateblue",
+ @"#778899", @"lightslategray",
+ @"#b0c4de", @"lightsteelblue",
+ @"#ffffe0", @"lightyellow",
+ @"#00ff00", @"lime",
+ @"#32cd32", @"limegreen",
+ @"#faf0e6", @"linen",
+ @"#ff00ff", @"magenta",
+ @"#800000", @"maroon",
+ @"#66cdaa", @"mediumaquamarine",
+ @"#0000cd", @"mediumblue",
+ @"#ba55d3", @"mediumorchid",
+ @"#9370d8", @"mediumpurple",
+ @"#3cb371", @"mediumseagreen",
+ @"#7b68ee", @"mediumslateblue",
+ @"#00fa9a", @"mediumspringgreen",
+ @"#48d1cc", @"mediumturquoise",
+ @"#c71585", @"mediumvioletred",
+ @"#191970", @"midnightblue",
+ @"#f5fffa", @"mintcream",
+ @"#ffe4e1", @"mistyrose",
+ @"#ffe4b5", @"moccasin",
+ @"#ffdead", @"navajowhite",
+ @"#000080", @"navy",
+ @"#fdf5e6", @"oldlace",
+ @"#808000", @"olive",
+ @"#6b8e23", @"olivedrab",
+ @"#ffa500", @"orange",
+ @"#ff4500", @"orangered",
+ @"#da70d6", @"orchid",
+ @"#eee8aa", @"palegoldenrod",
+ @"#98fb98", @"palegreen",
+ @"#afeeee", @"paleturquoise",
+ @"#d87093", @"palevioletred",
+ @"#ffefd5", @"papayawhip",
+ @"#ffdab9", @"peachpuff",
+ @"#cd853f", @"peru",
+ @"#ffc0cb", @"pink",
+ @"#dda0dd", @"plum",
+ @"#b0e0e6", @"powderblue",
+ @"#800080", @"purple",
+ @"#ff0000", @"red",
+ @"#bc8f8f", @"rosybrown",
+ @"#4169e1", @"royalblue",
+ @"#8b4513", @"saddlebrown",
+ @"#fa8072", @"salmon",
+ @"#f4a460", @"sandybrown",
+ @"#2e8b57", @"seagreen",
+ @"#fff5ee", @"seashell",
+ @"#a0522d", @"sienna",
+ @"#c0c0c0", @"silver",
+ @"#87ceeb", @"skyblue",
+ @"#6a5acd", @"slateblue",
+ @"#708090", @"slategray",
+ @"#fffafa", @"snow",
+ @"#00ff7f", @"springgreen",
+ @"#4682b4", @"steelblue",
+ @"#d2b48c", @"tan",
+ @"#008080", @"teal",
+ @"#d8bfd8", @"thistle",
+ @"#ff6347", @"tomato",
+ @"#40e0d0", @"turquoise",
+ @"#ee82ee", @"violet",
+ @"#d02090", @"violetred",
+ @"#f5deb3", @"wheat",
+ @"#ffffff", @"white",
+ @"#f5f5f5", @"whitesmoke",
+ @"#ffff00", @"yellow",
+ @"#9acd32", @"yellowgreen",
+ nil];
+
+ return namedColors;
+}
QRgb qRgb(int r, int g, int b)
{
return r << 16 | g << 8 | b;
}
-
QRgb qRgba(int r, int g, int b, int a)
{
return a << 24 | r << 16 | g << 8 | b;
}
-
-
QColor::QColor()
{
color = nil;
}
-
QColor::QColor(int r, int g, int b)
{
+ // This function is used during static contructor time, and needs to set up an autorelease pool.
+ createStaticConstructorAutoreleasePool();
+
color = nil;
- if (!globals_init) {
- initGlobalColors();
- }
- else {
- _initialize (r, g, b);
- }
+ setRgb(r, g, b);
}
QColor::QColor(const QString &name)
@@ -71,124 +240,81 @@ QColor::QColor(const QString &name)
QColor::QColor(const char *name)
{
color = nil;
- setNamedColor( QString(name) );
+ setNamedColor(name);
}
-
-void QColor::_initialize(int r, int g, int b)
+QColor::~QColor()
{
- color = [[NSColor colorWithCalibratedRed: ((float)(r)) / (float)255.0
- green: ((float)(g)) / (float)255.0
- blue: ((float)(b)) / (float)255.0
- alpha: 1.0] retain];
-}
-
-
-QColor::~QColor(){
- if (color != nil)
- [color release];
+ [color release];
}
-
QColor::QColor(const QColor ©From)
{
- if (copyFrom.color != nil) {
- color = [copyFrom.color retain];
- }
- else {
- color = nil;
- }
+ color = [copyFrom.color retain];
}
QString QColor::name() const
{
- NSString *name;
-
- name = [NSString stringWithFormat:@"#%02x%02x%02x", red(), green(), blue()];
-
- return NSSTRING_TO_QSTRING(name);
+ return QString::fromNSString([NSString stringWithFormat:@"#%02X%02X%02X", red(), green(), blue()]);
}
-static int hex2int( QChar hexchar )
+static int hex2int(QChar hexchar)
{
int v;
- if ( hexchar.isDigit() )
+
+ if (hexchar.isDigit())
v = hexchar.digitValue();
- else if ( hexchar >= 'A' && hexchar <= 'F' )
+ else if (hexchar >= 'A' && hexchar <= 'F')
v = hexchar.cell() - 'A' + 10;
- else if ( hexchar >= 'a' && hexchar <= 'f' )
+ else if (hexchar >= 'a' && hexchar <= 'f')
v = hexchar.cell() - 'a' + 10;
else
- v = 0;
+ v = -1;
+
return v;
}
-static bool looksLikeSixLetterHexColorString(const QString &string)
+static bool decodeColorFromHexColorString(const QString &string, int *r, int *g, int *b)
{
- bool result;
-
- result = TRUE;
-
- for (int i = 0; i < 6; i++) {
- QChar c = string.at(i);
- if ((c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'f') ||
- (c >= 'A' && c <= 'F')) {
- continue;
- }
- else {
- result = FALSE;
- break;
- }
+ int len = string.length();
+ if (len == 0)
+ return false;
+
+ const QChar *p = string.unicode();
+ if (string[0] == '#') {
+ len -= 1;
+ p += 1;
}
- return result;
-}
-
-static bool decodeColorFromHexColorString(const QString &string, int *r, int *g, int *b)
-{
- bool decoded;
+ for (int i = 0; i < len; i++)
+ if (hex2int(p[i]) == -1)
+ return false;
- decoded = FALSE;
-
- if ((string.length() == 7 && string[0] == '#') ||
- (string.length() == 4 && string[0] == '#') ||
- (string.length() == 6 && looksLikeSixLetterHexColorString(string))) {
- int offset = 0;
- int len;
- if (string[0] == '#') {
- offset = 1;
- len = string.length() - 1;
- }
- else {
- len = string.length();
- }
- const QChar *p = string.unicode() + offset;
- if (len == 12) {
- *r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- *g = (hex2int(p[4]) << 4) + hex2int(p[5]);
- *b = (hex2int(p[8]) << 4) + hex2int(p[9]);
- decoded = TRUE;
- } else if (len == 9) {
- *r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- *g = (hex2int(p[3]) << 4) + hex2int(p[4]);
- *b = (hex2int(p[6]) << 4) + hex2int(p[7]);
- decoded = TRUE;
- } else if (len == 6) {
- *r = (hex2int(p[0]) << 4) + hex2int(p[1]);
- *g = (hex2int(p[2]) << 4) + hex2int(p[3]);
- *b = (hex2int(p[4]) << 4) + hex2int(p[5]);
- decoded = TRUE;
- } else if (len == 3) {
- // Convert 0 to 15, to 0 to 255.
- *r = ROUND_TO_INT((1.0f/15.0f) * hex2int(p[0]) * 255.0f);
- *g = ROUND_TO_INT((1.0f/15.0f) * hex2int(p[1]) * 255.0f);
- *b = ROUND_TO_INT((1.0f/15.0f) * hex2int(p[2]) * 255.0f);
- decoded = TRUE;
- }
+ switch (len) {
+ case 12:
+ *r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ *g = (hex2int(p[4]) << 4) + hex2int(p[5]);
+ *b = (hex2int(p[8]) << 4) + hex2int(p[9]);
+ return true;
+ case 9:
+ *r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ *g = (hex2int(p[3]) << 4) + hex2int(p[4]);
+ *b = (hex2int(p[6]) << 4) + hex2int(p[7]);
+ return true;
+ case 6:
+ *r = (hex2int(p[0]) << 4) + hex2int(p[1]);
+ *g = (hex2int(p[2]) << 4) + hex2int(p[3]);
+ *b = (hex2int(p[4]) << 4) + hex2int(p[5]);
+ return true;
+ case 3:
+ // Convert 0 to F to 0 to 255.
+ *r = hex2int(p[0]) * 0x11;
+ *g = hex2int(p[1]) * 0x11;
+ *b = hex2int(p[2]) * 0x11;
+ return true;
}
- return decoded;
+ return false;
}
void QColor::setNamedColor(const QString &name)
@@ -204,97 +330,79 @@ void QColor::setNamedColor(const QString &name)
int r, g, b;
- r = g = b = 0;
-
- if ( name.isEmpty() ) {
- setRgb( 0 );
+ if (name.isEmpty()) {
+ [color release];
+ color = nil;
}
else if (decodeColorFromHexColorString(name, &r, &g, &b)) {
- setRgb(r, g, b);
+ setRgb(r, g, b);
}
else {
NSString *hexString;
- hexString = [namedColors objectForKey:[QSTRING_TO_NSSTRING(name) lowercaseString]];
+ hexString = [getNamedColors() objectForKey:[QSTRING_TO_NSSTRING(name) lowercaseString]];
if (hexString && decodeColorFromHexColorString(NSSTRING_TO_QSTRING(hexString), &r, &g, &b)) {
setRgb(r, g, b);
}
else {
- KWQDEBUG ("couldn't create color using name %s\n", name.ascii());
- setRgb(0, 0, 0);
+ KWQDEBUG("couldn't create color using name %s", name.ascii());
+ [color release];
+ color = nil;
}
}
}
-
bool QColor::isValid() const
{
- bool result;
-
- result = TRUE;
-
- if (color == nil) {
- result = FALSE;
- }
-
- return result;
+ return color != nil;
}
-
int QColor::red() const
{
if (color == nil)
return 0;
- return (int)([color redComponent] * 255);
+ return (int)(rint([color redComponent] * 255));
}
-
-int QColor::QColor::green() const
+int QColor::green() const
{
if (color == nil)
return 0;
- return (int)([color greenComponent] * 255);
+ return (int)(rint([color greenComponent] * 255));
}
int QColor::blue() const
{
if (color == nil)
return 0;
- return (int)([color blueComponent] * 255);
+ return (int)(rint([color blueComponent] * 255));
}
-
QRgb QColor::rgb() const
{
if (color == nil)
return 0;
- return qRgb (red(),green(),blue());
+ return qRgb(red(),green(),blue());
}
-
void QColor::setRgb(int r, int g, int b)
{
- if (color != nil)
- [color release];
- color = [[NSColor colorWithCalibratedRed: ((float)(r)) / (float)255.0
- green: ((float)(g)) / (float)255.0
- blue: ((float)(b)) / (float)255.0
- alpha: 1.0] retain];
+ [color release];
+ if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
+ color = nil;
+ else
+ color = [[NSColor colorWithCalibratedRed: r / 255.0
+ green: g / 255.0
+ blue: b / 255.0
+ alpha: 1.0] retain];
}
-
void QColor::setRgb(int rgb)
{
- if (color != nil)
- [color release];
- color = [[NSColor colorWithCalibratedRed: ((float)(rgb >> 16)) / 255.0
- green: ((float)(rgb >> 8)) / 255.0
- blue: ((float)(rgb & 0xff)) / 255.0
- alpha: 1.0] retain];
+ setRgb((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF);
}
-
void QColor::hsv(int *h, int *s, int *v) const
{
int r = red();
@@ -402,7 +510,6 @@ QColor QColor::light(int factor) const
return result;
}
-
QColor QColor::dark(int factor) const
{
if (factor <= 0) {
@@ -425,241 +532,29 @@ QColor QColor::dark(int factor) const
return result;
}
-
QColor &QColor::operator=(const QColor &assignFrom)
{
- if ( !globals_init )
- initGlobalColors();
- if (color != assignFrom.color){
- if (color != nil)
- [color release];
- if (assignFrom.color != nil)
- color = [assignFrom.color retain];
- else
- color = nil;
- }
+ [assignFrom.color retain];
+ [color release];
+ color = assignFrom.color;
return *this;
}
-
bool QColor::operator==(const QColor &compareTo) const
{
- return [color isEqual: compareTo.color];
+ if (color == compareTo.color)
+ return true;
+ if (color && compareTo.color)
+ return [color isEqual:compareTo.color];
+ return false;
}
-
bool QColor::operator!=(const QColor &compareTo) const
{
- return !(operator==(compareTo));
+ return !(*this == compareTo);
}
-
-
-
-/*****************************************************************************
- Global colors
- *****************************************************************************/
-
-bool QColor::globals_init = FALSE; // global color not initialized
-
-
-static QColor stdcol[19];
-
-QT_STATIC_CONST_IMPL QColor & Qt::color0 = stdcol[0];
-QT_STATIC_CONST_IMPL QColor & Qt::color1 = stdcol[1];
-QT_STATIC_CONST_IMPL QColor & Qt::black = stdcol[2];
-QT_STATIC_CONST_IMPL QColor & Qt::white = stdcol[3];
-QT_STATIC_CONST_IMPL QColor & Qt::darkGray = stdcol[4];
-QT_STATIC_CONST_IMPL QColor & Qt::gray = stdcol[5];
-QT_STATIC_CONST_IMPL QColor & Qt::lightGray = stdcol[6];
-QT_STATIC_CONST_IMPL QColor & Qt::red = stdcol[7];
-QT_STATIC_CONST_IMPL QColor & Qt::green = stdcol[8];
-QT_STATIC_CONST_IMPL QColor & Qt::blue = stdcol[9];
-QT_STATIC_CONST_IMPL QColor & Qt::cyan = stdcol[10];
-QT_STATIC_CONST_IMPL QColor & Qt::magenta = stdcol[11];
-QT_STATIC_CONST_IMPL QColor & Qt::yellow = stdcol[12];
-QT_STATIC_CONST_IMPL QColor & Qt::darkRed = stdcol[13];
-QT_STATIC_CONST_IMPL QColor & Qt::darkGreen = stdcol[14];
-QT_STATIC_CONST_IMPL QColor & Qt::darkBlue = stdcol[15];
-QT_STATIC_CONST_IMPL QColor & Qt::darkCyan = stdcol[16];
-QT_STATIC_CONST_IMPL QColor & Qt::darkMagenta = stdcol[17];
-QT_STATIC_CONST_IMPL QColor & Qt::darkYellow = stdcol[18];
-
-
-
-void QColor::initGlobalColors()
+NSColor *QColor::getNSColor() const
{
- NSAutoreleasePool *colorPool;
-
- colorPool = [[NSAutoreleasePool allocWithZone:NULL] init];
-
- globals_init = TRUE;
-
- stdcol[ 0].setRgb(255, 255, 255 );
- stdcol[ 1].setRgb( 0, 0, 0 );
- stdcol[ 2].setRgb( 0, 0, 0 );
- stdcol[ 3].setRgb( 255, 255, 255 );
- stdcol[ 4].setRgb( 128, 128, 128 );
- stdcol[ 5].setRgb( 160, 160, 164 );
- stdcol[ 6].setRgb( 192, 192, 192 );
- stdcol[ 7].setRgb( 255, 0, 0 );
- stdcol[ 8].setRgb( 0, 255, 0 );
- stdcol[ 9].setRgb( 0, 0, 255 );
- stdcol[10].setRgb( 0, 255, 255 );
- stdcol[11].setRgb( 255, 0, 255 );
- stdcol[12].setRgb( 255, 255, 0 );
- stdcol[13].setRgb( 128, 0, 0 );
- stdcol[14].setRgb( 0, 128, 0 );
- stdcol[15].setRgb( 0, 0, 128 );
- stdcol[16].setRgb( 0, 128, 128 );
- stdcol[17].setRgb( 128, 0, 128 );
- stdcol[18].setRgb( 128, 128, 0 );
-
- namedColors = [NSDictionary dictionaryWithObjectsAndKeys: \
- @"#f0f8ff",@"aliceblue", \
- @"#faebd7",@"antiquewhite", \
- @"#00ffff",@"aqua", \
- @"#7fffd4",@"aquamarine", \
- @"#f0ffff",@"azure", \
- @"#f5f5dc",@"beige", \
- @"#ffe4c4",@"bisque", \
- @"#000000",@"black", \
- @"#ffebcd",@"blanchedalmond", \
- @"#0000ff",@"blue", \
- @"#8a2be2",@"blueviolet", \
- @"#a52a2a",@"brown", \
- @"#deb887",@"burlywood", \
- @"#5f9ea0",@"cadetblue", \
- @"#7fff00",@"chartreuse", \
- @"#d2691e",@"chocolate", \
- @"#ff7f50",@"coral", \
- @"#6495ed",@"cornflowerblue", \
- @"#fff8dc",@"cornsilk", \
- @"#dc143c",@"crimson", \
- @"#00ffff",@"cyan", \
- @"#00008b",@"darkblue", \
- @"#008b8b",@"darkcyan", \
- @"#b8860b",@"darkgoldenrod", \
- @"#a9a9a9",@"darkgray", \
- @"#006400",@"darkgreen", \
- @"#bdb76b",@"darkkhaki", \
- @"#8b008b",@"darkmagenta", \
- @"#556b2f",@"darkolivegreen", \
- @"#ff8c00",@"darkorange", \
- @"#9932cc",@"darkorchid", \
- @"#8b0000",@"darkred", \
- @"#e9967a",@"darksalmon", \
- @"#8fbc8f",@"darkseagreen", \
- @"#483d8b",@"darkslateblue", \
- @"#2f4f4f",@"darkslategray", \
- @"#00ced1",@"darkturquoise", \
- @"#9400d3",@"darkviolet", \
- @"#ff1493",@"deeppink", \
- @"#00bfff",@"deepskyblue", \
- @"#696969",@"dimgray", \
- @"#1e90ff",@"dodgerblue", \
- @"#b22222",@"firebrick", \
- @"#fffaf0",@"floralwhite", \
- @"#228b22",@"forestgreen", \
- @"#ff00ff",@"fuchsia", \
- @"#dcdcdc",@"gainsboro", \
- @"#f8f8ff",@"ghostwhite", \
- @"#ffd700",@"gold", \
- @"#daa520",@"goldenrod", \
- @"#808080",@"gray", \
- @"#008000",@"green", \
- @"#adff2f",@"greenyellow", \
- @"#f0fff0",@"honeydew", \
- @"#ff69b4",@"hotpink", \
- @"#cd5c5c",@"indianred ", \
- @"#4b0082",@"indigo ", \
- @"#fffff0",@"ivory", \
- @"#f0e68c",@"khaki", \
- @"#e6e6fa",@"lavender", \
- @"#fff0f5",@"lavenderblush", \
- @"#7cfc00",@"lawngreen", \
- @"#fffacd",@"lemonchiffon", \
- @"#add8e6",@"lightblue", \
- @"#f08080",@"lightcoral", \
- @"#e0ffff",@"lightcyan", \
- @"#fafad2",@"lightgoldenrodyellow", \
- @"#d3d3d3",@"lightgray", \
- @"#90ee90",@"lightgreen", \
- @"#ffb6c1",@"lightpink", \
- @"#ffa07a",@"lightsalmon", \
- @"#20b2aa",@"lightseagreen", \
- @"#87cefa",@"lightskyblue", \
- @"#8470ff",@"lightslateblue", \
- @"#778899",@"lightslategray", \
- @"#b0c4de",@"lightsteelblue", \
- @"#ffffe0",@"lightyellow", \
- @"#00ff00",@"lime", \
- @"#32cd32",@"limegreen", \
- @"#faf0e6",@"linen", \
- @"#ff00ff",@"magenta", \
- @"#800000",@"maroon", \
- @"#66cdaa",@"mediumaquamarine", \
- @"#0000cd",@"mediumblue", \
- @"#ba55d3",@"mediumorchid", \
- @"#9370d8",@"mediumpurple", \
- @"#3cb371",@"mediumseagreen", \
- @"#7b68ee",@"mediumslateblue", \
- @"#00fa9a",@"mediumspringgreen", \
- @"#48d1cc",@"mediumturquoise", \
- @"#c71585",@"mediumvioletred", \
- @"#191970",@"midnightblue", \
- @"#f5fffa",@"mintcream", \
- @"#ffe4e1",@"mistyrose", \
- @"#ffe4b5",@"moccasin", \
- @"#ffdead",@"navajowhite", \
- @"#000080",@"navy", \
- @"#fdf5e6",@"oldlace", \
- @"#808000",@"olive", \
- @"#6b8e23",@"olivedrab", \
- @"#ffa500",@"orange", \
- @"#ff4500",@"orangered", \
- @"#da70d6",@"orchid", \
- @"#eee8aa",@"palegoldenrod", \
- @"#98fb98",@"palegreen", \
- @"#afeeee",@"paleturquoise", \
- @"#d87093",@"palevioletred", \
- @"#ffefd5",@"papayawhip", \
- @"#ffdab9",@"peachpuff", \
- @"#cd853f",@"peru", \
- @"#ffc0cb",@"pink", \
- @"#dda0dd",@"plum", \
- @"#b0e0e6",@"powderblue", \
- @"#800080",@"purple", \
- @"#ff0000",@"red", \
- @"#bc8f8f",@"rosybrown", \
- @"#4169e1",@"royalblue", \
- @"#8b4513",@"saddlebrown", \
- @"#fa8072",@"salmon", \
- @"#f4a460",@"sandybrown", \
- @"#2e8b57",@"seagreen", \
- @"#fff5ee",@"seashell", \
- @"#a0522d",@"sienna", \
- @"#c0c0c0",@"silver", \
- @"#87ceeb",@"skyblue", \
- @"#6a5acd",@"slateblue", \
- @"#708090",@"slategray", \
- @"#fffafa",@"snow", \
- @"#00ff7f",@"springgreen", \
- @"#4682b4",@"steelblue", \
- @"#d2b48c",@"tan", \
- @"#008080",@"teal", \
- @"#d8bfd8",@"thistle", \
- @"#ff6347",@"tomato", \
- @"#40e0d0",@"turquoise", \
- @"#ee82ee",@"violet", \
- @"#d02090",@"violetred", \
- @"#f5deb3",@"wheat", \
- @"#ffffff",@"white", \
- @"#f5f5f5",@"whitesmoke", \
- @"#ffff00",@"yellow", \
- @"#9acd32",@"yellowgreen", \
- NULL \
- ];
- [namedColors retain];
+ return color ? color : [[NSColor blackColor] retain];
}
-
diff --git a/WebCore/kwq/KWQCursor.mm b/WebCore/kwq/KWQCursor.mm
index 0a50143..36727f8 100644
--- a/WebCore/kwq/KWQCursor.mm
+++ b/WebCore/kwq/KWQCursor.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,14 +23,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
#include <qcursor.h>
+#include <kwqdebug.h>
-const QCursor & Qt::sizeAllCursor = QCursor();
-const QCursor & Qt::splitHCursor = QCursor();
-const QCursor & Qt::splitVCursor = QCursor();
-const QCursor & Qt::sizeHorCursor = QCursor();
-const QCursor & Qt::sizeVerCursor = QCursor();
+const QCursor Qt::sizeAllCursor;
+const QCursor Qt::splitHCursor;
+const QCursor Qt::splitVCursor;
+const QCursor Qt::sizeHorCursor;
+const QCursor Qt::sizeVerCursor;
QCursor::QCursor()
{
diff --git a/WebCore/kwq/KWQNamespace.h b/WebCore/kwq/KWQNamespace.h
index c1ea43d..58d4991 100644
--- a/WebCore/kwq/KWQNamespace.h
+++ b/WebCore/kwq/KWQNamespace.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,10 +26,6 @@
#ifndef QNAMESPACE_H_
#define QNAMESPACE_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <KWQDef.h>
class QColor;
@@ -37,15 +33,9 @@ class QCursor;
typedef unsigned int QRgb;
-// class Qt ====================================================================
-
class Qt {
public:
- // typedefs ----------------------------------------------------------------
-
- // enums -------------------------------------------------------------------
-
enum ButtonState {
NoButton = 0x0000,
LeftButton = 0x0001,
@@ -65,27 +55,19 @@ public:
AlignLeft = 0x0001,
AlignRight = 0x0002,
AlignHCenter = 0x0004,
- AlignTop = 0x0008,
- AlignBottom = 0x0010,
AlignVCenter = 0x0020,
AlignCenter = AlignVCenter | AlignHCenter,
- SingleLine = 0x0040, // misc. flags
- DontClip = 0x0080,
- ExpandTabs = 0x0100,
+ DontClip = 0x0080, // misc. flags
ShowPrefix = 0x0200,
WordBreak = 0x0400,
- DontPrint = 0x1000 // internal
};
enum PenStyle {
NoPen,
SolidLine,
DotLine,
- DashLine,
- DashDotLine,
- DashDotDotLine,
- MPenStyle = 0x0f
+ DashLine
};
enum BrushStyle {
@@ -244,52 +226,24 @@ public:
XorROP,
};
- enum WidgetFlags {
- WResizeNoErase = 0x00100000,
- WRepaintNoErase = 0x00800000,
- };
-
- // constants ---------------------------------------------------------------
-
-
- QT_STATIC_CONST QColor &color0;
- QT_STATIC_CONST QColor &color1;
- QT_STATIC_CONST QColor &black;
- QT_STATIC_CONST QColor &white;
- QT_STATIC_CONST QColor &darkGray;
- QT_STATIC_CONST QColor &gray;
- QT_STATIC_CONST QColor &lightGray;
- QT_STATIC_CONST QColor &red;
- QT_STATIC_CONST QColor &green;
- QT_STATIC_CONST QColor &blue;
- QT_STATIC_CONST QColor &cyan;
- QT_STATIC_CONST QColor &magenta;
- QT_STATIC_CONST QColor &yellow;
- QT_STATIC_CONST QColor &darkRed;
- QT_STATIC_CONST QColor &darkGreen;
- QT_STATIC_CONST QColor &darkBlue;
- QT_STATIC_CONST QColor &darkCyan;
- QT_STATIC_CONST QColor &darkMagenta;
- QT_STATIC_CONST QColor &darkYellow;
+ static const QColor black;
+ static const QColor white;
+ static const QColor darkGray;
+ static const QColor gray;
+ static const QColor lightGray;
+ static const QColor red;
+ static const QColor green;
+ static const QColor blue;
+ static const QColor cyan;
+ static const QColor magenta;
+ static const QColor yellow;
- static const QCursor &sizeAllCursor;
- static const QCursor &splitHCursor;
- static const QCursor &splitVCursor;
- static const QCursor &sizeHorCursor;
- static const QCursor &sizeVerCursor;
-
- // static member functions -------------------------------------------------
- // constructors, copy constructors, and destructors ------------------------
-
- // member functions --------------------------------------------------------
- // operators ---------------------------------------------------------------
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
-private:
-
+ static const QCursor sizeAllCursor;
+ static const QCursor splitHCursor;
+ static const QCursor splitVCursor;
+ static const QCursor sizeHorCursor;
+ static const QCursor sizeVerCursor;
-}; // class Qt =================================================================
+};
#endif
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 27eafc8..cebf8b1 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,6 +36,16 @@
#import <WebCoreTextRenderer.h>
+struct QPState { // painter state
+ QFont font;
+ QPen pen;
+ QBrush brush;
+ NSCompositingOperation compositingOperation;
+};
+
+typedef QPtrStack<QPState> QPStateStack;
+
+
struct QPainterPrivate {
friend class QPainter;
public:
@@ -46,9 +56,9 @@ public:
qbrush(),
qpen(),
isFocusLocked(0),
- ps_stack(0L),
+ ps_stack(0),
compositingOperation(NSCompositeCopy),
- bufferDevice(0L)
+ bufferDevice(0)
{
}
@@ -60,22 +70,12 @@ private:
QBrush qbrush;
QPen qpen;
uint isFocusLocked:1;
- void *ps_stack;
+ QPStateStack *ps_stack;
NSCompositingOperation compositingOperation;
const QPaintDevice *bufferDevice;
};
-struct QPState { // painter state
- QFont font;
- QPen pen;
- QBrush brush;
- NSCompositingOperation compositingOperation;
-};
-
-typedef QPtrStack<QPState> QPStateStack;
-
-
QPainter::QPainter()
{
_initialize(0);
@@ -167,7 +167,7 @@ QRect QPainter::xForm(const QRect &) const
void QPainter::save()
{
- QPStateStack *pss = (QPStateStack *)data->ps_stack;
+ QPStateStack *pss = data->ps_stack;
if ( pss == 0 ) {
pss = new QPStateStack;
data->ps_stack = pss;
@@ -185,7 +185,7 @@ void QPainter::save()
void QPainter::restore()
{
- QPStateStack *pss = (QPStateStack *)data->ps_stack;
+ QPStateStack *pss = data->ps_stack;
if ( pss == 0 || pss->isEmpty() ) {
KWQDEBUG("ERROR void QPainter::restore() stack is empty\n");
return;
@@ -208,11 +208,11 @@ void QPainter::restore()
void QPainter::drawRect(int x, int y, int w, int h)
{
_lockFocus();
- if (data->qbrush.style() != NoBrush){
+ if (data->qbrush.style() != NoBrush) {
_setColorFromBrush();
[NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
}
- if (data->qpen.style() != NoPen){
+ if (data->qpen.style() != NoPen) {
_setColorFromPen();
[NSBezierPath strokeRect:NSMakeRect(x, y, w, h)];
}
@@ -222,40 +222,64 @@ void QPainter::drawRect(int x, int y, int w, int h)
void QPainter::_setColorFromBrush()
{
- [data->qbrush.color().color set];
+ [data->qbrush.color().getNSColor() set];
}
void QPainter::_setColorFromPen()
{
- [data->qpen.color().color set];
+ [data->qpen.color().getNSColor() set];
}
+// This is only used to draw borders around text, and lines over text.
void QPainter::drawLine(int x1, int y1, int x2, int y2)
{
- _lockFocus();
- _setColorFromPen();
-
- NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
- BOOL flag = [graphicsContext shouldAntialias];
-
- [graphicsContext setShouldAntialias: NO];
-
-#if 0
+ PenStyle penStyle = data->qpen.style();
+ if (penStyle == NoPen)
+ return;
+ float width = data->qpen.width();
+ if (width < 1)
+ width = 1;
+
+ NSPoint p1 = NSMakePoint(x1 + width/2, y1 + width/2);
+ NSPoint p2 = NSMakePoint(x2 + width/2, y2 + width/2);
+
+ // This hack makes sure we don't end up with lines hanging off the ends, while
+ // keeping lines horizontal or vertical.
+ if (x1 != x2)
+ p2.x -= width;
+ if (y1 != y2)
+ p2.y -= width;
+
NSBezierPath *path = [NSBezierPath bezierPath];
- [path setLineWidth:(float)0.1];
- [path moveToPoint:NSMakePoint(x1, y1)];
- [path lineToPoint:NSMakePoint(x2, y2)];
+ [path setLineWidth:width];
+#if 0
+ switch (penStyle) {
+ case NoPen:
+ case SolidLine:
+ break;
+ case DotLine:
+ {
+ const float dottedLine[2] = { 1, 1 };
+ [path setLineDash:dottedLine count:2 phase:0];
+ }
+ break;
+ case DashLine:
+ {
+ const float dashedLine[2] = { 3, 2 };
+ [path setLineDash:dashedLine count:2 phase:0];
+ }
+ break;
+ }
+#endif
+ [path moveToPoint:p1];
+ [path lineToPoint:p2];
[path closePath];
- [path stroke];
-#endif
-
- [NSBezierPath setDefaultLineWidth:1.0f];
- [NSBezierPath strokeLineFromPoint: NSMakePoint (x1,y1-0.5f) toPoint: NSMakePoint (x2,y2-0.5f)];
- [graphicsContext setShouldAntialias: flag];
-
+ _lockFocus();
+ _setColorFromPen();
+ [path stroke];
_unlockFocus();
}
@@ -268,11 +292,11 @@ void QPainter::drawEllipse(int x, int y, int w, int h)
path = [NSBezierPath bezierPathWithOvalInRect: NSMakeRect (x, y, w, h)];
_lockFocus();
- if (data->qbrush.style() != NoBrush){
+ if (data->qbrush.style() != NoBrush) {
_setColorFromBrush();
[path fill];
}
- if (data->qpen.style() != NoPen){
+ if (data->qpen.style() != NoPen) {
_setColorFromPen();
[path stroke];
}
@@ -484,7 +508,7 @@ void QPainter::drawText(int x, int y, const QString &qstring, int len)
[[[WebCoreTextRendererFactory sharedFactory]
rendererWithFamily:data->qfont.getNSFamily() traits:data->qfont.getNSTraits() size:data->qfont.getNSSize()]
- drawCharacters:(const UniChar *)qstring.unicode() length: len atPoint:NSMakePoint(x,y) withColor:data->qpen.color().color];
+ drawCharacters:(const UniChar *)qstring.unicode() length: len atPoint:NSMakePoint(x,y) withColor:data->qpen.color().getNSColor()];
_unlockFocus();
}
@@ -519,7 +543,7 @@ void QPainter::drawUnderlineForText(int x, int y, const QString &qstring, int le
[[[WebCoreTextRendererFactory sharedFactory]
rendererWithFamily:data->qfont.getNSFamily() traits:data->qfont.getNSTraits() size:data->qfont.getNSSize()]
- drawUnderlineForString:string atPoint:NSMakePoint(x,y) withColor:data->qpen.color().color];
+ drawUnderlineForString:string atPoint:NSMakePoint(x,y) withColor:data->qpen.color().getNSColor()];
_unlockFocus();
}
@@ -555,7 +579,7 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString &qs
[[[WebCoreTextRendererFactory sharedFactory]
rendererWithFamily:data->qfont.getNSFamily() traits:data->qfont.getNSTraits() size:data->qfont.getNSSize()]
- drawString:string inRect:NSMakeRect(x, y, w, h) withColor:data->qpen.color().color paragraphStyle:style];
+ drawString:string inRect:NSMakeRect(x, y, w, h) withColor:data->qpen.color().getNSColor() paragraphStyle:style];
_unlockFocus();
}
@@ -565,8 +589,8 @@ void QPainter::drawText(int x, int y, int w, int h, int flags, const QString &qs
void QPainter::fillRect(int x, int y, int w, int h, const QBrush &brush)
{
_lockFocus();
- if (brush.style() == SolidPattern){
- [brush.color().color set];
+ if (brush.style() == SolidPattern) {
+ [brush.color().getNSColor() set];
[NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
}
_unlockFocus();
diff --git a/WebCore/kwq/KWQPen.h b/WebCore/kwq/KWQPen.h
index e944e03..aab7507 100644
--- a/WebCore/kwq/KWQPen.h
+++ b/WebCore/kwq/KWQPen.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,37 +26,13 @@
#ifndef QPEN_H_
#define QPEN_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <qnamespace.h>
#include <qcolor.h>
-class QPainter;
-
-// class QPen ==================================================================
-
class QPen : public Qt {
-friend class QPainter;
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QPen(const QColor &c = Qt::black, uint w = 0, PenStyle ps = SolidLine);
- // defaults are fine
- // QPen(const QPen &pen);
- // ~QPen();
- // QPen &operator=(const QPen &);
-
- // member functions --------------------------------------------------------
-
const QColor &color() const;
uint width() const;
PenStyle style() const;
@@ -65,20 +41,13 @@ public:
void setWidth(uint);
void setStyle(PenStyle);
- // operators ---------------------------------------------------------------
-
bool operator==(const QPen &) const;
bool operator!=(const QPen &) const;
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
private:
-
PenStyle penStyle;
uint penWidth;
QColor penColor;
- Q_UINT16 linest;
-
-}; // class QPen ===============================================================
+};
#endif
diff --git a/WebCore/kwq/KWQPen.mm b/WebCore/kwq/KWQPen.mm
index 1c6d660..e53e545 100644
--- a/WebCore/kwq/KWQPen.mm
+++ b/WebCore/kwq/KWQPen.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,11 +25,10 @@
#include <qpen.h>
-QPen::QPen(const QColor &color, uint width, PenStyle style) : penStyle((PenStyle)(style & MPenStyle)), penWidth(width), penColor(color), linest (style)
+QPen::QPen(const QColor &color, uint width, PenStyle style) : penStyle(style), penWidth(width), penColor(color)
{
}
-
const QColor &QPen::color() const
{
return penColor;
@@ -58,7 +57,6 @@ void QPen::setWidth(uint width)
void QPen::setStyle(PenStyle style)
{
penStyle = style;
- linest = (linest & ~MPenStyle) | style;
}
bool QPen::operator==(const QPen &compareTo) const
@@ -68,10 +66,9 @@ bool QPen::operator==(const QPen &compareTo) const
(penColor == compareTo.penColor);
}
-
bool QPen::operator!=(const QPen &compareTo) const
{
- return !(operator==( compareTo ));
+ return !(*this == compareTo);
}
diff --git a/WebCore/kwq/KWQPixmap.mm b/WebCore/kwq/KWQPixmap.mm
index d68b6c5..ea81af4 100644
--- a/WebCore/kwq/KWQPixmap.mm
+++ b/WebCore/kwq/KWQPixmap.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -43,9 +43,10 @@ QPixmap::QPixmap(const QByteArray &bytes)
{
NSData *data = [[NSData alloc] initWithBytes: bytes.data() length: bytes.size()];
nsimage = [[NSImage alloc] initWithData: data];
- NSArray *reps = [nsimage representations];
- NSImageRep *rep = [reps objectAtIndex: 0];
- [rep setSize:NSMakeSize([rep pixelsWide], [rep pixelsHigh])];
+ NSArray *reps = [nsimage representations];
+ NSImageRep *rep = [reps objectAtIndex: 0];
+ // Force the image to use the pixel size and ignore the dpi.
+ [rep setSize:NSMakeSize([rep pixelsWide], [rep pixelsHigh])];
[data release];
if (nsimage == nil){
KWQDEBUG("unable to create image\n");
diff --git a/WebCore/kwq/qt/qcolor.h b/WebCore/kwq/qt/qcolor.h
index d3d5d37..5dd6583 100644
--- a/WebCore/kwq/qt/qcolor.h
+++ b/WebCore/kwq/qt/qcolor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,35 +26,21 @@
#ifndef QCOLOR_H_
#define QCOLOR_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qnamespace.h>
#include <qstring.h>
#ifdef __OBJC__
-#import <Cocoa/Cocoa.h>
+ at class NSColor;
+#else
+typedef void NSColor;
#endif
-
typedef unsigned int QRgb; // RGB triplet
QRgb qRgb(int r, int g, int b);
QRgb qRgba(int r, int g, int b, int a);
-// class QColor ================================================================
-
class QColor {
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QColor();
QColor(int,int,int);
QColor(const QString &);
@@ -63,8 +49,6 @@ public:
~QColor();
- // member functions --------------------------------------------------------
-
QString name() const;
void setNamedColor(const QString&);
@@ -83,35 +67,14 @@ public:
QColor light(int f = 150) const;
QColor dark(int f = 200) const;
- // operators ---------------------------------------------------------------
-
QColor &operator=(const QColor &);
bool operator==(const QColor &x) const;
bool operator!=(const QColor &x) const;
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
- static bool globals_init;
+ NSColor *getNSColor() const;
- void initGlobalColors();
-
-#ifdef _KWQ_
- void _initialize(int,int,int);
-
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSColor *getNSColor();
-#else
- void *getNSColor();
-#endif
-
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+private:
NSColor *color;
-#else
- void *color;
-#endif
- QString cname;
-#endif
-
-}; // class QColor =============================================================
+};
#endif
diff --git a/WebCore/kwq/qt/qnamespace.h b/WebCore/kwq/qt/qnamespace.h
index c1ea43d..58d4991 100644
--- a/WebCore/kwq/qt/qnamespace.h
+++ b/WebCore/kwq/qt/qnamespace.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,10 +26,6 @@
#ifndef QNAMESPACE_H_
#define QNAMESPACE_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <KWQDef.h>
class QColor;
@@ -37,15 +33,9 @@ class QCursor;
typedef unsigned int QRgb;
-// class Qt ====================================================================
-
class Qt {
public:
- // typedefs ----------------------------------------------------------------
-
- // enums -------------------------------------------------------------------
-
enum ButtonState {
NoButton = 0x0000,
LeftButton = 0x0001,
@@ -65,27 +55,19 @@ public:
AlignLeft = 0x0001,
AlignRight = 0x0002,
AlignHCenter = 0x0004,
- AlignTop = 0x0008,
- AlignBottom = 0x0010,
AlignVCenter = 0x0020,
AlignCenter = AlignVCenter | AlignHCenter,
- SingleLine = 0x0040, // misc. flags
- DontClip = 0x0080,
- ExpandTabs = 0x0100,
+ DontClip = 0x0080, // misc. flags
ShowPrefix = 0x0200,
WordBreak = 0x0400,
- DontPrint = 0x1000 // internal
};
enum PenStyle {
NoPen,
SolidLine,
DotLine,
- DashLine,
- DashDotLine,
- DashDotDotLine,
- MPenStyle = 0x0f
+ DashLine
};
enum BrushStyle {
@@ -244,52 +226,24 @@ public:
XorROP,
};
- enum WidgetFlags {
- WResizeNoErase = 0x00100000,
- WRepaintNoErase = 0x00800000,
- };
-
- // constants ---------------------------------------------------------------
-
-
- QT_STATIC_CONST QColor &color0;
- QT_STATIC_CONST QColor &color1;
- QT_STATIC_CONST QColor &black;
- QT_STATIC_CONST QColor &white;
- QT_STATIC_CONST QColor &darkGray;
- QT_STATIC_CONST QColor &gray;
- QT_STATIC_CONST QColor &lightGray;
- QT_STATIC_CONST QColor &red;
- QT_STATIC_CONST QColor &green;
- QT_STATIC_CONST QColor &blue;
- QT_STATIC_CONST QColor &cyan;
- QT_STATIC_CONST QColor &magenta;
- QT_STATIC_CONST QColor &yellow;
- QT_STATIC_CONST QColor &darkRed;
- QT_STATIC_CONST QColor &darkGreen;
- QT_STATIC_CONST QColor &darkBlue;
- QT_STATIC_CONST QColor &darkCyan;
- QT_STATIC_CONST QColor &darkMagenta;
- QT_STATIC_CONST QColor &darkYellow;
+ static const QColor black;
+ static const QColor white;
+ static const QColor darkGray;
+ static const QColor gray;
+ static const QColor lightGray;
+ static const QColor red;
+ static const QColor green;
+ static const QColor blue;
+ static const QColor cyan;
+ static const QColor magenta;
+ static const QColor yellow;
- static const QCursor &sizeAllCursor;
- static const QCursor &splitHCursor;
- static const QCursor &splitVCursor;
- static const QCursor &sizeHorCursor;
- static const QCursor &sizeVerCursor;
-
- // static member functions -------------------------------------------------
- // constructors, copy constructors, and destructors ------------------------
-
- // member functions --------------------------------------------------------
- // operators ---------------------------------------------------------------
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
-
-private:
-
+ static const QCursor sizeAllCursor;
+ static const QCursor splitHCursor;
+ static const QCursor splitVCursor;
+ static const QCursor sizeHorCursor;
+ static const QCursor sizeVerCursor;
-}; // class Qt =================================================================
+};
#endif
diff --git a/WebCore/kwq/qt/qpen.h b/WebCore/kwq/qt/qpen.h
index e944e03..aab7507 100644
--- a/WebCore/kwq/qt/qpen.h
+++ b/WebCore/kwq/qt/qpen.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,37 +26,13 @@
#ifndef QPEN_H_
#define QPEN_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <qnamespace.h>
#include <qcolor.h>
-class QPainter;
-
-// class QPen ==================================================================
-
class QPen : public Qt {
-friend class QPainter;
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QPen(const QColor &c = Qt::black, uint w = 0, PenStyle ps = SolidLine);
- // defaults are fine
- // QPen(const QPen &pen);
- // ~QPen();
- // QPen &operator=(const QPen &);
-
- // member functions --------------------------------------------------------
-
const QColor &color() const;
uint width() const;
PenStyle style() const;
@@ -65,20 +41,13 @@ public:
void setWidth(uint);
void setStyle(PenStyle);
- // operators ---------------------------------------------------------------
-
bool operator==(const QPen &) const;
bool operator!=(const QPen &) const;
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
private:
-
PenStyle penStyle;
uint penWidth;
QColor penColor;
- Q_UINT16 linest;
-
-}; // class QPen ===============================================================
+};
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list