summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-07-18 22:20:24 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-07-18 22:20:24 +0200
commitf66f6a1be2370ed3d57c33100a4c3380379e166c (patch)
tree5bc3e6743950ec8562253dc06703008e3c37ee16 /src
parentcc6af6b78020be05cf853f7d7aecb04bbd551626 (diff)
clear offscreen before loading new file
Diffstat (limited to 'src')
-rw-r--r--src/GsWidget.H1
-rw-r--r--src/GsWidget.cxx35
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;
+ }
+}