[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:16 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit cbb01105fcab48a5819b60eba644d60fcfa63dab
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Oct 12 20:02:18 2001 +0000
Added textfield to support input type password and maxlength attribute.
Implemented the button types and combobox
.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@317 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/kwq/KWQCheckBox.mm b/WebCore/kwq/KWQCheckBox.mm
index 1069919..9e59f21 100644
--- a/WebCore/kwq/KWQCheckBox.mm
+++ b/WebCore/kwq/KWQCheckBox.mm
@@ -25,15 +25,27 @@
#include <qcheckbox.h>
+#include <KWQView.h>
+
#include <kwqdebug.h>
QCheckBox::QCheckBox(QWidget *w) : QButton (w)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ [button setButtonType: NSRadioButton];
+ setView (button);
}
-void QCheckBox::setChecked(bool)
+void QCheckBox::setChecked(bool isChecked)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ if (isChecked)
+ [button setState: NSOnState];
+ else
+ [button setState: NSOffState];
}
diff --git a/WebCore/kwq/KWQComboBox.h b/WebCore/kwq/KWQComboBox.h
index 42c9134..3043555 100644
--- a/WebCore/kwq/KWQComboBox.h
+++ b/WebCore/kwq/KWQComboBox.h
@@ -71,6 +71,10 @@ private:
QComboBox(const QComboBox &);
QComboBox &operator=(const QComboBox &);
+#ifdef _KWQ_
+ void init(bool isEditable);
+#endif
+
}; // class QComboBox ==========================================================
#endif
diff --git a/WebCore/kwq/KWQComboBox.mm b/WebCore/kwq/KWQComboBox.mm
index 655206f..ae3c938 100644
--- a/WebCore/kwq/KWQComboBox.mm
+++ b/WebCore/kwq/KWQComboBox.mm
@@ -22,32 +22,45 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <qcombobox.h>
+
+#include <KWQView.h>
+
#include <kwqdebug.h>
-#include <qcombobox.h>
+QComboBox::QComboBox(QWidget *parent, const char *name)
+{
+ init(FALSE);
+}
-QComboBox::QComboBox(QWidget *parent=0, const char *name=0)
+QComboBox::QComboBox(bool rw, QWidget *parent, const char *name)
{
- _logNotYetImplemented();
+ init(rw);
}
-QComboBox::QComboBox(bool rw, QWidget *parent=0, const char *name=0)
+void QComboBox::init(bool isEditable)
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox;
+
+ comboBox = [[[KWQNSComboBox alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this] autorelease];
+ if (isEditable == FALSE)
+ [comboBox setEditable: NO];
}
+
QComboBox::~QComboBox()
{
- _logNotYetImplemented();
}
int QComboBox::count() const
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+
+ return [comboBox numberOfItems];
}
@@ -69,20 +82,27 @@ bool QComboBox::eventFilter(QObject *object, QEvent *event)
}
-void QComboBox::insertItem(const QString &text, int index=-1)
+void QComboBox::insertItem(const QString &text, int index)
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+
+ if (index < 0)
+ index = count();
+ [comboBox insertItemWithObjectValue: QSTRING_TO_NSSTRING (text) atIndex: index];
}
void QComboBox::clear()
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+
+ [comboBox removeAllItems];
}
-void QComboBox::setCurrentItem(int)
+void QComboBox::setCurrentItem(int index)
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+ [comboBox selectItemAtIndex: index];
}
diff --git a/WebCore/kwq/KWQHBox.mm b/WebCore/kwq/KWQHBox.mm
index 6324e2a..9380340 100644
--- a/WebCore/kwq/KWQHBox.mm
+++ b/WebCore/kwq/KWQHBox.mm
@@ -22,30 +22,45 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <qhbox.h>
+
+#include <KWQView.h>
+#include <KWQNSTextField.h>
+
#include <kwqdebug.h>
-#include <qhbox.h>
+// This class is ONLY used by FORM <input type=file> elements. It's used
+// to stretch a LineEditWidget. We don't need it.
QHBox::QHBox()
{
- _logNotYetImplemented();
+ KWQView *view = (KWQView *)getView();
+ [view setIsFlipped: NO];
}
QHBox::QHBox(QWidget *)
{
- _logNotYetImplemented();
}
QHBox::~QHBox()
{
- _logNotYetImplemented();
+}
+
+
+// Override the focus proxy to simply add the line edit widget as a subview.
+void QHBox::setFocusProxy( QWidget *lineEdit)
+{
+ KWQView *view = (KWQView *)getView();
+ KWQNSTextField *fieldView = (KWQNSTextField *)lineEdit->getView();
+
+ // Do we also need to set size, or will layout take care of that?
+ [view addSubview: fieldView];
}
bool QHBox::setStretchFactor(QWidget*, int stretch)
{
- _logNotYetImplemented();
}
diff --git a/WebCore/kwq/KWQKLineEdit.mm b/WebCore/kwq/KWQKLineEdit.mm
index 32a1285..5230f1b 100644
--- a/WebCore/kwq/KWQKLineEdit.mm
+++ b/WebCore/kwq/KWQKLineEdit.mm
@@ -22,32 +22,30 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
-
#include <klineedit.h>
+#include <KWQNSTextField.h>
+
+#include <kwqdebug.h>
-KLineEdit::KLineEdit(QWidget *parent=0, const char *name=0)
+KLineEdit::KLineEdit(QWidget *parent, const char *name)
{
- _logNotYetImplemented();
}
KLineEdit::~KLineEdit()
{
- _logNotYetImplemented();
}
void KLineEdit::setMouseTracking(bool)
{
- _logNotYetImplemented();
+ KWQNSTextField *fieldView = (KWQNSTextField *)getView();
}
void KLineEdit::setContextMenuEnabled(bool showMenu)
{
- _logNotYetImplemented();
+ KWQNSTextField *fieldView = (KWQNSTextField *)getView();
}
diff --git a/WebCore/kwq/KWQLineEdit.mm b/WebCore/kwq/KWQLineEdit.mm
index 8943345..db8daf5 100644
--- a/WebCore/kwq/KWQLineEdit.mm
+++ b/WebCore/kwq/KWQLineEdit.mm
@@ -22,52 +22,66 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
#include <qlineedit.h>
-QLineEdit::QLineEdit(QWidget *parent=0, const char *name=0)
+#include <KWQNSTextField.h>
+
+#include <kwqdebug.h>
+
+QLineEdit::QLineEdit(QWidget *parent, const char *name)
{
- _logNotYetImplemented();
+ setView ([[[KWQNSTextField alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this] autorelease]);
}
QLineEdit::~QLineEdit()
{
- _logNotYetImplemented();
}
-void QLineEdit::setEchoMode(EchoMode)
+void QLineEdit::setEchoMode(EchoMode mode)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ if (mode == QLineEdit::Password)
+ [field setPasswordMode: YES];
+ else
+ [field setPasswordMode: NO];
}
void QLineEdit::setCursorPosition(int)
{
- _logNotYetImplemented();
+ // Don't do anything here.
}
-void QLineEdit::setText(const QString &)
+void QLineEdit::setText(const QString &s)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ [field setStringValue: QSTRING_TO_NSSTRING(s)];
}
-void QLineEdit::setMaxLength(int)
+void QLineEdit::setMaxLength(int len)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ [field setMaximumLength: len];
}
bool QLineEdit::isReadOnly() const
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field isEditable];
}
-void QLineEdit::setReadOnly(bool)
+void QLineEdit::setReadOnly(bool flag)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field setEditable: flag];
}
@@ -85,30 +99,35 @@ bool QLineEdit::frame() const
int QLineEdit::cursorPosition() const
{
- _logNotYetImplemented();
+ // Not needed. We ignore setCursorPosition().
+ return 0;
}
int QLineEdit::maxLength() const
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field maximumLength];
}
void QLineEdit::selectAll()
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field selectText: field];
}
QLineEdit::QLineEdit(const QLineEdit &)
{
- _logNotYetImplemented();
+ _logNeverImplemented();
}
QLineEdit &QLineEdit::operator=(const QLineEdit &)
{
- _logNotYetImplemented();
+ _logNeverImplemented();
}
diff --git a/WebCore/kwq/KWQKGlobal.mm b/WebCore/kwq/KWQNSTextField.h
similarity index 58%
copy from WebCore/kwq/KWQKGlobal.mm
copy to WebCore/kwq/KWQNSTextField.h
index b2544e0..1869c10 100644
--- a/WebCore/kwq/KWQKGlobal.mm
+++ b/WebCore/kwq/KWQNSTextField.h
@@ -22,52 +22,41 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
-#include <kglobal.h>
-
-#define Fixed MacFixed
-#define Rect MacRect
-#define Boolean MacBoolean
#include <Cocoa/Cocoa.h>
-#undef Fixed
-#undef Rect
-#undef Boolean
-
-KInstance *KGlobal::instance()
-{
- _logNotYetImplemented();
-}
-
-
-KCharsets *KGlobal::charsets()
-{
- _logNotYetImplemented();
-}
+class QWidget;
-KLocale *KGlobal::locale()
+ at interface KWQNSTextFieldFormatter : NSFormatter
{
- _logNotYetImplemented();
+ int maxLength;
+ bool isPassword;
}
+- (void)setPasswordMode: (bool)flag;
+- (bool)passwordMode;
+- (void)setMaximumLength: (int)len;
+- (int)maximumLength;
+- (NSString *)stringForObjectValue:(id)anObject;
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error;
+- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error;
+- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes;
-KStandardDirs *KGlobal::dirs()
-{
- _logNotYetImplemented();
-}
-
+ at end
-KConfig *KGlobal::config()
+ at interface KWQNSTextField : NSTextField
{
- _logNotYetImplemented();
+ at private
+ NSSecureTextField *secureField;
+ QWidget *widget;
+ KWQNSTextFieldFormatter *formatter;
}
+- initWithFrame: (NSRect)r widget: (QWidget *)w;
+- (KWQNSTextFieldFormatter *)formatter;
+- (void)setPasswordMode: (bool)flag;
+- (bool)passwordMode;
+- (void)setMaximumLength: (int)len;
+- (int)maximumLength;
-
-const QString &KGlobal::staticQString(const QString &)
-{
- _logNotYetImplemented();
-}
-
+ at end
diff --git a/WebCore/kwq/KWQNSTextField.mm b/WebCore/kwq/KWQNSTextField.mm
new file mode 100644
index 0000000..e4f87cd
--- /dev/null
+++ b/WebCore/kwq/KWQNSTextField.mm
@@ -0,0 +1,187 @@
+/*
+ * 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 <KWQNSTextField.h>
+
+
+ at implementation KWQNSTextField
+
+- initWithFrame: (NSRect) r widget: (QWidget *)w
+{
+ [super initWithFrame: r];
+ formatter = [[KWQNSTextFieldFormatter alloc] init];
+ [self setFormatter: formatter];
+ widget = w;
+}
+
+- (void)dealloc
+{
+ [formatter release];
+ [super dealloc];
+}
+
+
+- (KWQNSTextFieldFormatter *)formatter
+{
+ return formatter;
+}
+
+
+- (void)setPasswordMode: (bool)flag
+{
+ if (flag != [formatter passwordMode]){
+ if (flag == NO){
+ [self setStringValue: @""];
+ [secureField removeFromSuperview];
+ } else {
+ if (secureField == nil){
+ secureField = [[NSSecureTextField alloc] initWithFrame: [self bounds]];
+ [secureField setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+ [secureField setFormatter: formatter];
+ } else {
+ [secureField setBounds: [self bounds]];
+ }
+ [secureField setStringValue: @""];
+ [self addSubview: secureField];
+ }
+ [formatter setPasswordMode: flag];
+ }
+}
+
+
+- (void)setEditable:(BOOL)flag
+{
+ if (secureField != nil)
+ [secureField setEditable: flag];
+ [super setEditable: flag];
+}
+
+
+- (void)selectText:(id)sender
+{
+ if ([self passwordMode])
+ [secureField selectText: sender];
+}
+
+
+- (BOOL)isEditable
+{
+ return [super isEditable];
+}
+
+
+- (bool)passwordMode
+{
+ return [formatter passwordMode];
+}
+
+
+- (void)setMaximumLength: (int)len
+{
+ [self setStringValue: @""];
+ if (secureField != nil)
+ [secureField setStringValue: @""];
+ [formatter setMaximumLength: len];
+}
+
+
+- (int)maximumLength
+{
+ return [formatter maximumLength];
+}
+
+
+
+ at end
+
+
+ at implementation KWQNSTextFieldFormatter
+
+- init {
+ maxLength = 2147483647;
+ isPassword = NO;
+ return [super init];
+}
+
+- (void)setPasswordMode: (bool)flag
+{
+ isPassword = flag;
+}
+
+
+- (bool)passwordMode
+{
+ return isPassword;
+}
+
+
+- (void)setMaximumLength: (int)len
+{
+ maxLength = len;
+}
+
+
+- (int)maximumLength
+{
+ return maxLength;
+}
+
+
+- (NSString *)stringForObjectValue:(id)anObject
+{
+ return (NSString *)anObject;
+}
+
+
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error
+{
+ *obj = string;
+}
+
+
+- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
+{
+ int i, length = [(NSString *)partialString length];
+ NSString *string = @"";
+
+ if ([partialString length] >= maxLength){
+ *newString = nil;
+ return NO;
+ }
+
+ return YES;
+}
+
+
+- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes
+{
+ return nil;
+}
+
+
+
+ at end
+
diff --git a/WebCore/kwq/KWQPushButton.mm b/WebCore/kwq/KWQPushButton.mm
index 9666542..26d20f2 100644
--- a/WebCore/kwq/KWQPushButton.mm
+++ b/WebCore/kwq/KWQPushButton.mm
@@ -22,23 +22,24 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <qpushbutton.h>
+
+#include <KWQView.h>
+
#include <kwqdebug.h>
-#include <qpushbutton.h>
+// Should require no additional code over KWQButton
QPushButton::QPushButton(QWidget *w) : QButton (w)
{
- _logNotYetImplemented();
}
QPushButton::QPushButton(const QString &text, QWidget *parent, const char* name)
{
- _logNotYetImplemented();
}
QPushButton::~QPushButton()
{
- _logNotYetImplemented();
}
diff --git a/WebCore/kwq/KWQRadioButton.mm b/WebCore/kwq/KWQRadioButton.mm
index 0ce1f2b..09056eb 100644
--- a/WebCore/kwq/KWQRadioButton.mm
+++ b/WebCore/kwq/KWQRadioButton.mm
@@ -22,18 +22,30 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
#include <qradiobutton.h>
+#include <KWQView.h>
+
+#include <kwqdebug.h>
+
QRadioButton::QRadioButton(QWidget *w) : QButton (w)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ [button setButtonType: NSSwitchButton];
+ setView (button);
}
-void QRadioButton::setChecked(bool)
+void QRadioButton::setChecked(bool isChecked)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ if (isChecked)
+ [button setState: NSOnState];
+ else
+ [button setState: NSOffState];
}
diff --git a/WebCore/kwq/KWQKGlobal.mm b/WebCore/kwq/KWQTextField.h
similarity index 58%
copy from WebCore/kwq/KWQKGlobal.mm
copy to WebCore/kwq/KWQTextField.h
index b2544e0..1869c10 100644
--- a/WebCore/kwq/KWQKGlobal.mm
+++ b/WebCore/kwq/KWQTextField.h
@@ -22,52 +22,41 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
-#include <kglobal.h>
-
-#define Fixed MacFixed
-#define Rect MacRect
-#define Boolean MacBoolean
#include <Cocoa/Cocoa.h>
-#undef Fixed
-#undef Rect
-#undef Boolean
-
-KInstance *KGlobal::instance()
-{
- _logNotYetImplemented();
-}
-
-
-KCharsets *KGlobal::charsets()
-{
- _logNotYetImplemented();
-}
+class QWidget;
-KLocale *KGlobal::locale()
+ at interface KWQNSTextFieldFormatter : NSFormatter
{
- _logNotYetImplemented();
+ int maxLength;
+ bool isPassword;
}
+- (void)setPasswordMode: (bool)flag;
+- (bool)passwordMode;
+- (void)setMaximumLength: (int)len;
+- (int)maximumLength;
+- (NSString *)stringForObjectValue:(id)anObject;
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error;
+- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error;
+- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes;
-KStandardDirs *KGlobal::dirs()
-{
- _logNotYetImplemented();
-}
-
+ at end
-KConfig *KGlobal::config()
+ at interface KWQNSTextField : NSTextField
{
- _logNotYetImplemented();
+ at private
+ NSSecureTextField *secureField;
+ QWidget *widget;
+ KWQNSTextFieldFormatter *formatter;
}
+- initWithFrame: (NSRect)r widget: (QWidget *)w;
+- (KWQNSTextFieldFormatter *)formatter;
+- (void)setPasswordMode: (bool)flag;
+- (bool)passwordMode;
+- (void)setMaximumLength: (int)len;
+- (int)maximumLength;
-
-const QString &KGlobal::staticQString(const QString &)
-{
- _logNotYetImplemented();
-}
-
+ at end
diff --git a/WebCore/kwq/KWQTextField.mm b/WebCore/kwq/KWQTextField.mm
new file mode 100644
index 0000000..e4f87cd
--- /dev/null
+++ b/WebCore/kwq/KWQTextField.mm
@@ -0,0 +1,187 @@
+/*
+ * 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 <KWQNSTextField.h>
+
+
+ at implementation KWQNSTextField
+
+- initWithFrame: (NSRect) r widget: (QWidget *)w
+{
+ [super initWithFrame: r];
+ formatter = [[KWQNSTextFieldFormatter alloc] init];
+ [self setFormatter: formatter];
+ widget = w;
+}
+
+- (void)dealloc
+{
+ [formatter release];
+ [super dealloc];
+}
+
+
+- (KWQNSTextFieldFormatter *)formatter
+{
+ return formatter;
+}
+
+
+- (void)setPasswordMode: (bool)flag
+{
+ if (flag != [formatter passwordMode]){
+ if (flag == NO){
+ [self setStringValue: @""];
+ [secureField removeFromSuperview];
+ } else {
+ if (secureField == nil){
+ secureField = [[NSSecureTextField alloc] initWithFrame: [self bounds]];
+ [secureField setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+ [secureField setFormatter: formatter];
+ } else {
+ [secureField setBounds: [self bounds]];
+ }
+ [secureField setStringValue: @""];
+ [self addSubview: secureField];
+ }
+ [formatter setPasswordMode: flag];
+ }
+}
+
+
+- (void)setEditable:(BOOL)flag
+{
+ if (secureField != nil)
+ [secureField setEditable: flag];
+ [super setEditable: flag];
+}
+
+
+- (void)selectText:(id)sender
+{
+ if ([self passwordMode])
+ [secureField selectText: sender];
+}
+
+
+- (BOOL)isEditable
+{
+ return [super isEditable];
+}
+
+
+- (bool)passwordMode
+{
+ return [formatter passwordMode];
+}
+
+
+- (void)setMaximumLength: (int)len
+{
+ [self setStringValue: @""];
+ if (secureField != nil)
+ [secureField setStringValue: @""];
+ [formatter setMaximumLength: len];
+}
+
+
+- (int)maximumLength
+{
+ return [formatter maximumLength];
+}
+
+
+
+ at end
+
+
+ at implementation KWQNSTextFieldFormatter
+
+- init {
+ maxLength = 2147483647;
+ isPassword = NO;
+ return [super init];
+}
+
+- (void)setPasswordMode: (bool)flag
+{
+ isPassword = flag;
+}
+
+
+- (bool)passwordMode
+{
+ return isPassword;
+}
+
+
+- (void)setMaximumLength: (int)len
+{
+ maxLength = len;
+}
+
+
+- (int)maximumLength
+{
+ return maxLength;
+}
+
+
+- (NSString *)stringForObjectValue:(id)anObject
+{
+ return (NSString *)anObject;
+}
+
+
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error
+{
+ *obj = string;
+}
+
+
+- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
+{
+ int i, length = [(NSString *)partialString length];
+ NSString *string = @"";
+
+ if ([partialString length] >= maxLength){
+ *newString = nil;
+ return NO;
+ }
+
+ return YES;
+}
+
+
+- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes
+{
+ return nil;
+}
+
+
+
+ at end
+
diff --git a/WebCore/kwq/KWQView.h b/WebCore/kwq/KWQView.h
index 6c9eeb1..2b077fe 100644
--- a/WebCore/kwq/KWQView.h
+++ b/WebCore/kwq/KWQView.h
@@ -6,8 +6,10 @@ class QWidget;
@interface KWQView : NSView
{
QWidget *widget;
+ bool isFlipped;
}
- initWithFrame: (NSRect)r widget: (QWidget *)w;
+- (void)setIsFlipped: (bool)flag;
@end
@interface KWQNSButton : NSButton
@@ -16,3 +18,11 @@ class QWidget;
}
- initWithFrame: (NSRect)r widget: (QWidget *)w;
@end
+
+ at interface KWQNSComboBox : NSComboBox
+{
+ QWidget *widget;
+}
+- initWithFrame: (NSRect)r widget: (QWidget *)w;
+ at end
+
diff --git a/WebCore/kwq/KWQView.mm b/WebCore/kwq/KWQView.mm
index 7a0e12f..264cf33 100644
--- a/WebCore/kwq/KWQView.mm
+++ b/WebCore/kwq/KWQView.mm
@@ -8,6 +8,7 @@
{
[super initWithFrame: r];
widget = w;
+ isFlipped = YES;
}
@@ -16,14 +17,20 @@
widget->paint((void *)0);
}
+- (void)setIsFlipped: (bool)flag
+{
+ isFlipped = flag;
+}
+
- (BOOL)isFlipped
{
- return YES;
+ return isFlipped;
}
@end
+
@implementation KWQNSButton
- initWithFrame: (NSRect) r widget: (QWidget *)w
@@ -32,4 +39,15 @@
widget = w;
}
- at end
\ No newline at end of file
+ at end
+
+
+ at implementation KWQNSComboBox
+
+- initWithFrame: (NSRect) r widget: (QWidget *)w
+{
+ [super initWithFrame: r];
+ widget = w;
+}
+
+ at end
diff --git a/WebCore/kwq/Makefile.in b/WebCore/kwq/Makefile.in
index 530ef5e..140e5c0 100644
--- a/WebCore/kwq/Makefile.in
+++ b/WebCore/kwq/Makefile.in
@@ -93,6 +93,7 @@ MMOBJECTS = \
KWQListBox.o \
KWQLineEdit.o \
KWQMovie.o \
+ KWQNSTextField.o \
KWQObject.o \
KWQPainter.o \
KWQPaintDevice.o \
diff --git a/WebCore/kwq/kde/Makefile.in b/WebCore/kwq/kde/Makefile
similarity index 95%
copy from WebCore/kwq/kde/Makefile.in
copy to WebCore/kwq/kde/Makefile
index 2b1becc..52614ba 100644
--- a/WebCore/kwq/kde/Makefile.in
+++ b/WebCore/kwq/kde/Makefile
@@ -1,3 +1,4 @@
+# Generated automatically from Makefile.in by configure.
#======================================================================
#
# Makefile
diff --git a/WebCore/kwq/qt/qcombobox.h b/WebCore/kwq/qt/qcombobox.h
index 42c9134..3043555 100644
--- a/WebCore/kwq/qt/qcombobox.h
+++ b/WebCore/kwq/qt/qcombobox.h
@@ -71,6 +71,10 @@ private:
QComboBox(const QComboBox &);
QComboBox &operator=(const QComboBox &);
+#ifdef _KWQ_
+ void init(bool isEditable);
+#endif
+
}; // class QComboBox ==========================================================
#endif
diff --git a/WebCore/kwq/qt/qhbox.h b/WebCore/kwq/qt/qhbox.h
index a297f9a..dc2d12c 100644
--- a/WebCore/kwq/qt/qhbox.h
+++ b/WebCore/kwq/qt/qhbox.h
@@ -72,6 +72,10 @@ private:
QHBox &operator=(const QHBox &);
#endif
+#ifdef _KWQ_
+ void setFocusProxy( QWidget *lineEdit);
+#endif
+
}; // class QHBox ==============================================================
#endif
diff --git a/WebCore/src/kwq/KWQCheckBox.mm b/WebCore/src/kwq/KWQCheckBox.mm
index 1069919..9e59f21 100644
--- a/WebCore/src/kwq/KWQCheckBox.mm
+++ b/WebCore/src/kwq/KWQCheckBox.mm
@@ -25,15 +25,27 @@
#include <qcheckbox.h>
+#include <KWQView.h>
+
#include <kwqdebug.h>
QCheckBox::QCheckBox(QWidget *w) : QButton (w)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ [button setButtonType: NSRadioButton];
+ setView (button);
}
-void QCheckBox::setChecked(bool)
+void QCheckBox::setChecked(bool isChecked)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ if (isChecked)
+ [button setState: NSOnState];
+ else
+ [button setState: NSOffState];
}
diff --git a/WebCore/src/kwq/KWQComboBox.mm b/WebCore/src/kwq/KWQComboBox.mm
index 655206f..ae3c938 100644
--- a/WebCore/src/kwq/KWQComboBox.mm
+++ b/WebCore/src/kwq/KWQComboBox.mm
@@ -22,32 +22,45 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <qcombobox.h>
+
+#include <KWQView.h>
+
#include <kwqdebug.h>
-#include <qcombobox.h>
+QComboBox::QComboBox(QWidget *parent, const char *name)
+{
+ init(FALSE);
+}
-QComboBox::QComboBox(QWidget *parent=0, const char *name=0)
+QComboBox::QComboBox(bool rw, QWidget *parent, const char *name)
{
- _logNotYetImplemented();
+ init(rw);
}
-QComboBox::QComboBox(bool rw, QWidget *parent=0, const char *name=0)
+void QComboBox::init(bool isEditable)
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox;
+
+ comboBox = [[[KWQNSComboBox alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this] autorelease];
+ if (isEditable == FALSE)
+ [comboBox setEditable: NO];
}
+
QComboBox::~QComboBox()
{
- _logNotYetImplemented();
}
int QComboBox::count() const
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+
+ return [comboBox numberOfItems];
}
@@ -69,20 +82,27 @@ bool QComboBox::eventFilter(QObject *object, QEvent *event)
}
-void QComboBox::insertItem(const QString &text, int index=-1)
+void QComboBox::insertItem(const QString &text, int index)
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+
+ if (index < 0)
+ index = count();
+ [comboBox insertItemWithObjectValue: QSTRING_TO_NSSTRING (text) atIndex: index];
}
void QComboBox::clear()
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+
+ [comboBox removeAllItems];
}
-void QComboBox::setCurrentItem(int)
+void QComboBox::setCurrentItem(int index)
{
- _logNotYetImplemented();
+ KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
+ [comboBox selectItemAtIndex: index];
}
diff --git a/WebCore/src/kwq/KWQHBox.mm b/WebCore/src/kwq/KWQHBox.mm
index 6324e2a..9380340 100644
--- a/WebCore/src/kwq/KWQHBox.mm
+++ b/WebCore/src/kwq/KWQHBox.mm
@@ -22,30 +22,45 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <qhbox.h>
+
+#include <KWQView.h>
+#include <KWQNSTextField.h>
+
#include <kwqdebug.h>
-#include <qhbox.h>
+// This class is ONLY used by FORM <input type=file> elements. It's used
+// to stretch a LineEditWidget. We don't need it.
QHBox::QHBox()
{
- _logNotYetImplemented();
+ KWQView *view = (KWQView *)getView();
+ [view setIsFlipped: NO];
}
QHBox::QHBox(QWidget *)
{
- _logNotYetImplemented();
}
QHBox::~QHBox()
{
- _logNotYetImplemented();
+}
+
+
+// Override the focus proxy to simply add the line edit widget as a subview.
+void QHBox::setFocusProxy( QWidget *lineEdit)
+{
+ KWQView *view = (KWQView *)getView();
+ KWQNSTextField *fieldView = (KWQNSTextField *)lineEdit->getView();
+
+ // Do we also need to set size, or will layout take care of that?
+ [view addSubview: fieldView];
}
bool QHBox::setStretchFactor(QWidget*, int stretch)
{
- _logNotYetImplemented();
}
diff --git a/WebCore/src/kwq/KWQKLineEdit.mm b/WebCore/src/kwq/KWQKLineEdit.mm
index 32a1285..5230f1b 100644
--- a/WebCore/src/kwq/KWQKLineEdit.mm
+++ b/WebCore/src/kwq/KWQKLineEdit.mm
@@ -22,32 +22,30 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
-
#include <klineedit.h>
+#include <KWQNSTextField.h>
+
+#include <kwqdebug.h>
-KLineEdit::KLineEdit(QWidget *parent=0, const char *name=0)
+KLineEdit::KLineEdit(QWidget *parent, const char *name)
{
- _logNotYetImplemented();
}
KLineEdit::~KLineEdit()
{
- _logNotYetImplemented();
}
void KLineEdit::setMouseTracking(bool)
{
- _logNotYetImplemented();
+ KWQNSTextField *fieldView = (KWQNSTextField *)getView();
}
void KLineEdit::setContextMenuEnabled(bool showMenu)
{
- _logNotYetImplemented();
+ KWQNSTextField *fieldView = (KWQNSTextField *)getView();
}
diff --git a/WebCore/src/kwq/KWQLineEdit.mm b/WebCore/src/kwq/KWQLineEdit.mm
index 8943345..db8daf5 100644
--- a/WebCore/src/kwq/KWQLineEdit.mm
+++ b/WebCore/src/kwq/KWQLineEdit.mm
@@ -22,52 +22,66 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
#include <qlineedit.h>
-QLineEdit::QLineEdit(QWidget *parent=0, const char *name=0)
+#include <KWQNSTextField.h>
+
+#include <kwqdebug.h>
+
+QLineEdit::QLineEdit(QWidget *parent, const char *name)
{
- _logNotYetImplemented();
+ setView ([[[KWQNSTextField alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this] autorelease]);
}
QLineEdit::~QLineEdit()
{
- _logNotYetImplemented();
}
-void QLineEdit::setEchoMode(EchoMode)
+void QLineEdit::setEchoMode(EchoMode mode)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ if (mode == QLineEdit::Password)
+ [field setPasswordMode: YES];
+ else
+ [field setPasswordMode: NO];
}
void QLineEdit::setCursorPosition(int)
{
- _logNotYetImplemented();
+ // Don't do anything here.
}
-void QLineEdit::setText(const QString &)
+void QLineEdit::setText(const QString &s)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ [field setStringValue: QSTRING_TO_NSSTRING(s)];
}
-void QLineEdit::setMaxLength(int)
+void QLineEdit::setMaxLength(int len)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ [field setMaximumLength: len];
}
bool QLineEdit::isReadOnly() const
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field isEditable];
}
-void QLineEdit::setReadOnly(bool)
+void QLineEdit::setReadOnly(bool flag)
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field setEditable: flag];
}
@@ -85,30 +99,35 @@ bool QLineEdit::frame() const
int QLineEdit::cursorPosition() const
{
- _logNotYetImplemented();
+ // Not needed. We ignore setCursorPosition().
+ return 0;
}
int QLineEdit::maxLength() const
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field maximumLength];
}
void QLineEdit::selectAll()
{
- _logNotYetImplemented();
+ KWQNSTextField *field = (KWQNSTextField *)getView();
+
+ return [field selectText: field];
}
QLineEdit::QLineEdit(const QLineEdit &)
{
- _logNotYetImplemented();
+ _logNeverImplemented();
}
QLineEdit &QLineEdit::operator=(const QLineEdit &)
{
- _logNotYetImplemented();
+ _logNeverImplemented();
}
diff --git a/WebCore/kwq/KWQKGlobal.mm b/WebCore/src/kwq/KWQNSTextField.h
similarity index 58%
copy from WebCore/kwq/KWQKGlobal.mm
copy to WebCore/src/kwq/KWQNSTextField.h
index b2544e0..1869c10 100644
--- a/WebCore/kwq/KWQKGlobal.mm
+++ b/WebCore/src/kwq/KWQNSTextField.h
@@ -22,52 +22,41 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
-#include <kglobal.h>
-
-#define Fixed MacFixed
-#define Rect MacRect
-#define Boolean MacBoolean
#include <Cocoa/Cocoa.h>
-#undef Fixed
-#undef Rect
-#undef Boolean
-
-KInstance *KGlobal::instance()
-{
- _logNotYetImplemented();
-}
-
-
-KCharsets *KGlobal::charsets()
-{
- _logNotYetImplemented();
-}
+class QWidget;
-KLocale *KGlobal::locale()
+ at interface KWQNSTextFieldFormatter : NSFormatter
{
- _logNotYetImplemented();
+ int maxLength;
+ bool isPassword;
}
+- (void)setPasswordMode: (bool)flag;
+- (bool)passwordMode;
+- (void)setMaximumLength: (int)len;
+- (int)maximumLength;
+- (NSString *)stringForObjectValue:(id)anObject;
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error;
+- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error;
+- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes;
-KStandardDirs *KGlobal::dirs()
-{
- _logNotYetImplemented();
-}
-
+ at end
-KConfig *KGlobal::config()
+ at interface KWQNSTextField : NSTextField
{
- _logNotYetImplemented();
+ at private
+ NSSecureTextField *secureField;
+ QWidget *widget;
+ KWQNSTextFieldFormatter *formatter;
}
+- initWithFrame: (NSRect)r widget: (QWidget *)w;
+- (KWQNSTextFieldFormatter *)formatter;
+- (void)setPasswordMode: (bool)flag;
+- (bool)passwordMode;
+- (void)setMaximumLength: (int)len;
+- (int)maximumLength;
-
-const QString &KGlobal::staticQString(const QString &)
-{
- _logNotYetImplemented();
-}
-
+ at end
diff --git a/WebCore/src/kwq/KWQNSTextField.mm b/WebCore/src/kwq/KWQNSTextField.mm
new file mode 100644
index 0000000..e4f87cd
--- /dev/null
+++ b/WebCore/src/kwq/KWQNSTextField.mm
@@ -0,0 +1,187 @@
+/*
+ * 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 <KWQNSTextField.h>
+
+
+ at implementation KWQNSTextField
+
+- initWithFrame: (NSRect) r widget: (QWidget *)w
+{
+ [super initWithFrame: r];
+ formatter = [[KWQNSTextFieldFormatter alloc] init];
+ [self setFormatter: formatter];
+ widget = w;
+}
+
+- (void)dealloc
+{
+ [formatter release];
+ [super dealloc];
+}
+
+
+- (KWQNSTextFieldFormatter *)formatter
+{
+ return formatter;
+}
+
+
+- (void)setPasswordMode: (bool)flag
+{
+ if (flag != [formatter passwordMode]){
+ if (flag == NO){
+ [self setStringValue: @""];
+ [secureField removeFromSuperview];
+ } else {
+ if (secureField == nil){
+ secureField = [[NSSecureTextField alloc] initWithFrame: [self bounds]];
+ [secureField setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
+ [secureField setFormatter: formatter];
+ } else {
+ [secureField setBounds: [self bounds]];
+ }
+ [secureField setStringValue: @""];
+ [self addSubview: secureField];
+ }
+ [formatter setPasswordMode: flag];
+ }
+}
+
+
+- (void)setEditable:(BOOL)flag
+{
+ if (secureField != nil)
+ [secureField setEditable: flag];
+ [super setEditable: flag];
+}
+
+
+- (void)selectText:(id)sender
+{
+ if ([self passwordMode])
+ [secureField selectText: sender];
+}
+
+
+- (BOOL)isEditable
+{
+ return [super isEditable];
+}
+
+
+- (bool)passwordMode
+{
+ return [formatter passwordMode];
+}
+
+
+- (void)setMaximumLength: (int)len
+{
+ [self setStringValue: @""];
+ if (secureField != nil)
+ [secureField setStringValue: @""];
+ [formatter setMaximumLength: len];
+}
+
+
+- (int)maximumLength
+{
+ return [formatter maximumLength];
+}
+
+
+
+ at end
+
+
+ at implementation KWQNSTextFieldFormatter
+
+- init {
+ maxLength = 2147483647;
+ isPassword = NO;
+ return [super init];
+}
+
+- (void)setPasswordMode: (bool)flag
+{
+ isPassword = flag;
+}
+
+
+- (bool)passwordMode
+{
+ return isPassword;
+}
+
+
+- (void)setMaximumLength: (int)len
+{
+ maxLength = len;
+}
+
+
+- (int)maximumLength
+{
+ return maxLength;
+}
+
+
+- (NSString *)stringForObjectValue:(id)anObject
+{
+ return (NSString *)anObject;
+}
+
+
+- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error
+{
+ *obj = string;
+}
+
+
+- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
+{
+ int i, length = [(NSString *)partialString length];
+ NSString *string = @"";
+
+ if ([partialString length] >= maxLength){
+ *newString = nil;
+ return NO;
+ }
+
+ return YES;
+}
+
+
+- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes
+{
+ return nil;
+}
+
+
+
+ at end
+
diff --git a/WebCore/src/kwq/KWQPushButton.mm b/WebCore/src/kwq/KWQPushButton.mm
index 9666542..26d20f2 100644
--- a/WebCore/src/kwq/KWQPushButton.mm
+++ b/WebCore/src/kwq/KWQPushButton.mm
@@ -22,23 +22,24 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <qpushbutton.h>
+
+#include <KWQView.h>
+
#include <kwqdebug.h>
-#include <qpushbutton.h>
+// Should require no additional code over KWQButton
QPushButton::QPushButton(QWidget *w) : QButton (w)
{
- _logNotYetImplemented();
}
QPushButton::QPushButton(const QString &text, QWidget *parent, const char* name)
{
- _logNotYetImplemented();
}
QPushButton::~QPushButton()
{
- _logNotYetImplemented();
}
diff --git a/WebCore/src/kwq/KWQRadioButton.mm b/WebCore/src/kwq/KWQRadioButton.mm
index 0ce1f2b..09056eb 100644
--- a/WebCore/src/kwq/KWQRadioButton.mm
+++ b/WebCore/src/kwq/KWQRadioButton.mm
@@ -22,18 +22,30 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
#include <qradiobutton.h>
+#include <KWQView.h>
+
+#include <kwqdebug.h>
+
QRadioButton::QRadioButton(QWidget *w) : QButton (w)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ [button setButtonType: NSSwitchButton];
+ setView (button);
}
-void QRadioButton::setChecked(bool)
+void QRadioButton::setChecked(bool isChecked)
{
- _logNotYetImplemented();
+ KWQNSButton *button;
+
+ button = (KWQNSButton *)getView();
+ if (isChecked)
+ [button setState: NSOnState];
+ else
+ [button setState: NSOffState];
}
diff --git a/WebCore/src/kwq/KWQView.h b/WebCore/src/kwq/KWQView.h
index 6c9eeb1..2b077fe 100644
--- a/WebCore/src/kwq/KWQView.h
+++ b/WebCore/src/kwq/KWQView.h
@@ -6,8 +6,10 @@ class QWidget;
@interface KWQView : NSView
{
QWidget *widget;
+ bool isFlipped;
}
- initWithFrame: (NSRect)r widget: (QWidget *)w;
+- (void)setIsFlipped: (bool)flag;
@end
@interface KWQNSButton : NSButton
@@ -16,3 +18,11 @@ class QWidget;
}
- initWithFrame: (NSRect)r widget: (QWidget *)w;
@end
+
+ at interface KWQNSComboBox : NSComboBox
+{
+ QWidget *widget;
+}
+- initWithFrame: (NSRect)r widget: (QWidget *)w;
+ at end
+
diff --git a/WebCore/src/kwq/KWQView.mm b/WebCore/src/kwq/KWQView.mm
index 7a0e12f..264cf33 100644
--- a/WebCore/src/kwq/KWQView.mm
+++ b/WebCore/src/kwq/KWQView.mm
@@ -8,6 +8,7 @@
{
[super initWithFrame: r];
widget = w;
+ isFlipped = YES;
}
@@ -16,14 +17,20 @@
widget->paint((void *)0);
}
+- (void)setIsFlipped: (bool)flag
+{
+ isFlipped = flag;
+}
+
- (BOOL)isFlipped
{
- return YES;
+ return isFlipped;
}
@end
+
@implementation KWQNSButton
- initWithFrame: (NSRect) r widget: (QWidget *)w
@@ -32,4 +39,15 @@
widget = w;
}
- at end
\ No newline at end of file
+ at end
+
+
+ at implementation KWQNSComboBox
+
+- initWithFrame: (NSRect) r widget: (QWidget *)w
+{
+ [super initWithFrame: r];
+ widget = w;
+}
+
+ at end
diff --git a/WebCore/src/kwq/Makefile.in b/WebCore/src/kwq/Makefile.in
index 530ef5e..140e5c0 100644
--- a/WebCore/src/kwq/Makefile.in
+++ b/WebCore/src/kwq/Makefile.in
@@ -93,6 +93,7 @@ MMOBJECTS = \
KWQListBox.o \
KWQLineEdit.o \
KWQMovie.o \
+ KWQNSTextField.o \
KWQObject.o \
KWQPainter.o \
KWQPaintDevice.o \
diff --git a/WebCore/kwq/kde/Makefile.in b/WebCore/src/kwq/kde/Makefile
similarity index 95%
copy from WebCore/kwq/kde/Makefile.in
copy to WebCore/src/kwq/kde/Makefile
index 2b1becc..52614ba 100644
--- a/WebCore/kwq/kde/Makefile.in
+++ b/WebCore/src/kwq/kde/Makefile
@@ -1,3 +1,4 @@
+# Generated automatically from Makefile.in by configure.
#======================================================================
#
# Makefile
diff --git a/WebCore/src/kwq/qt/qcombobox.h b/WebCore/src/kwq/qt/qcombobox.h
index 42c9134..3043555 100644
--- a/WebCore/src/kwq/qt/qcombobox.h
+++ b/WebCore/src/kwq/qt/qcombobox.h
@@ -71,6 +71,10 @@ private:
QComboBox(const QComboBox &);
QComboBox &operator=(const QComboBox &);
+#ifdef _KWQ_
+ void init(bool isEditable);
+#endif
+
}; // class QComboBox ==========================================================
#endif
diff --git a/WebCore/src/kwq/qt/qhbox.h b/WebCore/src/kwq/qt/qhbox.h
index a297f9a..dc2d12c 100644
--- a/WebCore/src/kwq/qt/qhbox.h
+++ b/WebCore/src/kwq/qt/qhbox.h
@@ -72,6 +72,10 @@ private:
QHBox &operator=(const QHBox &);
#endif
+#ifdef _KWQ_
+ void setFocusProxy( QWidget *lineEdit);
+#endif
+
}; // class QHBox ==============================================================
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list