Update styles for new API

pull/1/head
Timothy Pearson 12 years ago
parent c8898cf01f
commit f16f8eb6bf

@ -711,7 +711,7 @@ void dotNETstyle::drawPrimitive(TQ_PrimitiveElement pe,
else else
cflags |= Style_On; cflags |= Style_On;
TQRect rr = TQRect( x + 6, y + 6, 16, h - 6 ); TQRect rr = TQRect( x + 4, y + 2, 16, h - 2 );
if (TQApplication::reverseLayout()) if (TQApplication::reverseLayout())
rr = visualRect( rr, r ); rr = visualRect( rr, r );
@ -1390,7 +1390,7 @@ void dotNETstyle::drawControl(TQ_ControlElement element,
if (checkable) { if (checkable) {
if (mi->isChecked()) { if (mi->isChecked()) {
drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt);
} }
} }
@ -1906,6 +1906,15 @@ int dotNETstyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, Co
return 1; return 1;
} }
case PM_MenuIndicatorFrameHBorder:
return 4;
case PM_MenuIndicatorFrameVBorder:
return 2;
case PM_MenuIconIndicatorFrameHBorder:
return 4;
case PM_MenuIconIndicatorFrameVBorder:
return 2;
default: default:
return KStyle::pixelMetric(m, ceData, elementFlags, widget); return KStyle::pixelMetric(m, ceData, elementFlags, widget);
} }
@ -2108,4 +2117,22 @@ bool dotNETstyle::objectEventHandler( TQStyleControlElementData ceData, ControlE
return false; return false;
} }
int dotNETstyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &opt, TQStyleHintReturn *returnData, const TQWidget *w) const
{
int ret;
switch (sh) {
case SH_MenuIndicatorColumnWidth:
{
ret = TQMAX(opt.maxIconWidth(), 26);
}
break;
default:
ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
break;
}
return ret;
}
// vim: noet ts=4 sw=4 // vim: noet ts=4 sw=4

@ -104,36 +104,41 @@ public:
const TQWidget *widget = 0 ) const; const TQWidget *widget = 0 ) const;
void drawComplexControlMask(TQStyle::ComplexControl c, void drawComplexControlMask(TQStyle::ComplexControl c,
TQPainter *p, TQPainter *p,
const TQStyleControlElementData ceData, const TQStyleControlElementData ceData,
const ControlElementFlags elementFlags, const ControlElementFlags elementFlags,
const TQRect &r, const TQRect &r,
const TQStyleOption &o=TQStyleOption::Default, const TQStyleOption &o=TQStyleOption::Default,
const TQWidget *w = 0) const; const TQWidget *w = 0) const;
TQSize sizeFromContents(TQStyle::ContentsType t, TQSize sizeFromContents(TQStyle::ContentsType t,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
const TQSize &s, const TQSize &s,
const TQStyleOption &o, const TQStyleOption &o,
const TQWidget *w = 0) const; const TQWidget *w = 0) const;
int styleHint(TQ_StyleHint, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
const TQStyleOption & = TQStyleOption::Default,
TQStyleHintReturn * = 0, const TQWidget * = 0 ) const;
protected: protected:
void renderButton(TQPainter *p, void renderButton(TQPainter *p,
const TQRect &r, const TQRect &r,
const TQColorGroup &g, const TQColorGroup &g,
bool sunken = false, bool sunken = false,
bool corners = false) const; bool corners = false) const;
void renderPanel(TQPainter *p, void renderPanel(TQPainter *p,
const TQRect &r, const TQRect &r,
const TQColorGroup &g, const TQColorGroup &g,
bool sunken = true, bool sunken = true,
bool thick = true) const; bool thick = true) const;
void renderSlider(TQPainter *p, void renderSlider(TQPainter *p,
const TQRect &r, const TQRect &r,
const TQColorGroup &g) const; const TQColorGroup &g) const;
bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
void updatePalette( TQComboBox * ); void updatePalette( TQComboBox * );
@ -145,7 +150,7 @@ protected slots:
void paletteChanged(); void paletteChanged();
private: private:
// Disable copy constructor and = operator // Disable copy constructor and = operator
dotNETstyle( const dotNETstyle & ); dotNETstyle( const dotNETstyle & );
dotNETstyle& operator=( const dotNETstyle & ); dotNETstyle& operator=( const dotNETstyle & );
TQStyle *winstyle; TQStyle *winstyle;

