Subversion Repositories Kolibri OS

Rev

Rev 4060 | Rev 4595 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4060 Rev 4143
Line 1... Line 1...
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
;;   Written by hidnplayr@kolibrios.org                            ;;
6
;;                                                                 ;;
7
;;                                                                 ;;
7
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;          Version 2, June 1991                                   ;;
9
;;          Version 2, June 1991                                   ;;
9
;;                                                                 ;;
10
;;                                                                 ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 12...
-
 
12
 
11
 
13
 
Line 12... Line 14...
12
 
14
 
Line 13... Line 15...
13
draw_window:
15
draw_window:    ; Completely redraw the window, recalculate all coordinates and sizes
14
 
16
 
Line 35... Line 37...
35
  .y_ok:
37
  .y_ok:
36
        mov     [ysize], esi
38
        mov     [ysize], esi
37
        add     esi, ebx
39
        add     esi, ebx
38
        mcall   67, -1, -1                      ; set the new sizes
40
        mcall   67, -1, -1                      ; set the new sizes
Line -... Line 41...
-
 
41
 
-
 
42
        popa
-
 
43
 
-
 
44
  .dont_resize:
-
 
45
 
-
 
46
        pusha
39
 
47
 
40
        mcall   12, 1
48
        mcall   12, 1
41
        xor     eax, eax                        ; draw window
49
        xor     eax, eax                        ; draw window
42
        mov     ebx, WIN_MIN_X
50
        mov     ebx, WIN_MIN_X
43
        mov     ecx, WIN_MIN_Y
51
        mov     ecx, WIN_MIN_Y
Line 47... Line 55...
47
        mcall
55
        mcall
48
        mcall   12, 2 ;; when do we actually need this??
56
        mcall   12, 2 ;; when do we actually need this??
Line 49... Line 57...
49
 
57
 
50
        mov     ebx, [xsize]
58
        mov     ebx, [xsize]
51
        mov     ecx, [ysize]
59
        mov     ecx, [ysize]
52
        sub     cx, 15 ;;;;
60
        sub     cx, BOTTOM_Y ;;;;
53
        push    cx
61
        push    cx
54
        shl     ecx, 16
62
        shl     ecx, 16
55
        pop     cx
63
        pop     cx
56
        mov     edx, [colors.work_graph]
64
        mov     edx, [colors.work_graph]
57
        mcall   38                              ; draw line
-
 
58
 
65
        mcall   38                              ; draw bottom line
-
 
66
        mov     ecx, TOP_Y SHL 16 + TOP_Y
-
 
67
        mcall                                   ; draw top line
-
 
68
 
-
 
69
; calculate available space for textbox and coordinates for scrollbars
-
 
70
        mov     eax, [ysize]
-
 
71
        sub     eax, TOP_Y + BOTTOM_Y - 1   ;;;;
-
 
72
        mov     [scroll2.y_size], ax
-
 
73
        mov     [scroll1.y_size], ax
-
 
74
        sub     eax, 4 ;;;;
-
 
75
        xor     edx, edx
59
        mov     ecx, TOP_Y SHL 16 + TOP_Y
76
        mov     ecx, FONT_HEIGHT
-
 
77
        div     ecx
-
 
78
        mov     [textbox_height], eax
-
 
79
        mov     [scroll2.cur_area], eax
Line -... Line 80...
-
 
80
        mov     [scroll1.cur_area], eax
-
 
81
 
-
 
82
        mov     eax, [xsize]
-
 
83
        sub     eax, SCROLLBAR_WIDTH
-
 
84
        mov     [scroll1.x_pos], ax
-
 
85
        mov     edi, [window_active]
-
 
86
        cmp     [edi + window.type], WINDOWTYPE_CHANNEL
-
 
87
        jne     @f
-
 
88
        sub     eax, USERLIST_WIDTH + SCROLLBAR_WIDTH + 2
-
 
89
  @@:
-
 
90
        mov     [scroll2.x_pos], ax
-
 
91
        sub     eax, 10
-
 
92
        xor     edx, edx
-
 
93
        mov     ecx, FONT_WIDTH
-
 
94
        div     ecx
-
 
95
        mov     [textbox_width], eax
-
 
96
 
-
 
97
; recalculate text line breaks (because height/width might have changed..)
-
 
98
        mov     edi, [window_active]
