15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef UI_BASE_L10N_L10N_UTIL_WIN_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UI_BASE_L10N_L10N_UTIL_WIN_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <windows.h> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector> 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)#include "base/strings/string16.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/base/ui_base_export.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace l10n_util { 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns the locale-dependent extended window styles. 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This function is used for adding locale-dependent extended window styles 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// (e.g. WS_EX_LAYOUTRTL, WS_EX_RTLREADING, etc.) when creating a window. 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Callers should OR this value into their extended style value when creating 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a window. 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT int GetExtendedStyles(); 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TODO(xji): 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This is a temporary name, it will eventually replace GetExtendedStyles 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT int GetExtendedTooltipStyles(); 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Give an HWND, this function sets the WS_EX_LAYOUTRTL extended style for the 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// underlying window. When this style is set, the UI for the window is going to 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// be mirrored. This is generally done for the UI of right-to-left languages 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// such as Hebrew. 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT void HWNDSetRTLLayout(HWND hwnd); 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// See http://blogs.msdn.com/oldnewthing/archive/2005/09/15/467598.aspx 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and http://blogs.msdn.com/oldnewthing/archive/2006/06/26/647365.aspx 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// as to why we need these three functions. 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Return true if the default font (we get from Windows) is not suitable 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to use in the UI of the current UI (e.g. Malayalam, Bengali). If 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// override_font_family and font_size_scaler are not null, they'll be 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// filled with the font family name and the size scaler. The output 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// parameters are not modified if the return value is false. 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT bool NeedOverrideDefaultUIFont( 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::string16* override_font_family, 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) double* font_size_scaler); 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// If the default UI font stored in |logfont| is not suitable, its family 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// and size are replaced with those stored in the per-locale resource. The 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// font size is adjusted based on the font scale setting in the OS preferences. 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Windows 8 supports scale factors of 1, 1.4 and 1.8. 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT void AdjustUIFont(LOGFONT* logfont); 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// If the default UI font stored in |logfont| is not suitable, its family 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// and size are replaced with those stored in the per-locale resource. The 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |dpi_scale| is the ratio of the OS setting for dots per inch relative to the 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// baseline of 96 DPI. This ratio is also used for converting sizes from 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// device independent pixels (DIP) to physical pixels. The font size is scaled 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// for use with Views and Aura which work in DIP. 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT void AdjustUIFontForDIP(float dpi_scale, LOGFONT* logfont); 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// If the font for a given window (pointed to by HWND) is not suitable for the 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// UI in the current UI langauge, its family and size are replaced with those 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// stored in the per-locale resource. 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT void AdjustUIFontForWindow(HWND hwnd); 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Allow processes to override the configured locale with the user's Windows UI 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// languages. This function should generally be called once early in 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Application startup. 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)UI_BASE_EXPORT void OverrideLocaleWithUILanguageList(); 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Retrieve the locale override, or an empty vector if the locale has not been 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// or failed to be overridden. 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const std::vector<std::string>& GetLocaleOverrides(); 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace l10n_util 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // UI_BASE_L10N_L10N_UTIL_WIN_H_ 78