Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef __CONTROL_H__
  2. #define __CONTROL_H_
  3.  
  4. #include "link.h"
  5.  
  6. typedef struct
  7. {
  8.   int  l;
  9.   int  t;
  10.   int  r;
  11.   int  b;
  12. }rect_t;
  13.  
  14. typedef struct ctx
  15. {
  16.   void    *pixmap;
  17.   int      stride;
  18.   int      offset_x;
  19.   int      offset_y;
  20. }ctx_t;
  21.  
  22. ctx_t *get_window_ctx();
  23.  
  24. typedef struct tag_control  ctrl_t;
  25.  
  26. typedef int (handler_t)(ctrl_t*, uint32_t, uint32_t, uint32_t);
  27.  
  28. struct tag_control
  29. {
  30.     link_t     link;
  31.     link_t     child;
  32.  
  33.     handler_t *handler;
  34.     ctrl_t    *parent;
  35.  
  36.     ctx_t     *ctx;
  37.     uint32_t   id;
  38.     uint32_t   style;
  39.  
  40.     rect_t     rc;
  41.     int        w;
  42.     int        h;
  43. };
  44.  
  45.  
  46. typedef struct timer
  47. {
  48.     link_t       link;
  49.     ctrl_t      *ctrl;
  50.     uint32_t     exp_time;            /* expiration time               */
  51.     uint32_t     tmr_arg;             /* random argument               */
  52. } ostimer_t;
  53.  
  54.  
  55. typedef struct
  56. {
  57.     link_t       link;
  58.     link_t       child;
  59.  
  60.     handler_t   *handler;
  61.     ctrl_t      *parent;
  62.  
  63.     ctx_t       *ctx;
  64.     uint32_t     id;
  65.     uint32_t     style;
  66.  
  67.     rect_t       rc;
  68.     int          w;
  69.     int          h;
  70.  
  71.     uint32_t     state;
  72.     ostimer_t    timer;
  73.  
  74.     char        *caption;
  75.     int          capt_len;
  76.  
  77.     void        *img_default;
  78.     void        *img_hilite;
  79.     void        *img_pressed;
  80. }button_t;
  81.  
  82. typedef struct
  83. {
  84.     ctrl_t  ctrl;
  85.     float   min;
  86.     float   max;
  87.     float   current;
  88.     int     pos;
  89. }progress_t;
  90.  
  91. typedef struct
  92. {
  93.     link_t       link;
  94.     link_t       child;
  95.  
  96.     handler_t   *handler;
  97.     ctrl_t      *parent;
  98.  
  99.     ctx_t       *ctx;
  100.     uint32_t     id;
  101.     uint32_t     style;
  102.  
  103.     rect_t       rc;
  104.     int          w;
  105.     int          h;
  106.  
  107.     uint32_t     state;
  108.  
  109.     int          pix_range;
  110.  
  111.     int          min_range;
  112.     int          max_range;
  113.     int          page_size;
  114.     int          thumb_pos;
  115.  
  116.     rect_t       tl_rect;
  117.     rect_t       br_rect;
  118.  
  119.     button_t    *btn_up;
  120.     button_t    *btn_down;
  121.     button_t    *thumb;
  122. }scroller_t;
  123.  
  124. #define  bPressed              2
  125. #define  bHighlight            1
  126.  
  127. #define  MSG_PAINT         0x001
  128.  
  129. #define  MSG_DRAW_CLIENT   0x004
  130.  
  131. #define  MSG_LBTNDOWN      0x010
  132. #define  MSG_LBTNUP        0x011
  133. #define  MSG_RBTNDOWN      0x012
  134. #define  MSG_RBTNUP        0x013
  135. #define  MSG_MBTNDOWN      0x014
  136. #define  MSG_MBTNUP        0x015
  137. #define  MSG_WHEELDOWN     0x016
  138. #define  MSG_WHEELUP       0x017
  139.  
  140. #define  MSG_LBTNDBLCLK    0x018
  141.  
  142. #define  MSG_MOUSEMOVE     0x019
  143. #define  MSG_MOUSEENTER    0x01A
  144. #define  MSG_MOUSELEAVE    0x01B
  145.  
  146. #define  MSG_SIZE          0x020
  147.  
  148. #define  MSG_COMMAND       0x030
  149. #define  MSG_TIMER         0x031
  150.  
  151.  
  152. #define  LBN_DBLCLK        0x100
  153. #define  LBOX_READDIR      0x100
  154. #define  LBOX_GETFILENAME  0x101
  155.  
  156. #define ID_CLOSE              1
  157. #define ID_MINIMIZE           2
  158.  
  159. #define ID_SCROLLER_UP       10
  160. #define ID_SCROLLER_DOWN     11
  161. #define ID_SCROLLER_THUMB    12
  162.  
  163. #define  send_message( ctrl, msg, arg1, arg2)              \
  164.                 (ctrl)->handler( (ctrl_t*)(ctrl),          \
  165.                 (uint32_t)(msg), (uint32_t)(arg1), (uint32_t)(arg2))
  166.  
  167. static inline handler_t *subclass_control(ctrl_t *ctrl, handler_t *handler)
  168. {
  169.     handler_t *old = ctrl->handler;
  170.     ctrl->handler = handler;
  171.     return old;
  172. };
  173.  
  174. //int inline send_message(ctrl_t *ctrl, u32_t msg, u32_t arg1, u32_t arg2)
  175. //{
  176. //  return ctrl->handler(ctrl, msg, arg1, arg2);
  177. //};
  178.  
  179. static inline int pt_in_rect(rect_t *rc, int x, int y)
  180. {
  181.     if( (x >= rc->l) && (x <  rc->r) &&
  182.         (y >= rc->t) && (y <  rc->b) )
  183.         return 1;
  184.     return 0;
  185. };
  186.  
  187. ctrl_t *get_child(ctrl_t *ctrl, int x, int y);
  188.  
  189. ctrl_t *capture_mouse(ctrl_t *newm);
  190.  
  191. #endif
  192.