summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-26 16:08:57 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-26 16:08:57 +0000
commit7fce5830e8404516079787ca6fb1975ba8947965 (patch)
tree84abd4680531ba85d14423b6c48e62f1d97d5f5d /src
parent85eb1cbeab8da10561784621f5f59b42ef23fbd9 (diff)
- cleanups - fix damage stuff for long tags
- cleanups - fix damage stuff for long tags
Diffstat (limited to 'src')
-rw-r--r--src/GsWidget.cxx4
-rw-r--r--src/PSEditWidget.H10
-rw-r--r--src/PSEditWidget.cxx93
3 files changed, 72 insertions, 35 deletions
diff --git a/src/GsWidget.cxx b/src/GsWidget.cxx
index 7b50b6f..e2c3341 100644
--- a/src/GsWidget.cxx
+++ b/src/GsWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: GsWidget.cxx,v 1.10 2004/10/26 17:22:45 hofmann Exp $"
+// "$Id: GsWidget.cxx,v 1.11 2004/10/26 18:08:57 hofmann Exp $"
//
// GsWidget routines.
//
@@ -84,7 +84,7 @@ void GsWidget::setProps() {
void GsWidget::kill_gs() {
int status;
- fprintf(stderr, "Killing...\n");
+
if (gs_pid > 0) {
kill(gs_pid, SIGTERM);
waitpid(gs_pid, &status, 0);
diff --git a/src/PSEditWidget.H b/src/PSEditWidget.H
index 6ad3704..775ac42 100644
--- a/src/PSEditWidget.H
+++ b/src/PSEditWidget.H
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditWidget.H,v 1.10 2004/10/26 16:58:49 hofmann Exp $"
+// "$Id: PSEditWidget.H,v 1.11 2004/10/26 18:08:57 hofmann Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -88,6 +88,14 @@ public:
int file_loaded();
int replace_tag(char* tag, char* text);
+
+ int PSEditWidget::bb_x(PSEditText *t);
+
+ int PSEditWidget::bb_y(PSEditText *t);
+
+ int PSEditWidget::bb_w(PSEditText *t);
+
+ int PSEditWidget::bb_h(PSEditText *t);
};
#endif
diff --git a/src/PSEditWidget.cxx b/src/PSEditWidget.cxx
index 4186504..21b327f 100644
--- a/src/PSEditWidget.cxx
+++ b/src/PSEditWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditWidget.cxx,v 1.23 2004/10/26 17:22:45 hofmann Exp $"
+// "$Id: PSEditWidget.cxx,v 1.24 2004/10/26 18:08:57 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -37,6 +37,11 @@
#include "PSEditWidget.H"
+#define FLPSED_FONT FL_HELVETICA
+#define FLPSED_TAG_FONT FL_COURIER
+#define FLPSED_TAG_FONT_SIZE 10
+
+
void PSEditWidget::clear_text() {
model->clear();
}
@@ -47,7 +52,7 @@ void PSEditWidget::draw() {
while (t) {
fl_color((Fl_Color) t->get_color());
- fl_font(FL_HELVETICA, t->get_size());
+ fl_font(FLPSED_FONT, t->get_size());
fl_draw(t->get_text(), t->get_x() + x(), t->get_y() + y());
if (model->is_cur_text(t)) {
fl_draw_box(FL_BORDER_FRAME,
@@ -61,7 +66,7 @@ void PSEditWidget::draw() {
if (t->get_tag() && show_tags) {
int text_height = fl_height() - fl_descent();
fl_color(FL_BLUE);
- fl_font(FL_COURIER, 10);
+ 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);
}
@@ -82,20 +87,20 @@ int PSEditWidget::next() {
}
void PSEditWidget::new_text(int x1, int y1, const char *s, int p) {
- PSEditText *t_old;
+ PSEditText *t_old, *t;
t_old = model->get_cur_text();
model->new_text(x1, y1, s, cur_size, p);
- fl_font(FL_HELVETICA, cur_size);
- damage(4, x1 - 10, y1 - fl_height() - 20,
- fl_width(s) + 20, fl_height() + 30);
+ t = model->get_cur_text();
+
+ if (t) {
+ damage(4, bb_x(t), bb_y(t), bb_w(t), bb_h(t));
+ }
if (t_old) {
- fl_font(FL_HELVETICA, t_old->get_size());
- damage(4, t_old->get_x() - 10, t_old->get_y() - fl_height() - 20,
- fl_width(t_old->get_text()) + 20, fl_height() + 30);
+ damage(4, bb_x(t_old), bb_y(t_old), bb_w(t_old), bb_h(t_old));
}
}
@@ -113,14 +118,10 @@ int PSEditWidget::set_cur_text(int x1, int y1) {
t_new = model->get_cur_text();
if (t_new) {
- fl_font(FL_HELVETICA, t_new->get_size());
- damage(4, t_new->get_x() - 10, t_new->get_y() - fl_height() - 20,
- fl_width(t_new->get_text()) + 20, fl_height() + 30);
+ damage(4, bb_x(t_new), bb_y(t_new), bb_w(t_new), bb_h(t_new));
}
if (t_old) {
- fl_font(FL_HELVETICA, t_old->get_size());
- damage(4, t_old->get_x() - 10, t_old->get_y() - fl_height() - 20,
- fl_width(t_old->get_text()) + 20, fl_height() + 30);
+ damage(4, bb_x(t_old), bb_y(t_old), bb_w(t_old), bb_h(t_old));
}
return 0;
}
@@ -134,8 +135,7 @@ void PSEditWidget::append_text(const char *s) {
t = model->get_cur_text();
if (t) {
- fl_font(FL_HELVETICA, t->get_size());
- damage(4, t->get_x() - 10, t->get_y() - fl_height() - 20, fl_width(t->get_text()) + 20, fl_height() + 30);
+ damage(4, bb_x(t), bb_y(t), bb_w(t), bb_h(t));
}
}
@@ -145,27 +145,25 @@ void PSEditWidget::move(int x1, int y1, int last_x, int last_y) {
model->move(x1, y1);
t = model->get_cur_text();
if (t) {
- fl_font(FL_HELVETICA, t->get_size());
- damage(4, x1 - 10, y1 - fl_height() - 20, fl_width(t->get_text()) + 20, fl_height() + 30);
- damage(4, last_x - 10, last_y - fl_height() - 20, fl_width(t->get_text()) + 20, fl_height() + 30);
-
+ damage(4, bb_x(t), bb_y(t), bb_w(t), bb_h(t));
+ damage(4, last_x - 10, last_y - fl_height() - 20, bb_w(t), bb_h(t));
}
}
void PSEditWidget::rm_char() {
PSEditText *t;
- double width;
+ int width;
t = model->get_cur_text();
if (t) {
- fl_font(FL_HELVETICA, t->get_size());
- width = fl_width(t->get_text());
+ fl_font(FLPSED_FONT, t->get_size());
+ width = bb_w(t);
}
model->rm_char();
if (t) {
- damage(4, t->get_x() - 10, t->get_y() - fl_height() - 20, width + 20, fl_height() + 30);
+ damage(4, bb_x(t), bb_y(t), width, bb_h(t));
}
}
@@ -181,21 +179,22 @@ void PSEditWidget::set_cur_size(int s) {
void PSEditWidget::set_size(int s) {
PSEditText *t;
- int old_size;
+ int old_x, old_y, old_w, old_h;
t = model->get_cur_text();
if (t) {
- old_size = t->get_size();
+ old_x = bb_x(t);
+ old_y = bb_y(t);
+ old_w = bb_w(t);
+ old_h = bb_h(t);
}
set_cur_size(s);
model->set_size(s);
if (t) {
- fl_font(FL_HELVETICA, t->get_size());
- damage(4, t->get_x() - 10, t->get_y() - fl_height() - 20, fl_width(t->get_text()) + 20, fl_height() + 30);
- fl_font(FL_HELVETICA, old_size);
- damage(4, t->get_x() - 10, t->get_y() - fl_height() - 20, fl_width(t->get_text()) + 20, fl_height() + 30);
+ damage(4, bb_x(t), bb_y(t), bb_w(t), bb_h(t));
+ damage(4, old_x, old_y, old_w, old_h);
}
}
@@ -250,3 +249,33 @@ int PSEditWidget::replace_tag(char *tag, char *text) {
return model->replace_tag(tag, text);
}
+int PSEditWidget::bb_x(PSEditText *t) {
+ return t->get_x() - 10;
+}
+
+int PSEditWidget::bb_y(PSEditText *t) {
+ fl_font(FLPSED_FONT, t->get_size());
+ return t->get_y() - fl_height() - 20;
+}
+
+int PSEditWidget::bb_w(PSEditText *t) {
+ int w, wt = 0;
+ char *tag;
+ fl_font(FLPSED_FONT, t->get_size());
+ w = (int) fl_width(t->get_text()) + 20;
+
+ tag = t->get_tag();
+ if (tag) {
+ fl_font(FLPSED_TAG_FONT, FLPSED_TAG_FONT_SIZE);
+ wt = (int) fl_width(tag) + 20;
+ }
+
+ return w>=wt?w:wt;
+}
+
+int PSEditWidget::bb_h(PSEditText *t) {
+ fl_font(FLPSED_FONT, t->get_size());
+ return fl_height() + 30;
+}
+
+