Subversion Repositories Kolibri OS

Rev

Rev 4659 | Rev 4669 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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