Subversion Repositories Kolibri OS

Rev

Rev 3068 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2693 Serge 1
#ifndef __CONTROL_H__
2
#define __CONTROL_H_
3
 
3248 Serge 4
#include 
2693 Serge 5
#include "link.h"
6
 
7
typedef struct
8
{
9
  int  l;
10
  int  t;
11
  int  r;
12
  int  b;
13
}rect_t;
14
 
15
typedef struct ctx
16
{
3248 Serge 17
  bitmap_t *pixmap;
2693 Serge 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
{
3068 serge 57
    ctrl_t  ctrl;
2693 Serge 58
 
59
    uint32_t     state;
60
    ostimer_t    timer;
61
 
62
    char        *caption;
63
    int          capt_len;
64
 
65
    void        *img_default;
66
    void        *img_hilite;
67
    void        *img_pressed;
68
}button_t;
69
 
70
typedef struct
71
{
72
    ctrl_t  ctrl;
73
    float   min;
74
    float   max;
75
    float   current;
76
    int     pos;
77
}progress_t;
78
 
79
typedef struct
80
{
3068 serge 81
    ctrl_t  ctrl;
82
    int     min;
83
    int     max;
84
    int     current;
85
    int     pos;
86
    int     vol;
87
    int     visible;
88
    void    *img_level;
89
}level_t;
90
 
91
typedef struct
92
{
93
    ctrl_t  ctrl;
94
    int     min;
95
    int     max;
96
    int     current;
97
    int     pos;
98
    int     mode;
99
    void    *img_slider;
100
    void    *img_vol_slider;
101
}slider_t;
102
 
103
typedef struct
104
{
2693 Serge 105
    link_t       link;
106
    link_t       child;
107
 
108
    handler_t   *handler;
109
    ctrl_t      *parent;
110
 
111
    ctx_t       *ctx;
112
    uint32_t     id;
113
    uint32_t     style;
114
 
115
    rect_t       rc;
116
    int          w;
117
    int          h;
118
 
119
    uint32_t     state;
120
 
121
    int          pix_range;
122
 
123
    int          min_range;
124
    int          max_range;
125
    int          page_size;
126
    int          thumb_pos;
127
 
128
    rect_t       tl_rect;
129
    rect_t       br_rect;
130
 
131
    button_t    *btn_up;
132
    button_t    *btn_down;
133
    button_t    *thumb;
134
}scroller_t;
135
 
136
#define  bPressed              2
137
#define  bHighlight            1
138
 
139
#define  MSG_PAINT         0x001
140
 
141
#define  MSG_DRAW_CLIENT   0x004
142
 
143
#define  MSG_LBTNDOWN      0x010
144
#define  MSG_LBTNUP        0x011
145
#define  MSG_RBTNDOWN      0x012
146
#define  MSG_RBTNUP        0x013
147
#define  MSG_MBTNDOWN      0x014
148
#define  MSG_MBTNUP        0x015
149
#define  MSG_WHEELDOWN     0x016
150
#define  MSG_WHEELUP       0x017
151
 
152
#define  MSG_LBTNDBLCLK    0x018
153
 
154
#define  MSG_MOUSEMOVE     0x019
155
#define  MSG_MOUSEENTER    0x01A
156
#define  MSG_MOUSELEAVE    0x01B
157
 
158
#define  MSG_SIZE          0x020
159
 
160
#define  MSG_COMMAND       0x030
161
#define  MSG_TIMER         0x031
162
 
163
#define  LBN_DBLCLK        0x100
164
#define  LBOX_READDIR      0x100
165
#define  LBOX_GETFILENAME  0x101
166
 
3068 serge 167
#define  PRG_PROGRESS      0x102
2693 Serge 168
 
3068 serge 169
#define  ID_CLOSE              1
170
#define  ID_MINIMIZE           2
2693 Serge 171
 
3068 serge 172
#define  ID_SCROLLER_UP       10
173
#define  ID_SCROLLER_DOWN     11
174
#define  ID_SCROLLER_THUMB    12
175
 
2693 Serge 176
#define  send_message( ctrl, msg, arg1, arg2)              \
177
                (ctrl)->handler( (ctrl_t*)(ctrl),          \
178
                (uint32_t)(msg), (uint32_t)(arg1), (uint32_t)(arg2))
179
 
180
static inline handler_t *subclass_control(ctrl_t *ctrl, handler_t *handler)
181
{
182
    handler_t *old = ctrl->handler;
183
    ctrl->handler = handler;
184
    return old;
185
};
186
 
187
//int inline send_message(ctrl_t *ctrl, u32_t msg, u32_t arg1, u32_t arg2)
188
//{
189
//  return ctrl->handler(ctrl, msg, arg1, arg2);
190
//};
191
 
192
static inline int pt_in_rect(rect_t *rc, int x, int y)
193
{
194
    if( (x >= rc->l) && (x <  rc->r) &&
195
        (y >= rc->t) && (y <  rc->b) )
196
        return 1;
197
    return 0;
198
};
199
 
200
ctrl_t *get_child(ctrl_t *ctrl, int x, int y);
201
 
202
ctrl_t *capture_mouse(ctrl_t *newm);
203
 
3248 Serge 204
void blit_raw(ctx_t *ctx, void *raw, int x, int y, int w, int h, int pitch);
205
 
206
#define __ALIGN_MASK(x,mask)  (((x)+(mask))&~(mask))
207
#define ALIGN(x,a)            __ALIGN_MASK(x,(typeof(x))(a)-1)
208
 
209
 
2693 Serge 210
#endif