Exemplo n.º 1
0
static void setup_range(DocInfo *dinfo, GtkPrintContext *ctx)
{
	dinfo->fr.hdc = dinfo->fr.hdcTarget = gtk_print_context_get_cairo_context(ctx);

	dinfo->fr.rcPage.left   = 0;
	dinfo->fr.rcPage.top    = 0;
	dinfo->fr.rcPage.right  = gtk_print_context_get_width(ctx);
	dinfo->fr.rcPage.bottom = gtk_print_context_get_height(ctx);

	dinfo->fr.rc.left   = dinfo->fr.rcPage.left;
	dinfo->fr.rc.top    = dinfo->fr.rcPage.top;
	dinfo->fr.rc.right  = dinfo->fr.rcPage.right;
	dinfo->fr.rc.bottom = dinfo->fr.rcPage.bottom;
#if GTK_CHECK_VERSION(2, 20, 0)
	{
		gdouble m_top, m_left, m_right, m_bottom;
		if (gtk_print_context_get_hard_margins(ctx, &m_top, &m_bottom, &m_left, &m_right))
		{
			dinfo->fr.rc.left   += m_left;
			dinfo->fr.rc.top    += m_top;
			dinfo->fr.rc.right  -= m_right;
			dinfo->fr.rc.bottom -= m_bottom;
		}
	}
#endif
	if (printing_prefs.print_page_header)
		dinfo->fr.rc.top += dinfo->line_height * 3; /* header height */
	if (printing_prefs.print_page_numbers)
		dinfo->fr.rc.bottom -= dinfo->line_height * 1; /* footer height */

	dinfo->fr.chrg.cpMin = 0;
	dinfo->fr.chrg.cpMax = sci_get_length(dinfo->sci);
}
Exemplo n.º 2
0
JNIEXPORT jboolean JNICALL
Java_org_gnome_gtk_GtkPrintContext_gtk_1print_1context_1get_1hard_1margins
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jdoubleArray _top,
	jdoubleArray _bottom,
	jdoubleArray _left,
	jdoubleArray _right
)
{
	gboolean result;
	jboolean _result;
	GtkPrintContext* self;
	gdouble* top;
	gdouble* bottom;
	gdouble* left;
	gdouble* right;

	// convert parameter self
	self = (GtkPrintContext*) _self;

	// convert parameter top
	top = (gdouble*) (*env)->GetDoubleArrayElements(env, _top, NULL);
	if (top == NULL) {
		return  JNI_FALSE; // Java Exception already thrown
	}

	// convert parameter bottom
	bottom = (gdouble*) (*env)->GetDoubleArrayElements(env, _bottom, NULL);
	if (bottom == NULL) {
		return  JNI_FALSE; // Java Exception already thrown
	}

	// convert parameter left
	left = (gdouble*) (*env)->GetDoubleArrayElements(env, _left, NULL);
	if (left == NULL) {
		return  JNI_FALSE; // Java Exception already thrown
	}

	// convert parameter right
	right = (gdouble*) (*env)->GetDoubleArrayElements(env, _right, NULL);
	if (right == NULL) {
		return  JNI_FALSE; // Java Exception already thrown
	}

	// call function
	result = gtk_print_context_get_hard_margins(self, top, bottom, left, right);

	// cleanup parameter self

	// cleanup parameter top
	(*env)->ReleaseDoubleArrayElements(env, _top, (jdouble*)top, 0);

	// cleanup parameter bottom
	(*env)->ReleaseDoubleArrayElements(env, _bottom, (jdouble*)bottom, 0);

	// cleanup parameter left
	(*env)->ReleaseDoubleArrayElements(env, _left, (jdouble*)left, 0);

	// cleanup parameter right
	(*env)->ReleaseDoubleArrayElements(env, _right, (jdouble*)right, 0);

	// translate return value to JNI type
	_result = (jboolean) result;

	// and finally
	return _result;
}