From 5b6037bba0a247515bffdb1c0914d9cb01b8518c Mon Sep 17 00:00:00 2001 From: pescuma Date: Sun, 25 Jan 2009 17:17:36 +0000 Subject: skins: 0.0.0.3 * Better handling of small sizes git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@137 c086bb3d-8645-0410-b8da-73a8550f86e7 --- Plugins/skins/SkinLib/FieldState.cpp | 58 ++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 22 deletions(-) (limited to 'Plugins/skins/SkinLib/FieldState.cpp') diff --git a/Plugins/skins/SkinLib/FieldState.cpp b/Plugins/skins/SkinLib/FieldState.cpp index 1d112cc..6851005 100644 --- a/Plugins/skins/SkinLib/FieldState.cpp +++ b/Plugins/skins/SkinLib/FieldState.cpp @@ -234,7 +234,15 @@ static inline int beetween(int val, int minVal, int maxVal) return max(minVal, min(maxVal, val)); } -RECT FieldState::getRect() const +static inline void intersection(RECT &main, const RECT &other) +{ + main.left = beetween(main.left, other.left, other.right); + main.right = beetween(main.right, other.left, other.right); + main.top = beetween(main.top, other.top, other.bottom); + main.bottom = beetween(main.bottom, other.top, other.bottom); +} + +RECT FieldState::getRect(bool raw) const { RECT ret = {0}; @@ -243,10 +251,33 @@ RECT FieldState::getRect() const RECT inside = dialog->getInsideRect(); - ret.left = beetween(getLeft() + inside.left, inside.left, inside.right); - ret.right = beetween(getRight() + inside.left, inside.left, inside.right); - ret.top = beetween(getTop() + inside.top, inside.top, inside.bottom); - ret.bottom = beetween(getBottom() + inside.top, inside.top, inside.bottom); + ret.left = getLeft() + inside.left; + ret.right = getRight() + inside.left; + ret.top = getTop() + inside.top; + ret.bottom = getBottom() + inside.top; + + if (!raw) + intersection(ret, inside); + + return ret; +} + +RECT FieldState::getInsideRect(bool raw) const +{ + RECT ret = {0}; + + if (!visible) + return ret; + + RECT inside = dialog->getInsideRect(); + + ret.left = getLeft() + borders.getLeft() + inside.left; + ret.right = getRight() - borders.getRight() + inside.left; + ret.top = getTop() + borders.getTop() + inside.top; + ret.bottom = getBottom() - borders.getBottom() + inside.top; + + if (!raw) + intersection(ret, inside); return ret; } @@ -270,20 +301,3 @@ void FieldState::setVAlign(VERTICAL_ALIGN valign) { this->valign = valign; } - -RECT FieldState::getInsideRect() const -{ - RECT ret = {0}; - - if (!visible) - return ret; - - RECT inside = dialog->getInsideRect(); - - ret.left = beetween(getLeft() + borders.getLeft() + inside.left, inside.left, inside.right); - ret.right = beetween(getRight() - borders.getRight() + inside.left, inside.left, inside.right); - ret.top = beetween(getTop() + borders.getTop() + inside.top, inside.top, inside.bottom); - ret.bottom = beetween(getBottom() - borders.getBottom() + inside.top, inside.top, inside.bottom); - - return ret; -} -- cgit v1.2.3