summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-12 18:52:23 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-12 18:52:23 +0000
commitbe8b4a78d6bcfd5738864cea03f8a218724f6397 (patch)
tree1775506a0ba17e68c1475c12f375b3ae1dd106a1
parent570f2cbe4b10f587591273226a64b79d6d0f48e7 (diff)
add initial tags handling
add initial tags handling
-rw-r--r--src/PSEditWidget.H14
-rw-r--r--src/PSEditWidget.cxx63
-rw-r--r--src/PSEditor.H7
-rw-r--r--src/PSEditor.cxx8
-rw-r--r--src/flpsed.cxx22
5 files changed, 97 insertions, 17 deletions
diff --git a/src/PSEditWidget.H b/src/PSEditWidget.H
index 04f72dd..afb3021 100644
--- a/src/PSEditWidget.H
+++ b/src/PSEditWidget.H
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditWidget.H,v 1.6 2004/07/09 17:22:55 hofmann Exp $"
+// "$Id: PSEditWidget.H,v 1.7 2004/10/12 20:52:23 hofmann Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -33,8 +33,11 @@ private:
PSText **text;
int max_pages;
int cur_size;
+ int show_tags;
protected:
+ int loaded;
+ int mod;
void clear_text();
void draw();
@@ -58,13 +61,20 @@ public:
void set_size(int s);
int get_size();
int get_max_pages();
+ char *get_tag();
+ int set_tag(const char *t);
+ int get_show_tags();
+ void set_show_tags(int s);
PSText * get_text(int p);
+ int modified();
+ int file_loaded();
};
class PSText {
int x, y;
char *s;
+ char *tag;
PSText *next;
PSEditWidget *gsew;
@@ -80,6 +90,8 @@ public:
void append(PSText *g);
PSText *get_match(int x1, int y1);
char *get_text();
+ char *get_tag();
+ int set_tag(const char *t);
int get_size();
PSText *get_next();
Fl_Color get_color();
diff --git a/src/PSEditWidget.cxx b/src/PSEditWidget.cxx
index 257cb7f..f6de76d 100644
--- a/src/PSEditWidget.cxx
+++ b/src/PSEditWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditWidget.cxx,v 1.15 2004/10/12 17:14:16 hofmann Exp $"
+// "$Id: PSEditWidget.cxx,v 1.16 2004/10/12 20:52:23 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -62,6 +62,7 @@ PSEditWidget::PSEditWidget(int X,int Y,int W, int H) : GsWidget(X, Y, W, H) {
}
cur_text = NULL;
cur_size = 12;
+ show_tags = 1;
}
int PSEditWidget::next() {
@@ -168,6 +169,15 @@ int PSEditWidget::get_max_pages() {
return max_pages;
}
+int PSEditWidget::get_show_tags() {
+ return show_tags;
+}
+
+void PSEditWidget::set_show_tags(int s) {
+ show_tags = s;
+ redraw();
+}
+
PSText *PSEditWidget::get_text(int p) {
if (p >= max_pages) {
return 0;
@@ -176,12 +186,36 @@ PSText *PSEditWidget::get_text(int p) {
}
}
+int PSEditWidget::set_tag(const char *t) {
+ if (cur_text) {
+ mod++;
+ return cur_text->set_tag(t);
+ } else {
+ return 1;
+ }
+}
+
+char *PSEditWidget::get_tag() {
+ if (cur_text) {
+ return cur_text->get_tag();
+ } else {
+ return NULL;
+ }
+}
+
+int PSEditWidget::modified() {
+ return mod;
+}
+int PSEditWidget::file_loaded() {
+ return loaded;
+}
PSText::PSText(PSEditWidget *g, int x1, int y1, const char *s1, int size1) {
x = x1;
y = y1;
s = strdup(s1);
+ tag = NULL;
c = FL_BLACK;
size = size1;
next = NULL;
@@ -195,6 +229,9 @@ PSText::~PSText() {
if (s) {
free(s);
}
+ if (tag) {
+ free(tag);
+ }
}
void PSText::append_text(const char*s1) {
@@ -246,8 +283,17 @@ void PSText::draw(int off_x,int off_y) {
fl_font(FL_HELVETICA, size);
fl_draw(s, x + off_x, y + off_y);
if (gsew->cur_text == this) {
- fl_draw_box(FL_BORDER_FRAME, x+off_x-1, y+off_y-fl_height()+fl_descent(), (int) fl_width(s)+2, fl_height(), FL_BLACK);
+ fl_draw_box(FL_BORDER_FRAME, x+off_x-1, y+off_y-fl_height()+fl_descent(),
+ (int) fl_width(s)+2, fl_height(), FL_BLACK);
+ }
+
+ if (tag && gsew->get_show_tags()) {
+ int text_height = fl_height() - fl_descent();
+ fl_color(FL_BLUE);
+ fl_font(FL_COURIER, 10);
+ fl_draw(tag, x + off_x, y + off_y - text_height - 1);
}
+
if (p->next) {
p->next->draw(off_x, off_y);
}
@@ -257,6 +303,19 @@ char *PSText::get_text() {
return s;
}
+char *PSText::get_tag() {
+ return tag;
+}
+
+int PSText::set_tag(const char *t) {
+ if (tag) {
+ free(tag);
+ }
+ tag = strdup(t);
+ gsew->redraw();
+ return 0;
+}
+
int PSText::get_size() {
return size;
}
diff --git a/src/PSEditor.H b/src/PSEditor.H
index dc7545c..10adee6 100644
--- a/src/PSEditor.H
+++ b/src/PSEditor.H
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditor.H,v 1.3 2004/10/11 14:44:47 hofmann Exp $"
+// "$Id: PSEditor.H,v 1.4 2004/10/12 20:52:23 hofmann Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -29,11 +29,8 @@
class PSEditor : public PSEditWidget {
private:
int mark_x, mark_y;
- int loaded;
- int mod;
int tmp_fd;
int ps_level;
-
int handle(int event);
public:
@@ -41,8 +38,6 @@ public:
int load(char *f);
int save(const char* savefile);
int import(char *f);
- int modified();
- int file_loaded();
void set_ps_level(int l);
int get_ps_level();
};
diff --git a/src/PSEditor.cxx b/src/PSEditor.cxx
index fa8ad34..8e9de8b 100644
--- a/src/PSEditor.cxx
+++ b/src/PSEditor.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditor.cxx,v 1.10 2004/10/12 17:14:16 hofmann Exp $"
+// "$Id: PSEditor.cxx,v 1.11 2004/10/12 20:52:23 hofmann Exp $"
//
// PSEditor routines.
//
@@ -102,13 +102,7 @@ int PSEditor::handle(int event) {
}
-int PSEditor::modified() {
- return mod;
-}
-int PSEditor::file_loaded() {
- return loaded;
-}
int PSEditor::load(char *f) {
diff --git a/src/flpsed.cxx b/src/flpsed.cxx
index 3ffda53..be72d7d 100644
--- a/src/flpsed.cxx
+++ b/src/flpsed.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: flpsed.cxx,v 1.14 2004/10/12 16:41:43 hofmann Exp $"
+// "$Id: flpsed.cxx,v 1.15 2004/10/12 20:52:23 hofmann Exp $"
//
// flpsed program.
//
@@ -148,7 +148,21 @@ void size_cb(Fl_Widget *w, void *) {
}
}
+void show_tags_cb(Fl_Widget* w, void*d) {
+ fprintf(stderr, "===> %d\n", ((int) d));
+ gsw_p->set_show_tags((int) d);
+}
+void edit_tag_cb() {
+ char *tag = gsw_p->get_tag();
+ const char *new_tag;
+ new_tag = fl_input("Tag Name", tag?tag:"");
+ if (strcmp(new_tag, "") != 0) {
+ gsw_p->set_tag(new_tag);
+ } else {
+ gsw_p->set_tag(NULL);
+ }
+}
Fl_Menu_Item menuitems[] = {
{ "&File", 0, 0, 0, FL_SUBMENU },
@@ -173,6 +187,12 @@ Fl_Menu_Item menuitems[] = {
{ "24", 0, (Fl_Callback *)size_cb },
{ 0 },
+ { "&Tags", 0, 0, 0, FL_SUBMENU },
+ { "Sh&ow Tags", FL_CTRL + 'o', (Fl_Callback *)show_tags_cb, (void *)1, FL_MENU_RADIO|FL_MENU_VALUE},
+ { "&Hide Tags", FL_CTRL + 'h', (Fl_Callback *)show_tags_cb, (void *)0, FL_MENU_RADIO},
+ { "&Edit Tag", FL_CTRL + 'e', (Fl_Callback *)edit_tag_cb },
+ { 0 },
+
{ "&Help", 0, 0, 0, FL_SUBMENU },
{ "About", 0, (Fl_Callback *)about_cb },
{ 0 },