The integer type of FPoint and FRect changed from short to int
This commit is contained in:
parent
1f64843fb6
commit
f6df9585f5
|
@ -1,5 +1,6 @@
|
||||||
2018-11-21 Markus Gans <guru.mail@muenster.de>
|
2018-11-21 Markus Gans <guru.mail@muenster.de>
|
||||||
* New type FKey for key inputs
|
* New type FKey for key inputs
|
||||||
|
* The integer type of FPoint and FRect changed from short to int
|
||||||
|
|
||||||
2018-11-18 Markus Gans <guru.mail@muenster.de>
|
2018-11-18 Markus Gans <guru.mail@muenster.de>
|
||||||
* The FListViewItem class now provides checkable list view items
|
* The FListViewItem class now provides checkable list view items
|
||||||
|
|
|
@ -44,36 +44,36 @@ FPoint& FPoint::operator = (const FPoint& p)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FPoint& FPoint::operator += (const FPoint& p)
|
FPoint& FPoint::operator += (const FPoint& p)
|
||||||
{
|
{
|
||||||
xpos = short(xpos + p.xpos);
|
xpos = xpos + p.xpos;
|
||||||
ypos = short(ypos + p.ypos);
|
ypos = ypos + p.ypos;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FPoint& FPoint::operator -= (const FPoint& p)
|
FPoint& FPoint::operator -= (const FPoint& p)
|
||||||
{
|
{
|
||||||
xpos = short(xpos - p.xpos);
|
xpos = xpos - p.xpos;
|
||||||
ypos = short(ypos - p.ypos);
|
ypos = ypos - p.ypos;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FPoint::setX (int x)
|
void FPoint::setX (int x)
|
||||||
{
|
{
|
||||||
xpos = short(x);
|
xpos = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FPoint::setY (int y)
|
void FPoint::setY (int y)
|
||||||
{
|
{
|
||||||
ypos = short(y);
|
ypos = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FPoint::setPoint (int x, int y)
|
void FPoint::setPoint (int x, int y)
|
||||||
{
|
{
|
||||||
xpos = short(x);
|
xpos = x;
|
||||||
ypos = short(y);
|
ypos = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -92,7 +92,7 @@ std::ostream& operator << (std::ostream& outstr, const FPoint& p)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::istream& operator >> (std::istream& instr, FPoint& p)
|
std::istream& operator >> (std::istream& instr, FPoint& p)
|
||||||
{
|
{
|
||||||
short x, y;
|
int x, y;
|
||||||
instr >> x;
|
instr >> x;
|
||||||
instr >> y;
|
instr >> y;
|
||||||
p.setPoint (x, y);
|
p.setPoint (x, y);
|
||||||
|
|
104
src/frect.cpp
104
src/frect.cpp
|
@ -34,10 +34,10 @@ namespace finalcut
|
||||||
// constructor and destructor
|
// constructor and destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FRect::FRect (const FPoint& p1, const FPoint& p2)
|
FRect::FRect (const FPoint& p1, const FPoint& p2)
|
||||||
: X1(short(p1.getX()))
|
: X1(p1.getX())
|
||||||
, Y1(short(p1.getY()))
|
, Y1(p1.getY())
|
||||||
, X2(short(p2.getX()))
|
, X2(p2.getX())
|
||||||
, Y2(short(p2.getY()))
|
, Y2(p2.getY())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -55,82 +55,82 @@ bool FRect::isNull() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setX1 (int n)
|
void FRect::setX1 (int n)
|
||||||
{
|
{
|
||||||
X1 = short(n);
|
X1 = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setY1 (int n)
|
void FRect::setY1 (int n)
|
||||||
{
|
{
|
||||||
Y1 = short(n);
|
Y1 = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setX2 (int n)
|
void FRect::setX2 (int n)
|
||||||
{
|
{
|
||||||
X2 = short(n);
|
X2 = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setY2 (int n)
|
void FRect::setY2 (int n)
|
||||||
{
|
{
|
||||||
Y2 = short(n);
|
Y2 = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setX (int n)
|
void FRect::setX (int n)
|
||||||
{
|
{
|
||||||
short dX = short(X2 - X1);
|
int dX = X2 - X1;
|
||||||
X1 = short(n);
|
X1 = n;
|
||||||
X2 = short(X1 + dX);
|
X2 = X1 + dX;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setY (int n)
|
void FRect::setY (int n)
|
||||||
{
|
{
|
||||||
short dY = short(Y2 - Y1);
|
int dY = Y2 - Y1;
|
||||||
Y1 = short(n);
|
Y1 = n;
|
||||||
Y2 = short(Y1 + dY);
|
Y2 = Y1 + dY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setPos (int x, int y)
|
void FRect::setPos (int x, int y)
|
||||||
{
|
{
|
||||||
short dX = short(X2 - X1);
|
int dX = X2 - X1;
|
||||||
short dY = short(Y2 - Y1);
|
int dY = Y2 - Y1;
|
||||||
X1 = short(x);
|
X1 = x;
|
||||||
Y1 = short(y);
|
Y1 = y;
|
||||||
X2 = short(X1 + dX);
|
X2 = X1 + dX;
|
||||||
Y2 = short(Y1 + dY);
|
Y2 = Y1 + dY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setPos (const FPoint& p)
|
void FRect::setPos (const FPoint& p)
|
||||||
{
|
{
|
||||||
short dX = short(X2 - X1);
|
int dX = X2 - X1;
|
||||||
short dY = short(Y2 - Y1);
|
int dY = Y2 - Y1;
|
||||||
X1 = short(p.getX());
|
X1 = p.getX();
|
||||||
Y1 = short(p.getY());
|
Y1 = p.getY();
|
||||||
X2 = short(X1 + dX);
|
X2 = X1 + dX;
|
||||||
Y2 = short(Y1 + dY);
|
Y2 = Y1 + dY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setWidth (std::size_t w)
|
void FRect::setWidth (std::size_t w)
|
||||||
{
|
{
|
||||||
X2 = short(X1 + short(w) - 1);
|
X2 = X1 + int(w) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setHeight (std::size_t h)
|
void FRect::setHeight (std::size_t h)
|
||||||
{
|
{
|
||||||
Y2 = short(Y1 + short(h) - 1);
|
Y2 = Y1 + int(h) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setSize (std::size_t w, std::size_t h)
|
void FRect::setSize (std::size_t w, std::size_t h)
|
||||||
{
|
{
|
||||||
X2 = short(X1 + short(w) - 1);
|
X2 = X1 + int(w) - 1;
|
||||||
Y2 = short(Y1 + short(h) - 1);
|
Y2 = Y1 + int(h) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -145,10 +145,10 @@ void FRect::setRect (const FRect& r)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setRect (int x, int y, std::size_t width, std::size_t height)
|
void FRect::setRect (int x, int y, std::size_t width, std::size_t height)
|
||||||
{
|
{
|
||||||
X1 = short(x);
|
X1 = x;
|
||||||
Y1 = short(y);
|
Y1 = y;
|
||||||
X2 = short(x + int(width) - 1);
|
X2 = x + int(width) - 1;
|
||||||
Y2 = short(y + int(height) - 1);
|
Y2 = y + int(height) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -160,28 +160,28 @@ void FRect::setCoordinates (const FPoint& p1, const FPoint& p2)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::setCoordinates (int x1, int y1, int x2, int y2)
|
void FRect::setCoordinates (int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
X1 = short(x1);
|
X1 = x1;
|
||||||
Y1 = short(y1);
|
Y1 = y1;
|
||||||
X2 = short(x2);
|
X2 = x2;
|
||||||
Y2 = short(y2);
|
Y2 = y2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::move (int dx, int dy)
|
void FRect::move (int dx, int dy)
|
||||||
{
|
{
|
||||||
X1 = short(X1 + dx);
|
X1 = X1 + dx;
|
||||||
Y1 = short(Y1 + dy);
|
Y1 = Y1 + dy;
|
||||||
X2 = short(X2 + dx);
|
X2 = X2 + dx;
|
||||||
Y2 = short(Y2 + dy);
|
Y2 = Y2 + dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FRect::move (const FPoint& d)
|
void FRect::move (const FPoint& d)
|
||||||
{
|
{
|
||||||
X1 = short(X1 + d.getX());
|
X1 = X1 + d.getX();
|
||||||
Y1 = short(Y1 + d.getY());
|
Y1 = Y1 + d.getY();
|
||||||
X2 = short(X2 + d.getX());
|
X2 = X2 + d.getX();
|
||||||
Y2 = short(Y2 + d.getY());
|
Y2 = Y2 + d.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -239,10 +239,10 @@ FRect FRect::combined (const FRect& r) const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FRect& FRect::operator = (const FRect& r)
|
FRect& FRect::operator = (const FRect& r)
|
||||||
{
|
{
|
||||||
X1 = short(r.getX1());
|
X1 = r.getX1();
|
||||||
Y1 = short(r.getY1());
|
Y1 = r.getY1();
|
||||||
X2 = short(r.getX2());
|
X2 = r.getX2();
|
||||||
Y2 = short(r.getY2());
|
Y2 = r.getY2();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ std::ostream& operator << (std::ostream& outstr, const FRect& r)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::istream& operator >> (std::istream& instr, FRect& r)
|
std::istream& operator >> (std::istream& instr, FRect& r)
|
||||||
{
|
{
|
||||||
short x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
instr >> x1;
|
instr >> x1;
|
||||||
instr >> y1;
|
instr >> y1;
|
||||||
instr >> x2;
|
instr >> x2;
|
||||||
|
|
|
@ -333,12 +333,12 @@ void FScrollView::scrollToY (int y)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FScrollView::scrollTo (int x, int y)
|
void FScrollView::scrollTo (int x, int y)
|
||||||
{
|
{
|
||||||
short& xoffset = viewport_geometry.x1_ref();
|
int& xoffset = viewport_geometry.x1_ref();
|
||||||
short& yoffset = viewport_geometry.y1_ref();
|
int& yoffset = viewport_geometry.y1_ref();
|
||||||
short xoffset_before = xoffset;
|
int xoffset_before = xoffset;
|
||||||
short yoffset_before = yoffset;
|
int yoffset_before = yoffset;
|
||||||
short xoffset_end = short(getScrollWidth() - getViewportWidth());
|
int xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||||
short yoffset_end = short(getScrollHeight() - getViewportHeight());
|
int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||||
std::size_t save_width = viewport_geometry.getWidth();
|
std::size_t save_width = viewport_geometry.getWidth();
|
||||||
std::size_t save_height = viewport_geometry.getHeight();
|
std::size_t save_height = viewport_geometry.getHeight();
|
||||||
bool changeX = false;
|
bool changeX = false;
|
||||||
|
@ -346,11 +346,11 @@ void FScrollView::scrollTo (int x, int y)
|
||||||
x--;
|
x--;
|
||||||
y--;
|
y--;
|
||||||
|
|
||||||
if ( xoffset == short(x) && yoffset == short(y) )
|
if ( xoffset == x && yoffset == y )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xoffset = short(x);
|
xoffset = x;
|
||||||
yoffset = short(y);
|
yoffset = y;
|
||||||
|
|
||||||
if ( yoffset < 0 )
|
if ( yoffset < 0 )
|
||||||
yoffset = 0;
|
yoffset = 0;
|
||||||
|
@ -374,7 +374,7 @@ void FScrollView::scrollTo (int x, int y)
|
||||||
{
|
{
|
||||||
viewport_geometry.setWidth(save_width);
|
viewport_geometry.setWidth(save_width);
|
||||||
setLeftPadding (1 - xoffset);
|
setLeftPadding (1 - xoffset);
|
||||||
setRightPadding (1 - (xoffset_end - xoffset) + short(nf_offset));
|
setRightPadding (1 - (xoffset_end - xoffset) + int(nf_offset));
|
||||||
|
|
||||||
if ( update_scrollbar )
|
if ( update_scrollbar )
|
||||||
{
|
{
|
||||||
|
@ -440,7 +440,7 @@ void FScrollView::draw()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FScrollView::onKeyPress (FKeyEvent* ev)
|
void FScrollView::onKeyPress (FKeyEvent* ev)
|
||||||
{
|
{
|
||||||
short yoffset_end = short(getScrollHeight() - getViewportHeight());
|
int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||||
|
|
||||||
switch ( ev->key() )
|
switch ( ev->key() )
|
||||||
{
|
{
|
||||||
|
@ -492,7 +492,7 @@ void FScrollView::onKeyPress (FKeyEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FScrollView::onWheel (FWheelEvent* ev)
|
void FScrollView::onWheel (FWheelEvent* ev)
|
||||||
{
|
{
|
||||||
short distance = 4;
|
int distance = 4;
|
||||||
|
|
||||||
switch ( ev->getWheel() )
|
switch ( ev->getWheel() )
|
||||||
{
|
{
|
||||||
|
@ -694,10 +694,10 @@ void FScrollView::copy2area()
|
||||||
ac = &print_area->text[(ay + y) * a_line_len + ax];
|
ac = &print_area->text[(ay + y) * a_line_len + ax];
|
||||||
std::memcpy (ac, vc, sizeof(charData) * unsigned(x_end));
|
std::memcpy (ac, vc, sizeof(charData) * unsigned(x_end));
|
||||||
|
|
||||||
if ( short(print_area->changes[ay + y].xmin) > ax )
|
if ( int(print_area->changes[ay + y].xmin) > ax )
|
||||||
print_area->changes[ay + y].xmin = uInt(ax);
|
print_area->changes[ay + y].xmin = uInt(ax);
|
||||||
|
|
||||||
if ( short(print_area->changes[ay + y].xmax) < ax + x_end - 1 )
|
if ( int(print_area->changes[ay + y].xmax) < ax + x_end - 1 )
|
||||||
print_area->changes[ay + y].xmax = uInt(ax + x_end - 1);
|
print_area->changes[ay + y].xmax = uInt(ax + x_end - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -892,8 +892,8 @@ void FScrollView::setViewportCursor()
|
||||||
void FScrollView::cb_VBarChange (FWidget*, data_ptr)
|
void FScrollView::cb_VBarChange (FWidget*, data_ptr)
|
||||||
{
|
{
|
||||||
FScrollbar::sType scrollType = vbar->getScrollType();
|
FScrollbar::sType scrollType = vbar->getScrollType();
|
||||||
short distance = 1;
|
int distance = 1;
|
||||||
short wheel_distance = 4;
|
int wheel_distance = 4;
|
||||||
|
|
||||||
if ( scrollType >= FScrollbar::scrollStepBackward
|
if ( scrollType >= FScrollbar::scrollStepBackward
|
||||||
&& scrollType <= FScrollbar::scrollWheelDown )
|
&& scrollType <= FScrollbar::scrollWheelDown )
|
||||||
|
@ -911,21 +911,21 @@ void FScrollView::cb_VBarChange (FWidget*, data_ptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollPageBackward:
|
case FScrollbar::scrollPageBackward:
|
||||||
distance = short(getViewportHeight());
|
distance = int(getViewportHeight());
|
||||||
// fall through
|
// fall through
|
||||||
case FScrollbar::scrollStepBackward:
|
case FScrollbar::scrollStepBackward:
|
||||||
scrollBy (0, -distance);
|
scrollBy (0, -distance);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollPageForward:
|
case FScrollbar::scrollPageForward:
|
||||||
distance = short(getViewportHeight());
|
distance = int(getViewportHeight());
|
||||||
// fall through
|
// fall through
|
||||||
case FScrollbar::scrollStepForward:
|
case FScrollbar::scrollStepForward:
|
||||||
scrollBy (0, distance);
|
scrollBy (0, distance);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollJump:
|
case FScrollbar::scrollJump:
|
||||||
scrollToY (1 + short(vbar->getValue()));
|
scrollToY (1 + int(vbar->getValue()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollWheelUp:
|
case FScrollbar::scrollWheelUp:
|
||||||
|
@ -944,8 +944,8 @@ void FScrollView::cb_VBarChange (FWidget*, data_ptr)
|
||||||
void FScrollView::cb_HBarChange (FWidget*, data_ptr)
|
void FScrollView::cb_HBarChange (FWidget*, data_ptr)
|
||||||
{
|
{
|
||||||
FScrollbar::sType scrollType = hbar->getScrollType();
|
FScrollbar::sType scrollType = hbar->getScrollType();
|
||||||
short distance = 1;
|
int distance = 1;
|
||||||
short wheel_distance = 4;
|
int wheel_distance = 4;
|
||||||
|
|
||||||
if ( scrollType >= FScrollbar::scrollStepBackward
|
if ( scrollType >= FScrollbar::scrollStepBackward
|
||||||
&& scrollType <= FScrollbar::scrollWheelDown )
|
&& scrollType <= FScrollbar::scrollWheelDown )
|
||||||
|
@ -963,21 +963,21 @@ void FScrollView::cb_HBarChange (FWidget*, data_ptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollPageBackward:
|
case FScrollbar::scrollPageBackward:
|
||||||
distance = short(getViewportWidth());
|
distance = int(getViewportWidth());
|
||||||
// fall through
|
// fall through
|
||||||
case FScrollbar::scrollStepBackward:
|
case FScrollbar::scrollStepBackward:
|
||||||
scrollBy (-distance, 0);
|
scrollBy (-distance, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollPageForward:
|
case FScrollbar::scrollPageForward:
|
||||||
distance = short(getViewportWidth());
|
distance = int(getViewportWidth());
|
||||||
// fall through
|
// fall through
|
||||||
case FScrollbar::scrollStepForward:
|
case FScrollbar::scrollStepForward:
|
||||||
scrollBy (distance, 0);
|
scrollBy (distance, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollJump:
|
case FScrollbar::scrollJump:
|
||||||
scrollToX (1 + short(hbar->getValue()));
|
scrollToX (1 + int(hbar->getValue()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FScrollbar::scrollWheelUp:
|
case FScrollbar::scrollWheelUp:
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "final/ftypes.h"
|
||||||
|
|
||||||
namespace finalcut
|
namespace finalcut
|
||||||
{
|
{
|
||||||
|
@ -83,13 +84,13 @@ class FPoint
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
|
|
||||||
// Point references
|
// Point references
|
||||||
short& x_ref();
|
int& x_ref();
|
||||||
short& y_ref();
|
int& y_ref();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data Members
|
// Data Members
|
||||||
short xpos;
|
int xpos;
|
||||||
short ypos;
|
int ypos;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
@ -109,8 +110,8 @@ inline FPoint::FPoint (const FPoint& p) // copy constructor
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FPoint::FPoint (int x, int y)
|
inline FPoint::FPoint (int x, int y)
|
||||||
: xpos(short(x))
|
: xpos(x)
|
||||||
, ypos(short(y))
|
, ypos(y)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -146,11 +147,11 @@ inline int FPoint::getY() const
|
||||||
{ return ypos; }
|
{ return ypos; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline short& FPoint::x_ref()
|
inline int& FPoint::x_ref()
|
||||||
{ return xpos; }
|
{ return xpos; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline short& FPoint::y_ref()
|
inline int& FPoint::y_ref()
|
||||||
{ return ypos; }
|
{ return ypos; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -107,10 +107,10 @@ class FRect
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
|
|
||||||
// Coordinate references
|
// Coordinate references
|
||||||
short& x1_ref();
|
int& x1_ref();
|
||||||
short& y1_ref();
|
int& y1_ref();
|
||||||
short& x2_ref();
|
int& x2_ref();
|
||||||
short& y2_ref();
|
int& y2_ref();
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void move (int, int);
|
void move (int, int);
|
||||||
|
@ -124,10 +124,10 @@ class FRect
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data Members
|
// Data Members
|
||||||
short X1;
|
int X1;
|
||||||
short Y1;
|
int Y1;
|
||||||
short X2;
|
int X2;
|
||||||
short Y2;
|
int Y2;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
@ -151,10 +151,10 @@ inline FRect::FRect (const FRect& r) // copy constructor
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FRect::FRect (int x, int y, std::size_t width, std::size_t height)
|
inline FRect::FRect (int x, int y, std::size_t width, std::size_t height)
|
||||||
: X1(short(x))
|
: X1(x)
|
||||||
, Y1(short(y))
|
, Y1(y)
|
||||||
, X2(short(x + short(width) - 1))
|
, X2(x + int(width) - 1)
|
||||||
, Y2(short(y + short(height) - 1))
|
, Y2(y + int(height) - 1)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -208,31 +208,31 @@ inline FPoint FRect::getLowerRightPos() const
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline std::size_t FRect::getWidth() const
|
inline std::size_t FRect::getWidth() const
|
||||||
{
|
{
|
||||||
short w = X2 - X1 + 1;
|
int w = X2 - X1 + 1;
|
||||||
return ( w < 0 ) ? 0 : std::size_t(w);
|
return ( w < 0 ) ? 0 : std::size_t(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline std::size_t FRect::getHeight() const
|
inline std::size_t FRect::getHeight() const
|
||||||
{
|
{
|
||||||
short h = Y2 - Y1 + 1;
|
int h = Y2 - Y1 + 1;
|
||||||
return ( h < 0 ) ? 0 : std::size_t(h);
|
return ( h < 0 ) ? 0 : std::size_t(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline short& FRect::x1_ref()
|
inline int& FRect::x1_ref()
|
||||||
{ return X1; }
|
{ return X1; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline short& FRect::y1_ref()
|
inline int& FRect::y1_ref()
|
||||||
{ return Y1; }
|
{ return Y1; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline short& FRect::x2_ref()
|
inline int& FRect::x2_ref()
|
||||||
{ return X2; }
|
{ return X2; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline short& FRect::y2_ref()
|
inline int& FRect::y2_ref()
|
||||||
{ return Y2; }
|
{ return Y2; }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include <cppunit/BriefTestProgressListener.h>
|
#include <cppunit/BriefTestProgressListener.h>
|
||||||
#include <cppunit/CompilerOutputter.h>
|
#include <cppunit/CompilerOutputter.h>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
@ -136,10 +138,11 @@ void FPointTest::assignmentTest()
|
||||||
CPPUNIT_ASSERT ( p2.getX() == 40 );
|
CPPUNIT_ASSERT ( p2.getX() == 40 );
|
||||||
CPPUNIT_ASSERT ( p2.getY() == 12 );
|
CPPUNIT_ASSERT ( p2.getY() == 12 );
|
||||||
|
|
||||||
// Value limit exceeded
|
// Value limit
|
||||||
const finalcut::FPoint p3 (-999999,1000000);
|
const finalcut::FPoint p3 ( std::numeric_limits<int>::min()
|
||||||
CPPUNIT_ASSERT ( p3.getX() != -999999 );
|
, std::numeric_limits<int>::max() );
|
||||||
CPPUNIT_ASSERT ( p3.getY() != 1000000 );
|
CPPUNIT_ASSERT ( p3.getX() == std::numeric_limits<int>::min() );
|
||||||
|
CPPUNIT_ASSERT ( p3.getY() == std::numeric_limits<int>::max() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -155,13 +158,15 @@ void FPointTest::additionAssignmentTest()
|
||||||
CPPUNIT_ASSERT ( p1.getY() == 0 );
|
CPPUNIT_ASSERT ( p1.getY() == 0 );
|
||||||
CPPUNIT_ASSERT ( p1.isNull() );
|
CPPUNIT_ASSERT ( p1.isNull() );
|
||||||
|
|
||||||
// Value limit exceeded
|
// Value limit
|
||||||
finalcut::FPoint p2 (18000,-18000);
|
finalcut::FPoint p2 ( std::numeric_limits<int>::max()
|
||||||
CPPUNIT_ASSERT ( p2.getX() == 18000 );
|
, std::numeric_limits<int>::min() );
|
||||||
CPPUNIT_ASSERT ( p2.getY() == -18000 );
|
CPPUNIT_ASSERT ( p2.getX() == std::numeric_limits<int>::max() );
|
||||||
p2 += finalcut::FPoint (18000,-18000);
|
CPPUNIT_ASSERT ( p2.getY() == std::numeric_limits<int>::min() );
|
||||||
CPPUNIT_ASSERT ( p2.getX() != 36000 );
|
p2 += finalcut::FPoint ( -std::numeric_limits<int>::max()
|
||||||
CPPUNIT_ASSERT ( p2.getY() != -36000 );
|
, -std::numeric_limits<int>::min() );
|
||||||
|
CPPUNIT_ASSERT ( p2.getX() == 0 );
|
||||||
|
CPPUNIT_ASSERT ( p2.getY() == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -202,13 +207,15 @@ void FPointTest::subtractionAssignmentTest()
|
||||||
CPPUNIT_ASSERT ( p1.getY() == 0 );
|
CPPUNIT_ASSERT ( p1.getY() == 0 );
|
||||||
CPPUNIT_ASSERT ( p1.isNull() );
|
CPPUNIT_ASSERT ( p1.isNull() );
|
||||||
|
|
||||||
// Value limit exceeded
|
// Value limit
|
||||||
finalcut::FPoint p2 (18000,-18000);
|
finalcut::FPoint p2 ( std::numeric_limits<int>::max()
|
||||||
CPPUNIT_ASSERT ( p2.getX() == 18000 );
|
, std::numeric_limits<int>::min() );
|
||||||
CPPUNIT_ASSERT ( p2.getY() == -18000 );
|
CPPUNIT_ASSERT ( p2.getX() == std::numeric_limits<int>::max() );
|
||||||
p2 += finalcut::FPoint (18000,-18000);
|
CPPUNIT_ASSERT ( p2.getY() == std::numeric_limits<int>::min() );
|
||||||
CPPUNIT_ASSERT ( p2.getX() != 36000 );
|
p2 -= finalcut::FPoint ( std::numeric_limits<int>::max(),
|
||||||
CPPUNIT_ASSERT ( p2.getY() != -36000 );
|
std::numeric_limits<int>::min() );
|
||||||
|
CPPUNIT_ASSERT ( p2.getX() == 0 );
|
||||||
|
CPPUNIT_ASSERT ( p2.getY() == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -276,8 +283,8 @@ void FPointTest::referenceTest()
|
||||||
CPPUNIT_ASSERT ( p1.getX() == 2 );
|
CPPUNIT_ASSERT ( p1.getX() == 2 );
|
||||||
CPPUNIT_ASSERT ( p1.getY() == 2 );
|
CPPUNIT_ASSERT ( p1.getY() == 2 );
|
||||||
|
|
||||||
short& x = p1.x_ref();
|
int& x = p1.x_ref();
|
||||||
short& y = p1.y_ref();
|
int& y = p1.y_ref();
|
||||||
x += 4;
|
x += 4;
|
||||||
y += 2;
|
y += 2;
|
||||||
CPPUNIT_ASSERT ( p1.getX() == 6 );
|
CPPUNIT_ASSERT ( p1.getX() == 6 );
|
||||||
|
|
|
@ -363,10 +363,10 @@ void FRectTest::referenceTest()
|
||||||
CPPUNIT_ASSERT ( r1.getX2() == 9 );
|
CPPUNIT_ASSERT ( r1.getX2() == 9 );
|
||||||
CPPUNIT_ASSERT ( r1.getY2() == 19 );
|
CPPUNIT_ASSERT ( r1.getY2() == 19 );
|
||||||
|
|
||||||
short& x1 = r1.x1_ref();
|
int& x1 = r1.x1_ref();
|
||||||
short& y1 = r1.y1_ref();
|
int& y1 = r1.y1_ref();
|
||||||
short& x2 = r1.x2_ref();
|
int& x2 = r1.x2_ref();
|
||||||
short& y2 = r1.y2_ref();
|
int& y2 = r1.y2_ref();
|
||||||
x1 += 2;
|
x1 += 2;
|
||||||
y1 -= 2;
|
y1 -= 2;
|
||||||
x2 -= 3;
|
x2 -= 3;
|
||||||
|
|
Loading…
Reference in New Issue