diff options
author | Henrik Kinnunen <fluxgen@fluxbox.org> | 2007-10-17 16:02:07 (GMT) |
---|---|---|
committer | Henrik Kinnunen <fluxgen@fluxbox.org> | 2007-10-17 16:02:07 (GMT) |
commit | 48e3a31cab2c6b515c26e69878f606a6d4d6df6f (patch) | |
tree | 976a0798689d3aa51548f422a41f35240807e354 /src/ScaleWindowToWindow.hh | |
download | fbpager-48e3a31cab2c6b515c26e69878f606a6d4d6df6f.zip fbpager-48e3a31cab2c6b515c26e69878f606a6d4d6df6f.tar.bz2 |
initial commit
Diffstat (limited to 'src/ScaleWindowToWindow.hh')
-rw-r--r-- | src/ScaleWindowToWindow.hh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ScaleWindowToWindow.hh b/src/ScaleWindowToWindow.hh new file mode 100644 index 0000000..63ab297 --- /dev/null +++ b/src/ScaleWindowToWindow.hh | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef SCALEWINDOWTOWINDOW_HH | ||
2 | #define SCALEWINDOWTOWINDOW_HH | ||
3 | |||
4 | #include "FbTk/FbWindow.hh" | ||
5 | |||
6 | namespace FbPager { | ||
7 | template <typename T> | ||
8 | inline void scaleFromWindowToWindow(const FbTk::FbWindow &src, | ||
9 | const FbTk::FbWindow &dest, | ||
10 | T &x, T &y) { | ||
11 | float xdiv = static_cast<float>(src.width()) / static_cast<float>(dest.width()); | ||
12 | float ydiv = static_cast<float>(src.height()) / static_cast<float>(dest.height()); | ||
13 | x = static_cast<T>((float)(x) / xdiv); | ||
14 | y = static_cast<T>((float)(y) / ydiv); | ||
15 | } | ||
16 | |||
17 | } // end namespace FbPager | ||
18 | |||
19 | #endif // SCALEWINDOWTOWINDOW_HH | ||