summaryrefslogtreecommitdiff
path: root/src/PSEditWidget.cxx
blob: ef8431ca13c03316fb3eab899c0c33c341396fd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// 
// "$Id: PSEditWidget.cxx,v 1.18 2004/10/21 19:55:36 hofmann Exp $"
//
// PSEditWidget routines.
//
// Copyright 2004 by Johannes Hofmann
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <errno.h>

#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/x.H>

#include "PSEditWidget.H"

void PSEditWidget::clear_text() {
  model->clear();
}

void PSEditWidget::draw() {
  GsWidget::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);
  cur_size = 12;
  show_tags = 1;
}
  
int PSEditWidget::next() {
  model->set_page(page);
  return GsWidget::next();
}  

void PSEditWidget::new_text(int x1, int y1, const char *s, int p) {
  model->new_text(x1, y1, s, cur_size, p);
  redraw();
}

void PSEditWidget::new_text(int x1, int y1, const char *s) {
  new_text(x1, y1, s, page);
}

int PSEditWidget::set_cur_text(int x1, int y1) {
  if (model->set_cur_text(x1, y1, page) == 0) {
    redraw();
    return 0;
  }
  return 1;
}

void PSEditWidget::append_text(const char *s) {
  model->append_text(s);
  redraw();
}

void PSEditWidget::move(int x1, int y1) {
  model->move(x1, y1);
  redraw();
}

void PSEditWidget::rm_char() {
  model->rm_char();
  redraw();
}


int PSEditWidget::reload() {
  model->set_page(0);
  return GsWidget::reload();
}

void PSEditWidget::set_cur_size(int s) {
  cur_size = s;
}

void PSEditWidget::set_size(int s) {
  set_cur_size(s);
  model->set_size(s);
  redraw();
}

int PSEditWidget::get_size() {
  int s;

  s = model->get_size();
  if (s >= 0) {
    return s;
  } else {
    return cur_size;
  }
}

int PSEditWidget::get_max_pages() {
  return model->get_max_pages();
}

int PSEditWidget::get_show_tags() {
  return show_tags;
}

void PSEditWidget::set_show_tags(int s) {
  show_tags = s;
  redraw();
}

int PSEditWidget::set_tag(const char *t) {
  if (model->set_tag(t) == 0) {
    mod++;
    return 0;
  } else {
    return 1;
  }
}

char *PSEditWidget::get_tag() {
  return model->get_tag();
}

int PSEditWidget::modified() {
  return mod;
}

int PSEditWidget::file_loaded() {
  return loaded;
}

int PSEditWidget::replace_tag(char *tag, char *text) {
  fprintf(stderr, "%s => %s\n", tag, text);

  return 0;
}