gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
CairoBox.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 
18 #ifndef CAIROBOX_H_
19 #define CAIROBOX_H_
20 
21 #include <cairo/cairo.h>
22 
23 #define CAIROBOX_DEFAULT_START_ORDINATE 0.
24 #define CAIROBOX_DEFAULT_WIDTH_HEIGHT 10.
25 #define CAIROBOX_DEFAULT_FILLED false
26 
27 
31 class CairoBox {
32  float x;
33  float y;
34  float width;
35  float height;
36  bool filled;
37 public:
41  width=height=CAIROBOX_DEFAULT_WIDTH_HEIGHT;
43  }
44 
54  CairoBox(cairo_t *cr, float xBase, float yBase, float w, float h, bool fill) {
55  setXY(xBase, yBase);
56  width=w;
57  height=h;
58  filled=fill;
59  draw(cr);
60  }
61 
63  virtual ~CairoBox() {
64  }
65 
73  void boxSettings(float xBase, float yBase, float w, float h, bool fill) {
74  setXY(xBase, yBase);
75  width=w;
76  height=h;
77  filled=fill;
78  }
79 
89  void draw(cairo_t *cr, float xBase, float yBase, float w, float h, bool fill) {
90  boxSettings(xBase, yBase, w, h, fill);
91  draw(cr);
92  }
93 
100  void draw(cairo_t *cr, float xBase, float yBase) {
101  setXY(xBase, yBase);
102  draw(cr);
103  }
104 
106  void draw(cairo_t *cr) {
107  if (!cr) return;
108  //cout<<x<<'\t'<<y<<'\t'<<width<<'\t'<<height<<endl;
109  cairo_rectangle(cr, x, y, width, height);
110  if (!filled)
111  cairo_stroke (cr);
112  else
113  cairo_fill (cr);
114  }
115 
119  float getX(void) {
120  return x;
121  }
125  float getY(void) {
126  return y;
127  }
131  float getWidth(void) {
132  return width;
133  }
137  float getHeight(void) {
138  return height;
139  }
140 
145  void setXY(float xBase, float yBase) {
146  x=xBase;
147  y=yBase;
148  }
149 
154  void setWidthHeight(int widthIn, int heightIn) {
155  width=widthIn;
156  height=heightIn;
157  }
158 };
159 
160 #endif // CAIROBOX_H_
float width
The box with.
Definition: CairoBox.H:34
float getHeight(void)
Definition: CairoBox.H:137
CairoBox(cairo_t *cr, float xBase, float yBase, float w, float h, bool fill)
Definition: CairoBox.H:54
void setWidthHeight(int widthIn, int heightIn)
Definition: CairoBox.H:154
CairoBox()
Empty constructor - sets default start point and width, height.
Definition: CairoBox.H:39
void draw(cairo_t *cr)
Definition: CairoBox.H:106
float height
The box height.
Definition: CairoBox.H:35
float y
The base coordinate.
Definition: CairoBox.H:33
#define CAIROBOX_DEFAULT_WIDTH_HEIGHT
The default width and height for the box.
Definition: CairoBox.H:24
float getY(void)
Definition: CairoBox.H:125
void draw(cairo_t *cr, float xBase, float yBase, float w, float h, bool fill)
Definition: CairoBox.H:89
void draw(cairo_t *cr, float xBase, float yBase)
Draw the box using the member variable state to define the box.
Definition: CairoBox.H:100
virtual ~CairoBox()
Destructor.
Definition: CairoBox.H:63
float x
The base ordinate.
Definition: CairoBox.H:32
#define CAIROBOX_DEFAULT_START_ORDINATE
The default starting ordinate/coordinate for the box.
Definition: CairoBox.H:23
bool filled
Whether to fill the box.
Definition: CairoBox.H:36
void boxSettings(float xBase, float yBase, float w, float h, bool fill)
Definition: CairoBox.H:73
float getWidth(void)
Definition: CairoBox.H:131
void setXY(float xBase, float yBase)
Definition: CairoBox.H:145
#define CAIROBOX_DEFAULT_FILLED
The default fill value.
Definition: CairoBox.H:25
float getX(void)
Definition: CairoBox.H:119
gtkIOStream: /tmp/gtkiostream/include/CairoBox.H Source File
GTK+ IOStream  Beta