Subversion Repositories Kolibri OS

Rev

Rev 7300 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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