| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef APP_WIN_WIN_UTIL_H_ | |
| 6 #define APP_WIN_WIN_UTIL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <windows.h> | |
| 10 | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/string16.h" | |
| 14 | |
| 15 class FilePath; | |
| 16 | |
| 17 namespace gfx { | |
| 18 class Font; | |
| 19 class Rect; | |
| 20 } | |
| 21 | |
| 22 namespace app { | |
| 23 namespace win { | |
| 24 | |
| 25 // Creates a string interpretation of the time of day represented by the given | |
| 26 // SYSTEMTIME that's appropriate for the user's default locale. | |
| 27 // Format can be an empty string (for the default format), or a "format picture" | |
| 28 // as specified in the Windows documentation for GetTimeFormat(). | |
| 29 string16 FormatSystemTime(const SYSTEMTIME& time, | |
| 30 const string16& format); | |
| 31 | |
| 32 // Creates a string interpretation of the date represented by the given | |
| 33 // SYSTEMTIME that's appropriate for the user's default locale. | |
| 34 // Format can be an empty string (for the default format), or a "format picture" | |
| 35 // as specified in the Windows documentation for GetDateFormat(). | |
| 36 string16 FormatSystemDate(const SYSTEMTIME& date, | |
| 37 const string16& format); | |
| 38 | |
| 39 // Returns the long path name given a short path name. A short path name | |
| 40 // is a path that follows the 8.3 convention and has ~x in it. If the | |
| 41 // path is already a long path name, the function returns the current | |
| 42 // path without modification. | |
| 43 bool ConvertToLongPath(const string16& short_path, string16* long_path); | |
| 44 | |
| 45 // Returns true if the current point is close enough to the origin point in | |
| 46 // space and time that it would be considered a double click. | |
| 47 bool IsDoubleClick(const POINT& origin, | |
| 48 const POINT& current, | |
| 49 DWORD elapsed_time); | |
| 50 | |
| 51 // Returns true if the current point is far enough from the origin that it | |
| 52 // would be considered a drag. | |
| 53 bool IsDrag(const POINT& origin, const POINT& current); | |
| 54 | |
| 55 // Returns true if edge |edge| (one of ABE_LEFT, TOP, RIGHT, or BOTTOM) of | |
| 56 // monitor |monitor| has an auto-hiding taskbar that's always-on-top. | |
| 57 bool EdgeHasTopmostAutoHideTaskbar(UINT edge, HMONITOR monitor); | |
| 58 | |
| 59 // Duplicates a section handle from another process to the current process. | |
| 60 // Returns the new valid handle if the function succeed. NULL otherwise. | |
| 61 HANDLE GetSectionFromProcess(HANDLE section, HANDLE process, bool read_only); | |
| 62 | |
| 63 // Duplicates a section handle from the current process for use in another | |
| 64 // process. Returns the new valid handle or NULL on failure. | |
| 65 HANDLE GetSectionForProcess(HANDLE section, HANDLE process, bool read_only); | |
| 66 | |
| 67 // Adjusts the value of |child_rect| if necessary to ensure that it is | |
| 68 // completely visible within |parent_rect|. | |
| 69 void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect, | |
| 70 gfx::Rect* child_rect, | |
| 71 int padding); | |
| 72 | |
| 73 // Returns the bounds for the monitor that contains the largest area of | |
| 74 // intersection with the specified rectangle. | |
| 75 gfx::Rect GetMonitorBoundsForRect(const gfx::Rect& rect); | |
| 76 | |
| 77 // Returns true if the virtual key code is a digit coming from the numeric | |
| 78 // keypad (with or without NumLock on). |extended_key| should be set to the | |
| 79 // extended key flag specified in the WM_KEYDOWN/UP where the |key_code| | |
| 80 // originated. | |
| 81 bool IsNumPadDigit(int key_code, bool extended_key); | |
| 82 | |
| 83 // Grabs a snapshot of the designated window and stores a PNG representation | |
| 84 // into a byte vector. | |
| 85 void GrabWindowSnapshot(HWND window_handle, | |
| 86 std::vector<unsigned char>* png_representation); | |
| 87 | |
| 88 // Returns whether the specified window is the current active window. | |
| 89 bool IsWindowActive(HWND hwnd); | |
| 90 | |
| 91 // Returns whether the specified file name is a reserved name on windows. | |
| 92 // This includes names like "com2.zip" (which correspond to devices) and | |
| 93 // desktop.ini and thumbs.db which have special meaning to the windows shell. | |
| 94 bool IsReservedName(const string16& filename); | |
| 95 | |
| 96 // A wrapper around Windows' MessageBox function. Using a Chrome specific | |
| 97 // MessageBox function allows us to control certain RTL locale flags so that | |
| 98 // callers don't have to worry about adding these flags when running in a | |
| 99 // right-to-left locale. | |
| 100 int MessageBox(HWND hwnd, | |
| 101 const string16& text, | |
| 102 const string16& caption, | |
| 103 UINT flags); | |
| 104 | |
| 105 // Returns the system set window title font. | |
| 106 gfx::Font GetWindowTitleFont(); | |
| 107 | |
| 108 // The thickness of an auto-hide taskbar in pixels. | |
| 109 extern const int kAutoHideTaskbarThicknessPx; | |
| 110 | |
| 111 } // namespace win | |
| 112 } // namespace app | |
| 113 | |
| 114 #endif // APP_WIN_WIN_UTIL_H_ | |
| OLD | NEW |