[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/unity/WebKit/WebCore/platform/qt
From:       Nikolas Zimmermann <wildfox () kde ! org>
Date:       2006-07-31 9:44:30
Message-ID: 1154339070.477860.13425.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 568151 by wildfox:

First stab at themeing. Buttons are now drawn properly by Qt.
I'll go on hacking in that area now :-)


 M  +66 -9     RenderThemeQt.cpp  


--- branches/work/unity/WebKit/WebCore/platform/qt/RenderThemeQt.cpp #568150:568151
@@ -21,13 +21,46 @@
  *
  */
 
+#include <QDebug>
+#include <QStyle>
+#include <QWidget>
+#include <QPainter>
+#include <QStyleOptionButton>
+
 #include "config.h"
 
+#include "HelperQt.h"
+#include "RenderTheme.h"
 #include "GraphicsContext.h"
-#include "RenderTheme.h"
 
 namespace WebCore {
 
+#define THEME_COLOR 204
+#define THEME_FONT  210
+
+// Generic state constants
+#define TS_NORMAL    1
+#define TS_HOVER     2
+#define TS_ACTIVE    3
+#define TS_DISABLED  4
+#define TS_FOCUSED   5
+
+// Button constants
+#define BP_BUTTON    1
+#define BP_RADIO     2
+#define BP_CHECKBOX  3
+
+// Textfield constants
+#define TFP_TEXTFIELD 1
+#define TFS_READONLY  6
+
+struct ThemeData {
+    ThemeData() :m_part(0), m_state(0) {}
+
+    unsigned m_part;
+    unsigned m_state;
+};
+    
 class RenderThemeQt : public RenderTheme
 {
 public:
@@ -45,7 +78,7 @@
     //virtual void setRadioSize(RenderStyle* style) const;
 
     virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
-    //virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const \
IntRect&); +    virtual bool paintButton(RenderObject*, const \
RenderObject::PaintInfo&, const IntRect&);  
     //virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) \
                const;
     //virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, \
const IntRect&); @@ -57,7 +90,7 @@
     unsigned determineState(RenderObject*);
     bool supportsFocus(EAppearance);
 
-   // ThemeData getThemeData(RenderObject*);
+   ThemeData getThemeData(RenderObject*);
 };
 
 RenderTheme* theme()
@@ -107,7 +140,6 @@
 
 unsigned RenderThemeQt::determineState(RenderObject* o)
 {
-#if 0
     unsigned result = TS_NORMAL;
     if (!isEnabled(o))
         result = TS_DISABLED;
@@ -122,12 +154,9 @@
     if (isChecked(o))
         result += 4; // 4 unchecked states, 4 checked states.
     return result;
-#endif
-    return 0;
 }
 
-#if 0
-ThemeData RenderThemeGdk::getThemeData(RenderObject* o)
+ThemeData RenderThemeQt::getThemeData(RenderObject* o)
 {
     ThemeData result;
     switch (o->style()->appearance()) {
@@ -152,13 +181,41 @@
 
     return result;
 }
-#endif
 
 void RenderThemeQt::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* \
style, WebCore::Element* e) const  {
     addIntrinsicMargins(style);
 }
 
+bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, \
const IntRect& r) +{
+	qDebug() << "RenderThemeQt::paintButton(), o=" << o << " r=" << r;
+
+	QPainter *painter = (i.p ? static_cast<QPainter *>(i.p->platformContext()) : 0);
+	if (!painter)
+		return true;
+
+	// TODO: This won't work for printing I guess...
+	QWidget *target = static_cast<QWidget *>(painter->device());
+	if (!target)
+		return true;
+
+	QStyle *style = (target ? target->style() : 0);
+	if (!style)
+		return true;
+
+	// Get the correct theme data for a button
+	ThemeData themeData = getThemeData(o);
+
+	// Now paint the button.
+	QStyleOptionButton option;
+	option.initFrom(target);
+	option.rect = r;
+
+	style->drawControl(QStyle::CE_PushButton, &option, painter);
+	return false;
 }
 
+}
+
 // vim: ts=4 sw=4 et


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic