1 // Copyright 2010-2018, Google Inc. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are 6 // met: 7 // 8 // * Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // * Redistributions in binary form must reproduce the above 11 // copyright notice, this list of conditions and the following disclaimer 12 // in the documentation and/or other materials provided with the 13 // distribution. 14 // * Neither the name of Google Inc. nor the names of its 15 // contributors may be used to endorse or promote products derived from 16 // this software without specific prior written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30 #ifndef MOZC_RENDERER_WIN32_INFOLIST_WINDOW_H_ 31 #define MOZC_RENDERER_WIN32_INFOLIST_WINDOW_H_ 32 33 #include <windows.h> 34 #define _ATL_NO_AUTOMATIC_NAMESPACE 35 #define _WTL_NO_AUTOMATIC_NAMESPACE 36 #include <atlbase.h> 37 #include <atlwin.h> 38 #include <atlapp.h> 39 #include <atlcrack.h> 40 #include <atlmisc.h> 41 #include <atlgdi.h> 42 43 #include <memory> 44 #include <string> 45 46 #include "base/const.h" 47 #include "base/coordinates.h" 48 #include "base/port.h" 49 50 namespace mozc { 51 52 namespace client { 53 class SendCommandInterface; 54 } // namespace client 55 56 namespace commands { 57 class Candidates; 58 } // namespace commands 59 60 namespace renderer { 61 class RendererStyle; 62 namespace win32 { 63 64 class TextRenderer; 65 66 typedef ATL::CWinTraits< 67 WS_POPUP | WS_DISABLED, 68 WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_NOACTIVATE> 69 InfolistWindowTraits; 70 71 // a class which implements an IME infolist window for Windows. This class 72 // is derived from an ATL CWindowImpl<T> class, which provides methods for 73 // creating a window and handling windows messages. 74 class InfolistWindow : public ATL::CWindowImpl<InfolistWindow, 75 ATL::CWindow, 76 InfolistWindowTraits> { 77 public: 78 DECLARE_WND_CLASS_EX(kInfolistWindowClassName, 79 CS_SAVEBITS | CS_DROPSHADOW, COLOR_WINDOW); 80 81 BEGIN_MSG_MAP_EX(InfolistWindow) 82 MSG_WM_DESTROY(OnDestroy) 83 MSG_WM_ERASEBKGND(OnEraseBkgnd) 84 MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) 85 MSG_WM_SETTINGCHANGE(OnSettingChange) 86 MSG_WM_PAINT(OnPaint) 87 MSG_WM_PRINTCLIENT(OnPrintClient) 88 MSG_WM_TIMER(OnTimer) 89 END_MSG_MAP() 90 91 InfolistWindow(); 92 ~InfolistWindow(); 93 void OnDestroy(); 94 BOOL OnEraseBkgnd(WTL::CDCHandle dc); 95 void OnGetMinMaxInfo(MINMAXINFO *min_max_info); 96 void OnPaint(WTL::CDCHandle dc); 97 void OnPrintClient(WTL::CDCHandle dc, UINT uFlags); 98 void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); 99 void OnTimer(UINT_PTR nIDEvent); 100 101 void UpdateLayout(const commands::Candidates &candidates); 102 void SetSendCommandInterface( 103 client::SendCommandInterface *send_command_interface); 104 105 // Layout information for the WindowManager class. 106 Size GetLayoutSize(); 107 108 void DelayShow(UINT mseconds); 109 void DelayHide(UINT mseconds); 110 111 private: 112 Size DoPaint(WTL::CDCHandle dc); 113 Size DoPaintRow(WTL::CDCHandle dc, int row, int ypos); 114 115 client::SendCommandInterface *send_command_interface_; 116 std::unique_ptr<commands::Candidates> candidates_; 117 std::unique_ptr<TextRenderer> text_renderer_; 118 std::unique_ptr<renderer::RendererStyle> style_; 119 bool metrics_changed_; 120 bool visible_; 121 122 DISALLOW_COPY_AND_ASSIGN(InfolistWindow); 123 }; 124 125 } // namespace win32 126 } // namespace renderer 127 } // namespace mozc 128 129 #endif // MOZC_RENDERER_WIN32_INFOLIST_WINDOW_H_ 130