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
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
PangoAttrList* attr_list = pango_attr_list_new();
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_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) {
@ -844,10 +853,13 @@ void TQt3CairoPaintDevice::setCairoTransformations() {
*/
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_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()
{
if (m_tabStops) {
pango_tab_array_free(m_tabStops);
}
if (m_tabStopArray) {
pango_tab_array_free(m_tabStopArray);
}
if (m_painter) {
cairo_destroy(m_painter);
m_painter = NULL;
@ -1176,6 +1195,8 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
m_clipRegion = TQImage();
m_clipRegionEnabled = false;
m_worldMatrixStack.clear();
m_tabStopsValid = false;
m_tabStopArrayValid = false;
}
break;
case PdcEnd:
@ -1302,27 +1323,40 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
}
}
break;
#if 0
case PdcSetTabStops:
s >> i_16;
painter->setTabStops( i_16 );
if (p) {
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;
case PdcSetTabArray:
s >> i_16;
if ( i_16 == 0 ) {
painter->setTabArray( 0 );
} else {
int *ta = new int[i_16];
TQ_CHECK_PTR( ta );
for ( int i=0; i<i_16; i++ ) {
s >> i1_16;
ta[i] = i1_16;
if (p) {
int tabcount = p[0].ival;
if (tabcount > 0) {
int* tabarray = p[1].ivec;
pango_tab_array_resize(m_tabStopArray, tabcount);
int i;
for (i=0;i<tabcount;i++) {
pango_tab_array_set_tab(m_tabStopArray, i, PANGO_TAB_LEFT, tabarray[i]*PANGO_SCALE);
}
m_tabStopArrayValid = true;
}
else {
pango_tab_array_resize(m_tabStopArray, 0);
m_tabStopArrayValid = false;
}
painter->setTabArray( ta );
delete [] ta;
}
break;
#endif
case PdcSetVXform:
if ((p) && (m_painter)) {
m_viewportMatrixEnabled = p[0].ival;

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

Loading…
Cancel
Save