summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2005-01-27 20:07:09 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2005-01-27 20:07:09 +0000
commite9defef906d2c31a1d03615a1a2ed31a89a81dc5 (patch)
treed7b6c03722af22614693ff04f66751213cfc82ea
parent37a96e693506ff169d6702d384405597f3ff54e1 (diff)
implement zoom
implement zoom
-rw-r--r--src/GsWidget.H6
-rw-r--r--src/GsWidget.cxx36
-rw-r--r--src/PSEditWidget.H7
-rw-r--r--src/PSEditWidget.cxx23
-rw-r--r--src/flpsed.cxx18
5 files changed, 76 insertions, 14 deletions
diff --git a/src/GsWidget.H b/src/GsWidget.H
index 8760213..99ef08a 100644
--- a/src/GsWidget.H
+++ b/src/GsWidget.H
@@ -1,5 +1,5 @@
//
-// "$Id: GsWidget.H,v 1.3 2004/11/10 18:49:08 hofmann Exp $"
+// "$Id: GsWidget.H,v 1.4 2005/01/27 21:07:09 hofmann Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -41,6 +41,8 @@ class GsWidget : public Fl_Widget {
pid_t gs_pid;
int display_x, display_y;
int in_fd, reload_needed;
+ int zoom_percent;
+ int initial_width, initial_height;
protected:
int page;
@@ -65,6 +67,8 @@ public:
int handleX11(int ev);
+ int zoom(int p);
+
int get_page();
private:
diff --git a/src/GsWidget.cxx b/src/GsWidget.cxx
index 590f6f5..3b7dc8e 100644
--- a/src/GsWidget.cxx
+++ b/src/GsWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: GsWidget.cxx,v 1.13 2004/11/14 20:04:09 hofmann Exp $"
+// "$Id: GsWidget.cxx,v 1.14 2005/01/27 21:07:09 hofmann Exp $"
//
// GsWidget routines.
//
@@ -100,10 +100,13 @@ GsWidget::GsWidget(int X,int Y,int W, int H) : Fl_Widget(X, Y, W, H) {
offscreen = 0;
gs_pid = 0;
page = 0;
- xdpi = 75;
- ydpi = 75;
+ zoom_percent = 100;
+ xdpi = 75 * zoom_percent / 100;
+ ydpi = 75 * zoom_percent / 100;
paper_x = 594; // DIN A4
paper_y = 841; //
+ initial_width = W;
+ initial_height = H;
in_fd = -1;
reload_needed = 0;
}
@@ -228,3 +231,30 @@ int GsWidget::handleX11(int ev) {
int GsWidget::get_page() {
return page;
}
+
+int GsWidget::zoom(int p) {
+ zoom_percent = p;
+
+ kill_gs();
+
+ // Clear widget
+ fl_begin_offscreen(offscreen);
+ fl_color(FL_WHITE);
+ fl_rectf(0, 0, w(), h());
+ fl_end_offscreen();
+ redraw();
+
+ if (offscreen) {
+ fl_delete_offscreen(offscreen);
+ offscreen = NULL;
+ }
+
+ w(initial_width * zoom_percent / 100);
+ h(initial_height * zoom_percent / 100);
+
+ xdpi = 75 * zoom_percent / 100;
+ ydpi = 75 * zoom_percent / 100;
+ reload();
+
+ return 0;
+}
diff --git a/src/PSEditWidget.H b/src/PSEditWidget.H
index 9f182dd..f66833b 100644
--- a/src/PSEditWidget.H
+++ b/src/PSEditWidget.H
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditWidget.H,v 1.14 2004/11/10 18:32:59 hofmann Exp $"
+// "$Id: PSEditWidget.H,v 1.15 2005/01/27 21:07:09 hofmann Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -35,6 +35,8 @@ private:
int show_tags;
+ int zoom_percent;
+
protected:
PSEditModel *model;
@@ -93,6 +95,9 @@ public:
int replace_tag(char* tag, char* text);
+ int zoom(int p);
+
+ private:
int bb_x(PSEditText *t);
int bb_y(PSEditText *t);
diff --git a/src/PSEditWidget.cxx b/src/PSEditWidget.cxx
index 5861814..0d95d2c 100644
--- a/src/PSEditWidget.cxx
+++ b/src/PSEditWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditWidget.cxx,v 1.31 2004/11/10 19:21:06 hofmann Exp $"
+// "$Id: PSEditWidget.cxx,v 1.32 2005/01/27 21:07:09 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -56,7 +56,7 @@ void PSEditWidget::draw() {
t_y = ps_to_display_y(t->get_y());
fl_color((Fl_Color) t->get_color());
- fl_font(FLPSED_FONT, t->get_size());
+ fl_font(FLPSED_FONT, t->get_size() * zoom_percent / 100);
fl_draw(t->get_text(), t_x + x(), t_y + y());
if (model->is_cur_text(t)) {
fl_draw_box(FL_BORDER_FRAME,
@@ -74,7 +74,7 @@ void PSEditWidget::draw() {
fl_draw(t->get_tag(), t_x + x(),
t_y + y() - text_height - 1);
}
-
+
t = t->get_next();
}
}
@@ -84,6 +84,7 @@ PSEditWidget::PSEditWidget(int X,int Y,int W, int H): GsWidget(X, Y, W, H) {
model = new PSEditModel();
cur_size = 12;
show_tags = 1;
+ zoom_percent = 100;
}
int PSEditWidget::next() {
@@ -214,7 +215,7 @@ void PSEditWidget::rm_char() {
t = model->get_cur_text();
if (t) {
- fl_font(FLPSED_FONT, t->get_size());
+ fl_font(FLPSED_FONT, t->get_size() * zoom_percent / 100);
width = bb_w(t);
}
@@ -308,19 +309,25 @@ int PSEditWidget::replace_tag(char *tag, char *text) {
return model->replace_tag(tag, text);
}
+int PSEditWidget::zoom(int p) {
+ zoom_percent = p;
+ return GsWidget::zoom(zoom_percent);
+}
+
+
int PSEditWidget::bb_x(PSEditText *t) {
return ps_to_display_x(t->get_x()) + x() - 10;
}
int PSEditWidget::bb_y(PSEditText *t) {
- fl_font(FLPSED_FONT, t->get_size());
- return ps_to_display_y(t->get_y()) - fl_height() + y() - 20;
+ fl_font(FLPSED_FONT, t->get_size() * zoom_percent / 100);
+ return ps_to_display_y(t->get_y()) - fl_height() + y() - 10;
}
int PSEditWidget::bb_w(PSEditText *t) {
int w, wt = 0;
char *tag;
- fl_font(FLPSED_FONT, t->get_size());
+ fl_font(FLPSED_FONT, t->get_size() * zoom_percent / 100);
w = (int) fl_width(t->get_text()) + 20;
tag = t->get_tag();
@@ -344,7 +351,7 @@ static int round_div(int a, int b) {
}
int PSEditWidget::bb_h(PSEditText *t) {
- fl_font(FLPSED_FONT, t->get_size());
+ fl_font(FLPSED_FONT, t->get_size() * zoom_percent / 100);
return fl_height() + 30;
}
diff --git a/src/flpsed.cxx b/src/flpsed.cxx
index 404df97..af257ef 100644
--- a/src/flpsed.cxx
+++ b/src/flpsed.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: flpsed.cxx,v 1.24 2004/11/10 18:32:59 hofmann Exp $"
+// "$Id: flpsed.cxx,v 1.25 2005/01/27 21:07:09 hofmann Exp $"
//
// flpsed program.
//
@@ -147,6 +147,14 @@ void size_cb(Fl_Widget *w, void *) {
}
}
+void zoom_cb(Fl_Widget *w, void *) {
+ Fl_Menu_* mw = (Fl_Menu_*)w;
+ const Fl_Menu_Item* m = mw->mvalue();
+ if (m) {
+ gsw_p->zoom(atoi(m->label()));
+ }
+}
+
void show_tags_cb(Fl_Widget* w, void*d) {
gsw_p->set_show_tags((int) d);
}
@@ -178,6 +186,14 @@ Fl_Menu_Item menuitems[] = {
{ "&Next", FL_CTRL + 'n', (Fl_Callback *)next_cb },
{ 0 },
+ { "&Zoom (%)", 0, 0, 0, FL_SUBMENU },
+ { "50", 0, (Fl_Callback *)zoom_cb },
+ { "75", 0, (Fl_Callback *)zoom_cb },
+ { "100", 0, (Fl_Callback *)zoom_cb },
+ { "150", 0, (Fl_Callback *)zoom_cb },
+ { "200", 0, (Fl_Callback *)zoom_cb },
+ { 0 },
+
{ "&Size", 0, 0, 0, FL_SUBMENU },
{ "8", 0, (Fl_Callback *)size_cb },
{ "10", 0, (Fl_Callback *)size_cb },