[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/khtml/rendering
From: Maks Orlovich <mo002j () mail ! rochester ! edu>
Date: 2003-05-14 23:01:32
[Download RAW message or body]
CVS commit by orlovich:
Calculate a mask for <input type="file"> elements, so they don't get a
grey or other such weird background
CCMAIL: 56830-done@bugs.kde.org
M +53 -4 render_form.cpp 1.228
M +3 -2 render_form.h 1.93
--- kdelibs/khtml/rendering/render_form.h #1.92:1.93
@@ -305,4 +305,5 @@ public:
KLineEdit* lineEdit() const { return m_edit; }
+ const QPushButton* pushButton() const { return m_button; }
public slots:
--- kdelibs/khtml/rendering/render_form.cpp #1.227:1.228
@@ -47,4 +47,5 @@
#include <qpopupmenu.h>
+#include <qbitmap.h>
using namespace khtml;
@@ -710,9 +711,55 @@ void RenderFieldset::paintBorderMinusLeg
// -------------------------------------------------------------------------
+//A helper widget that generates a mask
+class TransHBox:public QHBox
+{
+public:
+ TransHBox(RenderFileButton* owner, QWidget* parent):QHBox(parent), m_owner(owner)
+ {
+ setAutoMask(true);
+ }
+
+ virtual void updateMask()
+ {
+ QBitmap mask(size());
+ QPainter p(&mask);
+
+ const QPushButton* push = m_owner->pushButton();
+ const QLineEdit* lineEdit = m_owner->lineEdit();
+
+ //If we have the button & line edit, make a proper mask
+ if (push && lineEdit)
+ {
+ //Mask everything off
+ p.fillRect(0, 0, width(), height(), Qt::color0);
+
+ //Draw button mask
+ QRect buttonRect = QRect(push->pos(), push->size());
+ parentWidget()->style().drawControlMask(QStyle::CE_PushButton,
+ &p, push, buttonRect);
+
+ //Draw line edit mask
+ QRect lineEditRect = QRect(lineEdit->pos(), lineEdit->size());
+ p.fillRect(lineEditRect, Qt::color1);
+ }
+ else //Fall back everything visible.
+ p.fillRect(0, 0, width(), height(), Qt::color1);
+
+ p.end();
+ setMask(mask);
+ }
+
+private:
+ RenderFileButton* m_owner;
+};
+
RenderFileButton::RenderFileButton(HTMLInputElementImpl *element)
: RenderFormElement(element)
{
- // this sucks, it creates a grey background
- QHBox *w = new QHBox(view()->viewport());
+ m_edit = 0; //For the benefit of the transhbox.
+ m_button = 0;
+
+ // this sucks, we need to use a custom widget to get a proper background
+ TransHBox *w = new TransHBox(this, view()->viewport());
m_edit = new LineEditWidget(element, view(), w);
@@ -729,4 +776,6 @@ RenderFileButton::RenderFileButton(HTMLI
w->setStretchFactor(m_edit, 2);
w->setFocusProxy(m_edit);
+
+ w->updateMask();
setQWidget(w);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic