Release 940620
[wine.git] / windows / icon.c
blobdc9648e41450948e84caea01563deda893debaa8
2 /*
3 * Iconification functions
5 * Copyright 1994 John Richardson
6 */
8 static char Copyright[] = "Copyright John Richardson, 1994";
10 #include "win.h"
11 #include "class.h"
12 #include "message.h"
13 #include "sysmetrics.h"
14 #include "user.h"
15 #include "scroll.h"
16 #include "menu.h"
17 #include "icon.h"
19 RECT myrect;
22 ICON_Iconify(HWND hwnd)
24 WND *wndPtr = WIN_FindWndPtr( hwnd );
25 GC testgc;
26 WND *parwPtr;
28 #ifdef DEBUG_ICON
29 #endif
30 printf("ICON_Iconify %d\n", hwnd);
32 parwPtr = WIN_FindWndPtr(wndPtr->hwndParent);
33 if (parwPtr == NULL) {
34 printf("argh, the parent is NULL, what to do?\n");
35 exit(1);
37 wndPtr->dwStyle |= WS_MINIMIZE;
38 XUnmapWindow(display, wndPtr->window);
39 if (wndPtr->icon == NULL) {
40 printf("argh, couldn't find icon\n");
41 exit(1);
43 printf("parent edge values are %d, %d\n", parwPtr->rectWindow.left,
44 parwPtr->rectWindow.bottom);
45 wndPtr->ptIconPos.x = parwPtr->rectWindow.left + 10;
46 wndPtr->ptIconPos.y = parwPtr->rectWindow.bottom - 80;
48 #ifdef NOT
49 wndPtr->rectWindow.right = 100;
50 wndPtr->rectWindow.bottom = 32;
51 wndPtr->rectNormal.right = 1000;
52 wndPtr->rectNormal.bottom = 32;
53 wndPtr->rectClient.top= wndPtr->ptIconPos.y;
54 wndPtr->rectClient.left= wndPtr->ptIconPos.x;
56 wndPtr->rectClient.right = 100;
57 wndPtr->rectClient.bottom = 64;
58 #endif
59 wndPtr->rectClientSave = wndPtr->rectNormal;
60 myrect = wndPtr->rectClient;
62 MoveWindow(hwnd, wndPtr->ptIconPos.x, wndPtr->ptIconPos.y,
63 100, 64+20, FALSE);
65 XMoveWindow(display, wndPtr->icon,
66 wndPtr->ptIconPos.x, wndPtr->ptIconPos.y);
68 XMapWindow(display, wndPtr->icon);
70 SendMessage(hwnd, WM_PAINTICON, 0, 0);
71 printf("done with iconify\n");
75 BOOL ICON_isAtPoint(HWND hwnd, POINT pt)
77 WND *wndPtr = WIN_FindWndPtr( hwnd );
78 int iconWidth, iconHeight;
80 /****************
81 if (wndPtr->hwndParent != GetDesktopWindow()) {
82 pt.x -= wndPtr->rectClient.left;
83 pt.y -= wndPtr->rectClient.top;
85 *****************/
88 if (wndPtr->hIcon != (HICON)NULL) {
89 ICONALLOC *lpico;
90 lpico = (ICONALLOC *)GlobalLock(wndPtr->hIcon);
91 iconWidth = (int)lpico->descriptor.Width;
92 iconHeight = (int)lpico->descriptor.Height;
93 } else {
94 iconWidth = 64;
95 iconHeight = 64;
97 #define DEBUG_ICON 1
98 #ifdef DEBUG_ICON
99 printf("icon x,y is %d,%d\n",
100 wndPtr->ptIconPos.x, wndPtr->ptIconPos.y);
102 printf("icon end x,y is %d,%d\n",
103 wndPtr->ptIconPos.x + 100,
104 wndPtr->ptIconPos.y + iconHeight + 20);
106 printf("mouse pt x,y is %d,%d\n", pt.x, pt.y);
108 printf("%d\n", IsIconic(hwnd));
109 printf("%d\n", (pt.x >= wndPtr->ptIconPos.x));
110 printf("%d\n", (pt.x < wndPtr->ptIconPos.x + 100));
111 printf("%d\n", (pt.y >= wndPtr->ptIconPos.y));
112 printf("%d\n", (pt.y < wndPtr->ptIconPos.y + iconHeight + 20));
113 printf("%d\n", !(wndPtr->dwStyle & WS_DISABLED));
114 printf("%d\n", (wndPtr->dwStyle & WS_VISIBLE));
115 printf("%d\n", !(wndPtr->dwExStyle & WS_EX_TRANSPARENT));
116 #endif
118 if ( IsIconic(hwnd) &&
119 (pt.x >= wndPtr->ptIconPos.x) &&
120 (pt.x < wndPtr->ptIconPos.x + 100) &&
121 (pt.y >= wndPtr->ptIconPos.y) &&
122 (pt.y < wndPtr->ptIconPos.y + iconHeight + 20) &&
123 !(wndPtr->dwStyle & WS_DISABLED) &&
124 (wndPtr->dwStyle & WS_VISIBLE) &&
125 !(wndPtr->dwExStyle & WS_EX_TRANSPARENT))
127 printf("got a winner!\n");
128 return 1;
131 return 0;
135 HWND ICON_findIconFromPoint(POINT pt)
137 HWND hwnd = GetTopWindow( GetDesktopWindow() );
138 WND *wndPtr;
139 HWND hwndRet = 0;
141 while (hwnd) {
143 if ( !(wndPtr=WIN_FindWndPtr(hwnd))) return 0;
144 if (ICON_isAtPoint(hwnd, pt)) {
145 printf("returning\n");
146 return hwndRet = hwnd;
147 } else {
148 printf("checking child\n");
149 hwnd = wndPtr->hwndChild;
152 return hwndRet;
156 ICON_Deiconify(HWND hwnd)
158 WND *wndPtr = WIN_FindWndPtr( hwnd );
160 printf("deiconifying\n");
161 XUnmapWindow(display, wndPtr->icon);
162 wndPtr->dwStyle &= ~WS_MINIMIZE;
163 /* wndPtr->rectNormal = myrect;
165 MoveWindow(hwnd,
166 wndPtr->rectClientSave.left,
167 wndPtr->rectClientSave.top,
168 wndPtr->rectClientSave.right - wndPtr->rectClientSave.left,
169 wndPtr->rectClientSave.bottom - wndPtr->rectClientSave.top,
170 FALSE);
172 XMapWindow(display, wndPtr->window);