Move Point/Size/Rect classes to a new gfx-lib.

This commit is contained in:
David Capello 2010-09-25 16:22:32 -03:00
parent 51fbcae936
commit 28d09af036
62 changed files with 1015 additions and 1260 deletions

View File

@ -20,7 +20,7 @@ endif(MSVC)
set(libs3rdparty freetype jpeg libart_lgpl libpng loadpng tinyxml vaca zlib)
# All libraries for .exe files
set(all_libs base-lib aseprite-library alleg ${libs3rdparty} ${sys_libs})
set(all_libs base-lib gfx-lib aseprite-library alleg ${libs3rdparty} ${sys_libs})
# Directories where .h files can be found
include_directories(
@ -37,6 +37,7 @@ include_directories(
# Sub-libraries
add_subdirectory(base)
add_subdirectory(gfx)
######################################################################
# aseprite library

View File

@ -20,13 +20,13 @@
#include <allegro.h>
#include "jinete/jinete.h"
#include "Vaca/Bind.h"
#include "Vaca/Size.h"
#include "jinete/jinete.h"
#include "app.h"
#include "commands/command.h"
#include "commands/commands.h"
#include "gfx/size.h"
#include "modules/editors.h"
#include "modules/gfx.h"
#include "modules/gui.h"
@ -37,14 +37,14 @@
#include "raster/sprite.h"
#include "settings/settings.h"
#include "sprite_wrappers.h"
#include "ui_context.h"
#include "tools/tool.h"
#include "ui_context.h"
#include "widgets/color_button.h"
#include "widgets/editor.h"
#include "widgets/groupbut.h"
#include "widgets/statebar.h"
using Vaca::Size;
using namespace gfx;
static Frame* window = NULL;

View File

@ -31,6 +31,8 @@
#include "widgets/statebar.h"
#include "ui_context.h"
using namespace gfx;
//////////////////////////////////////////////////////////////////////
// show_grid

View File

@ -24,33 +24,33 @@
#include <vector>
#include "Vaca/Bind.h"
#include "Vaca/Size.h"
#include "jinete/jinete.h"
#include "app.h"
#include "app/color.h"
#include "commands/command.h"
#include "commands/params.h"
#include "core/cfg.h"
#include "app/color.h"
#include "dialogs/filesel.h"
#include "modules/gui.h"
#include "gfx/size.h"
#include "modules/editors.h"
#include "modules/gui.h"
#include "modules/palettes.h"
#include "raster/image.h"
#include "raster/palette.h"
#include "raster/sprite.h"
#include "raster/stock.h"
#include "raster/undo.h"
#include "sprite_wrappers.h"
#include "ui_context.h"
#include "util/quantize.h"
#include "widgets/color_bar.h"
#include "widgets/colview.h"
#include "widgets/editor.h"
#include "widgets/paledit.h"
#include "widgets/statebar.h"
#include "sprite_wrappers.h"
#include "ui_context.h"
using Vaca::Size;
using namespace gfx;
static Frame* window = NULL;
static int redraw_timer_id = -1;

View File

@ -27,6 +27,8 @@
#include "core/cfg.h"
#include "resource_finder.h"
using namespace gfx;
static char config_filename[512];
ConfigModule::ConfigModule()

View File

@ -20,11 +20,9 @@
#define CORE_CFG_H_INCLUDED
#include <allegro/config.h>
#include "Vaca/Rect.h"
#include "gfx/rect.h"
#include "app/color.h"
using Vaca::Rect;
class ConfigModule
{
public:
@ -35,8 +33,8 @@ public:
bool get_config_bool(const char *section, const char *name, bool value);
void set_config_bool(const char *section, const char *name, bool value);
Rect get_config_rect(const char *section, const char *name, const Rect& rect);
void set_config_rect(const char *section, const char *name, const Rect& rect);
gfx::Rect get_config_rect(const char *section, const char *name, const gfx::Rect& rect);
void set_config_rect(const char *section, const char *name, const gfx::Rect& rect);
Color get_config_color(const char *section, const char *name, const Color& value);
void set_config_color(const char *section, const char *name, const Color& value);

View File

@ -22,8 +22,8 @@
#include "jinete/jinete.h"
#include "Vaca/Rect.h"
#include "Vaca/Point.h"
#include "gfx/rect.h"
#include "gfx/point.h"
#include "commands/commands.h"
#include "commands/command.h"
@ -38,8 +38,7 @@
#include "sprite_wrappers.h"
#include "ui_context.h"
using Vaca::Rect;
using Vaca::Point;
using namespace gfx;
/*
Animator Editor

7
src/gfx/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
# ASE - Allegro Sprite Editor
# Copyright (C) 2001-2010 David Capello
add_library(gfx-lib
point.cpp
rect.cpp
size.cpp)

29
src/gfx/LICENSE.txt Normal file
View File

@ -0,0 +1,29 @@
ASE gfx library
Copyright (c) 2001-2010 David Capello
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

157
src/gfx/point.cpp Normal file
View File

@ -0,0 +1,157 @@
// ASE base library
// Copyright (C) 2001-2010 David Capello
//
// This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information.
#include "gfx/point.h"
#include "gfx/size.h"
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
using namespace gfx;
Point::Point()
{
x = 0;
y = 0;
}
Point::Point(int x, int y)
{
this->x = x;
this->y = y;
}
Point::Point(const Point& point)
{
x = point.x;
y = point.y;
}
Point::Point(const Size& size)
{
x = size.w;
y = size.h;
}
const Point& Point::operator=(const Point& pt)
{
x = pt.x;
y = pt.y;
return *this;
}
const Point& Point::operator+=(const Point& pt)
{
x += pt.x;
y += pt.y;
return *this;
}
const Point& Point::operator-=(const Point& pt)
{
x -= pt.x;
y -= pt.y;
return *this;
}
const Point& Point::operator+=(int value)
{
x += value;
y += value;
return *this;
}
const Point& Point::operator-=(int value)
{
x -= value;
y -= value;
return *this;
}
const Point& Point::operator*=(int value)
{
x *= value;
y *= value;
return *this;
}
const Point& Point::operator/=(int value)
{
x /= value;
y /= value;
return *this;
}
Point Point::operator+(const Point& pt) const
{
return Point(x+pt.x, y+pt.y);
}
Point Point::operator-(const Point& pt) const
{
return Point(x-pt.x, y-pt.y);
}
Point Point::operator+(int value) const
{
return Point(x+value, y+value);
}
Point Point::operator-(int value) const
{
return Point(x-value, y-value);
}
Point Point::operator*(int value) const
{
return Point(x*value, y*value);
}
Point Point::operator/(int value) const
{
return Point(x/value, y/value);
}
Point Point::operator-() const
{
return Point(-x, -y);
}
bool Point::operator==(const Point& pt) const
{
return x == pt.x && y == pt.y;
}
bool Point::operator!=(const Point& pt) const
{
return x != pt.x || y != pt.y;
}
#ifdef WIN32
Point::Point(const tagPOINT* pt)
{
x = pt->x;
y = pt->y;
}
Point::Point(const tagPOINTS* pt)
{
x = pt->x;
y = pt->y;
}
Point::operator tagPOINT() const
{
POINT pt;
pt.x = x;
pt.y = y;
return pt;
}
#endif

58
src/gfx/point.h Normal file
View File

@ -0,0 +1,58 @@
// ASE gfx library
// Copyright (C) 2001-2010 David Capello
//
// This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information.
#ifndef GFX_POINT_H_INCLUDED
#define GFX_POINT_H_INCLUDED
#ifdef WIN32
struct tagPOINT;
struct tagPOINTS;
#endif
namespace gfx {
class Size;
class Point // A 2D coordinate in the screen.
{
public:
int x, y;
Point();
Point(int x, int y);
Point(const Point& point);
explicit Point(const Size& size);
const Point& operator=(const Point& pt);
const Point& operator+=(const Point& pt);
const Point& operator-=(const Point& pt);
const Point& operator+=(int value);
const Point& operator-=(int value);
const Point& operator*=(int value);
const Point& operator/=(int value);
Point operator+(const Point& pt) const;
Point operator-(const Point& pt) const;
Point operator+(int value) const;
Point operator-(int value) const;
Point operator*(int value) const;
Point operator/(int value) const;
Point operator-() const;
bool operator==(const Point& pt) const;
bool operator!=(const Point& pt) const;
#ifdef WIN32
explicit Point(const tagPOINT* pt);
explicit Point(const tagPOINTS* pt);
operator tagPOINT() const;
#endif
};
} // namespace gfx
#endif

260
src/gfx/rect.cpp Normal file
View File

@ -0,0 +1,260 @@
// ASE gfx library
// Copyright (C) 2001-2010 David Capello
//
// This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information.
#include "gfx/rect.h"
#include "gfx/point.h"
#include "gfx/size.h"
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
using namespace gfx;
Rect::Rect()
{
x = 0;
y = 0;
w = 0;
h = 0;
}
Rect::Rect(int w, int h)
{
this->x = 0;
this->y = 0;
this->w = w;
this->h = h;
}
Rect::Rect(const Size& size)
{
x = 0;
y = 0;
w = size.w;
h = size.h;
}
Rect::Rect(const Rect& rect)
{
x = rect.x;
y = rect.y;
w = rect.w;
h = rect.h;
}
Rect::Rect(const Point& point, const Size& size)
{
this->x = point.x;
this->y = point.y;
this->w = size.w;
this->h = size.h;
}
Rect::Rect(const Point& point1, const Point& point2)
{
Point leftTop = point1;
Point rightBottom = point2;
register int t;
if (leftTop.x > rightBottom.x) {
t = leftTop.x;
leftTop.x = rightBottom.x;
rightBottom.x = t;
}
if (leftTop.y > rightBottom.y) {
t = leftTop.y;
leftTop.y = rightBottom.y;
rightBottom.y = t;
}
this->x = leftTop.x;
this->y = leftTop.y;
this->w = rightBottom.x - leftTop.x;
this->h = rightBottom.y - leftTop.y;
}
Rect::Rect(int x, int y, int w, int h)
{
this->x = x;
this->y = y;
this->w = w;
this->h = h;
}
bool Rect::isEmpty() const
{
return (w < 1 || h < 1);
}
Point Rect::getCenter() const
{
return Point(x+w/2, y+h/2);
}
Point Rect::getOrigin() const
{
return Point(x, y);
}
Point Rect::getPoint2() const
{
return Point(x+w, y+h);
}
Size Rect::getSize() const
{
return Size(w, h);
}
Rect& Rect::setOrigin(const Point& pt)
{
x = pt.x;
y = pt.y;
return *this;
}
Rect& Rect::setSize(const Size& sz)
{
w = sz.w;
h = sz.h;
return *this;
}
Rect& Rect::offset(int dx, int dy)
{
x += dx;
y += dy;
return *this;
}
Rect& Rect::offset(const Point& delta)
{
x += delta.x;
y += delta.y;
return *this;
}
Rect& Rect::inflate(int dw, int dh)
{
w += dw;
h += dh;
return *this;
}
Rect& Rect::inflate(const Size& delta)
{
w += delta.w;
h += delta.h;
return *this;
}
Rect& Rect::enlarge(int unit)
{
x -= unit;
y -= unit;
w += unit<<1;
h += unit<<1;
return *this;
}
Rect& Rect::shrink(int unit)
{
x += unit;
y += unit;
w -= unit<<1;
h -= unit<<1;
return *this;
}
bool Rect::contains(const Point& pt) const
{
return
pt.x >= x && pt.x < x+w &&
pt.y >= y && pt.y < y+h;
}
bool Rect::contains(const Rect& rc) const
{
if (isEmpty() || rc.isEmpty())
return false;
return
rc.x >= x && rc.x+rc.w <= x+w &&
rc.y >= y && rc.y+rc.h <= y+h;
}
bool Rect::intersects(const Rect& rc) const
{
if (isEmpty() || rc.isEmpty())
return false;
return
rc.x <= x+w && rc.x+rc.w > x &&
rc.y <= y+h && rc.y+rc.h > y;
}
Rect Rect::createUnion(const Rect& rc) const
{
if (isEmpty())
return rc;
else if (rc.isEmpty())
return *this;
else
return Rect(Point(x < rc.x ? x: rc.x,
y < rc.y ? y: rc.y),
Point(x+w > rc.x+rc.w ? x+w: rc.x+rc.w,
y+h > rc.y+rc.h ? y+h: rc.y+rc.h));
}
Rect Rect::createIntersect(const Rect& rc) const
{
if (intersects(rc))
return Rect(Point(x > rc.x ? x: rc.x,
y > rc.y ? y: rc.y),
Point(x+w < rc.x+rc.w ? x+w: rc.x+rc.w,
y+h < rc.y+rc.h ? y+h: rc.y+rc.h));
else
return Rect();
}
bool Rect::operator==(const Rect& rc) const
{
return
x == rc.x && w == rc.w &&
y == rc.y && h == rc.h;
}
bool Rect::operator!=(const Rect& rc) const
{
return
x != rc.x || w != rc.w ||
y != rc.y || h != rc.h;
}
#ifdef WIN32
Rect::Rect(const tagRECT* rc)
{
x = rc->left;
y = rc->top;
w = rc->right - rc->left;
h = rc->bottom - rc->top;
}
Rect::operator tagRECT() const
{
tagRECT rc;
rc.left = x;
rc.top = y;
rc.right = x+w;
rc.bottom = y+h;
return rc;
}
#endif

113
src/gfx/rect.h Normal file
View File

@ -0,0 +1,113 @@
// ASE gfx library
// Copyright (C) 2001-2010 David Capello
//
// This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information.
#ifndef GFX_RECT_H_INCLUDED
#define GFX_RECT_H_INCLUDED
#ifdef WIN32
struct tagRECT;
#endif
namespace gfx {
class Point;
class Size;
class Rect // A rectangle.
{
public:
int x, y, w, h;
// Creates a new empty rectangle with the origin in 0,0.
Rect();
// Creates a new rectangle with the specified size with the origin in 0,0.
Rect(int w, int h);
// Creates a new rectangle with the specified size with the origin in 0,0.
explicit Rect(const Size& size);
Rect(const Rect& rect);
Rect(const Point& point, const Size& size);
// Creates a new rectangle with the origin in point1 and size
// equal to point2-point1.
//
// If a coordinate of point1 is greater than point2, the coordinates
// are swapped. The resulting rectangle will be:
//
// x = min(point1.x, point2.x)
// y = min(point1.y, point2.y)
// w = max(point1.x, point2.x) - x
// h = max(point1.x, point2.x) - y
//
// See that point2 isn't included in the rectangle, it's like the
// point returned by getPoint2() member function.
Rect(const Point& point1, const Point& point2);
Rect(int x, int y, int w, int h);
// Verifies if the width and/or height of the rectangle are less or
// equal than zero.
bool isEmpty() const;
// Returns the middle point of the rectangle (x+w/2, y+h/2).
Point getCenter() const;
// Returns the point in the upper-left corner (that is inside the
// rectangle).
Point getOrigin() const;
// Returns point in the lower-right corner that is outside the
// rectangle (x+w, y+h).
Point getPoint2() const;
Size getSize() const;
Rect& setOrigin(const Point& pt);
Rect& setSize(const Size& sz);
// Moves the rectangle origin in the specified delta.
Rect& offset(int dx, int dy);
Rect& offset(const Point& delta);
Rect& inflate(int dw, int dh);
Rect& inflate(const Size& delta);
Rect& enlarge(int unit);
Rect& shrink(int unit);
// Returns true if this rectangle encloses the pt point.
bool contains(const Point& pt) const;
// Returns true if this rectangle entirely contains the rc rectangle.
bool contains(const Rect& rc) const;
// Returns true if the intersection between this rectangle with rc
// rectangle is not empty.
bool intersects(const Rect& rc) const;
// Returns the union rectangle between this and rc rectangle.
Rect createUnion(const Rect& rc) const;
// Returns the intersection rectangle between this and rc rectangles.
Rect createIntersect(const Rect& rc) const;
bool operator==(const Rect& rc) const;
bool operator!=(const Rect& rc) const;
#ifdef WIN32
explicit Rect(const tagRECT* rc);
operator tagRECT() const;
#endif
};
} // namespace gfx
#endif

167
src/gfx/size.cpp Normal file
View File

@ -0,0 +1,167 @@
// ASE gfx library
// Copyright (C) 2001-2010 David Capello
//
// This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information.
#include "gfx/size.h"
#include "gfx/point.h"
#include <algorithm>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef max
#undef min
#endif
using namespace gfx;
Size::Size()
{
w = 0;
h = 0;
}
Size::Size(int w, int h)
{
this->w = w;
this->h = h;
}
Size::Size(const Size& size)
{
w = size.w;
h = size.h;
}
Size::Size(const Point& point)
{
w = point.x;
h = point.y;
}
Size Size::createUnion(const Size& sz) const
{
return Size(std::max(w, sz.w),
std::max(h, sz.h));
}
Size Size::createIntersect(const Size& sz) const
{
return Size(std::min(w, sz.w),
std::min(h, sz.h));
}
const Size& Size::operator=(const Size& sz)
{
w = sz.w;
h = sz.h;
return *this;
}
const Size& Size::operator+=(const Size& sz)
{
w += sz.w;
h += sz.h;
return *this;
}
const Size& Size::operator-=(const Size& sz)
{
w -= sz.w;
h -= sz.h;
return *this;
}
const Size& Size::operator+=(int value)
{
w += value;
h += value;
return *this;
}
const Size& Size::operator-=(int value)
{
w -= value;
h -= value;
return *this;
}
const Size& Size::operator*=(int value)
{
w *= value;
h *= value;
return *this;
}
const Size& Size::operator/=(int value)
{
w /= value;
h /= value;
return *this;
}
Size Size::operator+(const Size& sz) const
{
return Size(w+sz.w, h+sz.h);
}
Size Size::operator-(const Size& sz) const
{
return Size(w-sz.w, h-sz.h);
}
Size Size::operator+(int value) const
{
return Size(w+value, h+value);
}
Size Size::operator-(int value) const
{
return Size(w-value, h-value);
}
Size Size::operator*(int value) const
{
return Size(w*value, h*value);
}
Size Size::operator/(int value) const
{
return Size(w/value, h/value);
}
Size Size::operator-() const
{
return Size(-w, -h);
}
bool Size::operator==(const Size& sz) const
{
return w == sz.w && h == sz.h;
}
bool Size::operator!=(const Size& sz) const
{
return w != sz.w || h != sz.h;
}
#ifdef WIN32
Size::Size(const tagSIZE* sz)
{
w = sz->cx;
h = sz->cy;
}
Size::operator tagSIZE() const
{
tagSIZE sz;
sz.cx = w;
sz.cy = h;
return sz;
}
#endif

59
src/gfx/size.h Normal file
View File

@ -0,0 +1,59 @@
// ASE gfx library
// Copyright (C) 2001-2010 David Capello
//
// This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information.
#ifndef GFX_SIZE_H_INCLUDED
#define GFX_SIZE_H_INCLUDED
#ifdef WIN32
struct tagSIZE;
#endif
namespace gfx {
class Point;
class Size // A 2D size.
{
public:
int w, h;
Size();
Size(int w, int h);
Size(const Size& size);
explicit Size(const Point& point);
Size createUnion(const Size& sz) const;
Size createIntersect(const Size& sz) const;
const Size& operator=(const Size& sz);
const Size& operator+=(const Size& sz);
const Size& operator-=(const Size& sz);
const Size& operator+=(int value);
const Size& operator-=(int value);
const Size& operator*=(int value);
const Size& operator/=(int value);
Size operator+(const Size& sz) const;
Size operator-(const Size& sz) const;
Size operator+(int value) const;
Size operator-(int value) const;
Size operator*(int value) const;
Size operator/(int value) const;
Size operator-() const;
bool operator==(const Size& sz) const;
bool operator!=(const Size& sz) const;
#ifdef WIN32
explicit Size(const tagSIZE* sz);
operator tagSIZE() const;
#endif
};
} // namespace gfx
#endif

View File

@ -38,7 +38,9 @@
#include "jinete/jrect.h"
#include "jinete/jwidget.h"
#include "jinete/jtheme.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
using namespace gfx;
static bool box_msg_proc(JWidget widget, JMessage msg);
static void box_request_size(JWidget widget, int *w, int *h);

View File

@ -34,9 +34,11 @@
#include <allegro.h>
#include "jinete/jinete.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#include "Vaca/PreferredSizeEvent.h"
using namespace gfx;
struct ComboBox::Item
{
std::string text;

View File

@ -43,6 +43,8 @@
#include "jinete/jsystem.h"
#include "jinete/jwidget.h"
using namespace gfx;
/* TODO optional anti-aliased textout */
#define SETUP_ANTIALISING(f, bg, fill_bg) \
ji_font_set_aa_mode(f, fill_bg || \

View File

@ -34,8 +34,7 @@
#include "jinete/jbase.h"
namespace Vaca { class Rect; }
using Vaca::Rect;
namespace gfx { class Rect; }
#define JI_COLOR_SHADE(color, r, g, b) \
makecol(MID(0, getr(color)+(r), 255), \
@ -59,7 +58,7 @@ void jrectshade(struct BITMAP *bmp, int x1, int y1, int x2, int y2,
void jdraw_rect(const JRect rect, int color);
void jdraw_rectfill(const JRect rect, int color);
void jdraw_rectfill(const Rect& rect, int color);
void jdraw_rectfill(const gfx::Rect& rect, int color);
void jdraw_rectedge(const JRect rect, int c1, int c2);
void jdraw_rectshade(const JRect rect, int c1, int c2, int align);
void jdraw_rectexclude(const JRect rc, const JRect exclude, int color);

View File

@ -40,7 +40,9 @@
#include "jinete/jrect.h"
#include "jinete/jwidget.h"
#include "jinete/jtheme.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
using namespace gfx;
struct Cell
{

View File

@ -18,9 +18,9 @@
#define TEST_GUI
#include "tests/test.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
using Vaca::Size;
using namespace gfx;
/**
* Tests two widgets in a row, each one of 10x10 pixels.

View File

@ -41,7 +41,9 @@
#include "jinete/jtheme.h"
#include "jinete/jview.h"
#include "jinete/jwidget.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
using namespace gfx;
static bool listbox_msg_proc(JWidget widget, JMessage msg);
static void listbox_request_size(JWidget widget, int *w, int *h);

View File

@ -37,10 +37,12 @@
#include "jinete/jinete.h"
#include "jinete/jintern.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#define TIMEOUT_TO_OPEN_SUBMENU 250
using namespace gfx;
//////////////////////////////////////////////////////////////////////
// Internal messages: to move between menus

View File

@ -37,13 +37,15 @@
#include "jinete/jsystem.h"
#include "jinete/jtheme.h"
#include "jinete/jwidget.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
typedef struct Panel
{
double pos;
} Panel;
using namespace gfx;
static bool panel_msg_proc(JWidget widget, JMessage msg);
static void panel_request_size(JWidget widget, int *w, int *h);
static void panel_set_position(JWidget widget, JRect rect);

View File

@ -35,9 +35,11 @@
#include "jinete/jinete.h"
#include "jinete/jintern.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#include "Vaca/PreferredSizeEvent.h"
using namespace gfx;
PopupWindow::PopupWindow(const char* text, bool close_on_buttonpressed)
: Frame(false, text)
{

View File

@ -36,7 +36,9 @@
#include "jinete/jrect.h"
#include "jinete/jtheme.h"
#include "jinete/jwidget.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
using namespace gfx;
static bool separator_msg_proc(JWidget widget, JMessage msg);

View File

@ -22,9 +22,11 @@
#include "jinete/jinete.h"
#include "jinete/jintern.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#include "Vaca/PreferredSizeEvent.h"
using namespace gfx;
typedef struct TipData
{
Widget* widget; // Widget that shows the tooltip

View File

@ -40,10 +40,12 @@
#include "jinete/jtheme.h"
#include "jinete/jview.h"
#include "jinete/jwidget.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#define BAR_SIZE widget->theme->scrollbar_size
using namespace gfx;
typedef struct View
{
int max_w, max_h; /* space which the widget need in the viewport */

View File

@ -50,6 +50,8 @@
#include "jinete/jintern.h"
#include "Vaca/PreferredSizeEvent.h"
using namespace gfx;
int ji_register_widget_type()
{
static int type = JI_USER_WIDGET;

View File

@ -36,7 +36,7 @@
#include "jinete/jbase.h"
#include "jinete/jrect.h"
#include "Vaca/Rect.h"
#include "gfx/rect.h"
#include "Vaca/Widget.h"
namespace Vaca { class PreferredSizeEvent; }
@ -49,8 +49,6 @@ namespace Vaca { class PreferredSizeEvent; }
#define ASSERT_VALID_WIDGET(widget) ((void)0)
#endif
using Vaca::Rect;
using Vaca::Size;
using Vaca::PreferredSizeEvent;
struct FONT;
@ -286,8 +284,8 @@ public:
//////////////////////////////////////////////////////////////////////
// position and geometry
Rect getBounds() const;
void setBounds(const Rect& rc);
gfx::Rect getBounds() const;
void setBounds(const gfx::Rect& rc);
//////////////////////////////////////////////////////////////////////
// manager handler
@ -299,9 +297,9 @@ public:
// SIZE & POSITION
// ===============================================================
Size getPreferredSize();
Size getPreferredSize(const Size& fitIn);
void setPreferredSize(const Size& fixedSize);
gfx::Size getPreferredSize();
gfx::Size getPreferredSize(const gfx::Size& fitIn);
void setPreferredSize(const gfx::Size& fixedSize);
void setPreferredSize(int fixedWidth, int fixedHeight);
// ===============================================================
@ -332,7 +330,7 @@ protected:
virtual void onPreferredSize(PreferredSizeEvent& ev);
private:
Size* m_preferredSize;
gfx::Size* m_preferredSize;
};
#endif

View File

@ -38,9 +38,11 @@
#include "jinete/jinete.h"
#include "jinete/jintern.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#include "Vaca/PreferredSizeEvent.h"
using namespace gfx;
enum {
WINDOW_NONE = 0,
WINDOW_MOVE = 1,

View File

@ -26,12 +26,12 @@
#include "jinete/jsystem.h"
#include "jinete/jtheme.h"
#include "Vaca/Point.h"
#include "Vaca/Rect.h"
#include "app.h"
#include "app/color_utils.h"
#include "console.h"
#include "core/cfg.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "modules/gfx.h"
#include "modules/gui.h"
#include "modules/palettes.h"
@ -40,15 +40,13 @@
#include "raster/image.h"
#include "raster/palette.h"
#include "widgets/editor.h"
#include "app/color_utils.h"
using Vaca::Rect;
using Vaca::Point;
static BITMAP* gfx_bmps[GFX_BITMAP_COUNT];
#include "modules/gfxdata.cpp"
using namespace gfx;
static void convert_data_to_bitmap(DATA *data, BITMAP** bmp)
{
int scale = jguiscale();

View File

@ -22,8 +22,7 @@
#include "app/color.h"
#include "jinete/jbase.h"
namespace Vaca { class Rect; }
using Vaca::Rect;
namespace gfx { class Rect; }
struct FONT;
struct BITMAP;
@ -93,10 +92,10 @@ void bevel_box(BITMAP* bmp, int x1, int y1, int x2, int y2, int c1, int c2, int
void rectdotted(BITMAP* bmp, int x1, int y1, int x2, int y2, int fg, int bg);
void rectgrid(BITMAP* bmp, int x1, int y1, int x2, int y2, int w, int h);
void draw_emptyset_symbol(BITMAP* bmp, const Rect& rc, int color);
void draw_color(BITMAP* bmp, const Rect& rc, int imgtype, const Color& color);
void draw_emptyset_symbol(BITMAP* bmp, const gfx::Rect& rc, int color);
void draw_color(BITMAP* bmp, const gfx::Rect& rc, int imgtype, const Color& color);
void draw_color_button(BITMAP* bmp,
const Rect& rc,
const gfx::Rect& rc,
bool outer_nw, bool outer_n, bool outer_ne, bool outer_e,
bool outer_se, bool outer_s, bool outer_sw, bool outer_w,
int imgtype, const Color& color,

View File

@ -70,6 +70,8 @@
# define DEF_SCALE 1
#endif
using namespace gfx;
static struct
{
int width;

View File

@ -25,9 +25,7 @@
#include "jinete/jtheme.h"
#include "jinete/jrect.h"
#include "Vaca/Property.h"
#include "Vaca/Rect.h"
using Vaca::Rect;
#include "gfx/rect.h"
// Property to show widgets with a special look (e.g.: buttons or sliders with mini-borders)
class SkinProperty : public Vaca::Property
@ -532,7 +530,7 @@ public:
void draw_part_as_vline(BITMAP* bmp, int x1, int y1, int x2, int y2, int part);
// Wrapper to use the new "Rect" class (x, y, w, h)
void draw_bounds_nw(BITMAP* bmp, const Rect& rc, int nw, int bg) {
void draw_bounds_nw(BITMAP* bmp, const gfx::Rect& rc, int nw, int bg) {
draw_bounds_nw(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, nw, bg);
}

View File

@ -19,11 +19,11 @@
#include "config.h"
#include <vector>
#include "Vaca/Point.h"
#include "gfx/point.h"
#include "raster/algo.h"
using Vaca::Point;
using namespace gfx;
// algo_polygon is an adaptation from Matthieu Haller code of GD library

View File

@ -19,13 +19,11 @@
#ifndef SETTINGS_SETTINGS_H_INCLUDED
#define SETTINGS_SETTINGS_H_INCLUDED
#include "Vaca/Rect.h"
#include "gfx/rect.h"
#include "app/color.h"
#include "tiled_mode.h"
#include "pen_type.h"
using Vaca::Rect;
class IToolSettings;
class IPenSettings;
class Tool;
@ -52,12 +50,12 @@ public:
virtual bool getSnapToGrid() = 0;
virtual bool getGridVisible() = 0;
virtual Rect getGridBounds() = 0;
virtual gfx::Rect getGridBounds() = 0;
virtual Color getGridColor() = 0;
virtual void setSnapToGrid(bool state) = 0;
virtual void setGridVisible(bool state) = 0;
virtual void setGridBounds(Rect rect) = 0;
virtual void setGridBounds(const gfx::Rect& rect) = 0;
virtual void setGridColor(const Color& color) = 0;
// Pixel grid

View File

@ -29,6 +29,8 @@
#include "tools/toolbox.h"
#include "widgets/color_bar.h"
using namespace gfx;
//////////////////////////////////////////////////////////////////////
// UISettingsImpl
@ -160,7 +162,7 @@ void UISettingsImpl::setGridVisible(bool state)
m_gridVisible = state;
}
void UISettingsImpl::setGridBounds(Rect rect)
void UISettingsImpl::setGridBounds(const Rect& rect)
{
m_gridBounds = rect;
}

View File

@ -45,12 +45,12 @@ public:
bool getSnapToGrid();
bool getGridVisible();
Rect getGridBounds();
gfx::Rect getGridBounds();
Color getGridColor();
void setSnapToGrid(bool state);
void setGridVisible(bool state);
void setGridBounds(Rect rect);
void setGridBounds(const gfx::Rect& rect);
void setGridColor(const Color& color);
// Pixel grid
@ -89,7 +89,7 @@ private:
int m_onionskin_opacity_step;
bool m_snapToGrid;
bool m_gridVisible;
Rect m_gridBounds;
gfx::Rect m_gridBounds;
Color m_gridColor;
bool m_pixelGridVisible;
Color m_pixelGridColor;

View File

@ -24,6 +24,8 @@
#include "util/render.h"
#include "context.h"
using namespace gfx;
//////////////////////////////////////////////////////////////////////
// ToolPointShape class

View File

@ -23,16 +23,13 @@
#include <list>
#include <vector>
#include "Vaca/Point.h"
#include "Vaca/Rect.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "jinete/jmessage.h"
#include "jinete/jrect.h"
#include "tiled_mode.h"
using Vaca::Point;
using Vaca::Rect;
class Context;
class Sprite;
class Image;
@ -109,11 +106,11 @@ class ToolController
public:
virtual ~ToolController() { }
virtual bool canSnapToGrid() { return true; }
virtual void pressButton(std::vector<Point>& points, const Point& point) = 0;
virtual bool releaseButton(std::vector<Point>& points, const Point& point) = 0;
virtual void movement(IToolLoop* loop, std::vector<Point>& points, const Point& point) = 0;
virtual void getPointsToInterwine(const std::vector<Point>& input, std::vector<Point>& output) = 0;
virtual void getStatusBarText(const std::vector<Point>& points, std::string& text) = 0;
virtual void pressButton(std::vector<gfx::Point>& points, const gfx::Point& point) = 0;
virtual bool releaseButton(std::vector<gfx::Point>& points, const gfx::Point& point) = 0;
virtual void movement(IToolLoop* loop, std::vector<gfx::Point>& points, const gfx::Point& point) = 0;
virtual void getPointsToInterwine(const std::vector<gfx::Point>& input, std::vector<gfx::Point>& output) = 0;
virtual void getStatusBarText(const std::vector<gfx::Point>& points, std::string& text) = 0;
};
// Converts a point to a shape to be drawn
@ -125,7 +122,7 @@ public:
virtual bool isFloodFill() { return false; }
virtual bool isSpray() { return false; }
virtual void transformPoint(IToolLoop* loop, int x, int y) = 0;
virtual void getModifiedArea(IToolLoop* loop, int x, int y, Rect& area) = 0;
virtual void getModifiedArea(IToolLoop* loop, int x, int y, gfx::Rect& area) = 0;
protected:
// Calls loop->getInk()->inkHline() function for each horizontal-scanline
@ -139,8 +136,8 @@ class ToolIntertwine
public:
virtual ~ToolIntertwine() { }
virtual bool snapByAngle() { return false; }
virtual void joinPoints(IToolLoop* loop, const std::vector<Point>& points) = 0;
virtual void fillPoints(IToolLoop* loop, const std::vector<Point>& points) = 0;
virtual void joinPoints(IToolLoop* loop, const std::vector<gfx::Point>& points) = 0;
virtual void fillPoints(IToolLoop* loop, const std::vector<gfx::Point>& points) = 0;
protected:
static void doPointshapePoint(int x, int y, IToolLoop* loop);
@ -254,7 +251,7 @@ public:
virtual Mask* getMask() = 0;
// Gets mask X,Y origin coordinates
virtual Point getMaskOrigin() = 0;
virtual gfx::Point getMaskOrigin() = 0;
// Return the mouse button which start the tool-loop (0 = left
// button, 1 = right button). It can be used by some tools that
@ -302,11 +299,11 @@ public:
virtual int getSpraySpeed() = 0;
// Offset for each point
virtual Point getOffset() = 0;
virtual gfx::Point getOffset() = 0;
// Velocity vector of the mouse
virtual void setSpeed(const Point& speed) = 0;
virtual Point getSpeed() = 0;
virtual void setSpeed(const gfx::Point& speed) = 0;
virtual gfx::Point getSpeed() = 0;
// Returns the ink to use with the tool. Each tool has an associated
// ink, but it could be modified for this specific loop, so
@ -326,10 +323,10 @@ public:
virtual bool isCanceled() = 0;
// Converts a coordinate in the screen to the sprite.
virtual Point screenToSprite(const Point& screenPoint) = 0;
virtual gfx::Point screenToSprite(const gfx::Point& screenPoint) = 0;
// Redraws in the screen the specified are of sprite.
virtual void updateArea(const Rect& dirty_area) = 0;
virtual void updateArea(const gfx::Rect& dirty_area) = 0;
virtual void updateStatusBar(const char* text) = 0;
@ -354,8 +351,8 @@ public:
class ToolLoopManager
{
IToolLoop* m_toolLoop;
std::vector<Point> m_points;
Point m_oldPoint;
std::vector<gfx::Point> m_points;
gfx::Point m_oldPoint;
public:
@ -385,10 +382,15 @@ public:
private:
void doLoopStep(bool last_step);
void snapToGrid(bool flexible, Point& point);
void snapToGrid(bool flexible, gfx::Point& point);
static void calculateDirtyArea(IToolLoop* loop, const std::vector<Point>& points, Rect& dirty_area);
static void calculateMinMax(const std::vector<Point>& points, Point& minpt, Point& maxpt);
static void calculateDirtyArea(IToolLoop* loop,
const std::vector<gfx::Point>& points,
gfx::Rect& dirty_area);
static void calculateMinMax(const std::vector<gfx::Point>& points,
gfx::Point& minpt,
gfx::Point& maxpt);
};
#endif

View File

@ -34,6 +34,8 @@
#include "tinyxml.h"
using namespace gfx;
#include "tools/controllers.h"
#include "tools/inks.h"
#include "tools/intertwiners.h"

View File

@ -18,18 +18,19 @@
#include "config.h"
#include <cstring>
#include <allegro.h>
#include <cstring>
#include "jinete/jinete.h"
#include "Vaca/Point.h"
#include "Vaca/Rect.h"
#include "app.h"
#include "app/color.h"
#include "commands/commands.h"
#include "commands/params.h"
#include "app.h"
#include "console.h"
#include "core/cfg.h"
#include "app/color.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "modules/editors.h"
#include "modules/gfx.h"
#include "modules/gui.h"
@ -39,16 +40,12 @@
#include "raster/palette.h"
#include "raster/sprite.h"
#include "raster/undo.h"
#include "sprite_wrappers.h"
#include "ui_context.h"
#include "widgets/color_bar.h"
#include "widgets/color_selector.h"
#include "widgets/paledit.h"
#include "widgets/statebar.h"
#include "sprite_wrappers.h"
#include "ui_context.h"
#include "console.h"
using Vaca::Point;
using Vaca::Rect;
#define COLORBAR_MAX_COLORS 256
#define ENTRYSIZE_MIN 12
@ -58,6 +55,8 @@ using Vaca::Rect;
#define FGBUTTON_SIZE (16*jguiscale())
#define BGBUTTON_SIZE (18*jguiscale())
using namespace gfx;
int colorbar_type()
{
static int type = 0;

View File

@ -61,10 +61,10 @@ private:
Color getHotColor(hotcolor_t hot);
void setHotColor(hotcolor_t hot, const Color& color);
Rect getColumnBounds(int column) const;
Rect getEntryBounds(int index) const;
Rect getFgBounds() const;
Rect getBgBounds() const;
gfx::Rect getColumnBounds(int column) const;
gfx::Rect getEntryBounds(int index) const;
gfx::Rect getFgBounds() const;
gfx::Rect getBgBounds() const;
void updateStatusBar(const Color& color, int msecs);
int m_firstIndex;

View File

@ -33,6 +33,8 @@
#include "modules/gui.h"
#include "widgets/colview.h"
using namespace gfx;
typedef struct ColorViewer
{
Color color;

View File

@ -54,9 +54,9 @@ class Editor : public Widget
};
private:
Type m_type;
Rect m_bounds;
gfx::Rect m_bounds;
public:
Decorator(Type type, const Rect& bounds);
Decorator(Type type, const gfx::Rect& bounds);
~Decorator();
void drawDecorator(Editor*editor, BITMAP* bmp);
@ -197,7 +197,7 @@ protected:
void onCurrentToolChange();
private:
void drawGrid(const Rect& gridBounds, const Color& color);
void drawGrid(const gfx::Rect& gridBounds, const Color& color);
void addDecorator(Decorator* decorator);
void deleteDecorators();

View File

@ -56,6 +56,8 @@
KB_ALT_FLAG | \
KB_CTRL_FLAG)) == (shift))
using namespace gfx;
static bool editor_view_msg_proc(JWidget widget, JMessage msg);
JWidget editor_view_new()

View File

@ -28,6 +28,8 @@
#include "undoable.h"
#include "widgets/editor/pixels_movement.h"
using namespace gfx;
class PixelsMovementImpl
{
SpriteWriter m_sprite_writer;

View File

@ -19,10 +19,6 @@
#ifndef WIDGETS_EDITOR_PIXELS_MOVEMENT_H_INCLUDED
#define WIDGETS_EDITOR_PIXELS_MOVEMENT_H_INCLUDED
#include "Vaca/Rect.h"
using Vaca::Rect;
class Sprite;
class Image;
@ -39,12 +35,12 @@ public:
void copyMask();
void catchImage(int x, int y);
void catchImageAgain(int x, int y);
Rect moveImage(int x, int y);
gfx::Rect moveImage(int x, int y);
void dropImageTemporarily();
void dropImage();
bool isDragging();
Rect getImageBounds();
gfx::Rect getImageBounds();
void setMaskColor(ase_uint32 mask_color);

View File

@ -42,6 +42,8 @@
#define MAX_THUMBNAIL_SIZE 128
#define ISEARCH_KEYPRESS_INTERVAL_MSECS 500
using namespace gfx;
typedef struct FileView
{
IFileItem* current_folder;

View File

@ -24,7 +24,7 @@
#include <cstring>
#include "jinete/jinete.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#include "Vaca/Bind.h"
#include "app.h"
@ -48,6 +48,8 @@
#include "widgets/editor.h"
#include "widgets/statebar.h"
using namespace gfx;
enum AniAction {
ACTION_FIRST,
ACTION_PREV,
@ -371,7 +373,7 @@ bool StatusBar::onProcessMessage(JMessage msg)
}
{
JRect rc = jrect_new_copy(this->rc);
Vaca::Size reqSize = m_movePixelsBox->getPreferredSize();
Size reqSize = m_movePixelsBox->getPreferredSize();
rc->x1 = rc->x2 - reqSize.w;
rc->x2 -= this->border_width.r;
jwidget_set_rect(m_movePixelsBox, rc);

View File

@ -25,7 +25,7 @@
#include "jinete/jinete.h"
#include "Vaca/Bind.h"
#include "Vaca/Signal.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
#include "app.h"
#include "commands/command.h"
@ -39,7 +39,7 @@
#include "widgets/statebar.h"
#include "widgets/toolbar.h"
using Vaca::Size;
using namespace gfx;
// Class to show selected tools for each tool (vertically)
class ToolBar : public Widget

View File

@ -8,11 +8,8 @@ add_library(vaca
src/Component.cpp
src/Event.cpp
src/Exception.cpp
src/Point.cpp
src/PreferredSizeEvent.cpp
src/Property.cpp
src/Rect.cpp
src/Referenceable.cpp
src/Size.cpp
src/String.cpp
src/Vaca.cpp)

View File

@ -1,86 +0,0 @@
// Vaca - Visual Application Components Abstraction
// Copyright (c) 2005-2009 David Capello
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the name of the author nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef VACA_POINT_H
#define VACA_POINT_H
#include "Vaca/base.h"
#ifdef VACA_ON_WINDOWS
struct tagPOINT;
struct tagPOINTS;
#endif
namespace Vaca {
/**
A 2D coordinate in the screen or client area of a widget.
*/
class VACA_DLL Point
{
public:
int x, y;
Point();
Point(int x, int y);
Point(const Point& point);
explicit Point(const Size& size);
const Point& operator=(const Point& pt);
const Point& operator+=(const Point& pt);
const Point& operator-=(const Point& pt);
const Point& operator+=(int value);
const Point& operator-=(int value);
const Point& operator*=(int value);
const Point& operator/=(int value);
Point operator+(const Point& pt) const;
Point operator-(const Point& pt) const;
Point operator+(int value) const;
Point operator-(int value) const;
Point operator*(int value) const;
Point operator/(int value) const;
Point operator-() const;
bool operator==(const Point& pt) const;
bool operator!=(const Point& pt) const;
#ifdef VACA_ON_WINDOWS
explicit Point(const tagPOINT* pt);
explicit Point(const tagPOINTS* pt);
operator tagPOINT() const;
#endif
};
} // namespace Vaca
#endif // VACA_POINT_H

View File

@ -34,26 +34,26 @@
#include "Vaca/base.h"
#include "Vaca/Event.h"
#include "Vaca/Size.h"
#include "gfx/size.h"
namespace Vaca {
class VACA_DLL PreferredSizeEvent : public Event
{
Size m_fitIn;
Size m_preferredSize;
gfx::Size m_fitIn;
gfx::Size m_preferredSize;
public:
PreferredSizeEvent(Widget* source, const Size& fitIn);
PreferredSizeEvent(Widget* source, const gfx::Size& fitIn);
virtual ~PreferredSizeEvent();
Size fitInSize() const;
gfx::Size fitInSize() const;
int fitInWidth() const;
int fitInHeight() const;
Size getPreferredSize() const;
void setPreferredSize(const Size& preferredSize);
gfx::Size getPreferredSize() const;
void setPreferredSize(const gfx::Size& preferredSize);
void setPreferredSize(int w, int h);
};

View File

@ -1,126 +0,0 @@
// Vaca - Visual Application Components Abstraction
// Copyright (c) 2005-2009 David Capello
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the name of the author nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef VACA_RECT_H
#define VACA_RECT_H
#include "Vaca/base.h"
#ifdef VACA_ON_WINDOWS
struct tagRECT;
#endif
namespace Vaca {
/**
A rectangle.
*/
class VACA_DLL Rect
{
public:
/**
Horizontal position of the rectangle's upper-left corner (increase from left to right).
@c x=0 means the beginning of the left side in the screen or
@link Widget#getClientBounds Widget's client area@endlink.
*/
int x;
/**
Vertical position of the rectangle's upper-left corner (increase from top to bottom).
@c y=0 means the beginning of the top side in the screen or
@link Widget#getClientBounds Widget's client area@endlink.
*/
int y;
/**
Width of the rectangle (increase from left to right).
@c w<1 means an empty rectangle.
*/
int w;
/**
Height of the rectangle (increase from left to right).
@c h<1 means an empty rectangle.
*/
int h;
Rect();
Rect(int w, int h);
explicit Rect(const Size& size);
Rect(const Rect& rect);
Rect(const Point& point, const Size& size);
Rect(const Point& point1, const Point& point2);
Rect(int x, int y, int w, int h);
bool isEmpty() const;
Point getCenter() const;
Point getOrigin() const;
Point getPoint2() const;
Size getSize() const;
Rect& setOrigin(const Point& pt);
Rect& setSize(const Size& sz);
Rect& offset(int dx, int dy);
Rect& offset(const Point& point);
Rect& inflate(int dw, int dh);
Rect& inflate(const Size& size);
Rect& enlarge(int unit);
Rect& shrink(int unit);
bool contains(const Point& pt) const;
bool contains(const Rect& rc) const;
bool intersects(const Rect& rc) const;
Rect createUnion(const Rect& rc) const;
Rect createIntersect(const Rect& rc) const;
bool operator==(const Rect& rc) const;
bool operator!=(const Rect& rc) const;
#ifdef VACA_ON_WINDOWS
explicit Rect(const tagRECT* rc);
operator tagRECT() const;
#endif
};
} // namespace Vaca
#endif // VACA_RECT_H

View File

@ -1,87 +0,0 @@
// Vaca - Visual Application Components Abstraction
// Copyright (c) 2005-2009 David Capello
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the name of the author nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef VACA_SIZE_H
#define VACA_SIZE_H
#include "Vaca/base.h"
#ifdef VACA_ON_WINDOWS
struct tagSIZE;
#endif
namespace Vaca {
/**
A 2D size.
*/
class VACA_DLL Size
{
public:
int w, h;
Size();
Size(int w, int h);
Size(const Size& size);
explicit Size(const Point& point);
Size createUnion(const Size& sz) const;
Size createIntersect(const Size& sz) const;
const Size& operator=(const Size& sz);
const Size& operator+=(const Size& sz);
const Size& operator-=(const Size& sz);
const Size& operator+=(int value);
const Size& operator-=(int value);
const Size& operator*=(int value);
const Size& operator/=(int value);
Size operator+(const Size& sz) const;
Size operator-(const Size& sz) const;
Size operator+(int value) const;
Size operator-(int value) const;
Size operator*(int value) const;
Size operator/(int value) const;
Size operator-() const;
bool operator==(const Size& sz) const;
bool operator!=(const Size& sz) const;
#ifdef VACA_ON_WINDOWS
explicit Size(const tagSIZE* sz);
operator tagSIZE() const;
#endif
};
} // namespace Vaca
#endif // VACA_SIZE_H

View File

@ -447,7 +447,6 @@ class NonCopyable;
class OpenFileDialog;
class PaintEvent;
class Pen;
class Point;
class PopupMenu;
class PreferredSizeEvent;
class ProgressBar;
@ -456,7 +455,6 @@ class RadioButton;
class RadioGroup;
class ReBar;
class ReBarBand;
class Rect;
class Referenceable;
class Region;
class ResizeEvent;
@ -469,7 +467,6 @@ class ScrollEvent;
class ScrollInfo;
class Separator;
class SetCursorEvent;
class Size;
class Slider;
class SpinButton;
class Spinner;

View File

@ -1,182 +0,0 @@
// Vaca - Visual Application Components Abstraction
// Copyright (c) 2005-2009 David Capello
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the name of the author nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Vaca/Point.h"
#include "Vaca/Size.h"
#ifdef VACA_ON_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
using namespace Vaca;
Point::Point()
{
x = 0;
y = 0;
}
Point::Point(int x, int y)
{
this->x = x;
this->y = y;
}
Point::Point(const Point& point)
{
x = point.x;
y = point.y;
}
Point::Point(const Size& size)
{
x = size.w;
y = size.h;
}
const Point& Point::operator=(const Point& pt)
{
x = pt.x;
y = pt.y;
return *this;
}
const Point& Point::operator+=(const Point& pt)
{
x += pt.x;
y += pt.y;
return *this;
}
const Point& Point::operator-=(const Point& pt)
{
x -= pt.x;
y -= pt.y;
return *this;
}
const Point& Point::operator+=(int value)
{
x += value;
y += value;
return *this;
}
const Point& Point::operator-=(int value)
{
x -= value;
y -= value;
return *this;
}
const Point& Point::operator*=(int value)
{
x *= value;
y *= value;
return *this;
}
const Point& Point::operator/=(int value)
{
x /= value;
y /= value;
return *this;
}
Point Point::operator+(const Point& pt) const
{
return Point(x+pt.x, y+pt.y);
}
Point Point::operator-(const Point& pt) const
{
return Point(x-pt.x, y-pt.y);
}
Point Point::operator+(int value) const
{
return Point(x+value, y+value);
}
Point Point::operator-(int value) const
{
return Point(x-value, y-value);
}
Point Point::operator*(int value) const
{
return Point(x*value, y*value);
}
Point Point::operator/(int value) const
{
return Point(x/value, y/value);
}
Point Point::operator-() const
{
return Point(-x, -y);
}
bool Point::operator==(const Point& pt) const
{
return x == pt.x && y == pt.y;
}
bool Point::operator!=(const Point& pt) const
{
return x != pt.x || y != pt.y;
}
#ifdef VACA_ON_WINDOWS
Point::Point(const tagPOINT* pt)
{
x = pt->x;
y = pt->y;
}
Point::Point(const tagPOINTS* pt)
{
x = pt->x;
y = pt->y;
}
Point::operator tagPOINT() const
{
POINT pt;
pt.x = x;
pt.y = y;
return pt;
}
#endif

View File

@ -32,6 +32,7 @@
#include "Vaca/PreferredSizeEvent.h"
#include "Vaca/Widget.h"
using namespace gfx;
using namespace Vaca;
/**

View File

@ -1,454 +0,0 @@
// Vaca - Visual Application Components Abstraction
// Copyright (c) 2005-2009 David Capello
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the name of the author nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Vaca/Rect.h"
#include "Vaca/Point.h"
#include "Vaca/Size.h"
#ifdef VACA_ON_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
using namespace Vaca;
/**
Creates a new empty rectangle with the origin in @c Point(0,0).
The rectangle will be @c #x=#y=#w=#h=0
@see isEmpty
*/
Rect::Rect()
{
x = 0;
y = 0;
w = 0;
h = 0;
}
/**
Creates a new rectangle with the specified size with the origin in @c Point(0,0).
The rectangle will be @c #x=#y=0.
*/
Rect::Rect(int w, int h)
{
this->x = 0;
this->y = 0;
this->w = w;
this->h = h;
}
/**
Creates a new rectangle with the specified size with the origin in @c Point(0,0).
The rectangle will be @c #x=#y=0.
*/
Rect::Rect(const Size& size)
{
x = 0;
y = 0;
w = size.w;
h = size.h;
}
/**
Creates a copy of @a rect.
*/
Rect::Rect(const Rect& rect)
{
x = rect.x;
y = rect.y;
w = rect.w;
h = rect.h;
}
/**
Creates a new rectangle with the origin in @a point
and the specified @a size.
*/
Rect::Rect(const Point& point, const Size& size)
{
this->x = point.x;
this->y = point.y;
this->w = size.w;
this->h = size.h;
}
/**
Creates a new rectangle with the origin in @a point1 and size equal
to @a point2 - @a point1.
If a coordinate of @a point1 is greater than @a point2 (Point#x
and/or Point#y), the coordinates are swapped. So the rectangle
will be:
@code
#x = MIN(point1.x, point2.x)
#y = MIN(point1.y, point2.y)
#w = MAX(point1.x, point2.x) - #x
#h = MAX(point1.x, point2.x) - #y
@endcode
See that @a point2 isn't included in the rectangle, it's
like the point returned by #getPoint2 member function.
@see #getPoint2
*/
Rect::Rect(const Point& point1, const Point& point2)
{
Point leftTop = point1;
Point rightBottom = point2;
register int t;
if (leftTop.x > rightBottom.x) {
t = leftTop.x;
leftTop.x = rightBottom.x;
rightBottom.x = t;
}
if (leftTop.y > rightBottom.y) {
t = leftTop.y;
leftTop.y = rightBottom.y;
rightBottom.y = t;
}
this->x = leftTop.x;
this->y = leftTop.y;
this->w = rightBottom.x - leftTop.x;
this->h = rightBottom.y - leftTop.y;
}
Rect::Rect(int x, int y, int w, int h)
{
this->x = x;
this->y = y;
this->w = w;
this->h = h;
}
/**
Verifies if the width and/or height of the rectangle are less or
equal than zero.
*/
bool Rect::isEmpty() const
{
return (w < 1 || h < 1);
}
/**
Returns the middle point of the rectangle (the centroid).
@return
Point(#x+#w/2, #y+#h/2)
*/
Point Rect::getCenter() const
{
return Point(x+w/2, y+h/2);
}
/**
Returns the point in the upper-left corner (that is inside the rectangle).
@return
Point(#x, #y)
*/
Point Rect::getOrigin() const
{
return Point(x, y);
}
/**
Returns point in the lower-right corner (that is outside the rectangle).
@return
Point(#x+#w, #y+#h)
*/
Point Rect::getPoint2() const
{
return Point(x+w, y+h);
}
/**
Returns the size of the rectangle.
@return
Size(#w, #h)
*/
Size Rect::getSize() const
{
return Size(w, h);
}
/**
Changes the origin of the rectangle without modifying its size.
*/
Rect& Rect::setOrigin(const Point& pt)
{
x = pt.x;
y = pt.y;
return *this;
}
/**
Changes the size of the rectangle without modifying its origin.
*/
Rect& Rect::setSize(const Size& sz)
{
w = sz.w;
h = sz.h;
return *this;
}
/**
Moves the rectangle origin in the specified delta.
@param dx
How many pixels displace the #x coordinate (#x+=dx).
@param dy
How many pixels displace the #y coordinate (#y+=dy).
@return
A reference to @c this.
*/
Rect& Rect::offset(int dx, int dy)
{
x += dx;
y += dy;
return *this;
}
/**
Moves the rectangle origin in the specified delta.
@param point
How many pixels displace the origin (#x+=point.x, #y+=point.y).
@return
A reference to @c this.
*/
Rect& Rect::offset(const Point& point)
{
x += point.x;
y += point.y;
return *this;
}
/**
Increases (or decreases if the delta is negative) the size of the
rectangle.
@param dw
How many pixels to increase the width of the rectangle #w.
@param dh
How many pixels to increase the height of the rectangle #h.
@return
A reference to @c this.
*/
Rect& Rect::inflate(int dw, int dh)
{
w += dw;
h += dh;
return *this;
}
/**
Increases (or decreases if the delta is negative) the size of the
rectangle.
@param size
How many pixels to increase the size of the
rectangle (#w+=size.w, #h+=size.h).
@return
A reference to @c this.
*/
Rect& Rect::inflate(const Size& size)
{
w += size.w;
h += size.h;
return *this;
}
/**
@todo docme
@return
A reference to @c this.
*/
Rect& Rect::enlarge(int unit)
{
x -= unit;
y -= unit;
w += unit<<1;
h += unit<<1;
return *this;
}
/**
@todo docme
@return
A reference to @c this.
*/
Rect& Rect::shrink(int unit)
{
x += unit;
y += unit;
w -= unit<<1;
h -= unit<<1;
return *this;
}
/**
Returns true if this rectangle encloses the @a pt point.
*/
bool Rect::contains(const Point& pt) const
{
return
pt.x >= x && pt.x < x+w &&
pt.y >= y && pt.y < y+h;
}
/**
Returns true if this rectangle entirely contains the @a rc rectangle.
@warning
If some rectangle is empty, this member function returns false.
*/
bool Rect::contains(const Rect& rc) const
{
if (isEmpty() || rc.isEmpty())
return false;
return
rc.x >= x && rc.x+rc.w <= x+w &&
rc.y >= y && rc.y+rc.h <= y+h;
}
/**
Returns true if the intersection between this rectangle with @a rc
rectangle is not empty.
@warning
If some rectangle is empty, this member function returns false.
*/
bool Rect::intersects(const Rect& rc) const
{
if (isEmpty() || rc.isEmpty())
return false;
return
rc.x <= x+w && rc.x+rc.w > x &&
rc.y <= y+h && rc.y+rc.h > y;
}
/**
Returns the union rectangle between this and @c rc rectangle.
@warning
If some rectangle is empty, this member function will return the
other rectangle.
*/
Rect Rect::createUnion(const Rect& rc) const
{
if (isEmpty())
return rc;
else if (rc.isEmpty())
return *this;
else
return Rect(Point(x < rc.x ? x: rc.x,
y < rc.y ? y: rc.y),
Point(x+w > rc.x+rc.w ? x+w: rc.x+rc.w,
y+h > rc.y+rc.h ? y+h: rc.y+rc.h));
}
/**
Returns the intersection rectangle between this and @c rc rectangles.
*/
Rect Rect::createIntersect(const Rect& rc) const
{
if (intersects(rc))
return Rect(Point(x > rc.x ? x: rc.x,
y > rc.y ? y: rc.y),
Point(x+w < rc.x+rc.w ? x+w: rc.x+rc.w,
y+h < rc.y+rc.h ? y+h: rc.y+rc.h));
else
return Rect();
}
bool Rect::operator==(const Rect& rc) const
{
return
x == rc.x && w == rc.w &&
y == rc.y && h == rc.h;
}
bool Rect::operator!=(const Rect& rc) const
{
return
x != rc.x || w != rc.w ||
y != rc.y || h != rc.h;
}
#ifdef VACA_ON_WINDOWS
/**
Converts a Win32's rectangle (RECT structure) to a Vaca's rectangle
(Rect class).
@internal
*/
Rect::Rect(const tagRECT* rc)
{
x = rc->left;
y = rc->top;
w = rc->right - rc->left;
h = rc->bottom - rc->top;
}
/**
Converts a Vaca's rectangle (Rect class) to a Win32's rectangle
(RECT structure).
@internal
*/
Rect::operator tagRECT() const
{
tagRECT rc;
rc.left = x;
rc.top = y;
rc.right = x+w;
rc.bottom = y+h;
return rc;
}
#endif

View File

@ -1,188 +0,0 @@
// Vaca - Visual Application Components Abstraction
// Copyright (c) 2005-2009 David Capello
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the name of the author nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Vaca/Size.h"
#include "Vaca/Point.h"
#ifdef VACA_ON_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
using namespace Vaca;
Size::Size()
{
w = 0;
h = 0;
}
Size::Size(int w, int h)
{
this->w = w;
this->h = h;
}
Size::Size(const Size& size)
{
w = size.w;
h = size.h;
}
Size::Size(const Point& point)
{
w = point.x;
h = point.y;
}
Size Size::createUnion(const Size& sz) const
{
return Size(max_value(w, sz.w),
max_value(h, sz.h));
}
Size Size::createIntersect(const Size& sz) const
{
return Size(min_value(w, sz.w),
min_value(h, sz.h));
}
const Size& Size::operator=(const Size& sz)
{
w = sz.w;
h = sz.h;
return *this;
}
const Size& Size::operator+=(const Size& sz)
{
w += sz.w;
h += sz.h;
return *this;
}
const Size& Size::operator-=(const Size& sz)
{
w -= sz.w;
h -= sz.h;
return *this;
}
const Size& Size::operator+=(int value)
{
w += value;
h += value;
return *this;
}
const Size& Size::operator-=(int value)
{
w -= value;
h -= value;
return *this;
}
const Size& Size::operator*=(int value)
{
w *= value;
h *= value;
return *this;
}
const Size& Size::operator/=(int value)
{
w /= value;
h /= value;
return *this;
}
Size Size::operator+(const Size& sz) const
{
return Size(w+sz.w, h+sz.h);
}
Size Size::operator-(const Size& sz) const
{
return Size(w-sz.w, h-sz.h);
}
Size Size::operator+(int value) const
{
return Size(w+value, h+value);
}
Size Size::operator-(int value) const
{
return Size(w-value, h-value);
}
Size Size::operator*(int value) const
{
return Size(w*value, h*value);
}
Size Size::operator/(int value) const
{
return Size(w/value, h/value);
}
Size Size::operator-() const
{
return Size(-w, -h);
}
bool Size::operator==(const Size& sz) const
{
return w == sz.w && h == sz.h;
}
bool Size::operator!=(const Size& sz) const
{
return w != sz.w || h != sz.h;
}
#ifdef VACA_ON_WINDOWS
Size::Size(const tagSIZE* sz)
{
w = sz->cx;
h = sz->cy;
}
Size::operator tagSIZE() const
{
tagSIZE sz;
sz.cx = w;
sz.cy = h;
return sz;
}
#endif