[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:50:27 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit afbded4ac73f9d2f7a075e54f8b289c41b0cb184
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 16 21:58:16 2001 +0000

    Implemented KWQTextArea that has all the functionality we need for the <TEXTAREA> widget.  KWQTextEdit.mm emulates the kde/Qt APIs and passes call through to KWQTextArea.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@331 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/kwq/KWQComboBox.mm b/WebCore/kwq/KWQComboBox.mm
index ae3c938..b368b3a 100644
--- a/WebCore/kwq/KWQComboBox.mm
+++ b/WebCore/kwq/KWQComboBox.mm
@@ -48,6 +48,7 @@ void QComboBox::init(bool isEditable)
     comboBox = [[[KWQNSComboBox alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this] autorelease];
     if (isEditable == FALSE)
         [comboBox setEditable: NO];
+    setView (comboBox);
 }
 
 
diff --git a/WebCore/kwq/KWQScrollView.mm b/WebCore/kwq/KWQScrollView.mm
index 51d0783..1536026 100644
--- a/WebCore/kwq/KWQScrollView.mm
+++ b/WebCore/kwq/KWQScrollView.mm
@@ -27,6 +27,15 @@
 
 #include <kwqdebug.h>
 
+/*
+    This class implementation does NOT actually emulate the Qt QScrollView.
+    Instead out WebPageView, like any other NSView can be set as the document
+    to a standard NSScrollView.
+
+    We do implement the placeWidget() function to essentially addSubview views
+    onto this view.
+*/
+
 QScrollView::QScrollView(QWidget *parent=0, const char *name=0, WFlags f=0)
 {
     _logNeverImplemented();
diff --git a/WebCore/kwq/KWQKProcess.mm b/WebCore/kwq/KWQTextArea.h
similarity index 71%
copy from WebCore/kwq/KWQKProcess.mm
copy to WebCore/kwq/KWQTextArea.h
index 1d4d7d3..0d32f84 100644
--- a/WebCore/kwq/KWQKProcess.mm
+++ b/WebCore/kwq/KWQTextArea.h
@@ -22,52 +22,43 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
+ 
+#import <Cocoa/Cocoa.h>
 
-#include <kprocess.h>
 
-KProcess::KProcess()
-{
-}
-
-
-KProcess::~KProcess()
-{
-}
-
-
-QStrList *KProcess::args()
-{
-}
+class QWidget;
 
 
-bool KProcess::isRunning() const
+ at interface KWQTextArea : NSScrollView
 {
+    NSTextView *textView;
+    QWidget *widget;
+    BOOL wrap;
 }
+- initWithFrame: (NSRect)r widget: (QWidget *)w; 
 
+// The following methods corresponds to methods required by KDE.
+- (void) setWordWrap: (BOOL)f;
 
-bool KProcess::writeStdin(const char *buffer, int buflen)
-{
-}
+- (BOOL) wordWrap;
 
+- (BOOL) isReadOnly;
 
-bool KProcess::start(RunMode runmode, Communication comm)
-{
-}
+- (void) setReadOnly: (BOOL)flag;
 
+- (void) setText: (NSString *)s;
 
-bool KProcess::kill(int signo=SIGTERM)
-{
-}
+- (NSString *)text;
 
+- (NSString *)textForLine: (int)line;
 
-void KProcess::resume()
-{
-}
+- (int) numLines;
 
+- (void) selectAll;
 
-KProcess &KProcess::operator<<(const QString& arg)
-{
-}
+- (void) setEditable: (BOOL)flag;
 
+- (BOOL)isEditable;
 
 
+ at end
diff --git a/WebCore/kwq/KWQTextArea.mm b/WebCore/kwq/KWQTextArea.mm
new file mode 100644
index 0000000..da39dda
--- /dev/null
+++ b/WebCore/kwq/KWQTextArea.mm
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2001 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#import <qwidget.h>
+
+#import <KWQTextArea.h>
+
+/*
+    This widget is used to implement the <TEXTAREA> element.
+    
+    It has a small set of features required by the definition of the <TEXTAREA>
+    element.  
+    
+    It support the three wierd WRAP modes:
+    
+              OFF - Text is not wrapped.  It is kept to single line, although if
+                    the user enters a return the line IS broken.  This emulates
+                    Mac IE 5.1.
+     SOFT|VIRUTAL - Text is wrapped, but not actually broken.  [text] sends text
+                    as typed by user.
+    HARD|PHYSICAL - Text is wrapped, and text is broken into seperate lines.  [text]
+                    returns broken text.
+                    
+    kde expects a line based widget.  It uses a line API to convert text into multiple lines
+    when wrapping is set to HARD.  To support kde with implement [textLine] and [numLines].
+*/
+
+
+ at implementation KWQTextArea
+
+const float LargeNumberForText = 1.0e7;
+
+- initWithFrame: (NSRect) r widget: (QWidget *)w 
+{
+    NSDictionary *attr;
+    NSMutableParagraphStyle *style = [[[NSMutableParagraphStyle alloc] init] autorelease];
+    NSRect textFrame;
+
+    [super initWithFrame: r];
+
+    [self setHasVerticalScroller: YES];
+    [self setHasHorizontalScroller: NO];
+
+    textFrame.origin.x = textFrame.origin.y = 0;
+    textFrame.size = [NSScrollView contentSizeForFrameSize:r.size hasHorizontalScroller:NO hasVerticalScroller:YES borderType: [self borderType]];
+
+    textView = [[NSTextView alloc] initWithFrame: textFrame];
+    [[textView textContainer] setWidthTracksTextView: NO];
+    
+    // Setup attributes for default cases WRAP=SOFT|VIRTUAL and WRAP=HARD|PHYSICAL.
+    // If WRAP=OFF we reset many of these attributes.
+    [style setLineBreakMode: NSLineBreakByWordWrapping];
+    [style setAlignment: NSLeftTextAlignment];
+    attr = [NSDictionary dictionaryWithObjectsAndKeys: style, NSParagraphStyleAttributeName, nil];
+    [textView setTypingAttributes: attr];
+
+    [self setDocumentView: textView];
+    
+    widget = w;
+}
+
+
+- (void) setWordWrap: (BOOL)f
+{
+    if (f == wrap)
+        return;
+        
+    NSDictionary *attr;
+    NSMutableParagraphStyle *style = [[[NSMutableParagraphStyle alloc] init] autorelease];
+    
+    if (f){
+        [self setHasHorizontalScroller: NO];
+        [textView setHorizontallyResizable: NO];
+        [[textView textContainer] setWidthTracksTextView: NO];
+        [style setLineBreakMode: NSLineBreakByWordWrapping];
+    }
+    else {
+        [self setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+        [[self contentView] setAutoresizesSubviews:YES];
+        [self setHasHorizontalScroller: YES];
+
+        [[textView textContainer] setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+        [[textView textContainer] setWidthTracksTextView:NO];
+        [[textView textContainer] setHeightTracksTextView:NO];
+
+        [textView setMinSize: [textView frame].size];
+        [textView setMaxSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+        [textView setHorizontallyResizable: YES];
+
+        [style setLineBreakMode: NSLineBreakByClipping];
+    }
+    
+    [style setAlignment: NSLeftTextAlignment];
+    attr = [NSDictionary dictionaryWithObjectsAndKeys: style, NSParagraphStyleAttributeName, nil];
+    
+    [textView setMaxSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+    [textView setTypingAttributes: attr];
+    
+    wrap = f;
+}
+
+
+- (BOOL) wordWrap
+{
+    return wrap;
+}
+
+
+- (BOOL) isReadOnly
+{
+    return [textView isEditable];
+}
+
+
+- (void) setReadOnly: (BOOL)flag
+{
+    return [textView setEditable: flag];
+}
+
+- (void) setText: (NSString *)s
+{
+    [textView setString: s];
+}
+
+
+- (NSString *)text
+{
+    return [textView string];
+}
+
+
+- (NSString *)textForLine: (int)line
+{
+    NSRange glyphRange = NSMakeRange(0,0), characterRange;
+    int lineCount = 0;
+    NSString *stringLine;
+    NSLayoutManager *layoutManager = [textView layoutManager];
+    unsigned numberOfGlyphs = [layoutManager numberOfGlyphs];
+    
+    while (NSMaxRange(glyphRange) < numberOfGlyphs) {
+        (void)[layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(glyphRange) effectiveRange:&glyphRange];
+        characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
+        if (line == lineCount){
+            // I hope this works, the alternative is
+            // [[view string] substringWithRange: characterRange]
+            stringLine = [[[textView textStorage] attributedSubstringFromRange: characterRange] string];
+            return stringLine;
+        }
+        lineCount++;
+    }
+    return @"";
+}
+
+
+- (int) numLines
+{
+    NSRange glyphRange = NSMakeRange(0,0);
+    NSLayoutManager *layoutManager = [textView layoutManager];
+    unsigned numberOfGlyphs = [layoutManager numberOfGlyphs];
+    int lineCount = 0;
+    
+    while (NSMaxRange(glyphRange) < numberOfGlyphs) {
+        (void)[layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(glyphRange) effectiveRange:&glyphRange];
+        lineCount++;
+    }
+    return lineCount;
+}
+
+
+- (void) selectAll
+{
+    [textView setSelectedRange: NSMakeRange(0, [[textView textStorage] length])];
+}
+
+
+- (void) setEditable: (BOOL)flag
+{
+    [textView setEditable: flag];
+}
+
+
+- (BOOL)isEditable
+{
+    return [textView isEditable];
+}
+
+
+
+ at end
+
diff --git a/WebCore/kwq/KWQTextEdit.mm b/WebCore/kwq/KWQTextEdit.mm
index 105b9f8..f434f52 100644
--- a/WebCore/kwq/KWQTextEdit.mm
+++ b/WebCore/kwq/KWQTextEdit.mm
@@ -26,142 +26,184 @@
 
 #include <keditcl.h>
 
+#import <KWQTextArea.h>
+
+
+// RenderTextArea actually uses a TextAreaWidget->KEdit->QMultiLineEdit->QTableView
 
 QTableView::QTableView()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
 QTableView::~QTableView()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
 QScrollBar *QTableView::verticalScrollBar() const
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 QScrollBar *QTableView::horizontalScrollBar() const
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 void QTableView::setTableFlags(uint)
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 void QTableView::clearTableFlags(uint f = ~0)
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 QMultiLineEdit::QMultiLineEdit()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
 QMultiLineEdit::~QMultiLineEdit()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
-void QMultiLineEdit::setWordWrap(WordWrap)
+void QMultiLineEdit::setWordWrap(WordWrap f)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+
+    if (f == QMultiLineEdit::WidgetWidth)
+        [textView setWordWrap: TRUE];
+    else
+        [textView setWordWrap: FALSE];
 }
 
 
 QMultiLineEdit::WordWrap QMultiLineEdit::wordWrap() const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    if ([textView wordWrap])
+        return QMultiLineEdit::WidgetWidth;
+    return QMultiLineEdit::NoWrap;
 }
 
 
 bool QMultiLineEdit::hasMarkedText() const
 {
-    _logNotYetImplemented();
+    // We can safely ignore this method.
+    _logNeverImplemented();
+    return false;
 }
 
 
 bool QMultiLineEdit::isReadOnly() const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return [textView isEditable];
 }
 
 
-void QMultiLineEdit::setReadOnly(bool)
+void QMultiLineEdit::setReadOnly(bool flag)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+
+    [textView setEditable: (BOOL)flag];
 }
 
 
 void QMultiLineEdit::setCursorPosition(int line, int col, bool mark = FALSE)
 {
-    _logNotYetImplemented();
+    // We can safely ignore this method.
+    _logNeverImplemented();
 }
 
 
 void QMultiLineEdit::getCursorPosition(int *line, int *col) const
 {
-    _logNotYetImplemented();
+    // We can safely ignore this method.
+    _logNeverImplemented();
 }
 
 
-void QMultiLineEdit::setText(const QString &)
+void QMultiLineEdit::setText(const QString &string)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    [textView setText: QSTRING_TO_NSSTRING (string)];
 }
 
 
 QString QMultiLineEdit::text()
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return NSSTRING_TO_QSTRING ([textView text]);
 }
 
 
 QString QMultiLineEdit::textLine(int line) const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return NSSTRING_TO_QSTRING([textView textForLine: line]);
 }
 
 
 int QMultiLineEdit::numLines() const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return [textView numLines];
 }
 
 
 void QMultiLineEdit::selectAll()
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    [textView selectAll];
 }
 
 
 KEdit::KEdit()
 {
-    _logNotYetImplemented();
+    _logNeverImplemented();
 }
 
 
