Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;
  3. ; This is example using GUI component Number from libGUI.
  4. ;
  5. ;
  6.  
  7. include 'macros.inc'
  8. use32
  9.         db      'MENUET01'
  10.         dd      1
  11.         dd      start
  12.         dd      i_end
  13.         dd      1700
  14.         dd      1700
  15.         dd      0
  16.         dd      path
  17.  
  18. start:
  19.         ;init hepe of memory
  20.         mcall   68,11
  21.  
  22.         ;set current dir as ./
  23.         call GetPath
  24.  
  25.         ;load dll
  26.         mcall   68,19,path
  27.  
  28.         test    eax,eax
  29.         jnz    libGUI_loaded
  30.  
  31.         mcall 68,19,sys_libGUI_path
  32.  
  33.            test eax,eax
  34.            jnz libGUI_loaded
  35.  
  36.              mcall -1
  37.  
  38.         libGUI_loaded:
  39.  
  40.         mov [myexport],eax
  41.  
  42.         ;load dll functions
  43.  
  44.         push fnDestroyControl
  45.         push [myexport]
  46.         call _ksys_cofflib_getproc
  47.         mov [destroy_control],eax
  48.  
  49.         push fnSendMessage
  50.         push [myexport]
  51.         call _ksys_cofflib_getproc
  52.         mov [send_message],eax
  53.  
  54.         push fnCraeteButton
  55.         push [myexport]
  56.         call _ksys_cofflib_getproc
  57.         mov [craete_button],eax
  58.  
  59.         push fnCraeteNumber
  60.         push [myexport]
  61.         call _ksys_cofflib_getproc
  62.         mov [craete_number],eax
  63.  
  64.         ;set events mask
  65.         mcall   40,1100111b
  66.  
  67.         ;get standart colors table
  68.         mcall   48,3,ColorsTable,40
  69.  
  70.         ;*********************************************
  71.         ;****************Init Butttons****************
  72.         ;*********************************************
  73.  
  74.         mov ecx,[ColorsTable+8]
  75.         and ecx,0xffffff
  76.  
  77.         mov [Button1.type],byte 10010001b
  78.         mov [Button1.x],10
  79.         mov [Button1.y],50
  80.         mov [Button1.width],word 70
  81.         mov [Button1.height],word 20
  82.         mov [Button1.color1],dword ecx
  83.         mov [Button1.color2],dword 0xffffff
  84.         mov [Button1.text],text1
  85.  
  86.         push Button1
  87.         push Parend
  88.         call [craete_button]
  89.         mov [PointerToControlForButtonExit],eax
  90.  
  91.          mov ecx,[ColorsTable+8]
  92.          and ecx,0xffffff
  93.  
  94.         ;********************************************
  95.         ;****************Init Numbers****************
  96.         ;********************************************
  97.  
  98.         mov [NumberFloat.type],byte 10000010b
  99.         mov [NumberFloat.color],0xffffff
  100.         mov [NumberFloat.x],20
  101.         mov [NumberFloat.y],10
  102.         mov [NumberFloat.parameters],4*65536+5
  103.         mov [NumberFloat.number],-1234.56789
  104.  
  105.         mov [NumberInteger.type],byte 10000000b
  106.         mov [NumberInteger.color],0xffffff
  107.         mov [NumberInteger.x],26
  108.         mov [NumberInteger.y],30
  109.         mov [NumberInteger.parameters],8*65536
  110.         mov [NumberInteger.number],12345678
  111.  
  112.         push NumberFloat
  113.         push Parend
  114.         call [craete_number]
  115.         mov [PointerToControlForNumberFloat],eax
  116.  
  117.         push NumberInteger
  118.         push Parend
  119.         call [craete_number]
  120.         mov [PointerToControlForNumberInteger],eax
  121.  
  122.         call draw_window
  123.  
  124.  
  125.         ;send message 1 for redrawing ALL controls
  126.         mov [Message],dword 1
  127.  
  128.         push Message
  129.         push Parend
  130.         call [send_message]
  131.  
  132. still:
  133.         mcall   10
  134.  
  135.         ;check for redraw window
  136.         cmp eax,1
  137.         jne no_window
  138.  
  139.           call draw_window
  140.  
  141.           mov [Message],dword 1
  142.           push Message
  143.           push Parend
  144.           call [send_message]
  145.  
  146.         jmp still
  147.         no_window:
  148.  
  149.         ;check for keys events
  150.         cmp eax,2
  151.         jne no_keys
  152.  
  153.           mcall   2
  154.           shr eax,8
  155.  
  156.           mov [Message],dword 2
  157.           mov [Message+4],eax
  158.  
  159.           push Message
  160.           push Parend
  161.           call [send_message]
  162.  
  163.           mov eax,[Message+4]
  164.  
  165.           cmp al,27
  166.           je exit
  167.  
  168.         jmp still
  169.         no_keys:
  170.  
  171.         ;check for pressed butons
  172.         cmp eax,3
  173.         jne no_buttons
  174.  
  175.           mcall   17
  176.           shr eax,8
  177.  
  178.         jmp still
  179.         no_buttons:
  180.  
  181.         ;check for mouse events
  182.         cmp eax,6
  183.         jne no_mouse
  184.  
  185.          mov [Message],dword 6
  186.  
  187.          mcall   37,1
  188.          mov ebx,eax
  189.          shr eax,16 ;x
  190.          and ebx,0xffff ;y
  191.  
  192.          mov [Message+4],eax
  193.          mov [Message+8],ebx
  194.  
  195.          mcall   37,2
  196.          mov [Message+12],eax
  197.  
  198.          ;send system events to control
  199.          push Message
  200.          push Parend
  201.          call [send_message]
  202.  
  203.          mov eax,[PointerToControlForButtonExit]
  204.  
  205.          xor ebx,ebx
  206.          mov bl,byte[eax+45]
  207.          cmp bl,11b
  208.          jne no_crossing_pressing_button
  209.  
  210.            mov [button_pressed],1
  211.  
  212.          no_crossing_pressing_button:
  213.  
  214.          xor ebx,ebx
  215.          mov bl,byte[eax+45]
  216.          cmp bl,1b
  217.          jne no_crossing_button
  218.  
  219.            cmp [button_pressed],1
  220.            jne no_crossing_button
  221.  
  222.               jmp exit
  223.  
  224.          no_crossing_button:
  225.  
  226.          jmp still
  227.          no_mouse:
  228.  
  229.         jmp still
  230.  
  231. exit:
  232.  
  233.         push [PointerToControlForButtonExit]
  234.         call [destroy_control]
  235.  
  236.         push [PointerToControlForNumberFloat]
  237.         call [destroy_control]
  238.  
  239.         push [PointerToControlForNumberInteger]
  240.         call [destroy_control]
  241.  
  242.         mcall   -1
  243.  
  244.  
  245.  
  246. ;**********************************************
  247. ;*******************Draw window****************
  248. ;**********************************************
  249.  
  250. draw_window:
  251.  
  252.         mcall   12,1
  253.  
  254.         xor eax,eax
  255.         mov ebx,50
  256.         mov ecx,50
  257.         shl ebx,16
  258.         shl ecx,16
  259.         add ebx,100
  260.         add ecx,100
  261.         mov edx,0x03aabbcc
  262.         mov esi,0x805080d0
  263.         mov edi,0x005080d0
  264.         mcall
  265.  
  266.         mcall   12,2
  267.         ret
  268.  
  269.  
  270. GetPath:
  271.  
  272.         mov ebx,255
  273.         mov ecx,path
  274.  
  275.         next_symvol:
  276.         mov edx,ecx
  277.         add edx,ebx
  278.  
  279.         xor eax,eax
  280.         mov al,[edx]
  281.         cmp eax,'/'
  282.         je exit_path
  283.  
  284.         dec ebx
  285.         jnz next_symvol
  286.  
  287.         exit_path:
  288.  
  289.         inc edx
  290.         mov esi,dll_name
  291.         mov edi,edx
  292.         mov ecx,10
  293.         rep movsb
  294.  
  295.         ret
  296.  
  297.  
  298. include 'getproc.asm'
  299.  
  300. ;************************************************************
  301. ;***************************DATA*****************************
  302. ;************************************************************
  303.  
  304. align 4
  305.  
  306. dll_name        db 'libGUI.obj',0
  307. sys_libGUI_path db '/sys/lib/libGUI.obj',0
  308.  
  309. text1           db 'Exit',0
  310.  
  311. fnDestroyControl                     db 'DestroyControl',0
  312. fnSendMessage                        db 'SendMessage',0
  313. fnCraeteButton                       db 'CraeteButton',0
  314. fnCraeteNumber                       db 'CraeteNumber',0
  315.  
  316. myexport                             dd 0
  317.  
  318. destroy_control                      dd 0
  319. send_message                         dd 0
  320. craete_button                         dd 0
  321. craete_number                         dd 0
  322.  
  323. PointerToControlForButtonExit        dd 0
  324.  
  325. PointerToControlForNumberFloat       dd 0
  326. PointerToControlForNumberInteger     dd 0
  327.  
  328. button_pressed                       dd 0
  329.  
  330. path                                 rb 256
  331.  
  332. Parend:        dd 0,0,0,0,0,0,0,0,0,0,0,0   ;44 bytes
  333. Message                               rd 4
  334.  
  335. ColorsTable  rd 10
  336.  
  337. struc BUTTON
  338. {
  339.  .type             db 1
  340.  .flag             db 1
  341.  .x                dw 1
  342.  .y                dw 1
  343.  .width            dw 1
  344.  .height           dw 1
  345.  .image            dd 1
  346.  .imageX           dw 1
  347.  .imageY           dw 1
  348.  .imageSizeX       dw 1
  349.  .imageSizeY       dw 1
  350.  .transparentColor dd 1
  351.  .text             dd 1
  352.  .textX            dw 1
  353.  .textY            dw 1
  354.  .textcolor        dd 1
  355.  .color1           dd 1
  356.  .color2           dd 1
  357.  .mouseX           dw 1
  358.  .mouseY           dw 1
  359. }
  360.  
  361.  
  362. struc NUMBER
  363. {
  364.  .type             rb 1
  365.  .flag             rb 1
  366.  .color            rd 1
  367.  .x                rd 1
  368.  .y                rd 1
  369.  .number           rd 1
  370.  .parameters       rd 1
  371. }
  372.  
  373. Button1             BUTTON
  374. NumberFloat         NUMBER
  375. NumberInteger       NUMBER
  376.  
  377. i_end:
  378.