Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3981 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;                                                                 ;;
7
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;          Version 2, June 1991                                   ;;
9
;;                                                                 ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
 
12
 
3545 hidnplayr 13
draw_window:
14
 
15
        pusha
16
 
17
        mcall   9, thread_info, -1              ; get current window size
18
        mov     eax, dword[thread_info+42]      ; window xsize
19
        mov     ebx, dword[thread_info+46]      ; ysize
20
        mov     edx, dword[thread_info+62]      ; work area xsize
21
        mov     esi, dword[thread_info+66]      ; ysize
22
        sub     eax, edx
23
        sub     ebx, esi
24
 
25
        cmp     edx, WIN_MIN_X
26
        jae     .x_ok
27
        mov     edx, WIN_MIN_X
28
  .x_ok:
29
        mov     [xsize], edx
30
        add     edx, eax
31
 
32
        cmp     esi, WIN_MIN_Y
33
        jae     .y_ok
34
        mov     esi, WIN_MIN_Y
35
  .y_ok:
36
        mov     [ysize], esi
37
        add     esi, ebx
38
        mcall   67, -1, -1                      ; set the new sizes
39
 
40
        mcall   12, 1
41
        xor     eax, eax                        ; draw window
42
        mov     ebx, WIN_MIN_X
43
        mov     ecx, WIN_MIN_Y
44
        mov     edx, [colors.work]
45
        add     edx, 0x33000000
46
        mov     edi, str_programname
47
        mcall
48
        mcall   12, 2 ;; when do we actually need this??
49
 
50
        mov     ebx, [xsize]
51
        mov     ecx, [ysize]
52
        sub     cx, 15 ;;;;
53
        push    cx
54
        shl     ecx, 16
55
        pop     cx
56
        mov     edx, [colors.work_graph]
57
        mcall   38                              ; draw line
58
 
59
        mov     ecx, TOP_Y SHL 16 + TOP_Y
60
        mcall
61
 
3981 hidnplayr 62
        mov     edi, [window_active]
3545 hidnplayr 63
        cmp     [edi + window.type], WINDOWTYPE_CHANNEL
64
        jne     .not_channel
65
 
66
        ; draw a vertical separator line
67
        mov     ebx, [xsize]
68
        sub     ebx, USERLIST_X + SCROLLBAR_WIDTH + 3
69
        push    bx
70
        shl     ebx, 16
71
        pop     bx
72
        mov     ecx, [ysize]
73
        add     ecx, TOP_Y SHL 16 -(15) ;;;;
74
        mcall
75
 
76
        call    redraw_channel_list
77
 
78
  .not_channel:
79
        mov     edx, [edi + window.data_ptr]
80
        add     edx, window_data.text
81
        call    draw_channel_text
82
 
83
; editbox
84
 
85
        mov     eax, [ysize]
86
        sub     eax, 12 ;;;;;;
87
        mov     [edit1.top], eax
88
 
89
        mov     eax, [xsize]
90
        mov     [edit1.width], eax
91
 
92
        push    dword edit1
93
        call    [edit_box_draw]
94
 
95
; tabs
3981 hidnplayr 96
        call    draw_windowtabs
3545 hidnplayr 97
 
98
        popa
99
        ret
100
 
101
 
102
 
103
redraw_channel_list:
104
 
105
; First, calculate scrollbar
106
 
3981 hidnplayr 107
        mov     ebx, [window_active]
3545 hidnplayr 108
        mov     eax, [ebx + window.users]       ; number of users in the open window
109
        mov     [scroll1.max_area], eax
110
 
111
        mov     eax, [ysize]
112
        sub     eax, TOP_Y + 15 ;;;;
113
        push    eax
114
        mov     [scroll1.y_size], ax
115
 
116
        mov     eax, [xsize]
117
        sub     eax, SCROLLBAR_WIDTH
118
        mov     [scroll1.x_pos], ax
119
 
120
        pop     eax                             ; scrollbar height
121
        xor     edx, edx
122
        mov     ecx, 10
123
        div     ecx
124
        mov     [scroll1.cur_area], eax
125
 
126
        ; Do we need a scrollbar?
127
        cmp     eax, [scroll1.max_area]
128
        jae     .noscroll
129
 
130
        ; Is the current position greater then the max position?
131
        cmp     eax, [scroll1.position]
132
        ja      @f
133
        mov     [scroll1.position], eax
134
  @@:
135
 
136
        ; OK, draw the scrollbar
137
        mov     [scroll1.all_redraw], 1
138
 
139
        push    dword scroll1
140
        call    [scrollbar_v_draw]
141
 
142
        jmp     print_channel_list
143
 
144
  .noscroll:
145
        mov     [scroll1.position], 0
146
 
147
 
148
 
149
print_channel_list:
150
 
151
        pusha
152
 
153
; first, draw an invisible button
154
        mov     ebx, [xsize]
155
        sub     ebx, USERLIST_X + SCROLLBAR_WIDTH
156
        shl     ebx, 16
157
        push    ebx
158
        mov     bx, USERLIST_X
159
        mov     ecx, [ysize]
160
        add     ecx, TEXT_Y shl 16 - (TEXT_Y + 15)        ;;;;;   + 10???
