tbx  0.7.5
drawfile.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 /*
26  * drawfile.h
27  *
28  * Created on: 2 Nov 2010
29  * Author: alanb
30  */
31 
32 #ifndef TBX_DRAWFILE_H_
33 #define TBX_DRAWFILE_H_
34 
35 #include "image.h"
36 #include "bbox.h"
37 #include "drawtransform.h"
38 #include <string>
39 
40 namespace tbx {
41 
48 class DrawFile : public Image
49 {
50 private:
51  char *_data;
52  int _size;
53 public:
54  DrawFile();
55  DrawFile(const DrawFile &other);
56  virtual ~DrawFile();
57 
58  DrawFile &operator=(const DrawFile &other);
59 
60  bool load(const std::string &file_name);
61 
65  bool is_valid() const {return _data != 0;}
66 
67  // Image overrides
68  virtual void plot(int x, int y) const;
69  virtual void plot(const tbx::Point &pt) const;
70 
71  void render(DrawTransform *dt = 0, BBox *clip = 0, int flatness = -1 ) const;
72  void bounds(BBox &bounds, DrawTransform *dt = 0) const;
73  void declare_fonts(bool download_fonts = true) const;
74 
75 };
76 
77 }
78 
79 #endif /* DRAWFILE_H_ */
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
Class to represent Drawing transforms.
Definition: drawtransform.h:59
bool is_valid() const
Check if a draw file has been loaded.
Definition: drawfile.h:65
DrawFile & operator=(const DrawFile &other)
Make into a copy of another draw file.
Definition: drawfile.cc:77
Class to represent a two dimensional bounding box.
Definition: bbox.h:37
void declare_fonts(bool download_fonts=true) const
Declare all the fonts in the drawfile for printing using PDriver_DeclareFonts.
Definition: drawfile.cc:212
DrawFile()
Construct an unloaded draw file.
Definition: drawfile.cc:42
virtual ~DrawFile()
Destructor deletes loaded drawfile.
Definition: drawfile.cc:69
Class to render a draw file to the screen.
Definition: drawfile.h:48
bool load(const std::string &file_name)
Load JPEG from file.
Definition: drawfile.cc:100
Base class image classes providing a consistent interface to plot the to the screen.
Definition: image.h:44
void render(DrawTransform *dt=0, BBox *clip=0, int flatness=-1) const
Render a draw file to screen.
Definition: drawfile.cc:166
virtual void plot(int x, int y) const
Plot draw file at given location.
Definition: drawfile.cc:139
Class to represent a position in two dimensional space.
Definition: point.h:36
void bounds(BBox &bounds, DrawTransform *dt=0) const
Return the bounding box for a drawfile with the given transform.
Definition: drawfile.cc:194