Subversion Repositories Kolibri OS

Rev

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