first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / graphiq / library / geometric / screen_rectangle.h
1 #ifndef SCREEN_RECTANGLE_CLASS
2 #define SCREEN_RECTANGLE_CLASS
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 <application/windoze_helper.h>
19
20 #include "rectangle.h"
21
22 #ifdef __WIN32__
23   // forward.
24   struct tagPOINT; struct tagRECT;
25 #endif
26
27 namespace geometric {
28
29 // forward.
30 class double_angle;
31
32 //! a simple class used to describe points on a graphics screen.
33
34 class screen_point : public point<int>
35 {
36 public:
37   screen_point(int x = 0, int y = 0) : point<int>(x, y) {}
38   screen_point(int r, double_angle theta) : point<int>(r, theta) {}
39   screen_point(const point<int> &original) : point<int>(original) {}
40   DEFINE_CLASS_NAME("screen_point");
41
42 #ifdef __WIN32__
43   screen_point(const tagPOINT &original);
44     //!< helpful conversions from basic ms-windows type.
45   operator tagPOINT();
46     //!< helpful conversions to basic ms-windows type.
47 #endif
48 };
49
50 const screen_point &screen_origin();
51   //!< the origin of the screen coordinate system (which is top-left here).
52
53 //////////////
54
55 //! Represents a rectangle as interpreted on display screens.
56 /*!
57   The origin is the top-left corner of the rectangle and the y coordinate
58   gets larger as one goes downwards.  This class is primarily useful in
59   conjunction with a windowing environment.
60 */
61
62 class screen_rectangle : public rectangle<int>
63 {
64 public:
65   screen_rectangle(const screen_point &vertex_1, const screen_point &vertex_2);
66   screen_rectangle(int x_1 = 0, int y_1 = 0, int x_2 = 0, int y_2 = 0);
67   screen_rectangle(const rectangle<int> &init);
68
69   screen_rectangle order() const;
70     //!< Re-orders the vertices to match expectations.
71     /*!< This is just like rectangle::order() except that the first vertex
72     will be closest to the top-left of the screen. */
73
74   screen_point top_left() const;
75   screen_point bottom_left() const;
76   screen_point top_right() const;
77   screen_point bottom_right() const;
78
79   int left() const { return top_left().x(); }
80   int top() const { return top_left().y(); }
81   int right() const { return bottom_right().x(); }
82   int bottom() const { return bottom_right().y(); }
83
84 #ifdef __WIN32__
85   screen_rectangle(const tagRECT &original);
86     //!< helpful conversion from basic ms-windows type.
87   operator tagRECT() const;
88     //!< helpful conversion to basic ms-windows type.
89 #endif
90 };
91
92 } // namespace.
93
94 #endif
95