Subversion Repositories Kolibri OS

Rev

Rev 4060 | Go to most recent revision | Blame | Compare with Previous | 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.  
  137.  
  138. print_channel_list:
  139.  
  140.         pusha
  141. ; Now, draw the usernames themselves
  142.  
  143. ; first, draw an invisible button
  144.         mov     ebx, [xsize]
  145.         sub     ebx, USERLIST_X + SCROLLBAR_WIDTH
  146.         shl     ebx, 16
  147.         push    ebx
  148.         mov     bx, USERLIST_X
  149.         mov     ecx, [ysize]
  150.         add     ecx, TEXT_Y shl 16 - (TEXT_Y + 15)        ;;;;;   + 10???
  151.         push    ecx ebx
  152.         mov     edx, 50 + 1 shl 29 + 1 shl 30
  153.         mcall   8
  154.  
  155. ; now draw rectangle to clear the names
  156.         pop     ebx ecx
  157.         mov     edx, [colors.work]
  158.         mcall   13
  159.  
  160. ; now draw the names according with scrollbar position and window size
  161.         mov     eax, [scroll1.position]
  162.         xor     edx, edx
  163.         mov     ecx, MAX_NICK_LEN
  164.         mul     ecx
  165.         mov     edx, eax
  166.         mov     eax, [window_open]
  167.         mov     ebp, [eax + window.selected]
  168.         add     edx, [eax + window.data_ptr]
  169.         sub     ebp, [scroll1.position]
  170.         add     edx, window_data.names
  171.  
  172.         pop     ebx
  173.         mov     bx, TEXT_Y
  174.         mov     ecx, [colors.work_text]
  175.         or      ecx, 0x80000000                 ; ASCIIZ string
  176.         mov     eax, 4                          ; draw text
  177.  
  178.         mov     edi, [ysize]                    ; Calculate how many names will fit on screen
  179.         sub     edi, TEXT_Y + 15 ;+ 10           ;;;;;
  180.   .loop:
  181.         cmp     byte[edx], 0                    ; end of list?
  182.         je      .done
  183.  
  184.         dec     ebp                             ; is this name selected?
  185.         jnz     .nothighlight
  186.                                                 ; yes, highlight it
  187.         pusha
  188.         mov     cx, bx
  189.         mov     bx, USERLIST_X
  190.         shl     ecx, 16
  191.         mov     cx, 10 - 1
  192.         mov     edx, 0x00000055                 ; blue!
  193.         mcall   13
  194.         popa
  195.  
  196.         mov     ecx, 0x8000ffff                 ; cyan!
  197.         mcall
  198.  
  199.         mov     ecx, [colors.work_text]
  200.         or      ecx, 0x80000000                 ; ASCIIZ string
  201.         jmp     .next
  202.  
  203.   .nothighlight:
  204.         mcall
  205.  
  206.   .next:
  207.         add     edx, MAX_NICK_LEN               ; next name
  208.         add     ebx, 10                         ; height distance between lines
  209.         sub     edi, 10
  210.         ja      .loop
  211.  
  212.   .done:
  213.         popa
  214.  
  215.         ret
  216.  
  217.  
  218.  
  219.  
  220. draw_channel_text:
  221.  
  222.         pusha
  223.  
  224.         mov     eax, 4                  ; draw text
  225.         mov     ebx, TEXT_X shl 16 + TEXT_Y
  226.         mov     ecx, 12                 ; 12 lines max ?
  227.         mov     esi, [textbox_width]
  228.  
  229.   .dct:
  230.         pusha
  231.         mov     cx, bx
  232.         shl     ecx, 16
  233.         mov     cx, 9                   ; character height
  234.         mov     eax, 13                 ; draw rectangle
  235.         mov     ebx, TEXT_X shl 16
  236.         mov     bx, word[textbox_width]
  237.         imul    bx, 6                   ; character width
  238.         mov     edx, [colors.work]
  239.         mcall
  240.         popa
  241.  
  242.         push    ecx
  243.         mov     ecx, [colors.work_text]
  244.         cmp     word[edx], '* '
  245.         jne     .no_red
  246.         mov     ecx, 0x00aa0000
  247.         jmp     .draw
  248.   .no_red:
  249.  
  250.         cmp     word[edx], '**'
  251.         jne     .no_light_blue
  252.         cmp     byte[edx+2], '*'
  253.         jne     .no_light_blue
  254.         mov     ecx, 0x000000aa
  255.         jmp     .draw
  256.   .no_light_blue:
  257.  
  258.         cmp     byte[edx], '#'
  259.         jne     .no_blue
  260.         mov     ecx, 0x0000aa00
  261. ;        jmp     .draw
  262.   .no_blue:
  263.  
  264.   .draw:
  265.         mcall
  266.         add     edx, [textbox_width]
  267.         add     ebx, 10                 ; height distance between lines
  268.  
  269.         pop     ecx
  270.         loop    .dct
  271.  
  272.         popa
  273.         ret
  274.  
  275.  
  276.  
  277. draw_windownames:
  278.  
  279.         mov     eax, 8
  280.         mov     ebx, 5 shl 16 + 120
  281.         mov     ecx, 12 shl 16 + 12
  282.         mov     edx, WINDOW_BTN_START
  283.         mov     edi, windows
  284.   .more_btn:
  285.         mov     esi, [colors.work_button]
  286.         cmp     [window_open], edi
  287.         jne     @f
  288.         not     esi
  289.         and     esi, 0x00ffffff
  290.       @@:
  291.         mcall
  292.         inc     edx
  293.         add     ebx, 125 shl 16
  294.         add     edi, sizeof.window
  295.         cmp     [edi + window.data_ptr], 0
  296.         jne     .more_btn
  297.  
  298.         mov     eax, 4
  299.         mov     ebx, 10 shl 16 + 15
  300.         mov     ecx, [colors.work_button_text]
  301.         or      ecx, 0x80000000         ; ASCIIZ string
  302.         lea     edx, [windows + window.name]
  303.         mov     esi, MAX_WINDOWS
  304.   .more:
  305.         mcall
  306.         add     edx, sizeof.window
  307.         cmp     byte[edx], 0
  308.         je      .enough
  309.         add     ebx, 125 shl 16
  310.         dec     esi
  311.         jnz     .more
  312.   .enough:
  313.  
  314.         ret
  315.  
  316.  
  317.