diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | src/PSEditModel.H | 19 | ||||
-rw-r--r-- | src/PSEditModel.cxx | 24 | ||||
-rw-r--r-- | src/PSEditWidget.H | 12 | ||||
-rw-r--r-- | src/PSEditWidget.cxx | 66 | ||||
-rw-r--r-- | src/PSEditor.cxx | 30 | ||||
-rw-r--r-- | src/Postscript.cxx | 12 | ||||
-rw-r--r-- | src/flpsed.cxx | 4 |
8 files changed, 85 insertions, 87 deletions
@@ -1,6 +1,11 @@ flpsed ChangeLog ================= +flpsed-0.3.1 + - Fix redraw problem after scrolling. + - Allow moving of text with arrow keys. + - Tab key now cycles through text fields. + flpsed-0.3.0 - Add support for tags (thanks to Reimar Bauer for his thoughts on this). - Add batch processing mode. diff --git a/src/PSEditModel.H b/src/PSEditModel.H index 2504d3d..ca28f5a 100644 --- a/src/PSEditModel.H +++ b/src/PSEditModel.H @@ -1,5 +1,5 @@ // -// "$Id: PSEditModel.H,v 1.10 2004/11/08 18:10:34 hofmann Exp $" +// "$Id: PSEditModel.H,v 1.11 2004/11/10 18:32:59 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -34,15 +34,10 @@ class PSEditModel { int page; - PSEditText *cur_text; - - float xdpi, ydpi; - - int paper_x, paper_y; - + PSEditText *cur_text; public: - PSEditModel(int x1, int y1, float dx, float dy); + PSEditModel(); ~PSEditModel(); @@ -84,14 +79,6 @@ public: int dump_tags(); - int ps_to_display_x(int x1); - - int ps_to_display_y(int y1); - - int ps_x(int x1); - - int ps_y(int y1); - int PSEditModel::load(FILE *fp); int save(FILE *sfp, int tmp_fd); diff --git a/src/PSEditModel.cxx b/src/PSEditModel.cxx index f898c50..5eeee9c 100644 --- a/src/PSEditModel.cxx +++ b/src/PSEditModel.cxx @@ -1,5 +1,5 @@ // -// "$Id: PSEditModel.cxx,v 1.11 2004/11/08 18:56:00 hofmann Exp $" +// "$Id: PSEditModel.cxx,v 1.12 2004/11/10 18:32:59 hofmann Exp $" // // PSEditWidget routines. // @@ -32,11 +32,7 @@ #include "PSEditModel.H" -PSEditModel::PSEditModel(int x1, int y1, float dx, float dy) { - paper_x = x1; - paper_y = y1; - xdpi = dx; - ydpi = dy; +PSEditModel::PSEditModel() { max_pages = 32; page = 0; text = (PSEditText**) malloc(sizeof(PSEditText*) * max_pages); @@ -240,22 +236,6 @@ PSEditText *PSEditModel::get_text(int p) { } } -int PSEditModel::ps_to_display_x(int x1) { - return (int) ((float) x1 * xdpi / 72.0); -} - -int PSEditModel::ps_to_display_y(int y1) { - return (int) ((float) (paper_y - y1) * xdpi / 72.0); -} - -int PSEditModel::ps_x(int x1) { - return (int) ((float) x1 * 72.0 / xdpi); -} - -int PSEditModel::ps_y(int y1) { - return paper_y - (int)((float) y1 * 72.0 / ydpi); -} - int PSEditModel::load(FILE *fp) { char tmpname[256]; char linebuf[1024]; diff --git a/src/PSEditWidget.H b/src/PSEditWidget.H index 6261646..9f182dd 100644 --- a/src/PSEditWidget.H +++ b/src/PSEditWidget.H @@ -1,5 +1,5 @@ // -// "$Id: PSEditWidget.H,v 1.13 2004/11/08 19:36:14 hofmann Exp $" +// "$Id: PSEditWidget.H,v 1.14 2004/11/10 18:32:59 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -63,6 +63,8 @@ public: void move(int x1, int y1); + void rel_move(int dx, int dy); + void rm_char(); int reload(); @@ -98,6 +100,14 @@ public: int bb_w(PSEditText *t); int bb_h(PSEditText *t); + + int ps_to_display_x(int x1); + + int ps_to_display_y(int y1); + + int ps_x(int x1); + + int ps_y(int y1); }; #endif diff --git a/src/PSEditWidget.cxx b/src/PSEditWidget.cxx index b235941..034be00 100644 --- a/src/PSEditWidget.cxx +++ b/src/PSEditWidget.cxx @@ -1,5 +1,5 @@ // -// "$Id: PSEditWidget.cxx,v 1.28 2004/11/08 19:54:54 hofmann Exp $" +// "$Id: PSEditWidget.cxx,v 1.29 2004/11/10 18:32:59 hofmann Exp $" // // PSEditWidget routines. // @@ -49,15 +49,19 @@ void PSEditWidget::clear_text() { void PSEditWidget::draw() { GsWidget::draw(); PSEditText *t = model->get_text(page); - + int t_x, t_y; + while (t) { + t_x = ps_to_display_x(t->get_x()); + t_y = ps_to_display_y(t->get_y()); + fl_color((Fl_Color) t->get_color()); fl_font(FLPSED_FONT, t->get_size()); - fl_draw(t->get_text(), t->get_x() + x(), t->get_y() + y()); + fl_draw(t->get_text(), t_x + x(), t_y + y()); if (model->is_cur_text(t)) { fl_draw_box(FL_BORDER_FRAME, - t->get_x()+x()-1, - t->get_y()+y()-fl_height()+fl_descent(), + t_x + x()-1, + t_y + y()-fl_height()+fl_descent(), (int) fl_width(t->get_text())+2, fl_height(), FL_BLACK); @@ -67,8 +71,8 @@ void PSEditWidget::draw() { int text_height = fl_height() - fl_descent(); fl_color(FL_BLUE); fl_font(FLPSED_TAG_FONT, FLPSED_TAG_FONT_SIZE); - fl_draw(t->get_tag(), t->get_x() + x(), - t->get_y() + y() - text_height - 1); + fl_draw(t->get_tag(), t_x + x(), + t_y + y() - text_height - 1); } t = t->get_next(); @@ -77,7 +81,7 @@ void PSEditWidget::draw() { PSEditWidget::PSEditWidget(int X,int Y,int W, int H): GsWidget(X, Y, W, H) { - model = new PSEditModel(paper_x, paper_y, xdpi, ydpi); + model = new PSEditModel(); cur_size = 12; show_tags = 1; } @@ -92,7 +96,7 @@ void PSEditWidget::new_text(int x1, int y1, const char *s, int p) { t_old = model->get_cur_text(); - model->new_text(x1, y1, s, cur_size, p); + model->new_text(ps_x(x1), ps_y(y1), s, cur_size, p); mod++; t = model->get_cur_text(); @@ -115,7 +119,7 @@ int PSEditWidget::set_cur_text(int x1, int y1) { t_old = model->get_cur_text(); - if (model->set_cur_text(x1, y1, page) == 0) { + if (model->set_cur_text(ps_x(x1), ps_y(y1), page) == 0) { t_new = model->get_cur_text(); @@ -174,7 +178,28 @@ void PSEditWidget::move(int x1, int y1) { old_bbh = bb_h(t); } - model->move(x1, y1); + model->move(ps_x(x1), ps_y(y1)); + mod++; + + if (t) { + damage(4, old_bbx, old_bby, old_bbw, old_bbh); + damage(4, bb_x(t), bb_y(t), bb_w(t), bb_h(t)); + } +} + +void PSEditWidget::rel_move(int dx, int dy) { + PSEditText *t; + int old_bbx, old_bby, old_bbw, old_bbh; + + t = model->get_cur_text(); + if (t) { + old_bbx = bb_x(t); + old_bby = bb_y(t); + old_bbw = bb_w(t); + old_bbh = bb_h(t); + } + + model->move(t->get_x() + dx, t->get_y() + dy); mod++; if (t) { @@ -284,12 +309,12 @@ int PSEditWidget::replace_tag(char *tag, char *text) { } int PSEditWidget::bb_x(PSEditText *t) { - return t->get_x() + x() - 10; + return ps_to_display_x(t->get_x()) + x() - 10; } int PSEditWidget::bb_y(PSEditText *t) { fl_font(FLPSED_FONT, t->get_size()); - return t->get_y() - fl_height() + y() - 20; + return ps_to_display_y(t->get_y()) - fl_height() + y() - 20; } int PSEditWidget::bb_w(PSEditText *t) { @@ -313,3 +338,18 @@ int PSEditWidget::bb_h(PSEditText *t) { } +int PSEditWidget::ps_to_display_x(int x1) { + return (int) ((float) x1 * xdpi / 72.0); +} + +int PSEditWidget::ps_to_display_y(int y1) { + return (int) ((float) (paper_y - y1) * xdpi / 72.0); +} + +int PSEditWidget::ps_x(int x1) { + return (int) ((float) x1 * 72.0 / xdpi); +} + +int PSEditWidget::ps_y(int y1) { + return paper_y - (int)((float) y1 * 72.0 / ydpi); +} diff --git a/src/PSEditor.cxx b/src/PSEditor.cxx index 6e1c644..276f4ff 100644 --- a/src/PSEditor.cxx +++ b/src/PSEditor.cxx @@ -1,5 +1,5 @@ // -// "$Id: PSEditor.cxx,v 1.21 2004/11/08 19:36:14 hofmann Exp $" +// "$Id: PSEditor.cxx,v 1.22 2004/11/10 18:32:59 hofmann Exp $" // // PSEditor routines. // @@ -73,33 +73,13 @@ int PSEditor::handle(int event) { if (key == FL_BackSpace) { rm_char(); } else if (key == FL_Left) { - PSEditText *t = model->get_cur_text(); - if (t) { - int x = t->get_x(); - int y = t->get_y(); - move(x - 1, y); - } + rel_move(-1, 0); } else if (key == FL_Right) { - PSEditText *t = model->get_cur_text(); - if (t) { - int x = t->get_x(); - int y = t->get_y(); - move(x + 1, y); - } + rel_move(1, 0); } else if (key == FL_Up) { - PSEditText *t = model->get_cur_text(); - if (t) { - int x = t->get_x(); - int y = t->get_y(); - move(x, y - 1); - } + rel_move(0, 1); } else if (key == FL_Down) { - PSEditText *t = model->get_cur_text(); - if (t) { - int x = t->get_x(); - int y = t->get_y(); - move(x, y + 1); - } + rel_move(0, -1); } else if (key == FL_Tab) { next_text(); } else if (Fl::compose(del)) { diff --git a/src/Postscript.cxx b/src/Postscript.cxx index 0579cf4..b3995aa 100644 --- a/src/Postscript.cxx +++ b/src/Postscript.cxx @@ -1,5 +1,5 @@ // -// "$Id: Postscript.cxx,v 1.12 2004/10/26 18:32:07 hofmann Exp $" +// "$Id: Postscript.cxx,v 1.13 2004/11/10 18:32:59 hofmann Exp $" // // Postscript handling routines. // @@ -123,8 +123,7 @@ int PSParser_1::parse(char *line) { cur_size = size; return 1; // line was recognized } else if (sscanf(line, PS_POS_FORMAT, &x1, &y1) == 2) { - pse->new_text(pse->ps_to_display_x(x1), pse->ps_to_display_y(y1), - "", cur_size, page); + pse->new_text(x1, y1, "", cur_size, page); return 1; } else if (sscanf(line, PS_GLYPH_FORMAT, glyph) == 1) { pse->append_text(glyph_to_char(glyph)); @@ -163,8 +162,7 @@ int PSParser_2::parse(char *line) { cur_size = size; return 1; } else if (inside && sscanf(line, PSEDIT_POS_FORMAT, &x1, &y1) == 2) { - pse->new_text(pse->ps_to_display_x(x1), pse->ps_to_display_y(y1),"", - cur_size, page); + pse->new_text(x1, y1, "", cur_size, page); return 1; } else if (inside && sscanf(line, PSEDIT_GLYPH_FORMAT, buf) == 1) { pse->append_text(glyph_to_char(buf)); @@ -293,9 +291,7 @@ int PSWriter::write_text(FILE *out, PSEditText *t) { if (strcmp(s, "") != 0 || t->get_tag() != NULL) { fprintf(out, size_format, t->get_size()); - fprintf(out, pos_format, - pse->ps_x(t->get_x()), - pse->ps_y(t->get_y())); + fprintf(out, pos_format, t->get_x(), t->get_y()); if (t->get_tag()) { fprintf(out, tag_format, t->get_tag()); } diff --git a/src/flpsed.cxx b/src/flpsed.cxx index 6dc6a1b..404df97 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -1,5 +1,5 @@ // -// "$Id: flpsed.cxx,v 1.23 2004/11/08 19:36:14 hofmann Exp $" +// "$Id: flpsed.cxx,v 1.24 2004/11/10 18:32:59 hofmann Exp $" // // flpsed program. // @@ -291,7 +291,7 @@ int main(int argc, char** argv) { // Batch Mode // - PSEditModel *m = new PSEditModel(594, 841, 75.0, 75.0); + PSEditModel *m = new PSEditModel(); int tmp_fd; if (!in_fp) { |