feisty meow concerns codebase  2.140
screen_rectangle.cpp
Go to the documentation of this file.
1 
2 
3 
4 /*****************************************************************************\
5 * *
6 * Name : screen_rectangle *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 1992-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
18 #include "rectangle.h"
19 #include "screen_rectangle.h"
20 
21 #include <basis/mutex.h>
22 
24 
25 using namespace basis;
26 
27 namespace geometric {
28 
29 SAFE_STATIC_CONST(screen_point, screen_origin, (0, 0))
30 
31 
33 #ifdef __WIN32__
34 screen_point::screen_point(const tagPOINT &original) : point<int>(original.x, original.y) {}
35 
36 screen_point::operator tagPOINT()
37 { POINT to_return; to_return.x = x(); to_return.y = y(); return to_return; }
38 #endif
39 
41 
42 screen_rectangle::screen_rectangle(const rectangle<int> &init)
43 : rectangle<int>(init) {}
44 
46  const screen_point &vertex_2)
47 : rectangle<int>(vertex_1, vertex_2) {}
48 
49 screen_rectangle::screen_rectangle(int x_1, int y_1, int x_2, int y_2)
50 : rectangle<int>(x_1, y_1, x_2, y_2) {}
51 
53 { return screen_rectangle(top_left(), bottom_right()); }
54 
56 { return rectangle<int>::bottom_left(); }
57 
59 { return rectangle<int>::top_left(); }
60 
62 { return rectangle<int>::bottom_right(); }
63 
65 { return rectangle<int>::top_right(); }
66 
67 #ifdef __WIN32__
68 screen_rectangle::screen_rectangle(const tagRECT &original)
69 : rectangle<int>(original.left, original.top, original.right, original.bottom)
70 {}
71 
72 screen_rectangle::operator tagRECT() const
73 {
74  RECT to_return; to_return.left = left();
75  to_return.top = top(); to_return.right = right();
76  to_return.bottom = bottom(); return to_return;
77 }
78 #endif
79 
80 } // namespace.
81 
82 
83 
point< numeric_type > top_left() const
Definition: rectangle.h:200
point< numeric_type > bottom_left() const
Definition: rectangle.h:207
point< numeric_type > bottom_right() const
returns the appropriate point as represented by our rectangle.
Definition: rectangle.h:221
point< numeric_type > top_right() const
Definition: rectangle.h:214
a simple class used to describe points on a graphics screen.
Represents a rectangle as interpreted on display screens.
screen_point bottom_right() const
screen_point bottom_left() const
screen_point top_left() const
screen_point top_right() const
screen_rectangle order() const
Re-orders the vertices to match expectations.
screen_rectangle(const screen_point &vertex_1, const screen_point &vertex_2)
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
Contains all of our objects for geometry and avoids name clashes.
Definition: angle.h:25
const screen_point & screen_origin()
the origin of the screen coordinate system (which is top-left here).
#define SAFE_STATIC_CONST(type, func_name, parms)
this version returns a constant object instead.