Subversion Repositories Kolibri OS

Rev

Rev 3220 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. draw_window:
  2.  
  3.         pusha
  4.  
  5.         mcall   9, thread_info, -1              ; get current window size
  6.         mov     eax, dword[thread_info+42]      ; window xsize
  7.         mov     ebx, dword[thread_info+46]      ; ysize
  8.         mov     edx, dword[thread_info+62]      ; work area xsize
  9.         mov     esi, dword[thread_info+66]      ; ysize
  10.         sub     eax, edx
  11.         sub     ebx, esi
  12.  
  13.         cmp     edx, WIN_MIN_X
  14.         jae     .x_ok
  15.         mov     edx, WIN_MIN_X
  16.   .x_ok:
  17.         mov     [xsize], edx
  18.         add     edx, eax
  19.  
  20.         cmp     esi, WIN_MIN_Y
  21.         jae     .y_ok
  22.         mov     esi, WIN_MIN_Y
  23.   .y_ok:
  24.         mov     [ysize], esi
  25.         add     esi, ebx
  26.         mcall   67, -1, -1                      ; set the new sizes
  27.  
  28.         mcall   12, 1
  29.         xor     eax, eax                        ; draw window
  30.         mov     ebx, WIN_MIN_X
  31.         mov     ecx, WIN_MIN_Y
  32.         mov     edx, [colors.work]
  33.         add     edx, 0x33000000
  34.         mov     edi, str_programname
  35.         mcall
  36.         mcall   12, 2 ;; when do we actually need this??
  37.  
  38.         mov     ebx, [xsize]
  39.         mov     ecx, [ysize]
  40.         sub     cx, 15 ;;;;
  41.         push    cx
  42.         shl     ecx, 16
  43.         pop     cx
  44.         mov     edx, [colors.work_graph]
  45.         mcall   38                              ; draw line
  46.  
  47.         mov     ecx, TOP_Y SHL 16 + TOP_Y
  48.         mcall
  49.  
  50.         mov     edi, [window_open]
  51.         cmp     [edi + window.type], WINDOWTYPE_CHANNEL
  52.         jne     .not_channel
  53.  
  54.         ; draw a vertical separator line
  55.         mov     ebx, [xsize]
  56.         sub     ebx, USERLIST_X + SCROLLBAR_WIDTH + 3
  57.         push    bx
  58.         shl     ebx, 16
  59.         pop     bx
  60.         mov     ecx, [ysize]
  61.         add     ecx, TOP_Y SHL 16 -(15) ;;;;
  62.         mcall
  63.  
  64.         call    redraw_channel_list
  65.  
  66.   .not_channel:
  67.         mov     edx, [edi + window.data_ptr]
  68.         add     edx, window_data.text
  69.         call    draw_channel_text
  70.  
  71. ; editbox
  72.  
  73.         mov     eax, [ysize]
  74.         sub     eax, 12 ;;;;;;
  75.         mov     [edit1.top], eax
  76.  
  77.         mov     eax, [xsize]
  78.         mov     [edit1.width], eax
  79.  
  80.         push    dword edit1
  81.         call    [edit_box_draw]
  82.  
  83. ; tabs
  84.  
  85.         call    draw_windownames
  86.  
  87.         popa
  88.         ret
  89.  
  90.  
  91.  
  92. redraw_channel_list:
  93.  
  94. ; First, calculate scrollbar
  95.  
  96.         mov     ebx, [window_open]
  97.         mov     eax, [ebx + window.users]       ; number of users in the open window
  98.         mov     [scroll1.max_area], eax
  99.  
  100.         mov     eax, [ysize]
  101.         sub     eax, TOP_Y + 15 ;;;;
  102.         push    eax
  103.         mov     [scroll1.y_size], ax
  104.  
  105.         mov     eax, [xsize]
  106.         sub     eax, SCROLLBAR_WIDTH
  107.         mov     [scroll1.x_pos], ax
  108.  
  109.         pop     eax                             ; scrollbar height
  110.         xor     edx, edx
  111.         mov     ecx, 10
  112.         div     ecx
  113.         mov     [scroll1.cur_area], eax
  114.  
  115.         ; Do we need a scrollbar?
  116.         cmp     eax, [scroll1.max_area]
  117.         jae     .noscroll
  118.  
  119.         ; Is the current position greater then the max position?
  120.         cmp     eax, [scroll1.position]
  121.         ja      @f
  122.         mov     [scroll1.position], eax
  123.   @@:
  124.  
  125.         ; OK, draw the scrollbar
  126.         mov     [scroll1.all_redraw], 1
  127.  
  128.         push    dword scroll1
  129.         call    [scrollbar_v_draw]
  130.  
  131.         jmp     print_channel_list
  132.  
  133.   .noscroll:
  134.         mov     [scroll1.position], 0
  135.  
  136. print_channel_list:
  137.  
  138.         pusha
  139. ; Now, draw the usernames themselves
  140.  
  141.         mov     eax, 13                         ; draw rectangle (clear list)
  142.  
  143.         mov     ebx, [xsize]
  144.         sub     ebx, USERLIST_X + SCROLLBAR_WIDTH
  145.         shl     ebx, 16
  146.         push    ebx
  147.         mov     bx, USERLIST_X
  148.         mov     ecx, [ysize]
  149.         add     ecx, TEXT_Y shl 16 - (TEXT_Y + 15)        ;;;;;   + 10???
  150.         mov     edx, [colors.work]
  151.         mcall
  152.  
  153.         mov     eax, [scroll1.position]
  154.         xor     edx, edx
  155.         mov     ecx, MAX_NICK_LEN
  156.         mul     ecx
  157.         mov     edx, eax
  158.         mov     eax, [window_open]
  159.         add     edx, [eax + window.data_ptr]
  160.         add     edx, window_data.names
  161.  
  162.         pop     ebx
  163.         mov     bx, TEXT_Y
  164.         mov     ecx, [colors.work_text]
  165.         or      ecx, 0x80000000                 ; ASCIIZ string
  166.         mov     eax, 4                          ; draw text
  167.  
  168.         mov     edi, [ysize]                    ; Calculate how many names will fit on screen
  169.         sub     edi, TEXT_Y + 15 ;+ 10           ;;;;;
  170.   .loop:
  171.         ; TODO: check if name is selected and highlight background color if so
  172.         cmp     byte[edx], ' '                  ; end of list?
  173.         je      .done
  174.         mcall
  175.  
  176.         add     edx, MAX_NICK_LEN               ; next name
  177.         add     ebx, 10                         ; height distance between lines
  178.         sub     edi, 10
  179.         ja      .loop
  180.   .done:
  181.  
  182.         popa
  183.  
  184.         ret
  185.  
  186.  
  187.  
  188.  
  189. draw_channel_text:
  190.  
  191.         pusha
  192.  
  193.         mov     eax, 4                  ; draw text
  194.         mov     ebx, TEXT_X shl 16 + TEXT_Y
  195.         mov     ecx, 12                 ; 12 lines max ?
  196.         mov     esi, [textbox_width]
  197.  
  198.   .dct:
  199.         pusha
  200.         mov     cx, bx
  201.         shl     ecx, 16
  202.         mov     cx, 9                   ; character height
  203.         mov     eax, 13                 ; draw rectangle
  204.         mov     ebx, TEXT_X shl 16
  205.         mov     bx, word[textbox_width]
  206.         imul    bx, 6                   ; character width
  207.         mov     edx, [colors.work]
  208.         mcall
  209.         popa
  210.  
  211.         push    ecx
  212.         mov     ecx, [colors.work_text]
  213.         cmp     word[edx], '* '
  214.         jne     .no_red
  215.         mov     ecx, 0x00aa0000
  216.         jmp     .draw
  217.   .no_red:
  218.  
  219.         cmp     word[edx], '**'
  220.         jne     .no_light_blue
  221.         cmp     byte[edx+2], '*'
  222.         jne     .no_light_blue
  223.         mov     ecx, 0x000000aa
  224.         jmp     .draw
  225.   .no_light_blue:
  226.  
  227.         cmp     byte[edx], '#'
  228.         jne     .no_blue
  229.         mov     ecx, 0x0000aa00
  230. ;        jmp     .draw
  231.   .no_blue:
  232.  
  233.   .draw:
  234.         mcall
  235.         add     edx, [textbox_width]
  236.         add     ebx, 10                 ; height distance between lines
  237.  
  238.         pop     ecx
  239.         loop    .dct
  240.  
  241.         popa
  242.         ret
  243.  
  244.  
  245.  
  246. draw_windownames:
  247.  
  248.         mov     eax, 8
  249.         mov     ebx, 5 shl 16 + 120
  250.         mov     ecx, 12 shl 16 + 12
  251.         mov     edx, WINDOW_BTN_START
  252.         mov     edi, windows
  253.   .more_btn:
  254.         mov     esi, [colors.work_button]
  255.         cmp     [window_open], edi
  256.         jne     @f
  257.         not     esi
  258.         and     esi, 0x00ffffff
  259.       @@:
  260.         mcall
  261.         inc     edx
  262.         add     ebx, 125 shl 16
  263.         add     edi, sizeof.window
  264.         cmp     [edi + window.data_ptr], 0
  265.         jne     .more_btn
  266.  
  267.         mov     eax, 4
  268.         mov     ebx, 10 shl 16 + 15
  269.         mov     ecx, [colors.work_button_text]
  270.         or      ecx, 0x80000000         ; ASCIIZ string
  271.         lea     edx, [windows + window.name]
  272.         mov     esi, MAX_WINDOWS
  273.   .more:
  274.         mcall
  275.         add     edx, sizeof.window
  276.         cmp     byte[edx], 0
  277.         je      .enough
  278.         add     ebx, 125 shl 16
  279.         dec     esi
  280.         jnz     .more
  281.   .enough:
  282.  
  283.         ret
  284.  
  285.  
  286.