2013-10-07 18:02:05 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2020-05-07 23:03:43 +03:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2020. All rights reserved. ;;
|
2013-10-07 18:02:05 +04:00
|
|
|
;; 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
|
|
|
|
|
2020-05-07 23:03:43 +03:00
|
|
|
; get system colors
|
|
|
|
mcall 48, 3, colors, 40
|
|
|
|
call set_edit_box_and_scrollbar_colors
|
|
|
|
|
2014-03-21 14:52:46 +04:00
|
|
|
mcall 9, thread_info, -1 ; get information about this thread
|
|
|
|
mov eax, [thread_info.box.width] ; window xsize
|
|
|
|
mov ebx, [thread_info.box.height] ; ysize
|
|
|
|
mov edx, [thread_info.client_box.width] ; work area xsize
|
|
|
|
mov esi, [thread_info.client_box.height] ; ysize
|
2013-05-28 21:34:26 +04:00
|
|
|
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
|
2014-03-21 14:52:46 +04:00
|
|
|
mcall 67, -1, -1 ; set the new sizes
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
popa
|
|
|
|
|
|
|
|
.dont_resize:
|
|
|
|
|
|
|
|
pusha
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mcall 12, 1
|
2016-01-26 04:13:24 +03:00
|
|
|
xor eax, eax ; draw window
|
|
|
|
mov ebx, WIN_MIN_X+10
|
|
|
|
mov ecx, WIN_MIN_Y+30
|
2013-05-28 21:34:26 +04:00
|
|
|
mov edx, [colors.work]
|
|
|
|
add edx, 0x33000000
|
|
|
|
mov edi, str_programname
|
|
|
|
mcall
|
2016-01-02 00:01:59 +03:00
|
|
|
|
2016-01-26 04:13:24 +03:00
|
|
|
test [thread_info.wnd_state], 100b ; skip if window is rolled up
|
2016-01-02 00:01:59 +03:00
|
|
|
jne .exit
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2018-07-01 17:29:23 +03:00
|
|
|
cmp [window_active], 0
|
|
|
|
je .no_window
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; calculate available space for textbox and coordinates for scrollbars
|
|
|
|
mov eax, [ysize]
|
2016-01-26 04:13:24 +03:00
|
|
|
sub eax, TOP_Y + INPUTBOX_HEIGHT - 1
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [scroll2.y_size], ax
|
|
|
|
mov [scroll1.y_size], ax
|
2016-01-26 04:13:24 +03:00
|
|
|
sub eax, 4
|
2013-11-01 18:02:08 +04:00
|
|
|
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..)
|
2014-03-09 20:07:08 +04:00
|
|
|
; meanwhile, recalculate line number of current line
|
|
|
|
mov esi, [edi + window.text_print]
|
|
|
|
mov al, byte[esi]
|
|
|
|
push eax
|
|
|
|
mov byte[esi], 0
|
|
|
|
push esi
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, [edi + window.text_start]
|
|
|
|
call text_insert_newlines
|
|
|
|
mov [edi + window.text_lines], edx
|
|
|
|
mov [edi + window.text_scanned], esi
|
2014-03-09 20:07:08 +04:00
|
|
|
mov [edi + window.text_line_print], edx
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
pop eax
|
|
|
|
mov byte[esi], al
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2014-03-16 15:50:59 +04:00
|
|
|
mov [scroll1.all_redraw], 1
|
2016-01-03 00:03:09 +03:00
|
|
|
call draw_user_list
|
2014-03-16 15:50:59 +04:00
|
|
|
|
|
|
|
; draw a vertical separator line when there is no scrollbar
|
|
|
|
cmp [scroll2.all_redraw], 1
|
|
|
|
jne .not_channel
|
|
|
|
|
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]
|
2016-01-02 00:01:59 +03:00
|
|
|
add ecx, TOP_Y shl 16 - (INPUTBOX_HEIGHT)
|
2013-11-01 18:02:08 +04:00
|
|
|
mov edx, [colors.work_graph]
|
|
|
|
mcall 38
|
2013-05-28 21:34:26 +04:00
|
|
|
.not_channel:
|
2018-07-01 17:29:23 +03:00
|
|
|
.no_window:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; draw editbox
|
2013-05-28 21:34:26 +04:00
|
|
|
mov eax, [ysize]
|
2016-01-02 00:01:59 +03:00
|
|
|
sub eax, INPUTBOX_HEIGHT
|
2013-05-28 21:34:26 +04:00
|
|
|
mov [edit1.top], eax
|
|
|
|
|
|
|
|
mov eax, [xsize]
|
|
|
|
mov [edit1.width], eax
|
|
|
|
|
2016-01-03 00:03:09 +03:00
|
|
|
invoke edit_box_draw, edit1
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; draw tabs
|
2016-01-03 00:03:09 +03:00
|
|
|
call draw_window_tabs
|
2014-03-21 14:52:46 +04:00
|
|
|
|
2014-03-21 13:51:25 +04:00
|
|
|
.exit:
|
2016-01-26 04:13:24 +03:00
|
|
|
mcall 12, 2
|
2013-05-28 21:34:26 +04:00
|
|
|
popa
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-01-03 00:03:09 +03:00
|
|
|
draw_user_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
|
2016-01-03 00:03:09 +03:00
|
|
|
invoke scrollbar_draw, scroll1
|
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]
|
2016-01-03 00:03:09 +03:00
|
|
|
or ecx, 0x90000000 ; 8x16 font, zero terminated string
|
2013-05-28 21:34:26 +04:00
|
|
|
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
|
2016-01-03 00:03:09 +03:00
|
|
|
mov cx, FONT_HEIGHT
|
2013-05-28 21:34:26 +04:00
|
|
|
mov edx, 0x00000055 ; blue!
|
|
|
|
mcall 13
|
|
|
|
popa
|
|
|
|
|
2016-01-03 00:03:09 +03:00
|
|
|
mov ecx, 0x9000ffff ; cyan!
|
2013-05-28 21:34:26 +04:00
|
|
|
mcall
|
|
|
|
|
|
|
|
mov ecx, [colors.work_text]
|
2016-01-03 00:03:09 +03:00
|
|
|
or ecx, 0x90000000 ; 8x16 font, zero terminated string
|
2013-05-28 21:34:26 +04:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2016-01-03 00:03:09 +03:00
|
|
|
draw_window_tabs:
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2016-01-02 00:01:59 +03:00
|
|
|
; Draw horizontal line
|
|
|
|
|
|
|
|
mov ebx, [xsize]
|
|
|
|
mov edx, [colors.work_graph]
|
|
|
|
mov ecx, TOP_Y SHL 16 + TOP_Y
|
|
|
|
mcall 38
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
; Create the buttons
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mov eax, 8
|
2016-01-02 00:01:59 +03:00
|
|
|
mov ebx, TAB_WIDTH
|
|
|
|
mov ecx, TOP_SPACE shl 16 + TAB_HEIGHT
|
2013-05-28 21:34:26 +04:00
|
|
|
mov edx, WINDOW_BTN_START
|
|
|
|
mov edi, windows
|
|
|
|
.more_btn:
|
2020-05-07 18:43:50 +03:00
|
|
|
mov esi, [colors.work]
|
2013-10-07 18:02:05 +04:00
|
|
|
cmp [window_active], edi
|
2013-05-28 21:34:26 +04:00
|
|
|
jne @f
|
2020-05-07 18:43:50 +03:00
|
|
|
;not esi
|
|
|
|
;and esi, 0x00ffffff
|
2020-05-07 23:03:43 +03:00
|
|
|
mov esi, [colors.work_light]
|
2013-05-28 21:34:26 +04:00
|
|
|
@@:
|
|
|
|
mcall
|
|
|
|
inc edx
|
2016-01-02 00:01:59 +03:00
|
|
|
add ebx, (TAB_WIDTH + TAB_SPACE) shl 16
|
2013-05-28 21:34:26 +04:00
|
|
|
add edi, sizeof.window
|
|
|
|
cmp [edi + window.data_ptr], 0
|
|
|
|
jne .more_btn
|
|
|
|
|
2014-03-10 01:57:21 +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]
|
2016-01-02 00:01:59 +03:00
|
|
|
sub ebx, SCROLLBAR_WIDTH
|
2014-03-10 01:57:21 +04:00
|
|
|
shl ebx, 16
|
2016-01-02 00:01:59 +03:00
|
|
|
mov bx, SCROLLBAR_WIDTH
|
|
|
|
mov ecx, TOP_SPACE shl 16 + TAB_HEIGHT - 1
|
2014-03-10 01:57:21 +04:00
|
|
|
mov edx, WINDOW_BTN_CLOSE
|
|
|
|
mov esi, 0x00aa0000 ; red !
|
2020-05-07 23:03:43 +03:00
|
|
|
mcall
|
2020-05-07 18:43:50 +03:00
|
|
|
|
2020-05-07 23:03:43 +03:00
|
|
|
pusha
|
|
|
|
; write closing cross
|
|
|
|
mov ebx, [xsize]
|
|
|
|
sub ebx, 9
|
2020-05-07 18:43:50 +03:00
|
|
|
shl ebx, 16
|
2020-05-07 23:03:43 +03:00
|
|
|
add ebx, TOP_SPACE+3
|
|
|
|
mov ecx, 0x80FFFfff
|
|
|
|
mov edx, closing_cross
|
2020-05-07 18:43:50 +03:00
|
|
|
mcall 4
|
2020-05-07 23:03:43 +03:00
|
|
|
popa
|
2014-03-10 01:57:21 +04:00
|
|
|
@@:
|
|
|
|
|
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
|
2016-01-02 00:01:59 +03:00
|
|
|
mov ebx, 5 shl 16 + TOP_SPACE + 4 ;;;;
|
2013-05-28 21:34:26 +04:00
|
|
|
mov esi, MAX_WINDOWS
|
2013-10-07 18:02:05 +04:00
|
|
|
mov edi, windows
|
2013-05-28 21:34:26 +04:00
|
|
|
.more:
|
2020-05-07 18:43:50 +03:00
|
|
|
mov ecx, [colors.work_text]
|
2013-10-07 18:02:05 +04:00
|
|
|
test [edi + window.flags], FLAG_UPDATED
|
|
|
|
jz @f
|
2016-01-02 00:01:59 +03:00
|
|
|
mov ecx, 0x00aa0000 ; RED!
|
2013-10-07 18:02:05 +04:00
|
|
|
@@:
|
|
|
|
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
|
2016-01-02 00:01:59 +03:00
|
|
|
add ebx, (TAB_WIDTH + TAB_SPACE) shl 16
|
2013-05-28 21:34:26 +04:00
|
|
|
dec esi
|
|
|
|
jnz .more
|
|
|
|
.enough:
|
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
ret
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
highlight_updated_tabs:
|
|
|
|
mov eax, 4
|
2016-01-02 00:01:59 +03:00
|
|
|
mov ebx, 5 shl 16 + TOP_SPACE + 4 ;;;;
|
2014-03-10 01:57:21 +04:00
|
|
|
mov ecx, 0x80aa0000
|
|
|
|
mov esi, MAX_WINDOWS
|
|
|
|
mov edi, windows
|
|
|
|
.more_:
|
|
|
|
test [edi + window.flags], FLAG_UPDATED
|
|
|
|
jz .next
|
|
|
|
lea edx, [edi + window.name]
|
|
|
|
mcall
|
|
|
|
.next:
|
|
|
|
add edi, sizeof.window ; get ptr to next window
|
|
|
|
cmp [edi + window.data_ptr], 0
|
|
|
|
je .enough_
|
2016-01-02 00:01:59 +03:00
|
|
|
add ebx, (TAB_WIDTH + TAB_SPACE) shl 16
|
2014-03-10 01:57:21 +04:00
|
|
|
dec esi
|
|
|
|
jnz .more_
|
|
|
|
.enough_:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2020-05-07 23:03:43 +03:00
|
|
|
ret
|
|
|
|
|
|
|
|
set_edit_box_and_scrollbar_colors:
|
|
|
|
mov eax, [colors.work]
|
|
|
|
mov [scroll1.bg_color], eax
|
|
|
|
mov [scroll2.bg_color], eax
|
|
|
|
|
|
|
|
mov eax, [colors.work_button]
|
|
|
|
mov [scroll1.front_color], eax
|
|
|
|
mov [scroll2.front_color], eax
|
|
|
|
|
|
|
|
mov eax, [colors.work_text]
|
|
|
|
mov [scroll1.line_color], eax
|
|
|
|
mov [scroll2.line_color], eax
|
|
|
|
|
|
|
|
mov [scroll1.type], 0 ; 0 = simple, 1 = skinned
|
|
|
|
mov [scroll2.type], 0
|
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
ret
|