Rev 4659 | Rev 4669 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3981 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
4622 | hidnplayr | 3 | ;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
3981 | hidnplayr | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
4143 | hidnplayr | 6 | ;; Written by hidnplayr@kolibrios.org ;; |
3981 | hidnplayr | 7 | ;; ;; |
8 | ;; GNU GENERAL PUBLIC LICENSE ;; |
||
9 | ;; Version 2, June 1991 ;; |
||
10 | ;; ;; |
||
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
12 | |||
13 | |||
3545 | hidnplayr | 14 | |
4143 | hidnplayr | 15 | draw_window: ; Completely redraw the window, recalculate all coordinates and sizes |
16 | |||
3545 | hidnplayr | 17 | pusha |
18 | |||
19 | mcall 9, thread_info, -1 ; get current window size |
||
20 | mov eax, dword[thread_info+42] ; window xsize |
||
21 | mov ebx, dword[thread_info+46] ; ysize |
||
22 | mov edx, dword[thread_info+62] ; work area xsize |
||
23 | mov esi, dword[thread_info+66] ; ysize |
||
24 | sub eax, edx |
||
25 | sub ebx, esi |
||
26 | |||
27 | cmp edx, WIN_MIN_X |
||
28 | jae .x_ok |
||
29 | mov edx, WIN_MIN_X |
||
30 | .x_ok: |
||
31 | mov [xsize], edx |
||
32 | add edx, eax |
||
33 | |||
34 | cmp esi, WIN_MIN_Y |
||
35 | jae .y_ok |
||
36 | mov esi, WIN_MIN_Y |
||
37 | .y_ok: |
||
38 | mov [ysize], esi |
||
39 | add esi, ebx |
||
40 | mcall 67, -1, -1 ; set the new sizes |
||
41 | |||
4143 | hidnplayr | 42 | popa |
43 | |||
44 | .dont_resize: |
||
45 | |||
46 | pusha |
||
47 | |||
3545 | hidnplayr | 48 | mcall 12, 1 |
49 | xor eax, eax ; draw window |
||
50 | mov ebx, WIN_MIN_X |
||
51 | mov ecx, WIN_MIN_Y |
||
52 | mov edx, [colors.work] |
||
53 | add edx, 0x33000000 |
||
54 | mov edi, str_programname |
||
55 | mcall |
||
56 | mcall 12, 2 ;; when do we actually need this?? |
||
4668 | gtament | 57 | |
58 | movsx eax, [thread_info+70] ; skip if window rolled up |
||
59 | test eax, 100b |
||
60 | jne .exit |
||
3545 | hidnplayr | 61 | |
62 | mov ebx, [xsize] |
||
63 | mov ecx, [ysize] |
||
4143 | hidnplayr | 64 | sub cx, BOTTOM_Y ;;;; |
3545 | hidnplayr | 65 | push cx |
66 | shl ecx, 16 |
||
67 | pop cx |
||
68 | mov edx, [colors.work_graph] |
||
4143 | hidnplayr | 69 | mcall 38 ; draw bottom line |
3545 | hidnplayr | 70 | mov ecx, TOP_Y SHL 16 + TOP_Y |
4143 | hidnplayr | 71 | mcall ; draw top line |
3545 | hidnplayr | 72 | |
4143 | hidnplayr | 73 | ; calculate available space for textbox and coordinates for scrollbars |
74 | mov eax, [ysize] |
||
75 | sub eax, TOP_Y + BOTTOM_Y - 1 ;;;; |
||
76 | mov [scroll2.y_size], ax |
||
77 | mov [scroll1.y_size], ax |
||
78 | sub eax, 4 ;;;; |
||
79 | xor edx, edx |
||
80 | mov ecx, FONT_HEIGHT |
||
81 | div ecx |
||
82 | mov [textbox_height], eax |
||
83 | mov [scroll2.cur_area], eax |
||
84 | mov [scroll1.cur_area], eax |
||
85 | |||
86 | mov eax, [xsize] |
||
87 | sub eax, SCROLLBAR_WIDTH |
||
88 | mov [scroll1.x_pos], ax |
||
3981 | hidnplayr | 89 | mov edi, [window_active] |
3545 | hidnplayr | 90 | cmp [edi + window.type], WINDOWTYPE_CHANNEL |
4143 | hidnplayr | 91 | jne @f |
92 | sub eax, USERLIST_WIDTH + SCROLLBAR_WIDTH + 2 |
||
93 | @@: |
||
94 | mov [scroll2.x_pos], ax |
||
95 | sub eax, 10 |
||
96 | xor edx, edx |
||
97 | mov ecx, FONT_WIDTH |
||
98 | div ecx |
||
99 | mov [textbox_width], eax |
||
100 | |||
101 | ; recalculate text line breaks (because height/width might have changed..) |
||
4622 | hidnplayr | 102 | ; meanwhile, recalculate line number of current line |
103 | mov esi, [edi + window.text_print] |
||
104 | mov al, byte[esi] |
||
105 | push eax |
||
106 | mov byte[esi], 0 |
||
107 | push esi |
||
108 | |||
4143 | hidnplayr | 109 | mov esi, [edi + window.text_start] |
110 | call text_insert_newlines |
||
111 | mov [edi + window.text_lines], edx |
||
112 | mov [edi + window.text_scanned], esi |
||
4622 | hidnplayr | 113 | mov [edi + window.text_line_print], edx |
4143 | hidnplayr | 114 | |
4622 | hidnplayr | 115 | pop esi |
116 | pop eax |
||
117 | mov byte[esi], al |
||
118 | |||
4143 | hidnplayr | 119 | ; and redraw the textbox (and scrollbar if needed) |
120 | mov [scroll2.all_redraw], 1 |
||
121 | call draw_channel_text |
||
122 | |||
123 | ; Draw userlist if active window is a channel |
||
124 | mov edi, [window_active] |
||
125 | cmp [edi + window.type], WINDOWTYPE_CHANNEL |
||
3545 | hidnplayr | 126 | jne .not_channel |
127 | |||
4659 | hidnplayr | 128 | mov [scroll1.all_redraw], 1 |
129 | call draw_channel_list |
||
130 | |||
131 | ; draw a vertical separator line when there is no scrollbar |
||
132 | cmp [scroll2.all_redraw], 1 |
||
133 | jne .not_channel |
||
134 | |||
3545 | hidnplayr | 135 | mov ebx, [xsize] |
4143 | hidnplayr | 136 | sub ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH + 3 |
3545 | hidnplayr | 137 | push bx |
138 | shl ebx, 16 |
||
139 | pop bx |
||
140 | mov ecx, [ysize] |
||
4659 | hidnplayr | 141 | add ecx, TOP_Y shl 16 - (BOTTOM_Y) |
4143 | hidnplayr | 142 | mov edx, [colors.work_graph] |
143 | mcall 38 |
||
3545 | hidnplayr | 144 | .not_channel: |
145 | |||
4143 | hidnplayr | 146 | ; draw editbox |
3545 | hidnplayr | 147 | mov eax, [ysize] |
4595 | hidnplayr | 148 | sub eax, 13 ;;;;;; |
3545 | hidnplayr | 149 | mov [edit1.top], eax |
150 | |||
151 | mov eax, [xsize] |
||
152 | mov [edit1.width], eax |
||
153 | |||
154 | push dword edit1 |
||
155 | call [edit_box_draw] |
||
156 | |||
4143 | hidnplayr | 157 | ; draw tabs |
3981 | hidnplayr | 158 | call draw_windowtabs |
4668 | gtament | 159 | |
160 | .exit: |
||
3545 | hidnplayr | 161 | popa |
162 | ret |
||
163 | |||
164 | |||
165 | |||
4143 | hidnplayr | 166 | draw_channel_list: |
3545 | hidnplayr | 167 | |
4143 | hidnplayr | 168 | pusha |
3545 | hidnplayr | 169 | |
4143 | hidnplayr | 170 | ; Do we need a scrollbar? |
3981 | hidnplayr | 171 | mov ebx, [window_active] |
4143 | hidnplayr | 172 | mov eax, [ebx + window.users] |
3545 | hidnplayr | 173 | mov [scroll1.max_area], eax |
4143 | hidnplayr | 174 | cmp [scroll1.cur_area], eax |
3545 | hidnplayr | 175 | jae .noscroll |
176 | |||
177 | ; Is the current position greater then the max position? |
||
178 | cmp eax, [scroll1.position] |
||
179 | ja @f |
||
180 | mov [scroll1.position], eax |
||
181 | @@: |
||
182 | ; OK, draw the scrollbar |
||
183 | push dword scroll1 |
||
4143 | hidnplayr | 184 | call [scrollbar_draw] |
3545 | hidnplayr | 185 | |
4143 | hidnplayr | 186 | ; dont redraw scrollbar completely next time, |
187 | ; unless draw_window asks us to by setting [scroll1.all_redraw] back to 1 |
||
188 | mov [scroll1.all_redraw], 0 |
||
189 | jmp .scroll_done |
||
3545 | hidnplayr | 190 | |
191 | .noscroll: |
||
192 | mov [scroll1.position], 0 |
||
4143 | hidnplayr | 193 | .scroll_done: |
3545 | hidnplayr | 194 | |
4143 | hidnplayr | 195 | ; draw an invisible button, where the usernames will go |
3545 | hidnplayr | 196 | mov ebx, [xsize] |
4143 | hidnplayr | 197 | sub ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH |
3545 | hidnplayr | 198 | shl ebx, 16 |
199 | push ebx |
||
4143 | hidnplayr | 200 | mov bx, USERLIST_WIDTH |
3545 | hidnplayr | 201 | mov ecx, [ysize] |
4143 | hidnplayr | 202 | add ecx, TEXT_Y shl 16 - (TEXT_Y + 16) |
3545 | hidnplayr | 203 | push ecx ebx |
3981 | hidnplayr | 204 | mov edx, WINDOW_BTN_LIST + 1 shl 29 + 1 shl 30 |
3545 | hidnplayr | 205 | mcall 8 |
206 | |||
4143 | hidnplayr | 207 | ; draw a filled rectangle to clear previously printed names |
3545 | hidnplayr | 208 | pop ebx ecx |
209 | mov edx, [colors.work] |
||
210 | mcall 13 |
||
211 | |||
4143 | hidnplayr | 212 | ; now, draw the names according to the scrollbar position and window size |
3545 | hidnplayr | 213 | mov eax, [scroll1.position] |
214 | xor edx, edx |
||
215 | mov ecx, MAX_NICK_LEN |
||
216 | mul ecx |
||
217 | mov edx, eax |
||
3981 | hidnplayr | 218 | mov eax, [window_active] |
3545 | hidnplayr | 219 | mov ebp, [eax + window.selected] |
220 | add edx, [eax + window.data_ptr] |
||
221 | sub ebp, [scroll1.position] |
||
222 | add edx, window_data.names |
||
223 | |||
224 | pop ebx |
||
225 | mov bx, TEXT_Y |
||
226 | mov ecx, [colors.work_text] |
||
227 | or ecx, 0x80000000 ; ASCIIZ string |
||
228 | mov eax, 4 ; draw text |
||
229 | |||
4143 | hidnplayr | 230 | mov edi, [textbox_height] ; how many names will fit on screen |
3545 | hidnplayr | 231 | .loop: |
232 | cmp byte[edx], 0 ; end of list? |
||
233 | je .done |
||
234 | |||
235 | dec ebp ; is this name selected? |
||
236 | jnz .nothighlight |
||
237 | ; yes, highlight it |
||
238 | pusha |
||
239 | mov cx, bx |
||
4143 | hidnplayr | 240 | mov bx, USERLIST_WIDTH |
3545 | hidnplayr | 241 | shl ecx, 16 |
242 | mov cx, 10 - 1 |
||
243 | mov edx, 0x00000055 ; blue! |
||
244 | mcall 13 |
||
245 | popa |
||
246 | |||
247 | mov ecx, 0x8000ffff ; cyan! |
||
248 | mcall |
||
249 | |||
250 | mov ecx, [colors.work_text] |
||
251 | or ecx, 0x80000000 ; ASCIIZ string |
||
252 | jmp .next |
||
253 | |||
254 | .nothighlight: |
||
255 | mcall |
||
256 | |||
257 | .next: |
||
4143 | hidnplayr | 258 | add edx, MAX_NICK_LEN |
259 | add ebx, FONT_HEIGHT |
||
260 | dec edi |
||
261 | jnz .loop |
||
3545 | hidnplayr | 262 | |
263 | .done: |
||
264 | popa |
||
265 | |||
266 | ret |
||
267 | |||
268 | |||
3981 | hidnplayr | 269 | draw_windowtabs: |
3545 | hidnplayr | 270 | |
3981 | hidnplayr | 271 | ; Create the buttons |
272 | |||
3545 | hidnplayr | 273 | mov eax, 8 |
274 | mov ebx, 5 shl 16 + 120 |
||
275 | mov ecx, 12 shl 16 + 12 |
||
276 | mov edx, WINDOW_BTN_START |
||
277 | mov edi, windows |
||
278 | .more_btn: |
||
279 | mov esi, [colors.work_button] |
||
3981 | hidnplayr | 280 | cmp [window_active], edi |
3545 | hidnplayr | 281 | jne @f |
282 | not esi |
||
283 | and esi, 0x00ffffff |
||
284 | @@: |
||
285 | mcall |
||
286 | inc edx |
||
287 | add ebx, 125 shl 16 |
||
288 | add edi, sizeof.window |
||
289 | cmp [edi + window.data_ptr], 0 |
||
290 | jne .more_btn |
||
291 | |||
4623 | hidnplayr | 292 | ; Draw the close window button |
293 | |||
294 | mov edi, [window_active] |
||
295 | cmp [edi + window.type], WINDOWTYPE_SERVER ; dont let the user close server window |
||
296 | je @f |
||
297 | |||
298 | ; mov eax, 8 |
||
299 | mov ebx, [xsize] |
||
300 | sub ebx, 12 |
||
301 | shl ebx, 16 |
||
302 | mov bx, 12 |
||
303 | mov ecx, 6 shl 16 + 12 |
||
304 | mov edx, WINDOW_BTN_CLOSE |
||
305 | mov esi, 0x00aa0000 ; red ! |
||
306 | mcall |
||
307 | @@: |
||
308 | |||
3981 | hidnplayr | 309 | ; Draw the windownames onto the buttons |
310 | |||
3545 | hidnplayr | 311 | mov eax, 4 |
312 | mov ebx, 10 shl 16 + 15 |
||
3981 | hidnplayr | 313 | mov esi, MAX_WINDOWS |
314 | mov edi, windows |
||
315 | .more: |
||
3545 | hidnplayr | 316 | mov ecx, [colors.work_button_text] |
3981 | hidnplayr | 317 | test [edi + window.flags], FLAG_UPDATED |
318 | jz @f |
||
319 | mov ecx, 0x00aa0000 ; RED! |
||
320 | @@: |
||
3545 | hidnplayr | 321 | or ecx, 0x80000000 ; ASCIIZ string |
3981 | hidnplayr | 322 | lea edx, [edi + window.name] |
3545 | hidnplayr | 323 | mcall |
3981 | hidnplayr | 324 | add edi, sizeof.window ; get ptr to next window |
325 | cmp [edi + window.data_ptr], 0 |
||
3545 | hidnplayr | 326 | je .enough |
327 | add ebx, 125 shl 16 |
||
328 | dec esi |
||
329 | jnz .more |
||
330 | .enough: |
||
331 | |||
4623 | hidnplayr | 332 | ret |
3981 | hidnplayr | 333 | |
334 | |||
4623 | hidnplayr | 335 | |
336 | highlight_updated_tabs: |
||
337 | mov eax, 4 |
||
338 | mov ebx, 10 shl 16 + 15 |
||
339 | mov ecx, 0x80aa0000 |
||
340 | mov esi, MAX_WINDOWS |
||
341 | mov edi, windows |
||
342 | .more_: |
||
343 | test [edi + window.flags], FLAG_UPDATED |
||
344 | jz .next |
||
345 | lea edx, [edi + window.name] |
||
3981 | hidnplayr | 346 | mcall |
4623 | hidnplayr | 347 | .next: |
348 | add edi, sizeof.window ; get ptr to next window |
||
349 | cmp [edi + window.data_ptr], 0 |
||
350 | je .enough_ |
||
351 | add ebx, 125 shl 16 |
||
352 | dec esi |
||
353 | jnz .more_ |
||
354 | .enough_: |
||
3981 | hidnplayr | 355 | |
4623 | hidnplayr | 356 | ret |