Subversion Repositories Kolibri OS

Rev

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

  1.  
  2.   use32
  3.   org    0x0
  4.  
  5.   db     'MENUET01'
  6.   dd     0x01
  7.   dd     START
  8.   dd     I_END
  9.   dd     0x1000
  10.   dd     0x1000
  11.   dd     0x0
  12.   dd     0x0
  13.  
  14. FALSE = 0
  15. TRUE  = 1
  16.  
  17. include '../../../../../proc32.inc'
  18. include '../../../../../macros.inc'
  19. include '../../libio/libio.inc'
  20. include '../../../../../dll.inc'
  21.  
  22. yy dd 20
  23.  
  24. proc draw xx,color,key,val
  25.         pushad
  26.  
  27.         mov     esi,[key]
  28.         mov     edi,buf
  29.         cld
  30.         mov     al,"'"
  31.         stosb
  32.     @@: lodsb
  33.         stosb
  34.         or      al,al
  35.         jnz     @b
  36.         mov     word[edi-1],"'"
  37.  
  38.         mov     esi,[val]
  39.         or      esi,esi
  40.         je      .noval
  41.         mov     eax," = '"
  42.         stosd
  43.     @@: lodsb
  44.         stosb
  45.         or      al,al
  46.         jnz     @b
  47.         mov     word[edi-1],"'"
  48.   .noval:
  49.  
  50.         or      [color],0x80000000
  51.         mcall   4,<[xx],[yy]>,[color],buf
  52.         add     [yy],10
  53.         popad
  54.         ret
  55. endp
  56.  
  57. proc callb_k f_name,sec_name,key_name,key_val
  58.         stdcall draw,224,0x0000FF,[key_name],[key_val]
  59.         mov     eax,TRUE
  60.         ret
  61. endp
  62.  
  63. proc callb f_name,sec_name
  64.         stdcall draw,200,0xFF0000,[sec_name],0
  65.         invoke  ini.enum_keys,[f_name],[sec_name],callb_k
  66.         mov     eax,TRUE
  67.         ret
  68. endp
  69.  
  70. ;---------------------------------------------------------------------
  71. ;---  ÍÀ×ÀËÎ ÏÐÎÃÐÀÌÌÛ  ----------------------------------------------
  72. ;---------------------------------------------------------------------
  73.  
  74. s_key1 db "LeftViewMode",0
  75. s_key2 db "RightViewMode",0
  76.  
  77. macro wildcard_test_data label1, label2, label3, [str1, str2, res]
  78. {
  79.   common
  80.     label label1
  81.   forward
  82.     local ..lbl
  83.     dd ..lbl - $
  84.     db str1,0
  85.     ..lbl:
  86.   common
  87.     dd 0
  88.     label label2
  89.   forward
  90.     local ..lbl
  91.     dd ..lbl - $
  92.     db str2,0
  93.     ..lbl:
  94.   common
  95.     label label3
  96.   forward
  97.     if res = "t"
  98.       dd 1
  99.     else
  100.       dd 0
  101.     end if
  102. }
  103.  
  104. wildcard_test_data _str1, _str2, _str3, \
  105.   ""           ,""       ,"t",    ""            ,"a"        ,"f", \
  106.   "a"          ,"a"      ,"t",    "a"           ,"b"        ,"f", \
  107.   "?"          ,"b"      ,"t",    "??"          ,"bc"       ,"t", \
  108.   "?c"         ,"bc"     ,"t",    "b?"          ,"bc"       ,"t", \
  109.   "[a-z]"      ,"b"      ,"t",    "[A-Z]"       ,"b"        ,"f", \
  110.   "*"          ,"a"      ,"t",    "**"          ,"a"        ,"t", \
  111.   "*"          ,""       ,"t",    "*bc*hij"     ,"abcdfghij","t", \
  112.   "*b*a*"      ,"b"      ,"f",    "*bc*hik"     ,"abcdfghij","f", \
  113.   "abc*"       ,"abc"    ,"t",    "abc**"       ,"abc"      ,"t", \
  114.   "[^]]"       ,"^"      ,"t",    "[^]]"        ,"]"        ,"f", \
  115.   "[^abc]"     ,"d"      ,"t",    "[^abc]"      ,"b"        ,"f", \
  116.   "*???"       ,"abc"    ,"t",    "*???"        ,"ab"       ,"f", \
  117.   "*???"       ,"abcd"   ,"t",    "*?*"         ,"abcd"     ,"t", \
  118.   "*bc"        ,"abc"    ,"t",    "*cc"         ,"abc"      ,"f", \
  119.   "[a-c]*"     ,"d"      ,"f",    "*[a-e]"      ,"d"        ,"t", \
  120.   "*a*"        ,"de"     ,"f",    "*[a-c]"      ,"d"        ,"f", \
  121.   "[a-c]"      ,"d"      ,"f",    "[b-d]"       ,"a"        ,"f", \
  122.   "[]abc]"     ,"b"      ,"t",    "[]abc]"      ,"d"        ,"f", \
  123.   "[z-a]"      ,"-"      ,"t",    "[z-a]"       ,"b"        ,"f", \
  124.   "[A-]"       ,"-"      ,"t",    "[A-]"        ,"]"        ,"f", \
  125.   "[-a]"       ,"-"      ,"t",    "[-[]"        ,"-"        ,"t", \
  126.   "[-]"        ,"-"      ,"t",    "[^-b]"       ,"a"        ,"t", \
  127.   "[^-b]"      ,"-"      ,"f",    "[-b]"        ,"a"        ,"f", \
  128.   "[a-g]lorian","florian","t",    "[a-g]*rorian","f"        ,"f", \
  129.   "*???*"      ,"123"    ,"t"
  130.  
  131. START:
  132.         mcall   68,11
  133.  
  134.         stdcall dll.Load,@IMPORT
  135.         or      eax,eax
  136.         jnz     exit
  137.  
  138. @^ ; commenting out, file.aux.match_wildcard is no longer exported
  139.         mov     esi,_str1 + 4
  140.         mov     edi,_str2 + 4
  141.         mov     ecx,_str3
  142.         xor     ebx,ebx
  143.         inc     ebx
  144.     @@: invoke  file.aux.match_wildcard,edi,esi,0
  145.         cmp     eax,[ecx]
  146.         je      .ok
  147.         mcall   -1
  148.   .ok:  inc     ebx
  149.         add     esi,[esi-4]
  150.         add     edi,[edi-4]
  151.         add     ecx,4
  152.         cmp     dword[esi-4],0
  153.         jnz     @b
  154. ^@
  155.  
  156.         invoke  ini.set_int,s_ini,s_sec,s_key1,100
  157.         invoke  ini.set_int,s_ini,s_sec,s_key2,101
  158.  
  159.         invoke  ini.get_int,s_ini,s_sec,s_key1,-1
  160.         cmp     eax,100
  161.         jne     exit
  162.         invoke  ini.get_int,s_ini,s_sec,s_key2,-1
  163.         cmp     eax,101
  164.         jne     exit
  165.  
  166.         mov     dword[buf],'102'
  167.         invoke  ini.set_str,s_ini,s_sec,s_key1,buf,3
  168.         mov     dword[buf],'103'
  169.         invoke  ini.set_str,s_ini,s_sec,s_key2,buf,3
  170.  
  171.         invoke  ini.get_str,s_ini,s_sec,s_key1,buf,1024,0
  172.         cmp     dword[buf],'102'
  173.         jne     exit
  174.         invoke  ini.get_str,s_ini,s_sec,s_key2,buf,1024,0
  175.         cmp     dword[buf],'103'
  176.         jne     exit
  177.  
  178.         invoke  ini.enum_sections,s_ini,callb
  179.  
  180. ;       invoke  file.open,s_ininame,O_WRITE+O_CREATE
  181. ;       or      eax,eax
  182. ;       jnz     @f
  183. ;       int3
  184. ;   @@: mov     [fh],eax
  185. ;       invoke  file.seek,[fh],SEEK_SET,8192
  186. ;       invoke  file.write,[fh],s_ininame,16
  187. ;       invoke  file.seteof,[fh]
  188. ;       invoke  file.close,[fh]
  189.  
  190. red:
  191.  
  192.         call    draw_window
  193.  
  194. ;---------------------------------------------------------------------
  195. ;---  ÖÈÊË ÎÁÐÀÁÎÒÊÈ ÑÎÁÛÒÈÉ  ----------------------------------------
  196. ;---------------------------------------------------------------------
  197.  
  198. still:
  199.         mcall   10
  200.  
  201.         cmp     eax,1
  202.         je      red
  203.         cmp     eax,2
  204.         je      key
  205.         cmp     eax,3
  206.         je      button
  207.  
  208.         jmp     still
  209.  
  210. ;---------------------------------------------------------------------
  211.  
  212.   key:
  213.         mcall   2
  214.         jmp     still
  215.  
  216. ;---------------------------------------------------------------------
  217.  
  218.   button:
  219.         mcall   17
  220.  
  221.         cmp     ah,1
  222.         jne     still
  223.  
  224.   exit:
  225.         mcall   -1
  226.  
  227. ;---------------------------------------------------------------------
  228. ;---  ÎÏÐÅÄÅËÅÍÈÅ È ÎÒÐÈÑÎÂÊÀ ÎÊÍÀ  ----------------------------------
  229. ;---------------------------------------------------------------------
  230.  
  231. ctx dd ?
  232.  
  233. draw_window:
  234.         invoke  gfx.open,TRUE
  235.         mov     [ctx],eax
  236.         mcall   0,<200,700>,<200,200>,0x33FFFFFF,,s_header
  237.         invoke  gfx.pen.color,[ctx],0x00FF0000
  238.         invoke  gfx.line,[ctx],0,0,50,50
  239.         invoke  gfx.framerect,[ctx],10,10,100,70
  240.         invoke  gfx.brush.color,[ctx],0x000000FF
  241.         invoke  gfx.fillrect,[ctx],15,15,95,65
  242.         invoke  gfx.pen.color,[ctx],0x00008800
  243.         invoke  gfx.brush.color,[ctx],0x00CCCCFF
  244.         invoke  gfx.rectangle,[ctx],20,20,90,60
  245.         invoke  gfx.move.to,[ctx],13,5
  246.         invoke  gfx.line.to,[ctx],105,5
  247.         invoke  gfx.line.to,[ctx],105,75
  248.         invoke  gfx.line.to,[ctx],5,75
  249.         invoke  gfx.line.to,[ctx],5,13
  250.         invoke  gfx.line.to,[ctx],13,5
  251.         invoke  gfx.pen.color,[ctx],0x00888888
  252.         invoke  gfx.polyline,[ctx],poly_points,11
  253.         invoke  gfx.close,[ctx]
  254.  
  255.         mov     [yy],10
  256.         invoke  ini.enum_sections,s_ini,callb
  257.  
  258.         invoke  file.find_first,_f_path,_f_mask,FA_ANY-FA_FOLDER
  259.         cmp     eax,0
  260.         jle     .finished
  261.         mov     ebp,eax
  262.         mov     [yy],10
  263.     @@: lea     edx,[ebp+FileInfo.FileName]
  264.         mcall   4,<450,[yy]>,0x80000000
  265.         add     [yy],10
  266.         invoke  file.find_next,ebp
  267.         cmp     eax,0
  268.         jg      @b
  269.         invoke  file.find_close,ebp
  270.  
  271.   .finished:
  272.  
  273.         ret
  274.  
  275. _f_path db '/rd/1/lib',0
  276. _f_mask db '*ini*',0
  277.  
  278. ;---------------------------------------------------------------------
  279. ;---  ÄÀÍÍÛÅ ÏÐÎÃÐÀÌÌÛ  ----------------------------------------------
  280. ;---------------------------------------------------------------------
  281.  
  282. s_header db 'EXAMPLE APPLICATION',0
  283.  
  284. s_ini db '/rd/1/test001.ini',0
  285. s_sec db 'Panels',0
  286. s_key db 'param1',0
  287.  
  288. align 4
  289. poly_points dd \
  290.   140, 10, \
  291.   150, 10, \
  292.   150, 20, \
  293.   160, 20, \
  294.   160, 30, \
  295.   170, 30, \
  296.   170, 40, \
  297.   180, 40, \
  298.   180, 50, \
  299.   140, 50, \
  300.   140, 10
  301.  
  302. ;---------------------------------------------------------------------
  303.  
  304. align 16
  305. @IMPORT:
  306.  
  307. library \
  308.         libini,'libini.obj',\
  309.         libio ,'libio.obj',\
  310.         libgfx,'libgfx.obj'
  311.  
  312. import  libini, \
  313.         ini.get_str,'ini_get_str',\
  314.         ini.set_str,'ini_set_str',\
  315.         ini.get_int,'ini_get_int',\
  316.         ini.set_int,'ini_set_int',\
  317.         ini.enum_sections,'ini_enum_sections',\
  318.         ini.enum_keys,'ini_enum_keys'
  319.  
  320. import  libio, \
  321. \;      file.aux.match_wildcard,'file_aux_match_wildcard',\
  322.         file.find_first,'file_find_first',\
  323.         file.find_next,'file_find_next',\
  324.         file.find_close,'file_find_close',\
  325.         file.open,'file_open',\
  326.         file.seek,'file_seek',\
  327.         file.write,'file_write',\
  328.         file.truncate,'file_truncate',\
  329.         file.close,'file_close'
  330.  
  331. import  libgfx, \
  332.         gfx.open        ,'gfx_open',\
  333.         gfx.close       ,'gfx_close',\
  334.         gfx.pen.color   ,'gfx_pen_color',\
  335.         gfx.brush.color ,'gfx_brush_color',\
  336.         gfx.pixel       ,'gfx_pixel',\
  337.         gfx.move.to     ,'gfx_move_to',\
  338.         gfx.line.to     ,'gfx_line_to',\
  339.         gfx.line        ,'gfx_line',\
  340.         gfx.polyline    ,'gfx_polyline',\
  341.         gfx.polyline.to ,'gfx_polyline_to',\
  342.         gfx.fillrect    ,'gfx_fillrect',\
  343.         gfx.fillrect.ex ,'gfx_fillrect_ex',\
  344.         gfx.framerect   ,'gfx_framerect',\
  345.         gfx.framerect.ex,'gfx_framerect_ex',\
  346.         gfx.rectangle   ,'gfx_rectangle',\
  347.         gfx.rectangle.ex,'gfx_rectangle_ex'
  348.  
  349. I_END:
  350.  
  351. fh dd ?
  352.  
  353. buf rb 1024
  354.