Patch for correct mapping of page.
- From: Serg Sh <merblud mail ru>
- To: dia-list gnome org
- Subject: Patch for correct mapping of page.
- Date: Tue, 29 Jun 2010 21:55:38 +0400
I apologise, has not found on a site where to dispatch patches. Therefore I write to the mailing list. I hope
that my patch will be useful.
The patch realises calculation quantity of pixels on centimetre for the current screen. As a result of
boundary of page and the diagramme sizes are displayed more precisely in relation to real at 100 % scale.
diff -urNp dia-0.97/app/display.c dia-0.97/app/display.c
--- dia-0.97/app/display.c 2009-04-17 12:25:23 +0400
+++ dia-0.97/app/display.c 2010-06-29 21:01:24 +0400
@@ -71,11 +71,10 @@ static void
update_zoom_status(DDisplay *ddisp)
{
gchar* zoom_text;
-
if (is_integrated_ui ())
{
zoom_text = g_strdup_printf("%.0f%%",
- ddisp->zoom_factor * 100.0 / DDISPLAY_NORMAL_ZOOM);
+ ddisp->zoom_factor * 100.0 / ddisp->ppcm);
integrated_ui_toolbar_set_zoom_text (ddisp->common_toolbar, zoom_text);
}
@@ -83,7 +82,7 @@ update_zoom_status(DDisplay *ddisp)
{
GtkWidget *zoomcombo;
zoom_text = g_strdup_printf("%.1f%%",
- ddisp->zoom_factor * 100.0 / DDISPLAY_NORMAL_ZOOM);
+ ddisp->zoom_factor * 100.0 / ddisp->ppcm);
zoomcombo = ddisp->zoom_status;
gtk_entry_set_text(GTK_ENTRY (g_object_get_data (G_OBJECT(zoomcombo), "user_data")),
zoom_text);
@@ -266,6 +265,8 @@ copy_display(DDisplay *orig_ddisp)
ddisp->zoom_factor = orig_ddisp->zoom_factor;
ddisp->visible = orig_ddisp->visible;
+ ddisp->ppcm = orig_ddisp->ppcm;
+
initialize_display_widgets(ddisp);
return ddisp; /* set the user data */
}
@@ -280,6 +281,9 @@ new_display(Diagram *dia)
{
DDisplay *ddisp;
Rectangle visible;
+ GdkScreen *dscreen;
+ gint wsc, hsc;
+ gint wscmm, hscmm;
ddisp = g_new0(DDisplay,1);
@@ -305,7 +309,16 @@ new_display(Diagram *dia)
g_signal_connect (dia, "selection_changed", G_CALLBACK(selection_changed), ddisp);
ddisp->origo.x = 0.0;
ddisp->origo.y = 0.0;
- ddisp->zoom_factor = prefs.new_view.zoom/100.0*DDISPLAY_NORMAL_ZOOM;
+
+ dscreen = gdk_screen_get_default();
+ wsc = gdk_screen_get_width(dscreen);
+ hsc = gdk_screen_get_height(dscreen);
+ wscmm = gdk_screen_get_width_mm(dscreen);
+ hscmm = gdk_screen_get_height_mm(dscreen);
+ ddisp->ppcm = hsc/(hscmm/10);
+ if (ddisp->ppcm < wsc/(wscmm/10)) ddisp->ppcm = wsc/(wscmm/10);
+
+ ddisp->zoom_factor = prefs.new_view.zoom/100.0*ddisp->ppcm;
if ((ddisp->diagram) && (ddisp->diagram->data)) {
Rectangle *extents = &ddisp->diagram->data->extents;
@@ -319,6 +332,7 @@ new_display(Diagram *dia)
visible.bottom = visible.top + prefs.new_view.height/ddisp->zoom_factor;
ddisp->visible = visible;
+
initialize_display_widgets(ddisp);
return ddisp; /* set the user data */
diff -urNp dia-0.97/app/display.h dia-0.97/app/display.h
--- dia-0.97/app/display.h 2009-04-17 12:25:23 +0400
+++ dia-0.97/app/display.h 2010-06-29 20:52:21 +0400
@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <gtk/gtkimcontext.h>
+#include <gdk/gdk.h>
typedef struct _DDisplay DDisplay;
@@ -107,6 +108,9 @@ struct _DDisplay {
/* Private field, indicates which text, if any, is being edited */
Focus *active_focus;
+
+ /* Defines the pixels per cm for current screen */
+ gint ppcm;
};
extern GdkCursor *default_cursor;
diff -urNp dia-0.97/app/interface.c dia-0.97/app/interface.c
--- dia-0.97/app/interface.c 2009-04-17 12:25:23 +0400
+++ dia-0.97/app/interface.c 2010-06-28 22:16:13 +0400
@@ -331,7 +331,7 @@ view_zoom_set (float factor)
middle.x = visible->left*0.5 + visible->right*0.5;
middle.y = visible->top*0.5 + visible->bottom*0.5;
- scale = ((real) factor)/1000.0 * DDISPLAY_NORMAL_ZOOM;
+ scale = ((real) factor)/1000.0 * ddisp->ppcm;
ddisplay_zoom(ddisp, &middle, scale / ddisp->zoom_factor);
}
@@ -360,7 +360,7 @@ zoom_activate_callback(GtkWidget *item,
zoomamount = g_strdup_printf("%f%%\n", zoom_amount);
gtk_entry_set_text(GTK_ENTRY(gtk_object_get_user_data(GTK_OBJECT(ddisp->zoom_status))), zoomamount);
g_free(zoomamount);
- magnify = (zoom_amount*DDISPLAY_NORMAL_ZOOM/100.0)/ddisp->zoom_factor;
+ magnify = (zoom_amount*ddisp->ppcm/100.0)/ddisp->zoom_factor;
if (fabs(magnify - 1.0) > 0.000001) {
visible = &ddisp->visible;
middle.x = visible->left*0.5 + visible->right*0.5;
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]