Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.     org 0x0
  3.     db  'MENUET01'
  4.     dd  0x01,start,i_end,e_end,e_end,0,0
  5.  
  6. include '../../../proc32.inc'
  7. include '../../../macros.inc'
  8.  
  9. BUTTON_SIDE          = 28      ; button are squares
  10. BUTTON_SPACE         = 34      ; space between cols and rows
  11. BUTTON_ID_SHIFT      = 2       ; button_id = character + BUTTON_ID_SHIFT
  12. TABLE_BEGIN_X        = 2
  13. TABLE_BEGIN_Y        = 2
  14. PANEL_Y              = BUTTON_SPACE*8+TABLE_BEGIN_Y+TABLE_BEGIN_Y
  15.  
  16. FOCUS_SQUARE_COLOR   = 0x000080FF
  17. SWITCHER_BLINK_COLOR = 0x00808080
  18.  
  19.  
  20. start:
  21. still:
  22.         mcall   10
  23.         dec     eax
  24.         jz      redraw
  25.         dec     eax
  26.         jz      key
  27.  
  28. button:
  29.         mcall   17
  30.         shr     eax, 8
  31.  
  32.         cmp     eax, 1
  33.         je      quit
  34.         cmp     ax, 0xFFAA                      ; page switcher
  35.         je      .switch_page                    ; any button with a character
  36.   .change_focus:
  37.         mov     bl, [symbol_focused]
  38.         mov     [symbol_unfocused], bl
  39.         sub     ax, BUTTON_ID_SHIFT             ; get the corresponding character
  40.         mov     [symbol_focused], al
  41.         stdcall draw_table, 0
  42.         call    draw_codes
  43.         jmp     still
  44.   .switch_page:
  45.         movzx   bx, [symbol_start]
  46.         add     bx, BUTTON_ID_SHIFT
  47.         mov     cx, 128                         ; half of page
  48.         mov     edx, 0x80000000
  49.         mov     dx, bx
  50.     @@: mcall   8
  51.         inc     edx
  52.         dec     cx
  53.         jnz     @b
  54.  
  55.     @@: add     [symbol_start], 128             ; change page
  56.         add     [symbol_focused], 128
  57.         stdcall draw_table, 1                   ; 1 means redraw the whole table
  58.         call    draw_codes
  59.         stdcall draw_page_switcher, 1           ; 1 means dark color, for blinking
  60.         mcall   5, 10
  61.         stdcall draw_page_switcher, 0           ; 0 means usual light color
  62.         jmp     still
  63.  
  64. redraw:
  65.         mcall   9, proc_info, -1
  66.  
  67.         mcall   12, 1
  68.  
  69.         mcall   48, 4                           ; get skin height
  70.         mov     ecx, 200*0x10000+PANEL_Y+33
  71.         add     ecx, eax
  72.         mov     ebx, 200*0x10000+BUTTON_SPACE*16+TABLE_BEGIN_X+TABLE_BEGIN_X+9
  73.         mcall   0, , , 0x34AAAaaa, 0x80000000, window_title
  74.         test    [proc_info.wnd_state], 0x04
  75.         jnz     @f
  76.  
  77.         stdcall draw_table, 1
  78.         call    draw_codes
  79.         stdcall draw_page_switcher, 0
  80.  
  81.     @@:
  82.         mcall   12, 2
  83.         jmp     still
  84.  
  85. key:
  86.         mcall   2
  87.         cmp     ah, 0x09                        ; TAB key
  88.         je      button.switch_page
  89.  
  90.         cmp     ah, 0xB0                        ; left
  91.         jne     @f
  92.         mov     bl, [symbol_focused]
  93.         mov     [symbol_unfocused], bl
  94.         dec     bl
  95.         and     bl, 0x0f
  96.         and     [symbol_focused], 0xf0
  97.         or      [symbol_focused], bl
  98.         stdcall draw_table, 0
  99.         call    draw_codes
  100.         jmp     still
  101.  
  102.     @@: cmp     ah, 0xB1                        ; down
  103.         jne     @f
  104.         mov     bl, [symbol_focused]
  105.         mov     [symbol_unfocused], bl
  106.         add     bl, 16
  107.         and     bl, 0x70
  108.         and     [symbol_focused], 0x8f
  109.         or      [symbol_focused], bl
  110.         stdcall draw_table, 0
  111.         call    draw_codes
  112.         jmp     still
  113.  
  114.     @@: cmp     ah, 0xB2                        ; up
  115.         jne     @f
  116.         mov     bl, [symbol_focused]
  117.         mov     [symbol_unfocused], bl
  118.         sub     bl, 16
  119.         and     bl, 0x70
  120.         and     [symbol_focused], 0x8f
  121.         or      [symbol_focused], bl
  122.         stdcall draw_table, 0
  123.         call    draw_codes
  124.         jmp     still
  125.  
  126.     @@: cmp     ah, 0xB3                        ; righ
  127.         jne     @f
  128.         mov     bl, [symbol_focused]
  129.         mov     [symbol_unfocused], bl
  130.         inc     bl
  131.         and     bl, 0x0f
  132.         and     [symbol_focused], 0xf0
  133.         or      [symbol_focused], bl
  134.         stdcall draw_table, 0
  135.         call    draw_codes
  136.         jmp     still
  137.         jne     @f
  138.  
  139.     @@:
  140.         jmp     still
  141.  
  142.  
  143.  
  144. proc    draw_table _full_redraw
  145.  
  146.         mov     al, [symbol_start]
  147.         mov     [symbol_current], al
  148.  
  149.   .next_button:
  150.  
  151.         xor     edi, edi                        ; character focus flag
  152.         mov     al, [symbol_current]
  153.         cmp     al, [symbol_focused]
  154.         jne     @f
  155.         inc     edi
  156.     @@: cmp     [_full_redraw], 1
  157.         je      .draw
  158.         cmp     al, [symbol_focused]
  159.         je      .draw
  160.         cmp     al, [symbol_unfocused]          ; previously focused, should redraw to clear focus
  161.         je      .draw
  162.         jmp     .skip                           ; skip button if it isn't (un)focused
  163.  
  164.   .draw:
  165.         call    draw_button
  166.   .skip:
  167.         mov     bl, [symbol_start]
  168.         add     bl, 127                         ; end of current page
  169.         cmp     [symbol_current], bl            ; the last on page?
  170.         jne     @f
  171.         mov     [button_x], TABLE_BEGIN_X
  172.         mov     [button_y], TABLE_BEGIN_Y
  173.         ret
  174.     @@: inc     [symbol_current]
  175.         add     [button_x], BUTTON_SPACE
  176.         cmp     [button_x], BUTTON_SPACE*16+TABLE_BEGIN_X    ; the last in row?
  177.         jne     .next_button
  178.         add     [button_y], BUTTON_SPACE        ; next row
  179.         mov     [button_x], TABLE_BEGIN_X
  180.         jmp     .next_button
  181.         ret
  182. endp
  183.  
  184.  
  185. proc    draw_button
  186.         mov     edx, 0x80000000
  187.         mov     dl, [symbol_current]
  188.         add     edx, BUTTON_ID_SHIFT
  189.         mov     esi, 0xFFFfff
  190.         mcall   8, <[button_x],BUTTON_SIDE>, <[button_y],BUTTON_SIDE>
  191.         and     edx, 0x7FFFFFFF
  192.         or      edx, 0x20000000
  193.         mcall
  194.  
  195.         test    edi, edi                        ; is focused?
  196.         jz      .symbol                         ; draw only character, not selection square
  197.   .focus_frame:                                 ; draw a blue square (selection), 8 segments
  198.         mov     esi, [button_x]
  199.         mov     edi, [button_y]
  200.  
  201.         mov     bx, si
  202.         shl     ebx, 16
  203.         mov     bx, si
  204.         add     bx, BUTTON_SIDE
  205.         mov     cx, di
  206.         shl     ecx, 16
  207.         mov     cx, di
  208.         mcall   38, , , FOCUS_SQUARE_COLOR
  209.         add     ecx, 0x00010001
  210.         mcall
  211.         add     ecx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
  212.         mcall
  213.         add     ecx, 0x00010001
  214.         mcall
  215.  
  216.         mov     bx, si
  217.         shl     ebx, 16
  218.         mov     bx, si
  219.         mov     cx, di
  220.         shl     ecx, 16
  221.         mov     cx, di
  222.         add     ecx, 2*0x10000+(BUTTON_SIDE-2)
  223.         mcall   38, , ,
  224.         add     ebx, 0x00010001
  225.         mcall
  226.         add     ebx, (BUTTON_SIDE-2)*0x10000+(BUTTON_SIDE-2)
  227.         mcall
  228.         add     ebx, 0x00010001
  229.         mcall
  230.  
  231.   .symbol:
  232.         mov     ebx, [button_x]
  233.         add     ebx, 9
  234.         shl     ebx, 16
  235.         add     ebx, [button_y]
  236.         add     ebx, 7
  237.         mcall   4, , 0x01000000, symbol_current, 1
  238.  
  239.         ret
  240. endp
  241.  
  242.  
  243. proc    draw_page_switcher _blinking
  244.  
  245.         mcall   8, , , 0x8000FFAA
  246.         mov     esi, 0xCCCccc
  247.         cmp     [_blinking], 1                  ; blinking?
  248.         jne     @f
  249.         mov     esi, SWITCHER_BLINK_COLOR
  250.     @@: mcall   , <2,98>, <PANEL_Y+1,23>, 0x2000FFAA
  251.  
  252.         mov     ecx, 0x81000000
  253.         mov     edx, string_000_127
  254.         cmp     [symbol_start], 0               ; first page?
  255.         je      @f
  256.         mov     edx, string_128_255             ; ok, the second one
  257.     @@: mcall   4, <10,PANEL_Y+6>,
  258.         mcall    , <115,PANEL_Y+6>, 0x81000000, string_ASCII_CODE
  259.  
  260.         ret
  261. endp
  262.  
  263.  
  264. proc    draw_codes
  265.  
  266.         movzx   ecx, [symbol_focused]
  267.         mcall   47, 0x00030000, , <250,PANEL_Y+6>, 0x41000000, 0xAAAaaa
  268.         mcall     , 0x00020100, , <500,PANEL_Y+6>,
  269.  
  270.         ret
  271. endp
  272.  
  273.  
  274. quit:
  275.         mcall   -1
  276.  
  277.  
  278. szZ window_title                ,'ASCIIVju'
  279. szZ string_000_127              ,'000-127'
  280. szZ string_128_255              ,'128-255'
  281. szZ string_ASCII_CODE           ,'ASCII Code:      ASCII Hex-Code:'
  282.  
  283. button_x                dd 2
  284. button_y                dd 2
  285.  
  286. symbol_current          db 0
  287. symbol_start            db 0
  288.  
  289. symbol_unfocused        db 0
  290. symbol_focused          db 0
  291. i_end:
  292. proc_info               process_information
  293. rb 0x400                ;stack
  294. e_end:
  295.