Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;Hello world example
  2.  
  3. use32
  4.         db      'MENUET01'
  5.         dd      1
  6.         dd      start
  7.         dd      i_end
  8.         dd      0x1500
  9.         dd      0x1500
  10.         dd      0
  11.         dd      0
  12.  
  13. TRUE    =     1
  14. FALSE   =     0
  15.  
  16. include 'libGUI.inc'
  17.  
  18. start:
  19.         ;load libGUI labrari
  20.         push NULL  ;use default system path to library
  21.         call LoadLibGUI
  22.  
  23.         ;create main window
  24.         CreateWindow
  25.         mov [window],eax
  26.  
  27.         ;change size of main window
  28.         SetWindowSizeRequest [window],90,60
  29.  
  30.         ;set callback function for button close window
  31.         SetCallbackFunction [window],DELETE_EVENT,callback_func_delete_window,NULL
  32.  
  33.         ;create control Button with text
  34.         mov [bdata.x],5
  35.         mov [bdata.y],5
  36.         mov [bdata.wight],70
  37.         mov [bdata.height],20
  38.         CreateButtonWithText bdata,btext
  39.         mov [button],eax
  40.  
  41.         ;set callback functions for button
  42.         SetCallbackFunction [button],BUTTON_ENTER_EVENT,callback_func1,NULL
  43.         SetCallbackFunction [button],BUTTON_PRESSED_EVENT,callback_func2,NULL
  44.         SetCallbackFunction [button],BUTTON_RELEASED_EVENT,callback_func3,NULL
  45.         SetCallbackFunction [button],BUTTON_LEAVE_EVENT,callback_func4,NULL
  46.  
  47.         ;pack control Text in window
  48.         PackControls [window],[button]
  49.  
  50.         ;start libGUI main loop
  51.         LibGUImain [window]
  52.  
  53.  
  54. ;void callback_func_delete_window(header_t *control,void *data)
  55. callback_func_delete_window:
  56.  
  57.         mov eax,[esp+4] ;control
  58.  
  59.         QuitLibGUI eax
  60.  
  61.         ret
  62.  
  63. ;void callback_func1(header_t *control,void *data)
  64. callback_func1:
  65.         ;save esi befor use
  66.         push esi
  67.         mov esi,btext1
  68.         call gui_ksys_debug_out_str
  69.         pop esi
  70.  
  71.         ret
  72.  
  73. ;void callback_func2(header_t *control,void *data)
  74. callback_func2:
  75.         ;save esi befor use
  76.         push esi
  77.         mov esi,btext2
  78.         call gui_ksys_debug_out_str
  79.         pop esi
  80.  
  81.         ret
  82.  
  83. ;void callback_func3(header_t *control,void *data)
  84. callback_func3:
  85.         ;save esi befor use
  86.         push esi
  87.         mov esi,btext3
  88.         call gui_ksys_debug_out_str
  89.         pop esi
  90.  
  91.         ret
  92.  
  93. ;void callback_func4(header_t *control,void *data)
  94. callback_func4:
  95.         ;save esi befor use
  96.         push esi
  97.         mov esi,btext4
  98.         call gui_ksys_debug_out_str
  99.         pop esi
  100.  
  101.         ret
  102.  
  103. align 4
  104. ;----------------------data--------------------
  105. btext           db 'Click Me!',0
  106. btext1          db 13,10,'entry in button',0
  107. btext2          db 13,10,'button pressed',0
  108. btext3          db 13,10,'button released',0
  109. btext4          db 13,10,'leave button',0
  110.  
  111. bdata           gui_button_data_t
  112. window          rd 1;parent_t *window
  113. button          rd 1;gui_button_t *button
  114.  
  115. i_end: