summaryrefslogtreecommitdiffstats
path: root/tkblt/generic/tkbltGrPostscript.C
blob: 4bbf504ddee64cd1e2f30de70fd3c9c8b747f93b (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
/*
 * Smithsonian Astrophysical Observatory, Cambridge, MA, USA
 * This code has been modified under the terms listed below and is made
 * available under the same terms.
 */

/*
 *	Copyright 1991-2004 George A Howlett.
 *
 *	Permission is hereby granted, free of charge, to any person obtaining
 *	a copy of this software and associated documentation files (the
 *	"Software"), to deal in the Software without restriction, including
 *	without limitation the rights to use, copy, modify, merge, publish,
 *	distribute, sublicense, and/or sell copies of the Software, and to
 *	permit persons to whom the Software is furnished to do so, subject to
 *	the following conditions:
 *
 *	The above copyright notice and this permission notice shall be
 *	included in all copies or substantial portions of the Software.
 *
 *	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *	LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *	OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include <stdlib.h>

#include "tkbltGraph.h"
#include "tkbltGrPostscript.h"
#include "tkbltConfig.h"

using namespace Blt;

static Tk_OptionSpec optionSpecs[] = {
  {TK_OPTION_BOOLEAN, "-center", "center", "Center", 
   "yes", -1, Tk_Offset(PostscriptOptions, center), 0, NULL, 0},
  {TK_OPTION_CUSTOM, "-comments", "comments", "Comments",
   NULL, -1, Tk_Offset(PostscriptOptions, comments), 
   TK_OPTION_NULL_OK, &listObjOption, 0},
  {TK_OPTION_BOOLEAN, "-decorations", "decorations", "Decorations",
   "yes", -1, Tk_Offset(PostscriptOptions, decorations), 0, NULL, 0},
  {TK_OPTION_BOOLEAN, "-footer", "footer", "Footer",
   "no", -1, Tk_Offset(PostscriptOptions, footer), 0, NULL, 0},
  {TK_OPTION_BOOLEAN, "-greyscale", "greyscale", "Greyscale",
   "no", -1, Tk_Offset(PostscriptOptions, greyscale), 0, NULL, 0},
  {TK_OPTION_PIXELS, "-height", "height", "Height", 
   "0", -1, Tk_Offset(PostscriptOptions, reqHeight), 0, NULL, 0},
  {TK_OPTION_BOOLEAN, "-landscape", "landscape", "Landscape",
   "no", -1, Tk_Offset(PostscriptOptions, landscape), 0, NULL, 0},
  {TK_OPTION_INT, "-level", "level", "Level", 
   "2", -1, Tk_Offset(PostscriptOptions, level), 0, NULL, 0},
  {TK_OPTION_PIXELS, "-padx", "padX", "PadX", 
   "1.0i", -1, Tk_Offset(PostscriptOptions, xPad), 0, NULL, 0},
  {TK_OPTION_PIXELS, "-pady", "padY", "PadY", 
   "1.0i", -1, Tk_Offset(PostscriptOptions, yPad), 0, NULL, 0},
  {TK_OPTION_PIXELS, "-paperheight", "paperHeight", "PaperHeight",
   "11.0i", -1, Tk_Offset(PostscriptOptions, reqPaperHeight), 0, NULL, 0},
  {TK_OPTION_PIXELS, "-paperwidth", "paperWidth", "PaperWidth",
   "8.5i", -1, Tk_Offset(PostscriptOptions, reqPaperWidth), 0, NULL, 0},
  {TK_OPTION_PIXELS, "-width", "width", "Width", 
   "0", -1, Tk_Offset(PostscriptOptions, reqWidth), 0, NULL, 0},
  {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
};

Postscript::Postscript(Graph* graphPtr)
{
  ops_ = (PostscriptOptions*)calloc(1, sizeof(PostscriptOptions));
  graphPtr_ = graphPtr;

  optionTable_ =Tk_CreateOptionTable(graphPtr_->interp_, optionSpecs);
  Tk_InitOptions(graphPtr_->interp_, (char*)ops_, optionTable_,
		 graphPtr_->tkwin_);
}

Postscript::~Postscript()
{
  Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_);
  free(ops_);
}