Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.         test libGUI library
  3. */
  4. #include "stdarg.h"
  5. #include "libGUI.h"
  6. #include "stdio.h"
  7. #include "stdlib.h"
  8. #include "string.h"
  9.  
  10. #define FALSE           0
  11. #define TRUE            1
  12.  
  13. void    callback_func_delete_window(header_t *control,void *data)
  14. {
  15.         QuitLibGUI((parent_t*)control);
  16. }
  17.  
  18. void    callback_func1(header_t *control,void *data)
  19. {
  20.         printf("\nentry in button");
  21. }
  22.  
  23. void    callback_func2(header_t *control,void *data)
  24. {
  25.         printf("\nbutton pressed");
  26. }
  27.  
  28. void    callback_func3(header_t *control,void *data)
  29. {
  30.         printf("\nbutton released");
  31. }
  32.  
  33. void    callback_func4(header_t *control,void *data)
  34. {
  35.         printf("\nleave button");
  36. }
  37.  
  38. int main(int argc, char *argv[])
  39. {
  40.         parent_t                *window;
  41.         gui_callback_t  *id1,*id2,*id3,*id4;
  42.         gui_button_data_t       button_data;
  43.         gui_button_t            *button;
  44.  
  45.         //load libGUI library
  46.         LoadLibGUI(NULL);
  47.  
  48.         //create main window
  49.         window=CreateWindow();
  50.         SetWindowSizeRequest(window,90,60);
  51.         //create button
  52.         button_data.x=5;
  53.         button_data.y=5;
  54.         button_data.width=70;
  55.         button_data.height=20;
  56.         //create button with text
  57.         button=CreateButtonWithText(&button_data,"Click my!");
  58.         //set callback functions for button close window
  59.         SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
  60.        
  61.         //set callback functions for button
  62.         id1=SetCallbackFunction(button,BUTTON_ENTER_EVENT,&callback_func1,NULL);
  63.         id2=SetCallbackFunction(button,BUTTON_PRESSED_EVENT,&callback_func2,NULL);
  64.         id3=SetCallbackFunction(button,BUTTON_RELEASED_EVENT,&callback_func3,NULL);
  65.         id4=SetCallbackFunction(button,BUTTON_LEAVE_EVENT,&callback_func4,NULL);
  66.         //pack button in window
  67.         PackControls(window,button);
  68.         //start main libGUI loop
  69.         LibGUImain(window);
  70. }
  71.