Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. #ifndef __CONTROL_H__
  2. #define __CONTROL_H_
  3.  
  4. #include <stdint.h>
  5. #include <pxdraw.h>
  6. #include "link.h"
  7.  
  8. typedef struct font font_t;
  9.  
  10. typedef struct control  ctrl_t;
  11.  
  12. typedef int (handler_t)(ctrl_t*, uint32_t, uint32_t, uint32_t);
  13.  
  14. struct control
  15. {
  16.     link_t     link;
  17.     link_t     child;
  18.  
  19.     handler_t *handler;
  20.     ctrl_t    *parent;
  21.  
  22.     ctx_t     *ctx;
  23.     font_t    *font;
  24.     uint32_t   id;
  25.     uint32_t   style;
  26.  
  27.     rect_t     rc;
  28.     int        w;
  29.     int        h;
  30. };
  31.  
  32. void *create_control(size_t size, int id, int x, int y,
  33.                          int w, int h, ctrl_t *parent);
  34.  
  35. #define  bPressed              2
  36. #define  bHighlight            1
  37.  
  38.  
  39. ctrl_t *create_button(char *caption, uint32_t style, int id, int x, int y,
  40.                       int w, int h, ctrl_t *parent);
  41.  
  42. typedef struct
  43. {
  44.   ctrl_t    ctrl;
  45.  
  46.   uint32_t  state;
  47.  
  48.   int       pix_range;
  49.   int       min_range;
  50.   int       max_range;
  51.   int       page_size;
  52.   int       thumb_pos;
  53.  
  54.   rect_t    tl_rect;
  55.   rect_t    br_rect;
  56.  
  57.   ctrl_t   *btn_up;
  58.   ctrl_t   *btn_down;
  59.   ctrl_t   *thumb;
  60. }scroller_t;
  61.  
  62.  
  63. #define  MSG_SYS_PAINT     0x001
  64. #define  MSG_SYS_KEY       0x002
  65. #define  MSG_SYS_BUTTON    0x003
  66. #define  MSG_SYS_MOUSE     0x006
  67.  
  68. #define  MSG_LBTNDOWN      0x010
  69. #define  MSG_LBTNUP        0x011
  70. #define  MSG_RBTNDOWN      0x012
  71. #define  MSG_RBTNUP        0x013
  72. #define  MSG_MBTNDOWN      0x014
  73. #define  MSG_MBTNUP        0x015
  74. #define  MSG_WHEELDOWN     0x016
  75. #define  MSG_WHEELUP       0x017
  76.  
  77. #define  MSG_LBTNDBLCLK    0x018
  78.  
  79. #define  MSG_MOUSEMOVE     0x019
  80. #define  MSG_MOUSEENTER    0x01A
  81. #define  MSG_MOUSELEAVE    0x01B
  82.  
  83. #define  MSG_CREATE        0x020
  84. #define  MSG_SIZE          0x021
  85. #define  MSG_DRAW          0x022
  86. #define  MSG_OWNERDRAW     0x023
  87. #define  MSG_POSCHANGING   0x024
  88. #define  MSG_POSCHANGE     0x025
  89.  
  90. #define  MSG_COMMAND       0x030
  91.  
  92. static inline int pt_in_rect(rect_t *rc, int x, int y)
  93. {
  94.     if( (x >= rc->l) && (x <  rc->r) &&
  95.         (y >= rc->t) && (y <  rc->b) )
  96.         return 1;
  97.     return 0;
  98. };
  99.  
  100.  
  101. #define  send_message( ctrl, msg, arg1, arg2)                   \
  102.                       (ctrl)->handler( (ctrl_t*)(ctrl),         \
  103.                       (uint32_t)(msg), (uint32_t)(arg1), (uint32_t)(arg2))
  104.  
  105. #define __ALIGN_MASK(x,mask)  (((x)+(mask))&~(mask))
  106. #define ALIGN(x,a)            __ALIGN_MASK(x,(typeof(x))(a)-1)
  107.  
  108.  
  109. #endif /* __CONTROL_H_ */
  110.