FLTK
Fl_Rect.H
1 //
2 // Fl_Rect header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2018 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
17 #ifndef Fl_Rect_H
18 #define Fl_Rect_H
19 
20 #include <FL/Fl_Widget.H> // for c'tor based on Fl_Widget
21 
30 class FL_EXPORT Fl_Rect {
31 
32  int x_;
33  int y_;
34  int w_;
35  int h_;
36 
37 public:
38 
41  : x_(0), y_(0), w_(0), h_(0) {}
42 
45  Fl_Rect(int W, int H)
46  : x_(0), y_(0), w_(W), h_(H) {}
47 
50  Fl_Rect(int X, int Y, int W, int H)
51  : x_(X), y_(Y), w_(W), h_(H) {}
52 
54  Fl_Rect (const Fl_Widget& widget)
55  : x_(widget.x()), y_(widget.y()), w_(widget.w()), h_(widget.h()) {}
56 
58  Fl_Rect (const Fl_Widget* const widget)
59  : x_(widget->x()), y_(widget->y()), w_(widget->w()), h_(widget->h()) {}
60 
61  int x() const { return x_; }
62  int y() const { return y_; }
63  int w() const { return w_; }
64  int h() const { return h_; }
65 
69  int r() const { return x_ + w_; }
73  int b() const { return y_ + h_; }
74 
75  void x(int X) { x_ = X; }
76  void y(int Y) { y_ = Y; }
77  void w(int W) { w_ = W; }
78  void h(int H) { h_ = H; }
79 
80 }; // class Fl_Rect
81 
82 #endif // Fl_Rect_H
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
void w(int W)
sets the width
Definition: Fl_Rect.H:77
int r() const
gets the right edge (x + w).
Definition: Fl_Rect.H:69
Fl_Rect()
The default constructor creates an empty rectangle (x = y = w = h = 0).
Definition: Fl_Rect.H:40
int y() const
gets the y coordinate (top edge)
Definition: Fl_Rect.H:62
int w() const
gets the width
Definition: Fl_Rect.H:63
void y(int Y)
sets the y coordinate (top edge)
Definition: Fl_Rect.H:76
void h(int H)
sets the height
Definition: Fl_Rect.H:78
Fl_Rect(const Fl_Widget &widget)
This constructor creates a rectangle based on a widget&#39;s position and size.
Definition: Fl_Rect.H:54
Fl_Widget, Fl_Label classes .
void x(int X)
sets the x coordinate (left edge)
Definition: Fl_Rect.H:75
Fl_Rect(int X, int Y, int W, int H)
This constructor creates a rectangle with the given x,y coordinates and the given width and height...
Definition: Fl_Rect.H:50
int b() const
gets the bottom edge (y + h).
Definition: Fl_Rect.H:73
Rectangle with standard FLTK coordinates (X, Y, W, H).
Definition: Fl_Rect.H:30
Fl_Rect(int W, int H)
This constructor creates a rectangle with x = y = 0 and the given width and height.
Definition: Fl_Rect.H:45
Fl_Rect(const Fl_Widget *const widget)
This constructor creates a rectangle based on a widget&#39;s position and size.
Definition: Fl_Rect.H:58
int h() const
gets the height
Definition: Fl_Rect.H:64
int x() const
gets the x coordinate (left edge)
Definition: Fl_Rect.H:61