Fix mask transforms

Use full TQt3 progress bar drawing code
pull/1/head
Timothy Pearson 12 years ago
parent d3b9433c0a
commit 76f5e2671f

@ -301,6 +301,116 @@ void gtkScaleToSliderCeData(GtkScale* scaleWidget, TQStyleControlElementData &ce
// }
}
static void
draw_combobox_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) {
cairo_save(cr);
cairo_matrix_t gtk_matrix;
cairo_get_matrix(cr, &gtk_matrix);
gtk_matrix.x0 = 0;
gtk_matrix.y0 = 0;
cairo_set_matrix(cr, &gtk_matrix);
GtkWidget* parent(widget?gtk_widget_get_parent(widget):0L);
if (GTK_IS_COMBO_BOX(parent)) {
const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(parent);
TQRect boundingRect(0, 0, allocation.width, allocation.height);
TQt3CairoPaintDevice pd2(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr);
TQPainter p2(&pd2);
TQStringList objectTypes;
objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) {
elementFlags = elementFlags | TQStyle::CEF_IsEditable;
}
ceData.rect = boundingRect;
// Draw item
tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE), TQStyle::SC_ComboBoxFrame, TQStyle::SC_None);
}
cairo_restore(cr);
}
static void
draw_progressbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) {
cairo_save(cr);
cairo_matrix_t gtk_matrix;
cairo_get_matrix(cr, &gtk_matrix);
gtk_matrix.x0 = 0;
gtk_matrix.y0 = 0;
cairo_set_matrix(cr, &gtk_matrix);
if (GTK_IS_PROGRESS_BAR(widget)) {
const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget);
TQRect boundingRect(0, 0, allocation.width, allocation.height);
TQt3CairoPaintDevice pd2(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr);
TQPainter p2(&pd2);
TQStringList objectTypes;
objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
ceData.rect = boundingRect;
ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
GtkProgressBar* progressBar = GTK_PROGRESS_BAR(widget);
gdouble gtkProgressBarFraction = gtk_progress_bar_get_fraction(progressBar);
ceData.totalSteps = 8192;
ceData.currentStep = gtkProgressBarFraction*8192;
TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_NONE);
sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default);
if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL)) {
// If vertical, apply a 90 degree rotation matrix to the painter
// This is required to make TQt draw a vertical progress bar
TQWMatrix m;
// // Upside down
// m.rotate(90.0);
// m.translate(0, (allocation.width)*(-1.0));
// Right side up
m.rotate(-90.0);
m.translate((allocation.height)*(-1.0), 0);
p2.setWorldMatrix(m, TRUE);
boundingRect = TQRect(0, 0, allocation.height, allocation.width);
ceData.rect = boundingRect;
}
TQRect progressBarGrooveRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags);
TQRect progressBarContentsRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, NULL), ceData, elementFlags);
// Draw background
TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p2, brush)
// Draw frame
tqApp->style().drawControl(TQStyle::CE_ProgressBarGroove, &p2, ceData, elementFlags, progressBarGrooveRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags);
// Draw contents
tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p2, ceData, elementFlags, progressBarContentsRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags);
}
cairo_restore(cr);
}
/* draw a texture placed on the centroid */
static gboolean
draw_centroid_texture (GtkThemingEngine *engine,
@ -364,6 +474,7 @@ tdegtk_draw_activity (DRAW_ARGS)
widget = m_widgetLookup.find(cr, path);
if (gtk_widget_path_is_type(path, GTK_TYPE_PROGRESS_BAR)) {
#if 0
TQStringList objectTypes;
objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
@ -381,6 +492,9 @@ tdegtk_draw_activity (DRAW_ARGS)
// Draw item
tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p, ceData, elementFlags, progressBarRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags);
#else
// Do nothing
#endif
}
else {
@ -509,6 +623,11 @@ tdegtk_draw_arrow (GtkThemingEngine *engine,
}
tqApp->style().drawPrimitive((subline)?TQStyle::PE_ScrollBarSubLine:TQStyle::PE_ScrollBarAddLine, p, scrollpagerect, gtkToTQtColorGroup(engine, state), sflags);
}
else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) {
// Do nothing
}
else {
pd = new TQt3CairoPaintDevice(NULL, x, y, size, size, cr);
p = new TQPainter(pd);
@ -583,6 +702,10 @@ tdegtk_draw_cell_background (DRAW_ARGS,
tqApp->style().drawComplexControl(TQStyle::CC_ListView, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE), TQStyle::SC_ListView, TQStyle::SC_All, listViewItemOpt);
}
// FIXME
// GtkCellRenderer backgrounds should be drawn here, however GTK3 does not provide any means for a GtkCellRenderer to call style engine methods!
// See upstream GTK bug #687677
else {
DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,128,64);
printf("[WARNING] tdegtk_draw_cell_background() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
@ -699,22 +822,7 @@ tdegtk_draw_common_background (DRAW_ARGS)
state = gtk_theming_engine_get_state(engine);
widget = m_widgetLookup.find(cr, path);
if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
|| (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW))
|| (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER))
|| (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY))
|| (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_COMBOBOX_ENTRY))
) {
TQStringList objectTypes;
objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
// Draw background
TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
}
else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) {
if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) {
TQStringList objectTypes;
objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
@ -733,6 +841,25 @@ tdegtk_draw_common_background (DRAW_ARGS)
tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
}
else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) {
draw_combobox_frame(engine, cr, x, y, width, height, path, state, widget);
}
else if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
|| (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW))
|| (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER))
|| (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY))
|| (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_COMBOBOX_ENTRY))
) {
TQStringList objectTypes;
objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
// Draw background
TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
}
#if 0
else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) {
bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0;
@ -995,29 +1122,11 @@ tdegtk_draw_common_frame (DRAW_ARGS)
tqApp->style().drawPrimitive(TQStyle::PE_ScrollBarAddPage, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE));
}
}
#if 0
else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) {
bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0;
TQStringList objectTypes;
objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) {
elementFlags = elementFlags | TQStyle::CEF_IsEditable;
else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) {
draw_combobox_frame(engine, cr, x, y, width, height, path, state, widget);
}
ceData.rect = boundingRect;
// Draw item
tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE), TQStyle::SC_ComboBoxFrame, TQStyle::SC_None);
}
#endif
else {
if (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON)) {
if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TOOLBAR)) {
@ -1125,29 +1234,7 @@ tdegtk_draw_common_frame (DRAW_ARGS)
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_PROGRESS_BAR)) {
TQStringList objectTypes;
objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
ceData.rect = boundingRect;
ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
GtkProgressBar* progressBar = GTK_PROGRESS_BAR(widget);
gdouble gtkProgressBarFraction = gtk_progress_bar_get_fraction(progressBar);
ceData.totalSteps = 8192;
ceData.currentStep = gtkProgressBarFraction*8192;
TQRect progressBarRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags);
// Draw background
TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
// Draw item
tqApp->style().drawControl(TQStyle::CE_ProgressBarGroove, &p, ceData, elementFlags, progressBarRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
draw_progressbar_frame(engine, cr, x, y, width, height, path, state, widget);
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_IMAGE)) {
@ -1365,7 +1452,11 @@ tdegtk_draw_focus (DRAW_ARGS)
state = gtk_theming_engine_get_state(engine);
widget = m_widgetLookup.find(cr, path);
if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) {
// Draw nothing!
}
else if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
|| (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW))
|| (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER))
|| (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY))
@ -1756,43 +1847,6 @@ tdegtk_draw_separator (DRAW_ARGS)
}
p.end();
return;
gdouble line_width;
tdegtk_get_line_width (engine, &line_width);
if (line_width == 0)
return;
/* FIXME right code should be
* if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
* but doesn't work for separator tool item. */
if (width > height)
{
cairo_move_to (cr, x, y + (gint) (height / 2) + line_width / 2);
cairo_line_to (cr, x + width, y + (gint) (height / 2) + line_width / 2);
tdegtk_cairo_set_source_inner_stroke (engine, cr, width, line_width);
cairo_stroke (cr);
cairo_move_to (cr, x, y + (gint) (height / 2) - line_width / 2);
cairo_line_to (cr, x + width, y + (gint) (height / 2) - line_width / 2);
tdegtk_cairo_set_source_border (engine, cr, width, line_width);
cairo_stroke (cr);
}
else
{
cairo_move_to (cr, x + (gint) (width / 2) + line_width / 2, y);
cairo_line_to (cr, x + (gint) (width / 2) + line_width / 2, y + height);
tdegtk_cairo_set_source_inner_stroke (engine, cr, line_width, height);
cairo_stroke (cr);
cairo_move_to (cr, x + (gint) (width / 2) - line_width / 2, y);
cairo_line_to (cr, x + (gint) (width / 2) - line_width / 2, y + height);
tdegtk_cairo_set_source_border (engine, cr, line_width, height);
cairo_stroke (cr);
}
}
static void

