diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/qapplication.cpp | 37 | ||||
-rw-r--r-- | src/kernel/qapplication_x11.cpp | 4 | ||||
-rw-r--r-- | src/kernel/qstyle.cpp | 35 | ||||
-rw-r--r-- | src/kernel/qstyle.h | 71 |
4 files changed, 117 insertions, 30 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 7296f4c..0478cf1 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -2557,6 +2557,21 @@ bool QApplication::event( QEvent *e ) return QObject::event(e); } +#define HOVER_SENSITIVE_WIDGET_SELECT if ( widget->inherits("QPushButton") \ + || widget->inherits("QComboBox") \ + || widget->inherits("QSpinWidget") \ + || widget->inherits("QCheckBox") \ + || widget->inherits("QRadioButton") \ + || widget->inherits("QToolButton") \ + || widget->inherits("QSlider") \ + || widget->inherits("QScrollBar") \ + || widget->inherits("QTabBar") \ + || widget->inherits("QDockWindowHandle") \ + || widget->inherits("QSplitterHandle") ) + +#define FOCUS_SENSITIVE_WIDGET_SELECT if ( widget->inherits("QLineEdit") ) +#define FOCUS_SENSITIVE_PARENT_WIDGET_SELECT if ( widget->parentWidget() && widget->parentWidget()->inherits("QSpinWidget") ) + /*!\internal Helper function called by notify() @@ -2579,10 +2594,28 @@ bool QApplication::internalNotify( QObject *receiver, QEvent * e) QWidget *widget = (QWidget*)receiver; // toggle HasMouse widget state on enter and leave - if ( e->type() == QEvent::Enter || e->type() == QEvent::DragEnter ) + if ( e->type() == QEvent::Enter || e->type() == QEvent::DragEnter ) { widget->setWState( WState_HasMouse ); - else if ( e->type() == QEvent::Leave || e->type() == QEvent::DragLeave ) + HOVER_SENSITIVE_WIDGET_SELECT { + widget->repaint(false); + } + } + else if ( e->type() == QEvent::Leave || e->type() == QEvent::DragLeave ) { widget->clearWState( WState_HasMouse ); + HOVER_SENSITIVE_WIDGET_SELECT { + widget->repaint(false); + } + } + + // repaint information entry widgets on focus set/unset + if ( e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut ) { + FOCUS_SENSITIVE_WIDGET_SELECT { + widget->repaint(false); + } + FOCUS_SENSITIVE_PARENT_WIDGET_SELECT { + widget->parentWidget()->repaint(false); + } + } // throw away any mouse-tracking-only mouse events if ( e->type() == QEvent::MouseMove && diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 6a68604..2873b9e 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -5184,8 +5184,6 @@ bool QETWidget::translateKeyEventInternal( const XEvent *event, int& count, qAddPostRoutine( deleteKeyDicts ); } - QWidget* tlw = topLevelWidget(); - XKeyEvent xkeyevent = event->xkey; // save the modifier state, we will use the keystate uint later by passing @@ -5211,7 +5209,6 @@ bool QETWidget::translateKeyEventInternal( const XEvent *event, int& count, // Implementation for X11R5 and newer, using XIM int keycode = event->xkey.keycode; - Status status; if ( type == QEvent::KeyPress ) { bool mb=FALSE; @@ -5295,7 +5292,6 @@ bool QETWidget::translateKeyEventInternal( const XEvent *event, int& count, // and independent of whether char is signed or not. textDict->replace( keycode, (void*)(long)(256+ascii) ); } - tlw = 0; } else { key = (int)(long)keyDict->find( keycode ); if ( key ) diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index e7d3fa5..843027d 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -48,6 +48,7 @@ #include "qlayout.h" #include "qlistview.h" #include "qpopupmenu.h" +#include "qpushbutton.h" #include "qobjectlist.h" #include "qwidgetlist.h" @@ -2165,7 +2166,16 @@ bool QStyle::eventFilter(QObject *o, QEvent *e) { QStyle* handler = m_objectEventSourceToHandlerMap[o]; QStyleControlElementData ceData = m_objectEventSourceDataToHandlerMap[o]; ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; - bool ret = handler->objectEventHandler(ceData, elementFlags, o, e); + bool ret; + QWidget* w = dynamic_cast<QWidget*>(o); + if ((w) && (e->type() == QEvent::Paint)) { + QPainter p(w); + ceData.activePainter = &p; + ret = handler->objectEventHandler(ceData, elementFlags, o, e); + } + else { + ret = handler->objectEventHandler(ceData, elementFlags, o, e); + } if (ret) { return ret; } @@ -2291,6 +2301,21 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen } delete list; } + else if (request == WAR_SetDefault) { + QPushButton *button = dynamic_cast<QPushButton*>(widget); + if (button) { + button->setDefault(TRUE); + } + } + else if (request == WAR_UnSetDefault) { + QPushButton *button = dynamic_cast<QPushButton*>(widget); + if (button) { + button->setDefault(FALSE); + } + } + else if (request == WAR_SendPaintEvent) { + static_cast<QObject*>(widget)->event(requestData.paintEvent); + } return true; } } @@ -2395,6 +2420,10 @@ QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QRect param) { rect = param; } +QStyleWidgetActionRequestData::QStyleWidgetActionRequestData(QPaintEvent* param) { + paintEvent = param; +} + QStyleWidgetActionRequestData::~QStyleWidgetActionRequestData() { // } @@ -2575,4 +2604,8 @@ QPixmap QStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption \obsolete */ +QStyleControlElementData::QStyleControlElementData() { + activePainter = 0; +} + #endif // QT_NO_STYLE diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 2d76d09..1d20b8c 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -63,26 +63,26 @@ class QStyleOption { public: enum StyleOptionDefault { Default }; - QStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL), cli(NULL) {} + QStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL), cli(NULL), tbh(NULL) {} // Note: we don't use default arguments since that is unnecessary // initialization. QStyleOption(int in1) : - def(FALSE), tb(NULL), i1(in1), cli(NULL) {} + def(FALSE), tb(NULL), i1(in1), cli(NULL), tbh(NULL) {} QStyleOption(int in1, int in2) : - def(FALSE), tb(NULL), i1(in1), i2(in2), cli(NULL) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), cli(NULL), tbh(NULL) {} QStyleOption(int in1, int in2, int in3, int in4) : - def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4), cli(NULL) {} - QStyleOption(QMenuItem* m) : def(FALSE), mi(m), tb(NULL), cli(NULL) {} - QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1), cli(NULL) {} - QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2), cli(NULL) {} - QStyleOption(const QColor& c) : def(FALSE), tb(NULL), cl(&c), cli(NULL) {} - QStyleOption(QTab* t) : def(FALSE), tb(t), cli(NULL) {} - QStyleOption(QListViewItem* i) : def(FALSE), tb(NULL), li(i), cli(NULL) {} - QStyleOption(QCheckListItem* i) : def(FALSE), tb(NULL), cli(i) {} - QStyleOption(Qt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a), cli(NULL) {} - QStyleOption(const QRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()), i4(r.height()), cli(NULL) {} - QStyleOption(QWidget *w) : def(FALSE), tb(NULL), cli(NULL), p1((void*)w) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4), cli(NULL), tbh(NULL) {} + QStyleOption(QMenuItem* m) : def(FALSE), mi(m), tb(NULL), cli(NULL), tbh(NULL) {} + QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1), cli(NULL), tbh(NULL) {} + QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2), cli(NULL), tbh(NULL) {} + QStyleOption(const QColor& c) : def(FALSE), tb(NULL), cl(&c), cli(NULL), tbh(NULL) {} + QStyleOption(QTab* t) : def(FALSE), tb(t), cli(NULL), tbh(NULL) {} + QStyleOption(QListViewItem* i) : def(FALSE), tb(NULL), li(i), cli(NULL), tbh(NULL) {} + QStyleOption(QCheckListItem* i) : def(FALSE), tb(NULL), cli(i), tbh(NULL) {} + QStyleOption(Qt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a), cli(NULL), tbh(NULL) {} + QStyleOption(const QRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()), i4(r.height()), cli(NULL), tbh(NULL) {} + QStyleOption(QWidget *w) : def(FALSE), tb(NULL), cli(NULL), p1((void*)w), tbh(NULL) {} bool isDefault() const { return def; } @@ -109,6 +109,9 @@ public: QRect rect() const { return QRect( i1, i2, i3, i4 ); } QWidget* widget() const { return (QWidget*)p1; } + QStyleOption(QTab* t, QTab* h) : def(FALSE), tb(t), cli(NULL), tbh(h) {} + QTab* hoverTab() const { return tbh; } + private: // NOTE: none of these components have constructors. bool def; @@ -121,6 +124,7 @@ private: int i5, i6; // reserved QCheckListItem* cli; void *p1, *p2, *p3, *p4; // reserved + QTab* tbh; // (padded to 64 bytes on some architectures) }; @@ -129,6 +133,8 @@ class QStyleHintReturn; // not defined yet typedef QMap<Q_UINT32, QSize> DialogButtonSizeMap; typedef QMap<Q_INT32, Q_INT32> TabIdentifierIndexMap; +class QStyleControlElementGenericWidgetData; + class QStyleControlElementPopupMenuData { public: // @@ -142,13 +148,6 @@ class QStyleControlElementCheckListItemData { int height; }; -class QStyleControlElementTabBarData { - public: - int tabCount; - QTabBar::Shape shape; - TabIdentifierIndexMap identIndexMap; -}; - class QStyleControlElementListViewData { public: bool rootDecorated; @@ -200,7 +199,23 @@ class QStyleControlElementGenericWidgetData { QFont font; }; -class QStyleControlElementData { +class QStyleControlElementTabBarData { + public: + int tabCount; + int currentTabIndex; + QTabBar::Shape shape; + TabIdentifierIndexMap identIndexMap; + QStyleControlElementGenericWidgetData cornerWidgets[4]; + + enum CornerWidgetLocation { + CWL_TopLeft = 0, + CWL_TopRight = 1, + CWL_BottomLeft = 2, + CWL_BottomRight = 3 + }; +}; + +class Q_EXPORT QStyleControlElementData { public: QStringList widgetObjectTypes; bool allDataPopulated; @@ -251,6 +266,10 @@ class QStyleControlElementData { Q_UINT32 comboBoxLineEditFlags; Q_UINT32 frameStyle; QRect sliderRect; + QPainter* activePainter; + + public: + QStyleControlElementData(); }; class Q_EXPORT QStyleWidgetActionRequestData { @@ -260,6 +279,7 @@ class Q_EXPORT QStyleWidgetActionRequestData { QStyleWidgetActionRequestData(QPalette palette, bool informWidgets = FALSE, const char* className = 0); QStyleWidgetActionRequestData(QFont font, bool informWidgets = FALSE, const char* className = 0); QStyleWidgetActionRequestData(QRect rect); + QStyleWidgetActionRequestData(QPaintEvent* paintEvent); ~QStyleWidgetActionRequestData(); public: bool bool1; @@ -271,6 +291,7 @@ class Q_EXPORT QStyleWidgetActionRequestData { QRect rect; const char * cstr; QString string; + QPaintEvent * paintEvent; }; typedef QStyleWidgetActionRequestData QStyleApplicationActionRequestData; @@ -309,6 +330,7 @@ public: CEF_IsActiveWindow = 0x00200000, CEF_IsTopLevel = 0x00400000, CEF_IsVisible = 0x00800000, + CEF_HasMouse = 0x01000000 }; // New QStyle API - most of these should probably be pure virtual @@ -1094,7 +1116,10 @@ public: WAR_SetBackgroundMode, WAR_SetBackgroundOrigin, WAR_SetFont, - WAR_RepaintAllAccelerators + WAR_RepaintAllAccelerators, + WAR_SetDefault, + WAR_UnSetDefault, + WAR_SendPaintEvent }; typedef bool (*WidgetActionRequestHook)(QStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, QStyleWidgetActionRequestData requestData); |