-
 
99
        mov     esi, [edi + window.text_start]
-
 
100
        call    text_insert_newlines
-
 
101
        mov     [edi + window.text_lines], edx
-
 
102
        mov     [edi + window.text_scanned], esi
-
 
103
 
-
 
104
; and redraw the textbox (and scrollbar if needed)
-
 
105
        mov     [scroll2.all_redraw], 1
-
 
106
        call    draw_channel_text
60
        mcall
107
 
61
 
108
; Draw userlist if active window is a channel
62
        mov     edi, [window_active]
109
        mov     edi, [window_active]
Line 63... Line 110...
63
        cmp     [edi + window.type], WINDOWTYPE_CHANNEL
110
        cmp     [edi + window.type], WINDOWTYPE_CHANNEL
-
 
111
        jne     .not_channel
64
        jne     .not_channel
112
 
65
 
113
        ; draw a vertical separator line
66
        ; draw a vertical separator line
114
        ; TODO: dont draw this if we draw textbox scrollbar ??
67
        mov     ebx, [xsize]
115
        mov     ebx, [xsize]
68
        sub     ebx, USERLIST_X + SCROLLBAR_WIDTH + 3
116
        sub     ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH + 3
69
        push    bx
117
        push    bx
70
        shl     ebx, 16
118
        shl     ebx, 16
71
        pop     bx
119
        pop     bx
72
        mov     ecx, [ysize]
-
 
73
        add     ecx, TOP_Y SHL 16 -(15) ;;;;
120
        mov     ecx, [ysize]
Line -... Line 121...
-
 
121
        add     ecx, TOP_Y SHL 16 -(BOTTOM_Y) ;;;;
-
 
122
        mov     edx, [colors.work_graph]
74
        mcall
123
        mcall   38
75
 
-
 
76
        call    redraw_channel_list
-
 
77
 
-
 
78
  .not_channel:
-
 
79
        mov     edx, [edi + window.data_ptr]
-
 
Line -... Line 124...
-
 
124
 
80
        add     edx, window_data.text
125
        mov     [scroll1.all_redraw], 1
81
        call    draw_channel_text
126
        call    draw_channel_list
82
 
127
  .not_channel:
Line 83... Line 128...
83
; editbox
128
 
84
 
129
; draw editbox
Line 85... Line 130...
85
        mov     eax, [ysize]
130
        mov     eax, [ysize]
86
        sub     eax, 12 ;;;;;;
131
        sub     eax, 12 ;;;;;;
Line 87... Line 132...
87
        mov     [edit1.top], eax
132
        mov     [edit1.top], eax
88
 
133
 
Line 89... Line 134...
89
        mov     eax, [xsize]
134
        mov     eax, [xsize]
90
        mov     [edit1.width], eax
135
        mov     [edit1.width], eax
Line 91... Line 136...
91
 
136
 
Line 92... Line 137...
92
        push    dword edit1
137
        push    dword edit1
Line -... Line 138...
-
 
138
        call    [edit_box_draw]
93
        call    [edit_box_draw]
139
 
94
 
140
; draw tabs
95
; tabs
141
        call    draw_windowtabs
96
        call    draw_windowtabs
-
 
97
 
-
 
98
        popa
-
 
99
        ret
-
 
100
 
-
 
101
 
-
 
102
 
-
 
103
redraw_channel_list:
-
 
104
 
-
 
105
; First, calculate scrollbar
-
 
106
 
-
 
107
        mov     ebx, [window_active]
-
 
108
        mov     eax, [ebx + window.users]       ; number of users in the open window
-
 
109
        mov     [scroll1.max_area], eax
-
 
110
 
142
 
111
        mov     eax, [ysize]
-
 
112
        sub     eax, TOP_Y + 15 ;;;;
-
 
113
        push    eax
-
 
114
        mov     [scroll1.y_size], ax
143
        popa
Line 115... Line 144...
115
 
144
        ret
116
        mov     eax, [xsize]
145
 
117
        sub     eax, SCROLLBAR_WIDTH
146
 
118
        mov     [scroll1.x_pos], ax
147
 
119
 
148
draw_channel_list:
120
        pop     eax                             ; scrollbar height
-
 
121
        xor     edx, edx
149
 
122
        mov     ecx, 10
-
 
123
        div     ecx
