diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GsWidget.H | 1 | ||||
-rw-r--r-- | src/GsWidget.cxx | 35 |
2 files changed, 22 insertions, 14 deletions
diff --git a/src/GsWidget.H b/src/GsWidget.H index a5d0fd1..e6f7390 100644 --- a/src/GsWidget.H +++ b/src/GsWidget.H @@ -32,6 +32,7 @@ class GsWidget : public Fl_Widget { int feeding; void resize(); + void clear(); protected: int page; diff --git a/src/GsWidget.cxx b/src/GsWidget.cxx index ad516b7..229047b 100644 --- a/src/GsWidget.cxx +++ b/src/GsWidget.cxx @@ -117,8 +117,10 @@ int GsWidget::open_file(char *f) { } int GsWidget::open_file(int fd) { + clear(); + if (in_fd >= 0 && fd != in_fd) { - close (in_fd); + close(in_fd); } in_fd = fd; @@ -383,19 +385,7 @@ int GsWidget::get_page() { int GsWidget::zoom(int p) { zoom_percent = p; - kill_gs(); - - if (offscreen) { - // Clear widget with current size - fl_begin_offscreen(offscreen); - fl_color(FL_WHITE); - fl_rectf(0, 0, w(), h()); - fl_end_offscreen(); - redraw(); - - fl_delete_offscreen(offscreen); - offscreen = 0; - } + clear(); xdpi = 75 * zoom_percent / 100; ydpi = 75 * zoom_percent / 100; @@ -420,3 +410,20 @@ void GsWidget::resize() { size(paper_x * xdpi / 72, paper_y * ydpi / 72); } + +void +GsWidget::clear() { + kill_gs(); + + if (offscreen) { + // Clear widget with current size + fl_begin_offscreen(offscreen); + fl_color(FL_WHITE); + fl_rectf(0, 0, w(), h()); + fl_end_offscreen(); + redraw(); + + fl_delete_offscreen(offscreen); + offscreen = 0; + } +} |