TQStyle API update

pull/1/head
Timothy Pearson 12 years ago
parent 8a81e3e9ad
commit 4fc58f393f

@ -119,27 +119,35 @@ TQString TQtCKStyle::defaultStyle()
} }
void TQtCKStyle::polish( TQWidget* widget ) void TQtCKStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{ {
if ( d->useFilledFrameWorkaround ) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
{ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
TQFrame::Shape shape = frame->frameShape(); if ( d->useFilledFrameWorkaround )
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel) {
widget->installEventFilter(this); if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
TQFrame::Shape shape = frame->frameShape();
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
installObjectEventHandler(ceData, elementFlags, ptr, this);
}
} }
} }
} }
void TQtCKStyle::unPolish( TQWidget* widget ) void TQtCKStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr )
{ {
if ( d->useFilledFrameWorkaround ) if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
{ TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
TQFrame::Shape shape = frame->frameShape(); if ( d->useFilledFrameWorkaround )
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel) {
widget->removeEventFilter(this); if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) {
TQFrame::Shape shape = frame->frameShape();
if (shape == TQFrame::ToolBarPanel || shape == TQFrame::MenuBarPanel)
removeObjectEventHandler(ceData, elementFlags, ptr, this);
}
} }
} }
} }
@ -1671,51 +1679,54 @@ int TQtCKStyle::styleHint( StyleHint sh, TQStyleControlElementData ceData, Contr
} }
} }
bool TQtCKStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
bool TQtCKStyle::eventFilter( TQObject* object, TQEvent* event )
{ {
if ( d->useFilledFrameWorkaround ) if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
{ TQObject* object = reinterpret_cast<TQObject*>(source);
// Make the TQMenuBar/TQToolBar paintEvent() cover a larger area to
// ensure that the filled frame contents are properly painted. if ( d->useFilledFrameWorkaround )
// We essentially modify the paintEvent's rect to include the
// panel border, which also paints the widget's interior.
// This is nasty, but I see no other way to properly repaint
// filled frames in all TQMenuBars and TQToolBars.
// -- Karol.
TQFrame *frame = 0;
if ( event->type() == TQEvent::Paint
&& (frame = ::tqqt_cast<TQFrame*>(object)) )
{ {
if (frame->frameShape() != TQFrame::ToolBarPanel && frame->frameShape() != TQFrame::MenuBarPanel) // Make the TQMenuBar/TQToolBar paintEvent() cover a larger area to
return false; // ensure that the filled frame contents are properly painted.
// We essentially modify the paintEvent's rect to include the
// panel border, which also paints the widget's interior.
// This is nasty, but I see no other way to properly repaint
// filled frames in all TQMenuBars and TQToolBars.
// -- Karol.
TQFrame *frame = 0;
if ( event->type() == TQEvent::Paint
&& (frame = ::tqqt_cast<TQFrame*>(object)) )
{
if (frame->frameShape() != TQFrame::ToolBarPanel && frame->frameShape() != TQFrame::MenuBarPanel)
return false;
bool horizontal = true; bool horizontal = true;
TQPaintEvent* pe = (TQPaintEvent*)event; TQPaintEvent* pe = (TQPaintEvent*)event;
TQToolBar *toolbar = ::tqqt_cast< TQToolBar *>( frame ); TQToolBar *toolbar = ::tqqt_cast< TQToolBar *>( frame );
TQRect r = pe->rect(); TQRect r = pe->rect();
if (toolbar && toolbar->orientation() == Qt::Vertical) if (toolbar && toolbar->orientation() == Qt::Vertical)
horizontal = false; horizontal = false;
if (horizontal) { if (horizontal) {
if ( r.height() == frame->height() ) if ( r.height() == frame->height() )
return false; // Let TQFrame handle the painting now. return false; // Let TQFrame handle the painting now.
// Else, send a new paint event with an updated paint rect. // Else, send a new paint event with an updated paint rect.
TQPaintEvent dummyPE( TQRect( r.x(), 0, r.width(), frame->height()) ); TQPaintEvent dummyPE( TQRect( r.x(), 0, r.width(), frame->height()) );
TQApplication::sendEvent( frame, &dummyPE ); TQApplication::sendEvent( frame, &dummyPE );
} }
else { // Vertical else { // Vertical
if ( r.width() == frame->width() ) if ( r.width() == frame->width() )
return false; return false;
TQPaintEvent dummyPE( TQRect( 0, r.y(), frame->width(), r.height()) ); TQPaintEvent dummyPE( TQRect( 0, r.y(), frame->width(), r.height()) );
TQApplication::sendEvent( frame, &dummyPE ); TQApplication::sendEvent( frame, &dummyPE );
} }
// Discard this event as we sent a new paintEvent. // Discard this event as we sent a new paintEvent.
return true; return true;
}
} }
} }

@ -253,8 +253,8 @@ class TQtCKStyle: public TQCommonStyle
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void polish( TQWidget* widget ); void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void unPolish( TQWidget* widget ); void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
void polishPopupMenu( TQPopupMenu* ); void polishPopupMenu( TQPopupMenu* );
void drawPrimitive( PrimitiveElement pe, void drawPrimitive( PrimitiveElement pe,
@ -320,7 +320,7 @@ class TQtCKStyle: public TQCommonStyle
const TQWidget* w = 0 ) const; const TQWidget* w = 0 ) const;
protected: protected:
bool eventFilter( TQObject* object, TQEvent* event ); virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
private: private:
// Disable copy constructor and = operator // Disable copy constructor and = operator

File diff suppressed because it is too large Load Diff

@ -134,11 +134,11 @@ class TQtCurveStyle : public BASE_STYLE
virtual ~TQtCurveStyle(); virtual ~TQtCurveStyle();
void polish(TQApplication *app); void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void polish(TQPalette &pal); void polish(TQPalette &pal);
TQColorGroup setColorGroup(const TQColorGroup &old, const TQColorGroup &act, bool dis=false); TQColorGroup setColorGroup(const TQColorGroup &old, const TQColorGroup &act, bool dis=false);
void polish(TQWidget *widget); void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void unPolish(TQWidget *widget); void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void drawLightBevel(TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags, void drawLightBevel(TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags,
int round, const TQColor &fill, const TQColor *custom=NULL, int round, const TQColor &fill, const TQColor *custom=NULL,
bool doBorder=true, bool doCorners=true, EWidget w=WIDGET_OTHER) const bool doBorder=true, bool doCorners=true, EWidget w=WIDGET_OTHER) const
@ -186,7 +186,7 @@ class TQtCurveStyle : public BASE_STYLE
protected: protected:
bool appIsNotEmbedded(TQDialog *dlg); bool appIsNotEmbedded(TQDialog *dlg);
bool eventFilter(TQObject *object, TQEvent *event); virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
void drawMenuItem(TQPainter *p, const TQRect &r, int flags, const TQColorGroup &cg, void drawMenuItem(TQPainter *p, const TQRect &r, int flags, const TQColorGroup &cg,
bool mbi, int round, const TQColor &bgnd, const TQColor *cols) const; bool mbi, int round, const TQColor &bgnd, const TQColor *cols) const;
void drawProgress(TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags, int round, void drawProgress(TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags, int round,

Loading…
Cancel
Save