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. void    callback_func_delete_window(header_t *control,void *data)
  11. {
  12.         QuitLibGUI((parent_t*)control);
  13. }
  14.  
  15. void    callback_func(header_t *control,void *data)
  16. {
  17.         printf("\npressed button with ID=%d control=%d",(int)control->ctrl_ID,(int)control);
  18. }
  19.  
  20. int main(int argc, char *argv[])
  21. {
  22.         parent_t                        *window;
  23.         gui_button_data_t               button_data;
  24.         gui_button_t                    *button;
  25.         gui_scrolled_window_data_t      scroll_win_data;
  26.         gui_scrolled_window_t   *ScrollWin;
  27.         int                             i,j;
  28.         static  char                    txt[20];
  29.        
  30.         //load libGUI library
  31.         LoadLibGUI(NULL);
  32.         //create main window
  33.         window=CreateWindow();
  34.         //change size of window
  35.         SetWindowSizeRequest(window,270,282);
  36.        
  37.         //create scrolled window
  38.         scroll_win_data.x=5;
  39.         scroll_win_data.y=5;
  40.         scroll_win_data.width=250;
  41.         scroll_win_data.height=250;
  42.         ScrollWin=CreateScrolledWindow(&scroll_win_data);
  43.  
  44.         //create buttons
  45.         for(j=1;j<=10;j++)
  46.         {
  47.                 for(i=1;i<=10;i++)
  48.                 {
  49.                         button_data.x=10+(i-1)*75;
  50.                         button_data.y=10+(j-1)*25;
  51.                         button_data.width=70;
  52.                         button_data.height=20;
  53.  
  54.                         snprintf(txt,20,"(%d,%d)",j,i);
  55.                         button=CreateButtonWithText(&button_data,txt);
  56.                
  57.                         SetCallbackFunction(button,BUTTON_PRESSED_EVENT,&callback_func,NULL);
  58.                         ScrolledWindowPackControls(ScrollWin,button);
  59.                 }
  60.         }
  61.         //set callback function for button close window
  62.         SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
  63.         //pack scrolled window in window
  64.         PackControls(window,ScrollWin);
  65.         //start main libGUI loop
  66.         LibGUImain(window);
  67. }
  68.