Subversion Repositories Kolibri OS

Rev

Rev 3981 | Rev 4143 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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