Subversion Repositories Kolibri OS

Rev

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->callback=(DWORD*)NULL;
  78.         WindowParent->calev_bk=(DWORD*)NULL;
  79.         WindowParent->calev_fd=(DWORD*)NULL;
  80.  
  81.         WindowParent->IDL_func=(DWORD*)NULL;
  82.  
  83. //---------------------------------------------------------------------------------
  84. //---------------------------platform depended part of code------------------------
  85. //---------------------------------------------------------------------------------
  86.         //create and initialize screen buffer
  87.         gui_get_screen_parameters();
  88.         //by default draw output to the screen
  89.         screen.draw_output=DRAW_OUTPUT_SCREEN;
  90.         //calculate size of client's arrea
  91.        screen.size_x=WindowParent->ctrl_sizex-9;
  92.        screen.size_y=WindowParent->ctrl_sizey-screen.skin_height-4;
  93. //----------------------------------------------------------------------------------
  94.        ID=0;
  95. #ifdef DEBUG
  96.        printf("\ncreated parent window %d",(DWORD)WindowParent);
  97. #endif
  98.        return(WindowParent);
  99. }
  100.  
  101. //---------------------------------------------------------------------------------
  102. //                              create window parent
  103. //---------------------------------------------------------------------------------
  104. void SetWindowSizeRequest(parent_t *WindowParent,int size_x,int size_y)
  105. {
  106.        static int      x,y,sizex,sizey;
  107. //---------------------------------------------------------------------------------
  108. //---------------------------platform depended part of code------------------------
  109. //---------------------------------------------------------------------------------
  110.        x=WindowParent->ctrl_x;
  111.        y=WindowParent->ctrl_y;
  112.        sizex=size_x;
  113.        sizey=size_y;
  114.        gui_ksys_set_position_and_size_window(x,y,sizex,sizey);
  115. //---------------------------------------------------------------------------------
  116.        WindowParent->ctrl_sizex=sizex;
  117.        WindowParent->ctrl_sizey=sizey;
  118.  
  119.        screen.size_x=WindowParent->ctrl_sizex-9;
  120.        screen.size_y=WindowParent->ctrl_sizey-screen.skin_height-4;
  121. #ifdef DEBUG
  122.        printf("\nwindow resized new sizex=%d sizey=%d",
  123.                WindowParent->ctrl_sizex,
  124.                WindowParent->ctrl_sizey);
  125. #endif
  126.  
  127. }
  128.  
  129. void GetNewWindowSizePos(parent_t *WindowParent)
  130. {
  131.        static  process_table_t procinfo;
  132.        
  133.        gui_ksys_get_current_process_information(&procinfo);
  134.        
  135.        WindowParent->ctrl_x=(DWORD)procinfo.winx_start;
  136.        WindowParent->ctrl_y=(DWORD)procinfo.winy_start;
  137.        WindowParent->ctrl_sizex=(DWORD)procinfo.winx_size;
  138.        WindowParent->ctrl_sizey=(DWORD)procinfo.winy_size;
  139.  
  140.        //get screen parameters again
  141.        gui_get_screen_parameters();
  142. }
  143.