Subversion Repositories Kolibri OS

Rev

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