From 4038374c679a63f95c57ef21dc11e7cd7207c2ec Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 17 Sep 2012 16:05:48 -0500 Subject: Add tab stop controls --- tdegtk/tqtcairopainter.cpp | 70 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 18 deletions(-) (limited to 'tdegtk/tqtcairopainter.cpp') diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp index 0e8da20..95c86c4 100644 --- a/tdegtk/tqtcairopainter.cpp +++ b/tdegtk/tqtcairopainter.cpp @@ -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> i1_16; - ta[i] = i1_16; - } - painter->setTabArray( ta ); - delete [] ta; + 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