161
        push    ecx ebx
3981 hidnplayr 162
        mov     edx, WINDOW_BTN_LIST + 1 shl 29 + 1 shl 30
3545 hidnplayr 163
        mcall   8
164
 
3981 hidnplayr 165
; draw rectangle to clear previously printed names
3545 hidnplayr 166
        pop     ebx ecx
167
        mov     edx, [colors.work]
168
        mcall   13
169
 
3981 hidnplayr 170
; now draw the names according to the scrollbar position and window size
3545 hidnplayr 171
        mov     eax, [scroll1.position]
172
        xor     edx, edx
173
        mov     ecx, MAX_NICK_LEN
174
        mul     ecx
175
        mov     edx, eax
3981 hidnplayr 176
        mov     eax, [window_active]
3545 hidnplayr 177
        mov     ebp, [eax + window.selected]
178
        add     edx, [eax + window.data_ptr]
179
        sub     ebp, [scroll1.position]
180
        add     edx, window_data.names
181
 
182
        pop     ebx
183
        mov     bx, TEXT_Y
184
        mov     ecx, [colors.work_text]
185
        or      ecx, 0x80000000                 ; ASCIIZ string
186
        mov     eax, 4                          ; draw text
187
 
188
        mov     edi, [ysize]                    ; Calculate how many names will fit on screen
189
        sub     edi, TEXT_Y + 15 ;+ 10           ;;;;;
190
  .loop:
191
        cmp     byte[edx], 0                    ; end of list?
192
        je      .done
193
 
194
        dec     ebp                             ; is this name selected?
195
        jnz     .nothighlight
196
                                                ; yes, highlight it
197
        pusha
198
        mov     cx, bx
199
        mov     bx, USERLIST_X
200
        shl     ecx, 16
201
        mov     cx, 10 - 1
202
        mov     edx, 0x00000055                 ; blue!
203
        mcall   13
204
        popa
205
 
206
        mov     ecx, 0x8000ffff                 ; cyan!
207
        mcall
208
 
209
        mov     ecx, [colors.work_text]
210
        or      ecx, 0x80000000                 ; ASCIIZ string
211
        jmp     .next
212
 
213
  .nothighlight:
214
        mcall
215
 
216
  .next:
217
        add     edx, MAX_NICK_LEN               ; next name
218
        add     ebx, 10                         ; height distance between lines
219
        sub     edi, 10
220
        ja      .loop
221
 
222
  .done:
223
        popa
224
 
225
        ret
226
 
227
 
3981 hidnplayr 228
draw_windowtabs:
3545 hidnplayr 229
 
3981 hidnplayr 230
; Create the buttons
231
 
3545 hidnplayr 232
        mov     eax, 8
233
        mov     ebx, 5 shl 16 + 120
234
        mov     ecx, 12 shl 16 + 12
235
        mov     edx, WINDOW_BTN_START
236
        mov     edi, windows
237
  .more_btn:
238
        mov     esi, [colors.work_button]
3981 hidnplayr 239
        cmp     [window_active], edi
3545 hidnplayr 240
        jne     @f
241
        not     esi
242
        and     esi, 0x00ffffff
243
      @@:
244
        mcall
245
        inc     edx
246
        add     ebx, 125 shl 16
247
        add     edi, sizeof.window
248
        cmp     [edi + window.data_ptr], 0
249
        jne     .more_btn
250
 
3981 hidnplayr 251
; Draw the windownames onto the buttons
252
 
3545 hidnplayr 253
        mov     eax, 4
254
        mov     ebx, 10 shl 16 + 15
3981 hidnplayr 255
        mov     esi, MAX_WINDOWS
256
        mov     edi, windows
257
  .more:
3545 hidnplayr 258
        mov     ecx, [colors.work_button_text]
3981 hidnplayr 259
        test    [edi + window.flags], FLAG_UPDATED
260
        jz      @f
261
        mov     ecx, 0x00aa0000 ; RED!
262
  @@:
3545 hidnplayr 263
        or      ecx, 0x80000000         ; ASCIIZ string
3981 hidnplayr 264
        lea     edx, [edi + window.name]
3545 hidnplayr 265
        mcall
3981 hidnplayr 266
        add     edi, sizeof.window      ; get ptr to next window
267
        cmp     [edi + window.data_ptr], 0
3545 hidnplayr 268
        je      .enough
269
        add     ebx, 125 shl 16
270
        dec     esi
271
        jnz     .more
272
  .enough:
273
 
3981 hidnplayr 274
; Draw the close window button
275
 
276
        mov     edi, [window_active]
277
        cmp     [edi + window.type], WINDOWTYPE_SERVER  ; dont let the user close server window
278
        je      @f
279
 
280
        mov     eax, 8
281
        mov     ebx, [xsize]
282
        sub     ebx, 12
283
        shl     ebx, 16
284
        mov     bx, 12
285
        mov     ecx, 6 shl 16 + 12
286
        mov     edx, WINDOW_BTN_CLOSE
287
;        mov     esi, [colors.work_button]
288
        mov     esi, 0x00aa0000         ; red !
289
        mcall
290
 
291
  @@:
292
 
3545 hidnplayr 293
        ret
294