@ -1015,9 +1015,11 @@ void PhaseStyle::drawPrimitive(TQ_PrimitiveElement element,
break; break;
} }
case PE_MenuItemIndicatorCheck: { case PE_MenuItemIndicatorCheck: {
int checkwidth = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, option, NULL, NULL);
int cx = reverse_ ? x+w - checkwidth : x;
drawPrimitive(PE_CheckMark, painter, ceData, elementFlags, drawPrimitive(PE_CheckMark, painter, ceData, elementFlags,
TQRect(x + ITEMFRAME, y + ITEMFRAME, TQRect(cx + ITEMFRAME, y + ITEMFRAME,
w - ITEMFRAME*2, h - ITEMFRAME*2), checkwidth - ITEMFRAME*2, h - ITEMFRAME*2),
group, Style_Default | group, Style_Default |
(active ? Style_Enabled : Style_On)); (active ? Style_Enabled : Style_On));
break; break;
@ -1415,8 +1417,7 @@ void PhaseStyle::drawControl(TQ_ControlElement element,
// draw check // draw check
if (mi->isChecked()) { if (mi->isChecked()) {
int cx = reverse_ ? x+w - checkwidth : x; drawPrimitive(PE_MenuItemIndicatorCheck, painter, ceData, elementFlags, TQRect(x, y, checkwidth, h), group, flags, option);
drawPrimitive(PE_MenuItemIndicatorCheck, painter, ceData, elementFlags, TQRect(cx, y, checkwidth, h), group, flags);
} }
// draw text // draw text
@ -2024,6 +2025,12 @@ int PhaseStyle::pixelMetric(PixelMetric metric, TQStyleControlElementData ceData
case PM_SliderControlThickness: case PM_SliderControlThickness:
return em; return em;
case PM_MenuIndicatorFrameHBorder:
case PM_MenuIndicatorFrameVBorder:
case PM_MenuIconIndicatorFrameHBorder:
case PM_MenuIconIndicatorFrameVBorder:
return ITEMFRAME;
default: default:
return KStyle::pixelMetric(metric, ceData, elementFlags, widget); return KStyle::pixelMetric(metric, ceData, elementFlags, widget);
} }
@ -2257,6 +2264,29 @@ bool PhaseStyle::flatToolbar(const TQToolBar *toolbar) const
return false; return false;
} }
int PhaseStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &opt, TQStyleHintReturn *returnData, const TQWidget *w) const
{
int ret;
switch (sh) {
case SH_MenuIndicatorColumnWidth:
{
int checkwidth = opt.maxIconWidth();
bool checkable = (elementFlags & CEF_IsCheckable);
if (checkable) checkwidth = TQMAX(checkwidth, 20);
ret = checkwidth;
}
break;
default:
ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
break;
}
return ret;
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// eventFilter() // eventFilter()
// ------------- // -------------

@ -34,165 +34,169 @@ class KPixmap;
class GradientSet class GradientSet
{ {
public: public:
enum GradientType { enum GradientType {
Horizontal, Horizontal,
Vertical, Vertical,
HorizontalReverse, HorizontalReverse,
VerticalReverse, VerticalReverse,
GradientTypeCount GradientTypeCount
}; };
GradientSet(const TQColor &color, int size); GradientSet(const TQColor &color, int size);
~GradientSet(); ~GradientSet();
KPixmap* gradient(bool horizontal, bool reverse); KPixmap* gradient(bool horizontal, bool reverse);
private: private:
KPixmap *set[GradientTypeCount]; KPixmap *set[GradientTypeCount];
TQColor color_; TQColor color_;
int size_; int size_;
}; };
class PhaseStyle : public KStyle class PhaseStyle : public KStyle
{ {
Q_OBJECT Q_OBJECT
public: public:
PhaseStyle(); PhaseStyle();
virtual ~PhaseStyle(); virtual ~PhaseStyle();
void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void polish(TQPalette &pal); void polish(TQPalette &pal);
void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *);
void drawPrimitive(TQ_PrimitiveElement element, void drawPrimitive(TQ_PrimitiveElement element,
TQPainter *painter, TQPainter *painter,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
const TQRect &rect, const TQRect &rect,
const TQColorGroup &group, const TQColorGroup &group,
SFlags flags = Style_Default, SFlags flags = Style_Default,
const TQStyleOption &option = TQStyleOption::Default) const; const TQStyleOption &option = TQStyleOption::Default) const;
void drawKStylePrimitive(KStylePrimitive element, void drawKStylePrimitive(KStylePrimitive element,
TQPainter *painter, TQPainter *painter,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
const TQRect &rect, const TQRect &rect,
const TQColorGroup &group, const TQColorGroup &group,
SFlags flags = Style_Default, SFlags flags = Style_Default,
const TQStyleOption &option = TQStyleOption::Default, const TQStyleOption &option = TQStyleOption::Default,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
void drawControl(TQ_ControlElement element, void drawControl(TQ_ControlElement element,
TQPainter *painter, TQPainter *painter,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
const TQRect &rect, const TQRect &rect,
const TQColorGroup &group, const TQColorGroup &group,
SFlags flags = Style_Default, SFlags flags = Style_Default,
const TQStyleOption &option = TQStyleOption::Default, const TQStyleOption &option = TQStyleOption::Default,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
void drawControlMask(TQ_ControlElement element, void drawControlMask(TQ_ControlElement element,
TQPainter *painter, TQPainter *painter,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
const TQRect &rect, const TQRect &rect,
const TQStyleOption &option = TQStyleOption::Default, const TQStyleOption &option = TQStyleOption::Default,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
void drawComplexControl(TQ_ComplexControl control, void drawComplexControl(TQ_ComplexControl control,
TQPainter *painter, TQPainter *painter,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
const TQRect &rect, const TQRect &rect,
const TQColorGroup &group, const TQColorGroup &group,
SFlags flags = Style_Default, SFlags flags = Style_Default,
SCFlags controls = SC_All, SCFlags controls = SC_All,
SCFlags active = SC_None, SCFlags active = SC_None,
const TQStyleOption &option = TQStyleOption::Default, const TQStyleOption &option = TQStyleOption::Default,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
void drawComplexControlMask(TQ_ComplexControl control, void drawComplexControlMask(TQ_ComplexControl control,
TQPainter *painter, TQPainter *painter,
const TQStyleControlElementData ceData, const TQStyleControlElementData ceData,
const ControlElementFlags elementFlags, const ControlElementFlags elementFlags,
const TQRect &rect, const TQRect &rect,
const TQStyleOption &option = TQStyleOption::Default, const TQStyleOption &option = TQStyleOption::Default,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
int pixelMetric(PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, int pixelMetric(PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
TQRect subRect(SubRect rect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget = 0) const; TQRect subRect(SubRect rect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget = 0) const;
TQRect querySubControlMetrics(TQ_ComplexControl control, TQRect querySubControlMetrics(TQ_ComplexControl control,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
SubControl subcontrol, SubControl subcontrol,
const TQStyleOption &option = TQStyleOption::Default, const TQStyleOption &option = TQStyleOption::Default,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
TQSize sizeFromContents(ContentsType contents, TQSize sizeFromContents(ContentsType contents,
TQStyleControlElementData ceData, TQStyleControlElementData ceData,
ControlElementFlags elementFlags, ControlElementFlags elementFlags,
const TQSize &contentsize, const TQSize &contentsize,
const TQStyleOption& option = TQStyleOption::Default, const TQStyleOption& option = TQStyleOption::Default,
const TQWidget *widget = 0) const; const TQWidget *widget = 0) const;
private: int styleHint(TQ_StyleHint, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
PhaseStyle(const PhaseStyle &); const TQStyleOption & = TQStyleOption::Default,
PhaseStyle& operator=(const PhaseStyle &); TQStyleHintReturn * = 0, const TQWidget * = 0 ) const;
void drawPhaseBevel(TQPainter *painter, private:
int x, int y, int w, int h, PhaseStyle(const PhaseStyle &);
const TQColorGroup &group, PhaseStyle& operator=(const PhaseStyle &);
const TQColor &fill,
bool sunken=false, void drawPhaseBevel(TQPainter *painter,
bool horizontal=true, int x, int y, int w, int h,
bool reverse=false) const; const TQColorGroup &group,
const TQColor &fill,
void drawPhaseButton(TQPainter *painter, bool sunken=false,
int x, int y, int w, int h, bool horizontal=true,
const TQColorGroup &group, bool reverse=false) const;
const TQColor &fill,
bool sunken=false) const; void drawPhaseButton(TQPainter *painter,
int x, int y, int w, int h,
void drawPhasePanel(TQPainter *painter, const TQColorGroup &group,
int x, int y, int w, int h, const TQColor &fill,
const TQColorGroup &group, bool sunken=false) const;
bool sunken=false,
const TQBrush *fill=NULL) const; void drawPhasePanel(TQPainter *painter,
int x, int y, int w, int h,
void drawPhaseTab(TQPainter *painter, const TQColorGroup &group,
int x, int y, int w, int h, bool sunken=false,
const TQColorGroup &group, const TQBrush *fill=NULL) const;
TQStyleControlElementData ceData,
ControlElementFlags elementFlags, void drawPhaseTab(TQPainter *painter,
const TQStyleOption &option, int x, int y, int w, int h,
const SFlags flags) const; const TQColorGroup &group,
TQStyleControlElementData ceData,
void drawPhaseGradient(TQPainter *painter, ControlElementFlags elementFlags,
const TQRect &rect, const TQStyleOption &option,
TQColor color, const SFlags flags) const;
bool horizontal,
int px=0, int py=0, void drawPhaseGradient(TQPainter *painter,
int pw=-1, int ph=-1, const TQRect &rect,
bool reverse=false) const; TQColor color,
bool horizontal,
bool flatToolbar(const TQToolBar *toolbar) const; int px=0, int py=0,
int pw=-1, int ph=-1,
bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); bool reverse=false) const;
private: bool flatToolbar(const TQToolBar *toolbar) const;
TQMap<unsigned int, TQIntDict<GradientSet> > * gradients;
bool gradients_; bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
bool highlights_;
bool reverse_; private:
bool kicker_; TQMap<unsigned int, TQIntDict<GradientSet> > * gradients;
bool gradients_;
bool highlights_;
bool reverse_;
bool kicker_;
}; };
#endif // PHASESTYLE_H #endif // PHASESTYLE_H

Loading…
Cancel
Save