2013-10-07 18:02:05 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2013-11-01 18:02:08 +04:00
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2013-10-07 18:02:05 +04:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
draw_window: ; Completely redraw the window, recalculate all coordinates and sizes
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
pusha
|
|
|
|
|
|
|
|
mcall 9, thread_info, -1 ; get current window size
|
|
|
|
mov eax, dword[thread_info+42] ; window xsize
|
|
|
|
mov ebx, dword[thread_info+46] ; ysize
|
|
|
|
mov edx, dword[thread_info+62] ; work area xsize
|
|
|
|
mov esi, dword[thread_info+66] ; ysize
|
|
|
|
sub eax, edx
|
|
|
|
sub ebx, esi
|
|
|
|
|
|
|
|
cmp edx, WIN_MIN_X
|
|
|
|
jae .x_ok
|
|
|
|
mov edx, WIN_MIN_X
|
|
|
|
.x_ok:
|
|
|
|
mov [xsize], edx
|
|
|
|
add edx, eax
|
|
|
|
|
|
|
|
cmp esi, WIN_MIN_Y
|
|
|
|
jae .y_ok
|
|
|
|
mov esi, WIN_MIN_Y
|
|
|
|
.y_ok:
|
|
|
|
mov [ysize], esi
|
|
|
|
add esi, ebx
|
|
|
|
mcall 67, -1, -1 ; set the new sizes
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
popa
|
|
|
|
|
|
|
|
.dont_resize:
|
|
|
|
|
|
|
|
pusha
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mcall 12, 1
|
|
|
|
xor eax, eax ; draw window
|
|
|
|
mov ebx, WIN_MIN_X
|
|
|
|
mov ecx, WIN_MIN_Y
|
|
|
|
mov edx, [colors.work]
|
|
|
|
add edx, 0x33000000
|
|
|
|
mov edi, str_programname
|
|
|
|
mcall
|
|
|
|
mcall 12, 2 ;; when do we actually need this??
|
|
|
|
|
|
|
|
mov ebx, [xsize]
|
|
|
|
mov ecx, [ysize]
|
2013-11-01 18:02:08 +04:00
|
|
|
sub cx, BOTTOM_Y ;;;;
|
2013-05-28 21:34:26 +04:00
|
|
|
push cx
|
|
|
|
shl ecx, 16
|
|
|
|
pop cx
|
|
|
|
mov edx, [colors.work_graph]
|
2013-11-01 18:02:08 +04:00
|
|
|
mcall 38 ; draw bottom line
|
2013-05-28 21:34:26 +04:00
|
|
|
mov ecx, TOP_Y SHL 16 + TOP_Y
|
2013-11-01 18:02:08 +04:00
|
|
|
mcall ; draw top line
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; calculate available space for textbox and coordinates for scrollbars
|
|
|
|
mov eax, [ysize]
|
|
|
|
sub eax, TOP_Y + BOTTOM_Y - 1 ;;;;
|
|
|
|
mov [scroll2.y_size], ax
|
|
|
|
mov [scroll1.y_size], ax
|
|
|
|
sub eax, 4 ;;;;
|
|
|
|
xor edx, edx
|
|
|
|
mov ecx, FONT_HEIGHT
|
|
|
|
div ecx
|
|
|
|
mov [textbox_height], eax
|
|
|
|
mov [scroll2.cur_area], eax
|
|
|
|
mov [scroll1.cur_area], eax
|
|
|
|
|
|
|
|
mov eax, [xsize]
|
|
|
|
sub eax, SCROLLBAR_WIDTH
|
|
|
|
mov [scroll1.x_pos], ax
|
|
|
|
mov edi, [window_active]
|
|
|
|
cmp [edi + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
jne @f
|
|
|
|
sub eax, USERLIST_WIDTH + SCROLLBAR_WIDTH + 2
|
|
|
|
@@:
|
|
|
|
mov [scroll2.x_pos], ax
|
|
|
|
sub eax, 10
|
|
|
|
xor edx, edx
|
|
|
|
mov ecx, FONT_WIDTH
|
|
|
|
div ecx
|
|
|
|
mov [textbox_width], eax
|
|
|
|
|
|
|
|
; recalculate text line breaks (because height/width might have changed..)
|
|
|
|
mov edi, [window_active]
|
|
|
|
mov esi, [edi + window.text_start]
|
|
|
|
call text_insert_newlines
|
|
|
|
mov [edi + window.text_lines], edx
|
|
|
|
mov [edi + window.text_scanned], esi
|
|
|
|
|
|
|
|
; and redraw the textbox (and scrollbar if needed)
|
|
|
|
mov [scroll2.all_redraw], 1
|
|
|
|
call draw_channel_text
|
|
|
|
|
|
|
|
; Draw userlist if active window is a channel
|
2013-10-07 18:02:05 +04:00
|
|
|
mov edi, [window_active]
|
2013-05-28 21:34:26 +04:00
|
|
|
cmp [edi + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
jne .not_channel
|
|
|
|
|
|
|
|
; draw a vertical separator line
|
2013-11-01 18:02:08 +04:00
|
|
|
; TODO: dont draw this if we draw textbox scrollbar ??
|
2013-05-28 21:34:26 +04:00
|
|
|
mov ebx, [xsize]
|
2013-11-01 18:02:08 +04:00
|
|
|
sub ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH + 3
|
2013-05-28 21:34:26 +04:00
|
|
|
push bx
|
|
|
|
shl ebx, 16
|
|
|
|
pop bx
|
|
|
|
mov ecx, [ysize]
|
2013-11-01 18:02:08 +04:00
|
|
|
add ecx, TOP_Y SHL 16 -(BOTTOM_Y) ;;;;
|
|
|
|
mov edx, [colors.work_graph]
|
|
|
|
mcall 38
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [scroll1.all_redraw], 1
|
|
|
|
call draw_channel_list
|
2013-05-28 21:34:26 +04:00
|
|
|
.not_channel:
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; draw editbox
|
2013-05-28 21:34:26 +04:00
|
|
|
mov eax, [ysize]
|
|
|
|
sub eax, 12 ;;;;;;
|
|
|
|
mov [edit1.top], eax
|
|
|
|
|
|
|
|
mov eax, [xsize]
|
|
|
|
mov [edit1.width], eax
|
|
|
|
|
|
|
|
push dword edit1
|
|
|
|
call [edit_box_draw]
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; draw tabs
|
2013-10-07 18:02:05 +04:00
|
|
|
call draw_windowtabs
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
popa
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
draw_channel_list:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
pusha
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; Do we need a scrollbar?
|
2013-10-07 18:02:05 +04:00
|
|
|
mov ebx, [window_active]
|
2013-11-01 18:02:08 +04:00
|
|
|
mov eax, [ebx + window.users]
|
2013-05-28 21:34:26 +04:00
|
|
|
mov [scroll1.max_area], eax
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp [scroll1.cur_area], eax
|
2013-05-28 21:34:26 +04:00
|
|
|
jae .noscroll
|
|
|
|
|
|
|
|
; Is the current position greater then the max position?
|
|
|
|
cmp eax, [scroll1.position]
|
|
|
|
ja @f
|
|
|
|
mov [scroll1.position], eax
|
|
|
|
@@:
|
|
|
|
; OK, draw the scrollbar
|
|
|
|
push dword scroll1
|
2013-11-01 18:02:08 +04:00
|
|
|
call [scrollbar_draw]
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; dont redraw scrollbar completely next time,
|
|
|
|
; unless draw_window asks us to by setting [scroll1.all_redraw] back to 1
|
|
|
|
mov [scroll1.all_redraw], 0
|
|
|
|
jmp .scroll_done
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
.noscroll:
|
|
|
|
mov [scroll1.position], 0
|
2013-11-01 18:02:08 +04:00
|
|
|
.scroll_done:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; draw an invisible button, where the usernames will go
|
2013-05-28 21:34:26 +04:00
|
|
|
mov ebx, [xsize]
|
2013-11-01 18:02:08 +04:00
|
|
|
sub ebx, USERLIST_WIDTH + SCROLLBAR_WIDTH
|
2013-05-28 21:34:26 +04:00
|
|
|
shl ebx, 16
|
|
|
|
push ebx
|
2013-11-01 18:02:08 +04:00
|
|
|
mov bx, USERLIST_WIDTH
|
2013-05-28 21:34:26 +04:00
|
|
|
mov ecx, [ysize]
|
2013-11-01 18:02:08 +04:00
|
|
|
add ecx, TEXT_Y shl 16 - (TEXT_Y + 16)
|
2013-05-28 21:34:26 +04:00
|
|
|
push ecx ebx
|
2013-10-07 18:02:05 +04:00
|
|
|
mov edx, WINDOW_BTN_LIST + 1 shl 29 + 1 shl 30
|
2013-05-28 21:34:26 +04:00
|
|
|
mcall 8
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; draw a filled rectangle to clear previously printed names
|
2013-05-28 21:34:26 +04:00
|
|
|
pop ebx ecx
|
|
|
|
mov edx, [colors.work]
|
|
|
|
mcall 13
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; now, draw the names according to the scrollbar position and window size
|
2013-05-28 21:34:26 +04:00
|
|
|
mov eax, [scroll1.position]
|
|
|
|
xor edx, edx
|
|
|
|
mov ecx, MAX_NICK_LEN
|
|
|
|
mul ecx
|
|
|
|
mov edx, eax
|
2013-10-07 18:02:05 +04:00
|
|
|
mov eax, [window_active]
|
2013-05-28 21:34:26 +04:00
|
|
|
mov ebp, [eax + window.selected]
|
|
|
|
add edx, [eax + window.data_ptr]
|
|
|
|
sub ebp, [scroll1.position]
|
|
|
|
add edx, window_data.names
|
|
|
|
|
|
|
|
pop ebx
|
|
|
|
mov bx, TEXT_Y
|
|
|
|
mov ecx, [colors.work_text]
|
|
|
|
or ecx, 0x80000000 ; ASCIIZ string
|
|
|
|
mov eax, 4 ; draw text
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov edi, [textbox_height] ; how many names will fit on screen
|
2013-05-28 21:34:26 +04:00
|
|
|
.loop:
|
|
|
|
cmp byte[edx], 0 ; end of list?
|
|
|
|
je .done
|
|
|
|
|
|
|
|
dec ebp ; is this name selected?
|
|
|
|
jnz .nothighlight
|
|
|
|
; yes, highlight it
|
|
|
|
pusha
|
|
|
|
mov cx, bx
|
2013-11-01 18:02:08 +04:00
|
|
|
mov bx, USERLIST_WIDTH
|
2013-05-28 21:34:26 +04:00
|
|
|
shl ecx, 16
|
|
|
|
mov cx, 10 - 1
|
|
|
|
mov edx, 0x00000055 ; blue!
|
|
|
|
mcall 13
|
|
|
|
popa
|
|
|
|
|
|
|
|
mov ecx, 0x8000ffff ; cyan!
|
|
|
|
mcall
|
|
|
|
|
|
|
|
mov ecx, [colors.work_text]
|
|
|
|
or ecx, 0x80000000 ; ASCIIZ string
|
|
|
|
jmp .next
|
|
|
|
|
|
|
|
.nothighlight:
|
|
|
|
mcall
|
|
|
|
|
|
|
|
.next:
|
2013-11-01 18:02:08 +04:00
|
|
|
add edx, MAX_NICK_LEN
|
|
|
|
add ebx, FONT_HEIGHT
|
|
|
|
dec edi
|
|
|
|
jnz .loop
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
.done:
|
|
|
|
popa
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
draw_windowtabs:
|
|
|
|
|
|
|
|
; Create the buttons
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mov eax, 8
|
|
|
|
mov ebx, 5 shl 16 + 120
|
|
|
|
mov ecx, 12 shl 16 + 12
|
|
|
|
mov edx, WINDOW_BTN_START
|
|
|
|
mov edi, windows
|
|
|
|
.more_btn:
|
|
|
|
mov esi, [colors.work_button]
|
2013-10-07 18:02:05 +04:00
|
|
|
cmp [window_active], edi
|
2013-05-28 21:34:26 +04:00
|
|
|
jne @f
|
|
|
|
not esi
|
|
|
|
and esi, 0x00ffffff
|
|
|
|
@@:
|
|
|
|
mcall
|
|
|
|
inc edx
|
|
|
|
add ebx, 125 shl 16
|
|
|
|
add edi, sizeof.window
|
|
|
|
cmp [edi + window.data_ptr], 0
|
|
|
|
jne .more_btn
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
; Draw the windownames onto the buttons
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mov eax, 4
|
|
|
|
mov ebx, 10 shl 16 + 15
|
|
|
|
mov esi, MAX_WINDOWS
|
2013-10-07 18:02:05 +04:00
|
|
|
mov edi, windows
|
2013-05-28 21:34:26 +04:00
|
|
|
.more:
|
2013-10-07 18:02:05 +04:00
|
|
|
mov ecx, [colors.work_button_text]
|
|
|
|
test [edi + window.flags], FLAG_UPDATED
|
|
|
|
jz @f
|
|
|
|
mov ecx, 0x00aa0000 ; RED!
|
|
|
|
@@:
|
|
|
|
or ecx, 0x80000000 ; ASCIIZ string
|
|
|
|
lea edx, [edi + window.name]
|
2013-05-28 21:34:26 +04:00
|
|
|
mcall
|
2013-10-07 18:02:05 +04:00
|
|
|
add edi, sizeof.window ; get ptr to next window
|
|
|
|
cmp [edi + window.data_ptr], 0
|
2013-05-28 21:34:26 +04:00
|
|
|
je .enough
|
|
|
|
add ebx, 125 shl 16
|
|
|
|
dec esi
|
|
|
|
jnz .more
|
|
|
|
.enough:
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
; Draw the close window button
|
|
|
|
|
|
|
|
mov edi, [window_active]
|
|
|
|
cmp [edi + window.type], WINDOWTYPE_SERVER ; dont let the user close server window
|
|
|
|
je @f
|
|
|
|
|
|
|
|
mov eax, 8
|
|
|
|
mov ebx, [xsize]
|
|
|
|
sub ebx, 12
|
|
|
|
shl ebx, 16
|
|
|
|
mov bx, 12
|
|
|
|
mov ecx, 6 shl 16 + 12
|
|
|
|
mov edx, WINDOW_BTN_CLOSE
|
|
|
|
; mov esi, [colors.work_button]
|
|
|
|
mov esi, 0x00aa0000 ; red !
|
|
|
|
mcall
|
|
|
|
|
|
|
|
@@:
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|