-KEdit::KEdit(QWidget *)
+KEdit::KEdit(QWidget *w)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView;
+    
+    textView = [[KWQTextArea alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this];
+    setView (textView);
+    [textView release];
 }
 
 
 KEdit::~KEdit()
 {
-    _logNotYetImplemented();
 }
 
 
diff --git a/WebCore/kwq/KWQView.h b/WebCore/kwq/KWQView.h
index 7b83bad..d22c9d9 100644
--- a/WebCore/kwq/KWQView.h
+++ b/WebCore/kwq/KWQView.h
@@ -1,3 +1,28 @@
+/*
+ * Copyright (C) 2001 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+ 
 #import <Cocoa/Cocoa.h>
 
 
@@ -33,3 +58,6 @@ class QWidget;
 - initWithFrame: (NSRect)r widget: (QWidget *)w; 
 @end
 
+
+
+
diff --git a/WebCore/kwq/KWQView.mm b/WebCore/kwq/KWQView.mm
index 264cf33..9303fdc 100644
--- a/WebCore/kwq/KWQView.mm
+++ b/WebCore/kwq/KWQView.mm
@@ -1,3 +1,27 @@
+/*
+ * Copyright (C) 2001 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
 #import "KWQView.h"
 
 #import <qwidget.h>
diff --git a/WebCore/kwq/Makefile.in b/WebCore/kwq/Makefile.in
index b981dd4..142d491 100644
--- a/WebCore/kwq/Makefile.in
+++ b/WebCore/kwq/Makefile.in
@@ -108,6 +108,7 @@ MMOBJECTS = \
 	KWQScrollView.o \
 	KWQStyle.o \
 	KWQTextEdit.o \
+	KWQTextArea.o \
 	KWQTimer.o \
 	KWQToolTip.o \
 	KWQVariant.o \
diff --git a/WebCore/kwq/kdeui/keditcl.h b/WebCore/kwq/kdeui/keditcl.h
index 9b21ea0..02458ab 100644
--- a/WebCore/kwq/kdeui/keditcl.h
+++ b/WebCore/kwq/kdeui/keditcl.h
@@ -98,9 +98,7 @@ public:
 
     enum WordWrap {
         NoWrap,
-        WidgetWidth,
-        FixedPixelWidth,
-        FixedColumnWidth
+        WidgetWidth
     };    
 
     // typedefs ----------------------------------------------------------------
diff --git a/WebCore/src/kwq/KWQComboBox.mm b/WebCore/src/kwq/KWQComboBox.mm
index ae3c938..b368b3a 100644
--- a/WebCore/src/kwq/KWQComboBox.mm
+++ b/WebCore/src/kwq/KWQComboBox.mm
@@ -48,6 +48,7 @@ void QComboBox::init(bool isEditable)
     comboBox = [[[KWQNSComboBox alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this] autorelease];
     if (isEditable == FALSE)
         [comboBox setEditable: NO];
+    setView (comboBox);
 }
 
 
diff --git a/WebCore/src/kwq/KWQScrollView.mm b/WebCore/src/kwq/KWQScrollView.mm
index 51d0783..1536026 100644
--- a/WebCore/src/kwq/KWQScrollView.mm
+++ b/WebCore/src/kwq/KWQScrollView.mm
@@ -27,6 +27,15 @@
 
 #include <kwqdebug.h>
 
+/*
+    This class implementation does NOT actually emulate the Qt QScrollView.
+    Instead out WebPageView, like any other NSView can be set as the document
+    to a standard NSScrollView.
+
+    We do implement the placeWidget() function to essentially addSubview views
+    onto this view.
+*/
+
 QScrollView::QScrollView(QWidget *parent=0, const char *name=0, WFlags f=0)
 {
     _logNeverImplemented();
diff --git a/WebCore/kwq/KWQKProcess.mm b/WebCore/src/kwq/KWQTextArea.h
similarity index 71%
copy from WebCore/kwq/KWQKProcess.mm
copy to WebCore/src/kwq/KWQTextArea.h
index 1d4d7d3..0d32f84 100644
--- a/WebCore/kwq/KWQKProcess.mm
+++ b/WebCore/src/kwq/KWQTextArea.h
@@ -22,52 +22,43 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
+ 
+#import <Cocoa/Cocoa.h>
 
-#include <kprocess.h>
 
-KProcess::KProcess()
-{
-}
-
-
-KProcess::~KProcess()
-{
-}
-
-
-QStrList *KProcess::args()
-{
-}
+class QWidget;
 
 
-bool KProcess::isRunning() const
+ at interface KWQTextArea : NSScrollView
 {
+    NSTextView *textView;
+    QWidget *widget;
+    BOOL wrap;
 }
+- initWithFrame: (NSRect)r widget: (QWidget *)w; 
 
+// The following methods corresponds to methods required by KDE.
+- (void) setWordWrap: (BOOL)f;
 
-bool KProcess::writeStdin(const char *buffer, int buflen)
-{
-}
+- (BOOL) wordWrap;
 
+- (BOOL) isReadOnly;
 
-bool KProcess::start(RunMode runmode, Communication comm)
-{
-}
+- (void) setReadOnly: (BOOL)flag;
 
+- (void) setText: (NSString *)s;
 
-bool KProcess::kill(int signo=SIGTERM)
-{
-}
+- (NSString *)text;
 
+- (NSString *)textForLine: (int)line;
 
-void KProcess::resume()
-{
-}
+- (int) numLines;
 
+- (void) selectAll;
 
-KProcess &KProcess::operator<<(const QString& arg)
-{
-}
+- (void) setEditable: (BOOL)flag;
 
+- (BOOL)isEditable;
 
 
+ at end
diff --git a/WebCore/src/kwq/KWQTextArea.mm b/WebCore/src/kwq/KWQTextArea.mm
new file mode 100644
index 0000000..da39dda
--- /dev/null
+++ b/WebCore/src/kwq/KWQTextArea.mm
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2001 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#import <qwidget.h>
+
+#import <KWQTextArea.h>
+
+/*
+    This widget is used to implement the <TEXTAREA> element.
+    
+    It has a small set of features required by the definition of the <TEXTAREA>
+    element.  
+    
+    It support the three wierd WRAP modes:
+    
+              OFF - Text is not wrapped.  It is kept to single line, although if
+                    the user enters a return the line IS broken.  This emulates
+                    Mac IE 5.1.
+     SOFT|VIRUTAL - Text is wrapped, but not actually broken.  [text] sends text
+                    as typed by user.
+    HARD|PHYSICAL - Text is wrapped, and text is broken into seperate lines.  [text]
+                    returns broken text.
+                    
+    kde expects a line based widget.  It uses a line API to convert text into multiple lines
+    when wrapping is set to HARD.  To support kde with implement [textLine] and [numLines].
+*/
+
+
+ at implementation KWQTextArea
+
+const float LargeNumberForText = 1.0e7;
+
+- initWithFrame: (NSRect) r widget: (QWidget *)w 
+{
+    NSDictionary *attr;
+    NSMutableParagraphStyle *style = [[[NSMutableParagraphStyle alloc] init] autorelease];
+    NSRect textFrame;
+
+    [super initWithFrame: r];
+
+    [self setHasVerticalScroller: YES];
+    [self setHasHorizontalScroller: NO];
+
+    textFrame.origin.x = textFrame.origin.y = 0;
+    textFrame.size = [NSScrollView contentSizeForFrameSize:r.size hasHorizontalScroller:NO hasVerticalScroller:YES borderType: [self borderType]];
+
+    textView = [[NSTextView alloc] initWithFrame: textFrame];
+    [[textView textContainer] setWidthTracksTextView: NO];
+    
+    // Setup attributes for default cases WRAP=SOFT|VIRTUAL and WRAP=HARD|PHYSICAL.
+    // If WRAP=OFF we reset many of these attributes.
+    [style setLineBreakMode: NSLineBreakByWordWrapping];
+    [style setAlignment: NSLeftTextAlignment];
+    attr = [NSDictionary dictionaryWithObjectsAndKeys: style, NSParagraphStyleAttributeName, nil];
+    [textView setTypingAttributes: attr];
+
+    [self setDocumentView: textView];
+    
+    widget = w;
+}
+
+
+- (void) setWordWrap: (BOOL)f
+{
+    if (f == wrap)
+        return;
+        
+    NSDictionary *attr;
+    NSMutableParagraphStyle *style = [[[NSMutableParagraphStyle alloc] init] autorelease];
+    
+    if (f){
+        [self setHasHorizontalScroller: NO];
+        [textView setHorizontallyResizable: NO];
+        [[textView textContainer] setWidthTracksTextView: NO];
+        [style setLineBreakMode: NSLineBreakByWordWrapping];
+    }
+    else {
+        [self setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+        [[self contentView] setAutoresizesSubviews:YES];
+        [self setHasHorizontalScroller: YES];
+
+        [[textView textContainer] setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+        [[textView textContainer] setWidthTracksTextView:NO];
+        [[textView textContainer] setHeightTracksTextView:NO];
+
+        [textView setMinSize: [textView frame].size];
+        [textView setMaxSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+        [textView setHorizontallyResizable: YES];
+
+        [style setLineBreakMode: NSLineBreakByClipping];
+    }
+    
+    [style setAlignment: NSLeftTextAlignment];
+    attr = [NSDictionary dictionaryWithObjectsAndKeys: style, NSParagraphStyleAttributeName, nil];
+    
+    [textView setMaxSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+    [textView setTypingAttributes: attr];
+    
+    wrap = f;
+}
+
+
+- (BOOL) wordWrap
+{
+    return wrap;
+}
+
+
+- (BOOL) isReadOnly
+{
+    return [textView isEditable];
+}
+
+
+- (void) setReadOnly: (BOOL)flag
+{
+    return [textView setEditable: flag];
+}
+
+- (void) setText: (NSString *)s
+{
+    [textView setString: s];
+}
+
+
+- (NSString *)text
+{
+    return [textView string];
+}
+
+
+- (NSString *)textForLine: (int)line
+{
+    NSRange glyphRange = NSMakeRange(0,0), characterRange;
+    int lineCount = 0;
+    NSString *stringLine;
+    NSLayoutManager *layoutManager = [textView layoutManager];
+    unsigned numberOfGlyphs = [layoutManager numberOfGlyphs];
+    
+    while (NSMaxRange(glyphRange) < numberOfGlyphs) {
+        (void)[layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(glyphRange) effectiveRange:&glyphRange];
+        characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
+        if (line == lineCount){
+            // I hope this works, the alternative is
+            // [[view string] substringWithRange: characterRange]
+            stringLine = [[[textView textStorage] attributedSubstringFromRange: characterRange] string];
+            return stringLine;
+        }
+        lineCount++;
+    }
+    return @"";
+}
+
+
+- (int) numLines
+{
+    NSRange glyphRange = NSMakeRange(0,0);
+    NSLayoutManager *layoutManager = [textView layoutManager];
+    unsigned numberOfGlyphs = [layoutManager numberOfGlyphs];
+    int lineCount = 0;
+    
+    while (NSMaxRange(glyphRange) < numberOfGlyphs) {
+        (void)[layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(glyphRange) effectiveRange:&glyphRange];
+        lineCount++;
+    }
+    return lineCount;
+}
+
+
+- (void) selectAll
+{
+    [textView setSelectedRange: NSMakeRange(0, [[textView textStorage] length])];
+}
+
+
+- (void) setEditable: (BOOL)flag
+{
+    [textView setEditable: flag];
+}
+
+
+- (BOOL)isEditable
+{
+    return [textView isEditable];
+}
+
+
+
+ at end
+
diff --git a/WebCore/src/kwq/KWQTextEdit.mm b/WebCore/src/kwq/KWQTextEdit.mm
index 105b9f8..f434f52 100644
--- a/WebCore/src/kwq/KWQTextEdit.mm
+++ b/WebCore/src/kwq/KWQTextEdit.mm
@@ -26,142 +26,184 @@
 
 #include <keditcl.h>
 
+#import <KWQTextArea.h>
+
+
+// RenderTextArea actually uses a TextAreaWidget->KEdit->QMultiLineEdit->QTableView
 
 QTableView::QTableView()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
 QTableView::~QTableView()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
 QScrollBar *QTableView::verticalScrollBar() const
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 QScrollBar *QTableView::horizontalScrollBar() const
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 void QTableView::setTableFlags(uint)
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 void QTableView::clearTableFlags(uint f = ~0)
 {
-    _logNotYetImplemented();
+    // Nothing needed.
+    _logNeverImplemented();
 }
 
 
 QMultiLineEdit::QMultiLineEdit()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
 QMultiLineEdit::~QMultiLineEdit()
 {
+    // Nothing needed.
     _logNotYetImplemented();
 }
 
 
-void QMultiLineEdit::setWordWrap(WordWrap)
+void QMultiLineEdit::setWordWrap(WordWrap f)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+
+    if (f == QMultiLineEdit::WidgetWidth)
+        [textView setWordWrap: TRUE];
+    else
+        [textView setWordWrap: FALSE];
 }
 
 
 QMultiLineEdit::WordWrap QMultiLineEdit::wordWrap() const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    if ([textView wordWrap])
+        return QMultiLineEdit::WidgetWidth;
+    return QMultiLineEdit::NoWrap;
 }
 
 
 bool QMultiLineEdit::hasMarkedText() const
 {
-    _logNotYetImplemented();
+    // We can safely ignore this method.
+    _logNeverImplemented();
+    return false;
 }
 
 
 bool QMultiLineEdit::isReadOnly() const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return [textView isEditable];
 }
 
 
-void QMultiLineEdit::setReadOnly(bool)
+void QMultiLineEdit::setReadOnly(bool flag)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+
+    [textView setEditable: (BOOL)flag];
 }
 
 
 void QMultiLineEdit::setCursorPosition(int line, int col, bool mark = FALSE)
 {
-    _logNotYetImplemented();
+    // We can safely ignore this method.
+    _logNeverImplemented();
 }
 
 
 void QMultiLineEdit::getCursorPosition(int *line, int *col) const
 {
-    _logNotYetImplemented();
+    // We can safely ignore this method.
+    _logNeverImplemented();
 }
 
 
-void QMultiLineEdit::setText(const QString &)
+void QMultiLineEdit::setText(const QString &string)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    [textView setText: QSTRING_TO_NSSTRING (string)];
 }
 
 
 QString QMultiLineEdit::text()
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return NSSTRING_TO_QSTRING ([textView text]);
 }
 
 
 QString QMultiLineEdit::textLine(int line) const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return NSSTRING_TO_QSTRING([textView textForLine: line]);
 }
 
 
 int QMultiLineEdit::numLines() const
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    return [textView numLines];
 }
 
 
 void QMultiLineEdit::selectAll()
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView = (KWQTextArea *)getView();
+    
+    [textView selectAll];
 }
 
 
 KEdit::KEdit()
 {
-    _logNotYetImplemented();
+    _logNeverImplemented();
 }
 
 
