Move Box methods and functions out of box.h and into box.C.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3302 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-01-07 14:36:10 +00:00
parent 22c088071d
commit c99b2f4819
4 changed files with 46 additions and 15 deletions

View File

@ -1,3 +1,8 @@
2002-01-07 Angus Leeming <a.leeming@ic.ac.uk>
* box.C: New file. Move the Box methods and functions out of box.h,
following Lars' suggestion.
2002-01-07 Angus Leeming <a.leeming@ic.ac.uk>
* box.h: #include "support/LOstream.h", needed for inlined function.

View File

@ -90,6 +90,7 @@ lyx_SOURCES = \
XFormsView.C \
XFormsView.h \
box.h \
box.C \
broken_headers.h \
buffer.C \
buffer.h \

33
src/box.C Normal file
View File

@ -0,0 +1,33 @@
/**
* \file box.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
// Code moved out of line and out of box.h by Angus (7 Jan 2002)
#include "box.h"
#include "support/LOstream.h"
using std::ostream;
Box::Box(int x1_, int x2_, int y1_, int y2_) :
x1(x1_), x2(x2_), y1(y1_), y2(y2_)
{}
bool Box::contained(int x, int y)
{
return (x1 < x && x2 > x &&
y1 < y && y2 > y);
}
ostream & operator<<(ostream & o, Box & b)
{
return o << "x1,y1: " << b.x1 << "," << b.y1
<< " x2,y2: " << b.x2 << "," << b.y2 << std::endl;
}

View File

@ -1,3 +1,4 @@
// -*- C++ -*-
/**
* \file box.h
* Copyright 2001 the LyX Team
@ -9,7 +10,7 @@
#ifndef BOX_H
#define BOX_H
#include "support/LOstream.h"
#include <iosfwd>
/**
* A simple class representing rectangular regions.
@ -25,27 +26,18 @@ struct Box {
int y1;
int y2;
Box(int x1_, int x2_,
int y1_, int y2_) :
x1(x1_), x2(x2_), y1(y1_), y2(y2_) {}
/// Initialise the member variables.
Box(int x1_, int x2_, int y1_, int y2_);
/**
* Returns true if the given co-ordinates are within
* the box. Check is exclusive (point on a border
* returns false).
*/
bool contained(int x, int y) {
return (x1 < x && x2 > x &&
y1 < y && y2 > y);
}
bool contained(int x, int y);
};
inline std::ostream & operator<<(std::ostream & o, Box & b)
{
return o << "x1,y1: " << b.x1 << "," << b.y1
<< " x2,y2: " << b.x2 << "," << b.y2 << std::endl;
}
std::ostream & operator<<(std::ostream &, Box &);
#endif // BOX_H