| 1 |
sf-pippijn |
1.1 |
/* align.cc |
| 2 |
|
|
* This file is part of NDK++ library |
| 3 |
|
|
* Copyright (c) 2003 by Stanislav Ievlev |
| 4 |
|
|
* |
| 5 |
|
|
* This file is covered by the GNU Library General Public License, |
| 6 |
sf-pippijn |
1.2 |
* which should be included with libndk as the file COPYING. |
| 7 |
sf-pippijn |
1.1 |
*/ |
| 8 |
sf-pippijn |
1.3 |
#include <stdexcept> |
| 9 |
|
|
|
| 10 |
sf-pippijn |
1.2 |
#include <ndk/align.hh> |
| 11 |
sf-pippijn |
1.1 |
|
| 12 |
|
|
int |
| 13 |
|
|
ndk::align::pos (int internal_size, int external_size, align::type align) |
| 14 |
|
|
{ |
| 15 |
|
|
switch (align) |
| 16 |
|
|
{ |
| 17 |
|
|
case left: |
| 18 |
|
|
return 0; |
| 19 |
|
|
case right: |
| 20 |
|
|
return external_size - internal_size; |
| 21 |
|
|
case center: |
| 22 |
|
|
return (external_size - internal_size) / 2; |
| 23 |
|
|
default: |
| 24 |
sf-pippijn |
1.3 |
throw std::runtime_error ("unknown align type"); |
| 25 |
sf-pippijn |
1.1 |
} |
| 26 |
|
|
} |