summaryrefslogtreecommitdiff
path: root/src/gipfel.cxx
blob: e72703d1f8b0ed88992a6abe58de5f09a420288d (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
// 
// "$Id: gipfel.cxx,v 1.2 2005/04/13 15:36:36 hofmann Exp $"
//
// flpsed program.
//
// Copyright 2004 by Johannes Hofmann
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU 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 <signal.h>

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Item.H>

#include "GipfelWidget.H"

char *filename;

void open_cb() {
  char *file = fl_file_chooser("Open File?", "*.ps", filename);
  if(file != NULL) {

  }  
}

void about_cb() {
  fl_message("flpsed -- a pseudo PostScript editor\n"
	     "(c) Johannes Hofmann 2004, 2005\n\n"
	     "PostScript is a registered trademark of Adobe Systems");
}

Fl_Menu_Item menuitems[] = {
  { "&File",              0, 0, 0, FL_SUBMENU },
    { "&Open File...",    FL_CTRL + 'o', (Fl_Callback *)open_cb },
  {0},
  { 0 }
};
  

void usage() {
  fprintf(stderr,
	  "usage: flpsed [-hbd] [-t <tag>=<value>] [<infile>] [<outfile>]\n"
	  "   -h                 print this message\n"
	  "   -b                 batch mode (no gui)\n"
	  "   -d                 dump tags and values from a document\n"
	  "                      to stdout (this implies -b)\n"
	  "   -t <tag>=<value>   set text to <value> where tag is <tag>\n"
	  "   <infile>           optional input file; in batch mode if no\n"
	  "                      input file is given, input is read from stdin\n"
	  "   <outfile>          optional output file for batch mode; if no\n"
	  "                      output file is given, output is written to stdout\n");
}


int main(int argc, char** argv) {
  char c, *sep, *tmp, **my_argv;
  int err, bflag = 0, dflag = 0, my_argc;
  Fl_Window *win;
  Fl_Scroll *scroll;
  Fl_Menu_Bar *m;
  
  err = 0;
  while ((c = getopt(argc, argv, "hdbt:")) != EOF) {
    switch (c) {  
    case 'h':
      usage();
      exit(0);
      break;
    case 'b':
      bflag = 1;
      break;
    case 'd':
      dflag = 1;
      break;
    default:
      err++;
    }
  }
  
  if (err) {
    usage();
    exit(1);
  }

  my_argc = argc - optind;
  my_argv = argv + optind;

  fprintf(stderr, "%d %s\n", my_argc, my_argv[0]);
  if (my_argc >= 1) {
    filename = my_argv[0];
  }
  

  win = new Fl_Window(600,700);
  m = new Fl_Menu_Bar(0, 0, 600, 30);
  m->menu(menuitems);
  scroll = new Fl_Scroll(0, 30, win->w(), win->h()-30);
  fprintf(stderr, "%s\n", filename);
  
  GipfelWidget *gipf = new GipfelWidget(0,30,500,500);

  gipf->load(filename);
  scroll->end();
  
    
  win->resizable(scroll);
  
  win->end();
  win->show(1, argv); 
  gipf->redraw_overlay();
  
  return Fl::run();
}