Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.         create  parent of window
  3. */
  4.  
  5. #define PARENT_WINDOW_DEFAULT_SIZEX             320
  6. #define PARENT_WINDOW_DEFAULT_SIZEY             200
  7.  
  8. #define PARENT_WINDOW_BORDER_WIDTH              5;
  9.  
  10. void gui_get_screen_parameters(void)
  11. {
  12.         int     value;
  13.        
  14.         value=(int)gui_ksys_get_screen_bits_per_pixel();
  15.         screen.bits_per_pixel=(char)value;
  16.         screen.bytes_per_pixel=screen.bits_per_pixel >> 3;
  17.        
  18.         screen.skin_height=gui_ksys_get_skin_height();
  19.  
  20.         screen.x=PARENT_WINDOW_BORDER_WIDTH;
  21.         screen.y=screen.skin_height;
  22.        
  23.         value=gui_ksys_get_screen_size();
  24.         screen.display_size_y=value & 0xffff;
  25.         screen.display_size_y=value >> 16;
  26. }
  27.  
  28. void    gui_draw_window(parent_t *window)
  29. {
  30.         DWORD   flag;
  31.        
  32.         flag=3;
  33.         flag=flag<<24;
  34.         flag +=0xaabbcc;
  35.  
  36.         gui_ksys_begin_draw_window();
  37.         gui_ksys_draw_window(window->ctrl_x,window->ctrl_y,window->ctrl_sizex,window->ctrl_sizey,flag);
  38.         gui_ksys_finish_draw_window();
  39. }
  40.  
  41. //---------------------------------------------------------------------------------
  42. //                              create window parent
  43. //---------------------------------------------------------------------------------
  44. void* CreateWindow(void)
  45. {
  46.         struct HEADERPARENT *WindowParent;
  47.  
  48.         WindowParent=malloc(sizeof(parent_t));
  49.         WindowParent->message=malloc(sizeof(gui_message_t));
  50.         WindowParent->control_for_callback_function=malloc(sizeof(DWORD)*MAX_CALLBACKS);
  51.         WindowParent->callback_for_control_callback=malloc(sizeof(DWORD)*MAX_CALLBACKS);
  52.  
  53.         WindowParent->main_parent=(DWORD*)WindowParent;
  54.         WindowParent->global_active_control_for_keys=(DWORD*)NULL;
  55.  
  56.         WindowParent->control_for_callback_function[0]=(DWORD*)NULL;
  57.         WindowParent->number_callbacks=0;
  58.  
  59.         WindowParent->child_bk=(DWORD*)NULL;
  60.         WindowParent->active_control_for_keys=(DWORD*)NULL;
  61.         WindowParent->active_control_for_mouse=(DWORD*)NULL;
  62.         WindowParent->ctrl_x=0x0;
  63.         WindowParent->ctrl_y=0x0;
  64.         WindowParent->ctrl_sizex=PARENT_WINDOW_DEFAULT_SIZEX;
  65.         WindowParent->ctrl_sizey=PARENT_WINDOW_DEFAULT_SIZEY;
  66.         WindowParent->callback=(DWORD*)NULL;//no callbacks yet
  67.         WindowParent->timer=(DWORD*)NULL;//no timers yet
  68.        
  69.         WindowParent->flags=0;
  70.         WindowParent->flags=WindowParent->flags | FLAG_SHOW_CONTROL;
  71.         WindowParent->flags=WindowParent->flags | FLAG_FOCUSE_INPUT_SUPPOROTE;
  72.  
  73.         WindowParent->number_timers_for_controls=0;
  74.         WindowParent->timer_bk=(DWORD*)NULL;
  75.         WindowParent->timer_fd=(DWORD*)NULL;
  76.  
  77.         WindowParent->calev_bk=(DWORD*)NULL;
  78.         WindowParent->calev_fd=(DWORD*)NULL;
  79.  
  80.         WindowParent->IDL_func=(DWORD*)NULL;
  81.  
  82. //---------------------------------------------------------------------------------
  83. //---------------------------platform depended part of code------------------------
  84. //---------------------------------------------------------------------------------
  85.         //create and initialize screen buffer
  86.         gui_get_screen_parameters();
  87.         //by default draw output to the screen
  88.         screen.draw_output=DRAW_OUTPUT_SCREEN;
  89.         //calculate size of client's arrea
  90.         screen.size_x=WindowParent->ctrl_sizex-9;
  91.         screen.size_y=WindowParent->ctrl_sizey-screen.skin_height-4;
  92. //----------------------------------------------------------------------------------
  93.         ID=0;
  94.         return(WindowParent);
  95. }
  96.  
  97. //---------------------------------------------------------------------------------
  98. //                              create window parent
  99. //---------------------------------------------------------------------------------
  100. void SetWindowSizeRequest(parent_t *WindowParent,int size_x,int size_y)
  101. {
  102.         static int      x,y,sizex,sizey;
  103. //---------------------------------------------------------------------------------
  104. //---------------------------platform depended part of code------------------------
  105. //---------------------------------------------------------------------------------
  106.         x=WindowParent->ctrl_x;
  107.         y=WindowParent->ctrl_y;
  108.         sizex=size_x;
  109.         sizey=size_y;
  110.         gui_ksys_set_position_and_size_window(x,y,sizex,sizey);
  111. //---------------------------------------------------------------------------------
  112.         WindowParent->ctrl_sizex=sizex;
  113.         WindowParent->ctrl_sizey=sizey;
  114.  
  115.         screen.size_x=WindowParent->ctrl_sizex-9;
  116.         screen.size_y=WindowParent->ctrl_sizey-screen.skin_height-4;   
  117. }
  118.  
  119. void GetNewWindowSizePos(parent_t *WindowParent)
  120. {
  121.         static  process_table_t procinfo;
  122.        
  123.         gui_ksys_get_current_process_information(&procinfo);
  124.        
  125.         WindowParent->ctrl_x=(DWORD)procinfo.winx_start;
  126.         WindowParent->ctrl_y=(DWORD)procinfo.winy_start;
  127.         WindowParent->ctrl_sizex=(DWORD)procinfo.winx_size;
  128.         WindowParent->ctrl_sizey=(DWORD)procinfo.winy_size;
  129.  
  130.         //get screen parameters again
  131.         gui_get_screen_parameters();
  132. }
  133.