-KEdit::KEdit(QWidget *)
+KEdit::KEdit(QWidget *w)
 {
-    _logNotYetImplemented();
+    KWQTextArea *textView;
+    
+    textView = [[KWQTextArea alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this];
+    setView (textView);
+    [textView release];
 }
 
 
 KEdit::~KEdit()
 {
-    _logNotYetImplemented();
 }
 
 
diff --git a/WebCore/src/kwq/KWQView.h b/WebCore/src/kwq/KWQView.h
index 7b83bad..d22c9d9 100644
--- a/WebCore/src/kwq/KWQView.h
+++ b/WebCore/src/kwq/KWQView.h
@@ -1,3 +1,28 @@
+/*
+ * Copyright (C) 2001 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+ 
 #import <Cocoa/Cocoa.h>
 
 
@@ -33,3 +58,6 @@ class QWidget;
 - initWithFrame: (NSRect)r widget: (QWidget *)w; 
 @end
 
+
+
+
diff --git a/WebCore/src/kwq/KWQView.mm b/WebCore/src/kwq/KWQView.mm
index 264cf33..9303fdc 100644
--- a/WebCore/src/kwq/KWQView.mm
+++ b/WebCore/src/kwq/KWQView.mm
@@ -1,3 +1,27 @@
+/*
+ * Copyright (C) 2001 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
 #import "KWQView.h"
 
 #import <qwidget.h>
diff --git a/WebCore/src/kwq/Makefile.in b/WebCore/src/kwq/Makefile.in
index b981dd4..142d491 100644
--- a/WebCore/src/kwq/Makefile.in
+++ b/WebCore/src/kwq/Makefile.in
@@ -108,6 +108,7 @@ MMOBJECTS = \
 	KWQScrollView.o \
 	KWQStyle.o \
 	KWQTextEdit.o \
+	KWQTextArea.o \
 	KWQTimer.o \
 	KWQToolTip.o \
 	KWQVariant.o \
diff --git a/WebCore/src/kwq/kdeui/keditcl.h b/WebCore/src/kwq/kdeui/keditcl.h
index 9b21ea0..02458ab 100644
--- a/WebCore/src/kwq/kdeui/keditcl.h
+++ b/WebCore/src/kwq/kdeui/keditcl.h
@@ -98,9 +98,7 @@ public:
 
     enum WordWrap {
         NoWrap,
-        WidgetWidth,
-        FixedPixelWidth,
-        FixedColumnWidth
+        WidgetWidth
     };    
 
     // typedefs ----------------------------------------------------------------

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list