]> git.saurik.com Git - wxWidgets.git/blob - include/wx/private/window.h
fixing warning and compile error against 10.4
[wxWidgets.git] / include / wx / private / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/private/window.h
3 // Purpose: misc wxWindow helpers
4 // Author: Vaclav Slavik
5 // Created: 2010-01-21
6 // RCS-ID: $Id$
7 // Copyright: (c) 2010 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_PRIVATE_WINDOW_H_
12 #define _WX_PRIVATE_WINDOW_H_
13
14 #include "wx/gdicmn.h"
15
16 namespace wxPrivate
17 {
18
19 // Windows' computes dialog units using average character width over upper-
20 // and lower-case ASCII alphabet and not using the average character width
21 // metadata stored in the font; see
22 // http://support.microsoft.com/default.aspx/kb/145994 for detailed discussion.
23 //
24 // This helper function computes font dimensions in the same way. It works with
25 // either wxDC or wxWindow argument.
26 template<typename T>
27 inline wxSize GetAverageASCIILetterSize(const T& of_what)
28 {
29 const wxStringCharType *TEXT_TO_MEASURE =
30 wxS("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
31
32 wxSize s = of_what.GetTextExtent(TEXT_TO_MEASURE);
33 s.x = (s.x / 26 + 1) / 2;
34 return s;
35 }
36
37 } // namespace wxPrivate
38
39 #endif // _WX_PRIVATE_WINDOW_H_