Add tab stop controls

pull/1/head
Timothy Pearson 12 years ago
parent 5fa60a7aba
commit 4038374c67

@ -676,6 +676,7 @@ void TQt3CairoPaintDevice::pangoSetupTextPath(PangoLayout *layout, const char* t
#endif #endif
pango_layout_set_font_description(layout, desc); pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
PangoAttrList* attr_list = pango_attr_list_new(); PangoAttrList* attr_list = pango_attr_list_new();
pango_attr_list_insert(attr_list, pango_attr_underline_new((underline)?PANGO_UNDERLINE_SINGLE:PANGO_UNDERLINE_NONE)); pango_attr_list_insert(attr_list, pango_attr_underline_new((underline)?PANGO_UNDERLINE_SINGLE:PANGO_UNDERLINE_NONE));
@ -683,7 +684,15 @@ void TQt3CairoPaintDevice::pangoSetupTextPath(PangoLayout *layout, const char* t
pango_layout_set_attributes(layout, attr_list); pango_layout_set_attributes(layout, attr_list);
pango_attr_list_unref(attr_list); pango_attr_list_unref(attr_list);
pango_font_description_free(desc); if (m_tabStopArrayValid) {
pango_layout_set_tabs(layout, m_tabStopArray);
}
else if (m_tabStopsValid) {
pango_layout_set_tabs(layout, m_tabStops);
}
else {
pango_layout_set_tabs(layout, NULL);
}
} }
void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString &str) { void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString &str) {
@ -844,10 +853,13 @@ void TQt3CairoPaintDevice::setCairoTransformations() {
*/ */
TQt3CairoPaintDevice::TQt3CairoPaintDevice( cairo_surface_t *cairosurface ) TQt3CairoPaintDevice::TQt3CairoPaintDevice( cairo_surface_t *cairosurface )
: TQPaintDevice( TQInternal::Picture | TQInternal::ExternalDevice ), m_intermediateSurface(NULL), m_painter(NULL), m_devicePainter(NULL) : TQPaintDevice( TQInternal::Picture | TQInternal::ExternalDevice ), m_intermediateSurface(NULL), m_painter(NULL), m_devicePainter(NULL), m_tabStops(NULL), m_tabStopArray(NULL)
{ {
m_surface = cairosurface; m_surface = cairosurface;
m_worldMatrixStack.setAutoDelete(TRUE); m_worldMatrixStack.setAutoDelete(TRUE);
m_tabStops = pango_tab_array_new(0, false);
m_tabStopArray = pango_tab_array_new(0, false);
} }
/*! /*!
@ -855,6 +867,13 @@ TQt3CairoPaintDevice::TQt3CairoPaintDevice( cairo_surface_t *cairosurface )
*/ */
TQt3CairoPaintDevice::~TQt3CairoPaintDevice() TQt3CairoPaintDevice::~TQt3CairoPaintDevice()
{ {
if (m_tabStops) {
pango_tab_array_free(m_tabStops);
}
if (m_tabStopArray) {
pango_tab_array_free(m_tabStopArray);
}
if (m_painter) { if (m_painter) {
cairo_destroy(m_painter); cairo_destroy(m_painter);
m_painter = NULL; m_painter = NULL;
@ -1176,6 +1195,8 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
m_clipRegion = TQImage(); m_clipRegion = TQImage();
m_clipRegionEnabled = false; m_clipRegionEnabled = false;
m_worldMatrixStack.clear(); m_worldMatrixStack.clear();
m_tabStopsValid = false;
m_tabStopArrayValid = false;
} }
break; break;
case PdcEnd: case PdcEnd:
@ -1302,27 +1323,40 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
} }
} }
break; break;
#if 0
case PdcSetTabStops: case PdcSetTabStops:
s >> i_16; if (p) {
painter->setTabStops( i_16 ); int tabspacing = p[0].ival;
if (tabspacing > 0) {
// Set up a repeating tab stop pattern
pango_tab_array_resize(m_tabStops, 2);
pango_tab_array_set_tab(m_tabStops, 0, PANGO_TAB_LEFT, (tabspacing*1)*PANGO_SCALE);
pango_tab_array_set_tab(m_tabStops, 1, PANGO_TAB_LEFT, (tabspacing*2)*PANGO_SCALE);
m_tabStopsValid = true;
}
else {
pango_tab_array_resize(m_tabStops, 0);
m_tabStopsValid = false;
}
}
break; break;
case PdcSetTabArray: case PdcSetTabArray:
s >> i_16; if (p) {
if ( i_16 == 0 ) { int tabcount = p[0].ival;
painter->setTabArray( 0 ); if (tabcount > 0) {
} else { int* tabarray = p[1].ivec;
int *ta = new int[i_16]; pango_tab_array_resize(m_tabStopArray, tabcount);
TQ_CHECK_PTR( ta ); int i;
for ( int i=0; i<i_16; i++ ) { for (i=0;i<tabcount;i++) {
s >> i1_16; pango_tab_array_set_tab(m_tabStopArray, i, PANGO_TAB_LEFT, tabarray[i]*PANGO_SCALE);
ta[i] = i1_16; }
m_tabStopArrayValid = true;
}
else {
pango_tab_array_resize(m_tabStopArray, 0);
m_tabStopArrayValid = false;
} }
painter->setTabArray( ta );
delete [] ta;
} }
break; break;
#endif
case PdcSetVXform: case PdcSetVXform:
if ((p) && (m_painter)) { if ((p) && (m_painter)) {
m_viewportMatrixEnabled = p[0].ival; m_viewportMatrixEnabled = p[0].ival;

@ -88,8 +88,12 @@ class Q_EXPORT TQt3CairoPaintDevice : public TQPaintDevice // picture class
TQFont m_font; TQFont m_font;
TQImage m_clipRegion; TQImage m_clipRegion;
bool m_clipRegionEnabled; bool m_clipRegionEnabled;
TQWMatrixStack m_worldMatrixStack; TQWMatrixStack m_worldMatrixStack;
PangoTabArray* m_tabStops;
PangoTabArray* m_tabStopArray;
bool m_tabStopsValid;
bool m_tabStopArrayValid;
}; };
#endif // TDEQT4PAINTER_H #endif // TDEQT4PAINTER_H

Loading…
Cancel
Save