[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:43:39 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 1e2183b29c3dc76143d9ec12ce0914e9cdbc158d
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 24 16:22:53 2002 +0000

    	Some improvements to the file button, including displaying the file without the
    	extension if it's set that way by the user, and using the system font rather
    	than hard-coding "Lucida Grande".
    
            * kwq/KWQFileButton.h: Add _label field.
            * kwq/KWQFileButton.mm:
            (KWQFileButton::KWQFileButton): Set up label.
            (KWQFileButton::~KWQFileButton): Release label.
            (KWQFileButton::setFilename): Use NSFileManager componentsToDisplayForPath to
    	figure out the appropriate label.
            (KWQFileButton::paint): Clip to passed-in rect, get font using systemFontOfSize,
    	and use NSString drawing rather than our own.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2136 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index c9a43ae..e7bfddf 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,18 @@
+2002-09-24  Darin Adler  <darin at apple.com>
+
+	Some improvements to the file button, including displaying the file without the
+	extension if it's set that way by the user, and using the system font rather
+	than hard-coding "Lucida Grande".
+
+        * kwq/KWQFileButton.h: Add _label field.
+        * kwq/KWQFileButton.mm:
+        (KWQFileButton::KWQFileButton): Set up label.
+        (KWQFileButton::~KWQFileButton): Release label.
+        (KWQFileButton::setFilename): Use NSFileManager componentsToDisplayForPath to
+	figure out the appropriate label.
+        (KWQFileButton::paint): Clip to passed-in rect, get font using systemFontOfSize,
+	and use NSString drawing rather than our own.
+
 2002-09-23  David Hyatt  <hyatt at apple.com>
 
 	Found the problem with the CSS W3C page.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c9a43ae..e7bfddf 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,18 @@
+2002-09-24  Darin Adler  <darin at apple.com>
+
+	Some improvements to the file button, including displaying the file without the
+	extension if it's set that way by the user, and using the system font rather
+	than hard-coding "Lucida Grande".
+
+        * kwq/KWQFileButton.h: Add _label field.
+        * kwq/KWQFileButton.mm:
+        (KWQFileButton::KWQFileButton): Set up label.
+        (KWQFileButton::~KWQFileButton): Release label.
+        (KWQFileButton::setFilename): Use NSFileManager componentsToDisplayForPath to
+	figure out the appropriate label.
+        (KWQFileButton::paint): Clip to passed-in rect, get font using systemFontOfSize,
+	and use NSString drawing rather than our own.
+
 2002-09-23  David Hyatt  <hyatt at apple.com>
 
 	Found the problem with the CSS W3C page.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c9a43ae..e7bfddf 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,18 @@
+2002-09-24  Darin Adler  <darin at apple.com>
+
+	Some improvements to the file button, including displaying the file without the
+	extension if it's set that way by the user, and using the system font rather
+	than hard-coding "Lucida Grande".
+
+        * kwq/KWQFileButton.h: Add _label field.
+        * kwq/KWQFileButton.mm:
+        (KWQFileButton::KWQFileButton): Set up label.
+        (KWQFileButton::~KWQFileButton): Release label.
+        (KWQFileButton::setFilename): Use NSFileManager componentsToDisplayForPath to
+	figure out the appropriate label.
+        (KWQFileButton::paint): Clip to passed-in rect, get font using systemFontOfSize,
+	and use NSString drawing rather than our own.
+
 2002-09-23  David Hyatt  <hyatt at apple.com>
 
 	Found the problem with the CSS W3C page.
diff --git a/WebCore/kwq/KWQFileButton.h b/WebCore/kwq/KWQFileButton.h
index 1a9a867..90f5551 100644
--- a/WebCore/kwq/KWQFileButton.h
+++ b/WebCore/kwq/KWQFileButton.h
@@ -31,9 +31,11 @@
 #ifdef __OBJC__
 @class KWQFileButtonAdapter;
 @class NSImage;
+ at class NSString;
 #else
 class KWQFileButtonAdapter;
 class NSImage;
+class NSString;
 #endif
 
 class KWQFileButton : public QPushButton {
@@ -57,6 +59,7 @@ private:
     QString _filename;
     KWQFileButtonAdapter *_adapter;
     NSImage *_icon;
+    NSString *_label;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQFileButton.mm b/WebCore/kwq/KWQFileButton.mm
index 7c028e5..e00fed5 100644
--- a/WebCore/kwq/KWQFileButton.mm
+++ b/WebCore/kwq/KWQFileButton.mm
@@ -25,16 +25,19 @@
 
 #import "KWQFileButton.h"
 
+// FIXME: These need to be localized.
+#define BUTTON_LABEL ("Choose File")
+#define NO_FILE_SELECTED (@"no file selected")
+
 #define AFTER_BUTTON_SPACING 4
 #define ICON_HEIGHT 16
 #define ICON_WIDTH 16
 #define ICON_FILENAME_SPACING 2
+// FIXME: Is it OK to hard-code the width of the filename part of this control?
 #define FILENAME_WIDTH 200
 
 #define ADDITIONAL_WIDTH (AFTER_BUTTON_SPACING + ICON_WIDTH + ICON_FILENAME_SPACING + FILENAME_WIDTH)
 
-#define FONT_FAMILY ("Lucida Grande")
-
 // FIXME: Clicks on the text should pull up the sheet too.
 
 @interface KWQFileButtonAdapter : NSObject
@@ -48,11 +51,11 @@
 @end
 
 KWQFileButton::KWQFileButton()
-    // FIXME: Needs to be localized.
-    : QPushButton("Choose File", 0)
+    : QPushButton(BUTTON_LABEL, 0)
     , _textChanged(this, SIGNAL(textChanged(const QString &)))
     , _adapter([[KWQFileButtonAdapter alloc] initWithKWQFileButton:this])
     , _icon(nil)
+    , _label([NO_FILE_SELECTED retain])
 {
 }
 
@@ -61,6 +64,7 @@ KWQFileButton::~KWQFileButton()
     _adapter->button = 0;
     [_adapter release];
     [_icon release];
+    [_label release];
 }
     
 void KWQFileButton::setFilename(const QString &f)
@@ -71,6 +75,14 @@ void KWQFileButton::setFilename(const QString &f)
     _filename = f;
     _textChanged.call(_filename);
     
+    // Get the label.
+    [_label release];
+    if (_filename.isEmpty()) {
+        _label = [NO_FILE_SELECTED retain];
+    } else {
+        _label = [[[[NSFileManager defaultManager] componentsToDisplayForPath:_filename.getNSString()] lastObject] copy];
+    }
+    
     // Get the icon.
     [_icon release];
     _icon = [[[NSWorkspace sharedWorkspace] iconForFile:_filename.getNSString()] retain];
@@ -132,16 +144,9 @@ void KWQFileButton::paint(QPainter *p, const QRect &r)
     
     QPushButton::paint(p, r);
     
-    QString text = _filename;
-    if (text.isEmpty()) {
-        text = "no file selected";
-    } else {
-        int slashPosition = text.findRev('/');
-        if (slashPosition >= 0 || text == "/") {
-            text.remove(0, slashPosition + 1);
-        }
-    }
-    
+    [NSGraphicsContext saveGraphicsState];
+    NSRectClip(NSIntersectRect(frameGeometry(), r));
+
     int left = x() + width() - ADDITIONAL_WIDTH + AFTER_BUTTON_SPACING;
 
     if (_icon) {
@@ -151,16 +156,12 @@ void KWQFileButton::paint(QPainter *p, const QRect &r)
         left += ICON_WIDTH + ICON_FILENAME_SPACING;
     }
 
-    // FIXME: Use same font as button, don't hardcode Lucida Grande.
-    // FIXME: Ellipsize the text to fit in the box.
-    QFont font;
-    font.setFamily(FONT_FAMILY);
-    font.setPixelSize([NSFont smallSystemFontSize]);
-    p->save();
-    p->addClip(frameGeometry());
-    p->setFont(font);
-    p->drawText(left, y() + baselinePosition(), 0, 0, 0, text);
-    p->restore();
+    // FIXME: Ellipsize the text to fit in the space available.
+    NSFont *font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+    NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
+    [_label drawAtPoint:NSMakePoint(left, y() + baselinePosition() - [font ascender]) withAttributes:attributes];
+
+    [NSGraphicsContext restoreGraphicsState];
 }
 
 @implementation KWQFileButtonAdapter

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list