3 ==============================================================================
5 This file is part of the async
6 Copyright 2005-10 by Satoshi Fujiwara.
8 async can be redistributed and/or modified under the terms of the
9 GNU General Public License, as published by the Free Software Foundation;
10 either version 2 of the License, or (at your option) any later version.
12 async is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with async; if not, visit www.gnu.org/licenses or write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 Boston, MA 02111-1307 USA
22 ==============================================================================
30 dpi_t() : init_(false), dpi_x_(96), dpi_y_(96) { }
31 //
\89æ
\96Ê
\82Ì DPI
\82ð
\8eæ
\93¾
\82µ
\82Ü
\82·
\81B
32 T dpix() { init(); return dpi_x_; }
33 T dpiy() { init(); return dpi_y_; }
35 //
\90â
\91Î
\83s
\83N
\83Z
\83\8b\82Æ
\91\8a\91Î
\83s
\83N
\83Z
\83\8b\8aÔ
\82Ì
\95Ï
\8a·
\82ð
\8ds
\82¢
\82Ü
\82·
\81B
36 T scale_x(T x) { init(); return MulDiv(x, dpi_x_, 96); }
37 T scale_y(T y) { init(); return MulDiv(y, dpi_y_, 96); }
38 T unscale_x(T x) { init(); return MulDiv(x, 96, dpi_x_); }
39 T unscale_y(T y) { init(); return MulDiv(y, 96, dpi_y_); }
41 //
\89æ
\96Ê
\83T
\83C
\83Y (
\91\8a\91Î
\83s
\83N
\83Z
\83\8b\92P
\88Ê)
\82ð
\8b\81\82ß
\82Ü
\82·
\81B
42 T scaled_screen_width() { return scaled_system_metrix_x(SM_CXSCREEN); }
43 T scaled_screen_height() { return scaled_system_metrix_y(SM_CYSCREEN); }
45 //
\8el
\8ap
\8c`
\82Ì
\83T
\83C
\83Y
\82ð
\90â
\91Î
\83s
\83N
\83Z
\83\8b\82©
\82ç
\91\8a\91Î
\83s
\83N
\83Z
\83\8b\82É
\95Ï
\8dX
\82µ
\82Ü
\82·
\81B
46 void scale_rect(RECT *rect_ptr)
48 rect_ptr->left = scale_x(rect_ptr->left);
49 rect_ptr->right = scale_x(rect_ptr->right);
50 rect_ptr->top = scale_y(rect_ptr->top);
51 rect_ptr->bottom = scale_y(rect_ptr->bottom);
54 //
\89æ
\96Ê
\89ð
\91\9c\93x
\82ª
\8dÅ
\92á
\92l (
\91\8a\91Î
\83s
\83N
\83Z
\83\8b\92P
\88Ê)
\82ð
\96\9e\82½
\82µ
\82Ä
\82¢
\82é
\82©
\82Ç
\82¤
\82©
\82ð
55 //
\8am
\94F
\82µ
\82Ü
\82·
\81B
56 bool is_resolution_at_least(T xmin, T ymin)
58 return (scaled_screen_width() >= xmin) && (scaled_screen_height() >= ymin);
60 //
\83|
\83C
\83\93\83g
\83T
\83C
\83Y (1/72
\83C
\83\93\83`)
\82ð
\90â
\91Î
\83s
\83N
\83Z
\83\8b\82É
\95Ï
\8a·
\82µ
\82Ü
\82·
\81B
61 T point_to_pixels(int pt) { return MulDiv(pt, dpi_y_, 72); }
62 //
\83L
\83\83\83b
\83V
\83\85\82³
\82ê
\82½
\83\81\83g
\83\8a\83b
\83N
\82ð
\82·
\82×
\82Ä
\96³
\8cø
\82É
\82µ
\82Ü
\82·
\81B
63 void invalidate() { init_ = false; }
67 T scaled_system_metrix_x(int nIndex)
70 return MulDiv(GetSystemMetrics(nIndex), 96, dpi_x_);
73 T scaled_system_metrix_y(int nIndex)
76 return MulDiv(GetSystemMetrics(nIndex), 96, dpi_y_);
85 typedef dpi_t<int> dpi;