src/float.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de>
00002 // See ../LICENSE.txt for license details.
00003 //
00004 // $Id: float.cpp 2 2007-05-16 10:38:27Z eg $
00005 
00006 #include "float.h"
00007 
00008 #include "rectangle.h"
00009 
00010 // applied patch by Dr. J. Pfefferl
00011 void Float::resize(Rectangle *rect, Direction dir, int stepW, int stepH)
00012 {
00013     int newW, newH;
00014 
00015     switch (dir) {
00016     case NORTH_WEST:
00017     case SOUTH_WEST:
00018     case LEFT:
00019         newW = rect->width() - stepW;
00020         if (0 < newW) {
00021           rect->setX(rect->x() + stepW);
00022           rect->setWidth(newW);
00023         }
00024         break;
00025     case NORTH_EAST:
00026     case SOUTH_EAST:
00027     case RIGHT:
00028         newW = rect->width() + stepW;
00029         if (0 < newW) {
00030           rect->setWidth(newW);
00031         }
00032         break;
00033     default:
00034         break;
00035     }
00036 
00037     switch (dir) {
00038     case NORTH_WEST:
00039     case NORTH_EAST:
00040     case UP:
00041         newH = rect->height() - stepH;
00042         if (0 < newH) {
00043           rect->setY(rect->y() + stepH);
00044           rect->setHeight(newH);
00045         }
00046         break;
00047     case SOUTH_WEST:
00048     case SOUTH_EAST:
00049     case DOWN:
00050         newH = rect->height() + stepH;
00051         if (0 < newH) {
00052           rect->setHeight(newH);
00053         }
00054         break;
00055     default:
00056         break;
00057     }
00058 }
00059 
00060 void Float::move(Rectangle *rect, int stepW, int stepH) {
00061     rect->setX(rect->x() + stepW);
00062     rect->setY(rect->y() + stepH);
00063 }
00064 
00065 void Float::center(Rectangle *rect, Rectangle *parentRect) {
00066 
00067     unsigned int clientCenterX = (rect->x() + rect->width()) / 2;
00068     unsigned int clientCenterY = (rect->y() + rect->height()) / 2;
00069     unsigned int parentCenterX = (parentRect->x() + parentRect->width()) / 2;
00070     unsigned int parentCenterY = (parentRect->y() + parentRect->height()) / 2;
00071     int dx = parentCenterX - clientCenterX;
00072     int dy = parentCenterY - clientCenterY;
00073     rect->setX(rect->x() + dx);
00074     rect->setY(rect->y() + dy);
00075 }

Generated on Thu May 24 15:19:32 2007 for ncwm by  doxygen 1.5.1