summaryrefslogtreecommitdiff
path: root/src/PSEditWidget.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2004-11-10 18:21:06 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2004-11-10 18:21:06 +0000
commitdbcf5fcc56e85f372d3be40f725a8e526ef00ca1 (patch)
tree8bddbbe58005daa73547899294c9c03e67a23f80 /src/PSEditWidget.cxx
parent9583092a2166fe6899c616dd2f52b73dba8d34bc (diff)
improve coordinate conversion methods doc updates
improve coordinate conversion methods doc updates
Diffstat (limited to 'src/PSEditWidget.cxx')
-rw-r--r--src/PSEditWidget.cxx22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/PSEditWidget.cxx b/src/PSEditWidget.cxx
index 572f010..5861814 100644
--- a/src/PSEditWidget.cxx
+++ b/src/PSEditWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditWidget.cxx,v 1.30 2004/11/10 18:49:08 hofmann Exp $"
+// "$Id: PSEditWidget.cxx,v 1.31 2004/11/10 19:21:06 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -332,24 +332,34 @@ int PSEditWidget::bb_w(PSEditText *t) {
return w>=wt?w:wt;
}
+static int round_div(int a, int b) {
+ int r;
+
+ r = a / b;
+ if (a % b > b / 2) {
+ r++;
+ }
+
+ return r;
+}
+
int PSEditWidget::bb_h(PSEditText *t) {
fl_font(FLPSED_FONT, t->get_size());
return fl_height() + 30;
}
-
int PSEditWidget::ps_to_display_x(int x1) {
- return (x1 * xdpi) / 72;
+ return round_div(x1 * xdpi, 72);
}
int PSEditWidget::ps_to_display_y(int y1) {
- return ((paper_y - y1) * xdpi) / 72;
+ return round_div((paper_y - y1) * xdpi, 72);
}
int PSEditWidget::ps_x(int x1) {
- return (x1 * 72) / xdpi;
+ return round_div(x1 * 72, xdpi);
}
int PSEditWidget::ps_y(int y1) {
- return paper_y - (y1 * 72) / ydpi;
+ return paper_y - round_div(y1 * 72, ydpi);
}