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 8268 - (hide annotations) (download) (as text)
Mon Oct 7 13:14:35 2019 UTC (4 years, 6 months ago) by yasuhide
Original Path: trunk/teraterm/teraterm/sizetip.c
File MIME type: text/x-csrc
File size: 5213 byte(s)
ツールチップクラス化ブランチをマージした

r8164 | auto_destroyを削除した
r8165 | TipWinの作成・削除の処理を統一した
r8166 | FRAME_WIDTHをTIP_WIN_FRAME_WIDTHに変更した
r8167 | _snprintf_sの引数を修正した
r8168 | TipWinの作成・削除の処理を明確にして整理した
r8169 | デバッグ用ヘッダを追加した
r8196 | [Tooltip] 初期化漏れを修正した
r8197 | [Tooltip] 不要な定義を整理した
r8198 | [Tooltip] RegisterClassの呼び出しをTera Term全体で1回にした
r8199 | [Tooltip] TipWinオブジェクトを破棄したあとで空にした
r8201 | [Tooltip] ウィンドウクラスを登録するときのチェックを強化した
r8202 | [Tooltip] タイマーの終了条件を修正した
r8203 | [Tooltip] ウィンドウクラス名をTeraTermTipWinClassに変更した
r8227 | [Tooltip] WNDCLASSをTipWinを使うファイル名から生成する
r8228 | [Tooltip] hInstanceを呼出側から渡せるようにした
r8229 | [Tooltip] TipWinの初期化処理を整理した
r8235 | [Tooltip] コンストラクタとCreate()の引数を変更した
r8255 | [Tooltip] 未使用変数の定義を削除した
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    
35     #include <windows.h>
36     #include <stdio.h>
37 zmatsuo 7507 #include <tchar.h>
38 doda 7089
39 zmatsuo 8122 #include "tipwin.h"
40 zmatsuo 7507
41     static TipWin *SizeTip;
42 doda 7089 static int tip_enabled = 0;
43    
44 doda 8139 /*
45     * point ��
46     * �X�N���[�����������o�������������A������������������
47     * NearestMonitor �� TRUE �������A�����������j�^
48     * FALSE�������A�}�E�X���������j�^������������
49     * �f�B�X�v���C���[���� FrameWidth(pixel) ��������������������
50 yutakapon 8097 */
51     static void FixPosFromFrame(POINT *point, int FrameWidth, BOOL NearestMonitor)
52     {
53     if (HasMultiMonitorSupport()) {
54 doda 8139 // �}���`���j�^���T�|�[�g��������������
55 yutakapon 8097 HMONITOR hm;
56     MONITORINFO mi;
57     int ix, iy;
58    
59 doda 8139 // �������W��������������
60 yutakapon 8097 ix = point->x;
61     iy = point->y;
62    
63     hm = MonitorFromPoint(*point, MONITOR_DEFAULTTONULL);
64     if (hm == NULL) {
65     if (NearestMonitor) {
66 doda 8139 // �����������j�^���\������
67 yutakapon 8097 hm = MonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST);
68     } else {
69 doda 8139 // �X�N���[�����������o���������������}�E�X���������j�^���\������
70 yutakapon 8097 GetCursorPos(point);
71     hm = MonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST);
72     }
73     }
74    
75     mi.cbSize = sizeof(MONITORINFO);
76     GetMonitorInfo(hm, &mi);
77     if (ix < mi.rcMonitor.left + FrameWidth) {
78     ix = mi.rcMonitor.left + FrameWidth;
79     }
80     if (iy < mi.rcMonitor.top + FrameWidth) {
81     iy = mi.rcMonitor.top + FrameWidth;
82     }
83    
84     point->x = ix;
85     point->y = iy;
86     }
87     else
88     {
89 doda 8139 // �}���`���j�^���T�|�[�g����������������
90 yutakapon 8097 if (point->x < FrameWidth) {
91     point->x = FrameWidth;
92     }
93     if (point->y < FrameWidth) {
94     point->y = FrameWidth;
95     }
96     }
97     }
98    
99 doda 8139 /* ���T�C�Y�p�c�[���`�b�v���\������
100 yutakapon 8100 *
101 doda 8139 * �����F
102     * src �E�B���h�E�n���h��
103     * cx, cy �c�[���`�b�v���\�������c���T�C�Y
104     * fwSide ���T�C�Y�����������E�B���h�E����������
105     * newX, newY ���T�C�Y�������������W
106 yutakapon 8100 *
107 yutakapon 8181 * ����:
108     * Windows9x�����������v���p�e�B���u�E�B���h�E�����e���\����������
109     * �h���b�O�����v���`�F�b�N�������������A�c�[���`�b�v���\�������������B
110 yutakapon 8100 */
111     void UpdateSizeTip(HWND src, int cx, int cy, UINT fwSide, int newX, int newY)
112 doda 7089 {
113     TCHAR str[32];
114 yutakapon 8100 int tooltip_movable = 0;
115 doda 7089
116     if (!tip_enabled)
117     return;
118    
119     /* Generate the tip text */
120 zmatsuo 7507 _stprintf_s(str, _countof(str), _T("%dx%d"), cx, cy);
121 doda 7089
122 doda 8139 // �E�B���h�E���E�A�E���A�����������������A�c�[���`�b�v�����������z�u�����B
123     // ���������O�����T�C�Y�������������z�u�����B
124 yutakapon 8100 if (!(fwSide == WMSZ_RIGHT || fwSide == WMSZ_BOTTOMRIGHT || fwSide == WMSZ_BOTTOM)) {
125     tooltip_movable = 1;
126     }
127    
128 zmatsuo 7507 if (SizeTip == NULL) {
129 doda 7089 RECT wr;
130 yutakapon 8097 POINT point;
131     int w, h;
132    
133 doda 8139 // ���������c���T�C�Y����������
134 yutakapon 8097 TipWinGetTextWidthHeight(src, str, &w, &h);
135    
136 doda 8139 // �E�B���h�E�����u������
137 doda 7089 GetWindowRect(src, &wr);
138 yutakapon 8100
139 doda 8139 // sizetip���o�����u���A�E�B���h�E����(X, Y)���������A
140 yasuhide 8268 // (X, Y - ������������ - TIP_WIN_FRAME_WIDTH * 2) �������B
141 yutakapon 8097 point.x = wr.left;
142 yasuhide 8268 point.y = wr.top - (h + TIP_WIN_FRAME_WIDTH * 2);
143 yutakapon 8097 FixPosFromFrame(&point, 16, FALSE);
144     cx = point.x;
145     cy = point.y;
146    
147 yasuhide 8268 SizeTip = TipWinCreate(NULL, src, cx, cy, str);
148 yutakapon 8100
149     //OutputDebugPrintf("Created: (%d,%d)\n", cx, cy);
150    
151 doda 7089 } else {
152     /* Tip already exists, just set the text */
153 zmatsuo 7507 TipWinSetText(SizeTip, str);
154     //SetWindowText(tip_wnd, str);
155 yutakapon 8100
156     //OutputDebugPrintf("Updated: (%d,%d)\n", cx, cy);
157    
158 doda 8139 // �E�B���h�E��������������������
159 yutakapon 8100 if (tooltip_movable) {
160 yasuhide 8268 TipWinSetPos(SizeTip, newX + TIP_WIN_FRAME_WIDTH*2, newY + TIP_WIN_FRAME_WIDTH*2);
161 yutakapon 8100 //OutputDebugPrintf("Moved: (%d,%d)\n", newX, newY);
162     }
163 doda 7089 }
164     }
165    
166     void EnableSizeTip(int bEnable)
167     {
168 zmatsuo 7507 if (SizeTip && !bEnable) {
169     TipWinDestroy(SizeTip);
170     SizeTip = NULL;
171 doda 7089 }
172    
173     tip_enabled = bEnable;
174     }

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