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