summaryrefslogtreecommitdiffstats
path: root/styles/phase/phasestyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'styles/phase/phasestyle.cpp')
-rw-r--r--styles/phase/phasestyle.cpp421
1 files changed, 218 insertions, 203 deletions
diff --git a/styles/phase/phasestyle.cpp b/styles/phase/phasestyle.cpp
index a36584ba..78f423cc 100644
--- a/styles/phase/phasestyle.cpp
+++ b/styles/phase/phasestyle.cpp
@@ -136,9 +136,12 @@ PhaseStyle::~PhaseStyle()
// --------
// Initialize application specific
-void PhaseStyle::polish(TQApplication* app)
+void PhaseStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags, void *ptr)
{
- if (!qstrcmp(app->argv()[0], "kicker")) kicker_ = true;
+ if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
+ TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
+ if (!qstrcmp(app->argv()[0], "kicker")) kicker_ = true;
+ }
}
//////////////////////////////////////////////////////////////////////////////
@@ -146,34 +149,38 @@ void PhaseStyle::polish(TQApplication* app)
// --------
// Initialize the appearance of a widget
-void PhaseStyle::polish(TQWidget *widget)
+void PhaseStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- if (::tqqt_cast<TQMenuBar*>(widget) ||
- ::tqqt_cast<TQPopupMenu*>(widget)) {
- // anti-flicker optimization
- widget->setBackgroundMode(NoBackground);
- } else if (::tqqt_cast<TQFrame*>(widget) ||
- widget->inherits(TQTOOLBAREXTENSION) ||
- (!qstrcmp(widget->name(), KTOOLBARWIDGET))) {
- // needs special handling on paint events
- widget->installEventFilter(this);
- } else if (highlights_ &&
- (::tqqt_cast<TQPushButton*>(widget) ||
- ::tqqt_cast<TQComboBox*>(widget) ||
- ::tqqt_cast<TQSpinWidget*>(widget) ||
- ::tqqt_cast<TQCheckBox*>(widget) ||
- ::tqqt_cast<TQRadioButton*>(widget) ||
- ::tqqt_cast<TQSlider*>(widget) ||
- widget->inherits(TQSPLITTERHANDLE))) {
- // mouseover highlighting
- widget->installEventFilter(this);
- } else if (highlights_ && ::tqqt_cast<TQTabBar*>(widget)) {
- // highlighting needing mouse tracking
- widget->setMouseTracking(true);
- widget->installEventFilter(this);
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+
+ if (::tqqt_cast<TQMenuBar*>(widget) ||
+ ::tqqt_cast<TQPopupMenu*>(widget)) {
+ // anti-flicker optimization
+ widget->setBackgroundMode(NoBackground);
+ } else if (::tqqt_cast<TQFrame*>(widget) ||
+ widget->inherits(TQTOOLBAREXTENSION) ||
+ (!qstrcmp(widget->name(), KTOOLBARWIDGET))) {
+ // needs special handling on paint events
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (highlights_ &&
+ (::tqqt_cast<TQPushButton*>(widget) ||
+ ::tqqt_cast<TQComboBox*>(widget) ||
+ ::tqqt_cast<TQSpinWidget*>(widget) ||
+ ::tqqt_cast<TQCheckBox*>(widget) ||
+ ::tqqt_cast<TQRadioButton*>(widget) ||
+ ::tqqt_cast<TQSlider*>(widget) ||
+ widget->inherits(TQSPLITTERHANDLE))) {
+ // mouseover highlighting
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (highlights_ && ::tqqt_cast<TQTabBar*>(widget)) {
+ // highlighting needing mouse tracking
+ widget->setMouseTracking(true);
+ installObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
}
- KStyle::polish(widget);
+ KStyle::polish(ceData, elementFlags, ptr);
}
//////////////////////////////////////////////////////////////////////////////
@@ -204,30 +211,34 @@ void PhaseStyle::polish(TQPalette &pal)
// ----------
// Undo the initialization of a widget's appearance
-void PhaseStyle::unPolish(TQWidget *widget)
+void PhaseStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
{
- if (::tqqt_cast<TQMenuBar*>(widget) ||
- ::tqqt_cast<TQPopupMenu*>(widget)) {
- widget->setBackgroundMode(PaletteBackground);
- } else if (::tqqt_cast<TQFrame*>(widget) ||
- widget->inherits(TQTOOLBAREXTENSION) ||
- (!qstrcmp(widget->name(), KTOOLBARWIDGET))) {
- widget->removeEventFilter(this);
- } else if (highlights_ && // highlighting
- (::tqqt_cast<TQPushButton*>(widget) ||
- ::tqqt_cast<TQComboBox*>(widget) ||
- ::tqqt_cast<TQSpinWidget*>(widget) ||
- ::tqqt_cast<TQCheckBox*>(widget) ||
- ::tqqt_cast<TQRadioButton*>(widget) ||
- ::tqqt_cast<TQSlider*>(widget) ||
- widget->inherits(TQSPLITTERHANDLE))) {
- widget->removeEventFilter(this);
- } else if (highlights_ && ::tqqt_cast<TQTabBar*>(widget)) {
- widget->setMouseTracking(false);
- widget->removeEventFilter(this);
+ if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
+ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
+
+ if (::tqqt_cast<TQMenuBar*>(widget) ||
+ ::tqqt_cast<TQPopupMenu*>(widget)) {
+ widget->setBackgroundMode(PaletteBackground);
+ } else if (::tqqt_cast<TQFrame*>(widget) ||
+ widget->inherits(TQTOOLBAREXTENSION) ||
+ (!qstrcmp(widget->name(), KTOOLBARWIDGET))) {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (highlights_ && // highlighting
+ (::tqqt_cast<TQPushButton*>(widget) ||
+ ::tqqt_cast<TQComboBox*>(widget) ||
+ ::tqqt_cast<TQSpinWidget*>(widget) ||
+ ::tqqt_cast<TQCheckBox*>(widget) ||
+ ::tqqt_cast<TQRadioButton*>(widget) ||
+ ::tqqt_cast<TQSlider*>(widget) ||
+ widget->inherits(TQSPLITTERHANDLE))) {
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ } else if (highlights_ && ::tqqt_cast<TQTabBar*>(widget)) {
+ widget->setMouseTracking(false);
+ removeObjectEventHandler(ceData, elementFlags, ptr, this);
+ }
}
- KStyle::unPolish(widget);
+ KStyle::unPolish(ceData, elementFlags, ptr);
}
//////////////////////////////////////////////////////////////////////////////
@@ -2251,162 +2262,166 @@ bool PhaseStyle::flatToolbar(const TQToolBar *toolbar) const
// Grab events we are interested in. Most of this routine is to handle the
// exceptions to the normal styling rules.
-bool PhaseStyle::eventFilter(TQObject *object, TQEvent *event)
+bool PhaseStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags, void* source, TQEvent *event )
{
- if (KStyle::eventFilter(object, event)) return true;
- if (!object->isWidgetType()) return false;
-
- bool horiz;
- int x, y, w, h;
- TQFrame *frame;
- TQToolBar *toolbar;
- TQWidget *widget;
-
- // painting events
- if (event->type() == TQEvent::Paint) {
- // make sure we do the most specific stuff first
-
- // KDE Toolbar Widget
- // patch by Daniel Brownlees <dbrownlees@paradise.net.nz>
- if (object->parent() && !qstrcmp(object->name(), KTOOLBARWIDGET)) {
- if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false;
- TQWidget *parent = ::tqqt_cast<TQWidget*>(object->parent());
- int px = widget->x(), py = widget->y();
- // find the toolbar
- while (parent && parent->parent()
- && !::tqqt_cast<TQToolBar*>(parent)) {
- px += parent->x();
- py += parent->y();
- parent = ::tqqt_cast<TQWidget*>(parent->parent());
- }
- if (!parent) return false;
- TQT_TQRECT_OBJECT(widget->rect()).rect(&x, &y, &w, &h);
- TQRect prect = parent->rect();
-
- toolbar = ::tqqt_cast<TQToolBar*>(parent);
- horiz = (toolbar) ? (toolbar->orientation() == Qt::Horizontal)
- : (prect.height() < prect.width());
- TQPainter painter(widget);
- if (flatToolbar(toolbar)) {
- painter.fillRect(widget->rect(),
- parent->colorGroup().background());
- } else {
- drawPhaseGradient(&painter, widget->rect(),
- parent->colorGroup().background(),
- !horiz, px, py,
- prect.width(), prect.height(), true);
- if (horiz && (h==prect.height()-2)) {
- painter.setPen(parent->colorGroup().mid());
- painter.drawLine(x, h-1, w-1, h-1);
- } else if (!horiz && (w==prect.width()-2)) {
- painter.setPen(parent->colorGroup().mid());
- painter.drawLine(w-1, y, w-1, h-1);
- }
- }
- }
-
- // TQToolBarExtensionWidget
- else if (object && object->isWidgetType() && object->parent() &&
- (toolbar = ::tqqt_cast<TQToolBar*>(object->parent()))) {
- if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false;
- horiz = (toolbar->orientation() == Qt::Horizontal);
- TQPainter painter(widget);
- TQT_TQRECT_OBJECT(widget->rect()).rect(&x, &y, &w, &h);
- // draw the extension
- drawPhaseGradient(&painter, widget->rect(),
- toolbar->colorGroup().background(),
- !horiz, x, y, w-1, h-1, true);
- if (horiz) {
- painter.setPen(toolbar->colorGroup().dark());
- painter.drawLine(w-1, 0, w-1, h-1);
- painter.setPen(toolbar->colorGroup().mid());
- painter.drawLine(w-2, 0, w-2, h-2);
- painter.drawLine(x, h-1, w-2, h-1);
- painter.drawLine(x, y, x, h-2);
- painter.setPen(toolbar->colorGroup().midlight());
- painter.drawLine(x+1, y, x+1, h-2);
- } else {
- painter.setPen(toolbar->colorGroup().dark());
- painter.drawLine(0, h-1, w-1, h-1);
- painter.setPen(toolbar->colorGroup().mid());
- painter.drawLine(0, h-2, w-2, h-2);
- painter.drawLine(w-1, y, w-1, h-2);
- painter.drawLine(x, y, w-2, y);
- painter.setPen(toolbar->colorGroup().midlight());
- painter.drawLine(x, y+1, w-2, y+1);
- }
- }
-
- // TQFrame lines (do this guy last)
- else if (0 != (frame = ::tqqt_cast<TQFrame*>(object))) {
- TQFrame::Shape shape = frame->frameShape();
- switch (shape) {
- case TQFrame::HLine:
- case TQFrame::VLine: {
- // NOTE: assuming lines have no content
- TQPainter painter(frame);
- TQT_TQRECT_OBJECT(frame->rect()).rect(&x, &y, &w, &h);
- painter.setPen(frame->colorGroup().dark());
- if (shape == TQFrame::HLine) {
- painter.drawLine(0, h/2, w, h/2);
- } else if (shape == TQFrame::VLine) {
- painter.drawLine(w/2, 0, w/2, h);
- }
- return true;
- }
- default:
- break;
- }
- }
-
- } else if (highlights_) { // "mouseover" events
- if (::tqqt_cast<TQPushButton*>(object) ||
- ::tqqt_cast<TQComboBox*>(object) ||
- ::tqqt_cast<TQSpinWidget*>(object) ||
- ::tqqt_cast<TQCheckBox*>(object) ||
- ::tqqt_cast<TQRadioButton*>(object) ||
- ::tqqt_cast<TQSlider*>(object) ||
- object->inherits(TQSPLITTERHANDLE)) {
- if (event->type() == TQEvent::Enter) {
- if (0 != (widget = ::tqqt_cast<TQWidget*>(object)) &&
- widget->isEnabled()) {
- hover_ = widget;
- widget->repaint(false);
- }
- } else if (event->type() == TQEvent::Leave) {
- if (0 != (widget = ::tqqt_cast<TQWidget*>(object))) {
- hover_ = 0;
- widget->repaint(false);
- }
- }
- } else if (::tqqt_cast<TQTabBar*>(object)) { // special case for qtabbar
- if (event->type() == TQEvent::Enter) {
- if (0 != (widget = ::tqqt_cast<TQWidget*>(object)) &&
- widget->isEnabled()) {
- hover_ = widget;
- hovertab_ = 0;;
- widget->repaint(false);
- }
- } else if (event->type() == TQEvent::Leave) {
- if (0 != (widget = ::tqqt_cast<TQWidget*>(object))) {
- hover_ = 0;
- hovertab_ = 0;;
- widget->repaint(false);
- }
- } else if (event->type() == TQEvent::MouseMove) {
- TQTabBar *tabbar;
- if (0 != (tabbar = ::tqqt_cast<TQTabBar*>(object))) {
- TQMouseEvent *me;
- if (0 != (me = dynamic_cast<TQMouseEvent*>(event))) {
- TQTab *tab = tabbar->selectTab(me->pos());
- if (hovertab_ != tab) {
- hovertab_ = tab;
- tabbar->repaint(false);
- }
- }
- }
- }
- }
+ if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
+ TQObject* object = reinterpret_cast<TQObject*>(source);
+
+ if (KStyle::eventFilter(object, event)) return true;
+ if (!object->isWidgetType()) return false;
+
+ bool horiz;
+ int x, y, w, h;
+ TQFrame *frame;
+ TQToolBar *toolbar;
+ TQWidget *widget;
+
+ // painting events
+ if (event->type() == TQEvent::Paint) {
+ // make sure we do the most specific stuff first
+
+ // KDE Toolbar Widget
+ // patch by Daniel Brownlees <dbrownlees@paradise.net.nz>
+ if (object->parent() && !qstrcmp(object->name(), KTOOLBARWIDGET)) {
+ if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false;
+ TQWidget *parent = ::tqqt_cast<TQWidget*>(object->parent());
+ int px = widget->x(), py = widget->y();
+ // find the toolbar
+ while (parent && parent->parent()
+ && !::tqqt_cast<TQToolBar*>(parent)) {
+ px += parent->x();
+ py += parent->y();
+ parent = ::tqqt_cast<TQWidget*>(parent->parent());
+ }
+ if (!parent) return false;
+ TQT_TQRECT_OBJECT(widget->rect()).rect(&x, &y, &w, &h);
+ TQRect prect = parent->rect();
+
+ toolbar = ::tqqt_cast<TQToolBar*>(parent);
+ horiz = (toolbar) ? (toolbar->orientation() == Qt::Horizontal)
+ : (prect.height() < prect.width());
+ TQPainter painter(widget);
+ if (flatToolbar(toolbar)) {
+ painter.fillRect(widget->rect(),
+ parent->colorGroup().background());
+ } else {
+ drawPhaseGradient(&painter, widget->rect(),
+ parent->colorGroup().background(),
+ !horiz, px, py,
+ prect.width(), prect.height(), true);
+ if (horiz && (h==prect.height()-2)) {
+ painter.setPen(parent->colorGroup().mid());
+ painter.drawLine(x, h-1, w-1, h-1);
+ } else if (!horiz && (w==prect.width()-2)) {
+ painter.setPen(parent->colorGroup().mid());
+ painter.drawLine(w-1, y, w-1, h-1);
+ }
+ }
+ }
+
+ // TQToolBarExtensionWidget
+ else if (object && object->isWidgetType() && object->parent() &&
+ (toolbar = ::tqqt_cast<TQToolBar*>(object->parent()))) {
+ if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false;
+ horiz = (toolbar->orientation() == Qt::Horizontal);
+ TQPainter painter(widget);
+ TQT_TQRECT_OBJECT(widget->rect()).rect(&x, &y, &w, &h);
+ // draw the extension
+ drawPhaseGradient(&painter, widget->rect(),
+ toolbar->colorGroup().background(),
+ !horiz, x, y, w-1, h-1, true);
+ if (horiz) {
+ painter.setPen(toolbar->colorGroup().dark());
+ painter.drawLine(w-1, 0, w-1, h-1);
+ painter.setPen(toolbar->colorGroup().mid());
+ painter.drawLine(w-2, 0, w-2, h-2);
+ painter.drawLine(x, h-1, w-2, h-1);
+ painter.drawLine(x, y, x, h-2);
+ painter.setPen(toolbar->colorGroup().midlight());
+ painter.drawLine(x+1, y, x+1, h-2);
+ } else {
+ painter.setPen(toolbar->colorGroup().dark());
+ painter.drawLine(0, h-1, w-1, h-1);
+ painter.setPen(toolbar->colorGroup().mid());
+ painter.drawLine(0, h-2, w-2, h-2);
+ painter.drawLine(w-1, y, w-1, h-2);
+ painter.drawLine(x, y, w-2, y);
+ painter.setPen(toolbar->colorGroup().midlight());
+ painter.drawLine(x, y+1, w-2, y+1);
+ }
+ }
+
+ // TQFrame lines (do this guy last)
+ else if (0 != (frame = ::tqqt_cast<TQFrame*>(object))) {
+ TQFrame::Shape shape = frame->frameShape();
+ switch (shape) {
+ case TQFrame::HLine:
+ case TQFrame::VLine: {
+ // NOTE: assuming lines have no content
+ TQPainter painter(frame);
+ TQT_TQRECT_OBJECT(frame->rect()).rect(&x, &y, &w, &h);
+ painter.setPen(frame->colorGroup().dark());
+ if (shape == TQFrame::HLine) {
+ painter.drawLine(0, h/2, w, h/2);
+ } else if (shape == TQFrame::VLine) {
+ painter.drawLine(w/2, 0, w/2, h);
+ }
+ return true;
+ }
+ default:
+ break;
+ }
+ }
+
+ } else if (highlights_) { // "mouseover" events
+ if (::tqqt_cast<TQPushButton*>(object) ||
+ ::tqqt_cast<TQComboBox*>(object) ||
+ ::tqqt_cast<TQSpinWidget*>(object) ||
+ ::tqqt_cast<TQCheckBox*>(object) ||
+ ::tqqt_cast<TQRadioButton*>(object) ||
+ ::tqqt_cast<TQSlider*>(object) ||
+ object->inherits(TQSPLITTERHANDLE)) {
+ if (event->type() == TQEvent::Enter) {
+ if (0 != (widget = ::tqqt_cast<TQWidget*>(object)) &&
+ widget->isEnabled()) {
+ hover_ = widget;
+ widget->repaint(false);
+ }
+ } else if (event->type() == TQEvent::Leave) {
+ if (0 != (widget = ::tqqt_cast<TQWidget*>(object))) {
+ hover_ = 0;
+ widget->repaint(false);
+ }
+ }
+ } else if (::tqqt_cast<TQTabBar*>(object)) { // special case for qtabbar
+ if (event->type() == TQEvent::Enter) {
+ if (0 != (widget = ::tqqt_cast<TQWidget*>(object)) &&
+ widget->isEnabled()) {
+ hover_ = widget;
+ hovertab_ = 0;;
+ widget->repaint(false);
+ }
+ } else if (event->type() == TQEvent::Leave) {
+ if (0 != (widget = ::tqqt_cast<TQWidget*>(object))) {
+ hover_ = 0;
+ hovertab_ = 0;;
+ widget->repaint(false);
+ }
+ } else if (event->type() == TQEvent::MouseMove) {
+ TQTabBar *tabbar;
+ if (0 != (tabbar = ::tqqt_cast<TQTabBar*>(object))) {
+ TQMouseEvent *me;
+ if (0 != (me = dynamic_cast<TQMouseEvent*>(event))) {
+ TQTab *tab = tabbar->selectTab(me->pos());
+ if (hovertab_ != tab) {
+ hovertab_ = tab;
+ tabbar->repaint(false);
+ }
+ }
+ }
+ }
+ }
+ }
}
return false;