Rev 5061 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5061 | Rev 5372 | ||
---|---|---|---|
1 | #include |
1 | #include |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
4 | #include "winlib.h" |
4 | #include "winlib.h" |
5 | 5 | ||
6 | #define CAPTION_CORNER_W 8 |
6 | #define CAPTION_CORNER_W 8 |
7 | #define FRAME_WIDTH 7 |
7 | #define FRAME_WIDTH 7 |
8 | 8 | ||
9 | extern uint32_t main_cursor; |
9 | extern uint32_t main_cursor; |
10 | 10 | ||
11 | extern uint32_t cursor_ns; |
11 | extern uint32_t cursor_ns; |
12 | extern uint32_t cursor_we; |
12 | extern uint32_t cursor_we; |
13 | extern uint32_t cursor_nwse; |
13 | extern uint32_t cursor_nwse; |
14 | extern uint32_t cursor_nesw; |
14 | extern uint32_t cursor_nesw; |
15 | 15 | ||
16 | extern ctrl_t *mouse_capture; |
16 | extern ctrl_t *mouse_capture; |
17 | 17 | ||
18 | static int frame_proc(ctrl_t *ctrl, uint32_t msg, |
18 | static int frame_proc(ctrl_t *ctrl, uint32_t msg, |
19 | uint32_t arg1, uint32_t arg2); |
19 | uint32_t arg1, uint32_t arg2); |
20 | 20 | ||
21 | void adjust_frame(window_t *win) |
21 | void adjust_frame(window_t *win) |
22 | { |
22 | { |
23 | frame_t *fr = &win->frame; |
23 | frame_t *fr = &win->frame; |
24 | 24 | ||
25 | fr->left.l = 0; |
25 | fr->left.l = 0; |
26 | fr->left.t = win->client.t; |
26 | fr->left.t = win->client.t; |
27 | fr->left.r = FRAME_WIDTH; |
27 | fr->left.r = FRAME_WIDTH; |
28 | fr->left.b = win->h-FRAME_WIDTH; |
28 | fr->left.b = win->h-FRAME_WIDTH; |
29 | 29 | ||
30 | fr->right.l = win->w - FRAME_WIDTH; |
30 | fr->right.l = win->w - FRAME_WIDTH; |
31 | fr->right.t = win->client.t; |
31 | fr->right.t = win->client.t; |
32 | fr->right.r = win->w; |
32 | fr->right.r = win->w; |
33 | fr->right.b = win->h-FRAME_WIDTH; |
33 | fr->right.b = win->h-FRAME_WIDTH; |
34 | 34 | ||
35 | fr->bottom.l = 0; |
35 | fr->bottom.l = 0; |
36 | fr->bottom.t = win->h - FRAME_WIDTH; |
36 | fr->bottom.t = win->h - FRAME_WIDTH; |
37 | fr->bottom.r = win->w; |
37 | fr->bottom.r = win->w; |
38 | fr->bottom.b = win->h; |
38 | fr->bottom.b = win->h; |
39 | 39 | ||
40 | win->client.l = FRAME_WIDTH; |
40 | win->client.l = FRAME_WIDTH; |
41 | win->client.r = win->w - FRAME_WIDTH; |
41 | win->client.r = win->w - FRAME_WIDTH; |
42 | // win->client.b = win->h - FRAME_WIDTH; |
42 | // win->client.b = win->h - FRAME_WIDTH; |
43 | // printf("Left: l:%d t:%d r:%d b:%d\n", |
43 | // printf("Left: l:%d t:%d r:%d b:%d\n", |
44 | // fr->left.l,fr->left.t,fr->left.r,fr->left.b); |
44 | // fr->left.l,fr->left.t,fr->left.r,fr->left.b); |
45 | // printf("Left: l:%d t:%d r:%d b:%d\n", |
45 | // printf("Left: l:%d t:%d r:%d b:%d\n", |
46 | // fr->right.l,fr->right.t,fr->right.r,fr->right.b); |
46 | // fr->right.l,fr->right.t,fr->right.r,fr->right.b); |
47 | // printf("Left: l:%d t:%d r:%d b:%d\n", |
47 | // printf("Left: l:%d t:%d r:%d b:%d\n", |
48 | // fr->bottom.l,fr->bottom.t,fr->bottom.r,fr->bottom.b); |
48 | // fr->bottom.l,fr->bottom.t,fr->bottom.r,fr->bottom.b); |
49 | 49 | ||
50 | }; |
50 | }; |
51 | 51 | ||
52 | void init_frame(window_t *win) |
52 | void init_frame(window_t *win) |
53 | { |
53 | { |
54 | frame_t *fr = &win->frame; |
54 | frame_t *fr = &win->frame; |
55 | 55 | ||
56 | link_initialize(&fr->link); |
56 | link_initialize(&fr->link); |
57 | list_initialize(&fr->child); |
57 | list_initialize(&fr->child); |
58 | 58 | ||
59 | fr->handler = frame_proc; |
59 | fr->handler = frame_proc; |
60 | fr->parent = (ctrl_t*)win; |
60 | fr->parent = (ctrl_t*)win; |
61 | 61 | ||
62 | adjust_frame(win); |
62 | adjust_frame(win); |
63 | }; |
63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | extern int res_border_left[]; |
66 | extern int res_border_left[]; |
67 | extern int res_border_right[]; |
67 | extern int res_border_right[]; |
68 | 68 | ||
- | 69 | #if 0 |
|
69 | int draw_frame(window_t *win) |
70 | int draw_frame(window_t *win) |
70 | { |
71 | { |
- | 72 | void *pixmap_data; |
|
- | 73 | uint32_t pixmap_pitch; |
|
- | 74 | ||
71 | int *pixmap, *src; |
75 | int *pixmap, *src; |
72 | int i, j; |
76 | int i, j; |
73 | 77 | ||
74 | int w; |
78 | int w; |
75 | 79 | ||
76 | frame_t *fr = &win->frame; |
80 | frame_t *fr = &win->frame; |
77 | 81 | ||
78 | pixmap = (int*)win->ctx->pixmap->data; |
82 | pixmap = (int*)win->ctx->pixmap->data; |
79 | pixmap+= CAPTION_HEIGHT*win->w; |
83 | pixmap+= CAPTION_HEIGHT*win->w; |
80 | src = res_border_left; |
84 | src = res_border_left; |
81 | 85 | ||
82 | for(fr->left.t; i < fr->left.b; i++) |
86 | for(fr->left.t; i < fr->left.b; i++) |
83 | { |
87 | { |
84 | for(j = 0; j < FRAME_WIDTH; j++) |
88 | for(j = 0; j < FRAME_WIDTH; j++) |
85 | pixmap[j] = src[j]; |
89 | pixmap[j] = src[j]; |
86 | 90 | ||
87 | pixmap+= win->ctx->pixmap->pitch/4; |
91 | pixmap+= win->ctx->pixmap->pitch/4; |
88 | }; |
92 | }; |
89 | 93 | ||
90 | 94 | ||
91 | pixmap = (int*)win->ctx->pixmap->data; |
95 | pixmap = (int*)win->ctx->pixmap->data; |
92 | pixmap+= (CAPTION_HEIGHT+1)*win->w - FRAME_WIDTH; |
96 | pixmap+= (CAPTION_HEIGHT+1)*win->w - FRAME_WIDTH; |
93 | src = res_border_right; |
97 | src = res_border_right; |
94 | 98 | ||
95 | for(i=fr->right.t; i < fr->right.b; i++) |
99 | for(i=fr->right.t; i < fr->right.b; i++) |
96 | { |
100 | { |
97 | for(j = 0; j < FRAME_WIDTH; j++) |
101 | for(j = 0; j < FRAME_WIDTH; j++) |
98 | pixmap[j] = src[j]; |
102 | pixmap[j] = src[j]; |
99 | 103 | ||
100 | pixmap+= win->ctx->pixmap->pitch/4; |
104 | pixmap+= win->ctx->pixmap->pitch/4; |
101 | }; |
105 | }; |
102 | 106 | ||
103 | pixmap = (int*)win->ctx->pixmap->data; |
107 | pixmap = (int*)win->ctx->pixmap->data; |
104 | 108 | ||
105 | pixmap+= fr->bottom.t * win->w; |
109 | pixmap+= fr->bottom.t * win->w; |
106 | 110 | ||
107 | for(i=0; i < FRAME_WIDTH; i++) |
111 | for(i=0; i < FRAME_WIDTH; i++) |
108 | { |
112 | { |
109 | for(j = 0; j < win->w; j++) |
113 | for(j = 0; j < win->w; j++) |
110 | pixmap[j] = 0x808080; |
114 | pixmap[j] = 0x808080; |
111 | 115 | ||
112 | pixmap+= win->ctx->pixmap->pitch/4; |
116 | pixmap+= win->ctx->pixmap->pitch/4; |
113 | }; |
117 | }; |
114 | 118 | ||
115 | ctrl_t *child; |
119 | ctrl_t *child; |
116 | child = (ctrl_t*)fr->child.next; |
120 | child = (ctrl_t*)fr->child.next; |
117 | 121 | ||
118 | while( &child->link != &fr->child) |
122 | while( &child->link != &fr->child) |
119 | { |
123 | { |
120 | send_message(child, 1, 0, 0); |
124 | send_message(child, 1, 0, 0); |
121 | child = (ctrl_t*)child->link.next; |
125 | child = (ctrl_t*)child->link.next; |
122 | }; |
126 | }; |
123 | 127 | ||
124 | return 0; |
128 | return 0; |
125 | }; |
129 | }; |
126 | 130 | #endif |
|
- | 131 | ||
- | 132 | ||
127 | int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) |
133 | int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) |
128 | { |
134 | { |
129 | static pos_t spos; |
135 | static pos_t spos; |
130 | static track_mode; |
136 | static track_mode; |
131 | 137 | ||
132 | uint32_t cursor; |
138 | uint32_t cursor; |
133 | ctrl_t *child; |
139 | ctrl_t *child; |
134 | 140 | ||
135 | frame_t *fr = (frame_t*)ctrl; |
141 | frame_t *fr = (frame_t*)ctrl; |
136 | window_t *win = (window_t*)fr->parent; |
142 | window_t *win = (window_t*)fr->parent; |
137 | rect_t *rc = NULL; |
143 | rect_t *rc = NULL; |
138 | int x, y; |
144 | int x, y; |
139 | 145 | ||
140 | if(win->win_state == FULLSCREEN) |
146 | if(win->win_state == FULLSCREEN) |
141 | return 0; |
147 | return 0; |
142 | 148 | ||
143 | x = ((pos_t)arg2).x; |
149 | x = ((pos_t)arg2).x; |
144 | y = ((pos_t)arg2).y; |
150 | y = ((pos_t)arg2).y; |
145 | 151 | ||
146 | 152 | ||
147 | // child = get_child(ctrl, x, y); |
153 | // child = get_child(ctrl, x, y); |
148 | // if(child) |
154 | // if(child) |
149 | // { |
155 | // { |
150 | // return send_message(child, msg, 0, arg2); |
156 | // return send_message(child, msg, 0, arg2); |
151 | // }; |
157 | // }; |
152 | 158 | ||
153 | if( (msg == MSG_LBTNDOWN) || |
159 | if( (msg == MSG_LBTNDOWN) || |
154 | (msg == MSG_MOUSEMOVE) ) |
160 | (msg == MSG_MOUSEMOVE) ) |
155 | { |
161 | { |
156 | x = ((pos_t)arg2).x; |
162 | x = ((pos_t)arg2).x; |
157 | y = ((pos_t)arg2).y; |
163 | y = ((pos_t)arg2).y; |
158 | 164 | ||
159 | if( pt_in_rect(&fr->left, x, y)) |
165 | if( pt_in_rect(&fr->left, x, y)) |
160 | { |
166 | { |
161 | rc = &fr->left; |
167 | rc = &fr->left; |
162 | if( (y+24) > win->h) |
168 | if( (y+24) > win->h) |
163 | cursor = cursor_nesw; |
169 | cursor = cursor_nesw; |
164 | else |
170 | else |
165 | cursor = cursor_we; |
171 | cursor = cursor_we; |
166 | set_cursor(cursor); |
172 | set_cursor(cursor); |
167 | main_cursor = cursor; |
173 | main_cursor = cursor; |
168 | } |
174 | } |
169 | else if( pt_in_rect(&fr->right, x, y)) |
175 | else if( pt_in_rect(&fr->right, x, y)) |
170 | { |
176 | { |
171 | // printf("pos x%d y%d\n", x, y); |
177 | // printf("pos x%d y%d\n", x, y); |
172 | 178 | ||
173 | rc = &fr->right; |
179 | rc = &fr->right; |
174 | if( (y+24) > win->h) |
180 | if( (y+24) > win->h) |
175 | cursor = cursor_nwse; |
181 | cursor = cursor_nwse; |
176 | else |
182 | else |
177 | cursor = cursor_we; |
183 | cursor = cursor_we; |
178 | // printf("Set cursor %x\n", cursor); |
184 | // printf("Set cursor %x\n", cursor); |
179 | set_cursor(cursor); |
185 | set_cursor(cursor); |
180 | main_cursor = cursor; |
186 | main_cursor = cursor; |
181 | } |
187 | } |
182 | else if( pt_in_rect(&fr->bottom, x, y)) |
188 | else if( pt_in_rect(&fr->bottom, x, y)) |
183 | { |
189 | { |
184 | rc = &fr->bottom; |
190 | rc = &fr->bottom; |
185 | cursor = cursor_ns; |
191 | cursor = cursor_ns; |
186 | if(x+24 > win->w) |
192 | if(x+24 > win->w) |
187 | cursor = cursor_nwse; |
193 | cursor = cursor_nwse; |
188 | else if(x < rc->l+24) |
194 | else if(x < rc->l+24) |
189 | cursor = cursor_nesw; |
195 | cursor = cursor_nesw; |
190 | set_cursor(cursor); |
196 | set_cursor(cursor); |
191 | main_cursor = cursor; |
197 | main_cursor = cursor; |
192 | } |
198 | } |
193 | }; |
199 | }; |
194 | 200 | ||
195 | switch( msg ) |
201 | switch( msg ) |
196 | { |
202 | { |
197 | case MSG_LBTNDOWN: |
203 | case MSG_LBTNDOWN: |
198 | if( rc != NULL) |
204 | if( rc != NULL) |
199 | { |
205 | { |
200 | int relx, rely; |
206 | int relx, rely; |
201 | 207 | ||
202 | capture_mouse(ctrl); |
208 | capture_mouse(ctrl); |
203 | spos = GetMousePos(POS_SCREEN); |
209 | spos = GetMousePos(POS_SCREEN); |
204 | fr->track = rc; |
210 | fr->track = rc; |
205 | 211 | ||
206 | relx = spos.x - win->rc.l; |
212 | relx = spos.x - win->rc.l; |
207 | rely = spos.y - win->rc.t; |
213 | rely = spos.y - win->rc.t; |
208 | // printf("relx %d rely %d\n", relx, rely); |
214 | // printf("relx %d rely %d\n", relx, rely); |
209 | 215 | ||
210 | if(fr->track == &fr->left || |
216 | if(fr->track == &fr->left || |
211 | fr->track == &fr->right) |
217 | fr->track == &fr->right) |
212 | { |
218 | { |
213 | if(rely+24 > win->h) |
219 | if(rely+24 > win->h) |
214 | track_mode = 1; |
220 | track_mode = 1; |
215 | }; |
221 | }; |
216 | if(fr->track == &fr->bottom) |
222 | if(fr->track == &fr->bottom) |
217 | { |
223 | { |
218 | if(relx < 24) |
224 | if(relx < 24) |
219 | track_mode = 2; |
225 | track_mode = 2; |
220 | else if(relx+24 > win->w) |
226 | else if(relx+24 > win->w) |
221 | track_mode = 3; |
227 | track_mode = 3; |
222 | } |
228 | } |
223 | 229 | ||
224 | break; |
230 | break; |
225 | }; |
231 | }; |
226 | 232 | ||
227 | case MSG_LBTNUP: |
233 | case MSG_LBTNUP: |
228 | release_mouse(); |
234 | release_mouse(); |
229 | fr->track = NULL; |
235 | fr->track = NULL; |
230 | track_mode = 0; |
236 | track_mode = 0; |
231 | break; |
237 | break; |
232 | 238 | ||
233 | case MSG_MOUSEMOVE: |
239 | case MSG_MOUSEMOVE: |
234 | if(mouse_capture == ctrl) |
240 | if(mouse_capture == ctrl) |
235 | { |
241 | { |
236 | pos_t npos; |
242 | pos_t npos; |
237 | npos = GetMousePos(POS_SCREEN); |
243 | npos = GetMousePos(POS_SCREEN); |
238 | // printf("cursor pos %dx%d\n", npos.x, npos.y); |
244 | // printf("cursor pos %dx%d\n", npos.x, npos.y); |
239 | 245 | ||
240 | if( npos.val != spos.val) |
246 | if( npos.val != spos.val) |
241 | { |
247 | { |
242 | int w, h; |
248 | int w, h; |
243 | 249 | ||
244 | rect_t nrc = win->rc; |
250 | rect_t nrc = win->rc; |
245 | spos = npos; |
251 | spos = npos; |
246 | 252 | ||
247 | if(fr->track == &fr->left) |
253 | if(fr->track == &fr->left) |
248 | { |
254 | { |
249 | nrc.l = npos.x-2; |
255 | nrc.l = npos.x-2; |
250 | if(nrc.l < 0) |
256 | if(nrc.l < 0) |
251 | nrc.l = 0; |
257 | nrc.l = 0; |
252 | if(track_mode==1) |
258 | if(track_mode==1) |
253 | nrc.b = npos.y+2; |
259 | nrc.b = npos.y+2; |
254 | } |
260 | } |
255 | else if(fr->track == &fr->right) |
261 | else if(fr->track == &fr->right) |
256 | { |
262 | { |
257 | nrc.r = npos.x+2; |
263 | nrc.r = npos.x+2; |
258 | if(track_mode==1) |
264 | if(track_mode==1) |
259 | nrc.b = npos.y+2; |
265 | nrc.b = npos.y+2; |
260 | } |
266 | } |
261 | else if(fr->track == &fr->bottom) |
267 | else if(fr->track == &fr->bottom) |
262 | { |
268 | { |
263 | nrc.b = npos.y+2; |
269 | nrc.b = npos.y+2; |
264 | if(track_mode==2) |
270 | if(track_mode==2) |
265 | nrc.l = npos.x-2; |
271 | nrc.l = npos.x-2; |
266 | else if (track_mode==3) |
272 | else if (track_mode==3) |
267 | nrc.r = npos.x+2; |
273 | nrc.r = npos.x+2; |
268 | }; |
274 | }; |
269 | 275 | ||
270 | w = nrc.r - nrc.l; |
276 | w = nrc.r - nrc.l; |
271 | h = nrc.b - nrc.t; |
277 | h = nrc.b - nrc.t; |
272 | 278 | ||
273 | if(w <310) |
279 | if(w <310) |
274 | w = 310; |
280 | w = 310; |
275 | if(h < 120) |
281 | if(h < 120) |
276 | h = 120; |
282 | h = 120; |
277 | 283 | ||
278 | __asm__ __volatile__( |
284 | __asm__ __volatile__( |
279 | "int $0x40" |
285 | "int $0x40" |
280 | ::"a"(67), "b"(nrc.l), "c"(nrc.t), |
286 | ::"a"(67), "b"(nrc.l), "c"(nrc.t), |
281 | "d"(w-1),"S"(h-1) ); |
287 | "d"(w-1),"S"(h-1) ); |
282 | }; |
288 | }; |
283 | } |
289 | } |
284 | }; |
290 | }; |
285 | 291 | ||
286 | return 1; |
292 | return 1; |
287 | }>310) |
293 | }>310) |
288 | >>>>>>>>>> |
294 | >>>>>>>>>> |