Subversion Repositories Kolibri OS

Rev

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.  
  8. #define FALSE           0
  9. #define TRUE            1
  10.  
  11. void    callback_func_delete_window(header_t *control,void *data)
  12. {
  13.         printf("\nlibGUI quit...");
  14.         QuitLibGUI((parent_t*)control);
  15. }
  16.  
  17. void ScrollStateH(header_t *control,void *data)
  18. {
  19.         gui_scroll_bar_t        *hsc;
  20.  
  21.         hsc=(gui_scroll_bar_t*)control;
  22.         printf("\nhorizontal ruler position %d%%",(int)(hsc->ruller_pos*100));
  23. }
  24.  
  25. void ScrollStateV(header_t *control,void *data)
  26. {
  27.         gui_scroll_bar_t        *vsc;
  28.  
  29.         vsc=(gui_scroll_bar_t*)control;
  30.         printf("\nvertical ruler position %d%%",(int)(vsc->ruller_pos*100));
  31. }
  32.  
  33. int main(int argc, char *argv[])
  34. {
  35.         parent_t                        *window;
  36.         gui_callback_t          *id1,*id2;
  37.         gui_scroll_bar_data_t   horizontal_sbar_data;
  38.         gui_scroll_bar_data_t   vertical_sbar_data;
  39.         gui_scroll_bar_t                *ScrollBarH;
  40.         gui_scroll_bar_t                *ScrollBarV;
  41.  
  42.         //load libGUI library
  43.         LoadLibGUI(NULL);//use default system path to library
  44.         //create main window
  45.         window=CreateWindow();
  46.         //change size of window
  47.         SetWindowSizeRequest(window,270,207);
  48.         //create horizontal scroll bar
  49.         horizontal_sbar_data.x=5;
  50.         horizontal_sbar_data.y=5;
  51.         horizontal_sbar_data.width=250;
  52.         horizontal_sbar_data.height=16;
  53.         horizontal_sbar_data.ruller_size=0.2;//size of ruler E [0,1]
  54.         horizontal_sbar_data.ruller_pos=0.5;//ruler position E [0,1]
  55.         horizontal_sbar_data.ruller_step=0.1;//step of change ruler pos after press of button E [0,1]
  56.         //create vertical scroll bar
  57.         vertical_sbar_data.x=5;
  58.         vertical_sbar_data.y=26;
  59.         vertical_sbar_data.width=16;
  60.         vertical_sbar_data.height=150;
  61.         vertical_sbar_data.ruller_size=0.5;//size of ruler E [0,1]
  62.         vertical_sbar_data.ruller_pos=0.05;//ruler position E [0,1]
  63.         vertical_sbar_data.ruller_step=0.1;//step of change ruler pos after press of button E [0,1]
  64.        
  65.         //create horizontal and vertical scroll bars
  66.         ScrollBarH=CreateHorizontalScrollBar(&horizontal_sbar_data);
  67.         ScrollBarV=CreateVerticalScrollBar(&vertical_sbar_data);
  68.         //set callback functions for scroll bars
  69.         id1=SetCallbackFunction(ScrollBarH,SCROLLBAR_CHANGED_EVENT,&ScrollStateH,NULL);
  70.         id2=SetCallbackFunction(ScrollBarV,SCROLLBAR_CHANGED_EVENT,&ScrollStateV,NULL);
  71.         //pack scroll bars in window
  72.         PackControls(window,ScrollBarH);
  73.         PackControls(window,ScrollBarV);
  74.         //start minl libGUI loop
  75.         LibGUImain(window);
  76. }
  77.