Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/ttcomtester/teraterm/teraterm/sizetip.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8504 - (hide annotations) (download) (as text)
Sun Jan 26 15:13:39 2020 UTC (4 years, 2 months ago) by zmatsuo
Original Path: trunk/teraterm/teraterm/sizetip.c
File MIME type: text/x-csrc
File size: 5244 byte(s)
マルチモニタ関連のAPIを直接呼ばないようにした

- MonitorFromWindow(), MonitorFromPoint(), GetMonitorInfo()
- pMonitorFromWindow(), pMonitorFromPoint(), pGetMonitorInfoA() を追加
- 使用しなくなった GetMonitorLeftmost() を削除
1 zmatsuo 8122 /*
2 zmatsuo 7507 * Copyright (C) 2008-2019 TeraTerm Project
3 doda 7089 * All rights reserved.
4     *
5     * Redistribution and use in source and binary forms, with or without
6     * modification, are permitted provided that the following conditions
7     * are met:
8     *
9     * 1. Redistributions of source code must retain the above copyright
10     * notice, this list of conditions and the following disclaimer.
11     * 2. Redistributions in binary form must reproduce the above copyright
12     * notice, this list of conditions and the following disclaimer in the
13     * documentation and/or other materials provided with the distribution.
14     * 3. The name of the author may not be used to endorse or promote products
15     * derived from this software without specific prior written permission.
16     *
17     * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27     */
28 zmatsuo 7507 /* original idea from PuTTY 0.60 windows/sizetip.c */
29 doda 7089
30     #include "teraterm.h"
31     #include "tttypes.h"
32     #include "ttlib.h"
33     #include "ttwinman.h"
34 zmatsuo 8504 #include "compat_win.h"
35 doda 7089
36     #include <windows.h>
37     #include <stdio.h>
38 zmatsuo 7507 #include <tchar.h>
39 doda 7089
40 zmatsuo 8122 #include "tipwin.h"
41 zmatsuo 7507
42     static TipWin *SizeTip;
43 doda 7089 static int tip_enabled = 0;
44    
45 doda 8139 /*
46     * point ��
47     * �X�N���[�����������o�������������A������������������
48     * NearestMonitor �� TRUE �������A�����������j�^
49     * FALSE�������A�}�E�X���������j�^������������
50     * �f�B�X�v���C���[���� FrameWidth(pixel) ��������������������
51 yutakapon 8097 */
52     static void FixPosFromFrame(POINT *point, int FrameWidth, BOOL NearestMonitor)
53     {
54     if (HasMultiMonitorSupport()) {
55 doda 8139 // �}���`���j�^���T�|�[�g��������������
56 yutakapon 8097 HMONITOR hm;
57     MONITORINFO mi;
58     int ix, iy;
59    
60 doda 8139 // �������W��������������
61 yutakapon 8097 ix = point->x;
62     iy = point->y;
63    
64 zmatsuo 8504 hm = pMonitorFromPoint(*point, MONITOR_DEFAULTTONULL);
65 yutakapon 8097 if (hm == NULL) {
66     if (NearestMonitor) {
67 doda 8139 // �����������j�^���\������
68 zmatsuo 8504 hm = pMonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST);
69 yutakapon 8097 } else {
70 doda 8139 // �X�N���[�����������o���������������}�E�X���������j�^���\������
71 yutakapon 8097 GetCursorPos(point);
72 zmatsuo 8504 hm = pMonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST);
73 yutakapon 8097 }
74     }
75    
76     mi.cbSize = sizeof(MONITORINFO);
77 zmatsuo 8504 pGetMonitorInfoA(hm, &mi);
78 yutakapon 8097 if (ix < mi.rcMonitor.left + FrameWidth) {
79     ix = mi.rcMonitor.left + FrameWidth;
80     }
81     if (iy < mi.rcMonitor.top + FrameWidth) {
82     iy = mi.rcMonitor.top + FrameWidth;
83     }
84    
85     point->x = ix;
86     point->y = iy;
87     }
88     else
89     {
90 doda 8139 // �}���`���j�^���T�|�[�g����������������
91 yutakapon 8097 if (point->x < FrameWidth) {
92     point->x = FrameWidth;
93     }
94     if (point->y < FrameWidth) {
95     point->y = FrameWidth;
96     }
97     }
98     }
99    
100 doda 8139 /* ���T�C�Y�p�c�[���`�b�v���\������
101 yutakapon 8100 *
102 doda 8139 * �����F
103     * src �E�B���h�E�n���h��
104     * cx, cy �c�[���`�b�v���\�������c���T�C�Y
105     * fwSide ���T�C�Y�����������E�B���h�E����������
106     * newX, newY ���T�C�Y�������������W
107 yutakapon 8100 *
108 yutakapon 8181 * ����:
109     * Windows9x�����������v���p�e�B���u�E�B���h�E�����e���\����������
110     * �h���b�O�����v���`�F�b�N�������������A�c�[���`�b�v���\�������������B
111 yutakapon 8100 */
112     void UpdateSizeTip(HWND src, int cx, int cy, UINT fwSide, int newX, int newY)
113 doda 7089 {
114     TCHAR str[32];
115 yutakapon 8100 int tooltip_movable = 0;
116 doda 7089
117     if (!tip_enabled)
118     return;
119    
120     /* Generate the tip text */
121 zmatsuo 7507 _stprintf_s(str, _countof(str), _T("%dx%d"), cx, cy);
122 doda 7089
123 doda 8139 // �E�B���h�E���E�A�E���A�����������������A�c�[���`�b�v�����������z�u�����B
124     // ���������O�����T�C�Y�������������z�u�����B
125 yutakapon 8100 if (!(fwSide == WMSZ_RIGHT || fwSide == WMSZ_BOTTOMRIGHT || fwSide == WMSZ_BOTTOM)) {
126     tooltip_movable = 1;
127     }
128    
129 zmatsuo 7507 if (SizeTip == NULL) {
130 doda 7089 RECT wr;
131 yutakapon 8097 POINT point;
132     int w, h;
133    
134 doda 8139 // ���������c���T�C�Y����������
135 yutakapon 8097 TipWinGetTextWidthHeight(src, str, &w, &h);
136    
137 doda 8139 // �E�B���h�E�����u������
138 doda 7089 GetWindowRect(src, &wr);
139 yutakapon 8100
140 doda 8139 // sizetip���o�����u���A�E�B���h�E����(X, Y)���������A
141 yasuhide 8268 // (X, Y - ������������ - TIP_WIN_FRAME_WIDTH * 2) �������B
142 yutakapon 8097 point.x = wr.left;
143 yasuhide 8268 point.y = wr.top - (h + TIP_WIN_FRAME_WIDTH * 2);
144 yutakapon 8097 FixPosFromFrame(&point, 16, FALSE);
145     cx = point.x;
146     cy = point.y;
147    
148 zmatsuo 8301 SizeTip = TipWinCreateT(NULL, src, cx, cy, str);
149 yutakapon 8100
150     //OutputDebugPrintf("Created: (%d,%d)\n", cx, cy);
151    
152 doda 7089 } else {
153     /* Tip already exists, just set the text */
154 zmatsuo 7507 TipWinSetText(SizeTip, str);
155     //SetWindowText(tip_wnd, str);
156 yutakapon 8100
157     //OutputDebugPrintf("Updated: (%d,%d)\n", cx, cy);
158    
159 doda 8139 // �E�B���h�E��������������������
160 yutakapon 8100 if (tooltip_movable) {
161 yasuhide 8268 TipWinSetPos(SizeTip, newX + TIP_WIN_FRAME_WIDTH*2, newY + TIP_WIN_FRAME_WIDTH*2);
162 yutakapon 8100 //OutputDebugPrintf("Moved: (%d,%d)\n", newX, newY);
163     }
164 doda 7089 }
165     }
166    
167     void EnableSizeTip(int bEnable)
168     {
169 zmatsuo 7507 if (SizeTip && !bEnable) {
170     TipWinDestroy(SizeTip);
171     SizeTip = NULL;
172 doda 7089 }
173    
174     tip_enabled = bEnable;
175     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26