-
 
124
        mov     [scroll1.cur_area], eax
150
        pusha
125
 
151
 
Line -... Line 152...
-
 
152
        ; Do we need a scrollbar?
-
 
153
        mov     ebx, [window_active]
-
 
154
        mov     eax, [ebx + window.users]
126
        ; Do we need a scrollbar?
155
        mov     [scroll1.max_area], eax
Line 127... Line 156...
127
        cmp     eax, [scroll1.max_area]
156
        cmp     [scroll1.cur_area], eax
128
        jae     .noscroll
157
        jae     .noscroll
-
 
158
 
Line 129... Line -...
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
 
159
        ; Is the current position greater then the max position?
136
        ; OK, draw the scrollbar
160
        cmp     eax, [scroll1.position]
137
        mov     [scroll1.all_redraw], 1
161
        ja      @f
138
 
162
        mov     [scroll1.position], eax
139
        push    dword scroll1
163
  @@:
140
        call    [scrollbar_v_draw]
164
        ; OK, draw the scrollbar
141
 
165
        push    dword scroll1
142
        jmp     print_channel_list
166
        call    [scrollbar_draw]
143
 
167
 
144
  .noscroll:
168
        ; dont redraw scrollbar completely next time,
145
        mov     [scroll1.position], 0
169
        ; unless draw_window asks us to by setting [scroll1.all_redraw] back to 1
Line 146... Line 170...
146
 
170
        mov     [scroll1.all_redraw], 0
147
 
171
        jmp     .scroll_done
148
 
172
 
149
print_channel_list:
173
  .noscroll:
Line 150... Line 174...
150
 
174
        mov     [scroll1.position], 0
151
        pusha
175
  .scroll_done:
152
 
176
 
153
; first, draw an invisible button
177
        ; draw an invisible button, where the usernames will go
154
        mov     ebx, [xsize]
178
        mov     ebx, [xsize]
155
        sub     ebx, USERLIST_X + SCROLLBAR_WIDTH
179
        sub     ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH
Line 183... Line 207...
183
        mov     bx, TEXT_Y
207
        mov     bx, TEXT_Y
184
        mov     ecx, [colors.work_text]
208
        mov     ecx, [colors.work_text]
185
        or      ecx, 0x80000000                 ; ASCIIZ string
209
        or      ecx, 0x80000000                 ; ASCIIZ string
186
        mov     eax, 4                          ; draw text
210
        mov     eax, 4                          ; draw text
Line 187... Line 211...
187
 
211
 
188
        mov     edi, [ysize]                    ; Calculate how many names will fit on screen
-
 
189
        sub     edi, TEXT_Y + 15 ;+ 10           ;;;;;
212
        mov     edi, [textbox_height]           ; how many names will fit on screen
190
  .loop:
213
  .loop:
191
        cmp     byte[edx], 0                    ; end of list?
214
        cmp     byte[edx], 0                    ; end of list?
Line 192... Line 215...
192
        je      .done
215
        je      .done
193
 
216
 
194
        dec     ebp                             ; is this name selected?
217
        dec     ebp                             ; is this name selected?
195
        jnz     .nothighlight
218
        jnz     .nothighlight
196
                                                ; yes, highlight it
219
                                                ; yes, highlight it
197
        pusha
220
        pusha
198
        mov     cx, bx
221
        mov     cx, bx
199
        mov     bx, USERLIST_X
222
        mov     bx, USERLIST_WIDTH
200
        shl     ecx, 16
223
        shl     ecx, 16
201
        mov     cx, 10 - 1
224
        mov     cx, 10 - 1
202
        mov     edx, 0x00000055                 ; blue!
225
        mov     edx, 0x00000055                 ; blue!
Line 212... Line 235...
212
 
235
 
213
  .nothighlight:
236
  .nothighlight:
Line 214... Line 237...
214
        mcall
237
        mcall
215
 
238
 
216
  .next:
239
  .next:
217
        add     edx, MAX_NICK_LEN               ; next name
240
        add     edx, MAX_NICK_LEN
218
        add     ebx, 10                         ; height distance between lines
241
        add     ebx, FONT_HEIGHT
Line 219... Line 242...
219
        sub     edi, 10
242
        dec     edi
220
        ja      .loop
243
        jnz     .loop
Line 221... Line 244...
221
 
244