Subversion Repositories Kolibri OS

Rev

Rev 7889 | Details | Compare with Previous | Last modification | View Log | RSS feed

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