Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.        service  structures of libGUI
  3. */
  4.  
  5. static DWORD    ID;
  6.  
  7. //screen's parameters
  8. #define BYTES_PER_PIXEL                                 4
  9.  
  10. //platform parameters
  11. #define KOLIBRIOS                                               1
  12. //#define       DEBUG
  13.  
  14. //boolean constants
  15. #define TRUE                                                    0x1
  16. #define FALSE                                                   0x0
  17.  
  18. //maximum callbacks for one check of callback
  19. #define MAX_CALLBACKS                                           255
  20.  
  21. /////////////////////////////////////////////////////////////////////////
  22. //                      libGUI sysyem messages types
  23. /////////////////////////////////////////////////////////////////////////
  24. #define         MESSAGE_FULL_REDRAW_ALL                         1
  25. #define         MESSAGE_KEYS_EVENT                                      2
  26. #define         MESSAGE_SPECIALIZED                                     3
  27. #define         MESSAGE_SET_FOCUSE                                      4
  28. #define         MESSAGE_CHANGE_FOCUSE                           5
  29. #define         MESSAGE_MOUSE_EVENT                                     6
  30. #define         MESSAGE_CHANGE_POSITION_EVENT                   7
  31. #define         MESSAGE_CHANGESIZE_EVENT                                8
  32. #define         MESSAGE_CALL_TIMER_EVENT                                9
  33. #define         MESSAGE_FULL_REDRAW_ALL_WITH_FINITION           10
  34. #define         MESSAGE_SET_MAIN_PARENT                         11
  35. #define         MESSAGE_DESTROY_CONTROL                         -1
  36.  
  37. /////////////////////////////////////////////////////////////////////////
  38. //                      system flags of controls
  39. /////////////////////////////////////////////////////////////////////////
  40. #define FLAG_SHOW_CONTROL                                       0x1
  41. #define FLAG_HIDE_CONTROL                                       0xfffe
  42. #define FLAG_FOCUSE_INPUT_SUPPOROTE                             0x2
  43. #define FLAG_FOCUSE_INPUT_NOTSUPPOROTE                  0xfffd
  44. #define FLAG_FOCUSE_INPUT_ON                                    0x4
  45. #define FLAG_FOCUSE_INPUT_OFF                           0xfffb
  46. #define FLAG_CONNECT_EVENT_ON                           0x8
  47. #define FLAG_CONNECT_EVENT_OFF                          0xfff7
  48. #define FLAG_MOUSE_BLOCKED_ON                           0x10
  49. #define FLAG_MOUSE_BLOCKED_OFF                          0xffef
  50. #define FLAG_GET_SPECIALIZED_MESSAGE_ON                 0x20
  51. #define FLAG_GET_SPECIALIZED_MESSAGE_OFF                        0xffdf
  52.  
  53. /////////////////////////////////////////////////////////////////////////
  54. //              system flags of callback functions
  55. /////////////////////////////////////////////////////////////////////////
  56. #define FLAG_BLOCK_CALLBACK_ON                          0x1
  57. #define FLAG_BLOCK_CALLBACK_OFF                         0xfe
  58.  
  59. /////////////////////////////////////////////////////////////////////////
  60. //              system flags of main wondow for timers
  61. /////////////////////////////////////////////////////////////////////////
  62. #define FLAG_TIMER_ON                                           0x1
  63. #define FLAG_TIMER_OFF                                  0xfe
  64.  
  65. /////////////////////////////////////////////////////////////////////////
  66. //                      system keys states
  67. /////////////////////////////////////////////////////////////////////////
  68. #define KEY_DOWN                                                16
  69. #define KEY_UP                                                  17
  70. #define KEY_HOTKEY                                              18
  71. /////////////////////////////////////////////////////////////////////////
  72. //                      system mouse buttons states
  73. /////////////////////////////////////////////////////////////////////////
  74. #define MOUSE_LEFT_BUTTON_DOWN                          19
  75. #define MOUSE_LEFT_BUTTON_UP                                    20
  76. #define MOUSE_RIGHT_BUTTON_DOWN                         21
  77. #define MOUSE_RIGHT_BUTTON_UP                           22
  78. #define MOUSE_MIDDLE_BUTTON_DOWN                                23
  79. #define MOUSE_MIDDLE_BUTTON_UP                          24
  80. #define MOUSE_4_BUTTON_DOWN                                     25
  81. #define MOUSE_4_BUTTON_UP                                       26
  82. #define MOUSE_5_BUTTON_DOWN                                     27
  83. #define MOUSE_5_BUTTON_UP                                       28
  84.  
  85.  
  86. /////////////////////////////////////////////////////////////////
  87. //              CONNECT EVENTS FOR CALLBACKs
  88. /////////////////////////////////////////////////////////////////
  89.  
  90. ////////////////////////////////////////////////////////////////
  91. //              connect events for button
  92. ////////////////////////////////////////////////////////////////
  93. #define BUTTON_ENTER_EVENT                                      29
  94. #define BUTTON_LEAVE_EVENT                                      30
  95. #define BUTTON_PRESSED_EVENT                                    31
  96. #define BUTTON_RELEASED_EVENT                           32
  97.  
  98. ////////////////////////////////////////////////////////////////
  99. //              connect events for button
  100. ////////////////////////////////////////////////////////////////
  101. #define SCROLLBAR_CHANGED_EVENT                         33
  102.  
  103. ////////////////////////////////////////////////////////////////
  104. //              connect events for main parent window
  105. ////////////////////////////////////////////////////////////////
  106. #define DELETE_EVENT                                            36
  107.  
  108. ////////////////////////////////////////////////////////////////////
  109. //screen buffer parameters
  110. ////////////////////////////////////////////////////////////////////
  111. #define DRAW_OUTPUT_SCREEN                                      0
  112. #define DRAW_OUTPUT_BUFFER                                      1
  113.  
  114.  
  115. static struct   SCREEN
  116. {
  117.         DWORD   bits_per_pixel;
  118.         DWORD   bytes_per_pixel;
  119.         DWORD   draw_output;
  120.         int     x;
  121.         int     y;
  122.         int     size_x;
  123.         int     size_y;
  124.         int     skin_height;
  125.         int     display_size_x;
  126.         int     display_size_y;
  127.         char    *buffer;
  128. }screen;
  129.  
  130. ////////////////////////////////////////////////////////////////
  131. //      header of parent of control
  132. ////////////////////////////////////////////////////////////////
  133. #pragma pack(push,1)
  134. struct HEADERPARENT
  135. {
  136.         DWORD   *ctrl_proc;
  137.         DWORD   *ctrl_fd;
  138.         DWORD   *ctrl_bk;
  139.         DWORD   *child_fd;
  140.         DWORD   *child_bk;
  141.         DWORD   *parent;
  142.         DWORD   *main_parent;
  143.         DWORD   ctrl_x;
  144.         DWORD   ctrl_y;
  145.         DWORD   ctrl_sizex;
  146.         DWORD   ctrl_sizey;
  147.         DWORD   ctrl_ID;
  148.         DWORD   *active_control_for_keys;
  149.         DWORD   *active_control_for_mouse;
  150.         DWORD   *callback;
  151.         DWORD   *finition;
  152.         DWORD   *timer;
  153.         DWORD   flags;
  154.  
  155.         DWORD   **control_for_callback_function;
  156.         DWORD   **callback_for_control_callback;
  157.         DWORD   number_callbacks;
  158.         DWORD   *global_active_control_for_keys;
  159.         DWORD   *message;
  160.         DWORD   *timer_bk;
  161.         DWORD   *timer_fd;
  162.         DWORD   number_timers_for_controls;
  163.         DWORD   *calev_bk;
  164.         DWORD   *calev_fd;
  165.         DWORD   *IDL_func;
  166.         DWORD   *IDL_func_data;
  167. };
  168. #pragma pack(pop)
  169.  
  170. typedef struct HEADERPARENT parent_t;
  171.  
  172. ////////////////////////////////////////////////////////////////
  173. //      header of control
  174. ////////////////////////////////////////////////////////////////
  175. #pragma pack(push,1)
  176. struct HEADER
  177. {
  178.         DWORD   *ctrl_proc;
  179.         DWORD   *ctrl_fd;
  180.         DWORD   *ctrl_bk;
  181.         DWORD   *child_fd;
  182.         DWORD   *child_bk;
  183.         DWORD   *parent;
  184.         DWORD   *main_parent;
  185.         DWORD   ctrl_x;
  186.         DWORD   ctrl_y;
  187.         DWORD   ctrl_sizex;
  188.         DWORD   ctrl_sizey;
  189.         DWORD   ctrl_ID;
  190.         DWORD   *active_control_for_keys;
  191.         DWORD   *active_control_for_mouse;
  192.         DWORD   *callback;
  193.         DWORD   *finition;
  194.         DWORD   *timer;
  195.         DWORD   flags;
  196. };
  197. #pragma pack(pop)
  198.  
  199. typedef struct HEADER header_t;
  200. ////////////////////////////////////////////////////////////////
  201. //      callback structure for callback function of control
  202. ////////////////////////////////////////////////////////////////
  203. #pragma pack(push,1)
  204. struct CALLBACK
  205. {
  206.         DWORD   *clb_bk;
  207.         DWORD   *clb_fd;
  208.         DWORD   *clb_control;
  209.         DWORD   *func;
  210.         DWORD   *func_data;
  211.         DWORD   connect_event;
  212.         DWORD   flags;
  213. };
  214. #pragma pack(pop)
  215.  
  216. typedef struct CALLBACK gui_callback_t;
  217. ////////////////////////////////////////////////////////////////
  218. //                      timer
  219. ////////////////////////////////////////////////////////////////
  220. #pragma pack(push,1)
  221. struct TIMER
  222. {
  223.         DWORD   *tmr_bk;
  224.         DWORD   *tmr_fd;
  225.         DWORD   *tmr_parent;
  226.         DWORD   *func;
  227.         DWORD   *func_data;
  228.         DWORD   last_time;
  229.         DWORD   time_tick;
  230.         DWORD   flags;
  231. };
  232. #pragma pack(pop)
  233.  
  234. typedef struct TIMER gui_timer_t;
  235. ////////////////////////////////////////////////////////////////
  236. //              structure for callback events
  237. ////////////////////////////////////////////////////////////////
  238. #pragma pack(push,1)
  239. struct CALLBACKEVENT
  240. {
  241.         DWORD   *calev_bk;
  242.         DWORD   *calev_fd;
  243.         DWORD   *calev_parent;
  244.         DWORD   *func;
  245.         DWORD   *func_data;
  246.         DWORD   event_type;
  247. };
  248. #pragma pack(pop)
  249.  
  250. typedef struct CALLBACKEVENT gui_callbackevent_t;
  251. ////////////////////////////////////////////////////////////////
  252. //              structure for callback events
  253. ////////////////////////////////////////////////////////////////
  254. #pragma pack(push,1)
  255. struct FINITION
  256. {
  257.         DWORD   x;
  258.         DWORD   y;
  259.         DWORD   sizex;
  260.         DWORD   sizey;
  261.         char    flags;
  262. };
  263. #pragma pack(pop)
  264.  
  265. typedef struct FINITION finition_t;
  266. ////////////////////////////////////////////////////////////////
  267. //              type of data - structure message
  268. ////////////////////////////////////////////////////////////////
  269. #pragma pack(push,1)
  270. struct MESSAGE
  271. {
  272.         DWORD   type;
  273.         DWORD   arg1;
  274.         DWORD   arg2;
  275.         DWORD   arg3;
  276.         DWORD   arg4;
  277. };
  278. #pragma pack(pop)
  279.  
  280. typedef struct MESSAGE gui_message_t;
  281. ////////////////////////////////////////////////////////////////
  282. //                      prototype of functions
  283. ////////////////////////////////////////////////////////////////
  284. void (*ControlProc)(void *Control,gui_message_t *message);
  285. void (*CallbackFunction)(header_t  *Control,void *data);
  286. void (*TimerCallbackFunction)(void *data);
  287. void (*CallbackFunctionForEvent)(gui_message_t *message,void *data);
  288. void (*IDL_Function)(void *data);
  289.  
  290. ////////////////////////////////////////////////////////////////
  291. //                              button
  292. ////////////////////////////////////////////////////////////////
  293. #pragma pack(push,1)
  294. struct ControlButton
  295. {
  296.         DWORD   *ctrl_proc;
  297.         DWORD   *ctrl_fd;
  298.         DWORD   *ctrl_bk;
  299.         DWORD   *child_fd;
  300.         DWORD   *child_bk;
  301.         DWORD   *parent;
  302.         DWORD   *main_parent;
  303.         DWORD   ctrl_x;
  304.         DWORD   ctrl_y;
  305.         DWORD   ctrl_sizex;
  306.         DWORD   ctrl_sizey;
  307.         DWORD   ctrl_ID;
  308.         DWORD   *active_control_for_keys;
  309.         DWORD   *active_control_for_mouse;
  310.         DWORD   *callback;
  311.         DWORD   *finition;
  312.         DWORD   *timer;
  313.         DWORD   flags;
  314.  
  315.         //button's data
  316.         unsigned char   btn_flags;
  317.  
  318. };
  319. #pragma pack(pop)
  320.  
  321. typedef struct ControlButton gui_button_t;
  322. // information for creating control Button
  323. #pragma pack(push,1)
  324. struct ButtonData
  325. {
  326.         int     x;
  327.         int     y;
  328.         int     width;
  329.         int     height;
  330. };
  331. #pragma pack(pop)
  332.  
  333. typedef struct ButtonData gui_button_data_t;
  334. ////////////////////////////////////////////////////////////////
  335. //      scroller
  336. ////////////////////////////////////////////////////////////////
  337. #pragma pack(push,1)
  338. struct ControlScrollBar
  339. {
  340.         DWORD   *ctrl_proc;
  341.         DWORD   *ctrl_fd;
  342.         DWORD   *ctrl_bk;
  343.         DWORD   *child_fd;
  344.         DWORD   *child_bk;
  345.         DWORD   *parent;
  346.         DWORD   *main_parent;
  347.         DWORD   ctrl_x;
  348.         DWORD   ctrl_y;
  349.         DWORD   ctrl_sizex;
  350.         DWORD   ctrl_sizey;
  351.         DWORD   ctrl_ID;
  352.         DWORD   *active_control_for_keys;
  353.         DWORD   *active_control_for_mouse;
  354.         DWORD   *callback;
  355.         DWORD   *finition;
  356.         DWORD   *timer;
  357.         DWORD   flags;
  358.  
  359.         //scroll bar's data
  360.         float   ruller_size;
  361.         float   ruller_pos;
  362.         float   ruller_step;
  363.         unsigned char   scb_flags;
  364. };
  365. #pragma pack(pop)
  366.  
  367. typedef struct ControlScrollBar gui_scroll_bar_t;
  368.  
  369. #pragma pack(push,1)
  370. struct ScrollBarData
  371. {
  372.         int     x;
  373.         int     y;
  374.         int     width;
  375.         int     height;
  376.         float   ruller_size;
  377.         float   ruller_pos;
  378.         float   ruller_step;
  379. };
  380. #pragma pack(pop)
  381.  
  382. typedef struct ScrollBarData gui_scroll_bar_data_t;
  383. ////////////////////////////////////////////////////////////////
  384. //      progressbar
  385. ////////////////////////////////////////////////////////////////
  386. #pragma pack(push,1)
  387. struct ControlProgressBar
  388. {
  389.         DWORD   *ctrl_proc;
  390.         DWORD   *ctrl_fd;
  391.         DWORD   *ctrl_bk;
  392.         DWORD   *child_fd;
  393.         DWORD   *child_bk;
  394.         DWORD   *parent;
  395.         DWORD   *main_parent;
  396.         DWORD   ctrl_x;
  397.         DWORD   ctrl_y;
  398.         DWORD   ctrl_sizex;
  399.         DWORD   ctrl_sizey;
  400.         DWORD   ctrl_ID;
  401.         DWORD   *active_control_for_keys;
  402.         DWORD   *active_control_for_mouse;
  403.         DWORD   *callback;
  404.         DWORD   *finition;
  405.         DWORD   *timer;
  406.         DWORD   flags;
  407.  
  408.         //progress bar's data
  409.         float   progress;
  410.         unsigned char   prb_flags;
  411. };
  412. #pragma pack(pop)
  413.  
  414. typedef struct ControlProgressBar gui_progress_bar_t;
  415.  
  416. #pragma pack(push,1)
  417. struct ProgressBarData
  418. {
  419.         int     x;
  420.         int     y;
  421.         int     width;
  422.         int     height;
  423.         float   progress;
  424. };
  425. #pragma pack(pop)
  426.  
  427. typedef struct ProgressBarData gui_progress_bar_data_t;
  428. ////////////////////////////////////////////////////////////////
  429. //      scrolled window
  430. ////////////////////////////////////////////////////////////////
  431. #pragma pack(push,1)
  432. struct ControlScrolledWindow
  433. {
  434.         DWORD   *ctrl_proc;
  435.         DWORD   *ctrl_fd;
  436.         DWORD   *ctrl_bk;
  437.         DWORD   *child_fd;
  438.         DWORD   *child_bk;
  439.         DWORD   *parent;
  440.         DWORD   *main_parent;
  441.         DWORD   ctrl_x;
  442.         DWORD   ctrl_y;
  443.         DWORD   ctrl_sizex;
  444.         DWORD   ctrl_sizey;
  445.         DWORD   ctrl_ID;
  446.         DWORD   *active_control_for_keys;
  447.         DWORD   *active_control_for_mouse;
  448.         DWORD   *callback;
  449.         DWORD   *finition;
  450.         DWORD   *timer;
  451.         DWORD   flags;
  452.  
  453.         //scrolled windows's data
  454.         DWORD   virtual_x;
  455.         DWORD   virtual_y;
  456.         DWORD   virtual_sizex;
  457.         DWORD   virtual_sizey;
  458.         DWORD   *virtual_controls_x;
  459.         DWORD   *virtual_controls_y;
  460.         DWORD   number_virtual_controls;
  461.         DWORD   scroll_arrea_sizex;
  462.         DWORD   scroll_arrea_sizey;
  463.         DWORD   *horizontal_scroll;
  464.         DWORD   *vertical_scroll;
  465.         unsigned char   scw_flags;
  466. };
  467. #pragma pack(pop)
  468.  
  469. typedef struct ControlScrolledWindow gui_scrolled_window_t;
  470.  
  471. #pragma pack(push,1)
  472. struct ScrolledWindowData
  473. {
  474.         int     x;
  475.         int     y;
  476.         int     width;
  477.         int     height;
  478. };
  479. #pragma pack(pop)
  480.  
  481. typedef struct ScrolledWindowData gui_scrolled_window_data_t;
  482.  
  483. ////////////////////////////////////////////////////////////////
  484. //      image
  485. ////////////////////////////////////////////////////////////////
  486. #pragma pack(push,1)
  487. struct ControlImage
  488. {
  489.         DWORD   *ctrl_proc;
  490.         DWORD   *ctrl_fd;
  491.         DWORD   *ctrl_bk;
  492.         DWORD   *child_fd;
  493.         DWORD   *child_bk;
  494.         DWORD   *parent;
  495.         DWORD   *main_parent;
  496.         DWORD   ctrl_x;
  497.         DWORD   ctrl_y;
  498.         DWORD   ctrl_sizex;
  499.         DWORD   ctrl_sizey;
  500.         DWORD   ctrl_ID;
  501.         DWORD   *active_control_for_keys;
  502.         DWORD   *active_control_for_mouse;
  503.         DWORD   *callback;
  504.         DWORD   *finition;
  505.         DWORD   *timer;
  506.         DWORD   flags;
  507.  
  508.         char    bits_per_pixel;
  509.         char    bytes_per_pixel;
  510.         char    *img;
  511. };
  512. #pragma pack(pop)
  513.  
  514. typedef struct ControlImage gui_image_t;
  515.  
  516. #pragma pack(push,1)
  517. struct ImageData
  518. {
  519.         int     x;
  520.         int     y;
  521.         int     width;
  522.         int     height;
  523.         char    bits_per_pixel;
  524. };
  525. #pragma pack(pop)
  526.  
  527. typedef struct ImageData gui_image_data_t;
  528.  
  529. ////////////////////////////////////////////////////////////////
  530. //      text
  531. ////////////////////////////////////////////////////////////////
  532. #pragma pack(push,1)
  533. struct ControlText
  534. {
  535.         DWORD   *ctrl_proc;
  536.         DWORD   *ctrl_fd;
  537.         DWORD   *ctrl_bk;
  538.         DWORD   *child_fd;
  539.         DWORD   *child_bk;
  540.         DWORD   *parent;
  541.         DWORD   *main_parent;
  542.         DWORD   ctrl_x;
  543.         DWORD   ctrl_y;
  544.         DWORD   ctrl_sizex;
  545.         DWORD   ctrl_sizey;
  546.         DWORD   ctrl_ID;
  547.         DWORD   *active_control_for_keys;
  548.         DWORD   *active_control_for_mouse;
  549.         DWORD   *callback;
  550.         DWORD   *finition;
  551.         DWORD   *timer;
  552.         DWORD   flags;
  553.  
  554.         DWORD   *font; 
  555.         DWORD   color;
  556.         DWORD   background_color;
  557.         char    *text;
  558.         BYTE    txt_flags;
  559. };
  560. #pragma pack(pop)
  561.  
  562. typedef struct ControlText gui_text_t;
  563.  
  564. #pragma pack(push,1)
  565. struct TextData
  566. {
  567.         int     x;
  568.         int     y;
  569.         DWORD   *font; 
  570.         DWORD   color;
  571.         DWORD   background_color;
  572.         char    background;
  573.         char    *text; 
  574. };
  575. #pragma pack(pop)
  576.  
  577. typedef struct TextData gui_text_data_t;
  578. /////////////////////////////////////////////////////////////////////////////
  579. //              prototips of some service functions
  580. /////////////////////////////////////////////////////////////////////////////
  581.  
  582. char    CheckCrossRectangles(int x1,int y1,int sizex1,int sizey1,int x2,int y2,int sizex2,int sizey2);
  583.