Subversion Repositories Kolibri OS

Rev

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