@ -56,11 +56,13 @@ tdegtk_engine_render_activity (GtkThemingEngine *engine,
tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions);
path = gtk_theming_engine_get_path (engine);
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER))
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER)) {
GTK_THEMING_ENGINE_CLASS (tdegtk_engine_parent_class)->render_activity (engine, cr, x, y, width, height);
else
}
else {
style_functions->draw_activity (engine, cr, x, y, width, height);
}
}
static void
tdegtk_engine_render_arrow (GtkThemingEngine *engine,
@ -97,15 +99,20 @@ tdegtk_engine_render_background (GtkThemingEngine *engine,
path = gtk_theming_engine_get_path (engine);
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) &&
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON))
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON)
) {
style_functions->draw_spinbutton_background (engine, cr, x, y, width, height);
}
else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) &&
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) &&
gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags))
gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags)
) {
style_functions->draw_cell_background (engine, cr, x, y, width, height, flags);
else
}
else {
style_functions->draw_common_background (engine, cr, x, y, width, height);
}
}
static void
tdegtk_engine_render_check (GtkThemingEngine *engine,
@ -193,18 +200,24 @@ tdegtk_engine_render_frame (GtkThemingEngine *engine,
tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions);
path = gtk_theming_engine_get_path (engine);
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR))
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR)) {
style_functions->draw_separator (engine, cr, x, y, width, height);
}
else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) &&
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON))
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON)
) {
style_functions->draw_spinbutton_frame (engine, cr, x, y, width, height);
}
else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) &&
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) &&
gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags))
gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags)
) {
style_functions->draw_cell_frame (engine, cr, x, y, width, height, flags);
else
}
else {
style_functions->draw_common_frame (engine, cr, x, y, width, height);
}
}
static void
tdegtk_engine_render_frame_gap (GtkThemingEngine *engine,
@ -223,11 +236,13 @@ tdegtk_engine_render_frame_gap (GtkThemingEngine *engine,
tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions);
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK))
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK)) {
style_functions->draw_notebook (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap);
else
}
else {
style_functions->draw_frame_gap (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap);
}
}
static void
tdegtk_engine_render_handle (GtkThemingEngine *engine,
@ -243,11 +258,13 @@ tdegtk_engine_render_handle (GtkThemingEngine *engine,
tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions);
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP)) {
style_functions->draw_grip (engine, cr, x, y, width, height);
else
}
else {
style_functions->draw_handle (engine, cr, x, y, width, height);
}
}
static void
tdegtk_engine_render_line (GtkThemingEngine *engine,

@ -597,6 +597,11 @@ void writeGtkThemeControlFile(int forceRecreate) {
bool combobox_appears_as_list = (!(tqApp->style().styleHint(TQStyle::SH_ComboBox_Popup) || tqApp->style().styleHint(TQStyle::SH_GUIStyle) == TQt::MotifStyle));
stream << parse_rc_string(TQString("-GtkComboBox-appears-as-list: %1px").arg(combobox_appears_as_list), "*");
// FIXME
// Work around problems detailed in upstream GTK bug #687677
stream << parse_rc_string(TQString("-GtkComboBox-shadow-type: in"), "*");
stream << parse_rc_string("-GtkComboBox-arrow-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ArrowSize)), "*");
stream << parse_rc_string("-GtkComboBox-arrow-scaling: 0", "*");

@ -336,7 +336,42 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() {
cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion);
cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY);
cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE);
// Clipping enabled
if (m_worldMatrixEnabled || m_viewportMatrixEnabled) {
// The mask needs to be transformed before application
cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion);
cairo_surface_t *transformedMaskSurface;
cairo_t *cr2;
int maxSize;
int w = cairo_image_surface_get_width(maskSurface);
int h = cairo_image_surface_get_height(maskSurface);
if (w>h) {
maxSize = w*2;
}
else {
maxSize = h*2;
}
transformedMaskSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, maxSize, maxSize);
cr2 = cairo_create(transformedMaskSurface);
setCairoTransformations(cr2);
cairo_set_source_surface (cr2, maskSurface, 0, 0);
cairo_set_operator(cr2, CAIRO_OPERATOR_SOURCE);
cairo_paint(cr2);
// Paint intermediate surface to final surface through mask
cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY);
cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE);
cairo_mask_surface(m_devicePainter, transformedMaskSurface, m_offsetX, m_offsetY);
cairo_surface_destroy(transformedMaskSurface);
}
else {
// Paint intermediate surface to final surface through mask
cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion);
cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY);
cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE);
cairo_mask_surface(m_devicePainter, maskSurface, m_offsetX, m_offsetY);
}
cairo_surface_destroy(maskSurface);
}
@ -1052,11 +1087,12 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla
transferIntermediateSurface();
}
void TQt3CairoPaintDevice::setCairoTransformations() {
void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable) {
cairo_matrix_t combinedMatrix;
cairo_matrix_t tempMatrix;
cairo_matrix_init_identity(&combinedMatrix);
if (!forceDisable) {
if (m_worldMatrixEnabled) {
cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_worldMatrix);
combinedMatrix = tempMatrix;
@ -1065,8 +1101,9 @@ void TQt3CairoPaintDevice::setCairoTransformations() {
cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_viewportMatrix);
combinedMatrix = tempMatrix;
}
}
cairo_set_matrix(m_painter, &combinedMatrix);
cairo_set_matrix(cr, &combinedMatrix);
}
/*!
@ -1488,7 +1525,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
m_viewportMatrixEnabled = false;
cairo_matrix_init_identity(&m_worldMatrix);
cairo_matrix_init_identity(&m_viewportMatrix);
setCairoTransformations();
setCairoTransformations(m_painter);
m_rop = TQPainter::CopyROP;
m_clipRegion = TQImage();
m_clipRegionEnabled = false;
@ -1603,7 +1640,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
case PdcSetVXform:
if ((p) && (m_painter)) {
m_viewportMatrixEnabled = p[0].ival;
setCairoTransformations();
setCairoTransformations(m_painter);
}
break;
case PdcSetWindow:
@ -1620,7 +1657,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
double scaleW = (double)vw/(double)ww;
double scaleH = (double)vh/(double)wh;
cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH);
setCairoTransformations();
setCairoTransformations(m_painter);
}
break;
case PdcSetViewport:
@ -1637,13 +1674,13 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
double scaleW = (double)vw/(double)ww;
double scaleH = (double)vh/(double)wh;
cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH);
setCairoTransformations();
setCairoTransformations(m_painter);
}
break;
case PdcSetWXform:
if ((p) && (m_painter)) {
m_worldMatrixEnabled = p[0].ival;
setCairoTransformations();
setCairoTransformations(m_painter);
}
break;
case PdcSetWMatrix:
@ -1661,7 +1698,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
// Replace
cairo_matrix_init(&m_worldMatrix, tqt3matrix->m11(), tqt3matrix->m12(), tqt3matrix->m21(), tqt3matrix->m22(), tqt3matrix->dx(), tqt3matrix->dy());
}
setCairoTransformations();
setCairoTransformations(m_painter);
}
}
break;

@ -70,7 +70,7 @@ class Q_EXPORT TQt3CairoPaintDevice : public TQPaintDevice // picture class
void drawText(TQPainter *p, int x, int y, const TQString &str);
void drawTextInRect(TQPainter *p, TQRect rect, int textFlags, const TQString &str);
void setCairoTransformations();
void setCairoTransformations(cairo_t* cr, bool forceDisable=false);
private:
mutable int m_width;

Loading…
Cancel
Save