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